Merge branch 'mob' into private-chatid-rework
[siplcs.git] / src / purple / purple-plugin.c
blob31f31aee1285e471fcc3d4ac210e3599561c26f6
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 purple_notify_user_info_add_pair(user_info,
154 sbi->label, sbi->text);
155 g_free(sbi->text);
156 g_free(sbi);
157 info = g_slist_delete_link(info, info);
161 static GList *sipe_purple_status_types(SIPE_UNUSED_PARAMETER PurpleAccount *acc)
163 PurpleStatusType *type;
164 GList *types = NULL;
166 /* Macros to reduce code repetition.
167 Translators: noun */
168 #define SIPE_ADD_STATUS(prim,id,name,user) type = purple_status_type_new_with_attrs( \
169 prim, id, name, \
170 TRUE, user, FALSE, \
171 SIPE_STATUS_ATTR_ID_MESSAGE, _("Message"), purple_value_new(PURPLE_TYPE_STRING), \
172 NULL); \
173 types = g_list_append(types, type);
175 /* Online */
176 SIPE_ADD_STATUS(PURPLE_STATUS_AVAILABLE,
177 NULL,
178 NULL,
179 TRUE);
181 /* Busy */
182 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE,
183 activity_to_purple[SIPE_ACTIVITY_BUSY],
184 _("Busy"),
185 TRUE);
187 /* Do Not Disturb */
188 SIPE_ADD_STATUS(PURPLE_STATUS_UNAVAILABLE,
189 activity_to_purple[SIPE_ACTIVITY_DND],
190 NULL,
191 TRUE);
193 /* Away */
194 /* Goes first in the list as
195 * purple picks the first status with the AWAY type
196 * for idle.
198 SIPE_ADD_STATUS(PURPLE_STATUS_AWAY,
199 NULL,
200 NULL,
201 TRUE);
203 /* Be Right Back */
204 SIPE_ADD_STATUS(PURPLE_STATUS_AWAY,
205 activity_to_purple[SIPE_ACTIVITY_BRB],
206 _("Be right back"),
207 TRUE);
209 /* Appear Offline */
210 SIPE_ADD_STATUS(PURPLE_STATUS_INVISIBLE,
211 NULL,
212 NULL,
213 TRUE);
215 /* Offline */
216 type = purple_status_type_new(PURPLE_STATUS_OFFLINE,
217 NULL,
218 NULL,
219 TRUE);
220 types = g_list_append(types, type);
222 return types;
225 static GList *sipe_purple_blist_node_menu(PurpleBlistNode *node)
227 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
228 return sipe_buddy_menu((PurpleBuddy *) node);
229 } else if(PURPLE_BLIST_NODE_IS_CHAT(node)) {
230 return sipe_purple_chat_menu((PurpleChat *)node);
231 } else {
232 return NULL;
236 static void sipe_purple_login(PurpleAccount *account)
238 PurpleConnection *gc = purple_account_get_connection(account);
239 const gchar *username = purple_account_get_username(account);
240 const gchar *email = purple_account_get_string(account, "email", NULL);
241 const gchar *email_url = purple_account_get_string(account, "email_url", NULL);
242 const gchar *transport = purple_account_get_string(account, "transport", "auto");
243 struct sipe_core_public *sipe_public;
244 gchar **username_split;
245 gchar *login_domain = NULL;
246 gchar *login_account = NULL;
247 const gchar *errmsg;
248 guint type;
249 struct sipe_backend_private *purple_private;
251 /* username format: <username>,[<optional login>] */
252 SIPE_DEBUG_INFO("sipe_purple_login: username '%s'", username);
253 username_split = g_strsplit(username, ",", 2);
255 /* login name specified? */
256 if (username_split[1] && strlen(username_split[1])) {
257 /* Allowed domain-account separators are / or \ */
258 gchar **domain_user = g_strsplit_set(username_split[1], "/\\", 2);
259 gboolean has_domain = domain_user[1] != NULL;
260 SIPE_DEBUG_INFO("sipe_purple_login: login '%s'", username_split[1]);
261 login_domain = has_domain ? g_strdup(domain_user[0]) : NULL;
262 login_account = g_strdup(domain_user[has_domain ? 1 : 0]);
263 SIPE_DEBUG_INFO("sipe_purple_login: auth domain '%s' user '%s'",
264 login_domain ? login_domain : "",
265 login_account);
266 g_strfreev(domain_user);
269 sipe_public = sipe_core_allocate(username_split[0],
270 login_domain, login_account,
271 purple_connection_get_password(gc),
272 email,
273 email_url,
274 &errmsg);
275 g_free(login_domain);
276 g_free(login_account);
277 g_strfreev(username_split);
279 if (!sipe_public) {
280 purple_connection_error_reason(gc,
281 PURPLE_CONNECTION_ERROR_INVALID_USERNAME,
282 errmsg);
283 return;
286 sipe_public->backend_private = purple_private = g_new0(struct sipe_backend_private, 1);
287 purple_private->public = sipe_public;
288 purple_private->gc = gc;
289 purple_private->account = account;
291 sipe_purple_chat_setup_rejoin(purple_private);
293 #ifdef HAVE_LIBKRB5
294 if (purple_account_get_bool(account, "krb5", FALSE))
295 SIPE_CORE_FLAG_SET(KRB5);
296 #endif
297 /* @TODO: is this correct?
298 "sso" is only available when Kerberos support is compiled in */
299 if (purple_account_get_bool(account, "sso", TRUE))
300 SIPE_CORE_FLAG_SET(SSO);
302 gc->proto_data = sipe_public;
303 sipe_purple_setup(sipe_public, gc);
304 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO | PURPLE_CONNECTION_NO_BGCOLOR |
305 PURPLE_CONNECTION_NO_FONTSIZE | PURPLE_CONNECTION_NO_URLDESC | PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY;
306 purple_connection_set_display_name(gc, sipe_public->sip_name);
307 purple_connection_update_progress(gc, _("Connecting"), 1, 2);
309 username_split = g_strsplit(purple_account_get_string(account, "server", ""), ":", 2);
310 if (sipe_strequal(transport, "auto")) {
311 type = (username_split[0] == NULL) ?
312 SIPE_TRANSPORT_AUTO : SIPE_TRANSPORT_TLS;
313 } else if (sipe_strequal(transport, "tls")) {
314 type = SIPE_TRANSPORT_TLS;
315 } else {
316 type = SIPE_TRANSPORT_TCP;
318 sipe_core_transport_sip_connect(sipe_public,
319 type,
320 username_split[0],
321 username_split[0] ? username_split[1] : NULL);
322 g_strfreev(username_split);
325 static void sipe_purple_close(PurpleConnection *gc)
327 struct sipe_core_public *sipe_public = PURPLE_GC_TO_SIPE_CORE_PUBLIC;
329 if (sipe_public) {
330 struct sipe_backend_private *purple_private = sipe_public->backend_private;
332 sipe_core_deallocate(sipe_public);
334 if (purple_private->roomlist_map)
335 g_hash_table_destroy(purple_private->roomlist_map);
336 sipe_purple_chat_destroy_rejoin(purple_private);
337 g_free(purple_private);
338 gc->proto_data = NULL;
342 #define SIPE_TYPING_SEND_TIMEOUT 4
344 static unsigned int sipe_purple_send_typing(PurpleConnection *gc,
345 const char *who,
346 PurpleTypingState state)
348 if (state == PURPLE_NOT_TYPING)
349 return 0;
351 sipe_core_user_feedback_typing(PURPLE_GC_TO_SIPE_CORE_PUBLIC,
352 who);
354 return SIPE_TYPING_SEND_TIMEOUT;
357 static void sipe_purple_add_permit(PurpleConnection *gc, const char *name)
359 sipe_core_contact_allow_deny(PURPLE_GC_TO_SIPE_CORE_PUBLIC, name, TRUE);
362 static void sipe_purple_add_deny(PurpleConnection *gc, const char *name)
364 sipe_core_contact_allow_deny(PURPLE_GC_TO_SIPE_CORE_PUBLIC, name, FALSE);
367 static void sipe_purple_keep_alive(PurpleConnection *gc)
369 struct sipe_core_public *sipe_public = PURPLE_GC_TO_SIPE_CORE_PUBLIC;
370 struct sipe_backend_private *purple_private = sipe_public->backend_private;
371 time_t now = time(NULL);
373 if ((sipe_public->keepalive_timeout > 0) &&
374 ((guint) (now - purple_private->last_keepalive) >= sipe_public->keepalive_timeout) &&
375 ((guint) (now - gc->last_received) >= sipe_public->keepalive_timeout)
377 sipe_core_transport_sip_keepalive(sipe_public);
378 purple_private->last_keepalive = now;
382 static void sipe_purple_alias_buddy(PurpleConnection *gc, const char *name,
383 SIPE_UNUSED_PARAMETER const char *alias)
385 sipe_core_group_set_user(PURPLE_GC_TO_SIPE_CORE_PUBLIC, name);
388 #if PURPLE_VERSION_CHECK(2,5,0)
389 static GHashTable *
390 sipe_purple_get_account_text_table(SIPE_UNUSED_PARAMETER PurpleAccount *account)
392 GHashTable *table;
393 table = g_hash_table_new(g_str_hash, g_str_equal);
394 g_hash_table_insert(table, "login_label", (gpointer)_("user@company.com"));
395 return table;
398 #if PURPLE_VERSION_CHECK(2,6,0)
399 #ifdef HAVE_VV
400 static gboolean sipe_purple_initiate_media(PurpleAccount *account, const char *who,
401 SIPE_UNUSED_PARAMETER PurpleMediaSessionType type)
403 sipe_core_media_initiate_call(PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC,
404 who,
405 (type & PURPLE_MEDIA_VIDEO));
406 return TRUE;
409 static PurpleMediaCaps sipe_purple_get_media_caps(SIPE_UNUSED_PARAMETER PurpleAccount *account,
410 SIPE_UNUSED_PARAMETER const char *who)
412 return PURPLE_MEDIA_CAPS_AUDIO
413 | PURPLE_MEDIA_CAPS_AUDIO_VIDEO
414 | PURPLE_MEDIA_CAPS_MODIFY_SESSION;
416 #endif
417 #endif
418 #endif
420 static PurplePluginProtocolInfo sipe_prpl_info =
422 OPT_PROTO_CHAT_TOPIC,
423 NULL, /* user_splits */
424 NULL, /* protocol_options */
425 NO_BUDDY_ICONS, /* icon_spec */
426 sipe_list_icon, /* list_icon */
427 NULL, /* list_emblems */
428 sipe_purple_status_text, /* status_text */
429 sipe_purple_tooltip_text, /* tooltip_text */ // add custom info to contact tooltip
430 sipe_purple_status_types, /* away_states */
431 sipe_purple_blist_node_menu, /* blist_node_menu */
432 sipe_purple_chat_info, /* chat_info */
433 sipe_purple_chat_info_defaults, /* chat_info_defaults */
434 sipe_purple_login, /* login */
435 sipe_purple_close, /* close */
436 sipe_im_send, /* send_im */
437 NULL, /* set_info */ // TODO maybe
438 sipe_purple_send_typing, /* send_typing */
439 sipe_get_info, /* get_info */
440 sipe_set_status, /* set_status */
441 sipe_set_idle, /* set_idle */
442 NULL, /* change_passwd */
443 sipe_add_buddy, /* add_buddy */
444 NULL, /* add_buddies */
445 sipe_remove_buddy, /* remove_buddy */
446 NULL, /* remove_buddies */
447 sipe_purple_add_permit, /* add_permit */
448 sipe_purple_add_deny, /* add_deny */
449 sipe_purple_add_deny, /* rem_permit */
450 sipe_purple_add_permit, /* rem_deny */
451 NULL, /* set_permit_deny */
452 sipe_purple_chat_join, /* join_chat */
453 NULL, /* reject_chat */
454 NULL, /* get_chat_name */
455 sipe_purple_chat_invite, /* chat_invite */
456 sipe_purple_chat_leave, /* chat_leave */
457 NULL, /* chat_whisper */
458 sipe_purple_chat_send, /* chat_send */
459 sipe_purple_keep_alive, /* keepalive */
460 NULL, /* register_user */
461 NULL, /* get_cb_info */ // deprecated
462 NULL, /* get_cb_away */ // deprecated
463 sipe_purple_alias_buddy, /* alias_buddy */
464 sipe_group_buddy, /* group_buddy */
465 sipe_rename_group, /* rename_group */
466 NULL, /* buddy_free */
467 sipe_convo_closed, /* convo_closed */
468 purple_normalize_nocase, /* normalize */
469 NULL, /* set_buddy_icon */
470 sipe_remove_group, /* remove_group */
471 NULL, /* get_cb_real_name */ // TODO?
472 NULL, /* set_chat_topic */
473 NULL, /* find_blist_chat */
474 sipe_purple_roomlist_get_list, /* roomlist_get_list */
475 sipe_purple_roomlist_cancel, /* roomlist_cancel */
476 NULL, /* roomlist_expand_category */
477 NULL, /* can_receive_file */
478 sipe_purple_ft_send_file, /* send_file */
479 sipe_purple_ft_new_xfer, /* new_xfer */
480 NULL, /* offline_message */
481 NULL, /* whiteboard_prpl_ops */
482 NULL, /* send_raw */
483 NULL, /* roomlist_room_serialize */
484 NULL, /* unregister_user */
485 NULL, /* send_attention */
486 NULL, /* get_attention_types */
487 #if !PURPLE_VERSION_CHECK(2,5,0)
488 /* Backward compatibility when compiling against 2.4.x API */
489 (void (*)(void)) /* _purple_reserved4 */
490 #endif
491 sizeof(PurplePluginProtocolInfo), /* struct_size */
492 #if PURPLE_VERSION_CHECK(2,5,0)
493 sipe_purple_get_account_text_table, /* get_account_text_table */
494 #if PURPLE_VERSION_CHECK(2,6,0)
495 #ifdef HAVE_VV
496 sipe_purple_initiate_media, /* initiate_media */
497 sipe_purple_get_media_caps, /* get_media_caps */
498 #else
499 NULL, /* initiate_media */
500 NULL, /* get_media_caps */
501 #endif
502 #if PURPLE_VERSION_CHECK(2,7,0)
503 NULL, /* get_moods */
504 NULL, /* set_public_alias */
505 NULL, /* get_public_alias */
506 #endif
507 #endif
508 #endif
511 /* PurplePluginInfo function calls & data structure */
512 static gboolean sipe_purple_plugin_load(SIPE_UNUSED_PARAMETER PurplePlugin *plugin)
514 return TRUE;
517 static gboolean sipe_purple_plugin_unload(SIPE_UNUSED_PARAMETER PurplePlugin *plugin)
519 return TRUE;
522 static void sipe_purple_plugin_destroy(SIPE_UNUSED_PARAMETER PurplePlugin *plugin)
524 GList *entry;
526 sipe_purple_activity_destroy();
527 sipe_core_destroy();
529 entry = sipe_prpl_info.protocol_options;
530 while (entry) {
531 purple_account_option_destroy(entry->data);
532 entry = g_list_delete_link(entry, entry);
534 sipe_prpl_info.protocol_options = NULL;
536 entry = sipe_prpl_info.user_splits;
537 while (entry) {
538 purple_account_user_split_destroy(entry->data);
539 entry = g_list_delete_link(entry, entry);
541 sipe_prpl_info.user_splits = NULL;
544 static void sipe_purple_show_about_plugin(PurplePluginAction *action)
546 gchar *tmp = sipe_core_about();
547 purple_notify_formatted((PurpleConnection *) action->context,
548 NULL, " ", NULL, tmp, NULL, NULL);
549 g_free(tmp);
552 static void sipe_purple_show_find_contact(PurplePluginAction *action)
554 PurpleConnection *gc = (PurpleConnection *) action->context;
555 PurpleRequestFields *fields;
556 PurpleRequestFieldGroup *group;
557 PurpleRequestField *field;
559 fields = purple_request_fields_new();
560 group = purple_request_field_group_new(NULL);
561 purple_request_fields_add_group(fields, group);
563 field = purple_request_field_string_new("givenName", _("First name"), NULL, FALSE);
564 purple_request_field_group_add_field(group, field);
565 field = purple_request_field_string_new("sn", _("Last name"), NULL, FALSE);
566 purple_request_field_group_add_field(group, field);
567 field = purple_request_field_string_new("company", _("Company"), NULL, FALSE);
568 purple_request_field_group_add_field(group, field);
569 field = purple_request_field_string_new("c", _("Country"), NULL, FALSE);
570 purple_request_field_group_add_field(group, field);
572 purple_request_fields(gc,
573 _("Search"),
574 _("Search for a contact"),
575 _("Enter the information for the person you wish to find. Empty fields will be ignored."),
576 fields,
577 _("_Search"), G_CALLBACK(sipe_search_contact_with_cb),
578 _("_Cancel"), NULL,
579 purple_connection_get_account(gc), NULL, NULL, gc);
582 static void sipe_purple_republish_calendar(PurplePluginAction *action)
584 PurpleConnection *gc = (PurpleConnection *) action->context;
585 sipe_core_update_calendar(PURPLE_GC_TO_SIPE_CORE_PUBLIC);
588 static void sipe_purple_reset_status(PurplePluginAction *action)
590 PurpleConnection *gc = (PurpleConnection *) action->context;
591 sipe_core_reset_status(PURPLE_GC_TO_SIPE_CORE_PUBLIC);
594 static GList *sipe_purple_actions(SIPE_UNUSED_PARAMETER PurplePlugin *plugin,
595 SIPE_UNUSED_PARAMETER gpointer context)
597 GList *menu = NULL;
598 PurplePluginAction *act;
600 act = purple_plugin_action_new(_("About SIPE plugin..."), sipe_purple_show_about_plugin);
601 menu = g_list_prepend(menu, act);
603 act = purple_plugin_action_new(_("Contact search..."), sipe_purple_show_find_contact);
604 menu = g_list_prepend(menu, act);
606 act = purple_plugin_action_new(_("Republish Calendar"), sipe_purple_republish_calendar);
607 menu = g_list_prepend(menu, act);
609 act = purple_plugin_action_new(_("Reset status"), sipe_purple_reset_status);
610 menu = g_list_prepend(menu, act);
612 return g_list_reverse(menu);
615 static PurplePluginInfo sipe_purple_info = {
616 PURPLE_PLUGIN_MAGIC,
617 PURPLE_MAJOR_VERSION,
618 PURPLE_MINOR_VERSION,
619 PURPLE_PLUGIN_PROTOCOL, /**< type */
620 NULL, /**< ui_requirement */
621 0, /**< flags */
622 NULL, /**< dependencies */
623 PURPLE_PRIORITY_DEFAULT, /**< priority */
624 "prpl-sipe", /**< id */
625 "Office Communicator", /**< name */
626 PACKAGE_VERSION, /**< version */
627 "Microsoft Office Communicator Protocol Plugin", /**< summary */
628 "A plugin for the extended SIP/SIMPLE protocol used by " /**< description */
629 "Microsoft Live/Office Communications Server (LCS2005/OCS2007+)", /**< description */
630 "Anibal Avelar <avelar@gmail.com>, " /**< author */
631 "Gabriel Burt <gburt@novell.com>, " /**< author */
632 "Stefan Becker <stefan.becker@nokia.com>, " /**< author */
633 "pier11 <pier11@operamail.com>", /**< author */
634 PACKAGE_URL, /**< homepage */
635 sipe_purple_plugin_load, /**< load */
636 sipe_purple_plugin_unload, /**< unload */
637 sipe_purple_plugin_destroy, /**< destroy */
638 NULL, /**< ui_info */
639 &sipe_prpl_info, /**< extra_info */
640 NULL,
641 sipe_purple_actions,
642 NULL,
643 NULL,
644 NULL,
645 NULL
648 static void sipe_purple_init_plugin(PurplePlugin *plugin)
650 PurpleAccountUserSplit *split;
651 PurpleAccountOption *option;
653 /* This needs to be called first */
654 sipe_core_init(LOCALEDIR);
655 sipe_purple_activity_init();
657 purple_plugin_register(plugin);
660 * When adding new string settings please make sure to keep these
661 * in sync:
663 * api/sipe-backend.h
664 * purple-settings.c:setting_name[]
666 split = purple_account_user_split_new(_("Login\n user or DOMAIN\\user or\n user@company.com"), NULL, ',');
667 purple_account_user_split_set_reverse(split, FALSE);
668 sipe_prpl_info.user_splits = g_list_append(sipe_prpl_info.user_splits, split);
670 option = purple_account_option_string_new(_("Server[:Port]\n(leave empty for auto-discovery)"), "server", "");
671 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
673 option = purple_account_option_list_new(_("Connection type"), "transport", NULL);
674 purple_account_option_add_list_item(option, _("Auto"), "auto");
675 purple_account_option_add_list_item(option, _("SSL/TLS"), "tls");
676 purple_account_option_add_list_item(option, _("TCP"), "tcp");
677 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
679 /*option = purple_account_option_bool_new(_("Publish status (note: everyone may watch you)"), "doservice", TRUE);
680 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);*/
682 option = purple_account_option_string_new(_("User Agent"), "useragent", "");
683 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
685 #ifdef HAVE_LIBKRB5
686 option = purple_account_option_bool_new(_("Use Kerberos"), "krb5", FALSE);
687 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
689 /* Suitable for sspi/NTLM, sspi/Kerberos and krb5 security mechanisms
690 * No login/password is taken into account if this option present,
691 * instead used default credentials stored in OS.
693 option = purple_account_option_bool_new(_("Use Single Sign-On"), "sso", TRUE);
694 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
695 #endif
697 /** Example (Exchange): https://server.company.com/EWS/Exchange.asmx
698 * Example (Domino) : https://[domino_server]/[mail_database_name].nsf
700 option = purple_account_option_string_new(_("Email services URL\n(leave empty for auto-discovery)"), "email_url", "");
701 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
703 option = purple_account_option_string_new(_("Email address\n(if different from Username)"), "email", "");
704 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
706 /** Example (Exchange): DOMAIN\user or user@company.com
707 * Example (Domino) : email_address
709 option = purple_account_option_string_new(_("Email login\n(if different from Login)"), "email_login", "");
710 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
712 option = purple_account_option_string_new(_("Email password\n(if different from Password)"), "email_password", "");
713 purple_account_option_set_masked(option, TRUE);
714 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
716 /** Example (federated domain): company.com (i.e. ocschat@company.com)
717 * Example (non-default user): user@company.com
719 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", "");
720 sipe_prpl_info.protocol_options = g_list_append(sipe_prpl_info.protocol_options, option);
723 /* This macro makes the code a purple plugin */
724 PURPLE_INIT_PLUGIN(sipe, sipe_purple_init_plugin, sipe_purple_info);
727 Local Variables:
728 mode: c
729 c-file-style: "bsd"
730 indent-tabs-mode: t
731 tab-width: 8
732 End: