Fri, 30 Aug 2013 05:50:20 +0530
Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
| 10977 | 1 | |
| 2 | /* | |
| 15884 | 3 | Meanwhile Protocol Plugin for Purple |
| 4 | Adds Lotus Sametime support to Purple using the Meanwhile library | |
| 10977 | 5 | |
| 6 | Copyright (C) 2004 Christopher (siege) O'Brien <siege@preoccupied.net> | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
7 | |
| 10977 | 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by | |
| 10 | the Free Software Foundation; either version 2 of the License, or (at | |
| 11 | your option) any later version. | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
12 | |
| 10977 | 13 | This program is distributed in the hope that it will be useful, but |
| 14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 16 | General Public License for more details. | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
17 | |
| 10977 | 18 | You should have received a copy of the GNU General Public License |
| 19 | 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:
19586
diff
changeset
|
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, |
| 10977 | 21 | USA. |
| 22 | */ | |
| 23 | ||
|
28981
4e3922ab4844
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
24 | #include "internal.h" |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
25 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
26 | /* system includes */ |
| 10977 | 27 | #include <stdlib.h> |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
28 | #include <time.h> |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
29 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
30 | /* glib includes */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
31 | #include <glib.h> |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
32 | |
| 15884 | 33 | /* purple includes */ |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
34 | #include "account.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
35 | #include "accountopt.h" |
|
34570
ac513e5901eb
Rename circbuffer files to circularbuffer files to match the object name
Ankit Vani <a@nevitus.org>
parents:
34529
diff
changeset
|
36 | #include "circularbuffer.h" |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
37 | #include "conversation.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
38 | #include "debug.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
39 | #include "ft.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
40 | #include "imgstore.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
41 | #include "mime.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
42 | #include "notify.h" |
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
34865
diff
changeset
|
43 | #include "plugins.h" |
|
36543
a8c3fecee2d3
Renamed prpl.[ch] to protocol.[ch]
Ankit Vani <a@nevitus.org>
parents:
36541
diff
changeset
|
44 | #include "protocol.h" |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
45 | #include "request.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
46 | #include "util.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
47 | #include "version.h" |
| 10977 | 48 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
49 | /* meanwhile includes */ |
| 10977 | 50 | #include <mw_cipher.h> |
| 51 | #include <mw_common.h> | |
| 52 | #include <mw_error.h> | |
| 53 | #include <mw_service.h> | |
| 54 | #include <mw_session.h> | |
| 55 | #include <mw_srvc_aware.h> | |
| 56 | #include <mw_srvc_conf.h> | |
| 57 | #include <mw_srvc_ft.h> | |
| 58 | #include <mw_srvc_im.h> | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
59 | #include <mw_srvc_place.h> |
| 10977 | 60 | #include <mw_srvc_resolve.h> |
| 61 | #include <mw_srvc_store.h> | |
| 62 | #include <mw_st_list.h> | |
| 63 | ||
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
64 | /* plugin includes */ |
| 10977 | 65 | #include "sametime.h" |
| 66 | ||
| 67 | ||
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
68 | static PurpleProtocol *my_protocol = NULL; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
69 | |
| 10977 | 70 | /* considering that there's no display of this information for prpls, |
| 71 | I don't know why I even bother providing these. Oh valiant reader, | |
| 72 | I do it all for you. */ | |
| 73 | /* scratch that, I just added it to the prpl options panel */ | |
|
14052
861fddc53217
[gaim-migrate @ 16563]
Evan Schoenberg <evands@pidgin.im>
parents:
14032
diff
changeset
|
74 | #define PLUGIN_ID "prpl-meanwhile" |
| 10977 | 75 | #define PLUGIN_NAME "Sametime" |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
76 | #define PLUGIN_CATEGORY "Protocol" |
| 10977 | 77 | #define PLUGIN_SUMMARY "Sametime Protocol Plugin" |
| 78 | #define PLUGIN_DESC "Open implementation of a Lotus Sametime client" | |
| 79 | #define PLUGIN_AUTHOR "Christopher (siege) O'Brien <siege@preoccupied.net>" | |
| 80 | #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/" | |
| 81 | ||
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
82 | #define PLUGIN_DOMAIN (g_quark_from_static_string(PLUGIN_ID)) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
83 | |
| 10977 | 84 | |
| 85 | /* plugin preference names */ | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
86 | #define MW_PROTOCOL_OPT_BASE "/plugins/prpl/meanwhile" |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
87 | #define MW_PROTOCOL_OPT_BLIST_ACTION MW_PROTOCOL_OPT_BASE "/blist_action" |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
88 | #define MW_PROTOCOL_OPT_PSYCHIC MW_PROTOCOL_OPT_BASE "/psychic" |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
89 | #define MW_PROTOCOL_OPT_FORCE_LOGIN MW_PROTOCOL_OPT_BASE "/force_login" |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
90 | #define MW_PROTOCOL_OPT_SAVE_DYNAMIC MW_PROTOCOL_OPT_BASE "/save_dynamic" |
| 10977 | 91 | |
| 92 | ||
| 93 | /* stages of connecting-ness */ | |
|
13779
410869639392
[gaim-migrate @ 16189]
Christopher O'Brien <siege@pidgin.im>
parents:
13713
diff
changeset
|
94 | #define MW_CONNECT_STEPS 11 |
| 10977 | 95 | |
| 96 | ||
| 97 | /* stages of conciousness */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
98 | #define MW_STATE_OFFLINE "offline" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
99 | #define MW_STATE_ACTIVE "active" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
100 | #define MW_STATE_AWAY "away" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
101 | #define MW_STATE_BUSY "dnd" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
102 | #define MW_STATE_MESSAGE "message" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
103 | #define MW_STATE_ENLIGHTENED "buddha" |
| 10977 | 104 | |
| 105 | ||
| 106 | /* keys to get/set chat information */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
107 | #define CHAT_KEY_CREATOR "chat.creator" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
108 | #define CHAT_KEY_NAME "chat.name" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
109 | #define CHAT_KEY_TOPIC "chat.topic" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
110 | #define CHAT_KEY_INVITE "chat.invite" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
111 | #define CHAT_KEY_IS_PLACE "chat.is_place" |
| 10977 | 112 | |
| 113 | ||
| 114 | /* key for associating a mwLoginType with a buddy */ | |
| 115 | #define BUDDY_KEY_CLIENT "meanwhile.client" | |
| 116 | ||
| 117 | /* store the remote alias so that we can re-create it easily */ | |
| 118 | #define BUDDY_KEY_NAME "meanwhile.shortname" | |
| 119 | ||
| 120 | /* enum mwSametimeUserType */ | |
| 121 | #define BUDDY_KEY_TYPE "meanwhile.type" | |
| 122 | ||
| 123 | ||
| 124 | /* key for the real group name for a meanwhile group */ | |
| 125 | #define GROUP_KEY_NAME "meanwhile.group" | |
| 126 | ||
| 127 | /* enum mwSametimeGroupType */ | |
| 128 | #define GROUP_KEY_TYPE "meanwhile.type" | |
| 129 | ||
| 130 | /* NAB group owning account */ | |
| 131 | #define GROUP_KEY_OWNER "meanwhile.account" | |
| 132 | ||
| 133 | /* key gtk blist uses to indicate a collapsed group */ | |
| 134 | #define GROUP_KEY_COLLAPSED "collapsed" | |
| 135 | ||
| 136 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
137 | /* verification replacement */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
138 | #define mwSession_NO_SECRET "meanwhile.no_secret" |
| 10977 | 139 | |
| 140 | ||
| 15884 | 141 | /* keys to get/set purple plugin information */ |
| 10977 | 142 | #define MW_KEY_HOST "server" |
| 143 | #define MW_KEY_PORT "port" | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
144 | #define MW_KEY_FORCE "force_login" |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
145 | #define MW_KEY_FAKE_IT "fake_client_id" |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
146 | #define MW_KEY_CLIENT "client_id_val" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
147 | #define MW_KEY_MAJOR "client_major" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
148 | #define MW_KEY_MINOR "client_minor" |
| 10977 | 149 | |
| 150 | ||
| 151 | /** number of seconds from the first blist change before a save to the | |
| 152 | storage service occurs. */ | |
| 153 | #define BLIST_SAVE_SECONDS 15 | |
| 154 | ||
| 155 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
156 | /** the possible buddy list storage settings */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
157 | enum blist_choice { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
158 | blist_choice_LOCAL = 1, /**< local only */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
159 | blist_choice_MERGE = 2, /**< merge from server */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
160 | blist_choice_STORE = 3, /**< merge from and save to server */ |
|
25105
fe13c190ca13
Remove the commas at the end of enumerator lists. This resolves warnings
Florian Quèze <florian@instantbird.org>
parents:
24816
diff
changeset
|
161 | blist_choice_SYNCH = 4 /**< sync with server */ |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
162 | }; |
| 10977 | 163 | |
| 164 | ||
| 165 | /** the default blist storage option */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
166 | #define BLIST_CHOICE_DEFAULT blist_choice_SYNCH |
| 10977 | 167 | |
| 168 | ||
| 169 | /* testing for the above */ | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
170 | #define BLIST_PREF_IS(n) (purple_prefs_get_int(MW_PROTOCOL_OPT_BLIST_ACTION)==(n)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
171 | #define BLIST_PREF_IS_LOCAL() BLIST_PREF_IS(blist_choice_LOCAL) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
172 | #define BLIST_PREF_IS_MERGE() BLIST_PREF_IS(blist_choice_MERGE) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
173 | #define BLIST_PREF_IS_STORE() BLIST_PREF_IS(blist_choice_STORE) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
174 | #define BLIST_PREF_IS_SYNCH() BLIST_PREF_IS(blist_choice_SYNCH) |
| 10977 | 175 | |
| 176 | ||
| 177 | /* debugging output */ | |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
178 | #define DEBUG_ERROR(...) purple_debug_error(G_LOG_DOMAIN, __VA_ARGS__) |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
179 | #define DEBUG_INFO(...) purple_debug_info(G_LOG_DOMAIN, __VA_ARGS__) |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
180 | #define DEBUG_MISC(...) purple_debug_misc(G_LOG_DOMAIN, __VA_ARGS__) |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
181 | #define DEBUG_WARN(...) purple_debug_warning(G_LOG_DOMAIN, __VA_ARGS__) |
| 10977 | 182 | |
| 183 | ||
| 184 | /** ensure non-null strings */ | |
| 185 | #ifndef NSTR | |
| 186 | # define NSTR(str) ((str)? (str): "(null)") | |
| 187 | #endif | |
| 188 | ||
| 189 | ||
| 190 | /** calibrates distinct secure channel nomenclature */ | |
| 191 | static const unsigned char no_secret[] = { | |
| 192 | 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65, | |
| 193 | 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a, | |
| 194 | 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64, | |
| 195 | 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00, | |
| 196 | }; | |
| 197 | ||
| 198 | ||
| 199 | /** handler IDs from g_log_set_handler in mw_plugin_init */ | |
| 200 | static guint log_handler[2] = { 0, 0 }; | |
| 201 | ||
| 202 | ||
| 15884 | 203 | /** the purple plugin data. |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
204 | available as purple_connection_get_protocol_data(gc) and mwSession_getClientData */ |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
205 | struct mwPurpleProtocolData { |
| 10977 | 206 | struct mwSession *session; |
| 207 | ||
| 208 | struct mwServiceAware *srvc_aware; | |
| 209 | struct mwServiceConference *srvc_conf; | |
| 210 | struct mwServiceFileTransfer *srvc_ft; | |
| 211 | struct mwServiceIm *srvc_im; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
212 | struct mwServicePlace *srvc_place; |
| 10977 | 213 | struct mwServiceResolve *srvc_resolve; |
| 214 | struct mwServiceStorage *srvc_store; | |
| 215 | ||
| 15884 | 216 | /** map of PurpleGroup:mwAwareList and mwAwareList:PurpleGroup */ |
| 10977 | 217 | GHashTable *group_list_map; |
| 218 | ||
| 219 | /** event id for the buddy list save callback */ | |
| 220 | guint save_event; | |
| 221 | ||
| 222 | /** socket fd */ | |
| 223 | int socket; | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
224 | guint inpa; /* input watcher */ |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
225 | gint outpa; /* like inpa, but the other way */ |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
226 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
227 | /** circular buffer for outgoing data */ |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
228 | PurpleCircularBuffer *sock_buf; |
| 15884 | 229 | |
| 230 | PurpleConnection *gc; | |
| 10977 | 231 | }; |
| 232 | ||
| 233 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
234 | typedef struct { |
| 15884 | 235 | PurpleBuddy *buddy; |
| 236 | PurpleGroup *group; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
237 | } BuddyAddData; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
238 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
239 | |
| 10977 | 240 | /* blist and aware functions */ |
| 241 | ||
| 15884 | 242 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist); |
| 243 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
244 | static void blist_store(struct mwPurpleProtocolData *pd); |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
245 | |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
246 | static void blist_schedule(struct mwPurpleProtocolData *pd); |
| 15884 | 247 | |
| 248 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 249 | ||
| 250 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 251 | ||
| 252 | static gboolean buddy_is_external(PurpleBuddy *b); | |
| 253 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
254 | static void buddy_add(struct mwPurpleProtocolData *pd, PurpleBuddy *buddy); |
| 15884 | 255 | |
| 256 | static PurpleBuddy * | |
| 257 | buddy_ensure(PurpleConnection *gc, PurpleGroup *group, | |
| 10977 | 258 | struct mwSametimeUser *stuser); |
| 259 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
260 | static void group_add(struct mwPurpleProtocolData *pd, PurpleGroup *group); |
| 15884 | 261 | |
| 262 | static PurpleGroup * | |
| 263 | group_ensure(PurpleConnection *gc, struct mwSametimeGroup *stgroup); | |
| 10977 | 264 | |
| 265 | static struct mwAwareList * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
266 | list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group); |
| 10977 | 267 | |
| 268 | ||
| 269 | /* session functions */ | |
| 270 | ||
| 271 | static struct mwSession * | |
| 15884 | 272 | gc_to_session(PurpleConnection *gc); |
| 273 | ||
| 274 | static PurpleConnection *session_to_gc(struct mwSession *session); | |
| 10977 | 275 | |
| 276 | ||
| 277 | /* conference functions */ | |
| 278 | ||
| 279 | static struct mwConference * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
280 | conf_find_by_id(struct mwPurpleProtocolData *pd, int id); |
| 10977 | 281 | |
| 282 | ||
| 283 | /* conversation functions */ | |
| 284 | ||
| 285 | struct convo_msg { | |
| 286 | enum mwImSendType type; | |
| 287 | gpointer data; | |
| 288 | GDestroyNotify clear; | |
| 289 | }; | |
| 290 | ||
| 291 | ||
| 292 | struct convo_data { | |
| 293 | struct mwConversation *conv; | |
| 294 | GList *queue; /**< outgoing message queue, list of convo_msg */ | |
| 295 | }; | |
| 296 | ||
| 297 | static void convo_data_new(struct mwConversation *conv); | |
| 298 | ||
| 299 | static void convo_data_free(struct convo_data *conv); | |
| 300 | ||
| 301 | static void convo_features(struct mwConversation *conv); | |
| 302 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
303 | static PurpleIMConversation *convo_get_im(struct mwConversation *conv); |
| 10977 | 304 | |
| 305 | ||
|
12629
14aae7d5da6b
[gaim-migrate @ 14965]
Richard Laager <rlaager@pidgin.im>
parents:
12624
diff
changeset
|
306 | /* name and id */ |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
307 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
308 | struct named_id { |
| 10977 | 309 | char *id; |
| 310 | char *name; | |
| 311 | }; | |
| 312 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
313 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
314 | /* connection functions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
315 | |
|
14178
d12b287697c9
[gaim-migrate @ 16750]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
316 | static void connect_cb(gpointer data, gint source, const gchar *error_message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
317 | |
| 10977 | 318 | |
| 319 | /* ----- session ------ */ | |
| 320 | ||
| 321 | ||
| 15884 | 322 | /** resolves a mwSession from a PurpleConnection */ |
| 323 | static struct mwSession *gc_to_session(PurpleConnection *gc) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
324 | struct mwPurpleProtocolData *pd; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
325 | |
| 10977 | 326 | g_return_val_if_fail(gc != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
327 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
328 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 329 | g_return_val_if_fail(pd != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
330 | |
| 10977 | 331 | return pd->session; |
| 332 | } | |
| 333 | ||
| 334 | ||
| 15884 | 335 | /** resolves a PurpleConnection from a mwSession */ |
| 336 | static PurpleConnection *session_to_gc(struct mwSession *session) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
337 | struct mwPurpleProtocolData *pd; |
| 10977 | 338 | |
| 339 | g_return_val_if_fail(session != NULL, NULL); | |
| 340 | ||
| 341 | pd = mwSession_getClientData(session); | |
| 342 | g_return_val_if_fail(pd != NULL, NULL); | |
| 343 | ||
| 344 | return pd->gc; | |
| 345 | } | |
| 346 | ||
| 347 | ||
| 15884 | 348 | static void write_cb(gpointer data, gint source, PurpleInputCondition cond) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
349 | struct mwPurpleProtocolData *pd = data; |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
350 | PurpleCircularBuffer *circ = pd->sock_buf; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
351 | gsize avail; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
352 | int ret; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
353 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
354 | DEBUG_INFO("write_cb\n"); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
355 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
356 | g_return_if_fail(circ != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
357 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
358 | avail = purple_circular_buffer_get_max_read(circ); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
359 | if(BUF_LONG < avail) avail = BUF_LONG; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
360 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
361 | while(avail) { |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
362 | ret = write(pd->socket, purple_circular_buffer_get_output(circ), avail); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
363 | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
364 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
365 | break; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
366 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
367 | purple_circular_buffer_mark_read(circ, ret); |
|
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
368 | avail = purple_circular_buffer_get_max_read(circ); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
369 | if(BUF_LONG < avail) avail = BUF_LONG; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
370 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
371 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
372 | if(! avail) { |
| 15884 | 373 | purple_input_remove(pd->outpa); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
374 | pd->outpa = 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
375 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
376 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
377 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
378 | |
| 10977 | 379 | static int mw_session_io_write(struct mwSession *session, |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
380 | const guchar *buf, gsize len) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
381 | struct mwPurpleProtocolData *pd; |
|
22709
6bd336964410
Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
382 | gssize ret = 0; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
383 | int err = 0; |
| 10977 | 384 | |
| 385 | pd = mwSession_getClientData(session); | |
| 386 | ||
| 387 | /* socket was already closed. */ | |
| 388 | if(pd->socket == 0) | |
| 389 | return 1; | |
| 390 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
391 | if(pd->outpa) { |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
392 | DEBUG_INFO("already pending INPUT_WRITE, buffering\n"); |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
393 | purple_circular_buffer_append(pd->sock_buf, buf, len); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
394 | return 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
395 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
396 | |
| 10977 | 397 | while(len) { |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
398 | ret = write(pd->socket, buf, (len > BUF_LEN)? BUF_LEN: len); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
399 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
400 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
401 | break; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
402 | |
| 10977 | 403 | len -= ret; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
404 | buf += ret; |
| 10977 | 405 | } |
| 406 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
407 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
408 | err = errno; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
409 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
410 | if(err == EAGAIN) { |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
411 | /* append remainder to circular buffer */ |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
412 | DEBUG_INFO("EAGAIN\n"); |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
413 | purple_circular_buffer_append(pd->sock_buf, buf, len); |
| 15884 | 414 | pd->outpa = purple_input_add(pd->socket, PURPLE_INPUT_WRITE, write_cb, pd); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
415 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
416 | } else if(len > 0) { |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
417 | gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
418 | g_strerror(errno)); |
|
22709
6bd336964410
Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
419 | DEBUG_ERROR("write returned %" G_GSSIZE_FORMAT ", %" G_GSIZE_FORMAT |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22277
diff
changeset
|
420 | " bytes left unwritten\n", ret, len); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
421 | purple_connection_error(pd->gc, |
| 21279 | 422 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
423 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
424 | g_free(tmp); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
425 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
426 | #if 0 |
| 10977 | 427 | close(pd->socket); |
| 428 | pd->socket = 0; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
429 | #endif |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
430 | |
| 10977 | 431 | return -1; |
| 432 | } | |
| 433 | ||
| 434 | return 0; | |
| 435 | } | |
| 436 | ||
| 437 | ||
| 438 | static void mw_session_io_close(struct mwSession *session) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
439 | struct mwPurpleProtocolData *pd; |
| 10977 | 440 | |
| 441 | pd = mwSession_getClientData(session); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
442 | g_return_if_fail(pd != NULL); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
443 | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
444 | if(pd->outpa) { |
| 15884 | 445 | purple_input_remove(pd->outpa); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
446 | pd->outpa = 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
447 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
448 | |
| 10977 | 449 | if(pd->socket) { |
| 450 | close(pd->socket); | |
| 451 | pd->socket = 0; | |
| 452 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
453 | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
454 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
455 | purple_input_remove(pd->inpa); |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
456 | pd->inpa = 0; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
457 | } |
| 10977 | 458 | } |
| 459 | ||
| 460 | ||
| 461 | static void mw_session_clear(struct mwSession *session) { | |
| 462 | ; /* nothing for now */ | |
| 463 | } | |
| 464 | ||
| 465 | ||
| 466 | /* ----- aware list ----- */ | |
| 467 | ||
| 468 | ||
| 469 | static void blist_resolve_alias_cb(struct mwServiceResolve *srvc, | |
| 470 | guint32 id, guint32 code, GList *results, | |
| 471 | gpointer data) { | |
| 472 | struct mwResolveResult *result; | |
| 473 | struct mwResolveMatch *match; | |
| 474 | ||
| 475 | g_return_if_fail(results != NULL); | |
| 476 | ||
| 477 | result = results->data; | |
| 478 | g_return_if_fail(result != NULL); | |
| 479 | g_return_if_fail(result->matches != NULL); | |
| 480 | ||
| 481 | match = result->matches->data; | |
| 482 | g_return_if_fail(match != NULL); | |
| 483 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
484 | purple_buddy_set_server_alias(data, match->name); |
| 15884 | 485 | purple_blist_node_set_string(data, BUDDY_KEY_NAME, match->name); |
| 10977 | 486 | } |
| 487 | ||
| 488 | ||
| 489 | static void mw_aware_list_on_aware(struct mwAwareList *list, | |
| 490 | struct mwAwareSnapshot *aware) { | |
| 491 | ||
| 15884 | 492 | PurpleConnection *gc; |
| 493 | PurpleAccount *acct; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
494 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
495 | struct mwPurpleProtocolData *pd; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
496 | guint32 idle; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
497 | guint stat; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
498 | const char *id; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
499 | const char *status = MW_STATE_ACTIVE; |
| 10977 | 500 | |
| 501 | gc = mwAwareList_getClientData(list); | |
| 15884 | 502 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
503 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
504 | pd = purple_connection_get_protocol_data(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
505 | idle = aware->status.time; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
506 | stat = aware->status.status; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
507 | id = aware->id.user; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
508 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
509 | if(idle) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
510 | guint32 idle_len; /*< how long a client has been idle */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
511 | guint32 ugly_idle_len; /*< how long a broken client has been idle */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
512 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
513 | DEBUG_INFO("%s has idle value 0x%x\n", NSTR(id), idle); |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
514 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
515 | idle_len = time(NULL) - idle; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
516 | ugly_idle_len = ((time(NULL) * 1000) - idle) / 1000; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
517 | |
|
25181
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
518 | if(idle > ugly_idle_len) |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
519 | ugly_idle_len = 0; |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
520 | else |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
521 | ugly_idle_len = (ugly_idle_len - idle) / 1000; |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
522 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
523 | /* |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
524 | what's the deal here? Well, good clients are smart enough to |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
525 | publish their idle time by using an attribute to indicate that |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
526 | they went idle at some time UTC, in seconds since epoch. Bad |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
527 | clients use milliseconds since epoch. So we're going to compute |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
528 | the idle time for either method, then figure out the lower of |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
529 | the two and use that. Blame the ST 7.5 development team for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
530 | this. |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
531 | */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
532 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
533 | DEBUG_INFO("idle time: %u, ugly idle time: %u\n", idle_len, ugly_idle_len); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
534 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
535 | #if 1 |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
536 | if(idle_len <= ugly_idle_len) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
537 | ; /* DEBUG_INFO("sane idle value, let's use it\n"); */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
538 | } else { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
539 | idle = time(NULL) - ugly_idle_len; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
540 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
541 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
542 | #else |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
543 | if(idle < 0 || idle > time(NULL)) { |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
544 | DEBUG_INFO("hiding a messy idle value 0x%x\n", NSTR(id), idle); |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
545 | idle = -1; |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
546 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
547 | #endif |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
548 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
549 | |
| 10977 | 550 | switch(stat) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
551 | case mwStatus_ACTIVE: |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
552 | status = MW_STATE_ACTIVE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
553 | idle = 0; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
554 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
555 | |
| 10977 | 556 | case mwStatus_IDLE: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
557 | if(! idle) idle = -1; |
| 10977 | 558 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
559 | |
| 10977 | 560 | case mwStatus_AWAY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
561 | status = MW_STATE_AWAY; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
562 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
563 | |
| 10977 | 564 | case mwStatus_BUSY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
565 | status = MW_STATE_BUSY; |
| 10977 | 566 | break; |
| 567 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
568 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
569 | /* NAB group members */ |
| 10977 | 570 | if(aware->group) { |
| 15884 | 571 | PurpleGroup *group; |
| 572 | PurpleBuddy *buddy; | |
| 573 | PurpleBlistNode *bnode; | |
| 10977 | 574 | |
| 575 | group = g_hash_table_lookup(pd->group_list_map, list); | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
576 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 15884 | 577 | bnode = (PurpleBlistNode *) buddy; |
| 10977 | 578 | |
| 579 | if(! buddy) { | |
| 580 | struct mwServiceResolve *srvc; | |
| 581 | GList *query; | |
| 582 | ||
| 15884 | 583 | buddy = purple_buddy_new(acct, id, NULL); |
| 584 | purple_blist_add_buddy(buddy, NULL, group, NULL); | |
| 585 | ||
| 586 | bnode = (PurpleBlistNode *) buddy; | |
| 10977 | 587 | |
| 588 | srvc = pd->srvc_resolve; | |
| 589 | query = g_list_append(NULL, (char *) id); | |
| 590 | ||
| 591 | mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS, | |
| 592 | blist_resolve_alias_cb, buddy, NULL); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
593 | g_list_free(query); |
| 10977 | 594 | } |
| 595 | ||
| 15884 | 596 | purple_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL); |
| 10977 | 597 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
598 | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
599 | if(aware->online) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
600 | purple_protocol_got_user_status(acct, id, status, NULL); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
601 | purple_protocol_got_user_idle(acct, id, !!idle, (time_t) idle); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
602 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
603 | } else { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
604 | purple_protocol_got_user_status(acct, id, MW_STATE_OFFLINE, NULL); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
605 | } |
| 10977 | 606 | } |
| 607 | ||
| 608 | ||
| 609 | static void mw_aware_list_on_attrib(struct mwAwareList *list, | |
| 610 | struct mwAwareIdBlock *id, | |
| 611 | struct mwAwareAttribute *attrib) { | |
| 612 | ||
| 613 | ; /* nothing. We'll get attribute data as we need it */ | |
| 614 | } | |
| 615 | ||
| 616 | ||
| 617 | static void mw_aware_list_clear(struct mwAwareList *list) { | |
| 618 | ; /* nothing for now */ | |
| 619 | } | |
| 620 | ||
| 621 | ||
| 622 | static struct mwAwareListHandler mw_aware_list_handler = { | |
|
17157
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
623 | mw_aware_list_on_aware, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
624 | mw_aware_list_on_attrib, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
625 | mw_aware_list_clear, |
| 10977 | 626 | }; |
| 627 | ||
| 628 | ||
| 629 | /** Ensures that an Aware List is associated with the given group, and | |
| 630 | returns that list. */ | |
| 631 | static struct mwAwareList * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
632 | list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
633 | |
| 10977 | 634 | struct mwAwareList *list; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
635 | |
| 10977 | 636 | g_return_val_if_fail(pd != NULL, NULL); |
| 637 | g_return_val_if_fail(group != NULL, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
638 | |
| 10977 | 639 | list = g_hash_table_lookup(pd->group_list_map, group); |
| 640 | if(! list) { | |
| 641 | list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler); | |
| 642 | mwAwareList_setClientData(list, pd->gc, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
643 | |
| 10977 | 644 | mwAwareList_watchAttributes(list, |
| 645 | mwAttribute_AV_PREFS_SET, | |
| 646 | mwAttribute_MICROPHONE, | |
| 647 | mwAttribute_SPEAKERS, | |
| 648 | mwAttribute_VIDEO_CAMERA, | |
| 649 | mwAttribute_FILE_TRANSFER, | |
| 650 | NULL); | |
| 651 | ||
| 652 | g_hash_table_replace(pd->group_list_map, group, list); | |
| 653 | g_hash_table_insert(pd->group_list_map, list, group); | |
| 654 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
655 | |
| 10977 | 656 | return list; |
| 657 | } | |
| 658 | ||
| 659 | ||
| 15884 | 660 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 10977 | 661 | /* - find the account for this connection |
| 662 | - iterate through the buddy list | |
| 663 | - add each buddy matching this account to the stlist | |
| 664 | */ | |
| 665 | ||
| 15884 | 666 | PurpleAccount *acct; |
| 667 | PurpleBlistNode *gn, *cn, *bn; | |
| 668 | PurpleGroup *grp; | |
| 669 | PurpleBuddy *bdy; | |
| 10977 | 670 | |
| 671 | struct mwSametimeGroup *stg = NULL; | |
| 672 | struct mwIdBlock idb = { NULL, NULL }; | |
| 673 | ||
| 15884 | 674 | acct = purple_connection_get_account(gc); |
| 10977 | 675 | g_return_if_fail(acct != NULL); |
| 676 | ||
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
677 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
678 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 10977 | 679 | const char *owner; |
| 680 | const char *gname; | |
| 681 | enum mwSametimeGroupType gtype; | |
| 682 | gboolean gopen; | |
| 683 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
684 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 685 | grp = (PurpleGroup *) gn; |
| 10977 | 686 | |
| 687 | /* the group's type (normal or dynamic) */ | |
| 15884 | 688 | gtype = purple_blist_node_get_int(gn, GROUP_KEY_TYPE); |
| 10977 | 689 | if(! gtype) gtype = mwSametimeGroup_NORMAL; |
| 690 | ||
| 691 | /* if it's a normal group with none of our people in it, skip it */ | |
| 15884 | 692 | if(gtype == mwSametimeGroup_NORMAL && !purple_group_on_account(grp, acct)) |
| 10977 | 693 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
694 | |
| 10977 | 695 | /* if the group has an owner and we're not it, skip it */ |
| 15884 | 696 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
| 697 | if(owner && strcmp(owner, purple_account_get_username(acct))) | |
| 10977 | 698 | continue; |
| 699 | ||
| 15884 | 700 | /* the group's actual name may be different from the purple group's |
| 10977 | 701 | name. Find whichever is there */ |
| 15884 | 702 | gname = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
703 | if(! gname) gname = purple_group_get_name(grp); |
| 10977 | 704 | |
| 705 | /* we save this, but never actually honor it */ | |
| 15884 | 706 | gopen = ! purple_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); |
| 10977 | 707 | |
| 708 | stg = mwSametimeGroup_new(stlist, gtype, gname); | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
709 | mwSametimeGroup_setAlias(stg, purple_group_get_name(grp)); |
| 10977 | 710 | mwSametimeGroup_setOpen(stg, gopen); |
| 711 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
712 | /* don't attempt to put buddies in a dynamic group, it breaks |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
713 | other clients */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
714 | if(gtype == mwSametimeGroup_DYNAMIC) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
715 | continue; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
716 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
717 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
718 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
719 | cn = purple_blist_node_get_sibling_next(cn)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
720 | if(! PURPLE_IS_CONTACT(cn)) continue; |
| 10977 | 721 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
722 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
723 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
724 | bn = purple_blist_node_get_sibling_next(bn)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
725 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
34865
764a33b41ac7
Renamed blist node's dont_save to transient.
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
726 | if(purple_blist_node_is_transient(bn)) continue; |
| 15884 | 727 | |
| 728 | bdy = (PurpleBuddy *) bn; | |
| 10977 | 729 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
730 | if(purple_buddy_get_account(bdy) == acct) { |
| 10977 | 731 | struct mwSametimeUser *stu; |
| 732 | enum mwSametimeUserType utype; | |
| 733 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
734 | idb.user = (char *)purple_buddy_get_name(bdy); |
| 10977 | 735 | |
| 15884 | 736 | utype = purple_blist_node_get_int(bn, BUDDY_KEY_TYPE); |
| 10977 | 737 | if(! utype) utype = mwSametimeUser_NORMAL; |
| 738 | ||
| 739 | stu = mwSametimeUser_new(stg, utype, &idb); | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
740 | mwSametimeUser_setShortName(stu, purple_buddy_get_server_alias(bdy)); |
|
34717
b3e588adef5a
Global replace purple_buddy_get_local_buddy_alias() with purple_buddy_get_local_alias()
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
741 | mwSametimeUser_setAlias(stu, purple_buddy_get_local_alias(bdy)); |
| 10977 | 742 | } |
| 743 | } | |
| 744 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
745 | } |
| 10977 | 746 | } |
| 747 | ||
| 748 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
749 | static void blist_store(struct mwPurpleProtocolData *pd) { |
| 10977 | 750 | |
| 751 | struct mwSametimeList *stlist; | |
| 752 | struct mwServiceStorage *srvc; | |
| 753 | struct mwStorageUnit *unit; | |
| 754 | ||
| 15884 | 755 | PurpleConnection *gc; |
| 10977 | 756 | |
| 757 | struct mwPutBuffer *b; | |
| 758 | struct mwOpaque *o; | |
| 759 | ||
| 760 | g_return_if_fail(pd != NULL); | |
| 761 | ||
| 762 | srvc = pd->srvc_store; | |
| 763 | g_return_if_fail(srvc != NULL); | |
| 764 | ||
| 765 | gc = pd->gc; | |
| 766 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
767 | if(BLIST_PREF_IS_LOCAL() || BLIST_PREF_IS_MERGE()) { |
| 10977 | 768 | DEBUG_INFO("preferences indicate not to save remote blist\n"); |
| 769 | return; | |
| 770 | ||
| 771 | } else if(MW_SERVICE_IS_DEAD(srvc)) { | |
| 772 | DEBUG_INFO("aborting save of blist: storage service is not alive\n"); | |
| 773 | return; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
774 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
775 | } else if(BLIST_PREF_IS_STORE() || BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
776 | DEBUG_INFO("saving remote blist\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
777 | |
| 10977 | 778 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
779 | g_return_if_reached(); |
| 10977 | 780 | } |
| 781 | ||
| 782 | /* create and export to a list object */ | |
| 783 | stlist = mwSametimeList_new(); | |
| 784 | blist_export(gc, stlist); | |
| 785 | ||
| 786 | /* write it to a buffer */ | |
| 787 | b = mwPutBuffer_new(); | |
| 788 | mwSametimeList_put(b, stlist); | |
| 789 | mwSametimeList_free(stlist); | |
| 790 | ||
| 791 | /* put the buffer contents into a storage unit */ | |
| 792 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
| 793 | o = mwStorageUnit_asOpaque(unit); | |
| 794 | mwPutBuffer_finalize(o, b); | |
| 795 | ||
| 796 | /* save the storage unit to the service */ | |
| 797 | mwServiceStorage_save(srvc, unit, NULL, NULL, NULL); | |
| 798 | } | |
| 799 | ||
| 800 | ||
| 801 | static gboolean blist_save_cb(gpointer data) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
802 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 803 | |
| 804 | blist_store(pd); | |
| 805 | pd->save_event = 0; | |
| 806 | return FALSE; | |
| 807 | } | |
| 808 | ||
| 809 | ||
| 810 | /** schedules the buddy list to be saved to the server */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
811 | static void blist_schedule(struct mwPurpleProtocolData *pd) { |
| 10977 | 812 | if(pd->save_event) return; |
| 813 | ||
|
25716
1b5be208d5ba
applied changes from a336cc1fd3a1ce815f97303b8d5ae8988f8cbd5b
Ethan Blanton <elb@pidgin.im>
parents:
25292
diff
changeset
|
814 | pd->save_event = purple_timeout_add_seconds(BLIST_SAVE_SECONDS, |
| 10977 | 815 | blist_save_cb, pd); |
| 816 | } | |
| 817 | ||
| 818 | ||
| 15884 | 819 | static gboolean buddy_is_external(PurpleBuddy *b) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
820 | g_return_val_if_fail(b != NULL, FALSE); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
821 | return purple_str_has_prefix(purple_buddy_get_name(b), "@E "); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
822 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
823 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
824 | |
| 10977 | 825 | /** Actually add a buddy to the aware service, and schedule the buddy |
| 826 | list to be saved to the server */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
827 | static void buddy_add(struct mwPurpleProtocolData *pd, |
| 15884 | 828 | PurpleBuddy *buddy) { |
| 10977 | 829 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
830 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) purple_buddy_get_name(buddy), NULL }; |
| 10977 | 831 | struct mwAwareList *list; |
| 832 | ||
| 15884 | 833 | PurpleGroup *group; |
| 10977 | 834 | GList *add; |
| 835 | ||
| 836 | add = g_list_prepend(NULL, &idb); | |
| 837 | ||
| 15884 | 838 | group = purple_buddy_get_group(buddy); |
| 10977 | 839 | list = list_ensure(pd, group); |
| 840 | ||
| 841 | if(mwAwareList_addAware(list, add)) { | |
| 15884 | 842 | purple_blist_remove_buddy(buddy); |
| 10977 | 843 | } |
| 844 | ||
| 845 | blist_schedule(pd); | |
| 846 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
847 | g_list_free(add); |
| 10977 | 848 | } |
| 849 | ||
| 850 | ||
| 15884 | 851 | /** ensure that a PurpleBuddy exists in the group with data |
| 10977 | 852 | appropriately matching the st user entry from the st list */ |
| 15884 | 853 | static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, |
| 10977 | 854 | struct mwSametimeUser *stuser) { |
| 855 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
856 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 857 | PurpleBuddy *buddy; |
| 858 | PurpleAccount *acct = purple_connection_get_account(gc); | |
| 10977 | 859 | |
| 860 | const char *id = mwSametimeUser_getUser(stuser); | |
| 861 | const char *name = mwSametimeUser_getShortName(stuser); | |
| 862 | const char *alias = mwSametimeUser_getAlias(stuser); | |
| 863 | enum mwSametimeUserType type = mwSametimeUser_getType(stuser); | |
| 864 | ||
| 865 | g_return_val_if_fail(id != NULL, NULL); | |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
866 | g_return_val_if_fail(*id, NULL); |
| 10977 | 867 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
868 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 10977 | 869 | if(! buddy) { |
| 15884 | 870 | buddy = purple_buddy_new(acct, id, alias); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
871 | |
| 15884 | 872 | purple_blist_add_buddy(buddy, NULL, group, NULL); |
| 10977 | 873 | buddy_add(pd, buddy); |
| 874 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
875 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
876 | purple_buddy_set_local_alias(buddy, alias); |
|
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
877 | purple_buddy_set_server_alias(buddy, name); |
| 15884 | 878 | purple_blist_node_set_string((PurpleBlistNode *) buddy, BUDDY_KEY_NAME, name); |
| 879 | purple_blist_node_set_int((PurpleBlistNode *) buddy, BUDDY_KEY_TYPE, type); | |
| 10977 | 880 | |
| 881 | return buddy; | |
| 882 | } | |
| 883 | ||
| 884 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
885 | /** add aware watch for a dynamic group */ |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
886 | static void group_add(struct mwPurpleProtocolData *pd, |
| 15884 | 887 | PurpleGroup *group) { |
| 10977 | 888 | |
| 889 | struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL }; | |
| 890 | struct mwAwareList *list; | |
| 891 | const char *n; | |
| 892 | GList *add; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
893 | |
| 15884 | 894 | n = purple_blist_node_get_string((PurpleBlistNode *) group, GROUP_KEY_NAME); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
895 | if(! n) n = purple_group_get_name(group); |
| 10977 | 896 | |
| 897 | idb.user = (char *) n; | |
| 898 | add = g_list_prepend(NULL, &idb); | |
| 899 | ||
| 900 | list = list_ensure(pd, group); | |
| 901 | mwAwareList_addAware(list, add); | |
| 902 | g_list_free(add); | |
| 903 | } | |
| 904 | ||
| 905 | ||
| 15884 | 906 | /** ensure that a PurpleGroup exists in the blist with data |
| 10977 | 907 | appropriately matching the st group entry from the st list */ |
| 15884 | 908 | static PurpleGroup *group_ensure(PurpleConnection *gc, |
| 10977 | 909 | struct mwSametimeGroup *stgroup) { |
| 15884 | 910 | PurpleAccount *acct; |
| 911 | PurpleGroup *group = NULL; | |
| 912 | PurpleBuddyList *blist; | |
| 913 | PurpleBlistNode *gn; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
914 | const char *name, *alias, *owner; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
915 | enum mwSametimeGroupType type; |
| 10977 | 916 | |
| 15884 | 917 | acct = purple_connection_get_account(gc); |
| 918 | owner = purple_account_get_username(acct); | |
| 919 | ||
|
34726
af52ff6660c0
Replaced purple_get_blist() with purple_blist_get_buddy_list()
Ankit Vani <a@nevitus.org>
parents:
34723
diff
changeset
|
920 | blist = purple_blist_get_buddy_list(); |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
921 | g_return_val_if_fail(blist != NULL, NULL); |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
922 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
923 | name = mwSametimeGroup_getName(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
924 | alias = mwSametimeGroup_getAlias(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
925 | type = mwSametimeGroup_getType(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
926 | |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
927 | if (!name) { |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
928 | DEBUG_WARN("Can't ensure a null group\n"); |
|
31991
efe4fb3772ad
Fix this compile warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
31983
diff
changeset
|
929 | return NULL; |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
930 | } |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
931 | |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
932 | if (!name) { |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
933 | DEBUG_WARN("Can't ensure a null group\n"); |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
934 | return NULL; |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
935 | } |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
936 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
937 | DEBUG_INFO("attempting to ensure group %s, called %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
938 | NSTR(name), NSTR(alias)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
939 | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
940 | /* first attempt at finding the group, by the name key */ |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
941 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
942 | gn = purple_blist_node_get_sibling_next(gn)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
943 | const char *n, *o; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
944 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 945 | n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
| 946 | o = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
947 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
948 | DEBUG_INFO("found group named %s, owned by %s\n", NSTR(n), NSTR(o)); |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
949 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
950 | if(n && !strcmp(n, name)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
951 | if(!o || !strcmp(o, owner)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
952 | DEBUG_INFO("that'll work\n"); |
| 15884 | 953 | group = (PurpleGroup *) gn; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
954 | break; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
955 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
956 | } |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
957 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
958 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
959 | /* try again, by alias */ |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
960 | if(! group) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
961 | DEBUG_INFO("searching for group by alias %s\n", NSTR(alias)); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
962 | group = purple_blist_find_group(alias); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
963 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
964 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
965 | /* oh well, no such group. Let's create it! */ |
| 10977 | 966 | if(! group) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
967 | DEBUG_INFO("creating group\n"); |
| 15884 | 968 | group = purple_group_new(alias); |
| 969 | purple_blist_add_group(group, NULL); | |
| 10977 | 970 | } |
| 971 | ||
| 15884 | 972 | gn = (PurpleBlistNode *) group; |
| 973 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); | |
| 974 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | |
| 10977 | 975 | |
| 976 | if(type == mwSametimeGroup_DYNAMIC) { | |
| 15884 | 977 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
978 | group_add(purple_connection_get_protocol_data(gc), group); |
| 10977 | 979 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
980 | |
| 10977 | 981 | return group; |
| 982 | } | |
| 983 | ||
| 984 | ||
| 15884 | 985 | /** merge the entries from a st list into the purple blist */ |
| 986 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist) { | |
| 10977 | 987 | struct mwSametimeGroup *stgroup; |
| 988 | struct mwSametimeUser *stuser; | |
| 989 | ||
| 15884 | 990 | PurpleGroup *group; |
| 10977 | 991 | |
| 992 | GList *gl, *gtl, *ul, *utl; | |
| 993 | ||
| 994 | gl = gtl = mwSametimeList_getGroups(stlist); | |
| 995 | for(; gl; gl = gl->next) { | |
| 996 | ||
| 997 | stgroup = (struct mwSametimeGroup *) gl->data; | |
| 998 | group = group_ensure(gc, stgroup); | |
| 999 | ||
| 1000 | ul = utl = mwSametimeGroup_getUsers(stgroup); | |
| 1001 | for(; ul; ul = ul->next) { | |
| 1002 | ||
| 1003 | stuser = (struct mwSametimeUser *) ul->data; | |
|
33782
1690e0b2c508
Fix a bunch of unused variables
Daniel Atallah <datallah@pidgin.im>
parents:
33745
diff
changeset
|
1004 | buddy_ensure(gc, group, stuser); |
| 10977 | 1005 | } |
| 1006 | g_list_free(utl); | |
| 1007 | } | |
| 1008 | g_list_free(gtl); | |
| 1009 | } | |
| 1010 | ||
| 1011 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1012 | /** remove all buddies on account from group. If del is TRUE and group |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1013 | is left empty, remove group as well */ |
| 15884 | 1014 | static void group_clear(PurpleGroup *group, PurpleAccount *acct, gboolean del) { |
| 1015 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1016 | GList *prune = NULL; |
| 15884 | 1017 | PurpleBlistNode *gn, *cn, *bn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1018 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1019 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1020 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1021 | DEBUG_INFO("clearing members from pruned group %s\n", NSTR(purple_group_get_name(group))); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1022 | |
| 15884 | 1023 | gc = purple_account_get_connection(acct); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1024 | g_return_if_fail(gc != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1025 | |
| 15884 | 1026 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1027 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1028 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1029 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1030 | cn = purple_blist_node_get_sibling_next(cn)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1031 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1032 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1033 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1034 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1035 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1036 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1037 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1038 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1039 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1040 | if(purple_buddy_get_account(gb) == acct) { |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1041 | DEBUG_INFO("clearing %s from group\n", NSTR(purple_buddy_get_name(gb))); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1042 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1043 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1044 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1045 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1046 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1047 | /* quickly unsubscribe from presence for the entire group */ |
| 15884 | 1048 | purple_account_remove_group(acct, group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1049 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1050 | /* remove blist entries that need to go */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1051 | while(prune) { |
| 15884 | 1052 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1053 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1054 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1055 | DEBUG_INFO("cleared buddies\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1056 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1057 | /* optionally remove group from blist */ |
|
34723
b496dd569514
Refactored libpurple plugins and protocols according to the blist API changes
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
1058 | if(del && !purple_counting_node_get_total_size(PURPLE_COUNTING_NODE(group))) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1059 | DEBUG_INFO("removing empty group\n"); |
| 15884 | 1060 | purple_blist_remove_group(group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1061 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1062 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1063 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1064 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1065 | /** prune out group members that shouldn't be there */ |
| 15884 | 1066 | static void group_prune(PurpleConnection *gc, PurpleGroup *group, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1067 | struct mwSametimeGroup *stgroup) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1068 | |
| 15884 | 1069 | PurpleAccount *acct; |
| 1070 | PurpleBlistNode *gn, *cn, *bn; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1071 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1072 | GHashTable *stusers; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1073 | GList *prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1074 | GList *ul, *utl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1075 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1076 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1077 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1078 | DEBUG_INFO("pruning membership of group %s\n", NSTR(purple_group_get_name(group))); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1079 | |
| 15884 | 1080 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1081 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1082 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1083 | stusers = g_hash_table_new(g_str_hash, g_str_equal); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1084 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1085 | /* build a hash table for quick lookup while pruning the group |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1086 | contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1087 | utl = mwSametimeGroup_getUsers(stgroup); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1088 | for(ul = utl; ul; ul = ul->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1089 | const char *id = mwSametimeUser_getUser(ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1090 | g_hash_table_insert(stusers, (char *) id, ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1091 | DEBUG_INFO("server copy has %s\n", NSTR(id)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1092 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1093 | g_list_free(utl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1094 | |
| 15884 | 1095 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1096 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1097 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1098 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1099 | cn = purple_blist_node_get_sibling_next(cn)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1100 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1101 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1102 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1103 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1104 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1105 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1106 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1107 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1108 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1109 | /* if the account is correct and they're not in our table, mark |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1110 | them for pruning */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1111 | if(purple_buddy_get_account(gb) == acct && !g_hash_table_lookup(stusers, purple_buddy_get_name(gb))) { |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1112 | DEBUG_INFO("marking %s for pruning\n", NSTR(purple_buddy_get_name(gb))); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1113 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1114 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1115 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1116 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1117 | DEBUG_INFO("done marking\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1118 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1119 | g_hash_table_destroy(stusers); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1120 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1121 | if(prune) { |
| 15884 | 1122 | purple_account_remove_buddies(acct, prune, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1123 | while(prune) { |
| 15884 | 1124 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1125 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1126 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1127 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1128 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1129 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1130 | |
| 15884 | 1131 | /** synch the entries from a st list into the purple blist, removing any |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1132 | existing buddies that aren't in the st list */ |
| 15884 | 1133 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 1134 | ||
| 1135 | PurpleAccount *acct; | |
| 1136 | PurpleBuddyList *blist; | |
| 1137 | PurpleBlistNode *gn; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1138 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1139 | GHashTable *stgroups; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1140 | GList *g_prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1141 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1142 | GList *gl, *gtl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1143 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1144 | const char *acct_n; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1145 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1146 | DEBUG_INFO("synchronizing local buddy list from server list\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1147 | |
| 15884 | 1148 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1149 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1150 | |
| 15884 | 1151 | acct_n = purple_account_get_username(acct); |
| 1152 | ||
|
34726
af52ff6660c0
Replaced purple_get_blist() with purple_blist_get_buddy_list()
Ankit Vani <a@nevitus.org>
parents:
34723
diff
changeset
|
1153 | blist = purple_blist_get_buddy_list(); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1154 | g_return_if_fail(blist != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1155 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1156 | /* build a hash table for quick lookup while pruning the local |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1157 | list, mapping group name to group structure */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1158 | stgroups = g_hash_table_new(g_str_hash, g_str_equal); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1159 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1160 | gtl = mwSametimeList_getGroups(stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1161 | for(gl = gtl; gl; gl = gl->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1162 | const char *name = mwSametimeGroup_getName(gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1163 | g_hash_table_insert(stgroups, (char *) name, gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1164 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1165 | g_list_free(gtl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1166 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1167 | /* find all groups which should be pruned from the local list */ |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1168 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1169 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 15884 | 1170 | PurpleGroup *grp = (PurpleGroup *) gn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1171 | const char *gname, *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1172 | struct mwSametimeGroup *stgrp; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1173 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1174 | if(! PURPLE_IS_GROUP(gn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1175 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1176 | /* group not belonging to this account */ |
| 15884 | 1177 | if(! purple_group_on_account(grp, acct)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1178 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1179 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1180 | /* dynamic group belonging to this account. don't prune contents */ |
| 15884 | 1181 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1182 | if(owner && !strcmp(owner, acct_n)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1183 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1184 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1185 | /* we actually are synching by this key as opposed to the group |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1186 | title, which can be different things in the st list */ |
| 15884 | 1187 | gname = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1188 | if(! gname) gname = purple_group_get_name(grp); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1189 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1190 | stgrp = g_hash_table_lookup(stgroups, gname); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1191 | if(! stgrp) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1192 | /* remove the whole group */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1193 | DEBUG_INFO("marking group %s for pruning\n", purple_group_get_name(grp)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1194 | g_prune = g_list_prepend(g_prune, grp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1195 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1196 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1197 | /* synch the group contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1198 | group_prune(gc, grp, stgrp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1199 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1200 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1201 | DEBUG_INFO("done marking groups\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1202 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1203 | /* don't need this anymore */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1204 | g_hash_table_destroy(stgroups); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1205 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1206 | /* prune all marked groups */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1207 | while(g_prune) { |
| 15884 | 1208 | PurpleGroup *grp = g_prune->data; |
| 1209 | PurpleBlistNode *gn = (PurpleBlistNode *) grp; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1210 | const char *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1211 | gboolean del = TRUE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1212 | |
| 15884 | 1213 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1214 | if(owner && strcmp(owner, acct_n)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1215 | /* it's a specialty group belonging to another account with some |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1216 | of our members in it, so don't fully delete it */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1217 | del = FALSE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1218 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1219 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1220 | group_clear(g_prune->data, acct, del); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1221 | g_prune = g_list_delete_link(g_prune, g_prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1222 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1223 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1224 | /* done with the pruning, let's merge in the additions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1225 | blist_merge(gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1226 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1227 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1228 | |
| 10977 | 1229 | /** callback passed to the storage service when it's told to load the |
| 1230 | st list */ | |
| 1231 | static void fetch_blist_cb(struct mwServiceStorage *srvc, | |
| 1232 | guint32 result, struct mwStorageUnit *item, | |
| 1233 | gpointer data) { | |
| 1234 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1235 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 1236 | struct mwSametimeList *stlist; |
| 1237 | ||
| 1238 | struct mwGetBuffer *b; | |
| 1239 | ||
| 1240 | g_return_if_fail(result == ERR_SUCCESS); | |
| 1241 | ||
| 1242 | /* check our preferences for loading */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1243 | if(BLIST_PREF_IS_LOCAL()) { |
| 10977 | 1244 | DEBUG_INFO("preferences indicate not to load remote buddy list\n"); |
| 1245 | return; | |
| 1246 | } | |
| 1247 | ||
| 1248 | b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); | |
| 1249 | ||
| 1250 | stlist = mwSametimeList_new(); | |
| 1251 | mwSametimeList_get(b, stlist); | |
| 1252 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1253 | /* merge or synch depending on preferences */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1254 | if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1255 | blist_merge(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1256 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1257 | } else if(BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1258 | blist_sync(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1259 | } |
| 10977 | 1260 | |
| 1261 | mwSametimeList_free(stlist); | |
| 22973 | 1262 | mwGetBuffer_free(b); |
| 10977 | 1263 | } |
| 1264 | ||
| 1265 | ||
| 15884 | 1266 | /** signal triggered when a conversation is opened in Purple */ |
| 1267 | static void conversation_created_cb(PurpleConversation *g_conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1268 | struct mwPurpleProtocolData *pd) { |
| 10977 | 1269 | |
| 1270 | /* we need to tell the IM service to negotiate features for the | |
| 1271 | conversation right away, otherwise it'll wait until the first | |
| 1272 | message is sent before offering NotesBuddy features. Therefore | |
| 15884 | 1273 | whenever Purple creates a conversation, we'll immediately open the |
| 10977 | 1274 | channel to the other side and figure out what the target can |
| 1275 | handle. Unfortunately, this makes us vulnerable to Psychic Mode, | |
| 1276 | whereas a more lazy negotiation based on the first message | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1277 | would not */ |
| 10977 | 1278 | |
| 15884 | 1279 | PurpleConnection *gc; |
| 10977 | 1280 | struct mwIdBlock who = { 0, 0 }; |
| 1281 | struct mwConversation *conv; | |
| 1282 | ||
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1283 | gc = purple_conversation_get_connection(g_conv); |
| 10977 | 1284 | if(pd->gc != gc) |
| 1285 | return; /* not ours */ | |
| 1286 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1287 | if(PURPLE_IS_CHAT_CONVERSATION(g_conv)) |
| 10977 | 1288 | return; /* wrong type */ |
| 1289 | ||
| 15884 | 1290 | who.user = (char *) purple_conversation_get_name(g_conv); |
| 10977 | 1291 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 1292 | ||
| 1293 | convo_features(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1294 | |
| 10977 | 1295 | if(mwConversation_isClosed(conv)) |
| 1296 | mwConversation_open(conv); | |
| 1297 | } | |
| 1298 | ||
| 1299 | ||
| 15884 | 1300 | static void blist_menu_nab(PurpleBlistNode *node, gpointer data) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1301 | struct mwPurpleProtocolData *pd = data; |
| 15884 | 1302 | PurpleConnection *gc; |
| 1303 | ||
| 1304 | PurpleGroup *group = (PurpleGroup *) node; | |
| 10977 | 1305 | |
| 1306 | GString *str; | |
| 1307 | char *tmp; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1308 | const char *gname; |
| 10977 | 1309 | |
| 1310 | g_return_if_fail(pd != NULL); | |
| 1311 | ||
| 1312 | gc = pd->gc; | |
| 1313 | g_return_if_fail(gc != NULL); | |
| 1314 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1315 | g_return_if_fail(PURPLE_IS_GROUP(node)); |
| 10977 | 1316 | |
| 1317 | str = g_string_new(NULL); | |
| 1318 | ||
| 15884 | 1319 | tmp = (char *) purple_blist_node_get_string(node, GROUP_KEY_NAME); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1320 | gname = purple_group_get_name(group); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1321 | |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1322 | g_string_append_printf(str, _("<b>Group Title:</b> %s<br>"), gname); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1323 | g_string_append_printf(str, _("<b>Notes Group ID:</b> %s<br>"), tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1324 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1325 | tmp = g_strdup_printf(_("Info for Group %s"), gname); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1326 | |
| 15884 | 1327 | purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
| 10977 | 1328 | NULL, str->str, NULL, NULL); |
| 1329 | ||
| 1330 | g_free(tmp); | |
| 1331 | g_string_free(str, TRUE); | |
| 1332 | } | |
| 1333 | ||
| 1334 | ||
| 1335 | /** The normal blist menu prpl function doesn't get called for groups, | |
| 1336 | so we use the blist-node-extended-menu signal to trigger this | |
| 1337 | handler */ | |
| 15884 | 1338 | static void blist_node_menu_cb(PurpleBlistNode *node, |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1339 | GList **menu, struct mwPurpleProtocolData *pd) { |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1340 | const char *owner; |
| 15884 | 1341 | PurpleAccount *acct; |
| 1342 | PurpleMenuAction *act; | |
| 10977 | 1343 | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1344 | /* we only want groups */ |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1345 | if(! PURPLE_IS_GROUP(node)) return; |
| 15884 | 1346 | |
| 1347 | acct = purple_connection_get_account(pd->gc); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1348 | g_return_if_fail(acct != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1349 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1350 | /* better make sure we're connected */ |
| 15884 | 1351 | if(! purple_account_is_connected(acct)) return; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1352 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1353 | #if 0 |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1354 | /* if there's anyone in the group for this acct, offer to invite |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1355 | them all to a conference */ |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
1356 | group = (PurpleGroup *) node; |
| 15884 | 1357 | if(purple_group_on_account(group, acct)) { |
| 1358 | act = purple_menu_action_new(_("Invite Group to Conference..."), | |
| 1359 | PURPLE_CALLBACK(blist_menu_group_invite), | |
| 13021 | 1360 | pd, NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1361 | *menu = g_list_append(*menu, NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1362 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1363 | #endif |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1364 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1365 | /* check if it's a NAB group for this account */ |
| 15884 | 1366 | owner = purple_blist_node_get_string(node, GROUP_KEY_OWNER); |
| 1367 | if(owner && !strcmp(owner, purple_account_get_username(acct))) { | |
| 1368 | act = purple_menu_action_new(_("Get Notes Address Book Info"), | |
| 1369 | PURPLE_CALLBACK(blist_menu_nab), pd, NULL); | |
| 10977 | 1370 | *menu = g_list_append(*menu, act); |
| 1371 | } | |
| 1372 | } | |
| 1373 | ||
| 1374 | ||
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1375 | /* lifted this from oldstatus, since HEAD doesn't do this at login |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1376 | anymore. */ |
| 15884 | 1377 | static void blist_init(PurpleAccount *acct) { |
| 1378 | PurpleBlistNode *gnode, *cnode, *bnode; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1379 | GList *add_buds = NULL; |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1380 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1381 | for(gnode = purple_blist_get_root(); gnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1382 | gnode = purple_blist_node_get_sibling_next(gnode)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1383 | if(! PURPLE_IS_GROUP(gnode)) continue; |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1384 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1385 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1386 | cnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1387 | cnode = purple_blist_node_get_sibling_next(cnode)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1388 | if(! PURPLE_IS_CONTACT(cnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1389 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1390 | for(bnode = purple_blist_node_get_first_child(cnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1391 | bnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1392 | bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 15884 | 1393 | PurpleBuddy *b; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1394 | if(!PURPLE_IS_BUDDY(bnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1395 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1396 | |
| 15884 | 1397 | b = (PurpleBuddy *)bnode; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1398 | if(purple_buddy_get_account(b) == acct) { |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1399 | add_buds = g_list_append(add_buds, b); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1400 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1401 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1402 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1403 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1404 | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1405 | if(add_buds) { |
|
32319
ab70b05e538b
sametime: fix build (add_buddies added param)
Paul Aurich <darkrain42@pidgin.im>
parents:
32316
diff
changeset
|
1406 | purple_account_add_buddies(acct, add_buds, NULL); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1407 | g_list_free(add_buds); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1408 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1409 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1410 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1411 | |
| 10977 | 1412 | /** Last thing to happen from a started session */ |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1413 | static void services_starting(struct mwPurpleProtocolData *pd) { |
| 15884 | 1414 | |
| 1415 | PurpleConnection *gc; | |
| 1416 | PurpleAccount *acct; | |
| 10977 | 1417 | struct mwStorageUnit *unit; |
| 15884 | 1418 | PurpleBlistNode *l; |
| 10977 | 1419 | |
| 1420 | gc = pd->gc; | |
| 15884 | 1421 | acct = purple_connection_get_account(gc); |
| 10977 | 1422 | |
| 1423 | /* grab the buddy list from the server */ | |
| 1424 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1425 | mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
| 10977 | 1426 | |
| 1427 | /* find all the NAB groups and subscribe to them */ | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1428 | for(l = purple_blist_get_root(); l; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1429 | l = purple_blist_node_get_sibling_next(l)) { |
| 15884 | 1430 | PurpleGroup *group = (PurpleGroup *) l; |
| 10977 | 1431 | enum mwSametimeGroupType gt; |
| 1432 | const char *owner; | |
| 1433 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1434 | if(! PURPLE_IS_GROUP(l)) continue; |
| 10977 | 1435 | |
| 1436 | /* if the group is ownerless, or has an owner and we're not it, | |
| 1437 | skip it */ | |
| 15884 | 1438 | owner = purple_blist_node_get_string(l, GROUP_KEY_OWNER); |
| 1439 | if(!owner || strcmp(owner, purple_account_get_username(acct))) | |
| 10977 | 1440 | continue; |
| 1441 | ||
| 15884 | 1442 | gt = purple_blist_node_get_int(l, GROUP_KEY_TYPE); |
| 10977 | 1443 | if(gt == mwSametimeGroup_DYNAMIC) |
| 1444 | group_add(pd, group); | |
| 1445 | } | |
| 1446 | ||
| 1447 | /* set the aware attributes */ | |
| 1448 | /* indicate we understand what AV prefs are, but don't support any */ | |
| 1449 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1450 | mwAttribute_AV_PREFS_SET, TRUE); | |
| 1451 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE); | |
| 1452 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS); | |
| 1453 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA); | |
| 1454 | ||
| 1455 | /* ... but we can do file transfers! */ | |
| 1456 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1457 | mwAttribute_FILE_TRANSFER, TRUE); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1458 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1459 | blist_init(acct); |
| 10977 | 1460 | } |
| 1461 | ||
| 1462 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1463 | static void session_loginRedirect(struct mwSession *session, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1464 | const char *host) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1465 | struct mwPurpleProtocolData *pd; |
| 15884 | 1466 | PurpleConnection *gc; |
| 1467 | PurpleAccount *account; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1468 | guint port; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1469 | const char *current_host; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1470 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1471 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1472 | gc = pd->gc; |
| 15884 | 1473 | account = purple_connection_get_account(gc); |
| 1474 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); | |
| 1475 | current_host = purple_account_get_string(account, MW_KEY_HOST, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1476 | MW_PLUGIN_DEFAULT_HOST); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1477 | |
| 15884 | 1478 | if(purple_account_get_bool(account, MW_KEY_FORCE, FALSE) || |
|
24739
35f208241e4c
Patch from Raiko Nitzsche to fix a crash when processing a LOGIN_REDIRECT with unexpected output. References #7563.
Daniel Atallah <datallah@pidgin.im>
parents:
24591
diff
changeset
|
1479 | !host || (! strcmp(current_host, host)) || |
|
27343
8a367ee70456
Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents:
26752
diff
changeset
|
1480 | (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1481 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1482 | /* if we're configured to force logins, or if we're being |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1483 | redirected to the already configured host, or if we couldn't |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1484 | connect to the new host, we'll force the login instead */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1485 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1486 | mwSession_forceLogin(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1487 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1488 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1489 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1490 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1491 | static void mw_protocol_set_status(PurpleAccount *acct, PurpleStatus *status); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1492 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1493 | |
| 10977 | 1494 | /** called from mw_session_stateChange when the session's state is |
| 1495 | mwSession_STARTED. Any finalizing of start-up stuff should go | |
| 1496 | here */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1497 | static void session_started(struct mwPurpleProtocolData *pd) { |
| 15884 | 1498 | PurpleStatus *status; |
| 1499 | PurpleAccount *acct; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1500 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1501 | /* set out initial status */ |
| 15884 | 1502 | acct = purple_connection_get_account(pd->gc); |
| 1503 | status = purple_account_get_active_status(acct); | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1504 | mw_protocol_set_status(acct, status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1505 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1506 | /* start watching for new conversations */ |
| 15884 | 1507 | purple_signal_connect(purple_conversations_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1508 | "conversation-created", pd, |
| 15884 | 1509 | PURPLE_CALLBACK(conversation_created_cb), pd); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1510 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1511 | /* watch for group extended menu items */ |
| 15884 | 1512 | purple_signal_connect(purple_blist_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1513 | "blist-node-extended-menu", pd, |
| 15884 | 1514 | PURPLE_CALLBACK(blist_node_menu_cb), pd); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1515 | |
| 10977 | 1516 | /* use our services to do neat things */ |
| 1517 | services_starting(pd); | |
| 1518 | } | |
| 1519 | ||
| 1520 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1521 | static void session_stopping(struct mwPurpleProtocolData *pd) { |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1522 | /* stop watching the signals from session_started */ |
| 15884 | 1523 | purple_signals_disconnect_by_handle(pd); |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1524 | } |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1525 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1526 | |
| 10977 | 1527 | static void mw_session_stateChange(struct mwSession *session, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1528 | enum mwSessionState state, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1529 | gpointer info) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1530 | struct mwPurpleProtocolData *pd; |
| 15884 | 1531 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1532 | const char *msg = NULL; |
| 10977 | 1533 | |
| 1534 | pd = mwSession_getClientData(session); | |
| 1535 | gc = pd->gc; | |
| 1536 | ||
| 1537 | switch(state) { | |
| 1538 | case mwSession_STARTING: | |
| 1539 | msg = _("Sending Handshake"); | |
| 15884 | 1540 | purple_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS); |
| 10977 | 1541 | break; |
| 1542 | ||
| 1543 | case mwSession_HANDSHAKE: | |
| 1544 | msg = _("Waiting for Handshake Acknowledgement"); | |
| 15884 | 1545 | purple_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS); |
| 10977 | 1546 | break; |
| 1547 | ||
| 1548 | case mwSession_HANDSHAKE_ACK: | |
| 1549 | msg = _("Handshake Acknowledged, Sending Login"); | |
| 15884 | 1550 | purple_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS); |
| 10977 | 1551 | break; |
| 1552 | ||
| 1553 | case mwSession_LOGIN: | |
| 1554 | msg = _("Waiting for Login Acknowledgement"); | |
| 15884 | 1555 | purple_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS); |
| 10977 | 1556 | break; |
| 1557 | ||
| 1558 | case mwSession_LOGIN_REDIR: | |
| 1559 | msg = _("Login Redirected"); | |
| 15884 | 1560 | purple_connection_update_progress(gc, msg, 6, MW_CONNECT_STEPS); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1561 | session_loginRedirect(session, info); |
| 10977 | 1562 | break; |
| 1563 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1564 | case mwSession_LOGIN_CONT: |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1565 | msg = _("Forcing Login"); |
| 15884 | 1566 | purple_connection_update_progress(gc, msg, 7, MW_CONNECT_STEPS); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1567 | |
| 10977 | 1568 | case mwSession_LOGIN_ACK: |
| 1569 | msg = _("Login Acknowledged"); | |
| 15884 | 1570 | purple_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS); |
| 10977 | 1571 | break; |
| 1572 | ||
| 1573 | case mwSession_STARTED: | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1574 | msg = _("Starting Services"); |
| 15884 | 1575 | purple_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS); |
| 10977 | 1576 | |
| 1577 | session_started(pd); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1578 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1579 | msg = _("Connected"); |
| 15884 | 1580 | purple_connection_update_progress(gc, msg, 10, MW_CONNECT_STEPS); |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1581 | purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED); |
| 10977 | 1582 | break; |
| 1583 | ||
| 1584 | case mwSession_STOPPING: | |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1585 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1586 | session_stopping(pd); |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1587 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1588 | if(GPOINTER_TO_UINT(info) & ERR_FAILURE) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1589 | char *err = mwError(GPOINTER_TO_UINT(info)); |
| 21279 | 1590 | PurpleConnectionError reason; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1591 | switch (GPOINTER_TO_UINT(info)) { |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1592 | case VERSION_MISMATCH: |
| 21279 | 1593 | reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1594 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1595 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1596 | case USER_RESTRICTED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1597 | case INCORRECT_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1598 | case USER_UNREGISTERED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1599 | case GUEST_IN_USE: |
| 21279 | 1600 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1601 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1602 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1603 | case ENCRYPT_MISMATCH: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1604 | case ERR_ENCRYPT_NO_SUPPORT: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1605 | case ERR_NO_COMMON_ENCRYPT: |
| 21279 | 1606 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1607 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1608 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1609 | case VERIFICATION_DOWN: |
| 21279 | 1610 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1611 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1612 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1613 | case MULTI_SERVER_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1614 | case MULTI_SERVER_LOGIN2: |
| 21279 | 1615 | reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1616 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1617 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1618 | default: |
| 21279 | 1619 | reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1620 | } |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1621 | purple_connection_error(gc, reason, err); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1622 | g_free(err); |
| 10977 | 1623 | } |
| 1624 | break; | |
| 1625 | ||
| 1626 | case mwSession_STOPPED: | |
| 1627 | break; | |
| 1628 | ||
| 1629 | case mwSession_UNKNOWN: | |
| 1630 | default: | |
| 1631 | DEBUG_WARN("session in unknown state\n"); | |
| 1632 | } | |
| 1633 | } | |
| 1634 | ||
| 1635 | ||
| 1636 | static void mw_session_setPrivacyInfo(struct mwSession *session) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1637 | struct mwPurpleProtocolData *pd; |
| 15884 | 1638 | PurpleConnection *gc; |
| 1639 | PurpleAccount *acct; | |
| 10977 | 1640 | struct mwPrivacyInfo *privacy; |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1641 | GSList *list; |
| 10977 | 1642 | guint count; |
| 1643 | ||
| 1644 | DEBUG_INFO("privacy information set from server\n"); | |
| 1645 | ||
| 1646 | g_return_if_fail(session != NULL); | |
| 1647 | ||
| 1648 | pd = mwSession_getClientData(session); | |
| 1649 | g_return_if_fail(pd != NULL); | |
| 1650 | ||
| 1651 | gc = pd->gc; | |
| 1652 | g_return_if_fail(gc != NULL); | |
| 1653 | ||
| 15884 | 1654 | acct = purple_connection_get_account(gc); |
| 10977 | 1655 | g_return_if_fail(acct != NULL); |
| 1656 | ||
| 1657 | privacy = mwSession_getPrivacyInfo(session); | |
| 1658 | count = privacy->count; | |
| 1659 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1660 | if (privacy->deny) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1661 | while ((list = purple_account_privacy_get_denied(acct))) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1662 | g_free(list->data); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1663 | purple_account_privacy_deny_remove(acct, list->data, TRUE); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1664 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1665 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1666 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1667 | purple_account_privacy_deny_add(acct, u->id, TRUE); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1668 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1669 | } else { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1670 | while ((list = purple_account_privacy_get_permitted(acct))) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1671 | g_free(list->data); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1672 | purple_account_privacy_permit_remove(acct, list->data, TRUE); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1673 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1674 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1675 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1676 | purple_account_privacy_permit_add(acct, u->id, TRUE); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1677 | } |
| 10977 | 1678 | } |
| 1679 | } | |
| 1680 | ||
| 1681 | ||
| 1682 | static void mw_session_setUserStatus(struct mwSession *session) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1683 | struct mwPurpleProtocolData *pd; |
| 15884 | 1684 | PurpleConnection *gc; |
| 10977 | 1685 | struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL }; |
| 1686 | struct mwUserStatus *stat; | |
| 1687 | ||
| 1688 | g_return_if_fail(session != NULL); | |
| 1689 | ||
| 1690 | pd = mwSession_getClientData(session); | |
| 1691 | g_return_if_fail(pd != NULL); | |
| 1692 | ||
| 1693 | gc = pd->gc; | |
| 1694 | g_return_if_fail(gc != NULL); | |
| 1695 | ||
| 1696 | idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); | |
| 1697 | stat = mwSession_getUserStatus(session); | |
| 1698 | ||
| 1699 | /* trigger an update of our own status if we're in the buddy list */ | |
| 1700 | mwServiceAware_setStatus(pd->srvc_aware, &idb, stat); | |
| 1701 | } | |
| 1702 | ||
| 1703 | ||
| 1704 | static void mw_session_admin(struct mwSession *session, | |
| 1705 | const char *text) { | |
| 15884 | 1706 | PurpleConnection *gc; |
| 1707 | PurpleAccount *acct; | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1708 | const char *host; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1709 | const char *msg; |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1710 | char *prim; |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1711 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1712 | gc = session_to_gc(session); |
| 10977 | 1713 | g_return_if_fail(gc != NULL); |
| 1714 | ||
| 15884 | 1715 | acct = purple_connection_get_account(gc); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1716 | g_return_if_fail(acct != NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1717 | |
| 15884 | 1718 | host = purple_account_get_string(acct, MW_KEY_HOST, NULL); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1719 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1720 | msg = _("A Sametime administrator has issued the following announcement" |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1721 | " on server %s"); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1722 | prim = g_strdup_printf(msg, NSTR(host)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1723 | |
| 15884 | 1724 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1725 | _("Sametime Administrator Announcement"), |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1726 | prim, text, NULL, NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1727 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1728 | g_free(prim); |
| 10977 | 1729 | } |
| 1730 | ||
| 1731 | ||
| 1732 | /** called from read_cb, attempts to read available data from sock and | |
| 1733 | pass it to the session, passing back the return code from the read | |
| 1734 | call for handling in read_cb */ | |
| 1735 | static int read_recv(struct mwSession *session, int sock) { | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1736 | guchar buf[BUF_LEN]; |
| 10977 | 1737 | int len; |
| 1738 | ||
| 1739 | len = read(sock, buf, BUF_LEN); | |
|
22277
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22195
diff
changeset
|
1740 | if(len > 0) { |
|
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22195
diff
changeset
|
1741 | mwSession_recv(session, buf, len); |
|
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22195
diff
changeset
|
1742 | } |
| 10977 | 1743 | |
| 1744 | return len; | |
| 1745 | } | |
| 1746 | ||
| 1747 | ||
| 15884 | 1748 | /** callback triggered from purple_input_add, watches the socked for |
| 10977 | 1749 | available data to be processed by the session */ |
| 15884 | 1750 | static void read_cb(gpointer data, gint source, PurpleInputCondition cond) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1751 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 1752 | int ret = 0, err = 0; |
| 1753 | ||
| 1754 | g_return_if_fail(pd != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1755 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1756 | ret = read_recv(pd->session, pd->socket); |
| 10977 | 1757 | |
| 1758 | /* normal operation ends here */ | |
| 1759 | if(ret > 0) return; | |
| 1760 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1761 | /* fetch the global error value */ |
| 10977 | 1762 | err = errno; |
| 1763 | ||
| 14754 | 1764 | /* read problem occurred if we're here, so we'll need to take care of |
| 10977 | 1765 | it and clean up internal state */ |
| 1766 | ||
| 1767 | if(pd->socket) { | |
| 1768 | close(pd->socket); | |
| 1769 | pd->socket = 0; | |
| 1770 | } | |
| 1771 | ||
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1772 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1773 | purple_input_remove(pd->inpa); |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1774 | pd->inpa = 0; |
| 10977 | 1775 | } |
| 1776 | ||
| 1777 | if(! ret) { | |
| 1778 | DEBUG_INFO("connection reset\n"); | |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1779 | purple_connection_error(pd->gc, |
| 21279 | 1780 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1781 | _("Server closed the connection")); |
| 10977 | 1782 | |
| 1783 | } else if(ret < 0) { | |
|
21486
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1784 | const gchar *err_str = g_strerror(err); |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1785 | char *msg = NULL; |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1786 | |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1787 | DEBUG_INFO("error in read callback: %s\n", err_str); |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1788 | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1789 | msg = g_strdup_printf(_("Lost connection with server: %s"), err_str); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1790 | purple_connection_error(pd->gc, |
| 21279 | 1791 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 1792 | msg); | |
| 10977 | 1793 | g_free(msg); |
| 1794 | } | |
| 1795 | } | |
| 1796 | ||
| 1797 | ||
| 15884 | 1798 | /** Callback passed to purple_proxy_connect when an account is logged |
| 10977 | 1799 | in, and if the session logging in receives a redirect message */ |
|
14178
d12b287697c9
[gaim-migrate @ 16750]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
1800 | static void connect_cb(gpointer data, gint source, const gchar *error_message) { |
| 10977 | 1801 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1802 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 1803 | |
| 1804 | if(source < 0) { | |
| 1805 | /* connection failed */ | |
| 1806 | ||
| 1807 | if(pd->socket) { | |
| 1808 | /* this is a redirect connect, force login on existing socket */ | |
| 1809 | mwSession_forceLogin(pd->session); | |
| 1810 | ||
| 1811 | } else { | |
| 1812 | /* this is a regular connect, error out */ | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1813 | gchar *tmp = g_strdup_printf(_("Unable to connect: %s"), |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1814 | error_message); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1815 | purple_connection_error(pd->gc, |
| 21279 | 1816 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1817 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1818 | g_free(tmp); |
| 10977 | 1819 | } |
| 1820 | ||
| 1821 | return; | |
| 1822 | } | |
| 1823 | ||
| 1824 | if(pd->socket) { | |
| 1825 | /* stop any existing login attempt */ | |
| 1826 | mwSession_stop(pd->session, ERR_SUCCESS); | |
| 1827 | } | |
| 1828 | ||
| 1829 | pd->socket = source; | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1830 | pd->inpa = purple_input_add(source, PURPLE_INPUT_READ, |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
1831 | read_cb, pd); |
| 10977 | 1832 | |
| 1833 | mwSession_start(pd->session); | |
| 1834 | } | |
| 1835 | ||
| 1836 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1837 | static void mw_session_announce(struct mwSession *s, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1838 | struct mwLoginInfo *from, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1839 | gboolean may_reply, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1840 | const char *text) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1841 | struct mwPurpleProtocolData *pd; |
| 15884 | 1842 | PurpleAccount *acct; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1843 | PurpleIMConversation *im; |
| 15884 | 1844 | PurpleBuddy *buddy; |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1845 | char *who = from->user_id; |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1846 | char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1847 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1848 | pd = mwSession_getClientData(s); |
| 15884 | 1849 | acct = purple_connection_get_account(pd->gc); |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1850 | im = purple_conversations_find_im_with_account(who, acct); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1851 | if(! im) im = purple_im_conversation_new(acct, who); |
| 15884 | 1852 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
1853 | buddy = purple_blist_find_buddy(acct, who); |
| 15884 | 1854 | if(buddy) who = (char *) purple_buddy_get_contact_alias(buddy); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1855 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1856 | who = g_strdup_printf(_("Announcement from %s"), who); |
| 15884 | 1857 | msg = purple_markup_linkify(text); |
| 1858 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1859 | purple_conversation_write(PURPLE_CONVERSATION(im), who, msg ? msg : "", |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1860 | PURPLE_MESSAGE_RECV, time(NULL)); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1861 | g_free(who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1862 | g_free(msg); |
| 10977 | 1863 | } |
| 1864 | ||
| 1865 | ||
| 1866 | static struct mwSessionHandler mw_session_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1867 | mw_session_io_write, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1868 | mw_session_io_close, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1869 | mw_session_clear, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1870 | mw_session_stateChange, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1871 | mw_session_setPrivacyInfo, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1872 | mw_session_setUserStatus, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1873 | mw_session_admin, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1874 | mw_session_announce, |
| 10977 | 1875 | }; |
| 1876 | ||
| 1877 | ||
| 1878 | static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
| 1879 | struct mwAwareAttribute *attrib) { | |
| 1880 | ||
| 1881 | ; /** @todo handle server attributes. There may be some stuff we | |
| 1882 | actually want to look for, but I'm not aware of anything right | |
| 1883 | now.*/ | |
| 1884 | } | |
| 1885 | ||
| 1886 | ||
| 1887 | static void mw_aware_clear(struct mwServiceAware *srvc) { | |
| 1888 | ; /* nothing for now */ | |
| 1889 | } | |
| 1890 | ||
| 1891 | ||
| 1892 | static struct mwAwareHandler mw_aware_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1893 | mw_aware_on_attrib, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1894 | mw_aware_clear, |
| 10977 | 1895 | }; |
| 1896 | ||
| 1897 | ||
| 1898 | static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
| 1899 | struct mwServiceAware *srvc; | |
| 1900 | srvc = mwServiceAware_new(s, &mw_aware_handler); | |
| 1901 | return srvc; | |
| 1902 | }; | |
| 1903 | ||
| 1904 | ||
| 1905 | static void mw_conf_invited(struct mwConference *conf, | |
| 1906 | struct mwLoginInfo *inviter, | |
| 1907 | const char *invitation) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1908 | |
| 10977 | 1909 | struct mwServiceConference *srvc; |
| 1910 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1911 | struct mwPurpleProtocolData *pd; |
| 15884 | 1912 | PurpleConnection *gc; |
| 10977 | 1913 | |
| 1914 | char *c_inviter, *c_name, *c_topic, *c_invitation; | |
| 1915 | GHashTable *ht; | |
| 1916 | ||
| 1917 | srvc = mwConference_getService(conf); | |
| 1918 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1919 | pd = mwSession_getClientData(session); | |
| 1920 | gc = pd->gc; | |
| 1921 | ||
| 1922 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1923 | ||
| 1924 | c_inviter = g_strdup(inviter->user_id); | |
| 1925 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
| 1926 | ||
| 1927 | c_name = g_strdup(mwConference_getName(conf)); | |
| 1928 | g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
| 1929 | ||
| 1930 | c_topic = g_strdup(mwConference_getTitle(conf)); | |
| 1931 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
| 1932 | ||
| 1933 | c_invitation = g_strdup(invitation); | |
| 1934 | g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
| 1935 | ||
| 1936 | DEBUG_INFO("received invitation from '%s' to join ('%s','%s'): '%s'\n", | |
| 1937 | NSTR(c_inviter), NSTR(c_name), | |
| 1938 | NSTR(c_topic), NSTR(c_invitation)); | |
| 1939 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1940 | if(! c_topic) c_topic = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1941 | if(! c_invitation) c_invitation = "(no message)"; |
| 10977 | 1942 | serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
| 1943 | } | |
| 1944 | ||
| 1945 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1946 | /* The following mess helps us relate a mwConference to a PurpleChatConversation |
| 10977 | 1947 | in the various forms by which either may be indicated */ |
| 1948 | ||
| 1949 | #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
| 1950 | #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
| 1951 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1952 | #define CHAT_TO_ID(chat) (purple_chat_conversation_get_id(chat)) |
|
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1953 | #define ID_TO_CHAT(id) (purple_conversations_find_chat(id)) |
| 10977 | 1954 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1955 | #define CHAT_TO_CONF(pd, chat) (ID_TO_CONF((pd), CHAT_TO_ID(chat))) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1956 | #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
| 10977 | 1957 | |
| 1958 | ||
| 1959 | static struct mwConference * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1960 | conf_find_by_id(struct mwPurpleProtocolData *pd, int id) { |
| 10977 | 1961 | |
| 1962 | struct mwServiceConference *srvc = pd->srvc_conf; | |
| 1963 | struct mwConference *conf = NULL; | |
| 1964 | GList *l, *ll; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1965 | |
| 10977 | 1966 | ll = mwServiceConference_getConferences(srvc); |
| 1967 | for(l = ll; l; l = l->next) { | |
| 1968 | struct mwConference *c = l->data; | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1969 | PurpleChatConversation *h = mwConference_getClientData(c); |
| 10977 | 1970 | |
| 1971 | if(CHAT_TO_ID(h) == id) { | |
| 1972 | conf = c; | |
| 1973 | break; | |
| 1974 | } | |
| 1975 | } | |
| 1976 | g_list_free(ll); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1977 | |
| 10977 | 1978 | return conf; |
| 1979 | } | |
| 1980 | ||
| 1981 | ||
| 1982 | static void mw_conf_opened(struct mwConference *conf, GList *members) { | |
| 1983 | struct mwServiceConference *srvc; | |
| 1984 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1985 | struct mwPurpleProtocolData *pd; |
| 15884 | 1986 | PurpleConnection *gc; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1987 | PurpleChatConversation *g_conf; |
| 10977 | 1988 | |
| 1989 | const char *n = mwConference_getName(conf); | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1990 | const char *t = mwConference_getTitle(conf); |
| 10977 | 1991 | |
| 1992 | DEBUG_INFO("conf %s opened, %u initial members\n", | |
| 1993 | NSTR(n), g_list_length(members)); | |
| 1994 | ||
| 1995 | srvc = mwConference_getService(conf); | |
| 1996 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1997 | pd = mwSession_getClientData(session); | |
| 1998 | gc = pd->gc; | |
| 1999 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2000 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2001 | g_conf = serv_got_joined_chat(gc, CONF_TO_ID(conf), t); |
| 10977 | 2002 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2003 | mwConference_setClientData(conf, g_conf, NULL); |
| 10977 | 2004 | |
| 2005 | for(; members; members = members->next) { | |
| 2006 | struct mwLoginInfo *peer = members->data; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2007 | purple_chat_conversation_add_user(g_conf, peer->user_id, |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
2008 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
| 10977 | 2009 | } |
| 2010 | } | |
| 2011 | ||
| 2012 | ||
| 2013 | static void mw_conf_closed(struct mwConference *conf, guint32 reason) { | |
| 2014 | struct mwServiceConference *srvc; | |
| 2015 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2016 | struct mwPurpleProtocolData *pd; |
| 15884 | 2017 | PurpleConnection *gc; |
| 10977 | 2018 | |
| 2019 | const char *n = mwConference_getName(conf); | |
| 2020 | char *msg = mwError(reason); | |
| 2021 | ||
| 2022 | DEBUG_INFO("conf %s closed, 0x%08x\n", NSTR(n), reason); | |
| 2023 | ||
| 2024 | srvc = mwConference_getService(conf); | |
| 2025 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2026 | pd = mwSession_getClientData(session); | |
| 2027 | gc = pd->gc; | |
| 2028 | ||
| 2029 | serv_got_chat_left(gc, CONF_TO_ID(conf)); | |
| 2030 | ||
| 15884 | 2031 | purple_notify_error(gc, _("Conference Closed"), NULL, msg); |
| 10977 | 2032 | g_free(msg); |
| 2033 | } | |
| 2034 | ||
| 2035 | ||
| 2036 | static void mw_conf_peer_joined(struct mwConference *conf, | |
| 2037 | struct mwLoginInfo *peer) { | |
| 2038 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2039 | PurpleChatConversation *g_conf; |
| 10977 | 2040 | |
| 2041 | const char *n = mwConference_getName(conf); | |
| 2042 | ||
| 2043 | DEBUG_INFO("%s joined conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2044 | ||
| 2045 | g_conf = mwConference_getClientData(conf); | |
| 2046 | g_return_if_fail(g_conf != NULL); | |
| 2047 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2048 | purple_chat_conversation_add_user(g_conf, peer->user_id, |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
2049 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
| 10977 | 2050 | } |
| 2051 | ||
| 2052 | ||
| 2053 | static void mw_conf_peer_parted(struct mwConference *conf, | |
| 2054 | struct mwLoginInfo *peer) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2055 | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2056 | PurpleChatConversation *g_conf; |
| 10977 | 2057 | |
| 2058 | const char *n = mwConference_getName(conf); | |
| 2059 | ||
| 2060 | DEBUG_INFO("%s left conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2061 | ||
| 2062 | g_conf = mwConference_getClientData(conf); | |
| 2063 | g_return_if_fail(g_conf != NULL); | |
| 2064 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2065 | purple_chat_conversation_remove_user(g_conf, peer->user_id, NULL); |
| 10977 | 2066 | } |
| 2067 | ||
| 2068 | ||
| 2069 | static void mw_conf_text(struct mwConference *conf, | |
| 2070 | struct mwLoginInfo *who, const char *text) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2071 | |
| 10977 | 2072 | struct mwServiceConference *srvc; |
| 2073 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2074 | struct mwPurpleProtocolData *pd; |
| 15884 | 2075 | PurpleConnection *gc; |
| 10977 | 2076 | char *esc; |
| 2077 | ||
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2078 | if(! text) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2079 | |
| 10977 | 2080 | srvc = mwConference_getService(conf); |
| 2081 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2082 | pd = mwSession_getClientData(session); | |
| 2083 | gc = pd->gc; | |
| 2084 | ||
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2085 | esc = g_markup_escape_text(text, -1); |
| 10977 | 2086 | serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, 0, esc, time(NULL)); |
| 2087 | g_free(esc); | |
| 2088 | } | |
| 2089 | ||
| 2090 | ||
| 2091 | static void mw_conf_typing(struct mwConference *conf, | |
| 2092 | struct mwLoginInfo *who, gboolean typing) { | |
| 2093 | ||
| 15884 | 2094 | /* purple really has no good way to expose this to the user. */ |
| 10977 | 2095 | |
| 2096 | const char *n = mwConference_getName(conf); | |
| 2097 | const char *w = who->user_id; | |
| 2098 | ||
| 2099 | if(typing) { | |
| 2100 | DEBUG_INFO("%s in conf %s: <typing>\n", NSTR(w), NSTR(n)); | |
| 2101 | ||
| 2102 | } else { | |
| 2103 | DEBUG_INFO("%s in conf %s: <stopped typing>\n", NSTR(w), NSTR(n)); | |
| 2104 | } | |
| 2105 | } | |
| 2106 | ||
| 2107 | ||
| 2108 | static void mw_conf_clear(struct mwServiceConference *srvc) { | |
| 2109 | ; | |
| 2110 | } | |
| 2111 | ||
| 2112 | ||
| 2113 | static struct mwConferenceHandler mw_conference_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2114 | mw_conf_invited, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2115 | mw_conf_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2116 | mw_conf_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2117 | mw_conf_peer_joined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2118 | mw_conf_peer_parted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2119 | mw_conf_text, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2120 | mw_conf_typing, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2121 | mw_conf_clear, |
| 10977 | 2122 | }; |
| 2123 | ||
| 2124 | ||
| 2125 | static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) { | |
| 2126 | struct mwServiceConference *srvc; | |
| 2127 | srvc = mwServiceConference_new(s, &mw_conference_handler); | |
| 2128 | return srvc; | |
| 2129 | } | |
| 2130 | ||
| 2131 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2132 | /** size of an outgoing file transfer chunk */ |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2133 | #define MW_FT_LEN (BUF_LONG * 2) |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2134 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2135 | |
| 15884 | 2136 | static void ft_incoming_cancel(PurpleXfer *xfer) { |
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29304
diff
changeset
|
2137 | /* incoming transfer rejected or cancelled in-progress */ |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2138 | struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
| 10977 | 2139 | if(ft) mwFileTransfer_reject(ft); |
| 2140 | } | |
| 2141 | ||
| 2142 | ||
| 15884 | 2143 | static void ft_incoming_init(PurpleXfer *xfer) { |
| 10977 | 2144 | /* incoming transfer accepted */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2145 | |
| 10977 | 2146 | /* - accept the mwFileTransfer |
| 2147 | - open/create the local FILE "wb" | |
| 2148 | - stick the FILE's fp in xfer->dest_fp | |
| 2149 | */ | |
| 2150 | ||
| 2151 | struct mwFileTransfer *ft; | |
| 2152 | FILE *fp; | |
| 2153 | ||
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2154 | ft = purple_xfer_get_protocol_data(xfer); |
| 10977 | 2155 | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2156 | fp = g_fopen(purple_xfer_get_local_filename(xfer), "wb"); |
| 10977 | 2157 | if(! fp) { |
| 2158 | mwFileTransfer_cancel(ft); | |
| 2159 | return; | |
| 2160 | } | |
| 2161 | ||
| 2162 | xfer->dest_fp = fp; | |
| 2163 | mwFileTransfer_accept(ft); | |
| 2164 | } | |
| 2165 | ||
| 2166 | ||
| 2167 | static void mw_ft_offered(struct mwFileTransfer *ft) { | |
| 2168 | /* | |
| 15884 | 2169 | - create a purple ft object |
| 10977 | 2170 | - offer it |
| 2171 | */ | |
| 2172 | ||
| 2173 | struct mwServiceFileTransfer *srvc; | |
| 2174 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2175 | struct mwPurpleProtocolData *pd; |
| 15884 | 2176 | PurpleConnection *gc; |
| 2177 | PurpleAccount *acct; | |
| 10977 | 2178 | const char *who; |
| 15884 | 2179 | PurpleXfer *xfer; |
| 10977 | 2180 | |
| 2181 | /* @todo add some safety checks */ | |
| 2182 | srvc = mwFileTransfer_getService(ft); | |
| 2183 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2184 | pd = mwSession_getClientData(session); | |
| 2185 | gc = pd->gc; | |
| 15884 | 2186 | acct = purple_connection_get_account(gc); |
| 10977 | 2187 | |
| 2188 | who = mwFileTransfer_getUser(ft)->user; | |
| 2189 | ||
| 2190 | DEBUG_INFO("file transfer %p offered\n", ft); | |
| 2191 | DEBUG_INFO(" from: %s\n", NSTR(who)); | |
| 2192 | DEBUG_INFO(" file: %s\n", NSTR(mwFileTransfer_getFileName(ft))); | |
| 2193 | DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft)); | |
| 2194 | DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft))); | |
| 2195 | ||
| 15884 | 2196 | xfer = purple_xfer_new(acct, PURPLE_XFER_RECEIVE, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2197 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2198 | { |
| 15884 | 2199 | purple_xfer_ref(xfer); |
| 2200 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2201 | purple_xfer_set_protocol_data(xfer, ft); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2202 | |
| 15884 | 2203 | purple_xfer_set_init_fnc(xfer, ft_incoming_init); |
| 2204 | purple_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); | |
| 2205 | purple_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); | |
| 2206 | ||
| 2207 | purple_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); | |
| 2208 | purple_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); | |
| 2209 | purple_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); | |
| 2210 | ||
| 2211 | purple_xfer_request(xfer); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2212 | } |
| 10977 | 2213 | } |
| 2214 | ||
| 2215 | ||
| 2216 | static void ft_send(struct mwFileTransfer *ft, FILE *fp) { | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2217 | guchar buf[MW_FT_LEN]; |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
2218 | struct mwOpaque o = { MW_FT_LEN, buf }; |
| 10977 | 2219 | guint32 rem; |
| 15884 | 2220 | PurpleXfer *xfer; |
| 10977 | 2221 | |
| 2222 | xfer = mwFileTransfer_getClientData(ft); | |
| 2223 | ||
| 2224 | rem = mwFileTransfer_getRemaining(ft); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2225 | if(rem < MW_FT_LEN) o.len = rem; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2226 | |
| 10977 | 2227 | if(fread(buf, (size_t) o.len, 1, fp)) { |
| 2228 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2229 | /* calculate progress and display it */ |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2230 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + o.len); |
| 15884 | 2231 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2232 | |
| 10977 | 2233 | mwFileTransfer_send(ft, &o); |
| 2234 | ||
| 2235 | } else { | |
| 2236 | int err = errno; | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2237 | DEBUG_WARN("problem reading from file %s: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20288
diff
changeset
|
2238 | NSTR(mwFileTransfer_getFileName(ft)), g_strerror(err)); |
| 10977 | 2239 | |
| 2240 | mwFileTransfer_cancel(ft); | |
| 2241 | } | |
| 2242 | } | |
| 2243 | ||
| 2244 | ||
| 2245 | static void mw_ft_opened(struct mwFileTransfer *ft) { | |
| 2246 | /* | |
| 15884 | 2247 | - get purple ft from client data in ft |
| 10977 | 2248 | - set the state to active |
| 2249 | */ | |
| 2250 | ||
| 15884 | 2251 | PurpleXfer *xfer; |
| 10977 | 2252 | |
| 2253 | xfer = mwFileTransfer_getClientData(ft); | |
| 2254 | ||
| 2255 | if(! xfer) { | |
| 2256 | mwFileTransfer_cancel(ft); | |
| 2257 | mwFileTransfer_free(ft); | |
| 2258 | g_return_if_reached(); | |
| 2259 | } | |
| 2260 | ||
| 15884 | 2261 | if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2262 | xfer->dest_fp = g_fopen(purple_xfer_get_local_filename(xfer), "rb"); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2263 | ft_send(ft, xfer->dest_fp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2264 | } |
| 10977 | 2265 | } |
| 2266 | ||
| 2267 | ||
| 2268 | static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
| 2269 | /* | |
| 15884 | 2270 | - get purple ft from client data in ft |
| 10977 | 2271 | - indicate rejection/cancelation/completion |
| 2272 | - free the file transfer itself | |
| 2273 | */ | |
| 2274 | ||
| 15884 | 2275 | PurpleXfer *xfer; |
| 10977 | 2276 | |
| 2277 | xfer = mwFileTransfer_getClientData(ft); | |
| 2278 | if(xfer) { | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2279 | purple_xfer_set_protocol_data(xfer, NULL); |
| 10977 | 2280 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2281 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2282 | purple_xfer_set_completed(xfer, TRUE); |
| 2283 | purple_xfer_end(xfer); | |
| 10977 | 2284 | |
| 2285 | } else if(mwFileTransfer_isCancelLocal(ft)) { | |
| 15884 | 2286 | /* calling purple_xfer_cancel_local is redundant, since that's |
| 10977 | 2287 | probably what triggered this function to be called */ |
| 2288 | ; | |
| 2289 | ||
| 2290 | } else if(mwFileTransfer_isCancelRemote(ft)) { | |
| 2291 | /* steal the reference for the xfer */ | |
| 2292 | mwFileTransfer_setClientData(ft, NULL, NULL); | |
| 15884 | 2293 | purple_xfer_cancel_remote(xfer); |
| 10977 | 2294 | |
| 2295 | /* drop the stolen reference */ | |
| 15884 | 2296 | purple_xfer_unref(xfer); |
| 10977 | 2297 | return; |
| 2298 | } | |
| 2299 | } | |
| 2300 | ||
| 2301 | mwFileTransfer_free(ft); | |
| 2302 | } | |
| 2303 | ||
| 2304 | ||
| 2305 | static void mw_ft_recv(struct mwFileTransfer *ft, | |
| 2306 | struct mwOpaque *data) { | |
| 2307 | /* | |
| 15884 | 2308 | - get purple ft from client data in ft |
| 10977 | 2309 | - update transfered percentage |
| 15884 | 2310 | - if done, destroy the ft, disassociate from purple ft |
| 10977 | 2311 | */ |
| 2312 | ||
| 15884 | 2313 | PurpleXfer *xfer; |
| 10977 | 2314 | FILE *fp; |
|
22195
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2315 | size_t wc; |
| 10977 | 2316 | |
| 2317 | xfer = mwFileTransfer_getClientData(ft); | |
| 2318 | g_return_if_fail(xfer != NULL); | |
| 2319 | ||
| 2320 | fp = xfer->dest_fp; | |
| 2321 | g_return_if_fail(fp != NULL); | |
| 2322 | ||
| 2323 | /* we must collect and save our precious data */ | |
|
22195
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2324 | wc = fwrite(data->data, 1, data->len, fp); |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2325 | if (wc != data->len) { |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2326 | DEBUG_ERROR("failed to write data\n"); |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2327 | purple_xfer_cancel_local(xfer); |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2328 | return; |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2329 | } |
| 10977 | 2330 | |
| 2331 | /* update the progress */ | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2332 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + data->len); |
| 15884 | 2333 | purple_xfer_update_progress(xfer); |
| 10977 | 2334 | |
| 2335 | /* let the other side know we got it, and to send some more */ | |
| 2336 | mwFileTransfer_ack(ft); | |
| 2337 | } | |
| 2338 | ||
| 2339 | ||
| 2340 | static void mw_ft_ack(struct mwFileTransfer *ft) { | |
| 15884 | 2341 | PurpleXfer *xfer; |
| 10977 | 2342 | |
| 2343 | xfer = mwFileTransfer_getClientData(ft); | |
| 2344 | g_return_if_fail(xfer != NULL); | |
|
32705
9d97ac4c2c22
Sametime: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents:
32698
diff
changeset
|
2345 | g_return_if_fail(purple_xfer_get_watcher(xfer) == 0); |
| 10977 | 2346 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2347 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2348 | purple_xfer_set_completed(xfer, TRUE); |
| 2349 | purple_xfer_end(xfer); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2350 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2351 | } else if(mwFileTransfer_isOpen(ft)) { |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2352 | ft_send(ft, xfer->dest_fp); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2353 | } |
| 10977 | 2354 | } |
| 2355 | ||
| 2356 | ||
| 2357 | static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
| 2358 | ; | |
| 2359 | } | |
| 2360 | ||
| 2361 | ||
| 2362 | static struct mwFileTransferHandler mw_ft_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2363 | mw_ft_offered, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2364 | mw_ft_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2365 | mw_ft_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2366 | mw_ft_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2367 | mw_ft_ack, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2368 | mw_ft_clear, |
| 10977 | 2369 | }; |
| 2370 | ||
| 2371 | ||
| 2372 | static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
| 2373 | struct mwServiceFileTransfer *srvc; | |
| 2374 | GHashTable *ft_map; | |
| 2375 | ||
| 2376 | ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 2377 | ||
| 2378 | srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
| 2379 | mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
| 2380 | (GDestroyNotify) g_hash_table_destroy); | |
| 2381 | ||
| 2382 | return srvc; | |
| 2383 | } | |
| 2384 | ||
| 2385 | ||
| 2386 | static void convo_data_free(struct convo_data *cd) { | |
| 2387 | GList *l; | |
| 2388 | ||
| 2389 | /* clean the queue */ | |
| 2390 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2391 | struct convo_msg *m = l->data; | |
| 2392 | if(m->clear) m->clear(m->data); | |
| 2393 | g_free(m); | |
| 2394 | } | |
| 2395 | ||
| 2396 | g_free(cd); | |
| 2397 | } | |
| 2398 | ||
| 2399 | ||
| 2400 | /** allocates a convo_data structure and associates it with the | |
| 2401 | conversation in the client data slot */ | |
| 2402 | static void convo_data_new(struct mwConversation *conv) { | |
| 2403 | struct convo_data *cd; | |
| 2404 | ||
| 2405 | g_return_if_fail(conv != NULL); | |
| 2406 | ||
| 2407 | if(mwConversation_getClientData(conv)) | |
| 2408 | return; | |
| 2409 | ||
| 2410 | cd = g_new0(struct convo_data, 1); | |
| 2411 | cd->conv = conv; | |
| 2412 | ||
| 2413 | mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
| 2414 | } | |
| 2415 | ||
| 2416 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2417 | static PurpleIMConversation *convo_get_im(struct mwConversation *conv) { |
| 10977 | 2418 | struct mwServiceIm *srvc; |
| 2419 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2420 | struct mwPurpleProtocolData *pd; |
| 15884 | 2421 | PurpleConnection *gc; |
| 2422 | PurpleAccount *acct; | |
| 10977 | 2423 | |
| 2424 | struct mwIdBlock *idb; | |
| 2425 | ||
| 2426 | srvc = mwConversation_getService(conv); | |
| 2427 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2428 | pd = mwSession_getClientData(session); | |
| 2429 | gc = pd->gc; | |
| 15884 | 2430 | acct = purple_connection_get_account(gc); |
| 10977 | 2431 | |
| 2432 | idb = mwConversation_getTarget(conv); | |
| 2433 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2434 | return purple_conversations_find_im_with_account(idb->user, acct); |
| 10977 | 2435 | } |
| 2436 | ||
| 2437 | ||
| 2438 | static void convo_queue(struct mwConversation *conv, | |
| 2439 | enum mwImSendType type, gconstpointer data) { | |
| 2440 | ||
| 2441 | struct convo_data *cd; | |
| 2442 | struct convo_msg *m; | |
| 2443 | ||
| 2444 | convo_data_new(conv); | |
| 2445 | cd = mwConversation_getClientData(conv); | |
| 2446 | ||
| 2447 | m = g_new0(struct convo_msg, 1); | |
| 2448 | m->type = type; | |
| 2449 | ||
| 2450 | switch(type) { | |
| 2451 | case mwImSend_PLAIN: | |
| 2452 | m->data = g_strdup(data); | |
| 2453 | m->clear = g_free; | |
| 2454 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2455 | |
| 10977 | 2456 | case mwImSend_TYPING: |
| 2457 | default: | |
| 2458 | m->data = (gpointer) data; | |
| 2459 | m->clear = NULL; | |
| 2460 | } | |
| 2461 | ||
| 2462 | cd->queue = g_list_append(cd->queue, m); | |
| 2463 | } | |
| 2464 | ||
| 2465 | ||
| 2466 | /* Does what it takes to get an error displayed for a conversation */ | |
| 2467 | static void convo_error(struct mwConversation *conv, guint32 err) { | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2468 | PurpleIMConversation *im; |
| 10977 | 2469 | char *tmp, *text; |
| 2470 | struct mwIdBlock *idb; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2471 | |
| 10977 | 2472 | idb = mwConversation_getTarget(conv); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2473 | |
| 10977 | 2474 | tmp = mwError(err); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2475 | text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2476 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2477 | im = convo_get_im(conv); |
|
34868
faa5b053f310
Replaced purple_conversation_helper_present_error() with simpler purple_conversation_present_error()
Ankit Vani <a@nevitus.org>
parents:
34865
diff
changeset
|
2478 | if(im && !purple_conversation_present_error(idb->user, |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2479 | purple_conversation_get_account(PURPLE_CONVERSATION(im)), text)) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2480 | |
| 10977 | 2481 | g_free(text); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2482 | text = g_strdup_printf(_("Unable to send message to %s:"), |
| 10977 | 2483 | (idb->user)? idb->user: "(unknown)"); |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2484 | purple_notify_error(purple_account_get_connection( |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2485 | purple_conversation_get_account(PURPLE_CONVERSATION(im))), |
| 10977 | 2486 | NULL, text, tmp); |
| 2487 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2488 | |
| 10977 | 2489 | g_free(tmp); |
| 2490 | g_free(text); | |
| 2491 | } | |
| 2492 | ||
| 2493 | ||
| 2494 | static void convo_queue_send(struct mwConversation *conv) { | |
| 2495 | struct convo_data *cd; | |
| 2496 | GList *l; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2497 | |
| 10977 | 2498 | cd = mwConversation_getClientData(conv); |
| 2499 | ||
| 2500 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2501 | struct convo_msg *m = l->data; | |
| 2502 | ||
| 2503 | mwConversation_send(conv, m->type, m->data); | |
| 2504 | ||
| 2505 | if(m->clear) m->clear(m->data); | |
| 2506 | g_free(m); | |
| 2507 | } | |
| 2508 | ||
| 2509 | cd->queue = NULL; | |
| 2510 | } | |
| 2511 | ||
| 2512 | ||
| 15884 | 2513 | /** called when a mw conversation leaves a purple conversation to |
| 2514 | inform the purple conversation that it's unsafe to offer any *cool* | |
| 10977 | 2515 | features. */ |
| 2516 | static void convo_nofeatures(struct mwConversation *conv) { | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2517 | PurpleIMConversation *im; |
| 15884 | 2518 | PurpleConnection *gc; |
| 10977 | 2519 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2520 | im = convo_get_im(conv); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2521 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2522 | |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2523 | gc = purple_conversation_get_connection(PURPLE_CONVERSATION(im)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2524 | if(! gc) return; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2525 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2526 | purple_conversation_set_features(PURPLE_CONVERSATION(im), |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2527 | purple_connection_get_flags(gc)); |
| 15884 | 2528 | } |
| 2529 | ||
| 2530 | ||
| 2531 | /** called when a mw conversation and purple conversation come together, | |
| 2532 | to inform the purple conversation of what features to offer the | |
| 10977 | 2533 | user */ |
| 2534 | static void convo_features(struct mwConversation *conv) { | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2535 | PurpleIMConversation *im; |
| 15884 | 2536 | PurpleConnectionFlags feat; |
| 10977 | 2537 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2538 | im = convo_get_im(conv); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2539 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2540 | |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2541 | feat = purple_conversation_get_features(PURPLE_CONVERSATION(im)); |
| 10977 | 2542 | |
| 2543 | if(mwConversation_isOpen(conv)) { | |
| 2544 | if(mwConversation_supports(conv, mwImSend_HTML)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2545 | feat |= PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2546 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2547 | feat &= ~PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2548 | } |
| 2549 | ||
| 2550 | if(mwConversation_supports(conv, mwImSend_MIME)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2551 | feat &= ~PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2552 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2553 | feat |= PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2554 | } |
| 2555 | ||
| 2556 | DEBUG_INFO("conversation features set to 0x%04x\n", feat); | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2557 | purple_conversation_set_features(PURPLE_CONVERSATION(im), feat); |
| 10977 | 2558 | |
| 2559 | } else { | |
| 2560 | convo_nofeatures(conv); | |
| 2561 | } | |
| 2562 | } | |
| 2563 | ||
| 2564 | ||
| 2565 | static void mw_conversation_opened(struct mwConversation *conv) { | |
| 2566 | struct mwServiceIm *srvc; | |
| 2567 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2568 | struct mwPurpleProtocolData *pd; |
| 15884 | 2569 | PurpleConnection *gc; |
| 2570 | PurpleAccount *acct; | |
| 10977 | 2571 | |
| 2572 | struct convo_dat *cd; | |
| 2573 | ||
| 2574 | srvc = mwConversation_getService(conv); | |
| 2575 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2576 | pd = mwSession_getClientData(session); | |
| 2577 | gc = pd->gc; | |
| 15884 | 2578 | acct = purple_connection_get_account(gc); |
| 10977 | 2579 | |
| 2580 | /* set up the queue */ | |
| 2581 | cd = mwConversation_getClientData(conv); | |
| 2582 | if(cd) { | |
| 2583 | convo_queue_send(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2584 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2585 | if(! convo_get_im(conv)) { |
| 10977 | 2586 | mwConversation_free(conv); |
| 2587 | return; | |
| 2588 | } | |
| 2589 | ||
| 2590 | } else { | |
| 2591 | convo_data_new(conv); | |
| 2592 | } | |
| 2593 | ||
| 2594 | { /* record the client key for the buddy */ | |
| 15884 | 2595 | PurpleBuddy *buddy; |
| 10977 | 2596 | struct mwLoginInfo *info; |
| 2597 | info = mwConversation_getTargetInfo(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2598 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
2599 | buddy = purple_blist_find_buddy(acct, info->user_id); |
| 10977 | 2600 | if(buddy) { |
| 15884 | 2601 | purple_blist_node_set_int((PurpleBlistNode *) buddy, |
| 10977 | 2602 | BUDDY_KEY_CLIENT, info->type); |
| 2603 | } | |
| 2604 | } | |
| 2605 | ||
| 2606 | convo_features(conv); | |
| 2607 | } | |
| 2608 | ||
| 2609 | ||
| 2610 | static void mw_conversation_closed(struct mwConversation *conv, | |
| 2611 | guint32 reason) { | |
| 2612 | ||
| 2613 | struct convo_data *cd; | |
| 2614 | ||
| 2615 | g_return_if_fail(conv != NULL); | |
| 2616 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2617 | /* if there's an error code and a non-typing message in the queue, |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2618 | print an error message to the conversation */ |
| 10977 | 2619 | cd = mwConversation_getClientData(conv); |
| 2620 | if(reason && cd && cd->queue) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2621 | GList *l; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2622 | for(l = cd->queue; l; l = l->next) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2623 | struct convo_msg *m = l->data; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2624 | if(m->type != mwImSend_TYPING) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2625 | convo_error(conv, reason); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2626 | break; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2627 | } |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2628 | } |
| 10977 | 2629 | } |
| 2630 | ||
| 2631 | #if 0 | |
| 2632 | /* don't do this, to prevent the occasional weird sending of | |
| 2633 | formatted messages as plaintext when the other end closes the | |
| 2634 | conversation after we've begun composing the message */ | |
| 2635 | convo_nofeatures(conv); | |
| 2636 | #endif | |
| 2637 | ||
| 2638 | mwConversation_removeClientData(conv); | |
| 2639 | } | |
| 2640 | ||
| 2641 | ||
| 2642 | static void im_recv_text(struct mwConversation *conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2643 | struct mwPurpleProtocolData *pd, |
| 10977 | 2644 | const char *msg) { |
| 2645 | ||
| 2646 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2647 | char *txt, *esc; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2648 | const char *t; |
| 10977 | 2649 | |
| 2650 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2651 | |
| 15884 | 2652 | txt = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2653 | t = txt? txt: msg; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2654 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2655 | esc = g_markup_escape_text(t, -1); |
| 10977 | 2656 | serv_got_im(pd->gc, idb->user, esc, 0, time(NULL)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2657 | g_free(esc); |
| 10977 | 2658 | |
| 2659 | g_free(txt); | |
| 2660 | } | |
| 2661 | ||
| 2662 | ||
| 2663 | static void im_recv_typing(struct mwConversation *conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2664 | struct mwPurpleProtocolData *pd, |
| 10977 | 2665 | gboolean typing) { |
| 2666 | ||
| 2667 | struct mwIdBlock *idb; | |
| 2668 | idb = mwConversation_getTarget(conv); | |
| 2669 | ||
| 2670 | serv_got_typing(pd->gc, idb->user, 0, | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
2671 | typing? PURPLE_IM_TYPING: PURPLE_IM_NOT_TYPING); |
| 10977 | 2672 | } |
| 2673 | ||
| 2674 | ||
| 2675 | static void im_recv_html(struct mwConversation *conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2676 | struct mwPurpleProtocolData *pd, |
| 10977 | 2677 | const char *msg) { |
| 2678 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2679 | char *t1, *t2; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2680 | const char *t; |
| 10977 | 2681 | |
| 2682 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2683 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2684 | /* ensure we're receiving UTF8 */ |
| 15884 | 2685 | t1 = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2686 | t = t1? t1: msg; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2687 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2688 | /* convert entities to UTF8 so they'll log correctly */ |
| 15884 | 2689 | t2 = purple_utf8_ncr_decode(t); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2690 | t = t2? t2: t; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2691 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2692 | serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
| 10977 | 2693 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2694 | g_free(t1); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2695 | g_free(t2); |
| 10977 | 2696 | } |
| 2697 | ||
| 2698 | ||
| 2699 | static void im_recv_subj(struct mwConversation *conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2700 | struct mwPurpleProtocolData *pd, |
| 10977 | 2701 | const char *subj) { |
| 2702 | ||
| 2703 | /** @todo somehow indicate receipt of a conversation subject. It | |
| 2704 | would also be nice if we added a /topic command for the | |
| 2705 | protocol */ | |
| 2706 | ; | |
| 2707 | } | |
| 2708 | ||
| 2709 | ||
| 2710 | /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */ | |
| 2711 | static char *make_cid(const char *cid) { | |
| 2712 | gsize n; | |
| 2713 | char *c, *d; | |
| 2714 | ||
| 2715 | g_return_val_if_fail(cid != NULL, NULL); | |
| 2716 | ||
| 2717 | n = strlen(cid); | |
| 2718 | g_return_val_if_fail(n > 2, NULL); | |
| 2719 | ||
| 2720 | c = g_strndup(cid+1, n-2); | |
| 2721 | d = g_strdup_printf("cid:%s", c); | |
| 2722 | ||
| 2723 | g_free(c); | |
| 2724 | return d; | |
| 2725 | } | |
| 2726 | ||
| 2727 | ||
| 2728 | static void im_recv_mime(struct mwConversation *conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2729 | struct mwPurpleProtocolData *pd, |
| 10977 | 2730 | const char *data) { |
| 2731 | ||
| 2732 | GHashTable *img_by_cid; | |
| 2733 | GList *images; | |
| 2734 | ||
| 2735 | GString *str; | |
| 2736 | ||
| 15884 | 2737 | PurpleMimeDocument *doc; |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
17157
diff
changeset
|
2738 | GList *parts; |
| 10977 | 2739 | |
| 2740 | img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
| 2741 | images = NULL; | |
| 2742 | ||
| 2743 | /* don't want the contained string to ever be NULL */ | |
| 2744 | str = g_string_new(""); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2745 | |
| 15884 | 2746 | doc = purple_mime_document_parse(data); |
| 10977 | 2747 | |
| 2748 | /* handle all the MIME parts */ | |
| 15884 | 2749 | parts = purple_mime_document_get_parts(doc); |
| 10977 | 2750 | for(; parts; parts = parts->next) { |
| 15884 | 2751 | PurpleMimePart *part = parts->data; |
| 10977 | 2752 | const char *type; |
| 2753 | ||
| 15884 | 2754 | type = purple_mime_part_get_field(part, "content-type"); |
| 10977 | 2755 | DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type)); |
| 2756 | ||
| 2757 | if(! type) { | |
| 2758 | ; /* feh */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2759 | |
| 15884 | 2760 | } else if(purple_str_has_prefix(type, "image")) { |
| 10977 | 2761 | /* put images into the image store */ |
| 2762 | ||
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2763 | guchar *d_dat; |
| 10977 | 2764 | gsize d_len; |
| 2765 | char *cid; | |
| 2766 | int img; | |
| 2767 | ||
| 2768 | /* obtain and unencode the data */ | |
| 15884 | 2769 | purple_mime_part_get_data_decoded(part, &d_dat, &d_len); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2770 | |
| 10977 | 2771 | /* look up the content id */ |
| 15884 | 2772 | cid = (char *) purple_mime_part_get_field(part, "Content-ID"); |
| 10977 | 2773 | cid = make_cid(cid); |
| 2774 | ||
| 15884 | 2775 | /* add image to the purple image store */ |
|
33762
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2776 | /* TODO: This PurpleStoredImage will be rendered within the IM window |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2777 | and right-clicking the image will allow the user to save the image |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2778 | to disk. The default filename used in this dialog is the filename |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2779 | that we pass to purple_imgstore_new_with_id(), so we should call |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2780 | g_path_get_basename() and purple_escape_filename() on it before |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2781 | passing it in. This is easy, but it's not clear if there might be |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2782 | other implications because this filename is used elsewhere within |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2783 | this PRPL. */ |
| 33661 | 2784 | img = purple_imgstore_new_with_id(d_dat, d_len, cid); |
| 10977 | 2785 | |
| 2786 | /* map the cid to the image store identifier */ | |
| 2787 | g_hash_table_insert(img_by_cid, cid, GINT_TO_POINTER(img)); | |
| 2788 | ||
| 2789 | /* recall the image for dereferencing later */ | |
| 2790 | images = g_list_append(images, GINT_TO_POINTER(img)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2791 | |
| 15884 | 2792 | } else if(purple_str_has_prefix(type, "text")) { |
| 10977 | 2793 | |
| 2794 | /* concatenate all the text parts together */ | |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2795 | guchar *data; |
| 10977 | 2796 | gsize len; |
| 2797 | ||
| 15884 | 2798 | purple_mime_part_get_data_decoded(part, &data, &len); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2799 | g_string_append(str, (const char *)data); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2800 | g_free(data); |
| 10977 | 2801 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2802 | } |
| 10977 | 2803 | |
| 15884 | 2804 | purple_mime_document_free(doc); |
| 10977 | 2805 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2806 | /* @todo should put this in its own function */ |
| 10977 | 2807 | { /* replace each IMG tag's SRC attribute with an ID attribute. This |
| 2808 | actually modifies the contents of str */ | |
| 2809 | GData *attribs; | |
| 2810 | char *start, *end; | |
| 2811 | char *tmp = str->str; | |
| 2812 | ||
| 15884 | 2813 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 2814 | (const char **) &end, &attribs)) { |
| 2815 | ||
| 2816 | char *alt, *align, *border, *src; | |
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2817 | int img = 0; |
| 10977 | 2818 | |
| 2819 | alt = g_datalist_get_data(&attribs, "alt"); | |
| 2820 | align = g_datalist_get_data(&attribs, "align"); | |
| 2821 | border = g_datalist_get_data(&attribs, "border"); | |
| 2822 | src = g_datalist_get_data(&attribs, "src"); | |
| 2823 | ||
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2824 | if(src) |
|
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2825 | img = GPOINTER_TO_INT(g_hash_table_lookup(img_by_cid, src)); |
|
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2826 | |
| 10977 | 2827 | if(img) { |
| 2828 | GString *atstr; | |
| 2829 | gsize len = (end - start); | |
| 2830 | gsize mov; | |
| 2831 | ||
| 2832 | atstr = g_string_new(""); | |
| 2833 | if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt); | |
| 2834 | if(align) g_string_append_printf(atstr, " align=\"%s\"", align); | |
| 2835 | if(border) g_string_append_printf(atstr, " border=\"%s\"", border); | |
| 2836 | ||
|
33052
df92c3d93904
From now on, prpls must specify images using SRC instead of ID.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32705
diff
changeset
|
2837 | mov = g_snprintf(start, len, "<img%s src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%i\"", atstr->str, img); |
| 10977 | 2838 | while(mov < len) start[mov++] = ' '; |
| 2839 | ||
| 2840 | g_string_free(atstr, TRUE); | |
| 2841 | } | |
| 2842 | ||
| 2843 | g_datalist_clear(&attribs); | |
| 2844 | tmp = end + 1; | |
| 2845 | } | |
| 2846 | } | |
| 2847 | ||
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2848 | im_recv_html(conv, pd, str->str); |
| 10977 | 2849 | |
| 2850 | g_string_free(str, TRUE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2851 | |
| 10977 | 2852 | /* clean up the cid table */ |
| 2853 | g_hash_table_destroy(img_by_cid); | |
| 2854 | ||
| 2855 | /* dereference all the imgages */ | |
| 2856 | while(images) { | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16121
diff
changeset
|
2857 | purple_imgstore_unref_by_id(GPOINTER_TO_INT(images->data)); |
| 10977 | 2858 | images = g_list_delete_link(images, images); |
| 2859 | } | |
| 2860 | } | |
| 2861 | ||
| 2862 | ||
| 2863 | static void mw_conversation_recv(struct mwConversation *conv, | |
| 2864 | enum mwImSendType type, | |
| 2865 | gconstpointer msg) { | |
| 2866 | struct mwServiceIm *srvc; | |
| 2867 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2868 | struct mwPurpleProtocolData *pd; |
| 10977 | 2869 | |
| 2870 | srvc = mwConversation_getService(conv); | |
| 2871 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2872 | pd = mwSession_getClientData(session); | |
| 2873 | ||
| 2874 | switch(type) { | |
| 2875 | case mwImSend_PLAIN: | |
| 2876 | im_recv_text(conv, pd, msg); | |
| 2877 | break; | |
| 2878 | ||
| 2879 | case mwImSend_TYPING: | |
| 2880 | im_recv_typing(conv, pd, !! msg); | |
| 2881 | break; | |
| 2882 | ||
| 2883 | case mwImSend_HTML: | |
| 2884 | im_recv_html(conv, pd, msg); | |
| 2885 | break; | |
| 2886 | ||
| 2887 | case mwImSend_SUBJECT: | |
| 2888 | im_recv_subj(conv, pd, msg); | |
| 2889 | break; | |
| 2890 | ||
| 2891 | case mwImSend_MIME: | |
| 2892 | im_recv_mime(conv, pd, msg); | |
| 2893 | break; | |
| 2894 | ||
| 2895 | default: | |
| 2896 | DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
| 2897 | ; /* erm... */ | |
| 2898 | } | |
| 2899 | } | |
| 2900 | ||
| 2901 | ||
| 2902 | static void mw_place_invite(struct mwConversation *conv, | |
| 2903 | const char *message, | |
| 2904 | const char *title, const char *name) { | |
| 2905 | struct mwServiceIm *srvc; | |
| 2906 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2907 | struct mwPurpleProtocolData *pd; |
| 10977 | 2908 | |
| 2909 | struct mwIdBlock *idb; | |
| 2910 | GHashTable *ht; | |
| 2911 | ||
| 2912 | srvc = mwConversation_getService(conv); | |
| 2913 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2914 | pd = mwSession_getClientData(session); | |
| 2915 | ||
| 2916 | idb = mwConversation_getTarget(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2917 | |
| 10977 | 2918 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 2919 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
| 2920 | g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
| 2921 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
| 2922 | g_hash_table_insert(ht, CHAT_KEY_INVITE, g_strdup(message)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2923 | g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
| 10977 | 2924 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2925 | if(! title) title = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2926 | if(! message) message = "(no message)"; |
| 10977 | 2927 | serv_got_chat_invite(pd->gc, title, idb->user, message, ht); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2928 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2929 | mwConversation_close(conv, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2930 | mwConversation_free(conv); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2931 | } |
| 10977 | 2932 | |
| 2933 | ||
| 2934 | static void mw_im_clear(struct mwServiceIm *srvc) { | |
| 2935 | ; | |
| 2936 | } | |
| 2937 | ||
| 2938 | ||
| 2939 | static struct mwImHandler mw_im_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2940 | mw_conversation_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2941 | mw_conversation_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2942 | mw_conversation_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2943 | mw_place_invite, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2944 | mw_im_clear, |
| 10977 | 2945 | }; |
| 2946 | ||
| 2947 | ||
| 2948 | static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
| 2949 | struct mwServiceIm *srvc; | |
| 2950 | srvc = mwServiceIm_new(s, &mw_im_handler); | |
| 2951 | mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
| 2952 | return srvc; | |
| 2953 | } | |
| 2954 | ||
| 2955 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2956 | /* The following helps us relate a mwPlace to a PurpleChatConversation in the |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2957 | various forms by which either may be indicated. Uses some of |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2958 | the similar macros from the conference service above */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2959 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2960 | #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2961 | #define ID_TO_PLACE(pd, id) (place_find_by_id((pd), (id))) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2962 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2963 | #define CHAT_TO_PLACE(pd, chat) (ID_TO_PLACE((pd), CHAT_TO_ID(chat))) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2964 | #define PLACE_TO_CHAT(place) (ID_TO_CHAT(PLACE_TO_ID(place))) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2965 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2966 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2967 | static struct mwPlace * |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2968 | place_find_by_id(struct mwPurpleProtocolData *pd, int id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2969 | struct mwServicePlace *srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2970 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2971 | GList *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2972 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2973 | l = (GList *) mwServicePlace_getPlaces(srvc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2974 | for(; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2975 | struct mwPlace *p = l->data; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2976 | PurpleChatConversation *h = mwPlace_getClientData(p); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2977 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2978 | if(CHAT_TO_ID(h) == id) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2979 | place = p; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2980 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2981 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2982 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2983 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2984 | return place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2985 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2986 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2987 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2988 | static void mw_place_opened(struct mwPlace *place) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2989 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2990 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2991 | struct mwPurpleProtocolData *pd; |
| 15884 | 2992 | PurpleConnection *gc; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2993 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2994 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2995 | GList *members, *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2996 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2997 | const char *n = mwPlace_getName(place); |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2998 | const char *t = mwPlace_getTitle(place); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2999 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3000 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3001 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3002 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3003 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3004 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3005 | members = mwPlace_getMembers(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3006 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3007 | DEBUG_INFO("place %s opened, %u initial members\n", |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3008 | NSTR(n), g_list_length(members)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3009 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
3010 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
3011 | gconf = serv_got_joined_chat(gc, PLACE_TO_ID(place), t); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3012 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3013 | mwPlace_setClientData(place, gconf, NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3014 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3015 | for(l = members; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3016 | struct mwIdBlock *idb = l->data; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3017 | purple_chat_conversation_add_user(gconf, idb->user, |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
3018 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3019 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3020 | g_list_free(members); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3021 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3022 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3023 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3024 | static void mw_place_closed(struct mwPlace *place, guint32 code) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3025 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3026 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3027 | struct mwPurpleProtocolData *pd; |
| 15884 | 3028 | PurpleConnection *gc; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3029 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3030 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3031 | char *msg = mwError(code); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3032 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3033 | DEBUG_INFO("place %s closed, 0x%08x\n", NSTR(n), code); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3034 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3035 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3036 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3037 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3038 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3039 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3040 | serv_got_chat_left(gc, PLACE_TO_ID(place)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3041 | |
| 15884 | 3042 | purple_notify_error(gc, _("Place Closed"), NULL, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3043 | g_free(msg); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3044 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3045 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3046 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3047 | static void mw_place_peerJoined(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3048 | const struct mwIdBlock *peer) { |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3049 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3050 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3051 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3052 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3053 | DEBUG_INFO("%s joined place %s\n", NSTR(peer->user), NSTR(n)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3054 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3055 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3056 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3057 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3058 | purple_chat_conversation_add_user(gconf, peer->user, |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
3059 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3060 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3061 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3062 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3063 | static void mw_place_peerParted(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3064 | const struct mwIdBlock *peer) { |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3065 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3066 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3067 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3068 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3069 | DEBUG_INFO("%s left place %s\n", NSTR(peer->user), NSTR(n)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3070 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3071 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3072 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3073 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3074 | purple_chat_conversation_remove_user(gconf, peer->user, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3075 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3076 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3077 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3078 | static void mw_place_peerSetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3079 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3080 | guint32 attr, struct mwOpaque *o) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3081 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3082 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3083 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3084 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3085 | static void mw_place_peerUnsetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3086 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3087 | guint32 attr) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3088 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3089 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3090 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3091 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3092 | static void mw_place_message(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3093 | const struct mwIdBlock *who, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3094 | const char *msg) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3095 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3096 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3097 | struct mwPurpleProtocolData *pd; |
| 15884 | 3098 | PurpleConnection *gc; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3099 | char *esc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3100 | |
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3101 | if(! msg) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3102 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3103 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3104 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3105 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3106 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3107 | |
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
3108 | esc = g_markup_escape_text(msg, -1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3109 | serv_got_chat_in(gc, PLACE_TO_ID(place), who->user, 0, esc, time(NULL)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3110 | g_free(esc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3111 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3112 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3113 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3114 | static void mw_place_clear(struct mwServicePlace *srvc) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3115 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3116 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3117 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3118 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3119 | static struct mwPlaceHandler mw_place_handler = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3120 | mw_place_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3121 | mw_place_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3122 | mw_place_peerJoined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3123 | mw_place_peerParted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3124 | mw_place_peerSetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3125 | mw_place_peerUnsetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3126 | mw_place_message, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3127 | mw_place_clear, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3128 | }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3129 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3130 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3131 | static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3132 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3133 | srvc = mwServicePlace_new(s, &mw_place_handler); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3134 | return srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3135 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3136 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3137 | |
| 10977 | 3138 | static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
| 3139 | struct mwServiceResolve *srvc; | |
| 3140 | srvc = mwServiceResolve_new(s); | |
| 3141 | return srvc; | |
| 3142 | } | |
| 3143 | ||
| 3144 | ||
| 3145 | static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
| 3146 | struct mwServiceStorage *srvc; | |
| 3147 | srvc = mwServiceStorage_new(s); | |
| 3148 | return srvc; | |
| 3149 | } | |
| 3150 | ||
| 3151 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3152 | /** allocate and associate a mwPurpleProtocolData with a PurpleConnection */ |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3153 | static struct mwPurpleProtocolData *mwPurpleProtocolData_new(PurpleConnection *gc) { |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3154 | struct mwPurpleProtocolData *pd; |
| 10977 | 3155 | |
| 3156 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3157 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3158 | pd = g_new0(struct mwPurpleProtocolData, 1); |
| 10977 | 3159 | pd->gc = gc; |
| 3160 | pd->session = mwSession_new(&mw_session_handler); | |
| 3161 | pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
| 3162 | pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
| 3163 | pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
| 3164 | pd->srvc_im = mw_srvc_im_new(pd->session); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3165 | pd->srvc_place = mw_srvc_place_new(pd->session); |
| 10977 | 3166 | pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
| 3167 | pd->srvc_store = mw_srvc_store_new(pd->session); | |
| 3168 | pd->group_list_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
3169 | pd->sock_buf = purple_circular_buffer_new(0); |
| 10977 | 3170 | |
| 3171 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
| 3172 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
| 3173 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
| 3174 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3175 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
| 10977 | 3176 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
| 3177 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
| 3178 | ||
| 3179 | mwSession_addCipher(pd->session, mwCipher_new_RC2_40(pd->session)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3180 | mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 10977 | 3181 | |
| 3182 | mwSession_setClientData(pd->session, pd, NULL); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3183 | purple_connection_set_protocol_data(gc, pd); |
| 10977 | 3184 | |
| 3185 | return pd; | |
| 3186 | } | |
| 3187 | ||
| 3188 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3189 | static void mwPurpleProtocolData_free(struct mwPurpleProtocolData *pd) { |
| 10977 | 3190 | g_return_if_fail(pd != NULL); |
| 3191 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3192 | purple_connection_set_protocol_data(pd->gc, NULL); |
| 10977 | 3193 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3194 | mwSession_removeService(pd->session, mwService_AWARE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3195 | mwSession_removeService(pd->session, mwService_CONFERENCE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3196 | mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3197 | mwSession_removeService(pd->session, mwService_IM); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3198 | mwSession_removeService(pd->session, mwService_PLACE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3199 | mwSession_removeService(pd->session, mwService_RESOLVE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3200 | mwSession_removeService(pd->session, mwService_STORAGE); |
| 10977 | 3201 | |
| 3202 | mwService_free(MW_SERVICE(pd->srvc_aware)); | |
| 3203 | mwService_free(MW_SERVICE(pd->srvc_conf)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3204 | mwService_free(MW_SERVICE(pd->srvc_ft)); |
| 10977 | 3205 | mwService_free(MW_SERVICE(pd->srvc_im)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3206 | mwService_free(MW_SERVICE(pd->srvc_place)); |
| 10977 | 3207 | mwService_free(MW_SERVICE(pd->srvc_resolve)); |
| 3208 | mwService_free(MW_SERVICE(pd->srvc_store)); | |
| 3209 | ||
| 3210 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3211 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
| 10977 | 3212 | |
| 3213 | mwSession_free(pd->session); | |
| 3214 | ||
| 3215 | g_hash_table_destroy(pd->group_list_map); | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
3216 | g_object_unref(G_OBJECT(pd->sock_buf)); |
| 10977 | 3217 | |
| 3218 | g_free(pd); | |
| 3219 | } | |
| 3220 | ||
| 3221 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3222 | static const char *mw_protocol_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
| 10977 | 3223 | /* my little green dude is a chopped up version of the aim running |
| 3224 | guy. First, cut off the head and store someplace safe. Then, | |
| 3225 | take the left-half side of the body and throw it away. Make a | |
| 3226 | copy of the remaining body, and flip it horizontally. Now attach | |
| 3227 | the two pieces into an X shape, and drop the head back on the | |
| 3228 | top, being careful to center it. Then, just change the color | |
| 3229 | saturation to bring the red down a bit, and voila! */ | |
| 3230 | ||
| 3231 | /* then, throw all of that away and use sodipodi to make a new | |
| 3232 | icon. You know, LIKE A REAL MAN. */ | |
| 3233 | ||
| 3234 | return "meanwhile"; | |
| 3235 | } | |
| 3236 | ||
| 3237 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3238 | static const char* mw_protocol_list_emblem(PurpleBuddy *b) |
| 15524 | 3239 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3240 | if(buddy_is_external(b)) |
| 15524 | 3241 | return "external"; |
| 3242 | ||
| 3243 | return NULL; | |
| 10977 | 3244 | } |
| 3245 | ||
| 3246 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3247 | static char *mw_protocol_status_text(PurpleBuddy *b) { |
| 15884 | 3248 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3249 | struct mwPurpleProtocolData *pd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3250 | struct mwAwareIdBlock t = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3251 | const char *ret = NULL; |
|
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3252 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3253 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3254 | && (pd = purple_connection_get_protocol_data(gc))) |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3255 | ret = mwServiceAware_getText(pd->srvc_aware, &t); |
|
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3256 | |
|
18861
cdbebb5a39c3
Fixes Ticket #1707 Crash with invalid UTF-8 status message from other Sametime client
Sean Egan <seanegan@pidgin.im>
parents:
18190
diff
changeset
|
3257 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3258 | } |
| 3259 | ||
| 3260 | ||
| 15884 | 3261 | static const char *status_text(PurpleBuddy *b) { |
| 3262 | PurplePresence *presence; | |
| 3263 | PurpleStatus *status; | |
| 3264 | ||
| 3265 | presence = purple_buddy_get_presence(b); | |
| 3266 | status = purple_presence_get_active_status(presence); | |
| 3267 | ||
| 3268 | return purple_status_get_name(status); | |
| 10977 | 3269 | } |
| 3270 | ||
| 3271 | ||
| 3272 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3273 | const char *who, guint32 feature) { | |
| 3274 | ||
| 3275 | const struct mwAwareAttribute *attr; | |
| 3276 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3277 | ||
| 3278 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3279 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3280 | } | |
| 3281 | ||
| 3282 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3283 | static char *user_supports_text(struct mwServiceAware *srvc, const char *who) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3284 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3285 | const char **f = feat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3286 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3287 | if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3288 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3289 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3290 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3291 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3292 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3293 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3294 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3295 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3296 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3297 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3298 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3299 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3300 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3301 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3302 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3303 | /* jenni loves siege */ |
| 10977 | 3304 | } |
| 3305 | ||
| 3306 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3307 | static void mw_protocol_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { |
| 15884 | 3308 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3309 | struct mwPurpleProtocolData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3310 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3311 | |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3312 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3313 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3314 | char *tmp; |
| 10977 | 3315 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3316 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3317 | && (pd = purple_connection_get_protocol_data(gc))) |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3318 | message = mwServiceAware_getText(pd->srvc_aware, &idb); |
|
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3319 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3320 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3321 | |
|
18861
cdbebb5a39c3
Fixes Ticket #1707 Crash with invalid UTF-8 status message from other Sametime client
Sean Egan <seanegan@pidgin.im>
parents:
18190
diff
changeset
|
3322 | if(message != NULL && g_utf8_validate(message, -1, NULL) && purple_utf8_strcasecmp(status, message)) { |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
3323 | purple_notify_user_info_add_pair_plaintext(user_info, status, message); |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3324 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3325 | } else { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
3326 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status); |
| 10977 | 3327 | } |
| 3328 | ||
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3329 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3330 | tmp = user_supports_text(pd->srvc_aware, purple_buddy_get_name(b)); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3331 | if(tmp) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
3332 | purple_notify_user_info_add_pair_plaintext(user_info, _("Supports"), tmp); |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3333 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3334 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3335 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3336 | if(buddy_is_external(b)) { |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
3337 | purple_notify_user_info_add_pair_plaintext(user_info, NULL, _("External User")); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3338 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3339 | } |
| 10977 | 3340 | } |
| 3341 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3342 | static GList *mw_protocol_status_types(PurpleAccount *acct) |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3343 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3344 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3345 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3346 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3347 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3348 | MW_STATE_ACTIVE, NULL, TRUE, TRUE, FALSE, |
|
34811
377d4d43e0e0
Refactored the remaining protocols to use GType and GValue instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34746
diff
changeset
|
3349 | MW_STATE_MESSAGE, _("Message"), purple_g_value_new(G_TYPE_STRING), |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3350 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3351 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3352 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3353 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY, |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3354 | MW_STATE_AWAY, NULL, TRUE, TRUE, FALSE, |
|
34811
377d4d43e0e0
Refactored the remaining protocols to use GType and GValue instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34746
diff
changeset
|
3355 | MW_STATE_MESSAGE, _("Message"), purple_g_value_new(G_TYPE_STRING), |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3356 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3357 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3358 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3359 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_UNAVAILABLE, |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3360 | MW_STATE_BUSY, _("Do Not Disturb"), TRUE, TRUE, FALSE, |
|
34811
377d4d43e0e0
Refactored the remaining protocols to use GType and GValue instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34746
diff
changeset
|
3361 | MW_STATE_MESSAGE, _("Message"), purple_g_value_new(G_TYPE_STRING), |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3362 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3363 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3364 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3365 | type = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3366 | MW_STATE_OFFLINE, NULL, TRUE, TRUE, FALSE); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3367 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3368 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3369 | return types; |
| 10977 | 3370 | } |
| 3371 | ||
| 3372 | ||
| 15884 | 3373 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3374 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3375 | ; /* nothing to do */ |
| 10977 | 3376 | } |
| 3377 | ||
| 3378 | ||
| 15884 | 3379 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3380 | PurpleRequestFields *fields) { | |
| 3381 | PurpleAccount *acct; | |
| 3382 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3383 | struct mwPurpleProtocolData *pd; |
| 10977 | 3384 | struct mwServiceConference *srvc; |
| 3385 | ||
| 15884 | 3386 | PurpleRequestField *f; |
| 10977 | 3387 | |
| 3388 | const char *topic, *invite; | |
| 3389 | struct mwConference *conf; | |
| 3390 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3391 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3392 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3393 | gc = purple_account_get_connection(acct); |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3394 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3395 | srvc = pd->srvc_conf; |
| 3396 | ||
| 15884 | 3397 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3398 | topic = purple_request_field_string_get_value(f); | |
| 3399 | ||
| 3400 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3401 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3402 | |
| 3403 | conf = mwConference_new(srvc, topic); | |
| 3404 | mwConference_open(conf); | |
| 3405 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3406 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3407 | mwConference_invite(conf, &idb, invite); |
| 3408 | } | |
| 3409 | ||
| 3410 | ||
| 15884 | 3411 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3412 | ||
| 3413 | PurpleRequestFields *fields; | |
| 3414 | PurpleRequestFieldGroup *g; | |
| 3415 | PurpleRequestField *f; | |
| 3416 | ||
| 3417 | PurpleAccount *acct; | |
| 3418 | PurpleConnection *gc; | |
| 10977 | 3419 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3420 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3421 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3422 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3423 | |
| 10977 | 3424 | g_return_if_fail(buddy != NULL); |
| 3425 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3426 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3427 | g_return_if_fail(acct != NULL); |
| 3428 | ||
| 15884 | 3429 | gc = purple_account_get_connection(acct); |
| 10977 | 3430 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3431 | |
| 15884 | 3432 | fields = purple_request_fields_new(); |
| 3433 | ||
| 3434 | g = purple_request_field_group_new(NULL); | |
| 3435 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3436 | |
| 15884 | 3437 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3438 | purple_request_field_group_add_field(g, f); | |
| 3439 | ||
| 3440 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3441 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3442 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3443 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3444 | msgB = _("Please enter a topic for the new conference, and an invitation" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3445 | " message to be sent to %s"); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3446 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3447 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3448 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3449 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3450 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3451 | _("Cancel"), G_CALLBACK(conf_create_prompt_cancel), |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16121
diff
changeset
|
3452 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3453 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3454 | g_free(msg1); |
| 10977 | 3455 | } |
| 3456 | ||
| 3457 | ||
| 15884 | 3458 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3459 | PurpleRequestFields *fields) { | |
| 10977 | 3460 | ; |
| 3461 | } | |
| 3462 | ||
| 3463 | ||
| 15884 | 3464 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3465 | PurpleRequestFields *fields) { | |
| 3466 | PurpleRequestField *f; | |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
17157
diff
changeset
|
3467 | GList *l; |
| 10977 | 3468 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3469 | |
| 15884 | 3470 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3471 | msg = purple_request_field_string_get_value(f); | |
| 3472 | ||
| 3473 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3474 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3475 | |
| 3476 | if(l) { | |
| 15884 | 3477 | gpointer d = purple_request_field_list_get_data(f, l->data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3478 | |
| 10977 | 3479 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3480 | blist_menu_conf_create(buddy, msg); | |
| 3481 | ||
| 3482 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3483 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3484 | mwConference_invite(d, &idb, msg); |
| 3485 | } | |
| 3486 | } | |
| 3487 | } | |
| 3488 | ||
| 3489 | ||
| 15884 | 3490 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3491 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3492 | |
| 15884 | 3493 | PurpleRequestFields *fields; |
| 3494 | PurpleRequestFieldGroup *g; | |
| 3495 | PurpleRequestField *f; | |
| 3496 | ||
| 3497 | PurpleAccount *acct; | |
| 3498 | PurpleConnection *gc; | |
| 10977 | 3499 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3500 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3501 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3502 | char *msg; |
| 10977 | 3503 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3504 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3505 | g_return_if_fail(acct != NULL); |
| 3506 | ||
| 15884 | 3507 | gc = purple_account_get_connection(acct); |
| 10977 | 3508 | g_return_if_fail(gc != NULL); |
| 3509 | ||
| 15884 | 3510 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3511 | |
| 15884 | 3512 | g = purple_request_field_group_new(NULL); |
| 3513 | purple_request_fields_add_group(fields, g); | |
| 3514 | ||
| 3515 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3516 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3517 | for(; confs; confs = confs->next) { |
| 3518 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3519 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3520 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3521 | purple_request_field_list_add_icon(f, _("Create New Conference..."), |
|
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3522 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3523 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3524 | |
| 15884 | 3525 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3526 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3527 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3528 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3529 | msgB = _("Select a conference from the list below to send an invite to" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3530 | " user %s. Select \"Create New Conference\" if you'd like to" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3531 | " create a new conference to invite this user to."); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3532 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3533 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3534 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3535 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3536 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3537 | _("Cancel"), G_CALLBACK(conf_select_prompt_cancel), |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16121
diff
changeset
|
3538 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3539 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3540 | g_free(msg); |
| 10977 | 3541 | } |
| 3542 | ||
| 3543 | ||
| 15884 | 3544 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 3545 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3546 | PurpleAccount *acct; | |
| 3547 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3548 | struct mwPurpleProtocolData *pd; |
| 10977 | 3549 | GList *l; |
| 3550 | ||
| 3551 | g_return_if_fail(node != NULL); | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3552 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 10977 | 3553 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3554 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3555 | g_return_if_fail(acct != NULL); |
| 3556 | ||
| 15884 | 3557 | gc = purple_account_get_connection(acct); |
| 10977 | 3558 | g_return_if_fail(gc != NULL); |
| 3559 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3560 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3561 | g_return_if_fail(pd != NULL); |
| 3562 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3563 | /* |
| 10977 | 3564 | - get a list of all conferences on this session |
| 3565 | - if none, prompt to create one, and invite buddy to it | |
| 3566 | - else, prompt to select a conference or create one | |
| 3567 | */ | |
| 3568 | ||
| 3569 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3570 | if(l) { | |
| 3571 | blist_menu_conf_list(buddy, l); | |
| 3572 | g_list_free(l); | |
| 3573 | ||
| 3574 | } else { | |
| 3575 | blist_menu_conf_create(buddy, NULL); | |
| 3576 | } | |
| 3577 | } | |
| 3578 | ||
| 3579 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3580 | #if 0 |
| 15884 | 3581 | static void blist_menu_announce(PurpleBlistNode *node, gpointer data) { |
| 3582 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3583 | PurpleAccount *acct; | |
| 3584 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3585 | struct mwPurpleProtocolData *pd; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3586 | struct mwSession *session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3587 | char *rcpt_name; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3588 | GList *rcpt; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3589 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3590 | g_return_if_fail(node != NULL); |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3591 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3592 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3593 | acct = buddy->account; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3594 | g_return_if_fail(acct != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3595 | |
| 15884 | 3596 | gc = purple_account_get_connection(acct); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3597 | g_return_if_fail(gc != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3598 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3599 | pd = purple_connection_get_protocol_data(gc); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3600 | g_return_if_fail(pd != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3601 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3602 | rcpt_name = g_strdup_printf("@U %s", buddy->name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3603 | rcpt = g_list_prepend(NULL, rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3604 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3605 | session = pd->session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3606 | mwSession_sendAnnounce(session, FALSE, |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3607 | "This is a TEST announcement. Please ignore.", |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3608 | rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3609 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3610 | g_list_free(rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3611 | g_free(rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3612 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3613 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3614 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3615 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3616 | static GList *mw_protocol_blist_node_menu(PurpleBlistNode *node) { |
| 10977 | 3617 | GList *l = NULL; |
| 15884 | 3618 | PurpleMenuAction *act; |
| 3619 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3620 | if(! PURPLE_IS_BUDDY(node)) |
| 10977 | 3621 | return l; |
| 3622 | ||
| 3623 | l = g_list_append(l, NULL); | |
| 3624 | ||
| 15884 | 3625 | act = purple_menu_action_new(_("Invite to Conference..."), |
| 3626 | PURPLE_CALLBACK(blist_menu_conf), NULL, NULL); | |
| 10977 | 3627 | l = g_list_append(l, act); |
| 3628 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3629 | #if 0 |
| 15884 | 3630 | act = purple_menu_action_new(_("Send TEST Announcement"), |
| 3631 | PURPLE_CALLBACK(blist_menu_announce), NULL, NULL); | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3632 | l = g_list_append(l, act); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3633 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3634 | |
| 15884 | 3635 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3636 | blist-node-extended-menu signal for that. The function |
| 3637 | blist_node_menu_cb is assigned to this signal in the function | |
| 3638 | services_starting */ | |
| 3639 | ||
| 3640 | return l; | |
| 3641 | } | |
| 3642 | ||
| 3643 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3644 | static GList *mw_protocol_chat_info(PurpleConnection *gc) { |
| 10977 | 3645 | GList *l = NULL; |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3646 | PurpleProtocolChatEntry *pce; |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3647 | |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3648 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3649 | pce->label = _("Topic:"); |
| 10977 | 3650 | pce->identifier = CHAT_KEY_TOPIC; |
| 3651 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3652 | |
| 10977 | 3653 | return l; |
| 3654 | } | |
| 3655 | ||
| 3656 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3657 | static GHashTable *mw_protocol_chat_info_defaults(PurpleConnection *gc, |
| 10977 | 3658 | const char *name) { |
| 3659 | GHashTable *table; | |
| 3660 | ||
| 3661 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3662 | ||
| 3663 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3664 | NULL, g_free); | |
| 3665 | ||
| 3666 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3667 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3668 | ||
| 3669 | return table; | |
| 3670 | } | |
| 3671 | ||
| 3672 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3673 | static void mw_protocol_login(PurpleAccount *acct); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3674 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3675 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3676 | static void mw_protocol_login(PurpleAccount *account) { |
| 15884 | 3677 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3678 | struct mwPurpleProtocolData *pd; |
| 10977 | 3679 | |
| 3680 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3681 | guint port; |
| 10977 | 3682 | |
| 15884 | 3683 | gc = purple_account_get_connection(account); |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3684 | pd = mwPurpleProtocolData_new(gc); |
| 10977 | 3685 | |
| 3686 | /* while we do support images, the default is to not offer it */ | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
3687 | purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_IMAGES); |
| 15884 | 3688 | |
| 3689 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3690 | |
| 3691 | host = strrchr(user, ':'); | |
| 3692 | if(host) { | |
| 3693 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3694 | *host++ = '\0'; | |
| 15884 | 3695 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3696 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3697 | |
| 10977 | 3698 | } else { |
| 15884 | 3699 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3700 | MW_PLUGIN_DEFAULT_HOST); |
| 3701 | } | |
| 3702 | ||
| 3703 | if(! host || ! *host) { | |
| 3704 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3705 | to actually continue, so let's ask the user directly. */ | |
|
25292
5b4e719c5bbb
Fix a potential leak "KuSh" discovered using "cppcheck". Fixes #7862.
Daniel Atallah <datallah@pidgin.im>
parents:
25181
diff
changeset
|
3706 | g_free(user); |
|
32636
b5255be84952
Fix a mistake I made while manually propagating from im.pidgin.pidgin.2.x.y
Mark Doliner <markdoliner@pidgin.im>
parents:
32635
diff
changeset
|
3707 | purple_connection_error(gc, |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
3708 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
3709 | _("A server is required to connect this account")); |
| 10977 | 3710 | return; |
| 3711 | } | |
| 3712 | ||
|
34022
c49f6e9ea27d
Make all the prpls build.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
3713 | pass = g_strdup(purple_connection_get_password(gc)); |
| 15884 | 3714 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3715 | |
| 3716 | DEBUG_INFO("user: '%s'\n", user); | |
| 3717 | DEBUG_INFO("host: '%s'\n", host); | |
| 3718 | DEBUG_INFO("port: %u\n", port); | |
| 3719 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3720 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3721 | (char *) no_secret, NULL); |
| 3722 | mwSession_setProperty(pd->session, mwSession_AUTH_USER_ID, user, g_free); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3723 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3724 | |
| 15884 | 3725 | if(purple_account_get_bool(account, MW_KEY_FAKE_IT, FALSE)) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3726 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3727 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3728 | /* if we're faking the login, let's also fake the version we're |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3729 | reporting. Let's also allow the actual values to be specified */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3730 | |
| 15884 | 3731 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3732 | major = purple_account_get_int(account, MW_KEY_MAJOR, 0x001e); | |
|
21947
3b04dd98ba04
avoid some version blocking servers by updating the major version specified when 'Hide client ID' is specified for an account
Christopher O'Brien <siege@pidgin.im>
parents:
21630
diff
changeset
|
3733 | minor = purple_account_get_int(account, MW_KEY_MINOR, 0x196f); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3734 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3735 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3736 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3737 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3738 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3739 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3740 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3741 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3742 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3743 | GUINT_TO_POINTER(major), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3744 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3745 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3746 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3747 | } |
| 10977 | 3748 | |
| 15884 | 3749 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3750 | ||
| 3751 | if (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL) { | |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
3752 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
3753 | _("Unable to connect")); |
| 10977 | 3754 | } |
| 3755 | } | |
| 3756 | ||
| 3757 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3758 | static void mw_protocol_close(PurpleConnection *gc) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3759 | struct mwPurpleProtocolData *pd; |
| 10977 | 3760 | |
| 3761 | g_return_if_fail(gc != NULL); | |
| 3762 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3763 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3764 | g_return_if_fail(pd != NULL); |
| 3765 | ||
| 3766 | /* get rid of the blist save timeout */ | |
| 3767 | if(pd->save_event) { | |
| 15884 | 3768 | purple_timeout_remove(pd->save_event); |
| 10977 | 3769 | pd->save_event = 0; |
| 3770 | blist_store(pd); | |
| 3771 | } | |
| 3772 | ||
| 3773 | /* stop the session */ | |
| 3774 | mwSession_stop(pd->session, 0x00); | |
| 3775 | ||
| 3776 | /* no longer necessary */ | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3777 | purple_connection_set_protocol_data(gc, NULL); |
| 10977 | 3778 | |
| 3779 | /* stop watching the socket */ | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3780 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3781 | purple_input_remove(pd->inpa); |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3782 | pd->inpa = 0; |
| 10977 | 3783 | } |
| 3784 | ||
| 3785 | /* clean up the rest */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3786 | mwPurpleProtocolData_free(pd); |
| 10977 | 3787 | } |
| 3788 | ||
| 3789 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21947
diff
changeset
|
3790 | static int mw_rand(void) { |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3791 | static int seed = 0; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3792 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3793 | /* for diversity, not security. don't touch */ |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3794 | srand(time(NULL) ^ seed); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3795 | seed = rand(); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3796 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3797 | return seed; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3798 | } |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3799 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3800 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3801 | /** generates a random-ish content id string */ |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21947
diff
changeset
|
3802 | static char *im_mime_content_id(void) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3803 | return g_strdup_printf("%03x@%05xmeanwhile", |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3804 | mw_rand() & 0xfff, mw_rand() & 0xfffff); |
| 10977 | 3805 | } |
| 3806 | ||
| 3807 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3808 | /** generates a multipart/related content type with a random-ish |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3809 | boundary value */ |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21947
diff
changeset
|
3810 | static char *im_mime_content_type(void) { |
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3811 | return g_strdup_printf("multipart/related; boundary=related_MW%03x_%04x", |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3812 | mw_rand() & 0xfff, mw_rand() & 0xffff); |
| 10977 | 3813 | } |
| 3814 | ||
| 3815 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3816 | /** determine content type from extension. Not so happy about this, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3817 | but I don't want to actually write image type detection */ |
| 15884 | 3818 | static char *im_mime_img_content_type(PurpleStoredImage *img) { |
| 3819 | const char *fn = purple_imgstore_get_filename(img); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3820 | const char *ct = NULL; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3821 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3822 | ct = strrchr(fn, '.'); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3823 | if(! ct) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3824 | ct = "image"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3825 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3826 | } else if(! strcmp(".png", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3827 | ct = "image/png"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3828 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3829 | } else if(! strcmp(".jpg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3830 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3831 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3832 | } else if(! strcmp(".jpeg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3833 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3834 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3835 | } else if(! strcmp(".gif", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3836 | ct = "image/gif"; |
| 10977 | 3837 | |
| 3838 | } else { | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3839 | ct = "image"; |
| 10977 | 3840 | } |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3841 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3842 | return g_strdup_printf("%s; name=\"%s\"", ct, fn); |
| 10977 | 3843 | } |
| 3844 | ||
| 3845 | ||
| 15884 | 3846 | static char *im_mime_img_content_disp(PurpleStoredImage *img) { |
| 3847 | const char *fn = purple_imgstore_get_filename(img); | |
| 10977 | 3848 | return g_strdup_printf("attachment; filename=\"%s\"", fn); |
| 3849 | } | |
| 3850 | ||
| 3851 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3852 | /** turn an IM with embedded images into a multi-part mime document */ |
| 15884 | 3853 | static char *im_mime_convert(PurpleConnection *gc, |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3854 | struct mwConversation *conv, |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3855 | const char *message) { |
| 10977 | 3856 | GString *str; |
| 15884 | 3857 | PurpleMimeDocument *doc; |
| 3858 | PurpleMimePart *part; | |
| 10977 | 3859 | |
| 3860 | GData *attr; | |
| 3861 | char *tmp, *start, *end; | |
| 3862 | ||
| 3863 | str = g_string_new(NULL); | |
| 3864 | ||
| 15884 | 3865 | doc = purple_mime_document_new(); |
| 3866 | ||
| 3867 | purple_mime_document_set_field(doc, "Mime-Version", "1.0"); | |
| 3868 | purple_mime_document_set_field(doc, "Content-Disposition", "inline"); | |
| 10977 | 3869 | |
| 3870 | tmp = im_mime_content_type(); | |
| 15884 | 3871 | purple_mime_document_set_field(doc, "Content-Type", tmp); |
| 10977 | 3872 | g_free(tmp); |
| 3873 | ||
| 3874 | tmp = (char *) message; | |
| 15884 | 3875 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 3876 | (const char **) &end, &attr)) { |
| 3877 | char *id; | |
| 15884 | 3878 | PurpleStoredImage *img = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3879 | |
| 10977 | 3880 | gsize len = (start - tmp); |
| 3881 | ||
| 3882 | /* append the in-between-tags text */ | |
| 3883 | if(len) g_string_append_len(str, tmp, len); | |
| 3884 | ||
| 3885 | /* find the imgstore data by the id tag */ | |
| 3886 | id = g_datalist_get_data(&attr, "id"); | |
| 3887 | if(id && *id) | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16121
diff
changeset
|
3888 | img = purple_imgstore_find_by_id(atoi(id)); |
| 10977 | 3889 | |
| 3890 | if(img) { | |
| 3891 | char *cid; | |
| 3892 | gpointer data; | |
| 3893 | size_t size; | |
| 3894 | ||
| 15884 | 3895 | part = purple_mime_part_new(doc); |
| 10977 | 3896 | |
| 3897 | data = im_mime_img_content_disp(img); | |
| 15884 | 3898 | purple_mime_part_set_field(part, "Content-Disposition", data); |
| 10977 | 3899 | g_free(data); |
| 3900 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3901 | data = im_mime_img_content_type(img); |
| 15884 | 3902 | purple_mime_part_set_field(part, "Content-Type", data); |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3903 | g_free(data); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3904 | |
| 10977 | 3905 | cid = im_mime_content_id(); |
| 3906 | data = g_strdup_printf("<%s>", cid); | |
| 15884 | 3907 | purple_mime_part_set_field(part, "Content-ID", data); |
| 10977 | 3908 | g_free(data); |
| 3909 | ||
| 15884 | 3910 | purple_mime_part_set_field(part, "Content-transfer-encoding", "base64"); |
| 10977 | 3911 | |
| 3912 | /* obtain and base64 encode the image data, and put it in the | |
| 3913 | mime part */ | |
| 15884 | 3914 | size = purple_imgstore_get_size(img); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16121
diff
changeset
|
3915 | data = purple_base64_encode(purple_imgstore_get_data(img), (gsize) size); |
| 15884 | 3916 | purple_mime_part_set_data(part, data); |
| 10977 | 3917 | g_free(data); |
| 3918 | ||
| 3919 | /* append the modified tag */ | |
| 3920 | g_string_append_printf(str, "<img src=\"cid:%s\">", cid); | |
| 3921 | g_free(cid); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3922 | |
| 10977 | 3923 | } else { |
| 3924 | /* append the literal image tag, since we couldn't find a | |
| 3925 | relative imgstore object */ | |
| 3926 | gsize len = (end - start) + 1; | |
| 3927 | g_string_append_len(str, start, len); | |
| 3928 | } | |
| 3929 | ||
| 3930 | g_datalist_clear(&attr); | |
| 3931 | tmp = end + 1; | |
| 3932 | } | |
| 3933 | ||
| 3934 | /* append left-overs */ | |
| 3935 | g_string_append(str, tmp); | |
| 3936 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3937 | /* add the text/html part */ |
| 15884 | 3938 | part = purple_mime_part_new(doc); |
| 3939 | purple_mime_part_set_field(part, "Content-Disposition", "inline"); | |
| 3940 | ||
| 3941 | tmp = purple_utf8_ncr_encode(str->str); | |
| 3942 | purple_mime_part_set_field(part, "Content-Type", "text/html"); | |
| 3943 | purple_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); | |
| 3944 | purple_mime_part_set_data(part, tmp); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3945 | g_free(tmp); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3946 | |
| 10977 | 3947 | g_string_free(str, TRUE); |
| 3948 | ||
| 3949 | str = g_string_new(NULL); | |
| 15884 | 3950 | purple_mime_document_write(doc, str); |
| 10977 | 3951 | tmp = str->str; |
| 3952 | g_string_free(str, FALSE); | |
| 3953 | ||
| 3954 | return tmp; | |
| 3955 | } | |
| 3956 | ||
| 3957 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3958 | static int mw_protocol_send_im(PurpleConnection *gc, |
| 10977 | 3959 | const char *name, |
| 3960 | const char *message, | |
| 15884 | 3961 | PurpleMessageFlags flags) { |
| 3962 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3963 | struct mwPurpleProtocolData *pd; |
| 10977 | 3964 | struct mwIdBlock who = { (char *) name, NULL }; |
| 3965 | struct mwConversation *conv; | |
| 3966 | ||
| 3967 | g_return_val_if_fail(gc != NULL, 0); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3968 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3969 | |
| 3970 | g_return_val_if_fail(pd != NULL, 0); | |
| 3971 | ||
| 3972 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 3973 | ||
| 3974 | /* this detection of features to determine how to send the message | |
| 3975 | (plain, html, or mime) is flawed because the other end of the | |
| 3976 | conversation could close their channel at any time, rendering any | |
| 3977 | existing formatting in an outgoing message innapropriate. The end | |
| 3978 | result is that it may be possible that the other side of the | |
| 3979 | conversation will receive a plaintext message with html contents, | |
| 3980 | which is bad. I'm not sure how to fix this correctly. */ | |
| 3981 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3982 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 3983 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 3984 | |
| 3985 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3986 | char *tmp; |
| 10977 | 3987 | int ret; |
| 3988 | ||
| 15884 | 3989 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 3990 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3991 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3992 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3993 | tmp = im_mime_convert(gc, conv, message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3994 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3995 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3996 | |
| 10977 | 3997 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3998 | /* send an HTML message */ |
| 10977 | 3999 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4000 | char *ncr; |
| 15884 | 4001 | ncr = purple_utf8_ncr_encode(message); |
| 4002 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4003 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4004 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4005 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4006 | g_free(tmp); |
| 10977 | 4007 | |
| 4008 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4009 | /* default to text */ |
| 15884 | 4010 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4011 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4012 | g_free(tmp); |
| 10977 | 4013 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4014 | |
| 10977 | 4015 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4016 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4017 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4018 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4019 | /* queue up the message safely as plain text */ |
| 15884 | 4020 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4021 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4022 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4023 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4024 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4025 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4026 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4027 | return 1; |
| 10977 | 4028 | } |
| 4029 | } | |
| 4030 | ||
| 4031 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4032 | static unsigned int mw_protocol_send_typing(PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4033 | const char *name, |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
4034 | PurpleIMTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4035 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4036 | struct mwPurpleProtocolData *pd; |
| 10977 | 4037 | struct mwIdBlock who = { (char *) name, NULL }; |
| 4038 | struct mwConversation *conv; | |
| 4039 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
4040 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 4041 | |
| 4042 | g_return_val_if_fail(gc != NULL, 0); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4043 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4044 | |
| 4045 | g_return_val_if_fail(pd != NULL, 0); | |
| 4046 | ||
| 4047 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 4048 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4049 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4050 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4051 | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
4052 | } else if((state == PURPLE_IM_TYPING) || (state == PURPLE_IM_TYPED)) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4053 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4054 | when typing has stopped. There's no point in re-opening a |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4055 | channel just to tell someone that this side isn't typing. */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4056 | |
| 10977 | 4057 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4058 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4059 | if(! mwConversation_isPending(conv)) { |
| 10977 | 4060 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4061 | } |
| 10977 | 4062 | } |
| 4063 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4064 | return 0; |
| 10977 | 4065 | } |
| 4066 | ||
| 4067 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4068 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4069 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4070 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4071 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4072 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4073 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4074 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4075 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4076 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4077 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4078 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4079 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4080 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4081 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4082 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4083 | return "Lotus Sametime Links"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4084 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4085 | case mwLogin_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4086 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4087 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4088 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4089 | return "Lotus Notes Client"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4090 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4091 | case mwLogin_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4092 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4093 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4094 | return "IBM Community Tools"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4095 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4096 | case mwLogin_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4097 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4098 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4099 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4100 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4101 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4102 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4103 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4104 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4105 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4106 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4107 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4108 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4109 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4110 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4111 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4112 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4113 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4114 | return "Trillian"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4115 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4116 | case mwLogin_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4117 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4118 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4119 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4120 | return NULL; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4121 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4122 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4123 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4124 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4125 | static void mw_protocol_get_info(PurpleConnection *gc, const char *who) { |
| 10977 | 4126 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4127 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4128 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4129 | struct mwPurpleProtocolData *pd; |
| 15884 | 4130 | PurpleAccount *acct; |
| 4131 | PurpleBuddy *b; | |
| 4132 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4133 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4134 | const char *tmp2; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4135 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4136 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4137 | g_return_if_fail(*who != '\0'); |
| 10977 | 4138 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4139 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4140 | |
| 15884 | 4141 | acct = purple_connection_get_account(gc); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4142 | b = purple_blist_find_buddy(acct, who); |
| 15884 | 4143 | user_info = purple_notify_user_info_new(); |
| 4144 | ||
| 4145 | if(purple_str_has_prefix(who, "@E ")) { | |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
4146 | purple_notify_user_info_add_pair_html(user_info, _("External User"), NULL); |
| 10977 | 4147 | } |
| 4148 | ||
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4149 | purple_notify_user_info_add_pair_plaintext(user_info, _("User ID"), who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4150 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4151 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4152 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4153 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4154 | if(purple_buddy_get_server_alias(b)) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4155 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4156 | or if we should be using add_pair_plaintext */ |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
4157 | purple_notify_user_info_add_pair_html(user_info, _("Full Name"), purple_buddy_get_server_alias(b)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4158 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4159 | |
| 15884 | 4160 | type = purple_blist_node_get_int((PurpleBlistNode *) b, BUDDY_KEY_CLIENT); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4161 | if(type) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4162 | tmp2 = mw_client_name(type); |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4163 | if (tmp2) { |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4164 | purple_notify_user_info_add_pair_plaintext(user_info, _("Last Known Client"), tmp2); |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4165 | } else { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4166 | tmp = g_strdup_printf(_("Unknown (0x%04x)<br>"), type); |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
4167 | purple_notify_user_info_add_pair_html(user_info, _("Last Known Client"), tmp); |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4168 | g_free(tmp); |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4169 | } |
| 10977 | 4170 | } |
| 4171 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4172 | |
| 10977 | 4173 | tmp = user_supports_text(pd->srvc_aware, who); |
| 4174 | if(tmp) { | |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4175 | purple_notify_user_info_add_pair_plaintext(user_info, _("Supports"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4176 | g_free(tmp); |
| 10977 | 4177 | } |
| 4178 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4179 | if(b) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4180 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status_text(b)); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4181 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4182 | /* XXX Is this adding a status message in its own section rather than with the "Status" label? */ |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4183 | tmp2 = mwServiceAware_getText(pd->srvc_aware, &idb); |
|
18861
cdbebb5a39c3
Fixes Ticket #1707 Crash with invalid UTF-8 status message from other Sametime client
Sean Egan <seanegan@pidgin.im>
parents:
18190
diff
changeset
|
4184 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
| 15884 | 4185 | purple_notify_user_info_add_section_break(user_info); |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4186 | purple_notify_user_info_add_pair_plaintext(user_info, NULL, tmp2); |
|
12496
788b20ccec91
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4187 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4188 | } |
| 10977 | 4189 | |
| 4190 | /* @todo emit a signal to allow a plugin to override the display of | |
| 4191 | this notification, so that it can create its own */ | |
| 4192 | ||
| 15884 | 4193 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 4194 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 4195 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4196 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4197 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4198 | static void mw_protocol_set_status(PurpleAccount *acct, PurpleStatus *status) { |
| 15884 | 4199 | PurpleConnection *gc; |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4200 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
4201 | char *message = NULL; |
| 10977 | 4202 | struct mwSession *session; |
| 4203 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4204 | |
| 10977 | 4205 | g_return_if_fail(acct != NULL); |
| 15884 | 4206 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4207 | |
| 15884 | 4208 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4209 | |
| 15884 | 4210 | DEBUG_INFO("Set status to %s\n", purple_status_get_name(status)); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4211 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4212 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4213 | |
| 10977 | 4214 | session = gc_to_session(gc); |
| 4215 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4216 | |
| 10977 | 4217 | /* get a working copy of the current status */ |
| 4218 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4219 | |
| 10977 | 4220 | /* determine the state */ |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4221 | if(! strcmp(state, MW_STATE_ACTIVE)) { |
| 10977 | 4222 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4223 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4224 | } else if(! strcmp(state, MW_STATE_AWAY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4225 | stat.status = mwStatus_AWAY; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4226 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4227 | } else if(! strcmp(state, MW_STATE_BUSY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4228 | stat.status = mwStatus_BUSY; |
| 10977 | 4229 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4230 | |
| 10977 | 4231 | /* determine the message */ |
| 15884 | 4232 | message = (char *) purple_status_get_attr_string(status, MW_STATE_MESSAGE); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4233 | |
| 10977 | 4234 | if(message) { |
| 4235 | /* all the possible non-NULL values of message up to this point | |
| 4236 | are const, so we don't need to free them */ | |
| 15884 | 4237 | message = purple_markup_strip_html(message); |
| 10977 | 4238 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4239 | |
| 10977 | 4240 | /* out with the old */ |
| 4241 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4242 | |
| 10977 | 4243 | /* in with the new */ |
| 4244 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4245 | |
| 10977 | 4246 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4247 | mwUserStatus_clear(&stat); |
| 10977 | 4248 | } |
| 4249 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4250 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4251 | static void mw_protocol_set_idle(PurpleConnection *gc, int t) { |
| 10977 | 4252 | struct mwSession *session; |
| 4253 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4254 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4255 | |
| 10977 | 4256 | session = gc_to_session(gc); |
| 4257 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4258 | |
| 10977 | 4259 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4260 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4261 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4262 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4263 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4264 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4265 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4266 | stat.time = 0; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4267 | } |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4268 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4269 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4270 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4271 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4272 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4273 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4274 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4275 | stat.status = mwStatus_ACTIVE; |
| 4276 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4277 | |
| 10977 | 4278 | mwSession_setUserStatus(session, &stat); |
| 4279 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4280 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4281 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4282 | |
| 15884 | 4283 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4284 | PurpleAccount *acct; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4285 | PurpleIMConversation *im; |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4286 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4287 | |
| 15884 | 4288 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4289 | id = g_list_nth_data(row, 1); |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4290 | im = purple_conversations_find_im_with_account(id, acct); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4291 | if(! im) im = purple_im_conversation_new(acct, id); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4292 | purple_conversation_present(PURPLE_CONVERSATION(im)); |
| 15884 | 4293 | } |
| 4294 | ||
| 4295 | ||
| 4296 | static void notify_add(PurpleConnection *gc, GList *row, void *user_data) { | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4297 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4298 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4299 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4300 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4301 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4302 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4303 | |
| 15884 | 4304 | purple_blist_request_add_buddy(purple_connection_get_account(gc), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4305 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4306 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4307 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4308 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4309 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4310 | static void notify_close(gpointer data) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4311 | if (data) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4312 | g_free(data); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4313 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4314 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4315 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4316 | |
| 10977 | 4317 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4318 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4319 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4320 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4321 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4322 | char *msg; |
| 10977 | 4323 | |
| 15884 | 4324 | PurpleNotifySearchResults *sres; |
| 4325 | PurpleNotifySearchColumn *scol; | |
| 4326 | ||
| 4327 | sres = purple_notify_searchresults_new(); | |
| 4328 | ||
| 4329 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4330 | purple_notify_searchresults_column_add(sres, scol); | |
| 4331 | ||
| 4332 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4333 | purple_notify_searchresults_column_add(sres, scol); | |
| 4334 | ||
| 4335 | purple_notify_searchresults_button_add(sres, PURPLE_NOTIFY_BUTTON_IM, | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4336 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4337 | |
| 15884 | 4338 | purple_notify_searchresults_button_add(sres, PURPLE_NOTIFY_BUTTON_ADD, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4339 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4340 | |
| 10977 | 4341 | for(l = result->matches; l; l = l->next) { |
| 4342 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4343 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4344 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4345 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4346 | NSTR(match->id), NSTR(match->name)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4347 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4348 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4349 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4350 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4351 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4352 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4353 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4354 | } |
| 10977 | 4355 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4356 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4357 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4358 | " users. Please select the correct user from the list below to" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4359 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4360 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4361 | |
| 15884 | 4362 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4363 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4364 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4365 | g_free(msg); |
| 10977 | 4366 | } |
| 4367 | ||
| 4368 | ||
| 4369 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4370 | guint32 id, guint32 code, GList *results, | |
| 4371 | gpointer b) { | |
| 4372 | ||
| 4373 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4374 | BuddyAddData *data = b; |
| 15884 | 4375 | PurpleBuddy *buddy = NULL; |
| 4376 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4377 | struct mwPurpleProtocolData *pd; |
| 10977 | 4378 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4379 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4380 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4381 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4382 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4383 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4384 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4385 | |
| 4386 | if(results) | |
| 4387 | res = results->data; | |
| 4388 | ||
| 4389 | if(!code && res && res->matches) { | |
|
24816
bd870d9ff0ab
The other day while struct hiding, I noticed a for loop that was checking
Richard Laager <rlaager@pidgin.im>
parents:
24739
diff
changeset
|
4390 | if(!res->matches->next) { |
| 10977 | 4391 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4392 | |
| 10977 | 4393 | /* only one? that might be the right one! */ |
| 4394 | if(strcmp(res->name, match->id)) { | |
| 4395 | /* uh oh, the single result isn't identical to the search | |
| 4396 | term, better safe then sorry, so let's make sure it's who | |
| 4397 | the user meant to add */ | |
| 15884 | 4398 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4399 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4400 | |
| 10977 | 4401 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4402 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4403 | /* same person, set the server alias */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4404 | purple_buddy_set_server_alias(buddy, match->name); |
| 15884 | 4405 | purple_blist_node_set_string((PurpleBlistNode *) buddy, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4406 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4407 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4408 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4409 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4410 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4411 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4412 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4413 | g_free(data); |
| 10977 | 4414 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4415 | |
| 10977 | 4416 | } else { |
| 4417 | /* prompt user if more than one match was returned */ | |
| 15884 | 4418 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4419 | multi_resolved_query(res, gc, data); |
| 10977 | 4420 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4421 | |
| 10977 | 4422 | return; |
| 4423 | } | |
| 4424 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4425 | #if 0 |
| 10977 | 4426 | /* fall-through indicates that we couldn't find a matching user in |
| 4427 | the resolve service (ether error or zero results), so we remove | |
| 4428 | this buddy */ | |
| 4429 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4430 | /* note: I can't really think of a good reason to alter the buddy |
|
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4431 | list in any way. There has been at least one report where the |
|
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4432 | resolve service isn't returning correct results anyway, so let's |
|
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4433 | just leave them in the list. I'm just going to if0 this section |
|
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4434 | out unless I can think of a very good reason to do this. -siege */ |
|
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4435 | |
| 10977 | 4436 | DEBUG_INFO("no such buddy in community\n"); |
| 15884 | 4437 | purple_blist_remove_buddy(buddy); |
| 10977 | 4438 | blist_schedule(pd); |
| 4439 | ||
| 4440 | if(res && res->name) { | |
| 4441 | /* compose and display an error message */ | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4442 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4443 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4444 | char *msg; |
| 10977 | 4445 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4446 | msgA = _("Unable to add user: user not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4447 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4448 | msgB = _("The identifier '%s' did not match any users in your" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4449 | " Sametime community. This entry has been removed from" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4450 | " your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4451 | msg = g_strdup_printf(msgB, NSTR(res->name)); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4452 | |
| 15884 | 4453 | purple_notify_error(gc, _("Unable to add user"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4454 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4455 | g_free(msg); |
| 10977 | 4456 | } |
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4457 | #endif |
| 10977 | 4458 | } |
| 4459 | ||
| 4460 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4461 | static void mw_protocol_add_buddy(PurpleConnection *gc, |
| 15884 | 4462 | PurpleBuddy *buddy, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4463 | PurpleGroup *group, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4464 | const char *message) { |
| 15884 | 4465 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4466 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4467 | struct mwServiceResolve *srvc; |
| 4468 | GList *query; | |
| 4469 | enum mwResolveFlag flags; | |
| 4470 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4471 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4472 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4473 | /* catch external buddies. They won't be in the resolve service */ |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4474 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4475 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4476 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4477 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4478 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4479 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4480 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4481 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4482 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4483 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4484 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4485 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4486 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4487 | ||
| 4488 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4489 | data, NULL); |
| 10977 | 4490 | g_list_free(query); |
| 4491 | ||
| 4492 | if(req == SEARCH_ERROR) { | |
| 15884 | 4493 | purple_blist_remove_buddy(buddy); |
| 10977 | 4494 | blist_schedule(pd); |
| 4495 | } | |
| 4496 | } | |
| 4497 | ||
| 4498 | ||
| 15884 | 4499 | static void foreach_add_buddies(PurpleGroup *group, GList *buddies, |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4500 | struct mwPurpleProtocolData *pd) { |
| 10977 | 4501 | struct mwAwareList *list; |
| 4502 | ||
| 4503 | list = list_ensure(pd, group); | |
| 4504 | mwAwareList_addAware(list, buddies); | |
| 4505 | g_list_free(buddies); | |
| 4506 | } | |
| 4507 | ||
| 4508 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4509 | static void mw_protocol_add_buddies(PurpleConnection *gc, |
| 10977 | 4510 | GList *buddies, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4511 | GList *groups, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4512 | const char *message) { |
| 10977 | 4513 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4514 | struct mwPurpleProtocolData *pd; |
| 10977 | 4515 | GHashTable *group_sets; |
| 4516 | struct mwAwareIdBlock *idbs, *idb; | |
| 4517 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4518 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4519 | |
| 15884 | 4520 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4521 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4522 | ||
| 4523 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4524 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4525 | ||
| 4526 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4527 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4528 | PurpleBuddy *b = buddies->data; |
| 4529 | PurpleGroup *g; | |
| 10977 | 4530 | const char *fn; |
| 4531 | GList *l; | |
| 4532 | ||
| 4533 | /* nab the saved server alias and stick it on the buddy */ | |
| 15884 | 4534 | fn = purple_blist_node_get_string((PurpleBlistNode *) b, BUDDY_KEY_NAME); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4535 | purple_buddy_set_server_alias(b, fn); |
| 15884 | 4536 | |
| 4537 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4538 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4539 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4540 | idb->community = NULL; |
| 4541 | ||
| 4542 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4543 | g = purple_buddy_get_group(b); |
| 10977 | 4544 | l = g_hash_table_lookup(group_sets, g); |
| 4545 | l = g_list_prepend(l, idb++); | |
| 4546 | g_hash_table_insert(group_sets, g, l); | |
| 4547 | } | |
| 4548 | ||
| 4549 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4550 | for saving */ | |
| 4551 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4552 | blist_schedule(pd); | |
| 4553 | ||
| 4554 | /* cleanup */ | |
| 4555 | g_hash_table_destroy(group_sets); | |
| 4556 | g_free(idbs); | |
| 4557 | } | |
| 4558 | ||
| 4559 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4560 | static void mw_protocol_remove_buddy(PurpleConnection *gc, |
| 15884 | 4561 | PurpleBuddy *buddy, PurpleGroup *group) { |
| 4562 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4563 | struct mwPurpleProtocolData *pd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4564 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4565 | struct mwAwareList *list; |
| 4566 | ||
| 4567 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4568 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4569 | pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4570 | group = purple_buddy_get_group(buddy); |
| 10977 | 4571 | list = list_ensure(pd, group); |
| 4572 | ||
| 4573 | mwAwareList_removeAware(list, rem); | |
| 4574 | blist_schedule(pd); | |
| 4575 | ||
| 4576 | g_list_free(rem); | |
| 4577 | } | |
| 4578 | ||
| 4579 | ||
| 4580 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4581 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4582 | |
| 10977 | 4583 | struct mwUserItem *u; |
| 4584 | guint count; | |
| 4585 | ||
| 4586 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4587 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4588 | |
| 4589 | priv->count = count; | |
| 4590 | priv->users = g_new0(struct mwUserItem, count); | |
| 4591 | ||
| 4592 | while(count--) { | |
| 4593 | u = priv->users + count; | |
| 4594 | u->id = members->data; | |
| 4595 | members = members->next; | |
| 4596 | } | |
| 4597 | } | |
| 4598 | ||
| 4599 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4600 | static void mw_protocol_set_permit_deny(PurpleConnection *gc) { |
| 15884 | 4601 | PurpleAccount *acct; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4602 | struct mwPurpleProtocolData *pd; |
| 10977 | 4603 | struct mwSession *session; |
| 4604 | ||
| 4605 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4606 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4607 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4608 | NULL, /* users */ |
| 10977 | 4609 | }; |
| 4610 | ||
| 4611 | g_return_if_fail(gc != NULL); | |
| 4612 | ||
| 15884 | 4613 | acct = purple_connection_get_account(gc); |
| 10977 | 4614 | g_return_if_fail(acct != NULL); |
| 4615 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4616 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4617 | g_return_if_fail(pd != NULL); |
| 4618 | ||
| 4619 | session = pd->session; | |
| 4620 | g_return_if_fail(session != NULL); | |
| 4621 | ||
|
32623
547eacef0b63
Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
32617
diff
changeset
|
4622 | switch(purple_account_get_privacy_type(acct)) { |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4623 | case PURPLE_ACCOUNT_PRIVACY_DENY_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4624 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_DENY_USERS\n"); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4625 | privacy_fill(&privacy, purple_account_privacy_get_denied(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4626 | privacy.deny = TRUE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4627 | break; |
| 10977 | 4628 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4629 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4630 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL\n"); |
| 10977 | 4631 | privacy.deny = TRUE; |
| 4632 | break; | |
| 4633 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4634 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4635 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS\n"); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4636 | privacy_fill(&privacy, purple_account_privacy_get_permitted(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4637 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4638 | break; |
| 10977 | 4639 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4640 | case PURPLE_ACCOUNT_PRIVACY_DENY_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4641 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_DENY_ALL\n"); |
| 10977 | 4642 | privacy.deny = FALSE; |
| 4643 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4644 | |
| 10977 | 4645 | default: |
|
32623
547eacef0b63
Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
32617
diff
changeset
|
4646 | DEBUG_INFO("acct->perm_deny is 0x%x\n", purple_account_get_privacy_type(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4647 | return; |
| 10977 | 4648 | } |
| 4649 | ||
| 4650 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4651 | g_free(privacy.users); | |
| 4652 | } | |
| 4653 | ||
| 4654 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4655 | static void mw_protocol_add_permit(PurpleConnection *gc, const char *name) { |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4656 | mw_protocol_set_permit_deny(gc); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4657 | } |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4658 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4659 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4660 | static void mw_protocol_add_deny(PurpleConnection *gc, const char *name) { |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4661 | mw_protocol_set_permit_deny(gc); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4662 | } |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4663 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4664 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4665 | static void mw_protocol_rem_permit(PurpleConnection *gc, const char *name) { |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4666 | mw_protocol_set_permit_deny(gc); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4667 | } |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4668 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4669 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4670 | static void mw_protocol_rem_deny(PurpleConnection *gc, const char *name) { |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4671 | mw_protocol_set_permit_deny(gc); |
| 10977 | 4672 | } |
| 4673 | ||
| 4674 | ||
| 4675 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4676 | const char *name) { | |
| 4677 | GList *l, *ll; | |
| 4678 | struct mwConference *conf = NULL; | |
| 4679 | ||
| 4680 | ll = mwServiceConference_getConferences(srvc); | |
| 4681 | for(l = ll; l; l = l->next) { | |
| 4682 | struct mwConference *c = l->data; | |
| 4683 | if(! strcmp(name, mwConference_getName(c))) { | |
| 4684 | conf = c; | |
| 4685 | break; | |
| 4686 | } | |
| 4687 | } | |
| 4688 | g_list_free(ll); | |
| 4689 | ||
| 4690 | return conf; | |
| 4691 | } | |
| 4692 | ||
| 4693 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4694 | static void mw_protocol_join_chat(PurpleConnection *gc, |
| 10977 | 4695 | GHashTable *components) { |
| 4696 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4697 | struct mwPurpleProtocolData *pd; |
| 10977 | 4698 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4699 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4700 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4701 | |
| 4702 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4703 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4704 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4705 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4706 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4707 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4708 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4709 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4710 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4711 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4712 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4713 | |
| 10977 | 4714 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4715 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4716 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4717 | struct mwConference *conf = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4718 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4719 | srvc = pd->srvc_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4720 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4721 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4722 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4723 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4724 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4725 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4726 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4727 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4728 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4729 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4730 | } |
| 10977 | 4731 | } |
| 4732 | } | |
| 4733 | ||
| 4734 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4735 | static void mw_protocol_reject_chat(PurpleConnection *gc, |
| 10977 | 4736 | GHashTable *components) { |
| 4737 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4738 | struct mwPurpleProtocolData *pd; |
| 10977 | 4739 | struct mwServiceConference *srvc; |
| 4740 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4741 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4742 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4743 | srvc = pd->srvc_conf; |
| 4744 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4745 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4746 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4747 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4748 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4749 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4750 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4751 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4752 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4753 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4754 | } |
| 10977 | 4755 | } |
| 4756 | } | |
| 4757 | ||
| 4758 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4759 | static char *mw_protocol_get_chat_name(GHashTable *components) { |
| 10977 | 4760 | return g_hash_table_lookup(components, CHAT_KEY_NAME); |
| 4761 | } | |
| 4762 | ||
| 4763 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4764 | static void mw_protocol_chat_invite(PurpleConnection *gc, |
| 10977 | 4765 | int id, |
| 4766 | const char *invitation, | |
| 4767 | const char *who) { | |
| 4768 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4769 | struct mwPurpleProtocolData *pd; |
| 10977 | 4770 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4771 | struct mwPlace *place; |
| 10977 | 4772 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4773 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4774 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4775 | g_return_if_fail(pd != NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4776 | |
| 10977 | 4777 | conf = ID_TO_CONF(pd, id); |
| 4778 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4779 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4780 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4781 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4782 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4783 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4784 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4785 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4786 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4787 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4788 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4789 | } |
| 4790 | ||
| 4791 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4792 | static void mw_protocol_chat_leave(PurpleConnection *gc, |
| 10977 | 4793 | int id) { |
| 4794 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4795 | struct mwPurpleProtocolData *pd; |
| 10977 | 4796 | struct mwConference *conf; |
| 4797 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4798 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4799 | |
| 4800 | g_return_if_fail(pd != NULL); | |
| 4801 | conf = ID_TO_CONF(pd, id); | |
| 4802 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4803 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4804 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4805 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4806 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4807 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4808 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4809 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4810 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4811 | } |
| 10977 | 4812 | } |
| 4813 | ||
| 4814 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4815 | static void mw_protocol_chat_whisper(PurpleConnection *gc, |
| 10977 | 4816 | int id, |
| 4817 | const char *who, | |
| 4818 | const char *message) { | |
| 4819 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4820 | mw_protocol_send_im(gc, who, message, 0); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4821 | } |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4822 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4823 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4824 | static int mw_protocol_chat_send(PurpleConnection *gc, |
| 10977 | 4825 | int id, |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4826 | const char *message, |
| 15884 | 4827 | PurpleMessageFlags flags) { |
| 4828 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4829 | struct mwPurpleProtocolData *pd; |
| 10977 | 4830 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4831 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4832 | int ret; |
| 10977 | 4833 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4834 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4835 | |
| 4836 | g_return_val_if_fail(pd != NULL, 0); | |
| 4837 | conf = ID_TO_CONF(pd, id); | |
| 4838 | ||
| 15884 | 4839 | msg = purple_markup_strip_html(message); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4840 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4841 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4842 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4843 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4844 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4845 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4846 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4847 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4848 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4849 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4850 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4851 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4852 | return ret; |
| 10977 | 4853 | } |
| 4854 | ||
| 4855 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4856 | static void mw_protocol_keepalive(PurpleConnection *gc) { |
| 10977 | 4857 | struct mwSession *session; |
| 4858 | ||
| 4859 | g_return_if_fail(gc != NULL); | |
| 4860 | ||
| 4861 | session = gc_to_session(gc); | |
| 4862 | g_return_if_fail(session != NULL); | |
| 4863 | ||
| 4864 | mwSession_sendKeepalive(session); | |
| 4865 | } | |
| 4866 | ||
| 4867 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4868 | static void mw_protocol_alias_buddy(PurpleConnection *gc, |
| 10977 | 4869 | const char *who, |
| 4870 | const char *alias) { | |
| 4871 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4872 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4873 | g_return_if_fail(pd != NULL); |
| 4874 | ||
| 4875 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4876 | the server copy */ | |
| 4877 | ||
| 4878 | blist_schedule(pd); | |
| 4879 | } | |
| 4880 | ||
| 4881 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4882 | static void mw_protocol_group_buddy(PurpleConnection *gc, |
| 10977 | 4883 | const char *who, |
| 4884 | const char *old_group, | |
| 4885 | const char *new_group) { | |
| 4886 | ||
| 4887 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 4888 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4889 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4890 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4891 | PurpleGroup *group; |
| 10977 | 4892 | struct mwAwareList *list; |
| 4893 | ||
| 4894 | /* add who to new_group's aware list */ | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4895 | group = purple_blist_find_group(new_group); |
| 10977 | 4896 | list = list_ensure(pd, group); |
| 4897 | mwAwareList_addAware(list, gl); | |
| 4898 | ||
| 4899 | /* remove who from old_group's aware list */ | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4900 | group = purple_blist_find_group(old_group); |
| 10977 | 4901 | list = list_ensure(pd, group); |
| 4902 | mwAwareList_removeAware(list, gl); | |
| 4903 | ||
| 4904 | g_list_free(gl); | |
| 4905 | ||
| 4906 | /* schedule the changes to be saved */ | |
| 4907 | blist_schedule(pd); | |
| 4908 | } | |
| 4909 | ||
| 4910 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4911 | static void mw_protocol_rename_group(PurpleConnection *gc, |
| 10977 | 4912 | const char *old, |
| 15884 | 4913 | PurpleGroup *group, |
| 10977 | 4914 | GList *buddies) { |
| 4915 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4916 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4917 | g_return_if_fail(pd != NULL); |
| 4918 | ||
| 4919 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4920 | the server copy. Also, having this function should prevent all | |
| 4921 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4922 | give a crap what the group is named in Purple other than to record |
| 10977 | 4923 | that as the group name/alias */ |
| 4924 | ||
| 4925 | blist_schedule(pd); | |
| 4926 | } | |
| 4927 | ||
| 4928 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4929 | static void mw_protocol_buddy_free(PurpleBuddy *buddy) { |
| 10977 | 4930 | /* I don't think we have any cleanup for buddies yet */ |
| 4931 | ; | |
| 4932 | } | |
| 4933 | ||
| 4934 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4935 | static void mw_protocol_convo_closed(PurpleConnection *gc, const char *who) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4936 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4937 | struct mwServiceIm *srvc; |
| 4938 | struct mwConversation *conv; | |
| 4939 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4940 | ||
| 4941 | g_return_if_fail(pd != NULL); | |
| 4942 | ||
| 4943 | srvc = pd->srvc_im; | |
| 4944 | g_return_if_fail(srvc != NULL); | |
| 4945 | ||
| 4946 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 4947 | if(! conv) return; | |
| 4948 | ||
| 4949 | if(mwConversation_isOpen(conv)) | |
| 4950 | mwConversation_free(conv); | |
| 4951 | } | |
| 4952 | ||
| 4953 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4954 | static const char *mw_protocol_normalize(const PurpleAccount *account, |
| 10977 | 4955 | const char *id) { |
| 4956 | ||
| 4957 | /* code elsewhere assumes that the return value points to different | |
| 4958 | memory than the passed value, but it won't free the normalized | |
| 4959 | data. wtf? */ | |
| 4960 | ||
| 4961 | static char buf[BUF_LEN]; | |
|
33745
c31cf8de31cd
Fix a crash in Sametime when a malicious server sends us an abnormally
Mark Doliner <mark@kingant.net>
parents:
32049
diff
changeset
|
4962 | g_strlcpy(buf, id, sizeof(buf)); |
| 10977 | 4963 | return buf; |
| 4964 | } | |
| 4965 | ||
| 4966 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4967 | static void mw_protocol_remove_group(PurpleConnection *gc, PurpleGroup *group) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4968 | struct mwPurpleProtocolData *pd; |
| 10977 | 4969 | struct mwAwareList *list; |
| 4970 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4971 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4972 | g_return_if_fail(pd != NULL); |
| 4973 | g_return_if_fail(pd->group_list_map != NULL); | |
| 4974 | ||
| 4975 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 4976 | ||
| 4977 | if(list) { | |
| 4978 | g_hash_table_remove(pd->group_list_map, list); | |
| 4979 | g_hash_table_remove(pd->group_list_map, group); | |
| 4980 | mwAwareList_free(list); | |
| 4981 | ||
| 4982 | blist_schedule(pd); | |
| 4983 | } | |
| 4984 | } | |
| 4985 | ||
| 4986 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4987 | static gboolean mw_protocol_can_receive_file(PurpleConnection *gc, |
| 10977 | 4988 | const char *who) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4989 | struct mwPurpleProtocolData *pd; |
| 10977 | 4990 | struct mwServiceAware *srvc; |
| 15884 | 4991 | PurpleAccount *acct; |
| 10977 | 4992 | |
| 4993 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 4994 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4995 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4996 | g_return_val_if_fail(pd != NULL, FALSE); |
| 4997 | ||
| 4998 | srvc = pd->srvc_aware; | |
| 4999 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5000 | |
| 15884 | 5001 | acct = purple_connection_get_account(gc); |
| 10977 | 5002 | g_return_val_if_fail(acct != NULL, FALSE); |
| 5003 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
5004 | return purple_blist_find_buddy(acct, who) && |
| 10977 | 5005 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 5006 | } | |
| 5007 | ||
| 5008 | ||
| 15884 | 5009 | static void ft_outgoing_init(PurpleXfer *xfer) { |
| 5010 | PurpleAccount *acct; | |
| 5011 | PurpleConnection *gc; | |
| 5012 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5013 | struct mwPurpleProtocolData *pd; |
| 10977 | 5014 | struct mwServiceFileTransfer *srvc; |
| 5015 | struct mwFileTransfer *ft; | |
| 5016 | ||
| 5017 | const char *filename; | |
| 5018 | gsize filesize; | |
| 5019 | FILE *fp; | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5020 | char *remote_user = NULL; |
| 10977 | 5021 | |
| 5022 | struct mwIdBlock idb = { NULL, NULL }; | |
| 5023 | ||
| 5024 | DEBUG_INFO("ft_outgoing_init\n"); | |
| 5025 | ||
| 15884 | 5026 | acct = purple_xfer_get_account(xfer); |
| 5027 | gc = purple_account_get_connection(acct); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5028 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5029 | srvc = pd->srvc_ft; |
| 5030 | ||
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5031 | remote_user = g_strdup(purple_xfer_get_remote_user(xfer)); |
|
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5032 | |
| 15884 | 5033 | filename = purple_xfer_get_local_filename(xfer); |
| 5034 | filesize = purple_xfer_get_size(xfer); | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5035 | idb.user = remote_user; |
| 10977 | 5036 | |
| 15884 | 5037 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5038 | |
| 10977 | 5039 | /* test that we can actually send the file */ |
| 5040 | fp = g_fopen(filename, "rb"); | |
| 5041 | if(! fp) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5042 | char *msg = g_strdup_printf(_("Error reading file %s: \n%s\n"), |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20288
diff
changeset
|
5043 | filename, g_strerror(errno)); |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
5044 | purple_xfer_error(purple_xfer_get_type(xfer), acct, purple_xfer_get_remote_user(xfer), msg); |
| 10977 | 5045 | g_free(msg); |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5046 | g_free(remote_user); |
| 10977 | 5047 | return; |
| 5048 | } | |
| 5049 | fclose(fp); | |
| 5050 | ||
| 5051 | { | |
| 5052 | char *tmp = strrchr(filename, G_DIR_SEPARATOR); | |
| 5053 | if(tmp++) filename = tmp; | |
| 5054 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5055 | |
| 10977 | 5056 | ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); |
| 5057 | ||
| 15884 | 5058 | purple_xfer_ref(xfer); |
| 5059 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
5060 | purple_xfer_set_protocol_data(xfer, ft); |
| 10977 | 5061 | |
| 5062 | mwFileTransfer_offer(ft); | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5063 | g_free(remote_user); |
| 10977 | 5064 | } |
| 5065 | ||
| 5066 | ||
| 15884 | 5067 | static void ft_outgoing_cancel(PurpleXfer *xfer) { |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
5068 | struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5069 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5070 | DEBUG_INFO("ft_outgoing_cancel called\n"); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5071 | |
| 10977 | 5072 | if(ft) mwFileTransfer_cancel(ft); |
| 5073 | } | |
| 5074 | ||
| 5075 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5076 | static PurpleXfer *mw_protocol_new_xfer(PurpleConnection *gc, const char *who) { |
| 15884 | 5077 | PurpleAccount *acct; |
| 5078 | PurpleXfer *xfer; | |
| 5079 | ||
| 5080 | acct = purple_connection_get_account(gc); | |
| 5081 | ||
| 5082 | xfer = purple_xfer_new(acct, PURPLE_XFER_SEND, who); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5083 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5084 | { |
| 15884 | 5085 | purple_xfer_set_init_fnc(xfer, ft_outgoing_init); |
| 5086 | purple_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5087 | } |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5088 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5089 | return xfer; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5090 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5091 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5092 | static void mw_protocol_send_file(PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5093 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5094 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5095 | PurpleXfer *xfer = mw_protocol_new_xfer(gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5096 | |
| 10977 | 5097 | if(file) { |
| 5098 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 5099 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 5100 | |
| 5101 | } else { | |
| 5102 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 5103 | purple_xfer_request(xfer); |
| 10977 | 5104 | } |
| 5105 | } | |
| 5106 | ||
|
34297
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
5107 | #if 0 |
| 15884 | 5108 | static PurplePluginPrefFrame * |
| 5109 | mw_plugin_get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 5110 | PurplePluginPrefFrame *frame; | |
| 5111 | PurplePluginPref *pref; | |
| 5112 | ||
| 5113 | frame = purple_plugin_pref_frame_new(); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5114 | |
| 15884 | 5115 | pref = purple_plugin_pref_new_with_label(_("Remotely Stored Buddy List")); |
| 5116 | purple_plugin_pref_frame_add(frame, pref); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5117 | |
| 10977 | 5118 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5119 | pref = purple_plugin_pref_new_with_name(MW_PROTOCOL_OPT_BLIST_ACTION); |
| 15884 | 5120 | purple_plugin_pref_set_label(pref, _("Buddy List Storage Mode")); |
| 5121 | ||
| 5122 | purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE); | |
| 5123 | purple_plugin_pref_add_choice(pref, _("Local Buddy List Only"), | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5124 | GINT_TO_POINTER(blist_choice_LOCAL)); |
| 15884 | 5125 | purple_plugin_pref_add_choice(pref, _("Merge List from Server"), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5126 | GINT_TO_POINTER(blist_choice_MERGE)); |
| 15884 | 5127 | purple_plugin_pref_add_choice(pref, _("Merge and Save List to Server"), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5128 | GINT_TO_POINTER(blist_choice_STORE)); |
| 15884 | 5129 | purple_plugin_pref_add_choice(pref, _("Synchronize List with Server"), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5130 | GINT_TO_POINTER(blist_choice_SYNCH)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5131 | |
| 15884 | 5132 | purple_plugin_pref_frame_add(frame, pref); |
| 10977 | 5133 | |
| 5134 | return frame; | |
| 5135 | } | |
|
34297
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
5136 | #endif |
| 10977 | 5137 | |
| 15884 | 5138 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5139 | struct mwSametimeList *l; |
| 5140 | ||
| 5141 | FILE *file; | |
| 5142 | char buf[BUF_LEN]; | |
| 5143 | size_t len; | |
| 5144 | ||
| 5145 | GString *str; | |
| 5146 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5147 | file = g_fopen(filename, "r"); |
| 10977 | 5148 | g_return_if_fail(file != NULL); |
| 5149 | ||
| 5150 | str = g_string_new(NULL); | |
| 5151 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 5152 | g_string_append_len(str, buf, len); | |
| 5153 | } | |
| 5154 | ||
| 5155 | fclose(file); | |
| 5156 | ||
| 5157 | l = mwSametimeList_load(str->str); | |
| 5158 | g_string_free(str, TRUE); | |
| 5159 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5160 | blist_merge(gc, l); |
| 10977 | 5161 | mwSametimeList_free(l); |
| 5162 | } | |
| 5163 | ||
| 5164 | ||
| 5165 | /** prompts for a file to import blist from */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5166 | static void st_import_action(PurpleProtocolAction *act) { |
| 15884 | 5167 | PurpleConnection *gc; |
| 5168 | PurpleAccount *account; | |
| 10977 | 5169 | char *title; |
| 5170 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5171 | gc = act->connection; |
| 15884 | 5172 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5173 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 5174 | purple_account_get_username(account)); |
| 5175 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5176 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 5177 | G_CALLBACK(st_import_action_cb), NULL, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16121
diff
changeset
|
5178 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5179 | gc); |
| 10977 | 5180 | |
| 5181 | g_free(title); | |
| 5182 | } | |
| 5183 | ||
| 5184 | ||
| 15884 | 5185 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5186 | struct mwSametimeList *l; |
| 5187 | char *str; | |
| 5188 | FILE *file; | |
| 5189 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5190 | file = g_fopen(filename, "w"); |
| 10977 | 5191 | g_return_if_fail(file != NULL); |
| 5192 | ||
| 5193 | l = mwSametimeList_new(); | |
| 5194 | blist_export(gc, l); | |
| 5195 | str = mwSametimeList_store(l); | |
| 5196 | mwSametimeList_free(l); | |
| 5197 | ||
| 5198 | fprintf(file, "%s", str); | |
| 5199 | fclose(file); | |
| 5200 | ||
| 5201 | g_free(str); | |
| 5202 | } | |
| 5203 | ||
| 5204 | ||
| 5205 | /** prompts for a file to export blist to */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5206 | static void st_export_action(PurpleProtocolAction *act) { |
| 15884 | 5207 | PurpleConnection *gc; |
| 5208 | PurpleAccount *account; | |
| 10977 | 5209 | char *title; |
| 5210 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5211 | gc = act->connection; |
| 15884 | 5212 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5213 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 5214 | purple_account_get_username(account)); |
| 5215 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5216 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 5217 | G_CALLBACK(st_export_action_cb), NULL, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16121
diff
changeset
|
5218 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5219 | gc); |
| 10977 | 5220 | |
| 5221 | g_free(title); | |
| 5222 | } | |
| 5223 | ||
| 5224 | ||
| 5225 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 5226 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5227 | |
| 15884 | 5228 | PurpleRequestField *f; |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
17157
diff
changeset
|
5229 | GList *l; |
| 10977 | 5230 | |
| 15884 | 5231 | f = purple_request_fields_get_field(fields, "group"); |
| 5232 | l = purple_request_field_list_get_items(f); | |
| 10977 | 5233 | |
| 5234 | for(; l; l = l->next) { | |
| 5235 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5236 | struct named_id *res; |
| 10977 | 5237 | |
| 15884 | 5238 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5239 | |
| 5240 | g_free(res->id); | |
| 5241 | g_free(res->name); | |
| 5242 | g_free(res); | |
| 5243 | } | |
| 5244 | } | |
| 5245 | ||
| 5246 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5247 | static void remote_group_done(struct mwPurpleProtocolData *pd, |
| 10977 | 5248 | const char *id, const char *name) { |
| 15884 | 5249 | PurpleConnection *gc; |
| 5250 | PurpleAccount *acct; | |
| 5251 | PurpleGroup *group; | |
| 5252 | PurpleBlistNode *gn; | |
| 10977 | 5253 | const char *owner; |
| 5254 | ||
| 5255 | g_return_if_fail(pd != NULL); | |
| 5256 | ||
| 5257 | gc = pd->gc; | |
| 15884 | 5258 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5259 | |
| 10977 | 5260 | /* collision checking */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
5261 | group = purple_blist_find_group(name); |
| 10977 | 5262 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5263 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5264 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5265 | char *msg; |
| 10977 | 5266 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5267 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5268 | msgB = _("A group named '%s' already exists in your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5269 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5270 | |
| 15884 | 5271 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5272 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5273 | g_free(msg); |
| 10977 | 5274 | return; |
| 5275 | } | |
| 5276 | ||
| 15884 | 5277 | group = purple_group_new(name); |
| 5278 | gn = (PurpleBlistNode *) group; | |
| 5279 | ||
| 5280 | owner = purple_account_get_username(acct); | |
| 5281 | ||
| 5282 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 5283 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 5284 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 5285 | purple_blist_add_group(group, NULL); | |
| 10977 | 5286 | |
| 5287 | group_add(pd, group); | |
| 5288 | blist_schedule(pd); | |
| 5289 | } | |
| 5290 | ||
| 5291 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5292 | static void remote_group_multi_cb(struct mwPurpleProtocolData *pd, |
| 15884 | 5293 | PurpleRequestFields *fields) { |
| 5294 | PurpleRequestField *f; | |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
17157
diff
changeset
|
5295 | GList *l; |
| 10977 | 5296 | |
| 15884 | 5297 | f = purple_request_fields_get_field(fields, "group"); |
| 5298 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 5299 | |
| 5300 | if(l) { | |
| 5301 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5302 | struct named_id *res; |
| 10977 | 5303 | |
| 15884 | 5304 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5305 | remote_group_done(pd, res->id, res->name); |
| 5306 | } | |
| 5307 | ||
| 5308 | remote_group_multi_cleanup(NULL, fields); | |
| 5309 | } | |
| 5310 | ||
| 5311 | ||
| 5312 | static void remote_group_multi(struct mwResolveResult *result, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5313 | struct mwPurpleProtocolData *pd) { |
| 15884 | 5314 | |
| 5315 | PurpleRequestFields *fields; | |
| 5316 | PurpleRequestFieldGroup *g; | |
| 5317 | PurpleRequestField *f; | |
| 10977 | 5318 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5319 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5320 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5321 | char *msg; |
| 10977 | 5322 | |
| 15884 | 5323 | PurpleConnection *gc = pd->gc; |
| 5324 | ||
| 5325 | fields = purple_request_fields_new(); | |
| 5326 | ||
| 5327 | g = purple_request_field_group_new(NULL); | |
| 5328 | purple_request_fields_add_group(fields, g); | |
| 5329 | ||
| 5330 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 5331 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 5332 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 5333 | |
| 5334 | for(l = result->matches; l; l = l->next) { | |
| 5335 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5336 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 5337 | |
| 5338 | res->id = g_strdup(match->id); | |
| 5339 | res->name = g_strdup(match->name); | |
| 5340 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
5341 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 5342 | } |
| 5343 | ||
| 15884 | 5344 | purple_request_field_group_add_field(g, f); |
| 10977 | 5345 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5346 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5347 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 5348 | " Notes Address Book groups. Please select the correct group from" |
| 5349 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5350 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 5351 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5352 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5353 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5354 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5355 | _("Cancel"), G_CALLBACK(remote_group_multi_cleanup), |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16121
diff
changeset
|
5356 | purple_connection_get_account(gc), result->name, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5357 | pd); |
| 10977 | 5358 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5359 | g_free(msg); |
| 10977 | 5360 | } |
| 5361 | ||
| 5362 | ||
| 5363 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 5364 | guint32 id, guint32 code, GList *results, | |
| 5365 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5366 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5367 | struct mwResolveResult *res = NULL; |
| 10977 | 5368 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5369 | struct mwPurpleProtocolData *pd; |
| 15884 | 5370 | PurpleConnection *gc; |
| 10977 | 5371 | |
| 5372 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5373 | g_return_if_fail(session != NULL); | |
| 5374 | ||
| 5375 | pd = mwSession_getClientData(session); | |
| 5376 | g_return_if_fail(pd != NULL); | |
| 5377 | ||
| 5378 | gc = pd->gc; | |
| 5379 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5380 | |
| 10977 | 5381 | if(!code && results) { |
| 5382 | res = results->data; | |
| 5383 | ||
| 5384 | if(res->matches) { | |
| 5385 | remote_group_multi(res, pd); | |
| 5386 | return; | |
| 5387 | } | |
| 5388 | } | |
| 5389 | ||
| 5390 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5391 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5392 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5393 | char *msg; |
| 10977 | 5394 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5395 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5396 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5397 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5398 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5399 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5400 | |
| 15884 | 5401 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5402 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5403 | g_free(msg); |
| 10977 | 5404 | } |
| 5405 | } | |
| 5406 | ||
| 5407 | ||
| 15884 | 5408 | static void remote_group_action_cb(PurpleConnection *gc, const char *name) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5409 | struct mwPurpleProtocolData *pd; |
| 10977 | 5410 | struct mwServiceResolve *srvc; |
| 5411 | GList *query; | |
| 5412 | enum mwResolveFlag flags; | |
| 5413 | guint32 req; | |
| 5414 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5415 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5416 | srvc = pd->srvc_resolve; |
| 5417 | ||
| 5418 | query = g_list_prepend(NULL, (char *) name); | |
| 5419 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5420 | |
| 10977 | 5421 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5422 | NULL, NULL); | |
| 5423 | g_list_free(query); | |
| 5424 | ||
| 5425 | if(req == SEARCH_ERROR) { | |
| 5426 | /** @todo display error */ | |
| 5427 | } | |
| 5428 | } | |
| 5429 | ||
| 5430 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5431 | static void remote_group_action(PurpleProtocolAction *act) { |
| 15884 | 5432 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5433 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5434 | const char *msgB; |
| 10977 | 5435 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5436 | gc = act->connection; |
| 10977 | 5437 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5438 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5439 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5440 | " to add the group and its members to your buddy list."); |
| 5441 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5442 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5443 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5444 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5445 | _("Cancel"), NULL, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16121
diff
changeset
|
5446 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5447 | gc); |
| 10977 | 5448 | } |
| 5449 | ||
| 5450 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5451 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5452 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5453 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5454 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5455 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5456 | char *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5457 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5458 | |
| 15884 | 5459 | PurpleNotifySearchResults *sres; |
| 5460 | PurpleNotifySearchColumn *scol; | |
| 5461 | ||
| 5462 | sres = purple_notify_searchresults_new(); | |
| 5463 | ||
| 5464 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5465 | purple_notify_searchresults_column_add(sres, scol); | |
| 5466 | ||
| 5467 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5468 | purple_notify_searchresults_column_add(sres, scol); | |
| 5469 | ||
| 5470 | purple_notify_searchresults_button_add(sres, PURPLE_NOTIFY_BUTTON_IM, | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5471 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5472 | |
| 15884 | 5473 | purple_notify_searchresults_button_add(sres, PURPLE_NOTIFY_BUTTON_ADD, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5474 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5475 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5476 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5477 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5478 | GList *row = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5479 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5480 | if(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5481 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5482 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5483 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5484 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5485 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5486 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5487 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5488 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5489 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5490 | " users. You may add these users to your buddy list or send them" |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5491 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5492 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5493 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5494 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5495 | |
| 15884 | 5496 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5497 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5498 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5499 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5500 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5501 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5502 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5503 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5504 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5505 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5506 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5507 | |
| 15884 | 5508 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5509 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5510 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5511 | if(results) res = results->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5512 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5513 | if(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5514 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5515 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5516 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5517 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5518 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5519 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5520 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5521 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5522 | msgB = _("The identifier '%s' did not match any users in your" |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5523 | " Sametime community."); |
|
20228
ce019944d765
applied changes from 9d35dde0c779cca73548172223ba557f27d61882
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
5524 | msg = g_strdup_printf(msgB, (res && res->name) ? NSTR(res->name) : ""); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5525 | |
| 15884 | 5526 | purple_notify_error(gc, _("No Matches"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5527 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5528 | g_free(msg); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5529 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5530 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5531 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5532 | |
| 15884 | 5533 | static void search_action_cb(PurpleConnection *gc, const char *name) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5534 | struct mwPurpleProtocolData *pd; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5535 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5536 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5537 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5538 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5539 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5540 | pd = purple_connection_get_protocol_data(gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5541 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5542 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5543 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5544 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5545 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5546 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5547 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5548 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5549 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5550 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5551 | /** @todo display error */ |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5552 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5553 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5554 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5555 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5556 | static void search_action(PurpleProtocolAction *act) { |
| 15884 | 5557 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5558 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5559 | const char *msgB; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5560 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5561 | gc = act->connection; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5562 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5563 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5564 | msgB = _("Enter a name or partial ID in the field below to search" |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5565 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5566 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5567 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5568 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5569 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5570 | _("Cancel"), NULL, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16121
diff
changeset
|
5571 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5572 | gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5573 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5574 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5575 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5576 | static GList *mw_protocol_get_actions(PurpleConnection *gc) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5577 | PurpleProtocolAction *act; |
| 10977 | 5578 | GList *l = NULL; |
| 5579 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5580 | act = purple_protocol_action_new(_("Import Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5581 | st_import_action); |
| 10977 | 5582 | l = g_list_append(l, act); |
| 5583 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5584 | act = purple_protocol_action_new(_("Export Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5585 | st_export_action); |
| 10977 | 5586 | l = g_list_append(l, act); |
| 5587 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5588 | act = purple_protocol_action_new(_("Add Notes Address Book Group..."), |
| 10977 | 5589 | remote_group_action); |
| 5590 | l = g_list_append(l, act); | |
| 5591 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5592 | act = purple_protocol_action_new(_("User Search..."), |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5593 | search_action); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5594 | l = g_list_append(l, act); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5595 | |
| 10977 | 5596 | return l; |
| 5597 | } | |
| 5598 | ||
| 5599 | ||
| 5600 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5601 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5602 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5603 | if(! (msg && *msg)) return; |
| 10977 | 5604 | |
| 15884 | 5605 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5606 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5607 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5608 | |
| 5609 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5610 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5611 | |
| 5612 | } else { | |
| 15884 | 5613 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5614 | } |
| 5615 | } | |
| 5616 | ||
| 5617 | ||
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5618 | static void |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5619 | mw_protocol_base_init(SametimeProtocolClass *klass) |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5620 | { |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5621 | PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_CLASS(klass); |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5622 | PurpleAccountUserSplit *split; |
| 15884 | 5623 | PurpleAccountOption *opt; |
| 10977 | 5624 | GList *l = NULL; |
| 5625 | ||
| 5626 | GLogLevelFlags logflags = | |
| 5627 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5628 | ||
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5629 | proto_class->id = PLUGIN_ID; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5630 | proto_class->name = PLUGIN_NAME; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5631 | proto_class->options = OPT_PROTO_IM_IMAGE; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5632 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5633 | /* set up the preferences */ |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5634 | purple_prefs_add_none(MW_PROTOCOL_OPT_BASE); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5635 | purple_prefs_add_int(MW_PROTOCOL_OPT_BLIST_ACTION, BLIST_CHOICE_DEFAULT); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5636 | |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5637 | /* set up account ID as user:server */ |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5638 | split = purple_account_user_split_new(_("Server"), |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5639 | MW_PLUGIN_DEFAULT_HOST, ':'); |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5640 | proto_class->user_splits = g_list_append(proto_class->user_splits, split); |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5641 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5642 | /* remove dead preferences */ |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5643 | purple_prefs_remove(MW_PROTOCOL_OPT_PSYCHIC); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5644 | purple_prefs_remove(MW_PROTOCOL_OPT_SAVE_DYNAMIC); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5645 | |
| 10977 | 5646 | /* port to connect to */ |
| 15884 | 5647 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5648 | MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 5649 | l = g_list_append(l, opt); |
| 5650 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5651 | { /* copy the old force login setting from prefs if it's |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5652 | there. Don't delete the preference, since there may be more |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5653 | than one account that wants to check for it. */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5654 | gboolean b = FALSE; |
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12422
diff
changeset
|
5655 | const char *label = _("Force login (ignore server redirects)"); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5656 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5657 | if(purple_prefs_exists(MW_PROTOCOL_OPT_FORCE_LOGIN)) |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5658 | b = purple_prefs_get_bool(MW_PROTOCOL_OPT_FORCE_LOGIN); |
| 15884 | 5659 | |
| 5660 | opt = purple_account_option_bool_new(label, MW_KEY_FORCE, b); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5661 | l = g_list_append(l, opt); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5662 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5663 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5664 | /* pretend to be Sametime Connect */ |
| 15884 | 5665 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5666 | MW_KEY_FAKE_IT, FALSE); |
|
12312
470a1452d009
[gaim-migrate @ 14616]
Christopher O'Brien <siege@pidgin.im>
parents:
12311
diff
changeset
|
5667 | l = g_list_append(l, opt); |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5668 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5669 | proto_class->protocol_options = l; |
| 10977 | 5670 | l = NULL; |
| 5671 | ||
| 15884 | 5672 | /* forward all our g_log messages to purple. Generally all the logging |
| 5673 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5674 | get caught here */ |
| 5675 | log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags, | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5676 | mw_log_handler, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5677 | |
| 15884 | 5678 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5679 | log_handler[1] = g_log_set_handler("meanwhile", logflags, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5680 | mw_log_handler, NULL); |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5681 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5682 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5683 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5684 | static void |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5685 | mw_protocol_base_finalize(SametimeProtocolClass *klass) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5686 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5687 | g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5688 | g_log_remove_handler("meanwhile", log_handler[1]); |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5689 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5690 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5691 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5692 | static void |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5693 | mw_protocol_interface_init(PurpleProtocolInterface *iface) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5694 | { |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5695 | iface->get_actions = mw_protocol_get_actions; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5696 | iface->list_icon = mw_protocol_list_icon; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5697 | iface->list_emblem = mw_protocol_list_emblem; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5698 | iface->status_text = mw_protocol_status_text; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5699 | iface->tooltip_text = mw_protocol_tooltip_text; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5700 | iface->status_types = mw_protocol_status_types; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5701 | iface->blist_node_menu = mw_protocol_blist_node_menu; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5702 | iface->chat_info = mw_protocol_chat_info; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5703 | iface->chat_info_defaults = mw_protocol_chat_info_defaults; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5704 | iface->login = mw_protocol_login; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5705 | iface->close = mw_protocol_close; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5706 | iface->send_im = mw_protocol_send_im; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5707 | iface->send_typing = mw_protocol_send_typing; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5708 | iface->get_info = mw_protocol_get_info; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5709 | iface->set_status = mw_protocol_set_status; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5710 | iface->set_idle = mw_protocol_set_idle; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5711 | iface->add_buddy = mw_protocol_add_buddy; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5712 | iface->add_buddies = mw_protocol_add_buddies; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5713 | iface->remove_buddy = mw_protocol_remove_buddy; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5714 | iface->add_permit = mw_protocol_add_permit; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5715 | iface->add_deny = mw_protocol_add_deny; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5716 | iface->rem_permit = mw_protocol_rem_permit; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5717 | iface->rem_deny = mw_protocol_rem_deny; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5718 | iface->set_permit_deny = mw_protocol_set_permit_deny; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5719 | iface->join_chat = mw_protocol_join_chat; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5720 | iface->reject_chat = mw_protocol_reject_chat; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5721 | iface->get_chat_name = mw_protocol_get_chat_name; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5722 | iface->chat_invite = mw_protocol_chat_invite; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5723 | iface->chat_leave = mw_protocol_chat_leave; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5724 | iface->chat_whisper = mw_protocol_chat_whisper; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5725 | iface->chat_send = mw_protocol_chat_send; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5726 | iface->keepalive = mw_protocol_keepalive; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5727 | iface->alias_buddy = mw_protocol_alias_buddy; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5728 | iface->group_buddy = mw_protocol_group_buddy; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5729 | iface->rename_group = mw_protocol_rename_group; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5730 | iface->buddy_free = mw_protocol_buddy_free; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5731 | iface->convo_closed = mw_protocol_convo_closed; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5732 | iface->normalize = mw_protocol_normalize; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5733 | iface->remove_group = mw_protocol_remove_group; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5734 | iface->can_receive_file = mw_protocol_can_receive_file; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5735 | iface->send_file = mw_protocol_send_file; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5736 | iface->new_xfer = mw_protocol_new_xfer; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5737 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5738 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5739 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5740 | static PurplePluginInfo * |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5741 | plugin_query(GError **error) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5742 | { |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5743 | return purple_plugin_info_new( |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5744 | "id", PLUGIN_ID, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5745 | "name", PLUGIN_NAME, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5746 | "version", DISPLAY_VERSION, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5747 | "category", PLUGIN_CATEGORY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5748 | "summary", PLUGIN_SUMMARY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5749 | "description", PLUGIN_DESC, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5750 | "author", PLUGIN_AUTHOR, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5751 | "website", PLUGIN_HOMEPAGE, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5752 | "abi-version", PURPLE_ABI_VERSION, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5753 | "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5754 | GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5755 | NULL |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5756 | ); |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5757 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5758 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5759 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5760 | static gboolean |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5761 | plugin_load(PurplePlugin *plugin, GError **error) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5762 | { |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5763 | my_protocol = purple_protocols_add(MW_TYPE_PROTOCOL); |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5764 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5765 | if (!my_protocol) { |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5766 | g_set_error(error, PLUGIN_DOMAIN, 0, _("Failed to add sametime protocol")); |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5767 | return FALSE; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5768 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5769 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5770 | return TRUE; |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5771 | } |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5772 | |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5773 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5774 | static gboolean |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5775 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5776 | { |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5777 | if (!purple_protocols_remove(my_protocol)) { |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5778 | g_set_error(error, PLUGIN_DOMAIN, 0, _("Failed to remove sametime protocol")); |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5779 | return FALSE; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5780 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5781 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5782 | return TRUE; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5783 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5784 | |
|
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:
36592
diff
changeset
|
5785 | static PurplePlugin *my_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:
36592
diff
changeset
|
5786 | PURPLE_PROTOCOL_DEFINE(my_plugin, SametimeProtocol, mw_protocol); |
|
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:
36592
diff
changeset
|
5787 | PURPLE_PLUGIN_INIT_VAL(my_plugin, sametime, 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:
36592
diff
changeset
|
5788 | plugin_unload); |
| 10977 | 5789 | /* The End. */ |
| 5790 |