libpurple/protocols/oscar/libaim.c

Fri, 30 Aug 2013 05:50:20 +0530

author
Ankit Vani <a@nevitus.org>
date
Fri, 30 Aug 2013 05:50:20 +0530
branch
soc.2013.gobjectification.plugins
changeset 36613
0e96218aa13a
parent 36590
e77919ff5e74
child 36628
3d43ca8d69ee
permissions
-rw-r--r--

Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured

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
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
42 proto_class->id = AIM_ID;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
43 proto_class->name = AIM_NAME;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
44
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
45 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
46 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
47 }
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
48
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
49 static void
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
50 aim_protocol_interface_init(PurpleProtocolInterface *iface)
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
51 {
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
52 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
53 iface->add_permit = oscar_add_permit;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
54 iface->rem_permit = oscar_rem_permit;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
55 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
56 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
57 }
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
58
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
59 static void aim_protocol_base_finalize(AIMProtocolClass *klass) { }
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
60
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
61 static PurplePluginInfo *
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
62 plugin_query(GError **error)
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
63 {
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
64 return purple_plugin_info_new(
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
65 "id", AIM_ID,
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
66 "name", AIM_NAME,
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
67 "version", DISPLAY_VERSION,
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
68 "category", N_("Protocol"),
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
69 "summary", N_("AIM Protocol Plugin"),
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
70 "description", N_("AIM Protocol Plugin"),
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
71 "website", PURPLE_WEBSITE,
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
72 "abi-version", PURPLE_ABI_VERSION,
36536
07f8c9889257 Added flags to all prpls
Ankit Vani <a@nevitus.org>
parents: 36530
diff changeset
73 "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL |
07f8c9889257 Added flags to all prpls
Ankit Vani <a@nevitus.org>
parents: 36530
diff changeset
74 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
75 NULL
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
76 );
15030
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
77 }
6a6cf7be07ea [gaim-migrate @ 17747]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
78
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
79 static gboolean
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
80 plugin_load(PurplePlugin *plugin, GError **error)
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
81 {
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
82 my_protocol = purple_protocols_add(AIM_TYPE_PROTOCOL);
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
83 if (!my_protocol) {
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
84 g_set_error(error, AIM_DOMAIN, 0, _("Failed to add aim protocol"));
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
85 return FALSE;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
86 }
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
87
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
88 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
89 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
90
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
91 return TRUE;
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
92 }
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
93
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
94 static gboolean
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
95 plugin_unload(PurplePlugin *plugin, GError **error)
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
96 {
36590
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
97 if (!purple_protocols_remove(my_protocol)) {
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
98 g_set_error(error, AIM_DOMAIN, 0, _("Failed to remove aim protocol"));
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
99 return FALSE;
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
100 }
36530
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
101
b8caab360c96 Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 33696
diff changeset
102 return TRUE;
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
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
105 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
106
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 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
108 OSCAR_TYPE_PROTOCOL, 0);
e77919ff5e74 Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
109
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
110 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
111 plugin_unload);

mercurial