Welcome to mirror list, hosted at ThFree Co, Russian Federation.

03-plugin.patch « patches - github.com/dequis/purple-facebook.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9a14ef1cc3a8fac245a3302c7255cc06cdc4f831 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
diff -r ad2ee74b913a libpurple/protocols/facebook/facebook.c
--- a/libpurple/protocols/facebook/facebook.c	Thu Jan 07 14:06:04 2016 -0500
+++ b/libpurple/protocols/facebook/facebook.c	Thu Jan 07 16:30:08 2016 -0500
@@ -446,7 +446,7 @@
 	id = purple_image_store_add_weak(pimg);
 
 	g_free(msg->text);
-	msg->text = g_strdup_printf("<img src=\""
+	msg->text = g_strdup_printf("<img id=\""
 	                            PURPLE_IMAGE_STORE_PROTOCOL
 	                            "%u\">", id);
 	msg->flags |= FB_API_MESSAGE_FLAG_DONE;
@@ -836,7 +836,7 @@
 	GSList *select = NULL;
 	PurpleConnection *gc;
 
-	if (!PURPLE_IS_BUDDY(node)) {
+	if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) {
 		return;
 	}
 
@@ -1022,7 +1022,7 @@
 	PurpleConnection *gc;
 	PurpleMenuAction *act;
 
-	if (!PURPLE_IS_BUDDY(node)) {
+	if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) {
 		return NULL;
 	}
 
@@ -1070,7 +1070,8 @@
 }
 
 static gint
-fb_im_send(PurpleConnection *gc, PurpleMessage *msg)
+fb_im_send(PurpleConnection *gc, const gchar *who, const gchar *tmsg,
+           PurpleMessageFlags flags)
 {
 	const gchar *name;
 	const gchar *text;
@@ -1079,6 +1080,8 @@
 	FbId uid;
 	gchar *sext;
 
+	PurpleMessage *msg = purple_message_new_outgoing(who, tmsg, flags);
+
 	fata = purple_connection_get_protocol_data(gc);
 	api = fb_data_get_api(fata);
 
@@ -1217,7 +1220,8 @@
 }
 
 static gint
-fb_chat_send(PurpleConnection *gc, gint id, PurpleMessage *msg)
+fb_chat_send(PurpleConnection *gc, gint id, const gchar *tmsg,
+             PurpleMessageFlags flags)
 {
 	const gchar *name;
 	const gchar *text;
@@ -1228,6 +1232,8 @@
 	PurpleAccount *acct;
 	PurpleChatConversation *chat;
 
+	PurpleMessage *msg = purple_message_new_outgoing(NULL, tmsg, flags);
+
 	acct = purple_connection_get_account(gc);
 	fata = purple_connection_get_protocol_data(gc);
 	api = fb_data_get_api(fata);
@@ -1396,14 +1402,119 @@
 }
 
 static void
-facebook_protocol_init(PurpleProtocol *protocol)
+fb_cmds_register(void)
+{
+	PurpleCmdId id;
+
+	static PurpleCmdFlag cflags =
+		PURPLE_CMD_FLAG_CHAT |
+		PURPLE_CMD_FLAG_PROTOCOL_ONLY;
+
+	g_return_if_fail(fb_cmds == NULL);
+
+	id = purple_cmd_register("kick", "s", PURPLE_CMD_P_PROTOCOL, cflags,
+				 "prpl-facebook", fb_cmd_kick,
+				 _("kick: Kick someone from the chat"),
+				 NULL);
+	fb_cmds = g_slist_prepend(fb_cmds, GUINT_TO_POINTER(id));
+
+	id = purple_cmd_register("leave", "", PURPLE_CMD_P_PROTOCOL, cflags,
+				 "prpl-facebook", fb_cmd_leave,
+				 _("leave: Leave the chat"),
+				 NULL);
+	fb_cmds = g_slist_prepend(fb_cmds, GUINT_TO_POINTER(id));
+}
+
+static void
+fb_cmds_unregister_free(gpointer data)
+{
+	PurpleCmdId id = GPOINTER_TO_UINT(data);
+	purple_cmd_unregister(id);
+}
+
+static void
+fb_cmds_unregister(void)
+{
+	g_slist_free_full(fb_cmds, fb_cmds_unregister_free);
+}
+
+static gboolean
+plugin_load(PurplePlugin *plugin)
+{
+	fb_cmds_register();
+	_purple_socket_init();
+	purple_http_init();
+	return TRUE;
+}
+
+static gboolean
+plugin_unload(PurplePlugin *plugin)
+{
+	fb_cmds_unregister();
+	purple_http_uninit();
+	_purple_socket_uninit();
+	return TRUE;
+}
+
+G_MODULE_EXPORT gboolean
+purple_init_plugin(PurplePlugin *plugin);
+
+G_MODULE_EXPORT gboolean
+purple_init_plugin(PurplePlugin *plugin)
 {
 	GList *opts = NULL;
 	PurpleAccountOption *opt;
 
-	protocol->id      = FB_PROTOCOL_ID;
-	protocol->name    = "Facebook";
-	protocol->options = OPT_PROTO_CHAT_TOPIC;
+	static gboolean inited = FALSE;
+	static PurplePluginInfo info;
+	static PurplePluginProtocolInfo pinfo;
+
+	(void) fb_protocol;
+	plugin->info = &info;
+
+	if (G_LIKELY(inited)) {
+		return purple_plugin_register(plugin);
+	}
+
+	memset(&info, 0, sizeof info);
+	memset(&pinfo, 0, sizeof pinfo);
+
+	info.magic = PURPLE_PLUGIN_MAGIC;
+	info.major_version = PURPLE_MAJOR_VERSION;
+	info.minor_version = PURPLE_MINOR_VERSION;
+	info.type = PURPLE_PLUGIN_PROTOCOL;
+	info.priority = PURPLE_PRIORITY_DEFAULT;
+	info.id = FB_PROTOCOL_ID;
+	info.name = "Facebook";
+	info.version = PACKAGE_VERSION;
+	info.summary = N_("Facebook Protocol Plugin");
+	info.description = N_("Facebook Protocol Plugin");
+	info.homepage = PACKAGE_URL;
+	info.load = plugin_load;
+	info.unload = plugin_unload;
+	info.extra_info = &pinfo;
+
+	pinfo.options = OPT_PROTO_CHAT_TOPIC;
+	pinfo.list_icon = fb_list_icon;
+	pinfo.tooltip_text = fb_client_tooltip_text;
+	pinfo.status_types = fb_status_types;
+	pinfo.blist_node_menu = fb_client_blist_node_menu;
+	pinfo.chat_info = fb_chat_info;
+	pinfo.chat_info_defaults = fb_chat_info_defaults;
+	pinfo.login = fb_login;
+	pinfo.close = fb_close;
+	pinfo.send_im = fb_im_send;
+	pinfo.send_typing = fb_im_send_typing;
+	pinfo.set_status = fb_server_set_status;
+	pinfo.join_chat = fb_chat_join;
+	pinfo.get_chat_name = fb_chat_get_name;
+	pinfo.chat_invite = fb_chat_invite;
+	pinfo.chat_send = fb_chat_send;
+	pinfo.set_chat_topic = fb_chat_set_topic;
+	pinfo.roomlist_get_list = fb_roomlist_get_list;
+	pinfo.roomlist_cancel = fb_roomlist_cancel;
+	pinfo.offline_message = fb_client_offline_message;
+	pinfo.struct_size = sizeof pinfo;
 
 	opt = purple_account_option_int_new(_("Buddy list sync interval"),
 	                                    "sync-interval", 30);
@@ -1425,147 +1536,8 @@
 	                                       "incoming messages"),
 	                                     "group-chat-open", TRUE);
 	opts = g_list_prepend(opts, opt);
-	protocol->account_options = g_list_reverse(opts);
+	pinfo.protocol_options = g_list_reverse(opts);
+
+	inited = TRUE;
+	return purple_plugin_register(plugin);
 }
-
-static void
-facebook_protocol_class_init(PurpleProtocolClass *klass)
-{
-	klass->login        = fb_login;
-	klass->close        = fb_close;
-	klass->status_types = fb_status_types;
-	klass->list_icon    = fb_list_icon;
-}
-
-static void
-facebook_protocol_client_iface_init(PurpleProtocolClientIface *iface)
-{
-	iface->tooltip_text    = fb_client_tooltip_text;
-	iface->blist_node_menu = fb_client_blist_node_menu;
-	iface->offline_message = fb_client_offline_message;
-}
-
-static void
-facebook_protocol_server_iface_init(PurpleProtocolServerIface *iface)
-{
-	iface->set_status = fb_server_set_status;
-}
-
-static void
-facebook_protocol_im_iface_init(PurpleProtocolIMIface *iface)
-{
-	iface->send        = fb_im_send;
-	iface->send_typing = fb_im_send_typing;
-}
-
-static void
-facebook_protocol_chat_iface_init(PurpleProtocolChatIface *iface)
-{
-	iface->info          = fb_chat_info;
-	iface->info_defaults = fb_chat_info_defaults;
-	iface->join          = fb_chat_join;
-	iface->get_name      = fb_chat_get_name;
-	iface->invite        = fb_chat_invite;
-	iface->send          = fb_chat_send;
-	iface->set_topic     = fb_chat_set_topic;
-}
-
-static void
-facebook_protocol_roomlist_iface_init(PurpleProtocolRoomlistIface *iface)
-{
-	iface->get_list = fb_roomlist_get_list;
-	iface->cancel   = fb_roomlist_cancel;
-}
-
-PURPLE_DEFINE_TYPE_EXTENDED(
-	FacebookProtocol, facebook_protocol, PURPLE_TYPE_PROTOCOL, 0,
-
-	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
-	                                  facebook_protocol_client_iface_init)
-	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
-	                                  facebook_protocol_server_iface_init)
-	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE,
-	                                  facebook_protocol_im_iface_init)
-	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE,
-	                                  facebook_protocol_chat_iface_init)
-	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE,
-	                                  facebook_protocol_roomlist_iface_init)
-);
-
-static void
-fb_cmds_register(void)
-{
-	PurpleCmdId id;
-
-	static PurpleCmdFlag cflags =
-		PURPLE_CMD_FLAG_CHAT |
-		PURPLE_CMD_FLAG_PROTOCOL_ONLY;
-
-	g_return_if_fail(fb_cmds == NULL);
-
-	id = purple_cmd_register("kick", "s", PURPLE_CMD_P_PROTOCOL, cflags,
-				 fb_protocol->id, fb_cmd_kick,
-				 _("kick: Kick someone from the chat"),
-				 NULL);
-	fb_cmds = g_slist_prepend(fb_cmds, GUINT_TO_POINTER(id));
-
-	id = purple_cmd_register("leave", "", PURPLE_CMD_P_PROTOCOL, cflags,
-				 fb_protocol->id, fb_cmd_leave,
-				 _("leave: Leave the chat"),
-				 NULL);
-	fb_cmds = g_slist_prepend(fb_cmds, GUINT_TO_POINTER(id));
-}
-
-static void
-fb_cmds_unregister_free(gpointer data)
-{
-	PurpleCmdId id = GPOINTER_TO_UINT(data);
-	purple_cmd_unregister(id);
-}
-
-static void
-fb_cmds_unregister(void)
-{
-	g_slist_free_full(fb_cmds, fb_cmds_unregister_free);
-}
-
-static PurplePluginInfo *
-plugin_query(GError **error)
-{
-	return purple_plugin_info_new(
-		"id",          FB_PROTOCOL_ID,
-		"name",        "Facebook Protocol",
-		"version",     DISPLAY_VERSION,
-		"category",    N_("Protocol"),
-		"summary",     N_("Facebook Protocol Plugin"),
-		"description", N_("Facebook Protocol Plugin"),
-		"website",     PURPLE_WEBSITE,
-		"abi-version", PURPLE_ABI_VERSION,
-		"flags",       PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
-		               PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD,
-		NULL
-	);
-}
-
-static gboolean
-plugin_load(PurplePlugin *plugin, GError **error)
-{
-	facebook_protocol_register_type(plugin);
-	fb_protocol = purple_protocols_add(FACEBOOK_TYPE_PROTOCOL, error);
-
-	if (fb_protocol == NULL) {
-		return FALSE;
-	}
-
-	fb_cmds_register();
-	return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin, GError **error)
-{
-	fb_cmds_unregister();
-	return purple_protocols_remove(fb_protocol, error);
-}
-
-PURPLE_PLUGIN_INIT(facebook, plugin_query, plugin_load, plugin_unload);
diff -r ad2ee74b913a libpurple/protocols/facebook/facebook.h
--- a/libpurple/protocols/facebook/facebook.h	Thu Jan 07 14:06:04 2016 -0500
+++ b/libpurple/protocols/facebook/facebook.h	Thu Jan 07 16:30:08 2016 -0500
@@ -22,24 +22,7 @@
 #ifndef _FACEBOOK_H_
 #define _FACEBOOK_H_
 
-/**
- * SECTION:facebook
- * @section_id: facebook-plugin
- * @short_description: <filename>facebook.h</filename>
- * @title: Facebook Plugin
- *
- * The Facebook Messenger #PurpleProtocol.
- */
-
 #include <glib.h>
-#include <gmodule.h>
-
-#define FACEBOOK_TYPE_PROTOCOL  (facebook_protocol_get_type())
-#define FACEBOOK_PROTOCOL(obj)  (G_TYPE_CHECK_INSTANCE_CAST((obj), FACEBOOK_TYPE_PROTOCOL, FacebookProtocol))
-#define FACEBOOK_PROTOCOL_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST((klass), FACEBOOK_TYPE_PROTOCOL, FacebookProtocolClass))
-#define FACEBOOK_IS_PROTOCOL(obj)  (G_TYPE_CHECK_INSTANCE_TYPE((obj), FACEBOOK_TYPE_PROTOCOL))
-#define FACEBOOK_IS_PROTOCOL_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), FACEBOOK_TYPE_PROTOCOL))
-#define FACEBOOK_PROTOCOL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), FACEBOOK_TYPE_PROTOCOL, FacebookProtocolClass))
 
 /**
  * FB_PROTOCOL_ID:
@@ -48,37 +31,4 @@
  */
 #define FB_PROTOCOL_ID  "prpl-facebook"
 
-typedef struct _FacebookProtocol FacebookProtocol;
-typedef struct _FacebookProtocolClass FacebookProtocolClass;
-
-/**
- * FacebookProtocol:
- *
- * Represents the Facebook #PurpleProtocol.
- */
-struct _FacebookProtocol
-{
-	/*< private >*/
-	PurpleProtocol parent;
-};
-
-/**
- * FacebookProtocolClass:
- *
- * The base class for all #FacebookProtocol's.
- */
-struct _FacebookProtocolClass
-{
-	/*< private >*/
-	PurpleProtocolClass parent_class;
-};
-
-/**
- * facebook_protocol_get_type:
- *
- * Returns: The #GType for a #FacebookProtocol.
- */
-G_MODULE_EXPORT GType
-facebook_protocol_get_type(void);
-
 #endif /* _FACEBOOK_H_ */