purple: build against GPlugin-based 3.x API
[siplcs.git] / src / purple / purple-plugin.c
blob5d6f83ab8cbeb84669622c0e4e3a681aadba75e2
1 /**
2 * @file purple-plugin.c
4 * pidgin-sipe
6 * Copyright (C) 2010-2015 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 sipe_purple_ft_new_xfer, /* 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 #if !PURPLE_VERSION_CHECK(2,5,0)
147 /* Backward compatibility when compiling against 2.4.x API */
148 (void (*)(void)) /* _purple_reserved4 */
149 #endif
150 sizeof(PurplePluginProtocolInfo), /* struct_size */
151 #if PURPLE_VERSION_CHECK(2,5,0)
152 sipe_purple_get_account_text_table, /* get_account_text_table */
153 #if PURPLE_VERSION_CHECK(2,6,0)
154 #ifdef HAVE_VV
155 sipe_purple_initiate_media, /* initiate_media */
156 sipe_purple_get_media_caps, /* get_media_caps */
157 #else
158 NULL, /* initiate_media */
159 NULL, /* get_media_caps */
160 #endif
161 #if PURPLE_VERSION_CHECK(2,7,0)
162 NULL, /* get_moods */
163 NULL, /* set_public_alias */
164 NULL, /* get_public_alias */
165 #if PURPLE_VERSION_CHECK(2,8,0)
166 NULL, /* add_buddy_with_invite */
167 NULL, /* add_buddies_with_invite */
168 #endif
169 #endif
170 #endif
171 #endif
173 #ifdef __GNUC__
174 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ >= 5)
175 #pragma GCC diagnostic pop
176 #endif
177 #endif
178 /* Original GCC error checking restored from here on... (see above) */
180 /* PurplePluginInfo function calls & data structure */
181 static void sipe_purple_plugin_destroy(SIPE_UNUSED_PARAMETER PurplePlugin *plugin)
183 GList *entry;
185 sipe_core_destroy();
187 entry = sipe_prpl_info.protocol_options;
188 while (entry) {
189 purple_account_option_destroy(entry->data);
190 entry = g_list_delete_link(entry, entry);
192 sipe_prpl_info.protocol_options = NULL;
194 entry = sipe_prpl_info.user_splits;
195 while (entry) {
196 purple_account_user_split_destroy(entry->data);
197 entry = g_list_delete_link(entry, entry);
199 sipe_prpl_info.user_splits = NULL;
202 static GList *purple_actions(SIPE_UNUSED_PARAMETER PurplePlugin *plugin,
203 SIPE_UNUSED_PARAMETER gpointer context)
205 return sipe_purple_actions();
208 static PurplePluginInfo sipe_purple_info = {
209 PURPLE_PLUGIN_MAGIC,
210 PURPLE_MAJOR_VERSION,
211 PURPLE_MINOR_VERSION,
212 PURPLE_PLUGIN_PROTOCOL, /**< type */
213 NULL, /**< ui_requirement */
214 0, /**< flags */
215 NULL, /**< dependencies */
216 PURPLE_PRIORITY_DEFAULT, /**< priority */
217 SIPE_PURPLE_PLUGIN_ID, /**< id */
218 SIPE_PURPLE_PLUGIN_NAME, /**< name */
219 PACKAGE_VERSION, /**< version */
220 SIPE_PURPLE_PLUGIN_SUMMARY, /**< summary */
221 SIPE_PURPLE_PLUGIN_DESCRIPTION, /**< description */
222 SIPE_PURPLE_PLUGIN_AUTHORS, /**< authors */
223 PACKAGE_URL, /**< homepage */
224 sipe_purple_plugin_load, /**< load */
225 sipe_purple_plugin_unload, /**< unload */
226 sipe_purple_plugin_destroy, /**< destroy */
227 NULL, /**< ui_info */
228 &sipe_prpl_info, /**< extra_info */
229 NULL,
230 purple_actions,
231 NULL,
232 NULL,
233 NULL,
234 NULL
237 static void sipe_purple_init_plugin(PurplePlugin *plugin)
239 /* This needs to be called first */
240 sipe_core_init(LOCALEDIR);
242 purple_plugin_register(plugin);
244 sipe_prpl_info.user_splits = g_list_append(sipe_prpl_info.user_splits,
245 sipe_purple_user_split());
247 sipe_prpl_info.protocol_options = sipe_purple_account_options();
250 /* This macro makes the code a purple plugin */
251 PURPLE_INIT_PLUGIN(sipe, sipe_purple_init_plugin, sipe_purple_info);
254 Local Variables:
255 mode: c
256 c-file-style: "bsd"
257 indent-tabs-mode: t
258 tab-width: 8
259 End: