2 * @file purple-plugin-common.c
6 * Copyright (C) 2010-2019 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "sipe-common.h"
33 #include "accountopt.h"
39 #if PURPLE_VERSION_CHECK(3,0,0)
41 #define PURPLE_TYPE_STRING G_TYPE_STRING
42 #define SIPE_PURPLE_ACTION_TO_CONNECTION action->connection
45 #define g_source_remove(t) purple_timeout_remove(t)
46 #define PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY
47 #define PURPLE_CONNECTION_FLAG_FORMATTING_WBFO PURPLE_CONNECTION_FORMATTING_WBFO
48 #define PURPLE_CONNECTION_FLAG_HTML PURPLE_CONNECTION_HTML
49 #define PURPLE_CONNECTION_FLAG_NO_BGCOLOR PURPLE_CONNECTION_NO_BGCOLOR
50 #define PURPLE_CONNECTION_FLAG_NO_FONTSIZE PURPLE_CONNECTION_NO_FONTSIZE
51 #define PURPLE_CONNECTION_FLAG_NO_URLDESC PURPLE_CONNECTION_NO_URLDESC
52 #define PURPLE_IS_BUDDY(n) PURPLE_BLIST_NODE_IS_BUDDY(n)
53 #define PURPLE_IS_CHAT(n) PURPLE_BLIST_NODE_IS_CHAT(n)
54 #define PURPLE_IM_TYPING PURPLE_TYPING
55 #define PURPLE_IM_NOT_TYPING PURPLE_NOT_TYPING
56 #define purple_account_option_string_set_masked(o, f) purple_account_option_set_masked(o, f)
57 #define purple_connection_error(g, e, m) purple_connection_error_reason(g, e, m)
58 #define purple_connection_get_flags(gc) 0
59 #define purple_connection_set_protocol_data(gc, p) gc->proto_data = p
60 #define purple_connection_set_flags(gc, f) gc->flags |= f
61 #define purple_protocol_action_new(l, c) purple_plugin_action_new(l, c)
62 #define PurpleProtocolAction PurplePluginAction
63 #define SIPE_PURPLE_ACTION_TO_CONNECTION action->context
66 #include "sipe-backend.h"
67 #include "sipe-core.h"
70 #include "purple-private.h"
73 * NOTE: this flag means two things:
75 * - is Single Sign-On supported, and
76 * - is Kerberos supported
78 #if defined(HAVE_GSSAPI_GSSAPI_H) || defined(HAVE_SSPI)
79 #define PURPLE_SIPE_SSO_AND_KERBEROS 1
81 #define PURPLE_SIPE_SSO_AND_KERBEROS 0
85 * SIPE core activity <-> Purple status mapping
87 * NOTE: this needs to be kept in sync with sipe_purple_status_types()
89 static const gchar
* const activity_to_purple_map
[SIPE_ACTIVITY_NUM_TYPES
] = {
90 /* SIPE_ACTIVITY_UNSET */ "unset", /* == purple_primitive_get_id_from_type(PURPLE_STATUS_UNSET) */
91 /* SIPE_ACTIVITY_AVAILABLE */ "available", /* == purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE) */
92 /* SIPE_ACTIVITY_ONLINE */ "online",
93 /* SIPE_ACTIVITY_INACTIVE */ "idle",
94 /* SIPE_ACTIVITY_BUSY */ "busy",
95 /* SIPE_ACTIVITY_BUSYIDLE */ "busyidle",
96 /* SIPE_ACTIVITY_DND */ "do-not-disturb",
97 /* SIPE_ACTIVITY_BRB */ "be-right-back",
98 /* SIPE_ACTIVITY_AWAY */ "away", /* == purple_primitive_get_id_from_type(PURPLE_STATUS_AWAY) */
99 /* SIPE_ACTIVITY_LUNCH */ "out-to-lunch",
100 /* SIPE_ACTIVITY_INVISIBLE */ "invisible", /* == purple_primitive_get_id_from_type(PURPLE_STATUS_INVISIBLE) */
101 /* SIPE_ACTIVITY_OFFLINE */ "offline", /* == purple_primitive_get_id_from_type(PURPLE_STATUS_OFFLINE) */
102 /* SIPE_ACTIVITY_ON_PHONE */ "on-the-phone",
103 /* SIPE_ACTIVITY_IN_CONF */ "in-a-conference",
104 /* SIPE_ACTIVITY_IN_MEETING */ "in-a-meeting",
105 /* SIPE_ACTIVITY_OOF */ "out-of-office",
106 /* SIPE_ACTIVITY_URGENT_ONLY */ "urgent-interruptions-only",
107 /* SIPE_ACTIVITY_IN_PRES */ "presenting",
108 /* SIPE_ACTIVIY_NUM_TYPES == 18 -> compare to sipe_purple_status_types() */
111 GHashTable
*purple_token_map
;
113 static void sipe_purple_activity_init(void)
117 purple_token_map
= g_hash_table_new(g_str_hash
, g_str_equal
);
118 for (index
= SIPE_ACTIVITY_UNSET
;
119 index
< SIPE_ACTIVITY_NUM_TYPES
;
121 g_hash_table_insert(purple_token_map
,
122 (gchar
*) activity_to_purple_map
[index
],
123 GUINT_TO_POINTER(index
));
127 static void sipe_purple_activity_shutdown(void)
129 g_hash_table_destroy(purple_token_map
);
132 const gchar
*sipe_purple_activity_to_token(guint type
)
134 return(activity_to_purple_map
[type
]);
137 guint
sipe_purple_token_to_activity(const gchar
*token
)
139 return(GPOINTER_TO_UINT(g_hash_table_lookup(purple_token_map
, token
)));
142 gchar
*sipe_backend_version(void)
144 return(g_strdup_printf("Purple/%s", purple_core_get_version()));
147 const char *sipe_purple_list_icon(SIPE_UNUSED_PARAMETER PurpleAccount
*a
,
148 SIPE_UNUSED_PARAMETER PurpleBuddy
*b
)
153 gchar
*sipe_purple_status_text(PurpleBuddy
*buddy
)
155 PurpleStatus
*status
= purple_presence_get_active_status(purple_buddy_get_presence(buddy
));
156 return sipe_core_buddy_status(PURPLE_BUDDY_TO_SIPE_CORE_PUBLIC
,
157 purple_buddy_get_name(buddy
),
158 sipe_purple_token_to_activity(purple_status_get_id(status
)),
159 purple_status_get_name(status
));
162 void sipe_purple_tooltip_text(PurpleBuddy
*buddy
,
163 PurpleNotifyUserInfo
*user_info
,
164 SIPE_UNUSED_PARAMETER gboolean full
)
166 PurplePresence
*presence
= purple_buddy_get_presence(buddy
);
167 sipe_core_buddy_tooltip_info(PURPLE_BUDDY_TO_SIPE_CORE_PUBLIC
,
168 purple_buddy_get_name(buddy
),
169 purple_status_get_name(purple_presence_get_active_status(presence
)),
170 purple_presence_is_online(presence
),
171 (struct sipe_backend_buddy_tooltip
*) user_info
);
174 GList
*sipe_purple_status_types(SIPE_UNUSED_PARAMETER PurpleAccount
*acc
)
176 PurpleStatusType
*type
;
179 /* Macro to reduce code repetition
181 #define SIPE_ADD_STATUS(prim,activity,user) type = purple_status_type_new_with_attrs( \
183 sipe_purple_activity_to_token(activity), \
184 sipe_core_activity_description(activity), \
186 SIPE_PURPLE_STATUS_ATTR_ID_MESSAGE, _("Message"), purple_value_new(PURPLE_TYPE_STRING), \
188 types = g_list_append(types, type);
191 * NOTE: needs to be kept in sync with activity_to_purple_map[],
192 * i.e. for each SIPE_ACTIVITY_xxx value there must be an
193 * entry on this list.
195 * NOTE: the following code is sorted by purple primitive type not
196 * by SIPE_ACTIVITY_xxx value.
199 /* 1: Unset - special case: no entry needed */
202 * Status list entries for primitive type AVAILABLE
205 SIPE_ADD_STATUS(PURPLE_STATUS_AVAILABLE
,
206 SIPE_ACTIVITY_AVAILABLE
,
210 SIPE_ADD_STATUS(PURPLE_STATUS_AVAILABLE
,
211 SIPE_ACTIVITY_ONLINE
,
214 /* 4: Inactive (Idle) */
215 SIPE_ADD_STATUS(PURPLE_STATUS_AVAILABLE
,
216 SIPE_ACTIVITY_INACTIVE
,
220 * Status list entries for primitive type UNAVAILABLE
223 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE
,
228 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE
,
229 SIPE_ACTIVITY_BUSYIDLE
,
232 /* 7: Do Not Disturb */
233 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE
,
238 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE
,
239 SIPE_ACTIVITY_ON_PHONE
,
242 /* 9: In a conference call */
243 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE
,
244 SIPE_ACTIVITY_IN_CONF
,
247 /* 10: In a meeting */
248 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE
,
249 SIPE_ACTIVITY_IN_MEETING
,
252 /* 11: Urgent interruptions only */
253 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE
,
254 SIPE_ACTIVITY_URGENT_ONLY
,
258 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE
,
259 SIPE_ACTIVITY_IN_PRES
,
263 * Status list entries for primitive type AWAY
265 * 12: Away - special case: needs to go first in the list as purple
266 * picks the first status with primitive type AWAY for idle
268 SIPE_ADD_STATUS(PURPLE_STATUS_AWAY
,
272 /* 13: Be Right Back */
273 SIPE_ADD_STATUS(PURPLE_STATUS_AWAY
,
277 /* 14: Out to lunch */
278 SIPE_ADD_STATUS(PURPLE_STATUS_AWAY
,
283 * Status list entries for primitive type EXTENDED_AWAY
285 * 15: Out of office */
286 SIPE_ADD_STATUS(PURPLE_STATUS_EXTENDED_AWAY
,
291 * Status list entries for primitive type INVISIBLE
293 * 16: Appear Offline */
294 SIPE_ADD_STATUS(PURPLE_STATUS_INVISIBLE
,
295 SIPE_ACTIVITY_INVISIBLE
,
299 * Status list entries for primitive type OFFLINE
301 * NOTE: this is always the last entry. Compare the number
302 * with the comment in activity_to_purple_map[].
304 * 17: Offline - special case: no message text */
305 type
= purple_status_type_new(PURPLE_STATUS_OFFLINE
,
309 types
= g_list_append(types
, type
);
314 GList
*sipe_purple_blist_node_menu(PurpleBlistNode
*node
)
316 if (PURPLE_IS_BUDDY(node
))
318 return sipe_purple_buddy_menu((PurpleBuddy
*) node
);
320 if (PURPLE_IS_CHAT(node
))
322 return sipe_purple_chat_menu((PurpleChat
*)node
);
328 static guint
get_authentication_type(PurpleAccount
*account
)
330 const gchar
*auth
= purple_account_get_string(account
, "authentication", "ntlm");
332 /* map option list to type - default is automatic */
333 guint authentication_type
= SIPE_AUTHENTICATION_TYPE_AUTOMATIC
;
334 if (sipe_strequal(auth
, "ntlm")) {
335 authentication_type
= SIPE_AUTHENTICATION_TYPE_NTLM
;
337 #if PURPLE_SIPE_SSO_AND_KERBEROS
338 if (sipe_strequal(auth
, "krb5")) {
339 authentication_type
= SIPE_AUTHENTICATION_TYPE_KERBEROS
;
342 if (sipe_strequal(auth
, "tls-dsk")) {
343 authentication_type
= SIPE_AUTHENTICATION_TYPE_TLS_DSK
;
346 return(authentication_type
);
349 static gboolean
get_sso_flag(PurpleAccount
*account
)
351 #if PURPLE_SIPE_SSO_AND_KERBEROS
353 * NOTE: the default must be *OFF*, i.e. it is up to the user to tell
354 * SIPE that it is OK to use Single Sign-On or not.
356 return(purple_account_get_bool(account
, "sso", FALSE
));
358 (void) account
; /* keep compiler happy */
363 static gboolean
get_dont_publish_flag(PurpleAccount
*account
)
365 /* default is to publish calendar information */
366 return(purple_account_get_bool(account
, "dont-publish", FALSE
));
369 static gboolean
get_allow_web_photo_flag(PurpleAccount
*account
)
371 /* default is to not allow insecure download of buddy icons from web */
372 return purple_account_get_bool(account
, "allow-web-photo", FALSE
);
375 static void connect_to_core(PurpleConnection
*gc
,
376 PurpleAccount
*account
,
377 const gchar
*password
)
379 const gchar
*username
= purple_account_get_username(account
);
380 const gchar
*email
= purple_account_get_string(account
, "email", NULL
);
381 const gchar
*email_url
= purple_account_get_string(account
, "email_url", NULL
);
382 const gchar
*transport
= purple_account_get_string(account
, "transport", "auto");
383 struct sipe_core_public
*sipe_public
;
384 gchar
**username_split
;
386 guint transport_type
;
387 struct sipe_backend_private
*purple_private
;
389 /* username format: <username>,[<optional login>] */
390 SIPE_DEBUG_INFO("sipe_purple_login: username '%s'", username
);
391 username_split
= g_strsplit(username
, ",", 2);
393 sipe_public
= sipe_core_allocate(username_split
[0],
394 get_sso_flag(account
),
400 g_strfreev(username_split
);
403 purple_connection_error(gc
,
404 PURPLE_CONNECTION_ERROR_INVALID_USERNAME
,
409 sipe_public
->backend_private
= purple_private
= g_new0(struct sipe_backend_private
, 1);
410 purple_private
->public = sipe_public
;
411 purple_private
->gc
= gc
;
412 purple_private
->account
= account
;
414 sipe_purple_chat_setup_rejoin(purple_private
);
416 SIPE_CORE_FLAG_UNSET(DONT_PUBLISH
);
417 if (get_dont_publish_flag(account
))
418 SIPE_CORE_FLAG_SET(DONT_PUBLISH
);
419 SIPE_CORE_FLAG_UNSET(ALLOW_WEB_PHOTO
);
420 if (get_allow_web_photo_flag(account
))
421 SIPE_CORE_FLAG_SET(ALLOW_WEB_PHOTO
);
423 purple_connection_set_protocol_data(gc
, sipe_public
);
424 purple_connection_set_flags(gc
,
425 purple_connection_get_flags(gc
) |
426 PURPLE_CONNECTION_FLAG_HTML
|
427 PURPLE_CONNECTION_FLAG_FORMATTING_WBFO
|
428 PURPLE_CONNECTION_FLAG_NO_BGCOLOR
|
429 PURPLE_CONNECTION_FLAG_NO_FONTSIZE
|
430 PURPLE_CONNECTION_FLAG_NO_URLDESC
|
431 PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY
);
432 purple_connection_set_display_name(gc
, sipe_public
->sip_name
);
433 purple_connection_update_progress(gc
, _("Connecting"), 1, 2);
435 username_split
= g_strsplit(purple_account_get_string(account
, "server", ""), ":", 2);
436 if (sipe_strequal(transport
, "auto")) {
437 transport_type
= (username_split
[0] == NULL
) ?
438 SIPE_TRANSPORT_AUTO
: SIPE_TRANSPORT_TLS
;
439 } else if (sipe_strequal(transport
, "tls")) {
440 transport_type
= SIPE_TRANSPORT_TLS
;
442 transport_type
= SIPE_TRANSPORT_TCP
;
444 sipe_core_transport_sip_connect(sipe_public
,
446 get_authentication_type(account
),
448 username_split
[0] ? username_split
[1] : NULL
);
449 g_strfreev(username_split
);
452 static void password_required_cb(PurpleConnection
*gc
,
453 SIPE_UNUSED_PARAMETER PurpleRequestFields
*fields
)
455 #if !PURPLE_VERSION_CHECK(3,0,0)
456 if (!PURPLE_CONNECTION_IS_VALID(gc
)) {
461 purple_connection_error(gc
,
462 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED
,
463 _("Password required"));
466 static void password_ok_cb(PurpleConnection
*gc
,
467 PurpleRequestFields
*fields
)
469 const gchar
*password
;
471 #if !PURPLE_VERSION_CHECK(3,0,0)
472 if (!PURPLE_CONNECTION_IS_VALID(gc
)) {
477 password
= purple_request_fields_get_string(fields
, "password");
479 if (password
&& strlen(password
)) {
480 PurpleAccount
*account
= purple_connection_get_account(gc
);
482 if (purple_request_fields_get_bool(fields
, "remember"))
483 purple_account_set_remember_password(account
, TRUE
);
484 purple_account_set_password(account
, password
485 #if PURPLE_VERSION_CHECK(3,0,0)
490 /* Now we have a password and we can connect */
491 connect_to_core(gc
, account
, password
);
494 /* reject an empty password */
495 password_required_cb(gc
, fields
);
498 void sipe_purple_login(PurpleAccount
*account
)
500 PurpleConnection
*gc
= purple_account_get_connection(account
);
501 const gchar
*password
= purple_connection_get_password(gc
);
503 /* Password required? */
504 if (sipe_core_transport_sip_requires_password(get_authentication_type(account
),
505 get_sso_flag(account
)) &&
506 (!password
|| !strlen(password
)))
507 /* No password set - request one from user */
508 purple_account_request_password(account
,
509 G_CALLBACK(password_ok_cb
),
510 G_CALLBACK(password_required_cb
),
513 /* No password required or saved password - connect now */
514 connect_to_core(gc
, account
, password
);
518 void sipe_purple_close(PurpleConnection
*gc
)
520 struct sipe_core_public
*sipe_public
= PURPLE_GC_TO_SIPE_CORE_PUBLIC
;
523 struct sipe_backend_private
*purple_private
= sipe_public
->backend_private
;
525 sipe_core_deallocate(sipe_public
);
527 /* anything left after that must be in pending state... */
528 sipe_purple_dns_query_cancel_all(purple_private
);
529 sipe_purple_transport_close_all(purple_private
);
531 if (purple_private
->roomlist_map
)
532 g_hash_table_destroy(purple_private
->roomlist_map
);
533 sipe_purple_chat_destroy_rejoin(purple_private
);
535 if (purple_private
->deferred_status_timeout
)
536 g_source_remove(purple_private
->deferred_status_timeout
);
537 g_free(purple_private
->deferred_status_note
);
539 g_free(purple_private
);
540 purple_connection_set_protocol_data(gc
, NULL
);
544 unsigned int sipe_purple_send_typing(PurpleConnection
*gc
,
546 PurpleIMTypingState state
)
548 gboolean typing
= (state
== PURPLE_IM_TYPING
);
550 /* only enable this debug output while testing
551 SIPE_DEBUG_INFO("sipe_purple_send_typing: '%s' state %d", who, state); */
554 * libpurple calls this function with PURPLE_NOT_TYPING *after*
555 * calling sipe_purple_send_im() with the message. This causes
556 * SIPE core to send out two SIP messages to the same dialog in
557 * short succession without waiting for the response to the first
558 * one. Some servers then reject the first one with
560 * SIP/2.0 500 Stale CSeq Value
562 * which triggers a "message not delivered" error for the user.
564 * Work around this by filtering out PURPLE_NOT_TYPING events.
566 if (state
!= PURPLE_IM_NOT_TYPING
)
567 sipe_core_user_feedback_typing(PURPLE_GC_TO_SIPE_CORE_PUBLIC
,
571 /* tell libpurple to send typing indications every 4 seconds */
572 return(typing
? 4 : 0);
575 void sipe_purple_get_info(PurpleConnection
*gc
, const char *who
)
577 sipe_core_buddy_get_info(PURPLE_GC_TO_SIPE_CORE_PUBLIC
,
581 void sipe_purple_add_permit(PurpleConnection
*gc
, const char *name
)
583 sipe_core_contact_allow_deny(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, name
, TRUE
);
586 void sipe_purple_add_deny(PurpleConnection
*gc
, const char *name
)
588 sipe_core_contact_allow_deny(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, name
, FALSE
);
591 void sipe_purple_alias_buddy(PurpleConnection
*gc
, const char *name
,
594 sipe_core_group_set_alias(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, name
, alias
);
597 void sipe_purple_group_rename(PurpleConnection
*gc
, const char *old_name
,
599 SIPE_UNUSED_PARAMETER GList
*moved_buddies
)
601 sipe_core_group_rename(PURPLE_GC_TO_SIPE_CORE_PUBLIC
,
603 purple_group_get_name(group
));
606 void sipe_purple_convo_closed(PurpleConnection
*gc
, const char *who
)
608 sipe_core_im_close(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, who
);
611 void sipe_purple_group_remove(PurpleConnection
*gc
, PurpleGroup
*group
)
613 sipe_core_group_remove(PURPLE_GC_TO_SIPE_CORE_PUBLIC
,
614 purple_group_get_name(group
));
618 sipe_purple_get_account_text_table(SIPE_UNUSED_PARAMETER PurpleAccount
*account
)
621 table
= g_hash_table_new(g_str_hash
, g_str_equal
);
622 g_hash_table_insert(table
, (char *)"login_label", (gpointer
)_("user@company.com"));
629 sipe_purple_sigusr1_handler(SIPE_UNUSED_PARAMETER
int signum
)
631 capture_pipeline("PURPLE_SIPE_PIPELINE");
634 gboolean
sipe_purple_initiate_media(PurpleAccount
*account
, const char *who
,
635 SIPE_UNUSED_PARAMETER PurpleMediaSessionType type
)
637 sipe_core_media_initiate_call(PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC
,
639 (type
& PURPLE_MEDIA_VIDEO
));
643 PurpleMediaCaps
sipe_purple_get_media_caps(SIPE_UNUSED_PARAMETER PurpleAccount
*account
,
644 SIPE_UNUSED_PARAMETER
const char *who
)
646 return PURPLE_MEDIA_CAPS_AUDIO
647 | PURPLE_MEDIA_CAPS_AUDIO_VIDEO
648 | PURPLE_MEDIA_CAPS_MODIFY_SESSION
;
652 /* PurplePluginInfo function calls & data structure */
653 gboolean
sipe_purple_plugin_load(SIPE_UNUSED_PARAMETER PurplePlugin
*plugin
)
657 struct sigaction action
;
658 memset(&action
, 0, sizeof (action
));
659 action
.sa_handler
= sipe_purple_sigusr1_handler
;
660 sigaction(SIGUSR1
, &action
, NULL
);
664 sipe_purple_activity_init();
669 gboolean
sipe_purple_plugin_unload(SIPE_UNUSED_PARAMETER PurplePlugin
*plugin
)
672 struct sigaction action
;
673 memset(&action
, 0, sizeof (action
));
674 action
.sa_handler
= SIG_DFL
;
675 sigaction(SIGUSR1
, &action
, NULL
);
678 sipe_purple_activity_shutdown();
683 static void sipe_purple_show_about_plugin(PurpleProtocolAction
*action
)
685 gchar
*tmp
= sipe_core_about();
686 purple_notify_formatted(SIPE_PURPLE_ACTION_TO_CONNECTION
,
687 NULL
, " ", NULL
, tmp
, NULL
, NULL
);
691 static void sipe_purple_join_conference_cb(PurpleConnection
*gc
,
692 PurpleRequestFields
*fields
)
694 GList
*entries
= purple_request_field_group_get_fields(purple_request_fields_get_groups(fields
)->data
);
697 const gchar
*location
= purple_request_fields_get_string(fields
,
699 const gchar
*organizer
= purple_request_fields_get_string(fields
,
701 const gchar
*meeting_id
= purple_request_fields_get_string(fields
,
703 sipe_core_conf_create(PURPLE_GC_TO_SIPE_CORE_PUBLIC
,
712 static void sipe_purple_phone_call_cb(PurpleConnection
*gc
,
713 PurpleRequestFields
*fields
)
715 GList
*entries
= purple_request_field_group_get_fields(purple_request_fields_get_groups(fields
)->data
);
718 sipe_core_media_phone_call(PURPLE_GC_TO_SIPE_CORE_PUBLIC
,
719 purple_request_fields_get_string(fields
,
723 static void sipe_purple_phone_call(PurpleProtocolAction
*action
)
725 PurpleConnection
*gc
= SIPE_PURPLE_ACTION_TO_CONNECTION
;
726 PurpleRequestFields
*fields
;
727 PurpleRequestFieldGroup
*group
;
728 PurpleRequestField
*field
;
730 fields
= purple_request_fields_new();
731 group
= purple_request_field_group_new(NULL
);
732 purple_request_fields_add_group(fields
, group
);
734 field
= purple_request_field_string_new("phoneNumber", _("Phone number"), NULL
, FALSE
);
735 purple_request_field_group_add_field(group
, field
);
737 purple_request_fields(gc
,
738 _("Call a phone number"),
739 _("Call a phone number"),
742 _("_Call"), G_CALLBACK(sipe_purple_phone_call_cb
),
744 #if PURPLE_VERSION_CHECK(3,0,0)
745 purple_request_cpar_from_connection(gc
),
747 purple_connection_get_account(gc
), NULL
, NULL
,
752 static void sipe_purple_test_call(PurpleProtocolAction
*action
)
754 PurpleConnection
*gc
= SIPE_PURPLE_ACTION_TO_CONNECTION
;
755 sipe_core_media_test_call(PURPLE_GC_TO_SIPE_CORE_PUBLIC
);
759 static void sipe_purple_show_join_conference(PurpleProtocolAction
*action
)
761 PurpleConnection
*gc
= SIPE_PURPLE_ACTION_TO_CONNECTION
;
762 PurpleRequestFields
*fields
;
763 PurpleRequestFieldGroup
*group
;
764 PurpleRequestField
*field
;
766 fields
= purple_request_fields_new();
767 group
= purple_request_field_group_new(NULL
);
768 purple_request_fields_add_group(fields
, group
);
770 field
= purple_request_field_string_new("meetingLocation", _("Meeting location"), NULL
, FALSE
);
771 purple_request_field_group_add_field(group
, field
);
772 field
= purple_request_field_label_new("separator", _("Alternatively"));
773 purple_request_field_group_add_field(group
, field
);
774 field
= purple_request_field_string_new("meetingOrganizer", _("Organizer email"), NULL
, FALSE
);
775 purple_request_field_group_add_field(group
, field
);
776 field
= purple_request_field_string_new("meetingID", _("Meeting ID"), NULL
, FALSE
);
777 purple_request_field_group_add_field(group
, field
);
779 purple_request_fields(gc
,
780 _("Join conference"),
781 _("Join scheduled conference"),
782 _("Enter meeting location string you received in the invitation.\n"
784 "Valid location will be something like\n"
785 "meet:sip:someone@company.com;gruu;opaque=app:conf:focus:id:abcdef1234\n"
786 "conf:sip:someone@company.com;gruu;opaque=app:conf:focus:id:abcdef1234\n"
788 "https://meet.company.com/someone/abcdef1234"),
790 _("_Join"), G_CALLBACK(sipe_purple_join_conference_cb
),
792 #if PURPLE_VERSION_CHECK(3,0,0)
793 purple_request_cpar_from_connection(gc
),
795 purple_connection_get_account(gc
), NULL
, NULL
,
800 void sipe_purple_republish_calendar(PurpleAccount
*account
)
802 struct sipe_core_public
*sipe_public
= PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC
;
803 if (get_dont_publish_flag(account
)) {
804 sipe_backend_notify_error(sipe_public
,
805 _("Publishing of calendar information has been disabled"),
808 sipe_core_update_calendar(sipe_public
);
812 static void sipe_purple_republish_calendar_action(PurpleProtocolAction
*action
)
814 PurpleConnection
*gc
= SIPE_PURPLE_ACTION_TO_CONNECTION
;
815 PurpleAccount
*account
= purple_connection_get_account(gc
);
816 sipe_purple_republish_calendar(account
);
819 void sipe_purple_reset_status(PurpleAccount
*account
)
821 if (get_dont_publish_flag(account
)) {
822 sipe_backend_notify_error(PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC
,
823 _("Publishing of calendar information has been disabled"),
826 sipe_core_reset_status(PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC
);
830 static void sipe_purple_reset_status_action(PurpleProtocolAction
*action
)
832 PurpleConnection
*gc
= SIPE_PURPLE_ACTION_TO_CONNECTION
;
833 PurpleAccount
*account
= purple_connection_get_account(gc
);
834 sipe_purple_reset_status(account
);
837 GList
*sipe_purple_actions()
840 PurpleProtocolAction
*act
;
842 act
= purple_protocol_action_new(_("About SIPE plugin..."), sipe_purple_show_about_plugin
);
843 menu
= g_list_prepend(menu
, act
);
845 act
= purple_protocol_action_new(_("Contact search..."), sipe_purple_show_find_contact
);
846 menu
= g_list_prepend(menu
, act
);
849 act
= purple_protocol_action_new(_("Call a phone number..."), sipe_purple_phone_call
);
850 menu
= g_list_prepend(menu
, act
);
852 act
= purple_protocol_action_new(_("Test call"), sipe_purple_test_call
);
853 menu
= g_list_prepend(menu
, act
);
856 act
= purple_protocol_action_new(_("Join scheduled conference..."), sipe_purple_show_join_conference
);
857 menu
= g_list_prepend(menu
, act
);
859 act
= purple_protocol_action_new(_("Republish Calendar"), sipe_purple_republish_calendar_action
);
860 menu
= g_list_prepend(menu
, act
);
862 act
= purple_protocol_action_new(_("Reset status"), sipe_purple_reset_status_action
);
863 menu
= g_list_prepend(menu
, act
);
865 return g_list_reverse(menu
);
868 GList
* sipe_purple_account_options()
870 PurpleAccountOption
*option
;
871 GList
*options
= NULL
;
874 * When adding new string settings please make sure to keep these
878 * purple-settings.c:setting_name[]
880 option
= purple_account_option_string_new(_("Server[:Port]\n(leave empty for auto-discovery)"), "server", "");
881 options
= g_list_append(options
, option
);
883 option
= purple_account_option_list_new(_("Connection type"), "transport", NULL
);
884 purple_account_option_add_list_item(option
, _("Auto"), "auto");
885 purple_account_option_add_list_item(option
, _("SSL/TLS"), "tls");
886 purple_account_option_add_list_item(option
, _("TCP"), "tcp");
887 options
= g_list_append(options
, option
);
889 /*option = purple_account_option_bool_new(_("Publish status (note: everyone may watch you)"), "doservice", TRUE);
890 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);*/
892 option
= purple_account_option_string_new(_("User Agent"), "useragent", "");
893 options
= g_list_append(options
, option
);
895 option
= purple_account_option_list_new(_("Authentication scheme"), "authentication", NULL
);
896 purple_account_option_add_list_item(option
, _("Auto"), "auto");
897 purple_account_option_add_list_item(option
, _("NTLM"), "ntlm");
898 #if PURPLE_SIPE_SSO_AND_KERBEROS
899 purple_account_option_add_list_item(option
, _("Kerberos"), "krb5");
901 purple_account_option_add_list_item(option
, _("TLS-DSK"), "tls-dsk");
902 options
= g_list_append(options
, option
);
904 #if PURPLE_SIPE_SSO_AND_KERBEROS
906 * When the user selects Single Sign-On then SIPE will ignore the
907 * settings for "login name" and "password". Instead it will use the
908 * default credentials provided by the OS.
910 * NOTE: the default must be *OFF*, i.e. it is up to the user to tell
911 * SIPE that it is OK to use Single Sign-On or not.
913 * Configurations that are known to support Single Sign-On:
915 * - Windows, host joined to domain, SIPE with SSPI: NTLM
916 * - Windows, host joined to domain, SIPE with SSPI: Kerberos
917 * - SIPE with libkrb5, valid TGT in cache (kinit): Kerberos
919 option
= purple_account_option_bool_new(_("Use Single Sign-On"), "sso", FALSE
);
920 options
= g_list_append(options
, option
);
923 /** Example (Exchange): https://server.company.com/EWS/Exchange.asmx
924 * Example (Domino) : https://[domino_server]/[mail_database_name].nsf
926 option
= purple_account_option_bool_new(_("Don't publish my calendar information"), "dont-publish", FALSE
);
927 options
= g_list_append(options
, option
);
929 option
= purple_account_option_bool_new(_("Show profile pictures from web\n(potentially dangerous)"), "allow-web-photo", FALSE
);
930 options
= g_list_append(options
, option
);
932 option
= purple_account_option_string_new(_("Email services URL\n(leave empty for auto-discovery)"), "email_url", "");
933 options
= g_list_append(options
, option
);
935 option
= purple_account_option_string_new(_("Email address\n(if different from Username)"), "email", "");
936 options
= g_list_append(options
, option
);
938 /** Example (Exchange): DOMAIN\user or user@company.com
939 * Example (Domino) : email_address
941 option
= purple_account_option_string_new(_("Email login\n(if different from Login)"), "email_login", "");
942 options
= g_list_append(options
, option
);
944 option
= purple_account_option_string_new(_("Email password\n(if different from Password)"), "email_password", "");
945 purple_account_option_string_set_masked(option
, TRUE
);
946 options
= g_list_append(options
, option
);
948 /** Example (federated domain): company.com (i.e. ocschat@company.com)
949 * Example (non-default user): user@company.com
951 option
= purple_account_option_string_new(_("Group Chat Proxy\n company.com or user@company.com\n(leave empty to determine from Username)"), "groupchat_user", "");
952 options
= g_list_append(options
, option
);
955 option
= purple_account_option_string_new(_("Remote desktop client"), "rdp_client", "");
956 options
= g_list_append(options
, option
);
960 option
= purple_account_option_list_new(_("Media encryption"), "encryption-policy", NULL
);
961 purple_account_option_add_list_item(option
, _("Obey server policy"), "obey-server");
962 purple_account_option_add_list_item(option
, _("Always"), "required");
963 purple_account_option_add_list_item(option
, _("Optional"), "optional");
964 purple_account_option_add_list_item(option
, _("Disabled"), "disabled");
965 options
= g_list_append(options
, option
);
971 gpointer
sipe_purple_user_split()
973 PurpleAccountUserSplit
*split
=
974 purple_account_user_split_new(
975 _("Login\n user or DOMAIN\\user or\n user@company.com"),
977 * pidgin works fine with NULL as default
978 * finch returns string "(null)" for NULL
982 purple_account_user_split_set_reverse(split
, FALSE
);