Wed, 28 Aug 2013 03:37:22 +0530
Refactored oscar to use the new protocol API
| 15884 | 1 | /* purple |
| 15030 | 2 | * |
| 15884 | 3 | * Purple is the legal property of its developers, whose names are too numerous |
| 15030 | 4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 5 | * source distribution. | |
| 6 | * | |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 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 | 20 | * |
| 21 | */ | |
| 22 | ||
| 30403 | 23 | /* libicq is the ICQ protocol plugin. It is linked against liboscar, |
| 15030 | 24 | * which contains all the shared implementation code with libaim |
| 25 | */ | |
| 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" |
| 15030 | 30 | |
|
36590
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
31 | #include "libicq.h" |
| 15030 | 32 | #include "oscarcommon.h" |
| 33 | ||
|
36590
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
34 | static PurpleProtocol *my_protocol = NULL; |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
35 | |
|
24235
46abfb2f03e4
Show 'ICQ UIN...' and 'Yahoo ID...' in the screenname field
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23277
diff
changeset
|
36 | static GHashTable * |
|
46abfb2f03e4
Show 'ICQ UIN...' and 'Yahoo ID...' in the screenname field
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23277
diff
changeset
|
37 | icq_get_account_text_table(PurpleAccount *account) |
|
46abfb2f03e4
Show 'ICQ UIN...' and 'Yahoo ID...' in the screenname field
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23277
diff
changeset
|
38 | { |
|
46abfb2f03e4
Show 'ICQ UIN...' and 'Yahoo ID...' in the screenname field
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23277
diff
changeset
|
39 | GHashTable *table; |
|
46abfb2f03e4
Show 'ICQ UIN...' and 'Yahoo ID...' in the screenname field
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23277
diff
changeset
|
40 | table = g_hash_table_new(g_str_hash, g_str_equal); |
|
46abfb2f03e4
Show 'ICQ UIN...' and 'Yahoo ID...' in the screenname field
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23277
diff
changeset
|
41 | g_hash_table_insert(table, "login_label", (gpointer)_("ICQ UIN...")); |
|
46abfb2f03e4
Show 'ICQ UIN...' and 'Yahoo ID...' in the screenname field
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23277
diff
changeset
|
42 | return table; |
|
46abfb2f03e4
Show 'ICQ UIN...' and 'Yahoo ID...' in the screenname field
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23277
diff
changeset
|
43 | } |
|
46abfb2f03e4
Show 'ICQ UIN...' and 'Yahoo ID...' in the screenname field
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23277
diff
changeset
|
44 | |
|
34312
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33696
diff
changeset
|
45 | static gsize |
|
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33696
diff
changeset
|
46 | icq_get_max_message_size(PurpleConnection *gc) |
|
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33696
diff
changeset
|
47 | { |
|
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33696
diff
changeset
|
48 | /* got from pidgin-otr */ |
|
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33696
diff
changeset
|
49 | return 2346; |
|
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33696
diff
changeset
|
50 | } |
|
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33696
diff
changeset
|
51 | |
|
36590
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
52 | static void |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
53 | icq_protocol_base_init(ICQProtocolClass *klass) |
| 15030 | 54 | { |
|
36590
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
55 | 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
|
56 | PurpleAccountOption *option; |
|
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 | proto_class->id = ICQ_ID; |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
59 | proto_class->name = ICQ_NAME; |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
60 | |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
61 | option = purple_account_option_string_new(_("Server"), "server", oscar_get_login_server(TRUE, TRUE)); |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
62 | 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
|
63 | |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
64 | option = purple_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
65 | 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
|
66 | } |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
67 | |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
68 | static void |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
69 | icq_protocol_interface_init(PurpleProtocolInterface *iface) |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
70 | { |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
71 | iface->list_icon = oscar_list_icon_icq; |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
72 | iface->get_account_text_table = icq_get_account_text_table; |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
73 | iface->get_moods = oscar_get_purple_moods; |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
74 | iface->get_max_message_size = icq_get_max_message_size; |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
75 | } |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
76 | |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
77 | static void icq_protocol_base_finalize(ICQProtocolClass *klass) { } |
| 15030 | 78 | |
|
36530
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
79 | static PurplePluginInfo * |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
80 | plugin_query(GError **error) |
| 15030 | 81 | { |
|
36530
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
82 | return purple_plugin_info_new( |
|
36590
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
83 | "id", ICQ_ID, |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
84 | "name", ICQ_NAME, |
|
36530
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
85 | "version", DISPLAY_VERSION, |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
86 | "category", N_("Protocol"), |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
87 | "summary", N_("ICQ Protocol Plugin"), |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
88 | "description", N_("ICQ Protocol Plugin"), |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
89 | "website", PURPLE_WEBSITE, |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
90 | "abi-version", PURPLE_ABI_VERSION, |
| 36536 | 91 | "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL | |
| 92 | 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
|
93 | NULL |
|
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 | } |
| 15030 | 96 | |
|
36530
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
97 | static gboolean |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
98 | plugin_load(PurplePlugin *plugin, GError **error) |
| 15030 | 99 | { |
|
36590
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
100 | my_protocol = purple_protocols_add(ICQ_TYPE_PROTOCOL); |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
101 | if (!my_protocol) { |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
102 | g_set_error(error, ICQ_DOMAIN, 0, _("Failed to add icq protocol")); |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
103 | return FALSE; |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
104 | } |
| 15030 | 105 | |
|
36590
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
106 | 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
|
107 | 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
|
108 | |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
109 | return TRUE; |
| 15030 | 110 | } |
| 111 | ||
|
36530
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
112 | static gboolean |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
113 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
114 | { |
|
36590
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
115 | if (!purple_protocols_remove(my_protocol)) { |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
116 | g_set_error(error, ICQ_DOMAIN, 0, _("Failed to remove icq protocol")); |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
117 | return FALSE; |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
118 | } |
|
36530
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
119 | |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
120 | return TRUE; |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
121 | } |
|
b8caab360c96
Refactored oscar to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33696
diff
changeset
|
122 | |
|
36590
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
123 | PURPLE_PROTOCOL_DEFINE_EXTENDED(ICQProtocol, icq_protocol, |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
124 | OSCAR_TYPE_PROTOCOL, 0); |
|
e77919ff5e74
Refactored oscar to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
125 | |
| 36538 | 126 | PURPLE_PLUGIN_INIT(icq, plugin_query, plugin_load, plugin_unload); |