debug: dump libpurple local candidates
[siplcs.git] / src / purple / purple-plugin.c
blob72e364d420fb8a1a8c21fecef5436d14eb3e55d1
1 /**
2 * @file purple-plugin.c
4 * pidgin-sipe
6 * Copyright (C) 2010-2017 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 <glib.h>
29 #include "sipe-common.h"
31 /* Flag needed for correct version of PURPLE_INIT_PLUGIN() */
32 #ifndef PURPLE_PLUGINS
33 #define PURPLE_PLUGINS
34 #endif
36 /* for LOCALEDIR
37 * as it's determined on runtime, as Pidgin installation can be anywhere.
39 #ifdef _WIN32
40 #include "win32/win32dep.h"
41 #endif
43 #include "accountopt.h"
44 #include "prpl.h"
46 #include "sipe-core.h"
48 #define _PurpleMessageFlags PurpleMessageFlags
49 #include "purple-private.h"
51 static int sipe_purple_send_im(PurpleConnection *gc,
52 const char *who,
53 const char *what,
54 SIPE_UNUSED_PARAMETER PurpleMessageFlags flags)
56 sipe_core_im_send(PURPLE_GC_TO_SIPE_CORE_PUBLIC, who, what);
57 return 1;
61 * Simplistic source upward compatibility path for newer libpurple APIs
63 * Usually we compile with -Werror=missing-field-initializers if GCC supports
64 * it. But that means that the compilation of this structure can fail if the
65 * newer API has added additional plugin callbacks. For the benefit of the
66 * user we downgrade it to a warning here.
68 * Diagnostic #pragma was added in GCC 4.2.0
69 * Diagnostic push/pop was added in GCC 4.6.0
71 #ifdef __GNUC__
72 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || (__GNUC__ >= 5)
73 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ >= 5)
74 #pragma GCC diagnostic push
75 #endif
76 #pragma GCC diagnostic warning "-Wmissing-field-initializers"
77 #endif
78 #endif
79 static PurplePluginProtocolInfo sipe_prpl_info =
81 SIPE_PURPLE_PROTOCOL_OPTIONS,
82 NULL, /* user_splits */
83 NULL, /* protocol_options */
84 NO_BUDDY_ICONS, /* icon_spec */
85 sipe_purple_list_icon, /* list_icon */
86 NULL, /* list_emblems */
87 sipe_purple_status_text, /* status_text */
88 sipe_purple_tooltip_text, /* tooltip_text */ // add custom info to contact tooltip
89 sipe_purple_status_types, /* away_states */
90 sipe_purple_blist_node_menu, /* blist_node_menu */
91 sipe_purple_chat_info, /* chat_info */
92 sipe_purple_chat_info_defaults, /* chat_info_defaults */
93 sipe_purple_login, /* login */
94 sipe_purple_close, /* close */
95 sipe_purple_send_im, /* send_im */
96 NULL, /* set_info */ // TODO maybe
97 sipe_purple_send_typing, /* send_typing */
98 sipe_purple_get_info, /* get_info */
99 sipe_purple_set_status, /* set_status */
100 sipe_purple_set_idle, /* set_idle */
101 NULL, /* change_passwd */
102 sipe_purple_add_buddy, /* add_buddy */
103 NULL, /* add_buddies */
104 sipe_purple_remove_buddy, /* remove_buddy */
105 NULL, /* remove_buddies */
106 sipe_purple_add_permit, /* add_permit */
107 sipe_purple_add_deny, /* add_deny */
108 sipe_purple_add_deny, /* rem_permit */
109 sipe_purple_add_permit, /* rem_deny */
110 NULL, /* set_permit_deny */
111 sipe_purple_chat_join, /* join_chat */
112 NULL, /* reject_chat */
113 NULL, /* get_chat_name */
114 sipe_purple_chat_invite, /* chat_invite */
115 sipe_purple_chat_leave, /* chat_leave */
116 NULL, /* chat_whisper */
117 sipe_purple_chat_send, /* chat_send */
118 NULL, /* keepalive */
119 NULL, /* register_user */
120 NULL, /* get_cb_info */ // deprecated
121 NULL, /* get_cb_away */ // deprecated
122 sipe_purple_alias_buddy, /* alias_buddy */
123 sipe_purple_group_buddy, /* group_buddy */
124 sipe_purple_group_rename, /* rename_group */
125 NULL, /* buddy_free */
126 sipe_purple_convo_closed, /* convo_closed */
127 purple_normalize_nocase, /* normalize */
128 NULL, /* set_buddy_icon */
129 sipe_purple_group_remove, /* remove_group */
130 NULL, /* get_cb_real_name */ // TODO?
131 NULL, /* set_chat_topic */
132 NULL, /* find_blist_chat */
133 sipe_purple_roomlist_get_list, /* roomlist_get_list */
134 sipe_purple_roomlist_cancel, /* roomlist_cancel */
135 NULL, /* roomlist_expand_category */
136 NULL, /* can_receive_file */
137 sipe_purple_ft_send_file, /* send_file */
138 NULL, /* new_xfer */
139 NULL, /* offline_message */
140 NULL, /* whiteboard_prpl_ops */
141 NULL, /* send_raw */
142 NULL, /* roomlist_room_serialize */
143 NULL, /* unregister_user */
144 NULL, /* send_attention */
145 NULL, /* get_attention_types */
146 sizeof(PurplePluginProtocolInfo), /* struct_size */
147 sipe_purple_get_account_text_table, /* get_account_text_table */
148 #ifdef HAVE_VV
149 sipe_purple_initiate_media, /* initiate_media */
150 sipe_purple_get_media_caps, /* get_media_caps */
151 #else
152 NULL, /* initiate_media */
153 NULL, /* get_media_caps */
154 #endif
155 NULL, /* get_moods */
156 NULL, /* set_public_alias */
157 NULL, /* get_public_alias */
158 #if PURPLE_VERSION_CHECK(2,8,0)
159 NULL, /* add_buddy_with_invite */
160 NULL, /* add_buddies_with_invite */
161 #endif
163 #ifdef __GNUC__
164 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ >= 5)
165 #pragma GCC diagnostic pop
166 #endif
167 #endif
168 /* Original GCC error checking restored from here on... (see above) */
170 /* PurplePluginInfo function calls & data structure */
171 static void sipe_purple_plugin_destroy(SIPE_UNUSED_PARAMETER PurplePlugin *plugin)
173 GList *entry;
175 sipe_core_destroy();
177 entry = sipe_prpl_info.protocol_options;
178 while (entry) {
179 purple_account_option_destroy(entry->data);
180 entry = g_list_delete_link(entry, entry);
182 sipe_prpl_info.protocol_options = NULL;
184 entry = sipe_prpl_info.user_splits;
185 while (entry) {
186 purple_account_user_split_destroy(entry->data);
187 entry = g_list_delete_link(entry, entry);
189 sipe_prpl_info.user_splits = NULL;
192 static GList *purple_actions(SIPE_UNUSED_PARAMETER PurplePlugin *plugin,
193 SIPE_UNUSED_PARAMETER gpointer context)
195 return sipe_purple_actions();
198 static PurplePluginInfo sipe_purple_info = {
199 PURPLE_PLUGIN_MAGIC,
200 PURPLE_MAJOR_VERSION,
201 PURPLE_MINOR_VERSION,
202 PURPLE_PLUGIN_PROTOCOL, /**< type */
203 NULL, /**< ui_requirement */
204 0, /**< flags */
205 NULL, /**< dependencies */
206 PURPLE_PRIORITY_DEFAULT, /**< priority */
207 SIPE_PURPLE_PLUGIN_ID, /**< id */
208 SIPE_PURPLE_PLUGIN_NAME, /**< name */
209 PACKAGE_VERSION, /**< version */
210 SIPE_PURPLE_PLUGIN_SUMMARY, /**< summary */
211 SIPE_PURPLE_PLUGIN_DESCRIPTION, /**< description */
212 SIPE_PURPLE_PLUGIN_AUTHORS, /**< authors */
213 PACKAGE_URL, /**< homepage */
214 sipe_purple_plugin_load, /**< load */
215 sipe_purple_plugin_unload, /**< unload */
216 sipe_purple_plugin_destroy, /**< destroy */
217 NULL, /**< ui_info */
218 &sipe_prpl_info, /**< extra_info */
219 NULL,
220 purple_actions,
221 NULL,
222 NULL,
223 NULL,
224 NULL
227 static void sipe_purple_init_plugin(PurplePlugin *plugin)
229 /* This needs to be called first */
230 sipe_core_init(LOCALEDIR);
232 purple_plugin_register(plugin);
234 sipe_prpl_info.user_splits = g_list_append(sipe_prpl_info.user_splits,
235 sipe_purple_user_split());
237 sipe_prpl_info.protocol_options = sipe_purple_account_options();
240 /* This macro makes the code a purple plugin */
241 PURPLE_INIT_PLUGIN(sipe, sipe_purple_init_plugin, sipe_purple_info);
244 Local Variables:
245 mode: c
246 c-file-style: "bsd"
247 indent-tabs-mode: t
248 tab-width: 8
249 End: