purple: fix build when appshare server is disabled
[siplcs.git] / src / purple / purple-plugin.c
blob46d1eef2021e2ee27b67fe5b3addb85676e20732
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
162 #if PURPLE_VERSION_CHECK(2,14,0)
163 NULL, /* get_cb_alias */
164 #endif
166 #ifdef __GNUC__
167 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ >= 5)
168 #pragma GCC diagnostic pop
169 #endif
170 #endif
171 /* Original GCC error checking restored from here on... (see above) */
173 /* PurplePluginInfo function calls & data structure */
174 static void sipe_purple_plugin_destroy(SIPE_UNUSED_PARAMETER PurplePlugin *plugin)
176 GList *entry;
178 sipe_core_destroy();
180 entry = sipe_prpl_info.protocol_options;
181 while (entry) {
182 purple_account_option_destroy(entry->data);
183 entry = g_list_delete_link(entry, entry);
185 sipe_prpl_info.protocol_options = NULL;
187 entry = sipe_prpl_info.user_splits;
188 while (entry) {
189 purple_account_user_split_destroy(entry->data);
190 entry = g_list_delete_link(entry, entry);
192 sipe_prpl_info.user_splits = NULL;
195 static GList *purple_actions(SIPE_UNUSED_PARAMETER PurplePlugin *plugin,
196 SIPE_UNUSED_PARAMETER gpointer context)
198 return sipe_purple_actions();
201 static PurplePluginInfo sipe_purple_info = {
202 PURPLE_PLUGIN_MAGIC,
203 PURPLE_MAJOR_VERSION,
204 PURPLE_MINOR_VERSION,
205 PURPLE_PLUGIN_PROTOCOL, /**< type */
206 NULL, /**< ui_requirement */
207 0, /**< flags */
208 NULL, /**< dependencies */
209 PURPLE_PRIORITY_DEFAULT, /**< priority */
210 SIPE_PURPLE_PLUGIN_ID, /**< id */
211 SIPE_PURPLE_PLUGIN_NAME, /**< name */
212 PACKAGE_VERSION, /**< version */
213 SIPE_PURPLE_PLUGIN_SUMMARY, /**< summary */
214 SIPE_PURPLE_PLUGIN_DESCRIPTION, /**< description */
215 SIPE_PURPLE_PLUGIN_AUTHORS, /**< authors */
216 PACKAGE_URL, /**< homepage */
217 sipe_purple_plugin_load, /**< load */
218 sipe_purple_plugin_unload, /**< unload */
219 sipe_purple_plugin_destroy, /**< destroy */
220 NULL, /**< ui_info */
221 &sipe_prpl_info, /**< extra_info */
222 NULL,
223 purple_actions,
224 NULL,
225 NULL,
226 NULL,
227 NULL
230 static void sipe_purple_init_plugin(PurplePlugin *plugin)
232 /* This needs to be called first */
233 sipe_core_init(LOCALEDIR);
235 purple_plugin_register(plugin);
237 sipe_prpl_info.user_splits = g_list_append(sipe_prpl_info.user_splits,
238 sipe_purple_user_split());
240 sipe_prpl_info.protocol_options = sipe_purple_account_options();
243 /* This macro makes the code a purple plugin */
244 PURPLE_INIT_PLUGIN(sipe, sipe_purple_init_plugin, sipe_purple_info);
247 Local Variables:
248 mode: c
249 c-file-style: "bsd"
250 indent-tabs-mode: t
251 tab-width: 8
252 End: