purple: markup escape text in buddy's tooltip
[siplcs.git] / src / purple / purple-plugin.c
blob122b85db450260a3bcfa7938f4b38dfd61d00aae
1 /**
2 * @file purple-plugin.c
4 * pidgin-sipe
6 * Copyright (C) 2010 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
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
27 #include <string.h>
28 #include <time.h>
30 #include <glib.h>
32 #include "sipe-common.h"
34 /* Flag needed for correct version of PURPLE_INIT_PLUGIN() */
35 #ifndef PURPLE_PLUGINS
36 #define PURPLE_PLUGINS
37 #endif
39 /* for LOCALEDIR
40 * as it's determined on runtime, as Pidgin installation can be anywhere.
42 #ifdef _WIN32
43 #include "win32/win32dep.h"
44 #endif
46 #include "accountopt.h"
47 #include "blist.h"
48 #include "connection.h"
49 #include "core.h"
50 #include "dnssrv.h"
51 #ifdef HAVE_VV
52 #include "media.h"
53 #endif
54 #include "prpl.h"
55 #include "plugin.h"
56 #include "request.h"
57 #include "status.h"
58 #include "version.h"
60 #include "sipe-backend.h"
61 #include "sipe-core.h"
62 #include "sipe-nls.h"
64 #include "core-depurple.h"
66 #define _PurpleMessageFlags PurpleMessageFlags
67 #include "purple-private.h"
69 /* Backward compatibility when compiling against 2.4.x API */
70 #if !PURPLE_VERSION_CHECK(2,5,0)
71 #define PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY 0x0100
72 #endif
74 /* Convenience macros */
75 #define PURPLE_BUDDY_TO_SIPE_CORE_PUBLIC ((struct sipe_core_public *) buddy->account->gc->proto_data)
77 /* Status attributes (see also sipe_status_types() */
78 #define SIPE_STATUS_ATTR_ID_MESSAGE "message"
80 /* Sipe core activity <-> Purple status mapping */
81 static const gchar * const activity_to_purple[SIPE_ACTIVITY_NUM_TYPES] = {
82 /* SIPE_ACTIVITY_UNSET */ "unset",
83 /* SIPE_ACTIVITY_ONLINE */ "online",
84 /* SIPE_ACTIVITY_INACTIVE */ "idle",
85 /* SIPE_ACTIVITY_BUSY */ "busy",
86 /* SIPE_ACTIVITY_BUSYIDLE */ "busyidle",
87 /* SIPE_ACTIVITY_DND */ "do-not-disturb",
88 /* SIPE_ACTIVITY_BRB */ "be-right-back",
89 /* SIPE_ACTIVITY_AWAY */ "away",
90 /* SIPE_ACTIVITY_LUNCH */ "out-to-lunch",
91 /* SIPE_ACTIVITY_OFFLINE */ "offline",
92 /* SIPE_ACTIVITY_ON_PHONE */ "on-the-phone",
93 /* SIPE_ACTIVITY_IN_CONF */ "in-a-conference",
94 /* SIPE_ACTIVITY_IN_MEETING */ "in-a-meeting",
95 /* SIPE_ACTIVITY_OOF */ "out-of-office",
96 /* SIPE_ACTIVITY_URGENT_ONLY */ "urgent-interruptions-only",
98 GHashTable *purple_to_activity = NULL;
99 #define PURPLE_STATUS_TO_ACTIVITY(x) \
100 GPOINTER_TO_UINT(g_hash_table_lookup(purple_to_activity, (x)))
102 static void sipe_purple_activity_init(void)
104 sipe_activity index = SIPE_ACTIVITY_UNSET;
105 purple_to_activity = g_hash_table_new(g_str_hash, g_str_equal);
106 while (index < SIPE_ACTIVITY_NUM_TYPES) {
107 g_hash_table_insert(purple_to_activity,
108 (gpointer) activity_to_purple[index],
109 GUINT_TO_POINTER(index));
110 index++;
114 gchar *sipe_backend_version(void)
116 return(g_strdup_printf("Purple/%s", purple_core_get_version()));
119 static void sipe_purple_activity_destroy(void)
121 g_hash_table_destroy(purple_to_activity);
122 purple_to_activity = NULL;
125 /* PurplePluginProtocolInfo function calls & data structure */
126 static const char *sipe_list_icon(SIPE_UNUSED_PARAMETER PurpleAccount *a,
127 SIPE_UNUSED_PARAMETER PurpleBuddy *b)
129 return "sipe";
132 static gchar *sipe_purple_status_text(PurpleBuddy *buddy)
134 const PurpleStatus *status = purple_presence_get_active_status(purple_buddy_get_presence(buddy));
135 return sipe_core_buddy_status(PURPLE_BUDDY_TO_SIPE_CORE_PUBLIC,
136 buddy->name,
137 PURPLE_STATUS_TO_ACTIVITY(purple_status_get_id(status)),
138 purple_status_get_name(status));
141 static void sipe_purple_tooltip_text(PurpleBuddy *buddy,
142 PurpleNotifyUserInfo *user_info,
143 SIPE_UNUSED_PARAMETER gboolean full)
145 const PurplePresence *presence = purple_buddy_get_presence(buddy);
146 GSList *info = sipe_core_buddy_info(PURPLE_BUDDY_TO_SIPE_CORE_PUBLIC,
147 buddy->name,
148 purple_status_get_name(purple_presence_get_active_status(presence)),
149 purple_presence_is_online(presence));
151 while (info) {
152 struct sipe_buddy_info *sbi = info->data;
153 gchar *label_esc = g_markup_escape_text(sbi->label, -1);
154 gchar *text_esc = g_markup_escape_text(sbi->text, -1);
156 purple_notify_user_info_add_pair(user_info, label_esc, text_esc);
158 g_free(label_esc);
159 g_free(text_esc);
160 g_free(sbi->text);
161 g_free(sbi);
162 info = g_slist_delete_link(info, info);
166 static GList *sipe_purple_status_types(SIPE_UNUSED_PARAMETER PurpleAccount *acc)
168 PurpleStatusType *type;
169 GList *types = NULL;
171 /* Macros to reduce code repetition.
172 Translators: noun */
173 #define SIPE_ADD_STATUS(prim,id,name,user) type = purple_status_type_new_with_attrs( \
174 prim, id, name, \
175 TRUE, user, FALSE, \
176 SIPE_STATUS_ATTR_ID_MESSAGE, _("Message"), purple_value_new(PURPLE_TYPE_STRING), \
177 NULL); \
178 types = g_list_append(types, type);
180 /* Online */
181 SIPE_ADD_STATUS(PURPLE_STATUS_AVAILABLE,
182 NULL,
183 NULL,
184 TRUE);
186 /* Busy */
187 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE,
188 activity_to_purple[SIPE_ACTIVITY_BUSY],
189 _("Busy"),
190 TRUE);
192 /* Do Not Disturb */
193 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE,
194 activity_to_purple[SIPE_ACTIVITY_DND],
195 NULL,
196 TRUE);
198 /* Away */
199 /* Goes first in the list as
200 * purple picks the first status with the AWAY type
201 * for idle.
203 SIPE_ADD_STATUS(PURPLE_STATUS_AWAY,
204 NULL,
205 NULL,
206 TRUE);
208 /* Be Right Back */
209 SIPE_ADD_STATUS(PURPLE_STATUS_AWAY,
210 activity_to_purple[SIPE_ACTIVITY_BRB],
211 _("Be right back"),
212 TRUE);
214 /* Appear Offline */
215 SIPE_ADD_STATUS(PURPLE_STATUS_INVISIBLE,
216 NULL,
217 NULL,
218 TRUE);
220 /* Offline */
221 type = purple_status_type_new(PURPLE_STATUS_OFFLINE,
222 NULL,
223 NULL,
224 TRUE);
225 types = g_list_append(types, type);
227 return types;
230 static GList *sipe_purple_blist_node_menu(PurpleBlistNode *node)
232 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
233 return sipe_buddy_menu((PurpleBuddy *) node);
234 } else if(PURPLE_BLIST_NODE_IS_CHAT(node)) {
235 return sipe_purple_chat_menu((PurpleChat *)node);
236 } else {
237 return NULL;
241 static void sipe_purple_login(PurpleAccount *account)
243 PurpleConnection *gc = purple_account_get_connection(account);
244 const gchar *username = purple_account_get_username(account);
245 const gchar *email = purple_account_get_string(account, "email", NULL);
246 const gchar *email_url = purple_account_get_string(account, "email_url", NULL);
247 const gchar *transport = purple_account_get_string(account, "transport", "auto");
248 struct sipe_core_public *sipe_public;
249 gchar **username_split;
250 gchar *login_domain = NULL;
251 gchar *login_account = NULL;
252 const gchar *errmsg;
253 guint type;
254 struct sipe_backend_private *purple_private;
256 /* username format: <username>,[<optional login>] */
257 SIPE_DEBUG_INFO("sipe_purple_login: username '%s'", username);
258 username_split = g_strsplit(username, ",", 2);
260 /* login name specified? */
261 if (username_split[1] && strlen(username_split[1])) {
262 /* Allowed domain-account separators are / or \ */
263 gchar **domain_user = g_strsplit_set(username_split[1], "/\\", 2);
264 gboolean has_domain = domain_user[1] != NULL;
265 SIPE_DEBUG_INFO("sipe_purple_login: login '%s'", username_split[1]);
266 login_domain = has_domain ? g_strdup(domain_user[0]) : NULL;
267 login_account = g_strdup(domain_user[has_domain ? 1 : 0]);
268 SIPE_DEBUG_INFO("sipe_purple_login: auth domain '%s' user '%s'",
269 login_domain ? login_domain : "",
270 login_account);
271 g_strfreev(domain_user);
274 sipe_public = sipe_core_allocate(username_split[0],
275 login_domain, login_account,
276 purple_connection_get_password(gc),
277 email,
278 email_url,
279 &errmsg);
280 g_free(login_domain);
281 g_free(login_account);
282 g_strfreev(username_split);
284 if (!sipe_public) {
285 purple_connection_error_reason(gc,
286 PURPLE_CONNECTION_ERROR_INVALID_USERNAME,
287 errmsg);
288 return;
291 sipe_public->backend_private = purple_private = g_new0(struct sipe_backend_private, 1);
292 purple_private->public = sipe_public;
293 purple_private->gc = gc;
294 purple_private->account = account;
296 sipe_purple_chat_setup_rejoin(purple_private);
298 #ifdef HAVE_LIBKRB5
299 if (purple_account_get_bool(account, "krb5", FALSE))
300 SIPE_CORE_FLAG_SET(KRB5);
301 #endif
302 /* @TODO: is this correct?
303 "sso" is only available when Kerberos support is compiled in */
304 if (purple_account_get_bool(account, "sso", TRUE))
305 SIPE_CORE_FLAG_SET(SSO);
307 gc->proto_data = sipe_public;
308 sipe_purple_setup(sipe_public, gc);
309 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO | PURPLE_CONNECTION_NO_BGCOLOR |
310 PURPLE_CONNECTION_NO_FONTSIZE | PURPLE_CONNECTION_NO_URLDESC | PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY;
311 purple_connection_set_display_name(gc, sipe_public->sip_name);
312 purple_connection_update_progress(gc, _("Connecting"), 1, 2);
314 username_split = g_strsplit(purple_account_get_string(account, "server", ""), ":", 2);
315 if (sipe_strequal(transport, "auto")) {
316 type = (username_split[0] == NULL) ?
317 SIPE_TRANSPORT_AUTO : SIPE_TRANSPORT_TLS;
318 } else if (sipe_strequal(transport, "tls")) {
319 type = SIPE_TRANSPORT_TLS;
320 } else {
321 type = SIPE_TRANSPORT_TCP;
323 sipe_core_transport_sip_connect(sipe_public,
324 type,
325 username_split[0],
326 username_split[0] ? username_split[1] : NULL);
327 g_strfreev(username_split);
330 static void sipe_purple_close(PurpleConnection *gc)
332 struct sipe_core_public *sipe_public = PURPLE_GC_TO_SIPE_CORE_PUBLIC;
334 if (sipe_public) {
335 struct sipe_backend_private *purple_private = sipe_public->backend_private;
337 sipe_core_deallocate(sipe_public);
339 if (purple_private->roomlist_map)
340 g_hash_table_destroy(purple_private->roomlist_map);
341 sipe_purple_chat_destroy_rejoin(purple_private);
342 g_free(purple_private);
343 gc->proto_data = NULL;
347 #define SIPE_TYPING_SEND_TIMEOUT 4
349 static unsigned int sipe_purple_send_typing(PurpleConnection *gc,
350 const char *who,
351 PurpleTypingState state)
353 if (state == PURPLE_NOT_TYPING)
354 return 0;
356 sipe_core_user_feedback_typing(PURPLE_GC_TO_SIPE_CORE_PUBLIC,
357 who);
359 return SIPE_TYPING_SEND_TIMEOUT;
362 static void sipe_purple_add_permit(PurpleConnection *gc, const char *name)
364 sipe_core_contact_allow_deny(PURPLE_GC_TO_SIPE_CORE_PUBLIC, name, TRUE);
367 static void sipe_purple_add_deny(PurpleConnection *gc, const char *name)
369 sipe_core_contact_allow_deny(PURPLE_GC_TO_SIPE_CORE_PUBLIC, name, FALSE);
372 static void sipe_purple_keep_alive(PurpleConnection *gc)
374 struct sipe_core_public *sipe_public = PURPLE_GC_TO_SIPE_CORE_PUBLIC;
375 struct sipe_backend_private *purple_private = sipe_public->backend_private;
376 time_t now = time(NULL);
378 if ((sipe_public->keepalive_timeout > 0) &&
379 ((guint) (now - purple_private->last_keepalive) >= sipe_public->keepalive_timeout) &&
380 ((guint) (now - gc->last_received) >= sipe_public->keepalive_timeout)
382 sipe_core_transport_sip_keepalive(sipe_public);
383 purple_private->last_keepalive = now;
387 static void sipe_purple_alias_buddy(PurpleConnection *gc, const char *name,
388 SIPE_UNUSED_PARAMETER const char *alias)
390 sipe_core_group_set_user(PURPLE_GC_TO_SIPE_CORE_PUBLIC, name);
393 #if PURPLE_VERSION_CHECK(2,5,0)
394 static GHashTable *
395 sipe_purple_get_account_text_table(SIPE_UNUSED_PARAMETER PurpleAccount *account)
397 GHashTable *table;
398 table = g_hash_table_new(g_str_hash, g_str_equal);
399 g_hash_table_insert(table, "login_label", (gpointer)_("user@company.com"));
400 return table;
403 #if PURPLE_VERSION_CHECK(2,6,0)
404 #ifdef HAVE_VV
405 static gboolean sipe_purple_initiate_media(PurpleAccount *account, const char *who,
406 SIPE_UNUSED_PARAMETER PurpleMediaSessionType type)
408 sipe_core_media_initiate_call(PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC,
409 who,
410 (type & PURPLE_MEDIA_VIDEO));
411 return TRUE;
414 static PurpleMediaCaps sipe_purple_get_media_caps(SIPE_UNUSED_PARAMETER PurpleAccount *account,
415 SIPE_UNUSED_PARAMETER const char *who)
417 return PURPLE_MEDIA_CAPS_AUDIO
418 | PURPLE_MEDIA_CAPS_AUDIO_VIDEO
419 | PURPLE_MEDIA_CAPS_MODIFY_SESSION;
421 #endif
422 #endif
423 #endif
425 static PurplePluginProtocolInfo sipe_prpl_info =
427 OPT_PROTO_CHAT_TOPIC,
428 NULL, /* user_splits */
429 NULL, /* protocol_options */
430 NO_BUDDY_ICONS, /* icon_spec */
431 sipe_list_icon, /* list_icon */
432 NULL, /* list_emblems */
433 sipe_purple_status_text, /* status_text */
434 sipe_purple_tooltip_text, /* tooltip_text */ // add custom info to contact tooltip
435 sipe_purple_status_types, /* away_states */
436 sipe_purple_blist_node_menu, /* blist_node_menu */
437 sipe_purple_chat_info, /* chat_info */
438 sipe_purple_chat_info_defaults, /* chat_info_defaults */
439 sipe_purple_login, /* login */
440 sipe_purple_close, /* close */
441 sipe_im_send, /* send_im */
442 NULL, /* set_info */ // TODO maybe
443 sipe_purple_send_typing, /* send_typing */
444 sipe_get_info, /* get_info */
445 sipe_set_status, /* set_status */
446 sipe_set_idle, /* set_idle */
447 NULL, /* change_passwd */
448 sipe_add_buddy, /* add_buddy */
449 NULL, /* add_buddies */
450 sipe_remove_buddy, /* remove_buddy */
451 NULL, /* remove_buddies */
452 sipe_purple_add_permit, /* add_permit */
453 sipe_purple_add_deny, /* add_deny */
454 sipe_purple_add_deny, /* rem_permit */
455 sipe_purple_add_permit, /* rem_deny */
456 NULL, /* set_permit_deny */
457 sipe_purple_chat_join, /* join_chat */
458 NULL, /* reject_chat */
459 NULL, /* get_chat_name */
460 sipe_purple_chat_invite, /* chat_invite */
461 sipe_purple_chat_leave, /* chat_leave */
462 NULL, /* chat_whisper */
463 sipe_purple_chat_send, /* chat_send */
464 sipe_purple_keep_alive, /* keepalive */
465 NULL, /* register_user */
466 NULL, /* get_cb_info */ // deprecated
467 NULL, /* get_cb_away */ // deprecated
468 sipe_purple_alias_buddy, /* alias_buddy */
469 sipe_group_buddy, /* group_buddy */
470 sipe_rename_group, /* rename_group */
471 NULL, /* buddy_free */
472 sipe_convo_closed, /* convo_closed */
473 purple_normalize_nocase, /* normalize */
474 NULL, /* set_buddy_icon */
475 sipe_remove_group, /* remove_group */
476 NULL, /* get_cb_real_name */ // TODO?
477 NULL, /* set_chat_topic */
478 NULL, /* find_blist_chat */
479 sipe_purple_roomlist_get_list, /* roomlist_get_list */
480 sipe_purple_roomlist_cancel, /* roomlist_cancel */
481 NULL, /* roomlist_expand_category */
482 NULL, /* can_receive_file */
483 sipe_purple_ft_send_file, /* send_file */
484 sipe_purple_ft_new_xfer, /* new_xfer */
485 NULL, /* offline_message */
486 NULL, /* whiteboard_prpl_ops */
487 NULL, /* send_raw */
488 NULL, /* roomlist_room_serialize */
489 NULL, /* unregister_user */
490 NULL, /* send_attention */
491 NULL, /* get_attention_types */
492 #if !PURPLE_VERSION_CHECK(2,5,0)
493 /* Backward compatibility when compiling against 2.4.x API */
494 (void (*)(void)) /* _purple_reserved4 */
495 #endif
496 sizeof(PurplePluginProtocolInfo), /* struct_size */
497 #if PURPLE_VERSION_CHECK(2,5,0)
498 sipe_purple_get_account_text_table, /* get_account_text_table */
499 #if PURPLE_VERSION_CHECK(2,6,0)
500 #ifdef HAVE_VV
501 sipe_purple_initiate_media, /* initiate_media */
502 sipe_purple_get_media_caps, /* get_media_caps */
503 #else
504 NULL, /* initiate_media */
505 NULL, /* get_media_caps */
506 #endif
507 #if PURPLE_VERSION_CHECK(2,7,0)
508 NULL, /* get_moods */
509 NULL, /* set_public_alias */
510 NULL, /* get_public_alias */
511 #endif
512 #endif
513 #endif
516 /* PurplePluginInfo function calls & data structure */
517 static gboolean sipe_purple_plugin_load(SIPE_UNUSED_PARAMETER PurplePlugin *plugin)
519 return TRUE;
522 static gboolean sipe_purple_plugin_unload(SIPE_UNUSED_PARAMETER PurplePlugin *plugin)
524 return TRUE;
527 static void sipe_purple_plugin_destroy(SIPE_UNUSED_PARAMETER PurplePlugin *plugin)
529 GList *entry;
531 sipe_purple_activity_destroy();
532 sipe_core_destroy();
534 entry = sipe_prpl_info.protocol_options;
535 while (entry) {
536 purple_account_option_destroy(entry->data);
537 entry = g_list_delete_link(entry, entry);
539 sipe_prpl_info.protocol_options = NULL;
541 entry = sipe_prpl_info.user_splits;
542 while (entry) {
543 purple_account_user_split_destroy(entry->data);
544 entry = g_list_delete_link(entry, entry);
546 sipe_prpl_info.user_splits = NULL;
549 static void sipe_purple_show_about_plugin(PurplePluginAction *action)
551 gchar *tmp = sipe_core_about();
552 purple_notify_formatted((PurpleConnection *) action->context,
553 NULL, " ", NULL, tmp, NULL, NULL);
554 g_free(tmp);
557 static void sipe_purple_show_find_contact(PurplePluginAction *action)
559 PurpleConnection *gc = (PurpleConnection *) action->context;
560 PurpleRequestFields *fields;
561 PurpleRequestFieldGroup *group;
562 PurpleRequestField *field;
564 fields = purple_request_fields_new();
565 group = purple_request_field_group_new(NULL);
566 purple_request_fields_add_group(fields, group);
568 field = purple_request_field_string_new("givenName", _("First name"), NULL, FALSE);
569 purple_request_field_group_add_field(group, field);
570 field = purple_request_field_string_new("sn", _("Last name"), NULL, FALSE);
571 purple_request_field_group_add_field(group, field);
572 field = purple_request_field_string_new("company", _("Company"), NULL, FALSE);
573 purple_request_field_group_add_field(group, field);
574 field = purple_request_field_string_new("c", _("Country"), NULL, FALSE);
575 purple_request_field_group_add_field(group, field);
577 purple_request_fields(gc,
578 _("Search"),
579 _("Search for a contact"),
580 _("Enter the information for the person you wish to find. Empty fields will be ignored."),
581 fields,
582 _("_Search"), G_CALLBACK(sipe_search_contact_with_cb),
583 _("_Cancel"), NULL,
584 purple_connection_get_account(gc), NULL, NULL, gc);
587 static void sipe_purple_republish_calendar(PurplePluginAction *action)
589 PurpleConnection *gc = (PurpleConnection *) action->context;
590 sipe_core_update_calendar(PURPLE_GC_TO_SIPE_CORE_PUBLIC);
593 static void sipe_purple_reset_status(PurplePluginAction *action)
595 PurpleConnection *gc = (PurpleConnection *) action->context;
596 sipe_core_reset_status(PURPLE_GC_TO_SIPE_CORE_PUBLIC);
599 static GList *sipe_purple_actions(SIPE_UNUSED_PARAMETER PurplePlugin *plugin,
600 SIPE_UNUSED_PARAMETER gpointer context)
602 GList *menu = NULL;
603 PurplePluginAction *act;
605 act = purple_plugin_action_new(_("About SIPE plugin..."), sipe_purple_show_about_plugin);
606 menu = g_list_prepend(menu, act);
608 act = purple_plugin_action_new(_("Contact search..."), sipe_purple_show_find_contact);
609 menu = g_list_prepend(menu, act);
611 act = purple_plugin_action_new(_("Republish Calendar"), sipe_purple_republish_calendar);
612 menu = g_list_prepend(menu, act);
614 act = purple_plugin_action_new(_("Reset status"), sipe_purple_reset_status);
615 menu = g_list_prepend(menu, act);
617 return g_list_reverse(menu);
620 static PurplePluginInfo sipe_purple_info = {
621 PURPLE_PLUGIN_MAGIC,
622 PURPLE_MAJOR_VERSION,
623 PURPLE_MINOR_VERSION,
624 PURPLE_PLUGIN_PROTOCOL, /**< type */
625 NULL, /**< ui_requirement */
626 0, /**< flags */
627 NULL, /**< dependencies */
628 PURPLE_PRIORITY_DEFAULT, /**< priority */
629 "prpl-sipe", /**< id */
630 "Office Communicator", /**< name */
631 PACKAGE_VERSION, /**< version */
632 "Microsoft Office Communicator Protocol Plugin", /**< summary */
633 "A plugin for the extended SIP/SIMPLE protocol used by " /**< description */
634 "Microsoft Live/Office Communications Server (LCS2005/OCS2007+)", /**< description */
635 "Anibal Avelar <avelar@gmail.com>, " /**< author */
636 "Gabriel Burt <gburt@novell.com>, " /**< author */
637 "Stefan Becker <stefan.becker@nokia.com>, " /**< author */
638 "pier11 <pier11@operamail.com>", /**< author */
639 PACKAGE_URL, /**< homepage */
640 sipe_purple_plugin_load, /**< load */
641 sipe_purple_plugin_unload, /**< unload */
642 sipe_purple_plugin_destroy, /**< destroy */
643 NULL, /**< ui_info */
644 &sipe_prpl_info, /**< extra_info */
645 NULL,
646 sipe_purple_actions,
647 NULL,
648 NULL,
649 NULL,
650 NULL
653 static void sipe_purple_init_plugin(PurplePlugin *plugin)
655 PurpleAccountUserSplit *split;
656 PurpleAccountOption *option;
658 /* This needs to be called first */
659 sipe_core_init(LOCALEDIR);
660 sipe_purple_activity_init();
662 purple_plugin_register(plugin);
665 * When adding new string settings please make sure to keep these
666 * in sync:
668 * api/sipe-backend.h
669 * purple-settings.c:setting_name[]
671 split = purple_account_user_split_new(_("Login\n user or DOMAIN\\user or\n user@company.com"), NULL, ',');
672 purple_account_user_split_set_reverse(split, FALSE);
673 sipe_prpl_info.user_splits = g_list_append(sipe_prpl_info.user_splits, split);
675 option = purple_account_option_string_new(_("Server[:Port]\n(leave empty for auto-discovery)"), "server", "");
676 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
678 option = purple_account_option_list_new(_("Connection type"), "transport", NULL);
679 purple_account_option_add_list_item(option, _("Auto"), "auto");
680 purple_account_option_add_list_item(option, _("SSL/TLS"), "tls");
681 purple_account_option_add_list_item(option, _("TCP"), "tcp");
682 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
684 /*option = purple_account_option_bool_new(_("Publish status (note: everyone may watch you)"), "doservice", TRUE);
685 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);*/
687 option = purple_account_option_string_new(_("User Agent"), "useragent", "");
688 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
690 #ifdef HAVE_LIBKRB5
691 option = purple_account_option_bool_new(_("Use Kerberos"), "krb5", FALSE);
692 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
694 /* Suitable for sspi/NTLM, sspi/Kerberos and krb5 security mechanisms
695 * No login/password is taken into account if this option present,
696 * instead used default credentials stored in OS.
698 option = purple_account_option_bool_new(_("Use Single Sign-On"), "sso", TRUE);
699 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
700 #endif
702 /** Example (Exchange): https://server.company.com/EWS/Exchange.asmx
703 * Example (Domino) : https://[domino_server]/[mail_database_name].nsf
705 option = purple_account_option_string_new(_("Email services URL\n(leave empty for auto-discovery)"), "email_url", "");
706 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
708 option = purple_account_option_string_new(_("Email address\n(if different from Username)"), "email", "");
709 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
711 /** Example (Exchange): DOMAIN\user or user@company.com
712 * Example (Domino) : email_address
714 option = purple_account_option_string_new(_("Email login\n(if different from Login)"), "email_login", "");
715 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
717 option = purple_account_option_string_new(_("Email password\n(if different from Password)"), "email_password", "");
718 purple_account_option_set_masked(option, TRUE);
719 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
721 /** Example (federated domain): company.com (i.e. ocschat@company.com)
722 * Example (non-default user): user@company.com
724 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", "");
725 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
728 /* This macro makes the code a purple plugin */
729 PURPLE_INIT_PLUGIN(sipe, sipe_purple_init_plugin, sipe_purple_info);
732 Local Variables:
733 mode: c
734 c-file-style: "bsd"
735 indent-tabs-mode: t
736 tab-width: 8
737 End: