1- diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.c
2- --- a/libpurple/protocols/facebook/facebook.c Mon Dec 21 21:34:55 2015 -0500
3- +++ b/libpurple/protocols/facebook/facebook.c Mon Dec 21 22:02:55 2015 -0500
1+ diff -r ad2ee74b913a libpurple/protocols/facebook/facebook.c
2+ --- a/libpurple/protocols/facebook/facebook.c Thu Jan 07 14:06:04 2016 -0500
3+ +++ b/libpurple/protocols/facebook/facebook.c Thu Jan 07 16:30:08 2016 -0500
44@@ -446,7 +446,7 @@
55 id = purple_image_store_add_weak(pimg);
66
@@ -10,7 +10,7 @@ diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.c
1010 PURPLE_IMAGE_STORE_PROTOCOL
1111 "%u\">", id);
1212 msg->flags |= FB_API_MESSAGE_FLAG_DONE;
13- @@ -825 ,7 +825 ,7 @@
13+ @@ -836 ,7 +836 ,7 @@
1414 GSList *select = NULL;
1515 PurpleConnection *gc;
1616
@@ -19,7 +19,7 @@ diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.c
1919 return;
2020 }
2121
22- @@ -1011 ,7 +1011 ,7 @@
22+ @@ -1022 ,7 +1022 ,7 @@
2323 PurpleConnection *gc;
2424 PurpleMenuAction *act;
2525
@@ -28,7 +28,7 @@ diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.c
2828 return NULL;
2929 }
3030
31- @@ -1059 ,7 +1059 ,8 @@
31+ @@ -1070 ,7 +1070 ,8 @@
3232 }
3333
3434 static gint
@@ -38,7 +38,7 @@ diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.c
3838 {
3939 const gchar *name;
4040 const gchar *text;
41- @@ -1068 ,6 +1069 ,8 @@
41+ @@ -1079 ,6 +1080 ,8 @@
4242 FbId uid;
4343 gchar *sext;
4444
@@ -47,7 +47,7 @@ diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.c
4747 fata = purple_connection_get_protocol_data(gc);
4848 api = fb_data_get_api(fata);
4949
50- @@ -1206 ,7 +1209 ,8 @@
50+ @@ -1217 ,7 +1220 ,8 @@
5151 }
5252
5353 static gint
@@ -57,7 +57,7 @@ diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.c
5757 {
5858 const gchar *name;
5959 const gchar *text;
60- @@ -1217 ,6 +1221 ,8 @@
60+ @@ -1228 ,6 +1232 ,8 @@
6161 PurpleAccount *acct;
6262 PurpleChatConversation *chat;
6363
@@ -66,37 +66,140 @@ diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.c
6666 acct = purple_connection_get_account(gc);
6767 fata = purple_connection_get_protocol_data(gc);
6868 api = fb_data_get_api(fata);
69- @@ -1385,99 +1391,6 @@
69+ @@ -1396,14 +1402,119 @@
7070 }
7171
7272 static void
7373- facebook_protocol_init(PurpleProtocol *protocol)
74- - {
75- - GList *opts = NULL;
76- - PurpleAccountOption *opt;
77- -
74+ + fb_cmds_register(void)
75+ + {
76+ + PurpleCmdId id;
77+ +
78+ + static PurpleCmdFlag cflags =
79+ + PURPLE_CMD_FLAG_CHAT |
80+ + PURPLE_CMD_FLAG_PROTOCOL_ONLY;
81+ +
82+ + g_return_if_fail(fb_cmds == NULL);
83+ +
84+ + id = purple_cmd_register("kick", "s", PURPLE_CMD_P_PROTOCOL, cflags,
85+ + "prpl-facebook", fb_cmd_kick,
86+ + _("kick: Kick someone from the chat"),
87+ + NULL);
88+ + fb_cmds = g_slist_prepend(fb_cmds, GUINT_TO_POINTER(id));
89+ +
90+ + id = purple_cmd_register("leave", "", PURPLE_CMD_P_PROTOCOL, cflags,
91+ + "prpl-facebook", fb_cmd_leave,
92+ + _("leave: Leave the chat"),
93+ + NULL);
94+ + fb_cmds = g_slist_prepend(fb_cmds, GUINT_TO_POINTER(id));
95+ + }
96+ +
97+ + static void
98+ + fb_cmds_unregister_free(gpointer data)
99+ + {
100+ + PurpleCmdId id = GPOINTER_TO_UINT(data);
101+ + purple_cmd_unregister(id);
102+ + }
103+ +
104+ + static void
105+ + fb_cmds_unregister(void)
106+ + {
107+ + g_slist_free_full(fb_cmds, fb_cmds_unregister_free);
108+ + }
109+ +
110+ + static gboolean
111+ + plugin_load(PurplePlugin *plugin)
112+ + {
113+ + fb_cmds_register();
114+ + _purple_socket_init();
115+ + purple_http_init();
116+ + return TRUE;
117+ + }
118+ +
119+ + static gboolean
120+ + plugin_unload(PurplePlugin *plugin)
121+ + {
122+ + fb_cmds_unregister();
123+ + purple_http_uninit();
124+ + _purple_socket_uninit();
125+ + return TRUE;
126+ + }
127+ +
128+ + G_MODULE_EXPORT gboolean
129+ + purple_init_plugin(PurplePlugin *plugin);
130+ +
131+ + G_MODULE_EXPORT gboolean
132+ + purple_init_plugin(PurplePlugin *plugin)
133+ {
134+ GList *opts = NULL;
135+ PurpleAccountOption *opt;
136+
78137- protocol->id = FB_PROTOCOL_ID;
79138- protocol->name = "Facebook";
80139- protocol->options = OPT_PROTO_CHAT_TOPIC;
81- -
82- - opt = purple_account_option_int_new(_("Buddy list sync interval"),
83- - "sync-interval", 30);
84- - opts = g_list_prepend(opts, opt);
85- -
86- - opt = purple_account_option_bool_new(_("Mark messages as read"),
87- - "mark-read", TRUE);
88- - opts = g_list_prepend(opts, opt);
89- -
90- - opt = purple_account_option_bool_new(_("Show unread messages"),
91- - "show-unread", TRUE);
92- - opts = g_list_prepend(opts, opt);
93- -
94- - opt = purple_account_option_bool_new(_("Open new group chats with "
95- - "incoming messages"),
96- - "group-chat-open", TRUE);
97- - opts = g_list_prepend(opts, opt);
140+ + static gboolean inited = FALSE;
141+ + static PurplePluginInfo info;
142+ + static PurplePluginProtocolInfo pinfo;
143+ +
144+ + (void) fb_protocol;
145+ + plugin->info = &info;
146+ +
147+ + if (G_LIKELY(inited)) {
148+ + return purple_plugin_register(plugin);
149+ + }
150+ +
151+ + memset(&info, 0, sizeof info);
152+ + memset(&pinfo, 0, sizeof pinfo);
153+ +
154+ + info.magic = PURPLE_PLUGIN_MAGIC;
155+ + info.major_version = PURPLE_MAJOR_VERSION;
156+ + info.minor_version = PURPLE_MINOR_VERSION;
157+ + info.type = PURPLE_PLUGIN_PROTOCOL;
158+ + info.priority = PURPLE_PRIORITY_DEFAULT;
159+ + info.id = FB_PROTOCOL_ID;
160+ + info.name = "Facebook";
161+ + info.version = PACKAGE_VERSION;
162+ + info.summary = N_("Facebook Protocol Plugin");
163+ + info.description = N_("Facebook Protocol Plugin");
164+ + info.homepage = PACKAGE_URL;
165+ + info.load = plugin_load;
166+ + info.unload = plugin_unload;
167+ + info.extra_info = &pinfo;
168+ +
169+ + pinfo.options = OPT_PROTO_CHAT_TOPIC;
170+ + pinfo.list_icon = fb_list_icon;
171+ + pinfo.tooltip_text = fb_client_tooltip_text;
172+ + pinfo.status_types = fb_status_types;
173+ + pinfo.blist_node_menu = fb_client_blist_node_menu;
174+ + pinfo.chat_info = fb_chat_info;
175+ + pinfo.chat_info_defaults = fb_chat_info_defaults;
176+ + pinfo.login = fb_login;
177+ + pinfo.close = fb_close;
178+ + pinfo.send_im = fb_im_send;
179+ + pinfo.send_typing = fb_im_send_typing;
180+ + pinfo.set_status = fb_server_set_status;
181+ + pinfo.join_chat = fb_chat_join;
182+ + pinfo.get_chat_name = fb_chat_get_name;
183+ + pinfo.chat_invite = fb_chat_invite;
184+ + pinfo.chat_send = fb_chat_send;
185+ + pinfo.set_chat_topic = fb_chat_set_topic;
186+ + pinfo.roomlist_get_list = fb_roomlist_get_list;
187+ + pinfo.roomlist_cancel = fb_roomlist_cancel;
188+ + pinfo.offline_message = fb_client_offline_message;
189+ + pinfo.struct_size = sizeof pinfo;
190+
191+ opt = purple_account_option_int_new(_("Buddy list sync interval"),
192+ "sync-interval", 30);
193+ @@ -1425,147 +1536,8 @@
194+ "incoming messages"),
195+ "group-chat-open", TRUE);
196+ opts = g_list_prepend(opts, opt);
98197- protocol->account_options = g_list_reverse(opts);
99- - }
198+ + pinfo.protocol_options = g_list_reverse(opts);
199+ +
200+ + inited = TRUE;
201+ + return purple_plugin_register(plugin);
202+ }
100203-
101204- static void
102205- facebook_protocol_class_init(PurpleProtocolClass *klass)
@@ -163,34 +266,45 @@ diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.c
163266- );
164267-
165268- static void
166- fb_cmds_register(void)
167- {
168- PurpleCmdId id;
169- @@ -1489,13 +1402,13 @@
170- g_return_if_fail(fb_cmds == NULL);
171-
172- id = purple_cmd_register("kick", "s", PURPLE_CMD_P_PROTOCOL, cflags,
269+ - fb_cmds_register(void)
270+ - {
271+ - PurpleCmdId id;
272+ -
273+ - static PurpleCmdFlag cflags =
274+ - PURPLE_CMD_FLAG_CHAT |
275+ - PURPLE_CMD_FLAG_PROTOCOL_ONLY;
276+ -
277+ - g_return_if_fail(fb_cmds == NULL);
278+ -
279+ - id = purple_cmd_register("kick", "s", PURPLE_CMD_P_PROTOCOL, cflags,
173280- fb_protocol->id, fb_cmd_kick,
174- + "prpl-facebook", fb_cmd_kick,
175- _("kick: Kick someone from the chat"),
176- NULL);
177- fb_cmds = g_slist_prepend(fb_cmds, GUINT_TO_POINTER(id));
178-
179- id = purple_cmd_register("leave", "", PURPLE_CMD_P_PROTOCOL, cflags,
281+ - _("kick: Kick someone from the chat"),
282+ - NULL);
283+ - fb_cmds = g_slist_prepend(fb_cmds, GUINT_TO_POINTER(id));
284+ -
285+ - id = purple_cmd_register("leave", "", PURPLE_CMD_P_PROTOCOL, cflags,
180286- fb_protocol->id, fb_cmd_leave,
181- + "prpl-facebook", fb_cmd_leave,
182- _("leave: Leave the chat"),
183- NULL);
184- fb_cmds = g_slist_prepend(fb_cmds, GUINT_TO_POINTER(id));
185- @@ -1514,43 +1427,102 @@
186- g_slist_free_full(fb_cmds, fb_cmds_unregister_free);
187- }
188-
287+ - _("leave: Leave the chat"),
288+ - NULL);
289+ - fb_cmds = g_slist_prepend(fb_cmds, GUINT_TO_POINTER(id));
290+ - }
291+ -
292+ - static void
293+ - fb_cmds_unregister_free(gpointer data)
294+ - {
295+ - PurpleCmdId id = GPOINTER_TO_UINT(data);
296+ - purple_cmd_unregister(id);
297+ - }
298+ -
299+ - static void
300+ - fb_cmds_unregister(void)
301+ - {
302+ - g_slist_free_full(fb_cmds, fb_cmds_unregister_free);
303+ - }
304+ -
189305- static PurplePluginInfo *
190306- plugin_query(GError **error)
191- + static gboolean
192- + plugin_load(PurplePlugin *plugin)
193- {
307+ - {
194308- return purple_plugin_info_new(
195309- "id", FB_PROTOCOL_ID,
196310- "name", "Facebook Protocol",
@@ -216,108 +330,21 @@ diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.c
216330- return FALSE;
217331- }
218332-
219- fb_cmds_register();
220- + _purple_socket_init();
221- + purple_http_init();
222- return TRUE;
223- }
224-
225- static gboolean
333+ - fb_cmds_register();
334+ - return TRUE;
335+ - }
336+ -
337+ - static gboolean
226338- plugin_unload(PurplePlugin *plugin, GError **error)
227- + plugin_unload(PurplePlugin *plugin)
228- {
229- fb_cmds_unregister();
339+ - {
340+ - fb_cmds_unregister();
230341- return purple_protocols_remove(fb_protocol, error);
231- + purple_http_uninit();
232- + _purple_socket_uninit();
233- + return TRUE;
234- }
235-
342+ - }
343+ -
236344- PURPLE_PLUGIN_INIT(facebook, plugin_query, plugin_load, plugin_unload);
237- + G_MODULE_EXPORT gboolean
238- + purple_init_plugin(PurplePlugin *plugin);
239- +
240- + G_MODULE_EXPORT gboolean
241- + purple_init_plugin(PurplePlugin *plugin)
242- + {
243- + GList *opts = NULL;
244- + PurpleAccountOption *opt;
245- +
246- + static gboolean inited = FALSE;
247- + static PurplePluginInfo info;
248- + static PurplePluginProtocolInfo pinfo;
249- +
250- + (void) fb_protocol;
251- + plugin->info = &info;
252- +
253- + if (G_LIKELY(inited)) {
254- + return purple_plugin_register(plugin);
255- + }
256- +
257- + memset(&info, 0, sizeof info);
258- + memset(&pinfo, 0, sizeof pinfo);
259- +
260- + info.magic = PURPLE_PLUGIN_MAGIC;
261- + info.major_version = PURPLE_MAJOR_VERSION;
262- + info.minor_version = PURPLE_MINOR_VERSION;
263- + info.type = PURPLE_PLUGIN_PROTOCOL;
264- + info.priority = PURPLE_PRIORITY_DEFAULT;
265- + info.id = FB_PROTOCOL_ID;
266- + info.name = "Facebook";
267- + info.version = PACKAGE_VERSION;
268- + info.summary = N_("Facebook Protocol Plugin");
269- + info.description = N_("Facebook Protocol Plugin");
270- + info.homepage = PACKAGE_URL;
271- + info.load = plugin_load;
272- + info.unload = plugin_unload;
273- + info.extra_info = &pinfo;
274- +
275- + pinfo.options = OPT_PROTO_CHAT_TOPIC;
276- + pinfo.list_icon = fb_list_icon;
277- + pinfo.tooltip_text = fb_client_tooltip_text;
278- + pinfo.status_types = fb_status_types;
279- + pinfo.blist_node_menu = fb_client_blist_node_menu;
280- + pinfo.chat_info = fb_chat_info;
281- + pinfo.chat_info_defaults = fb_chat_info_defaults;
282- + pinfo.login = fb_login;
283- + pinfo.close = fb_close;
284- + pinfo.send_im = fb_im_send;
285- + pinfo.send_typing = fb_im_send_typing;
286- + pinfo.set_status = fb_server_set_status;
287- + pinfo.join_chat = fb_chat_join;
288- + pinfo.get_chat_name = fb_chat_get_name;
289- + pinfo.chat_invite = fb_chat_invite;
290- + pinfo.chat_send = fb_chat_send;
291- + pinfo.set_chat_topic = fb_chat_set_topic;
292- + pinfo.roomlist_get_list = fb_roomlist_get_list;
293- + pinfo.roomlist_cancel = fb_roomlist_cancel;
294- + pinfo.offline_message = fb_client_offline_message;
295- + pinfo.struct_size = sizeof pinfo;
296- +
297- + opt = purple_account_option_int_new(_("Buddy list sync interval"),
298- + "sync-interval", 30);
299- + opts = g_list_prepend(opts, opt);
300- +
301- + opt = purple_account_option_bool_new(_("Mark messages as read"),
302- + "mark-read", TRUE);
303- + opts = g_list_prepend(opts, opt);
304- +
305- + opt = purple_account_option_bool_new(_("Show unread messages"),
306- + "show-unread", TRUE);
307- + opts = g_list_prepend(opts, opt);
308- +
309- + opt = purple_account_option_bool_new(_("Open new group chats with "
310- + "incoming messages"),
311- + "group-chat-open", TRUE);
312- + opts = g_list_prepend(opts, opt);
313- + pinfo.protocol_options = g_list_reverse(opts);
314- +
315- + inited = TRUE;
316- + return purple_plugin_register(plugin);
317- + }
318- diff -r 50bb40c42245 libpurple/protocols/facebook/facebook.h
319- --- a/libpurple/protocols/facebook/facebook.h Mon Dec 21 21:34:55 2015 -0500
320- +++ b/libpurple/protocols/facebook/facebook.h Mon Dec 21 22:02:55 2015 -0500
345+ diff -r ad2ee74b913a libpurple/protocols/facebook/facebook.h
346+ --- a/libpurple/protocols/facebook/facebook.h Thu Jan 07 14:06:04 2016 -0500
347+ +++ b/libpurple/protocols/facebook/facebook.h Thu Jan 07 16:30:08 2016 -0500
321348@@ -22,24 +22,7 @@
322349 #ifndef _FACEBOOK_H_
323350 #define _FACEBOOK_H_
0 commit comments