libpurple/protocols/oscar/libaim.c

Mon, 02 Sep 2013 03:45:31 +0530

author
Ankit Vani <a@nevitus.org>
date
Mon, 02 Sep 2013 03:45:31 +0530
branch
soc.2013.gobjectification.plugins
changeset 36651
13a650a1dba6
parent 36650
7b581b0a96d4
child 36653
4084c34c051d
permissions
-rw-r--r--

Avoid code duplication this way

15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15685
diff changeset
1 /* purple
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
2 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15685
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
5 * source distribution.
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
6 *
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
10 * (at your option) any later version.
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
11 *
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
15 * GNU General Public License for more details.
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
16 *
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19050
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
20 *
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
21 */
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
22
30402
80efab176d1f Minor comment fix.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 30138
diff changeset
23 /* libaim is the AIM protocol plugin. It is linked against liboscar,
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
24 * which contains all the shared implementation code with libicq
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
25 */
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
26
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
27 #include "core.h"
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
28 #include "plugins.h"
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
29 #include "signals.h"
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
30
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
31 #include "libaim.h"
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
32 #include "oscarcommon.h"
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
33
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
34 static PurpleProtocol *my_protocol = NULL;
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
35
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
36 static void
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
37 aim_protocol_base_init(AIMProtocolClass *klass)
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
38 {
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
39 PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_CLASS(klass);
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
40 PurpleAccountOption *option;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
41
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36628
diff changeset
42 proto_class->id = "aim";
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36628
diff changeset
43 proto_class->name = "AIM";
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
44
36651
13a650a1dba6 Avoid code duplication this way
Ankit Vani <a@nevitus.org>
parents: 36650
diff changeset
45 oscar_init_protocol_options(proto_class);
36650
7b581b0a96d4 Initialize oscar protocol options in libaim and libicq so that they know who they are
Ankit Vani <a@nevitus.org>
parents: 36638
diff changeset
46
7b581b0a96d4 Initialize oscar protocol options in libaim and libicq so that they know who they are
Ankit Vani <a@nevitus.org>
parents: 36638
diff changeset
47 option = purple_account_option_bool_new(_("Allow multiple simultaneous logins"), "allow_multiple_logins",
7b581b0a96d4 Initialize oscar protocol options in libaim and libicq so that they know who they are
Ankit Vani <a@nevitus.org>
parents: 36638
diff changeset
48 OSCAR_DEFAULT_ALLOW_MULTIPLE_LOGINS);
7b581b0a96d4 Initialize oscar protocol options in libaim and libicq so that they know who they are
Ankit Vani <a@nevitus.org>
parents: 36638
diff changeset
49 proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
7b581b0a96d4 Initialize oscar protocol options in libaim and libicq so that they know who they are
Ankit Vani <a@nevitus.org>
parents: 36638
diff changeset
50
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
51 option = purple_account_option_string_new(_("Server"), "server", oscar_get_login_server(FALSE, TRUE));
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
52 proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
53 }
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
54
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
55 static void
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
56 aim_protocol_interface_init(PurpleProtocolInterface *iface)
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
57 {
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
58 iface->list_icon = oscar_list_icon_aim;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
59 iface->add_permit = oscar_add_permit;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
60 iface->rem_permit = oscar_rem_permit;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
61 iface->set_permit_deny = oscar_set_aim_permdeny;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
62 iface->get_max_message_size = oscar_get_max_message_size;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
63 }
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
64
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
65 static void aim_protocol_base_finalize(AIMProtocolClass *klass) { }
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
66
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
67 static PurplePluginInfo *
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
68 plugin_query(GError **error)
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
69 {
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
70 return purple_plugin_info_new(
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36628
diff changeset
71 "id", "protocol-aim",
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36628
diff changeset
72 "name", "AIM Protocol",
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
73 "version", DISPLAY_VERSION,
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
74 "category", N_("Protocol"),
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
75 "summary", N_("AIM Protocol Plugin"),
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
76 "description", N_("AIM Protocol Plugin"),
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
77 "website", PURPLE_WEBSITE,
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
78 "abi-version", PURPLE_ABI_VERSION,
36536
07f8c9889257 Added flags to all prpls
Ankit Vani <a@nevitus.org>
parents: 36530
diff changeset
79 "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL |
07f8c9889257 Added flags to all prpls
Ankit Vani <a@nevitus.org>
parents: 36530
diff changeset
80 GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY,
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
81 NULL
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
82 );
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
83 }
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
84
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
85 static gboolean
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
86 plugin_load(PurplePlugin *plugin, GError **error)
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
87 {
36628
3d43ca8d69ee Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents: 36613
diff changeset
88 my_protocol = purple_protocols_add(AIM_TYPE_PROTOCOL, error);
3d43ca8d69ee Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents: 36613
diff changeset
89 if (!my_protocol)
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
90 return FALSE;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
91
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
92 purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
93 PURPLE_CALLBACK(oscar_uri_handler), NULL);
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
94
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
95 return TRUE;
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
96 }
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
97
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
98 static gboolean
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
99 plugin_unload(PurplePlugin *plugin, GError **error)
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
100 {
36628
3d43ca8d69ee Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents: 36613
diff changeset
101 if (!purple_protocols_remove(my_protocol, error))
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
102 return FALSE;
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
103
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
104 return TRUE;
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
105 }
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
106
36613
0e96218aa13a Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
Ankit Vani <a@nevitus.org>
parents: 36590
diff changeset
107 extern PurplePlugin *_oscar_plugin;
0e96218aa13a Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
Ankit Vani <a@nevitus.org>
parents: 36590
diff changeset
108
0e96218aa13a Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
Ankit Vani <a@nevitus.org>
parents: 36590
diff changeset
109 PURPLE_PROTOCOL_DEFINE_EXTENDED(_oscar_plugin, AIMProtocol, aim_protocol,
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
110 OSCAR_TYPE_PROTOCOL, 0);
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
111
36613
0e96218aa13a Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
Ankit Vani <a@nevitus.org>
parents: 36590
diff changeset
112 PURPLE_PLUGIN_INIT_VAL(_oscar_plugin, aim, plugin_query, plugin_load,
0e96218aa13a Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
Ankit Vani <a@nevitus.org>
parents: 36590
diff changeset
113 plugin_unload);

mercurial