2 * @file purple-plugin.c
6 * Copyright (C) 2010-11 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
32 #include "sipe-common.h"
34 /* Flag needed for correct version of PURPLE_INIT_PLUGIN() */
35 #ifndef PURPLE_PLUGINS
36 #define PURPLE_PLUGINS
40 * as it's determined on runtime, as Pidgin installation can be anywhere.
43 #include "win32/win32dep.h"
46 #include "accountopt.h"
48 #include "connection.h"
59 * NOTE: Currently PURPLE_VERSION_CHECK(2,y,z) returns FALSE for libpurple >= 3.0.0.
60 * See also <http://developer.pidgin.im/ticket/14551>
62 * As a workaround an additional PURPLE_VERSION_CHECK(3,0,0) needs to be added.
66 #include "sipe-backend.h"
67 #include "sipe-core.h"
70 #include "core-depurple.h"
72 #define _PurpleMessageFlags PurpleMessageFlags
73 #include "purple-private.h"
75 /* Backward compatibility when compiling against 2.4.x API */
76 #if !PURPLE_VERSION_CHECK(2,5,0) && !PURPLE_VERSION_CHECK(3,0,0)
77 #define PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY 0x0100
80 /* Convenience macros */
81 #define PURPLE_BUDDY_TO_SIPE_CORE_PUBLIC ((struct sipe_core_public *) buddy->account->gc->proto_data)
83 /* Status attributes (see also sipe_status_types() */
84 #define SIPE_STATUS_ATTR_ID_MESSAGE "message"
86 /* Sipe core activity <-> Purple status mapping */
87 static const gchar
* const activity_to_purple
[SIPE_ACTIVITY_NUM_TYPES
] = {
88 /* SIPE_ACTIVITY_UNSET */ "unset",
89 /* SIPE_ACTIVITY_ONLINE */ "online",
90 /* SIPE_ACTIVITY_INACTIVE */ "idle",
91 /* SIPE_ACTIVITY_BUSY */ "busy",
92 /* SIPE_ACTIVITY_BUSYIDLE */ "busyidle",
93 /* SIPE_ACTIVITY_DND */ "do-not-disturb",
94 /* SIPE_ACTIVITY_BRB */ "be-right-back",
95 /* SIPE_ACTIVITY_AWAY */ "away",
96 /* SIPE_ACTIVITY_LUNCH */ "out-to-lunch",
97 /* SIPE_ACTIVITY_OFFLINE */ "offline",
98 /* SIPE_ACTIVITY_ON_PHONE */ "on-the-phone",
99 /* SIPE_ACTIVITY_IN_CONF */ "in-a-conference",
100 /* SIPE_ACTIVITY_IN_MEETING */ "in-a-meeting",
101 /* SIPE_ACTIVITY_OOF */ "out-of-office",
102 /* SIPE_ACTIVITY_URGENT_ONLY */ "urgent-interruptions-only",
104 GHashTable
*purple_to_activity
= NULL
;
105 #define PURPLE_STATUS_TO_ACTIVITY(x) \
106 GPOINTER_TO_UINT(g_hash_table_lookup(purple_to_activity, (x)))
108 static void sipe_purple_activity_init(void)
110 sipe_activity index
= SIPE_ACTIVITY_UNSET
;
111 purple_to_activity
= g_hash_table_new(g_str_hash
, g_str_equal
);
112 while (index
< SIPE_ACTIVITY_NUM_TYPES
) {
113 g_hash_table_insert(purple_to_activity
,
114 (gpointer
) activity_to_purple
[index
],
115 GUINT_TO_POINTER(index
));
120 gchar
*sipe_backend_version(void)
122 return(g_strdup_printf("Purple/%s", purple_core_get_version()));
125 static void sipe_purple_activity_destroy(void)
127 g_hash_table_destroy(purple_to_activity
);
128 purple_to_activity
= NULL
;
131 /* PurplePluginProtocolInfo function calls & data structure */
132 static const char *sipe_list_icon(SIPE_UNUSED_PARAMETER PurpleAccount
*a
,
133 SIPE_UNUSED_PARAMETER PurpleBuddy
*b
)
138 static gchar
*sipe_purple_status_text(PurpleBuddy
*buddy
)
140 const PurpleStatus
*status
= purple_presence_get_active_status(purple_buddy_get_presence(buddy
));
141 return sipe_core_buddy_status(PURPLE_BUDDY_TO_SIPE_CORE_PUBLIC
,
143 PURPLE_STATUS_TO_ACTIVITY(purple_status_get_id(status
)),
144 purple_status_get_name(status
));
147 static void sipe_purple_tooltip_text(PurpleBuddy
*buddy
,
148 PurpleNotifyUserInfo
*user_info
,
149 SIPE_UNUSED_PARAMETER gboolean full
)
151 const PurplePresence
*presence
= purple_buddy_get_presence(buddy
);
152 GSList
*info
= sipe_core_buddy_info(PURPLE_BUDDY_TO_SIPE_CORE_PUBLIC
,
154 purple_status_get_name(purple_presence_get_active_status(presence
)),
155 purple_presence_is_online(presence
));
158 struct sipe_buddy_info
*sbi
= info
->data
;
159 #if PURPLE_VERSION_CHECK(3,0,0)
160 purple_notify_user_info_add_pair_html(
162 purple_notify_user_info_add_pair(
165 sbi
->label
, sbi
->text
);
168 info
= g_slist_delete_link(info
, info
);
172 static GList
*sipe_purple_status_types(SIPE_UNUSED_PARAMETER PurpleAccount
*acc
)
174 PurpleStatusType
*type
;
177 /* Macros to reduce code repetition.
179 #define SIPE_ADD_STATUS(prim,id,name,user) type = purple_status_type_new_with_attrs( \
182 SIPE_STATUS_ATTR_ID_MESSAGE, _("Message"), purple_value_new(PURPLE_TYPE_STRING), \
184 types = g_list_append(types, type);
187 SIPE_ADD_STATUS(PURPLE_STATUS_AVAILABLE
,
193 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE
,
194 activity_to_purple
[SIPE_ACTIVITY_BUSY
],
199 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE
,
200 activity_to_purple
[SIPE_ACTIVITY_DND
],
205 /* Goes first in the list as
206 * purple picks the first status with the AWAY type
209 SIPE_ADD_STATUS(PURPLE_STATUS_AWAY
,
215 SIPE_ADD_STATUS(PURPLE_STATUS_AWAY
,
216 activity_to_purple
[SIPE_ACTIVITY_BRB
],
221 SIPE_ADD_STATUS(PURPLE_STATUS_INVISIBLE
,
227 type
= purple_status_type_new(PURPLE_STATUS_OFFLINE
,
231 types
= g_list_append(types
, type
);
236 static GList
*sipe_purple_blist_node_menu(PurpleBlistNode
*node
)
238 if(PURPLE_BLIST_NODE_IS_BUDDY(node
)) {
239 return sipe_buddy_menu((PurpleBuddy
*) node
);
240 } else if(PURPLE_BLIST_NODE_IS_CHAT(node
)) {
241 return sipe_purple_chat_menu((PurpleChat
*)node
);
247 static void sipe_purple_login(PurpleAccount
*account
)
249 PurpleConnection
*gc
= purple_account_get_connection(account
);
250 const gchar
*username
= purple_account_get_username(account
);
251 const gchar
*email
= purple_account_get_string(account
, "email", NULL
);
252 const gchar
*email_url
= purple_account_get_string(account
, "email_url", NULL
);
253 const gchar
*transport
= purple_account_get_string(account
, "transport", "auto");
254 struct sipe_core_public
*sipe_public
;
255 gchar
**username_split
;
256 gchar
*login_domain
= NULL
;
257 gchar
*login_account
= NULL
;
260 struct sipe_backend_private
*purple_private
;
262 /* username format: <username>,[<optional login>] */
263 SIPE_DEBUG_INFO("sipe_purple_login: username '%s'", username
);
264 username_split
= g_strsplit(username
, ",", 2);
266 /* login name specified? */
267 if (username_split
[1] && strlen(username_split
[1])) {
268 /* Allowed domain-account separators are / or \ */
269 gchar
**domain_user
= g_strsplit_set(username_split
[1], "/\\", 2);
270 gboolean has_domain
= domain_user
[1] != NULL
;
271 SIPE_DEBUG_INFO("sipe_purple_login: login '%s'", username_split
[1]);
272 login_domain
= has_domain
? g_strdup(domain_user
[0]) : NULL
;
273 login_account
= g_strdup(domain_user
[has_domain
? 1 : 0]);
274 SIPE_DEBUG_INFO("sipe_purple_login: auth domain '%s' user '%s'",
275 login_domain
? login_domain
: "",
277 g_strfreev(domain_user
);
280 sipe_public
= sipe_core_allocate(username_split
[0],
281 login_domain
, login_account
,
282 purple_connection_get_password(gc
),
286 g_free(login_domain
);
287 g_free(login_account
);
288 g_strfreev(username_split
);
291 #if PURPLE_VERSION_CHECK(3,0,0)
292 purple_connection_error(
294 purple_connection_error_reason(
297 PURPLE_CONNECTION_ERROR_INVALID_USERNAME
,
302 sipe_public
->backend_private
= purple_private
= g_new0(struct sipe_backend_private
, 1);
303 purple_private
->public = sipe_public
;
304 purple_private
->gc
= gc
;
305 purple_private
->account
= account
;
307 sipe_purple_chat_setup_rejoin(purple_private
);
310 if (purple_account_get_bool(account
, "krb5", FALSE
))
311 SIPE_CORE_FLAG_SET(KRB5
);
313 /* @TODO: is this correct?
314 "sso" is only available when Kerberos support is compiled in */
315 if (purple_account_get_bool(account
, "sso", TRUE
))
316 SIPE_CORE_FLAG_SET(SSO
);
318 gc
->proto_data
= sipe_public
;
319 sipe_purple_setup(sipe_public
, gc
);
320 gc
->flags
|= PURPLE_CONNECTION_HTML
| PURPLE_CONNECTION_FORMATTING_WBFO
| PURPLE_CONNECTION_NO_BGCOLOR
|
321 PURPLE_CONNECTION_NO_FONTSIZE
| PURPLE_CONNECTION_NO_URLDESC
| PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY
;
322 purple_connection_set_display_name(gc
, sipe_public
->sip_name
);
323 purple_connection_update_progress(gc
, _("Connecting"), 1, 2);
325 username_split
= g_strsplit(purple_account_get_string(account
, "server", ""), ":", 2);
326 if (sipe_strequal(transport
, "auto")) {
327 type
= (username_split
[0] == NULL
) ?
328 SIPE_TRANSPORT_AUTO
: SIPE_TRANSPORT_TLS
;
329 } else if (sipe_strequal(transport
, "tls")) {
330 type
= SIPE_TRANSPORT_TLS
;
332 type
= SIPE_TRANSPORT_TCP
;
334 sipe_core_transport_sip_connect(sipe_public
,
337 username_split
[0] ? username_split
[1] : NULL
);
338 g_strfreev(username_split
);
341 static void sipe_purple_close(PurpleConnection
*gc
)
343 struct sipe_core_public
*sipe_public
= PURPLE_GC_TO_SIPE_CORE_PUBLIC
;
346 struct sipe_backend_private
*purple_private
= sipe_public
->backend_private
;
348 sipe_core_deallocate(sipe_public
);
350 if (purple_private
->roomlist_map
)
351 g_hash_table_destroy(purple_private
->roomlist_map
);
352 sipe_purple_chat_destroy_rejoin(purple_private
);
353 g_free(purple_private
);
354 gc
->proto_data
= NULL
;
358 static int sipe_purple_send_im(PurpleConnection
*gc
,
361 SIPE_UNUSED_PARAMETER PurpleMessageFlags flags
)
363 sipe_core_im_send(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, who
, what
);
367 #define SIPE_TYPING_SEND_TIMEOUT 4
369 static unsigned int sipe_purple_send_typing(PurpleConnection
*gc
,
371 PurpleTypingState state
)
373 if (state
== PURPLE_NOT_TYPING
)
376 sipe_core_user_feedback_typing(PURPLE_GC_TO_SIPE_CORE_PUBLIC
,
379 return SIPE_TYPING_SEND_TIMEOUT
;
382 static void sipe_purple_add_permit(PurpleConnection
*gc
, const char *name
)
384 sipe_core_contact_allow_deny(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, name
, TRUE
);
387 static void sipe_purple_add_deny(PurpleConnection
*gc
, const char *name
)
389 sipe_core_contact_allow_deny(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, name
, FALSE
);
392 static void sipe_purple_keep_alive(PurpleConnection
*gc
)
394 struct sipe_core_public
*sipe_public
= PURPLE_GC_TO_SIPE_CORE_PUBLIC
;
395 struct sipe_backend_private
*purple_private
= sipe_public
->backend_private
;
396 time_t now
= time(NULL
);
398 if ((sipe_public
->keepalive_timeout
> 0) &&
399 ((guint
) (now
- purple_private
->last_keepalive
) >= sipe_public
->keepalive_timeout
) &&
400 ((guint
) (now
- gc
->last_received
) >= sipe_public
->keepalive_timeout
)
402 sipe_core_transport_sip_keepalive(sipe_public
);
403 purple_private
->last_keepalive
= now
;
407 static void sipe_purple_alias_buddy(PurpleConnection
*gc
, const char *name
,
408 SIPE_UNUSED_PARAMETER
const char *alias
)
410 sipe_core_group_set_user(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, name
);
413 static void sipe_purple_group_rename(PurpleConnection
*gc
,
414 const char *old_name
,
416 SIPE_UNUSED_PARAMETER GList
*moved_buddies
)
418 sipe_core_group_rename(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, old_name
, group
->name
);
421 static void sipe_purple_group_remove(PurpleConnection
*gc
, PurpleGroup
*group
)
423 sipe_core_group_remove(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, group
->name
);
426 #if PURPLE_VERSION_CHECK(2,5,0) || PURPLE_VERSION_CHECK(3,0,0)
428 sipe_purple_get_account_text_table(SIPE_UNUSED_PARAMETER PurpleAccount
*account
)
431 table
= g_hash_table_new(g_str_hash
, g_str_equal
);
432 g_hash_table_insert(table
, "login_label", (gpointer
)_("user@company.com"));
436 #if PURPLE_VERSION_CHECK(2,6,0) || PURPLE_VERSION_CHECK(3,0,0)
439 extern void capture_pipeline(gchar
*label
);
442 sipe_purple_sigusr1_handler(SIPE_UNUSED_PARAMETER
int signum
)
444 capture_pipeline("PURPLE_SIPE_PIPELINE");
447 static gboolean
sipe_purple_initiate_media(PurpleAccount
*account
, const char *who
,
448 SIPE_UNUSED_PARAMETER PurpleMediaSessionType type
)
450 sipe_core_media_initiate_call(PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC
,
452 (type
& PURPLE_MEDIA_VIDEO
));
456 static PurpleMediaCaps
sipe_purple_get_media_caps(SIPE_UNUSED_PARAMETER PurpleAccount
*account
,
457 SIPE_UNUSED_PARAMETER
const char *who
)
459 return PURPLE_MEDIA_CAPS_AUDIO
460 | PURPLE_MEDIA_CAPS_AUDIO_VIDEO
461 | PURPLE_MEDIA_CAPS_MODIFY_SESSION
;
468 * Simplistic source upward compatibility path for newer libpurple APIs
470 * Usually we compile with -Werror=missing-field-initializers if GCC supports
471 * it. But that means that the compilation of this structure can fail if the
472 * newer API has added additional plugin callbacks. For the benefit of the
473 * user we downgrade it to a warning here.
475 * Diagnostic #pragma was added in GCC 4.2.0
476 * Diagnostic push/pop was added in GCC 4.6.0
479 #if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 2)
480 #if __GNUC_MINOR__ >= 6
481 #pragma GCC diagnostic push
483 #pragma GCC diagnostic warning "-Wmissing-field-initializers"
486 static PurplePluginProtocolInfo sipe_prpl_info
=
488 OPT_PROTO_CHAT_TOPIC
,
489 NULL
, /* user_splits */
490 NULL
, /* protocol_options */
491 NO_BUDDY_ICONS
, /* icon_spec */
492 sipe_list_icon
, /* list_icon */
493 NULL
, /* list_emblems */
494 sipe_purple_status_text
, /* status_text */
495 sipe_purple_tooltip_text
, /* tooltip_text */ // add custom info to contact tooltip
496 sipe_purple_status_types
, /* away_states */
497 sipe_purple_blist_node_menu
, /* blist_node_menu */
498 sipe_purple_chat_info
, /* chat_info */
499 sipe_purple_chat_info_defaults
, /* chat_info_defaults */
500 sipe_purple_login
, /* login */
501 sipe_purple_close
, /* close */
502 sipe_purple_send_im
, /* send_im */
503 NULL
, /* set_info */ // TODO maybe
504 sipe_purple_send_typing
, /* send_typing */
505 sipe_get_info
, /* get_info */
506 sipe_set_status
, /* set_status */
507 sipe_set_idle
, /* set_idle */
508 NULL
, /* change_passwd */
509 sipe_add_buddy
, /* add_buddy */
510 NULL
, /* add_buddies */
511 sipe_remove_buddy
, /* remove_buddy */
512 NULL
, /* remove_buddies */
513 sipe_purple_add_permit
, /* add_permit */
514 sipe_purple_add_deny
, /* add_deny */
515 sipe_purple_add_deny
, /* rem_permit */
516 sipe_purple_add_permit
, /* rem_deny */
517 NULL
, /* set_permit_deny */
518 sipe_purple_chat_join
, /* join_chat */
519 NULL
, /* reject_chat */
520 NULL
, /* get_chat_name */
521 sipe_purple_chat_invite
, /* chat_invite */
522 sipe_purple_chat_leave
, /* chat_leave */
523 NULL
, /* chat_whisper */
524 sipe_purple_chat_send
, /* chat_send */
525 sipe_purple_keep_alive
, /* keepalive */
526 NULL
, /* register_user */
527 NULL
, /* get_cb_info */ // deprecated
528 NULL
, /* get_cb_away */ // deprecated
529 sipe_purple_alias_buddy
, /* alias_buddy */
530 sipe_purple_group_buddy
, /* group_buddy */
531 sipe_purple_group_rename
, /* rename_group */
532 NULL
, /* buddy_free */
533 sipe_convo_closed
, /* convo_closed */
534 purple_normalize_nocase
, /* normalize */
535 NULL
, /* set_buddy_icon */
536 sipe_purple_group_remove
, /* remove_group */
537 NULL
, /* get_cb_real_name */ // TODO?
538 NULL
, /* set_chat_topic */
539 NULL
, /* find_blist_chat */
540 sipe_purple_roomlist_get_list
, /* roomlist_get_list */
541 sipe_purple_roomlist_cancel
, /* roomlist_cancel */
542 NULL
, /* roomlist_expand_category */
543 NULL
, /* can_receive_file */
544 sipe_purple_ft_send_file
, /* send_file */
545 sipe_purple_ft_new_xfer
, /* new_xfer */
546 NULL
, /* offline_message */
547 NULL
, /* whiteboard_prpl_ops */
549 NULL
, /* roomlist_room_serialize */
550 NULL
, /* unregister_user */
551 NULL
, /* send_attention */
552 NULL
, /* get_attention_types */
553 #if !PURPLE_VERSION_CHECK(2,5,0) && !PURPLE_VERSION_CHECK(3,0,0)
554 /* Backward compatibility when compiling against 2.4.x API */
555 (void (*)(void)) /* _purple_reserved4 */
557 sizeof(PurplePluginProtocolInfo
), /* struct_size */
558 #if PURPLE_VERSION_CHECK(2,5,0) || PURPLE_VERSION_CHECK(3,0,0)
559 sipe_purple_get_account_text_table
, /* get_account_text_table */
560 #if PURPLE_VERSION_CHECK(2,6,0) || PURPLE_VERSION_CHECK(3,0,0)
562 sipe_purple_initiate_media
, /* initiate_media */
563 sipe_purple_get_media_caps
, /* get_media_caps */
565 NULL
, /* initiate_media */
566 NULL
, /* get_media_caps */
568 #if PURPLE_VERSION_CHECK(2,7,0) || PURPLE_VERSION_CHECK(3,0,0)
569 NULL
, /* get_moods */
570 NULL
, /* set_public_alias */
571 NULL
, /* get_public_alias */
572 #if PURPLE_VERSION_CHECK(2,8,0) || PURPLE_VERSION_CHECK(3,0,0)
573 NULL
, /* add_buddy_with_invite */
574 NULL
, /* add_buddies_with_invite */
581 #if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 6)
582 #pragma GCC diagnostic pop
585 /* Original GCC error checking restored from here on... (see above) */
587 /* PurplePluginInfo function calls & data structure */
588 static gboolean
sipe_purple_plugin_load(SIPE_UNUSED_PARAMETER PurplePlugin
*plugin
)
591 struct sigaction action
;
592 memset(&action
, 0, sizeof (action
));
593 action
.sa_handler
= sipe_purple_sigusr1_handler
;
594 sigaction(SIGUSR1
, &action
, NULL
);
599 static gboolean
sipe_purple_plugin_unload(SIPE_UNUSED_PARAMETER PurplePlugin
*plugin
)
602 struct sigaction action
;
603 memset(&action
, 0, sizeof (action
));
604 action
.sa_handler
= SIG_DFL
;
605 sigaction(SIGUSR1
, &action
, NULL
);
610 static void sipe_purple_plugin_destroy(SIPE_UNUSED_PARAMETER PurplePlugin
*plugin
)
614 sipe_purple_activity_destroy();
617 entry
= sipe_prpl_info
.protocol_options
;
619 purple_account_option_destroy(entry
->data
);
620 entry
= g_list_delete_link(entry
, entry
);
622 sipe_prpl_info
.protocol_options
= NULL
;
624 entry
= sipe_prpl_info
.user_splits
;
626 purple_account_user_split_destroy(entry
->data
);
627 entry
= g_list_delete_link(entry
, entry
);
629 sipe_prpl_info
.user_splits
= NULL
;
632 static void sipe_purple_show_about_plugin(PurplePluginAction
*action
)
634 gchar
*tmp
= sipe_core_about();
635 purple_notify_formatted((PurpleConnection
*) action
->context
,
636 NULL
, " ", NULL
, tmp
, NULL
, NULL
);
640 static void sipe_purple_show_find_contact(PurplePluginAction
*action
)
642 PurpleConnection
*gc
= (PurpleConnection
*) action
->context
;
643 PurpleRequestFields
*fields
;
644 PurpleRequestFieldGroup
*group
;
645 PurpleRequestField
*field
;
647 fields
= purple_request_fields_new();
648 group
= purple_request_field_group_new(NULL
);
649 purple_request_fields_add_group(fields
, group
);
651 field
= purple_request_field_string_new("givenName", _("First name"), NULL
, FALSE
);
652 purple_request_field_group_add_field(group
, field
);
653 field
= purple_request_field_string_new("sn", _("Last name"), NULL
, FALSE
);
654 purple_request_field_group_add_field(group
, field
);
655 field
= purple_request_field_string_new("company", _("Company"), NULL
, FALSE
);
656 purple_request_field_group_add_field(group
, field
);
657 field
= purple_request_field_string_new("c", _("Country"), NULL
, FALSE
);
658 purple_request_field_group_add_field(group
, field
);
660 purple_request_fields(gc
,
662 _("Search for a contact"),
663 _("Enter the information for the person you wish to find. Empty fields will be ignored."),
665 _("_Search"), G_CALLBACK(sipe_search_contact_with_cb
),
667 purple_connection_get_account(gc
), NULL
, NULL
, gc
);
670 static void sipe_purple_join_conference_cb(PurpleConnection
*gc
,
671 PurpleRequestFields
*fields
)
673 GList
*entries
= purple_request_field_group_get_fields(purple_request_fields_get_groups(fields
)->data
);
676 PurpleRequestField
*field
= entries
->data
;
677 const char *id
= purple_request_field_get_id(field
);
678 const char *value
= purple_request_field_string_get_value(field
);
680 if (!sipe_strequal(id
, "meetingLocation"))
683 sipe_core_conf_create(PURPLE_GC_TO_SIPE_CORE_PUBLIC
, value
);
687 static void sipe_purple_show_join_conference(PurplePluginAction
*action
)
689 PurpleConnection
*gc
= (PurpleConnection
*) action
->context
;
690 PurpleRequestFields
*fields
;
691 PurpleRequestFieldGroup
*group
;
692 PurpleRequestField
*field
;
694 fields
= purple_request_fields_new();
695 group
= purple_request_field_group_new(NULL
);
696 purple_request_fields_add_group(fields
, group
);
698 field
= purple_request_field_string_new("meetingLocation", _("Meeting location"), NULL
, FALSE
);
699 purple_request_field_group_add_field(group
, field
);
701 purple_request_fields(gc
,
702 _("Join conference"),
703 _("Join scheduled conference"),
704 _("Enter meeting location string you received in the invitation.\n"
706 "Valid location will be something like\n"
707 "meet:sip:someone@company.com;gruu;opaque=app:conf:focus:id:abcdef1234"),
709 _("_Join"), G_CALLBACK(sipe_purple_join_conference_cb
),
711 purple_connection_get_account(gc
), NULL
, NULL
, gc
);
714 static void sipe_purple_republish_calendar(PurplePluginAction
*action
)
716 PurpleConnection
*gc
= (PurpleConnection
*) action
->context
;
717 sipe_core_update_calendar(PURPLE_GC_TO_SIPE_CORE_PUBLIC
);
720 static void sipe_purple_reset_status(PurplePluginAction
*action
)
722 PurpleConnection
*gc
= (PurpleConnection
*) action
->context
;
723 sipe_core_reset_status(PURPLE_GC_TO_SIPE_CORE_PUBLIC
);
726 static GList
*sipe_purple_actions(SIPE_UNUSED_PARAMETER PurplePlugin
*plugin
,
727 SIPE_UNUSED_PARAMETER gpointer context
)
730 PurplePluginAction
*act
;
732 act
= purple_plugin_action_new(_("About SIPE plugin..."), sipe_purple_show_about_plugin
);
733 menu
= g_list_prepend(menu
, act
);
735 act
= purple_plugin_action_new(_("Contact search..."), sipe_purple_show_find_contact
);
736 menu
= g_list_prepend(menu
, act
);
738 act
= purple_plugin_action_new(_("Join scheduled conference..."), sipe_purple_show_join_conference
);
739 menu
= g_list_prepend(menu
, act
);
741 act
= purple_plugin_action_new(_("Republish Calendar"), sipe_purple_republish_calendar
);
742 menu
= g_list_prepend(menu
, act
);
744 act
= purple_plugin_action_new(_("Reset status"), sipe_purple_reset_status
);
745 menu
= g_list_prepend(menu
, act
);
747 return g_list_reverse(menu
);
750 static PurplePluginInfo sipe_purple_info
= {
752 PURPLE_MAJOR_VERSION
,
753 PURPLE_MINOR_VERSION
,
754 PURPLE_PLUGIN_PROTOCOL
, /**< type */
755 NULL
, /**< ui_requirement */
757 NULL
, /**< dependencies */
758 PURPLE_PRIORITY_DEFAULT
, /**< priority */
759 "prpl-sipe", /**< id */
760 "Office Communicator", /**< name */
761 PACKAGE_VERSION
, /**< version */
762 "Microsoft Office Communicator Protocol Plugin", /**< summary */
763 "A plugin for the extended SIP/SIMPLE protocol used by " /**< description */
764 "Microsoft Live/Office Communications Server (LCS2005/OCS2007+)", /**< description */
765 "Anibal Avelar <avelar@gmail.com>, " /**< author */
766 "Gabriel Burt <gburt@novell.com>, " /**< author */
767 "Stefan Becker <stefan.becker@nokia.com>, " /**< author */
768 "pier11 <pier11@operamail.com>", /**< author */
769 PACKAGE_URL
, /**< homepage */
770 sipe_purple_plugin_load
, /**< load */
771 sipe_purple_plugin_unload
, /**< unload */
772 sipe_purple_plugin_destroy
, /**< destroy */
773 NULL
, /**< ui_info */
774 &sipe_prpl_info
, /**< extra_info */
783 static void sipe_purple_init_plugin(PurplePlugin
*plugin
)
785 PurpleAccountUserSplit
*split
;
786 PurpleAccountOption
*option
;
788 /* This needs to be called first */
789 sipe_core_init(LOCALEDIR
);
790 sipe_purple_activity_init();
792 purple_plugin_register(plugin
);
795 * When adding new string settings please make sure to keep these
799 * purple-settings.c:setting_name[]
801 split
= purple_account_user_split_new(_("Login\n user or DOMAIN\\user or\n user@company.com"), NULL
, ',');
802 purple_account_user_split_set_reverse(split
, FALSE
);
803 sipe_prpl_info
.user_splits
= g_list_append(sipe_prpl_info
.user_splits
, split
);
805 option
= purple_account_option_string_new(_("Server[:Port]\n(leave empty for auto-discovery)"), "server", "");
806 sipe_prpl_info
.protocol_options
= g_list_append(sipe_prpl_info
.protocol_options
, option
);
808 option
= purple_account_option_list_new(_("Connection type"), "transport", NULL
);
809 purple_account_option_add_list_item(option
, _("Auto"), "auto");
810 purple_account_option_add_list_item(option
, _("SSL/TLS"), "tls");
811 purple_account_option_add_list_item(option
, _("TCP"), "tcp");
812 sipe_prpl_info
.protocol_options
= g_list_append(sipe_prpl_info
.protocol_options
, option
);
814 /*option = purple_account_option_bool_new(_("Publish status (note: everyone may watch you)"), "doservice", TRUE);
815 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);*/
817 option
= purple_account_option_string_new(_("User Agent"), "useragent", "");
818 sipe_prpl_info
.protocol_options
= g_list_append(sipe_prpl_info
.protocol_options
, option
);
821 option
= purple_account_option_bool_new(_("Use Kerberos"), "krb5", FALSE
);
822 sipe_prpl_info
.protocol_options
= g_list_append(sipe_prpl_info
.protocol_options
, option
);
824 /* Suitable for sspi/NTLM, sspi/Kerberos and krb5 security mechanisms
825 * No login/password is taken into account if this option present,
826 * instead used default credentials stored in OS.
828 option
= purple_account_option_bool_new(_("Use Single Sign-On"), "sso", TRUE
);
829 sipe_prpl_info
.protocol_options
= g_list_append(sipe_prpl_info
.protocol_options
, option
);
832 /** Example (Exchange): https://server.company.com/EWS/Exchange.asmx
833 * Example (Domino) : https://[domino_server]/[mail_database_name].nsf
835 option
= purple_account_option_string_new(_("Email services URL\n(leave empty for auto-discovery)"), "email_url", "");
836 sipe_prpl_info
.protocol_options
= g_list_append(sipe_prpl_info
.protocol_options
, option
);
838 option
= purple_account_option_string_new(_("Email address\n(if different from Username)"), "email", "");
839 sipe_prpl_info
.protocol_options
= g_list_append(sipe_prpl_info
.protocol_options
, option
);
841 /** Example (Exchange): DOMAIN\user or user@company.com
842 * Example (Domino) : email_address
844 option
= purple_account_option_string_new(_("Email login\n(if different from Login)"), "email_login", "");
845 sipe_prpl_info
.protocol_options
= g_list_append(sipe_prpl_info
.protocol_options
, option
);
847 option
= purple_account_option_string_new(_("Email password\n(if different from Password)"), "email_password", "");
848 purple_account_option_set_masked(option
, TRUE
);
849 sipe_prpl_info
.protocol_options
= g_list_append(sipe_prpl_info
.protocol_options
, option
);
851 /** Example (federated domain): company.com (i.e. ocschat@company.com)
852 * Example (non-default user): user@company.com
854 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", "");
855 sipe_prpl_info
.protocol_options
= g_list_append(sipe_prpl_info
.protocol_options
, option
);
858 /* This macro makes the code a purple plugin */
859 PURPLE_INIT_PLUGIN(sipe
, sipe_purple_init_plugin
, sipe_purple_info
);