libpurple/protocols/jabber/libfacebook.c

Tue, 27 Aug 2013 04:08:20 +0530

author
Ankit Vani <a@nevitus.org>
date
Tue, 27 Aug 2013 04:08:20 +0530
branch
soc.2013.gobjectification.plugins
changeset 36582
095b9c85c45c
parent 36545
23b59a16c808
child 36583
0582190c9382
permissions
-rw-r--r--

Refactored jabber to use the new protocol API.
XMPPProtocol, GTalkProtocol and FacebookProtocol inherit JabberProtocol.

32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
1 /* purple
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
2 *
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
5 * source distribution.
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
6 *
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
10 * (at your option) any later version.
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
11 *
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
15 * GNU General Public License for more details.
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
16 *
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
20 *
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
21 */
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
22
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
23 /* libfacebook is the Facebook XMPP protocol plugin. It is linked against
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
24 * libjabbercommon, which may be used to support other protocols (Bonjour)
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
25 * which may need to share code.
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
26 */
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
27
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
28 #include "internal.h"
36582
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
29 #include "chat.h"
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
30 #include "core.h"
36509
86e882c3cfdf Refactored libpurple according to the changes
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
31 #include "plugins.h"
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
32
36582
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
33 #include "libfacebook.h"
32927
551b4268afe0 Remove UI hack for XMPP sub-prpls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32926
diff changeset
34
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36525
diff changeset
35 static PurpleProtocol *my_protocol = NULL;
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
36
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
37 static PurpleAccount *find_acct(const char *prpl, const char *acct_id)
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
38 {
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
39 PurpleAccount *acct = NULL;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
40
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
41 /* If we have a specific acct, use it */
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
42 if (acct_id) {
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
43 acct = purple_accounts_find(acct_id, prpl);
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
44 if (acct && !purple_account_is_connected(acct))
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
45 acct = NULL;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
46 } else { /* Otherwise find an active account for the protocol */
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
47 GList *l = purple_accounts_get_all();
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
48 while (l) {
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
49 if (!strcmp(prpl, purple_account_get_protocol_id(l->data))
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
50 && purple_account_is_connected(l->data)) {
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
51 acct = l->data;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
52 break;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
53 }
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
54 l = l->next;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
55 }
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
56 }
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
57
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
58 return acct;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
59 }
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
60
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
61 static gboolean xmpp_uri_handler(const char *proto, const char *user, GHashTable *params)
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
62 {
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
63 char *acct_id = params ? g_hash_table_lookup(params, "account") : NULL;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
64 PurpleAccount *acct;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
65
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
66 if (g_ascii_strcasecmp(proto, "xmpp"))
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
67 return FALSE;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
68
36582
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
69 acct = find_acct(purple_protocol_get_id(my_protocol), acct_id);
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
70
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
71 if (!acct)
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
72 return FALSE;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
73
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
74 /* xmpp:romeo@montague.net?message;subject=Test%20Message;body=Here%27s%20a%20test%20message */
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
75 /* params is NULL if the URI has no '?' (or anything after it) */
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
76 if (!params || g_hash_table_lookup_extended(params, "message", NULL, NULL)) {
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
77 char *body = g_hash_table_lookup(params, "body");
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
78 if (user && *user) {
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34627
diff changeset
79 PurpleIMConversation *im =
34627
08733a7475df Replaced purple_conversation_new() with purple_[im,chat]_conversation_new()
Ankit Vani <a@nevitus.org>
parents: 32937
diff changeset
80 purple_im_conversation_new(acct, user);
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34627
diff changeset
81 purple_conversation_present(PURPLE_CONVERSATION(im));
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
82 if (body && *body)
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34627
diff changeset
83 purple_conversation_send_confirm(PURPLE_CONVERSATION(im), body);
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
84 }
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
85 } else if (g_hash_table_lookup_extended(params, "roster", NULL, NULL)) {
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
86 char *name = g_hash_table_lookup(params, "name");
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
87 if (user && *user)
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
88 purple_blist_request_add_buddy(acct, user, NULL, name);
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
89 } else if (g_hash_table_lookup_extended(params, "join", NULL, NULL)) {
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
90 PurpleConnection *gc = purple_account_get_connection(acct);
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
91 if (user && *user) {
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
92 GHashTable *params = jabber_chat_info_defaults(gc, user);
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
93 jabber_chat_join(gc, params);
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
94 }
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
95 return TRUE;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
96 }
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
97
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
98 return FALSE;
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
99 }
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
100
36582
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
101 static const char *
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
102 facebook_list_icon(PurpleAccount *a, PurpleBuddy *b)
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
103 {
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
104 return "facebook";
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
105 }
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
106
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
107 static void
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
108 facebook_protocol_base_init(FacebookProtocolClass *klass)
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
109 {
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
110 PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_CLASS(klass);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
111 PurpleAccountUserSplit *split;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
112 PurpleAccountOption *option;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
113 GList *encryption_values = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
114
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
115 proto_class->id = FACEBOOK_ID;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
116 proto_class->name = FACEBOOK_NAME;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
117
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
118 /* Translators: 'domain' is used here in the context of Internet domains, e.g. pidgin.im */
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
119 split = purple_account_user_split_new(_("Domain"), "chat.facebook.com", '@');
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
120 purple_account_user_split_set_reverse(split, FALSE);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
121 proto_class->user_splits = g_list_append(proto_class->user_splits, split);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
122
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
123 split = purple_account_user_split_new(_("Resource"), "", '/');
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
124 purple_account_user_split_set_reverse(split, FALSE);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
125 proto_class->user_splits = g_list_append(proto_class->user_splits, split);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
126
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
127 #define ADD_VALUE(list, desc, v) { \
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
128 PurpleKeyValuePair *kvp = g_new0(PurpleKeyValuePair, 1); \
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
129 kvp->key = g_strdup((desc)); \
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
130 kvp->value = g_strdup((v)); \
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
131 list = g_list_prepend(list, kvp); \
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
132 }
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
133
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
134 ADD_VALUE(encryption_values, _("Require encryption"), "require_tls");
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
135 ADD_VALUE(encryption_values, _("Use encryption if available"), "opportunistic_tls");
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
136 ADD_VALUE(encryption_values, _("Use old-style SSL"), "old_ssl");
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
137 #if 0
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
138 ADD_VALUE(encryption_values, "None", "none");
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
139 #endif
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
140 encryption_values = g_list_reverse(encryption_values);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
141
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
142 #undef ADD_VALUE
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
143
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
144 option = purple_account_option_list_new(_("Connection security"), "connection_security", encryption_values);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
145 proto_class->protocol_options = g_list_append(proto_class->protocol_options,
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
146 option);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
147
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
148 option = purple_account_option_bool_new(
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
149 _("Allow plaintext auth over unencrypted streams"),
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
150 "auth_plain_in_clear", FALSE);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
151 proto_class->protocol_options = g_list_append(proto_class->protocol_options,
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
152 option);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
153
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
154 option = purple_account_option_int_new(_("Connect port"), "port", 5222);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
155 proto_class->protocol_options = g_list_append(proto_class->protocol_options,
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
156 option);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
157
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
158 option = purple_account_option_string_new(_("Connect server"),
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
159 "connect_server", NULL);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
160 proto_class->protocol_options = g_list_append(proto_class->protocol_options,
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
161 option);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
162
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
163 option = purple_account_option_string_new(_("BOSH URL"),
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
164 "bosh_url", NULL);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
165 proto_class->protocol_options = g_list_append(proto_class->protocol_options,
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
166 option);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
167
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
168 /* this should probably be part of global smiley theme settings later on,
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
169 shared with MSN */
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
170 option = purple_account_option_bool_new(_("Show Custom Smileys"),
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
171 "custom_smileys", TRUE);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
172 proto_class->protocol_options = g_list_append(proto_class->protocol_options,
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
173 option);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
174 }
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
175
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
176 static void
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
177 facebook_protocol_interface_init(PurpleProtocolInterface *iface)
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
178 {
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
179 iface->list_icon = facebook_list_icon;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
180
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
181 /* disable xmpp functions not available for facebook */
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
182 iface->add_buddy = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
183 iface->remove_buddy = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
184 iface->add_deny = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
185 iface->rem_deny = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
186 iface->register_user = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
187 iface->alias_buddy = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
188 iface->group_buddy = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
189 iface->rename_group = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
190 iface->can_receive_file = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
191 iface->send_file = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
192 iface->new_xfer = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
193 iface->unregister_user = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
194 iface->send_attention = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
195 iface->get_attention_types = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
196 iface->initiate_media = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
197 iface->get_media_caps = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
198 iface->get_moods = NULL;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
199 }
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
200
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
201 static void facebook_protocol_base_finalize(FacebookProtocolClass *klass) { }
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
202
36496
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
203 static PurplePluginInfo *
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
204 plugin_query(GError **error)
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
205 {
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
206 return purple_plugin_info_new(
36582
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
207 "id", FACEBOOK_ID,
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
208 "name", FACEBOOK_NAME,
36496
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
209 "version", DISPLAY_VERSION,
36497
c542ad807256 Forgot flags
Ankit Vani <a@nevitus.org>
parents: 36496
diff changeset
210 "category", N_("Protocol"),
36496
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
211 "summary", N_("Facebook XMPP Protocol Plugin"),
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
212 "description", N_("Facebook XMPP Protocol Plugin"),
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
213 "website", PURPLE_WEBSITE,
36505
60c161851325 Integrated purple ABI requirement into GPlugin's "abi-version" property
Ankit Vani <a@nevitus.org>
parents: 36504
diff changeset
214 "abi-version", PURPLE_ABI_VERSION,
36497
c542ad807256 Forgot flags
Ankit Vani <a@nevitus.org>
parents: 36496
diff changeset
215 "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL |
c542ad807256 Forgot flags
Ankit Vani <a@nevitus.org>
parents: 36496
diff changeset
216 GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY,
36496
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
217 NULL
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
218 );
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
219 }
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
220
36496
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
221 static gboolean
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
222 plugin_load(PurplePlugin *plugin, GError **error)
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
223 {
36582
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
224 my_protocol = purple_protocols_add(FACEBOOK_TYPE_PROTOCOL);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
225 if (!my_protocol) {
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
226 g_set_error(error, FACEBOOK_DOMAIN, 0, _("Failed to add facebook protocol"));
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
227 return FALSE;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
228 }
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
229
36525
ea477f05a2ea Connect signals by protocol instead of plugin
Ankit Vani <a@nevitus.org>
parents: 36509
diff changeset
230 purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
231 PURPLE_CALLBACK(xmpp_uri_handler), NULL);
36496
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
232
36582
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
233 jabber_protocol_init(my_protocol);
36496
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
234 return TRUE;
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
235 }
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
236
36496
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
237 static gboolean
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
238 plugin_unload(PurplePlugin *plugin, GError **error)
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
239 {
36582
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
240 jabber_protocol_uninit(my_protocol);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
241 if (!purple_protocols_remove(my_protocol)) {
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
242 g_set_error(error, FACEBOOK_DOMAIN, 0, _("Failed to remove facebook protocol"));
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
243 return FALSE;
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
244 }
32926
6a06b6cea862 Since XMPP is already a split-prpl thing, make two new prpls for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
245
36496
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
246 return TRUE;
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
247 }
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
248
36582
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
249 PURPLE_PROTOCOL_DEFINE_EXTENDED(FacebookProtocol, facebook_protocol,
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
250 JABBER_TYPE_PROTOCOL, 0);
095b9c85c45c Refactored jabber to use the new protocol API.
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
251
36496
e7fe371c60a6 Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
252 PURPLE_PLUGIN_INIT(facebookxmpp, plugin_query, plugin_load, plugin_unload);

mercurial