Tue, 17 Sep 2024 14:31:28 -0500
Use the result of g_string_free(..., FALSE)
Thus silencing the warnings about unused results.
Testing Done:
Compiled with fewer warnings.
Reviewed at https://reviews.imfreedom.org/r/3509/
| 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" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
36 | #include "circbuffer.h" |
|
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" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
43 | #include "plugin.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
44 | #include "privacy.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
45 | #include "prpl.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
46 | #include "request.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
47 | #include "util.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
48 | #include "version.h" |
| 10977 | 49 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
50 | /* meanwhile includes */ |
| 10977 | 51 | #include <mw_cipher.h> |
| 52 | #include <mw_common.h> | |
| 53 | #include <mw_error.h> | |
| 54 | #include <mw_service.h> | |
| 55 | #include <mw_session.h> | |
| 56 | #include <mw_srvc_aware.h> | |
| 57 | #include <mw_srvc_conf.h> | |
| 58 | #include <mw_srvc_ft.h> | |
| 59 | #include <mw_srvc_im.h> | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
60 | #include <mw_srvc_place.h> |
| 10977 | 61 | #include <mw_srvc_resolve.h> |
| 62 | #include <mw_srvc_store.h> | |
| 63 | #include <mw_st_list.h> | |
| 64 | ||
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
65 | /* plugin includes */ |
| 10977 | 66 | #include "sametime.h" |
| 67 | ||
| 68 | ||
| 69 | /* considering that there's no display of this information for prpls, | |
| 70 | I don't know why I even bother providing these. Oh valiant reader, | |
| 71 | I do it all for you. */ | |
| 72 | /* 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
|
73 | #define PLUGIN_ID "prpl-meanwhile" |
| 10977 | 74 | #define PLUGIN_NAME "Sametime" |
| 75 | #define PLUGIN_SUMMARY "Sametime Protocol Plugin" | |
| 76 | #define PLUGIN_DESC "Open implementation of a Lotus Sametime client" | |
| 77 | #define PLUGIN_AUTHOR "Christopher (siege) O'Brien <siege@preoccupied.net>" | |
| 78 | #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/" | |
| 79 | ||
| 80 | ||
| 81 | /* plugin preference names */ | |
| 82 | #define MW_PRPL_OPT_BASE "/plugins/prpl/meanwhile" | |
| 83 | #define MW_PRPL_OPT_BLIST_ACTION MW_PRPL_OPT_BASE "/blist_action" | |
| 84 | #define MW_PRPL_OPT_PSYCHIC MW_PRPL_OPT_BASE "/psychic" | |
| 85 | #define MW_PRPL_OPT_FORCE_LOGIN MW_PRPL_OPT_BASE "/force_login" | |
| 86 | #define MW_PRPL_OPT_SAVE_DYNAMIC MW_PRPL_OPT_BASE "/save_dynamic" | |
| 87 | ||
| 88 | ||
| 89 | /* stages of connecting-ness */ | |
|
13779
410869639392
[gaim-migrate @ 16189]
Christopher O'Brien <siege@pidgin.im>
parents:
13713
diff
changeset
|
90 | #define MW_CONNECT_STEPS 11 |
| 10977 | 91 | |
| 92 | ||
| 93 | /* stages of conciousness */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
94 | #define MW_STATE_OFFLINE "offline" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
95 | #define MW_STATE_ACTIVE "active" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
96 | #define MW_STATE_AWAY "away" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
97 | #define MW_STATE_BUSY "dnd" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
98 | #define MW_STATE_MESSAGE "message" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
99 | #define MW_STATE_ENLIGHTENED "buddha" |
| 10977 | 100 | |
| 101 | ||
| 102 | /* keys to get/set chat information */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
103 | #define CHAT_KEY_CREATOR "chat.creator" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
104 | #define CHAT_KEY_NAME "chat.name" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
105 | #define CHAT_KEY_TOPIC "chat.topic" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
106 | #define CHAT_KEY_INVITE "chat.invite" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
107 | #define CHAT_KEY_IS_PLACE "chat.is_place" |
| 10977 | 108 | |
| 109 | ||
| 110 | /* key for associating a mwLoginType with a buddy */ | |
| 111 | #define BUDDY_KEY_CLIENT "meanwhile.client" | |
| 112 | ||
| 113 | /* store the remote alias so that we can re-create it easily */ | |
| 114 | #define BUDDY_KEY_NAME "meanwhile.shortname" | |
| 115 | ||
| 116 | /* enum mwSametimeUserType */ | |
| 117 | #define BUDDY_KEY_TYPE "meanwhile.type" | |
| 118 | ||
| 119 | ||
| 120 | /* key for the real group name for a meanwhile group */ | |
| 121 | #define GROUP_KEY_NAME "meanwhile.group" | |
| 122 | ||
| 123 | /* enum mwSametimeGroupType */ | |
| 124 | #define GROUP_KEY_TYPE "meanwhile.type" | |
| 125 | ||
| 126 | /* NAB group owning account */ | |
| 127 | #define GROUP_KEY_OWNER "meanwhile.account" | |
| 128 | ||
| 129 | /* key gtk blist uses to indicate a collapsed group */ | |
| 130 | #define GROUP_KEY_COLLAPSED "collapsed" | |
| 131 | ||
| 132 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
133 | /* verification replacement */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
134 | #define mwSession_NO_SECRET "meanwhile.no_secret" |
| 10977 | 135 | |
| 136 | ||
| 15884 | 137 | /* keys to get/set purple plugin information */ |
| 10977 | 138 | #define MW_KEY_HOST "server" |
| 139 | #define MW_KEY_PORT "port" | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
140 | #define MW_KEY_FORCE "force_login" |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
141 | #define MW_KEY_FAKE_IT "fake_client_id" |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
142 | #define MW_KEY_CLIENT "client_id_val" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
143 | #define MW_KEY_MAJOR "client_major" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
144 | #define MW_KEY_MINOR "client_minor" |
| 10977 | 145 | |
| 146 | ||
| 147 | /** number of seconds from the first blist change before a save to the | |
| 148 | storage service occurs. */ | |
| 149 | #define BLIST_SAVE_SECONDS 15 | |
| 150 | ||
| 151 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
152 | /** the possible buddy list storage settings */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
153 | enum blist_choice { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
154 | blist_choice_LOCAL = 1, /**< local only */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
155 | blist_choice_MERGE = 2, /**< merge from server */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
156 | 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
|
157 | blist_choice_SYNCH = 4 /**< sync with server */ |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
158 | }; |
| 10977 | 159 | |
| 160 | ||
| 161 | /** the default blist storage option */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
162 | #define BLIST_CHOICE_DEFAULT blist_choice_SYNCH |
| 10977 | 163 | |
| 164 | ||
| 165 | /* testing for the above */ | |
| 15884 | 166 | #define BLIST_PREF_IS(n) (purple_prefs_get_int(MW_PRPL_OPT_BLIST_ACTION)==(n)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
167 | #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
|
168 | #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
|
169 | #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
|
170 | #define BLIST_PREF_IS_SYNCH() BLIST_PREF_IS(blist_choice_SYNCH) |
| 10977 | 171 | |
| 172 | ||
| 173 | /* 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
|
174 | #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
|
175 | #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
|
176 | #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
|
177 | #define DEBUG_WARN(...) purple_debug_warning(G_LOG_DOMAIN, __VA_ARGS__) |
| 10977 | 178 | |
| 179 | ||
| 180 | /** ensure non-null strings */ | |
| 181 | #ifndef NSTR | |
| 182 | # define NSTR(str) ((str)? (str): "(null)") | |
| 183 | #endif | |
| 184 | ||
| 185 | ||
| 186 | /** calibrates distinct secure channel nomenclature */ | |
| 187 | static const unsigned char no_secret[] = { | |
| 188 | 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65, | |
| 189 | 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a, | |
| 190 | 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64, | |
| 191 | 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00, | |
| 192 | }; | |
| 193 | ||
| 194 | ||
| 195 | /** handler IDs from g_log_set_handler in mw_plugin_init */ | |
| 196 | static guint log_handler[2] = { 0, 0 }; | |
| 197 | ||
| 198 | ||
| 15884 | 199 | /** the purple plugin data. |
| 10977 | 200 | available as gc->proto_data and mwSession_getClientData */ |
| 15884 | 201 | struct mwPurplePluginData { |
| 10977 | 202 | struct mwSession *session; |
| 203 | ||
| 204 | struct mwServiceAware *srvc_aware; | |
| 205 | struct mwServiceConference *srvc_conf; | |
| 206 | struct mwServiceFileTransfer *srvc_ft; | |
| 207 | struct mwServiceIm *srvc_im; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
208 | struct mwServicePlace *srvc_place; |
| 10977 | 209 | struct mwServiceResolve *srvc_resolve; |
| 210 | struct mwServiceStorage *srvc_store; | |
| 211 | ||
| 15884 | 212 | /** map of PurpleGroup:mwAwareList and mwAwareList:PurpleGroup */ |
| 10977 | 213 | GHashTable *group_list_map; |
| 214 | ||
| 215 | /** event id for the buddy list save callback */ | |
| 216 | guint save_event; | |
| 217 | ||
| 218 | /** socket fd */ | |
| 219 | int socket; | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
220 | gint outpa; /* like inpa, but the other way */ |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
221 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
222 | /** circular buffer for outgoing data */ |
| 15884 | 223 | PurpleCircBuffer *sock_buf; |
| 224 | ||
| 225 | PurpleConnection *gc; | |
| 10977 | 226 | }; |
| 227 | ||
| 228 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
229 | typedef struct { |
| 15884 | 230 | PurpleBuddy *buddy; |
| 231 | PurpleGroup *group; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
232 | } BuddyAddData; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
233 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
234 | |
| 10977 | 235 | /* blist and aware functions */ |
| 236 | ||
| 15884 | 237 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist); |
| 238 | ||
| 239 | static void blist_store(struct mwPurplePluginData *pd); | |
| 240 | ||
| 241 | static void blist_schedule(struct mwPurplePluginData *pd); | |
| 242 | ||
| 243 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 244 | ||
| 245 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 246 | ||
| 247 | static gboolean buddy_is_external(PurpleBuddy *b); | |
| 248 | ||
| 249 | static void buddy_add(struct mwPurplePluginData *pd, PurpleBuddy *buddy); | |
| 250 | ||
| 251 | static PurpleBuddy * | |
| 252 | buddy_ensure(PurpleConnection *gc, PurpleGroup *group, | |
| 10977 | 253 | struct mwSametimeUser *stuser); |
| 254 | ||
| 15884 | 255 | static void group_add(struct mwPurplePluginData *pd, PurpleGroup *group); |
| 256 | ||
| 257 | static PurpleGroup * | |
| 258 | group_ensure(PurpleConnection *gc, struct mwSametimeGroup *stgroup); | |
| 10977 | 259 | |
| 260 | static struct mwAwareList * | |
| 15884 | 261 | list_ensure(struct mwPurplePluginData *pd, PurpleGroup *group); |
| 10977 | 262 | |
| 263 | ||
| 264 | /* session functions */ | |
| 265 | ||
| 266 | static struct mwSession * | |
| 15884 | 267 | gc_to_session(PurpleConnection *gc); |
| 268 | ||
| 269 | static PurpleConnection *session_to_gc(struct mwSession *session); | |
| 10977 | 270 | |
| 271 | ||
| 272 | /* conference functions */ | |
| 273 | ||
| 274 | static struct mwConference * | |
| 15884 | 275 | conf_find_by_id(struct mwPurplePluginData *pd, int id); |
| 10977 | 276 | |
| 277 | ||
| 278 | /* conversation functions */ | |
| 279 | ||
| 280 | struct convo_msg { | |
| 281 | enum mwImSendType type; | |
| 282 | gpointer data; | |
| 283 | GDestroyNotify clear; | |
| 284 | }; | |
| 285 | ||
| 286 | ||
| 287 | struct convo_data { | |
| 288 | struct mwConversation *conv; | |
| 289 | GList *queue; /**< outgoing message queue, list of convo_msg */ | |
| 290 | }; | |
| 291 | ||
| 292 | static void convo_data_new(struct mwConversation *conv); | |
| 293 | ||
| 294 | static void convo_data_free(struct convo_data *conv); | |
| 295 | ||
| 296 | static void convo_features(struct mwConversation *conv); | |
| 297 | ||
| 15884 | 298 | static PurpleConversation *convo_get_gconv(struct mwConversation *conv); |
| 10977 | 299 | |
| 300 | ||
|
12629
14aae7d5da6b
[gaim-migrate @ 14965]
Richard Laager <rlaager@pidgin.im>
parents:
12624
diff
changeset
|
301 | /* name and id */ |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
302 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
303 | struct named_id { |
| 10977 | 304 | char *id; |
| 305 | char *name; | |
| 306 | }; | |
| 307 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
308 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
309 | /* connection functions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
310 | |
|
14178
d12b287697c9
[gaim-migrate @ 16750]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
311 | 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
|
312 | |
| 10977 | 313 | |
| 314 | /* ----- session ------ */ | |
| 315 | ||
| 316 | ||
| 15884 | 317 | /** resolves a mwSession from a PurpleConnection */ |
| 318 | static struct mwSession *gc_to_session(PurpleConnection *gc) { | |
| 319 | struct mwPurplePluginData *pd; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
320 | |
| 10977 | 321 | g_return_val_if_fail(gc != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
322 | |
| 10977 | 323 | pd = gc->proto_data; |
| 324 | g_return_val_if_fail(pd != NULL, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
325 | |
| 10977 | 326 | return pd->session; |
| 327 | } | |
| 328 | ||
| 329 | ||
| 15884 | 330 | /** resolves a PurpleConnection from a mwSession */ |
| 331 | static PurpleConnection *session_to_gc(struct mwSession *session) { | |
| 332 | struct mwPurplePluginData *pd; | |
| 10977 | 333 | |
| 334 | g_return_val_if_fail(session != NULL, NULL); | |
| 335 | ||
| 336 | pd = mwSession_getClientData(session); | |
| 337 | g_return_val_if_fail(pd != NULL, NULL); | |
| 338 | ||
| 339 | return pd->gc; | |
| 340 | } | |
| 341 | ||
| 342 | ||
| 15884 | 343 | static void write_cb(gpointer data, gint source, PurpleInputCondition cond) { |
| 344 | struct mwPurplePluginData *pd = data; | |
| 345 | PurpleCircBuffer *circ = pd->sock_buf; | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
346 | gsize avail; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
347 | int ret; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
348 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
349 | DEBUG_INFO("write_cb\n"); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
350 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
351 | g_return_if_fail(circ != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
352 | |
| 15884 | 353 | avail = purple_circ_buffer_get_max_read(circ); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
354 | if(BUF_LONG < avail) avail = BUF_LONG; |
|
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 | while(avail) { |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
357 | ret = write(pd->socket, circ->outptr, avail); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
358 | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
359 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
360 | break; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
361 | |
| 15884 | 362 | purple_circ_buffer_mark_read(circ, ret); |
| 363 | avail = purple_circ_buffer_get_max_read(circ); | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
364 | if(BUF_LONG < avail) avail = BUF_LONG; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
365 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
366 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
367 | if(! avail) { |
| 15884 | 368 | purple_input_remove(pd->outpa); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
369 | pd->outpa = 0; |
|
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 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
373 | |
| 10977 | 374 | static int mw_session_io_write(struct mwSession *session, |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
375 | const guchar *buf, gsize len) { |
| 15884 | 376 | struct mwPurplePluginData *pd; |
|
22709
6bd336964410
Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
377 | gssize ret = 0; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
378 | int err = 0; |
| 10977 | 379 | |
| 380 | pd = mwSession_getClientData(session); | |
| 381 | ||
| 382 | /* socket was already closed. */ | |
| 383 | if(pd->socket == 0) | |
| 384 | return 1; | |
| 385 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
386 | if(pd->outpa) { |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
387 | DEBUG_INFO("already pending INPUT_WRITE, buffering\n"); |
| 15884 | 388 | purple_circ_buffer_append(pd->sock_buf, buf, len); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
389 | return 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
390 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
391 | |
| 10977 | 392 | while(len) { |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
393 | 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
|
394 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
395 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
396 | break; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
397 | |
| 10977 | 398 | len -= ret; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
399 | buf += ret; |
| 10977 | 400 | } |
| 401 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
402 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
403 | err = errno; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
404 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
405 | if(err == EAGAIN) { |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
406 | /* append remainder to circular buffer */ |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
407 | DEBUG_INFO("EAGAIN\n"); |
| 15884 | 408 | purple_circ_buffer_append(pd->sock_buf, buf, len); |
| 409 | 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
|
410 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
411 | } else if(len > 0) { |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
412 | 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
|
413 | g_strerror(errno)); |
|
22709
6bd336964410
Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
414 | 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
|
415 | " bytes left unwritten\n", ret, len); |
| 21279 | 416 | purple_connection_error_reason(pd->gc, |
| 417 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
418 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
419 | g_free(tmp); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
420 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
421 | #if 0 |
| 10977 | 422 | close(pd->socket); |
| 423 | pd->socket = 0; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
424 | #endif |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
425 | |
| 10977 | 426 | return -1; |
| 427 | } | |
| 428 | ||
| 429 | return 0; | |
| 430 | } | |
| 431 | ||
| 432 | ||
| 433 | static void mw_session_io_close(struct mwSession *session) { | |
| 15884 | 434 | struct mwPurplePluginData *pd; |
| 435 | PurpleConnection *gc; | |
| 10977 | 436 | |
| 437 | pd = mwSession_getClientData(session); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
438 | g_return_if_fail(pd != NULL); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
439 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
440 | gc = pd->gc; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
441 | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
442 | if(pd->outpa) { |
| 15884 | 443 | purple_input_remove(pd->outpa); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
444 | pd->outpa = 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
445 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
446 | |
| 10977 | 447 | if(pd->socket) { |
| 448 | close(pd->socket); | |
| 449 | pd->socket = 0; | |
| 450 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
451 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
452 | if(gc->inpa) { |
| 15884 | 453 | purple_input_remove(gc->inpa); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
454 | gc->inpa = 0; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
455 | } |
| 10977 | 456 | } |
| 457 | ||
| 458 | ||
| 459 | static void mw_session_clear(struct mwSession *session) { | |
| 460 | ; /* nothing for now */ | |
| 461 | } | |
| 462 | ||
| 463 | ||
| 464 | /* ----- aware list ----- */ | |
| 465 | ||
| 466 | ||
| 467 | static void blist_resolve_alias_cb(struct mwServiceResolve *srvc, | |
| 468 | guint32 id, guint32 code, GList *results, | |
| 469 | gpointer data) { | |
| 470 | struct mwResolveResult *result; | |
| 471 | struct mwResolveMatch *match; | |
| 472 | ||
| 473 | g_return_if_fail(results != NULL); | |
| 474 | ||
| 475 | result = results->data; | |
| 476 | g_return_if_fail(result != NULL); | |
| 477 | g_return_if_fail(result->matches != NULL); | |
| 478 | ||
| 479 | match = result->matches->data; | |
| 480 | g_return_if_fail(match != NULL); | |
| 481 | ||
| 15884 | 482 | purple_blist_server_alias_buddy(data, match->name); |
| 483 | purple_blist_node_set_string(data, BUDDY_KEY_NAME, match->name); | |
| 10977 | 484 | } |
| 485 | ||
| 486 | ||
| 487 | static void mw_aware_list_on_aware(struct mwAwareList *list, | |
| 488 | struct mwAwareSnapshot *aware) { | |
| 489 | ||
| 15884 | 490 | PurpleConnection *gc; |
| 491 | PurpleAccount *acct; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
492 | |
| 15884 | 493 | struct mwPurplePluginData *pd; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
494 | guint32 idle; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
495 | guint stat; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
496 | const char *id; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
497 | const char *status = MW_STATE_ACTIVE; |
| 10977 | 498 | |
| 499 | gc = mwAwareList_getClientData(list); | |
| 15884 | 500 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
501 | |
| 10977 | 502 | pd = gc->proto_data; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
503 | idle = aware->status.time; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
504 | stat = aware->status.status; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
505 | id = aware->id.user; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
506 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
507 | if(idle) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
508 | guint32 idle_len; /*< how long a client has been idle */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
509 | 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
|
510 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
511 | 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
|
512 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
513 | idle_len = time(NULL) - idle; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
514 | ugly_idle_len = ((time(NULL) * 1000) - idle) / 1000; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
515 | |
|
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
|
516 | 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
|
517 | 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
|
518 | 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
|
519 | 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
|
520 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
521 | /* |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
522 | 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
|
523 | 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
|
524 | 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
|
525 | 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
|
526 | 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
|
527 | 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
|
528 | this. |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
529 | */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
530 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
531 | 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
|
532 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
533 | #if 1 |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
534 | if(idle_len <= ugly_idle_len) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
535 | ; /* DEBUG_INFO("sane idle value, let's use it\n"); */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
536 | } else { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
537 | idle = time(NULL) - ugly_idle_len; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
538 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
539 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
540 | #else |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
541 | if(idle < 0 || idle > time(NULL)) { |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
542 | 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
|
543 | idle = -1; |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
544 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
545 | #endif |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
546 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
547 | |
| 10977 | 548 | switch(stat) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
549 | case mwStatus_ACTIVE: |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
550 | status = MW_STATE_ACTIVE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
551 | idle = 0; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
552 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
553 | |
| 10977 | 554 | case mwStatus_IDLE: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
555 | if(! idle) idle = -1; |
| 10977 | 556 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
557 | |
| 10977 | 558 | case mwStatus_AWAY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
559 | status = MW_STATE_AWAY; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
560 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
561 | |
| 10977 | 562 | case mwStatus_BUSY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
563 | status = MW_STATE_BUSY; |
| 10977 | 564 | break; |
| 565 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
566 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
567 | /* NAB group members */ |
| 10977 | 568 | if(aware->group) { |
| 15884 | 569 | PurpleGroup *group; |
| 570 | PurpleBuddy *buddy; | |
| 571 | PurpleBlistNode *bnode; | |
| 10977 | 572 | |
| 573 | group = g_hash_table_lookup(pd->group_list_map, list); | |
| 15884 | 574 | buddy = purple_find_buddy_in_group(acct, id, group); |
| 575 | bnode = (PurpleBlistNode *) buddy; | |
| 10977 | 576 | |
| 577 | if(! buddy) { | |
| 578 | struct mwServiceResolve *srvc; | |
| 579 | GList *query; | |
| 580 | ||
| 15884 | 581 | buddy = purple_buddy_new(acct, id, NULL); |
| 582 | purple_blist_add_buddy(buddy, NULL, group, NULL); | |
| 583 | ||
| 584 | bnode = (PurpleBlistNode *) buddy; | |
| 10977 | 585 | |
| 586 | srvc = pd->srvc_resolve; | |
| 587 | query = g_list_append(NULL, (char *) id); | |
| 588 | ||
| 589 | mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS, | |
| 590 | blist_resolve_alias_cb, buddy, NULL); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
591 | g_list_free(query); |
| 10977 | 592 | } |
| 593 | ||
| 15884 | 594 | purple_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL); |
| 10977 | 595 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
596 | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
597 | if(aware->online) { |
| 15884 | 598 | purple_prpl_got_user_status(acct, id, status, NULL); |
| 599 | purple_prpl_got_user_idle(acct, id, !!idle, (time_t) idle); | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
600 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
601 | } else { |
| 15884 | 602 | purple_prpl_got_user_status(acct, id, MW_STATE_OFFLINE, NULL); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
603 | } |
| 10977 | 604 | } |
| 605 | ||
| 606 | ||
| 607 | static void mw_aware_list_on_attrib(struct mwAwareList *list, | |
| 608 | struct mwAwareIdBlock *id, | |
| 609 | struct mwAwareAttribute *attrib) { | |
| 610 | ||
| 611 | ; /* nothing. We'll get attribute data as we need it */ | |
| 612 | } | |
| 613 | ||
| 614 | ||
| 615 | static void mw_aware_list_clear(struct mwAwareList *list) { | |
| 616 | ; /* nothing for now */ | |
| 617 | } | |
| 618 | ||
| 619 | ||
| 620 | static struct mwAwareListHandler mw_aware_list_handler = { | |
|
17157
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
621 | mw_aware_list_on_aware, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
622 | mw_aware_list_on_attrib, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
623 | mw_aware_list_clear, |
| 10977 | 624 | }; |
| 625 | ||
| 626 | ||
| 627 | /** Ensures that an Aware List is associated with the given group, and | |
| 628 | returns that list. */ | |
| 629 | static struct mwAwareList * | |
| 15884 | 630 | list_ensure(struct mwPurplePluginData *pd, PurpleGroup *group) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
631 | |
| 10977 | 632 | struct mwAwareList *list; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
633 | |
| 10977 | 634 | g_return_val_if_fail(pd != NULL, NULL); |
| 635 | g_return_val_if_fail(group != NULL, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
636 | |
| 10977 | 637 | list = g_hash_table_lookup(pd->group_list_map, group); |
| 638 | if(! list) { | |
| 639 | list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler); | |
| 640 | mwAwareList_setClientData(list, pd->gc, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
641 | |
| 10977 | 642 | mwAwareList_watchAttributes(list, |
| 643 | mwAttribute_AV_PREFS_SET, | |
| 644 | mwAttribute_MICROPHONE, | |
| 645 | mwAttribute_SPEAKERS, | |
| 646 | mwAttribute_VIDEO_CAMERA, | |
| 647 | mwAttribute_FILE_TRANSFER, | |
| 648 | NULL); | |
| 649 | ||
| 650 | g_hash_table_replace(pd->group_list_map, group, list); | |
| 651 | g_hash_table_insert(pd->group_list_map, list, group); | |
| 652 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
653 | |
| 10977 | 654 | return list; |
| 655 | } | |
| 656 | ||
| 657 | ||
| 15884 | 658 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 10977 | 659 | /* - find the account for this connection |
| 660 | - iterate through the buddy list | |
| 661 | - add each buddy matching this account to the stlist | |
| 662 | */ | |
| 663 | ||
| 15884 | 664 | PurpleAccount *acct; |
| 665 | PurpleBlistNode *gn, *cn, *bn; | |
| 666 | PurpleGroup *grp; | |
| 667 | PurpleBuddy *bdy; | |
| 10977 | 668 | |
| 669 | struct mwSametimeGroup *stg = NULL; | |
| 670 | struct mwIdBlock idb = { NULL, NULL }; | |
| 671 | ||
| 15884 | 672 | acct = purple_connection_get_account(gc); |
| 10977 | 673 | g_return_if_fail(acct != NULL); |
| 674 | ||
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
675 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
676 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 10977 | 677 | const char *owner; |
| 678 | const char *gname; | |
| 679 | enum mwSametimeGroupType gtype; | |
| 680 | gboolean gopen; | |
| 681 | ||
| 15884 | 682 | if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; |
| 683 | grp = (PurpleGroup *) gn; | |
| 10977 | 684 | |
| 685 | /* the group's type (normal or dynamic) */ | |
| 15884 | 686 | gtype = purple_blist_node_get_int(gn, GROUP_KEY_TYPE); |
| 10977 | 687 | if(! gtype) gtype = mwSametimeGroup_NORMAL; |
| 688 | ||
| 689 | /* if it's a normal group with none of our people in it, skip it */ | |
| 15884 | 690 | if(gtype == mwSametimeGroup_NORMAL && !purple_group_on_account(grp, acct)) |
| 10977 | 691 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
692 | |
| 10977 | 693 | /* if the group has an owner and we're not it, skip it */ |
| 15884 | 694 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
695 | if(owner && !purple_strequal(owner, purple_account_get_username(acct))) |
| 10977 | 696 | continue; |
| 697 | ||
| 15884 | 698 | /* the group's actual name may be different from the purple group's |
| 10977 | 699 | name. Find whichever is there */ |
| 15884 | 700 | 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
|
701 | if(! gname) gname = purple_group_get_name(grp); |
| 10977 | 702 | |
| 703 | /* we save this, but never actually honor it */ | |
| 15884 | 704 | gopen = ! purple_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); |
| 10977 | 705 | |
| 706 | 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
|
707 | mwSametimeGroup_setAlias(stg, purple_group_get_name(grp)); |
| 10977 | 708 | mwSametimeGroup_setOpen(stg, gopen); |
| 709 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
710 | /* 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
|
711 | other clients */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
712 | if(gtype == mwSametimeGroup_DYNAMIC) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
713 | continue; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
714 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
715 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
716 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
717 | cn = purple_blist_node_get_sibling_next(cn)) { |
| 15884 | 718 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
| 10977 | 719 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
720 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
721 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
722 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 723 | if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; |
| 724 | if(! PURPLE_BLIST_NODE_SHOULD_SAVE(bn)) continue; | |
| 725 | ||
| 726 | bdy = (PurpleBuddy *) bn; | |
| 10977 | 727 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
728 | if(purple_buddy_get_account(bdy) == acct) { |
| 10977 | 729 | struct mwSametimeUser *stu; |
| 730 | enum mwSametimeUserType utype; | |
| 731 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
732 | idb.user = (char *)purple_buddy_get_name(bdy); |
| 10977 | 733 | |
| 15884 | 734 | utype = purple_blist_node_get_int(bn, BUDDY_KEY_TYPE); |
| 10977 | 735 | if(! utype) utype = mwSametimeUser_NORMAL; |
| 736 | ||
| 737 | 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
|
738 | mwSametimeUser_setShortName(stu, purple_buddy_get_server_alias(bdy)); |
|
24950
143f594f0cd0
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
739 | mwSametimeUser_setAlias(stu, purple_buddy_get_local_buddy_alias(bdy)); |
| 10977 | 740 | } |
| 741 | } | |
| 742 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
743 | } |
| 10977 | 744 | } |
| 745 | ||
| 746 | ||
| 15884 | 747 | static void blist_store(struct mwPurplePluginData *pd) { |
| 10977 | 748 | |
| 749 | struct mwSametimeList *stlist; | |
| 750 | struct mwServiceStorage *srvc; | |
| 751 | struct mwStorageUnit *unit; | |
| 752 | ||
| 15884 | 753 | PurpleConnection *gc; |
| 10977 | 754 | |
| 755 | struct mwPutBuffer *b; | |
| 756 | struct mwOpaque *o; | |
| 757 | ||
| 758 | g_return_if_fail(pd != NULL); | |
| 759 | ||
| 760 | srvc = pd->srvc_store; | |
| 761 | g_return_if_fail(srvc != NULL); | |
| 762 | ||
| 763 | gc = pd->gc; | |
| 764 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
765 | if(BLIST_PREF_IS_LOCAL() || BLIST_PREF_IS_MERGE()) { |
| 10977 | 766 | DEBUG_INFO("preferences indicate not to save remote blist\n"); |
| 767 | return; | |
| 768 | ||
| 769 | } else if(MW_SERVICE_IS_DEAD(srvc)) { | |
| 770 | DEBUG_INFO("aborting save of blist: storage service is not alive\n"); | |
| 771 | return; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
772 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
773 | } else if(BLIST_PREF_IS_STORE() || BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
774 | DEBUG_INFO("saving remote blist\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
775 | |
| 10977 | 776 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
777 | g_return_if_reached(); |
| 10977 | 778 | } |
| 779 | ||
| 780 | /* create and export to a list object */ | |
| 781 | stlist = mwSametimeList_new(); | |
| 782 | blist_export(gc, stlist); | |
| 783 | ||
| 784 | /* write it to a buffer */ | |
| 785 | b = mwPutBuffer_new(); | |
| 786 | mwSametimeList_put(b, stlist); | |
| 787 | mwSametimeList_free(stlist); | |
| 788 | ||
| 789 | /* put the buffer contents into a storage unit */ | |
| 790 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
| 791 | o = mwStorageUnit_asOpaque(unit); | |
| 792 | mwPutBuffer_finalize(o, b); | |
| 793 | ||
| 794 | /* save the storage unit to the service */ | |
| 795 | mwServiceStorage_save(srvc, unit, NULL, NULL, NULL); | |
| 796 | } | |
| 797 | ||
| 798 | ||
| 799 | static gboolean blist_save_cb(gpointer data) { | |
| 15884 | 800 | struct mwPurplePluginData *pd = data; |
| 10977 | 801 | |
| 802 | blist_store(pd); | |
| 803 | pd->save_event = 0; | |
| 804 | return FALSE; | |
| 805 | } | |
| 806 | ||
| 807 | ||
| 808 | /** schedules the buddy list to be saved to the server */ | |
| 15884 | 809 | static void blist_schedule(struct mwPurplePluginData *pd) { |
| 10977 | 810 | if(pd->save_event) return; |
| 811 | ||
|
25716
1b5be208d5ba
applied changes from a336cc1fd3a1ce815f97303b8d5ae8988f8cbd5b
Ethan Blanton <elb@pidgin.im>
parents:
25292
diff
changeset
|
812 | pd->save_event = purple_timeout_add_seconds(BLIST_SAVE_SECONDS, |
| 10977 | 813 | blist_save_cb, pd); |
| 814 | } | |
| 815 | ||
| 816 | ||
| 15884 | 817 | static gboolean buddy_is_external(PurpleBuddy *b) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
818 | 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
|
819 | 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
|
820 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
821 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
822 | |
| 10977 | 823 | /** Actually add a buddy to the aware service, and schedule the buddy |
| 824 | list to be saved to the server */ | |
| 15884 | 825 | static void buddy_add(struct mwPurplePluginData *pd, |
| 826 | PurpleBuddy *buddy) { | |
| 10977 | 827 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
828 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) purple_buddy_get_name(buddy), NULL }; |
| 10977 | 829 | struct mwAwareList *list; |
| 830 | ||
| 15884 | 831 | PurpleGroup *group; |
| 10977 | 832 | GList *add; |
| 833 | ||
| 834 | add = g_list_prepend(NULL, &idb); | |
| 835 | ||
| 15884 | 836 | group = purple_buddy_get_group(buddy); |
| 10977 | 837 | list = list_ensure(pd, group); |
| 838 | ||
| 839 | if(mwAwareList_addAware(list, add)) { | |
| 15884 | 840 | purple_blist_remove_buddy(buddy); |
| 10977 | 841 | } |
| 842 | ||
| 843 | blist_schedule(pd); | |
| 844 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
845 | g_list_free(add); |
| 10977 | 846 | } |
| 847 | ||
| 848 | ||
| 15884 | 849 | /** ensure that a PurpleBuddy exists in the group with data |
| 10977 | 850 | appropriately matching the st user entry from the st list */ |
| 15884 | 851 | static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, |
| 10977 | 852 | struct mwSametimeUser *stuser) { |
| 853 | ||
| 15884 | 854 | struct mwPurplePluginData *pd = gc->proto_data; |
| 855 | PurpleBuddy *buddy; | |
| 856 | PurpleAccount *acct = purple_connection_get_account(gc); | |
| 10977 | 857 | |
| 858 | const char *id = mwSametimeUser_getUser(stuser); | |
| 859 | const char *name = mwSametimeUser_getShortName(stuser); | |
| 860 | const char *alias = mwSametimeUser_getAlias(stuser); | |
| 861 | enum mwSametimeUserType type = mwSametimeUser_getType(stuser); | |
| 862 | ||
| 863 | g_return_val_if_fail(id != NULL, NULL); | |
| 864 | g_return_val_if_fail(strlen(id) > 0, NULL); | |
| 865 | ||
| 15884 | 866 | buddy = purple_find_buddy_in_group(acct, id, group); |
| 10977 | 867 | if(! buddy) { |
| 15884 | 868 | buddy = purple_buddy_new(acct, id, alias); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
869 | |
| 15884 | 870 | purple_blist_add_buddy(buddy, NULL, group, NULL); |
| 10977 | 871 | buddy_add(pd, buddy); |
| 872 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
873 | |
| 15884 | 874 | purple_blist_alias_buddy(buddy, alias); |
| 875 | purple_blist_server_alias_buddy(buddy, name); | |
| 876 | purple_blist_node_set_string((PurpleBlistNode *) buddy, BUDDY_KEY_NAME, name); | |
| 877 | purple_blist_node_set_int((PurpleBlistNode *) buddy, BUDDY_KEY_TYPE, type); | |
| 10977 | 878 | |
| 879 | return buddy; | |
| 880 | } | |
| 881 | ||
| 882 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
883 | /** add aware watch for a dynamic group */ |
| 15884 | 884 | static void group_add(struct mwPurplePluginData *pd, |
| 885 | PurpleGroup *group) { | |
| 10977 | 886 | |
| 887 | struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL }; | |
| 888 | struct mwAwareList *list; | |
| 889 | const char *n; | |
| 890 | GList *add; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
891 | |
| 15884 | 892 | 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
|
893 | if(! n) n = purple_group_get_name(group); |
| 10977 | 894 | |
| 895 | idb.user = (char *) n; | |
| 896 | add = g_list_prepend(NULL, &idb); | |
| 897 | ||
| 898 | list = list_ensure(pd, group); | |
| 899 | mwAwareList_addAware(list, add); | |
| 900 | g_list_free(add); | |
| 901 | } | |
| 902 | ||
| 903 | ||
| 15884 | 904 | /** ensure that a PurpleGroup exists in the blist with data |
| 10977 | 905 | appropriately matching the st group entry from the st list */ |
| 15884 | 906 | static PurpleGroup *group_ensure(PurpleConnection *gc, |
| 10977 | 907 | struct mwSametimeGroup *stgroup) { |
| 15884 | 908 | PurpleAccount *acct; |
| 909 | PurpleGroup *group = NULL; | |
| 910 | PurpleBuddyList *blist; | |
| 911 | PurpleBlistNode *gn; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
912 | const char *name, *alias, *owner; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
913 | enum mwSametimeGroupType type; |
| 10977 | 914 | |
| 15884 | 915 | acct = purple_connection_get_account(gc); |
| 916 | owner = purple_account_get_username(acct); | |
| 917 | ||
| 918 | blist = purple_get_blist(); | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
919 | g_return_val_if_fail(blist != NULL, NULL); |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
920 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
921 | name = mwSametimeGroup_getName(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
922 | alias = mwSametimeGroup_getAlias(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
923 | type = mwSametimeGroup_getType(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
924 | |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
925 | if (!name) { |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
926 | DEBUG_WARN("Can't ensure a null group\n"); |
|
31991
efe4fb3772ad
Fix this compile warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
31983
diff
changeset
|
927 | return NULL; |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
928 | } |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
929 | |
|
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
|
930 | 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
|
931 | 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
|
932 | 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
|
933 | } |
|
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 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
935 | DEBUG_INFO("attempting to ensure group %s, called %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
936 | NSTR(name), NSTR(alias)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
937 | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
938 | /* 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
|
939 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
940 | gn = purple_blist_node_get_sibling_next(gn)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
941 | const char *n, *o; |
| 15884 | 942 | if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; |
| 943 | n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); | |
| 944 | 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
|
945 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
946 | 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
|
947 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
948 | if(n && purple_strequal(n, name)) { |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
949 | if(!o || purple_strequal(o, owner)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
950 | DEBUG_INFO("that'll work\n"); |
| 15884 | 951 | group = (PurpleGroup *) gn; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
952 | break; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
953 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
954 | } |
|
12524
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 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
957 | /* try again, by alias */ |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
958 | if(! group) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
959 | DEBUG_INFO("searching for group by alias %s\n", NSTR(alias)); |
| 15884 | 960 | group = purple_find_group(alias); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
961 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
962 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
963 | /* oh well, no such group. Let's create it! */ |
| 10977 | 964 | if(! group) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
965 | DEBUG_INFO("creating group\n"); |
| 15884 | 966 | group = purple_group_new(alias); |
| 967 | purple_blist_add_group(group, NULL); | |
| 10977 | 968 | } |
| 969 | ||
| 15884 | 970 | gn = (PurpleBlistNode *) group; |
| 971 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); | |
| 972 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | |
| 10977 | 973 | |
| 974 | if(type == mwSametimeGroup_DYNAMIC) { | |
| 15884 | 975 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); |
| 10977 | 976 | group_add(gc->proto_data, group); |
| 977 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
978 | |
| 10977 | 979 | return group; |
| 980 | } | |
| 981 | ||
| 982 | ||
| 15884 | 983 | /** merge the entries from a st list into the purple blist */ |
| 984 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist) { | |
| 10977 | 985 | struct mwSametimeGroup *stgroup; |
| 986 | struct mwSametimeUser *stuser; | |
| 987 | ||
| 15884 | 988 | PurpleGroup *group; |
| 10977 | 989 | |
| 990 | GList *gl, *gtl, *ul, *utl; | |
| 991 | ||
| 992 | gl = gtl = mwSametimeList_getGroups(stlist); | |
| 993 | for(; gl; gl = gl->next) { | |
| 994 | ||
| 995 | stgroup = (struct mwSametimeGroup *) gl->data; | |
| 996 | group = group_ensure(gc, stgroup); | |
| 997 | ||
| 998 | ul = utl = mwSametimeGroup_getUsers(stgroup); | |
| 999 | for(; ul; ul = ul->next) { | |
| 1000 | ||
| 1001 | stuser = (struct mwSametimeUser *) ul->data; | |
|
33782
1690e0b2c508
Fix a bunch of unused variables
Daniel Atallah <datallah@pidgin.im>
parents:
33745
diff
changeset
|
1002 | buddy_ensure(gc, group, stuser); |
| 10977 | 1003 | } |
| 1004 | g_list_free(utl); | |
| 1005 | } | |
| 1006 | g_list_free(gtl); | |
| 1007 | } | |
| 1008 | ||
| 1009 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1010 | /** 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
|
1011 | is left empty, remove group as well */ |
| 15884 | 1012 | static void group_clear(PurpleGroup *group, PurpleAccount *acct, gboolean del) { |
| 1013 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1014 | GList *prune = NULL; |
| 15884 | 1015 | PurpleBlistNode *gn, *cn, *bn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1016 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1017 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1018 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1019 | 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
|
1020 | |
| 15884 | 1021 | gc = purple_account_get_connection(acct); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1022 | g_return_if_fail(gc != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1023 | |
| 15884 | 1024 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1025 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1026 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1027 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1028 | cn = purple_blist_node_get_sibling_next(cn)) { |
| 15884 | 1029 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1030 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1031 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1032 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1033 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1034 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1035 | ||
| 1036 | if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1037 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1038 | 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
|
1039 | 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
|
1040 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1041 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1042 | } |
|
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 | /* quickly unsubscribe from presence for the entire group */ |
| 15884 | 1046 | purple_account_remove_group(acct, group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1047 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1048 | /* remove blist entries that need to go */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1049 | while(prune) { |
| 15884 | 1050 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1051 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1052 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1053 | DEBUG_INFO("cleared buddies\n"); |
|
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 | /* optionally remove group from blist */ |
| 15884 | 1056 | if(del && !purple_blist_get_group_size(group, TRUE)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1057 | DEBUG_INFO("removing empty group\n"); |
| 15884 | 1058 | purple_blist_remove_group(group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1059 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1060 | } |
|
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 | /** prune out group members that shouldn't be there */ |
| 15884 | 1064 | static void group_prune(PurpleConnection *gc, PurpleGroup *group, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1065 | struct mwSametimeGroup *stgroup) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1066 | |
| 15884 | 1067 | PurpleAccount *acct; |
| 1068 | PurpleBlistNode *gn, *cn, *bn; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1069 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1070 | GHashTable *stusers; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1071 | GList *prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1072 | GList *ul, *utl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1073 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1074 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1075 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1076 | 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
|
1077 | |
| 15884 | 1078 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1079 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1080 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1081 | 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
|
1082 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1083 | /* 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
|
1084 | contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1085 | utl = mwSametimeGroup_getUsers(stgroup); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1086 | for(ul = utl; ul; ul = ul->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1087 | const char *id = mwSametimeUser_getUser(ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1088 | g_hash_table_insert(stusers, (char *) id, ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1089 | DEBUG_INFO("server copy has %s\n", NSTR(id)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1090 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1091 | g_list_free(utl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1092 | |
| 15884 | 1093 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1094 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1095 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1096 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1097 | cn = purple_blist_node_get_sibling_next(cn)) { |
| 15884 | 1098 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1099 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1100 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1101 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1102 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1103 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1104 | ||
| 1105 | if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1106 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1107 | /* 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
|
1108 | them for pruning */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1109 | 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
|
1110 | 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
|
1111 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1112 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1113 | } |
|
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 | DEBUG_INFO("done marking\n"); |
|
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 | g_hash_table_destroy(stusers); |
|
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 | if(prune) { |
| 15884 | 1120 | purple_account_remove_buddies(acct, prune, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1121 | while(prune) { |
| 15884 | 1122 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1123 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1124 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1125 | } |
|
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 | |
| 15884 | 1129 | /** 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
|
1130 | existing buddies that aren't in the st list */ |
| 15884 | 1131 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 1132 | ||
| 1133 | PurpleAccount *acct; | |
| 1134 | PurpleBuddyList *blist; | |
| 1135 | PurpleBlistNode *gn; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1136 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1137 | GHashTable *stgroups; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1138 | GList *g_prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1139 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1140 | GList *gl, *gtl; |
|
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 | const char *acct_n; |
|
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 | DEBUG_INFO("synchronizing local buddy list from server list\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1145 | |
| 15884 | 1146 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1147 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1148 | |
| 15884 | 1149 | acct_n = purple_account_get_username(acct); |
| 1150 | ||
| 1151 | blist = purple_get_blist(); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1152 | g_return_if_fail(blist != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1153 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1154 | /* 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
|
1155 | list, mapping group name to group structure */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1156 | 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
|
1157 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1158 | gtl = mwSametimeList_getGroups(stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1159 | for(gl = gtl; gl; gl = gl->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1160 | const char *name = mwSametimeGroup_getName(gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1161 | g_hash_table_insert(stgroups, (char *) name, gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1162 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1163 | g_list_free(gtl); |
|
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 | /* 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
|
1166 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1167 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 15884 | 1168 | PurpleGroup *grp = (PurpleGroup *) gn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1169 | const char *gname, *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1170 | struct mwSametimeGroup *stgrp; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1171 | |
| 15884 | 1172 | if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1173 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1174 | /* group not belonging to this account */ |
| 15884 | 1175 | if(! purple_group_on_account(grp, acct)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1176 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1177 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1178 | /* dynamic group belonging to this account. don't prune contents */ |
| 15884 | 1179 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
1180 | if(owner && purple_strequal(owner, acct_n)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1181 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1182 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1183 | /* 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
|
1184 | title, which can be different things in the st list */ |
| 15884 | 1185 | 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
|
1186 | if(! gname) gname = purple_group_get_name(grp); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1187 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1188 | stgrp = g_hash_table_lookup(stgroups, gname); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1189 | if(! stgrp) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1190 | /* remove the whole group */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1191 | 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
|
1192 | g_prune = g_list_prepend(g_prune, grp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1193 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1194 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1195 | /* synch the group contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1196 | group_prune(gc, grp, stgrp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1197 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1198 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1199 | DEBUG_INFO("done marking groups\n"); |
|
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 | /* don't need this anymore */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1202 | g_hash_table_destroy(stgroups); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1203 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1204 | /* prune all marked groups */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1205 | while(g_prune) { |
| 15884 | 1206 | PurpleGroup *grp = g_prune->data; |
| 1207 | PurpleBlistNode *gn = (PurpleBlistNode *) grp; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1208 | const char *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1209 | gboolean del = TRUE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1210 | |
| 15884 | 1211 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
1212 | if(owner && !purple_strequal(owner, acct_n)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1213 | /* 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
|
1214 | 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
|
1215 | del = FALSE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1216 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1217 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1218 | group_clear(g_prune->data, acct, del); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1219 | g_prune = g_list_delete_link(g_prune, g_prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1220 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1221 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1222 | /* done with the pruning, let's merge in the additions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1223 | blist_merge(gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1224 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1225 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1226 | |
| 10977 | 1227 | /** callback passed to the storage service when it's told to load the |
| 1228 | st list */ | |
| 1229 | static void fetch_blist_cb(struct mwServiceStorage *srvc, | |
| 1230 | guint32 result, struct mwStorageUnit *item, | |
| 1231 | gpointer data) { | |
| 1232 | ||
| 15884 | 1233 | struct mwPurplePluginData *pd = data; |
| 10977 | 1234 | struct mwSametimeList *stlist; |
| 1235 | ||
| 1236 | struct mwGetBuffer *b; | |
| 1237 | ||
| 1238 | g_return_if_fail(result == ERR_SUCCESS); | |
| 1239 | ||
| 1240 | /* check our preferences for loading */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1241 | if(BLIST_PREF_IS_LOCAL()) { |
| 10977 | 1242 | DEBUG_INFO("preferences indicate not to load remote buddy list\n"); |
| 1243 | return; | |
| 1244 | } | |
| 1245 | ||
| 1246 | b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); | |
| 1247 | ||
| 1248 | stlist = mwSametimeList_new(); | |
| 1249 | mwSametimeList_get(b, stlist); | |
| 1250 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1251 | /* merge or synch depending on preferences */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1252 | if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1253 | blist_merge(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1254 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1255 | } else if(BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1256 | blist_sync(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1257 | } |
| 10977 | 1258 | |
| 1259 | mwSametimeList_free(stlist); | |
| 22973 | 1260 | mwGetBuffer_free(b); |
| 10977 | 1261 | } |
| 1262 | ||
| 1263 | ||
| 15884 | 1264 | /** signal triggered when a conversation is opened in Purple */ |
| 1265 | static void conversation_created_cb(PurpleConversation *g_conv, | |
| 1266 | struct mwPurplePluginData *pd) { | |
| 10977 | 1267 | |
| 1268 | /* we need to tell the IM service to negotiate features for the | |
| 1269 | conversation right away, otherwise it'll wait until the first | |
| 1270 | message is sent before offering NotesBuddy features. Therefore | |
| 15884 | 1271 | whenever Purple creates a conversation, we'll immediately open the |
| 10977 | 1272 | channel to the other side and figure out what the target can |
| 1273 | handle. Unfortunately, this makes us vulnerable to Psychic Mode, | |
| 1274 | 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
|
1275 | would not */ |
| 10977 | 1276 | |
| 15884 | 1277 | PurpleConnection *gc; |
| 10977 | 1278 | struct mwIdBlock who = { 0, 0 }; |
| 1279 | struct mwConversation *conv; | |
| 1280 | ||
| 15884 | 1281 | gc = purple_conversation_get_gc(g_conv); |
| 10977 | 1282 | if(pd->gc != gc) |
| 1283 | return; /* not ours */ | |
| 1284 | ||
| 15884 | 1285 | if(purple_conversation_get_type(g_conv) != PURPLE_CONV_TYPE_IM) |
| 10977 | 1286 | return; /* wrong type */ |
| 1287 | ||
| 15884 | 1288 | who.user = (char *) purple_conversation_get_name(g_conv); |
| 10977 | 1289 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 1290 | ||
| 1291 | convo_features(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1292 | |
| 10977 | 1293 | if(mwConversation_isClosed(conv)) |
| 1294 | mwConversation_open(conv); | |
| 1295 | } | |
| 1296 | ||
| 1297 | ||
| 15884 | 1298 | static void blist_menu_nab(PurpleBlistNode *node, gpointer data) { |
| 1299 | struct mwPurplePluginData *pd = data; | |
| 1300 | PurpleConnection *gc; | |
| 1301 | ||
| 1302 | PurpleGroup *group = (PurpleGroup *) node; | |
| 10977 | 1303 | |
| 1304 | GString *str; | |
| 1305 | char *tmp; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1306 | const char *gname; |
| 10977 | 1307 | |
| 1308 | g_return_if_fail(pd != NULL); | |
| 1309 | ||
| 1310 | gc = pd->gc; | |
| 1311 | g_return_if_fail(gc != NULL); | |
| 1312 | ||
| 15884 | 1313 | g_return_if_fail(PURPLE_BLIST_NODE_IS_GROUP(node)); |
| 10977 | 1314 | |
| 1315 | str = g_string_new(NULL); | |
| 1316 | ||
| 15884 | 1317 | 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
|
1318 | gname = purple_group_get_name(group); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1319 | |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1320 | 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
|
1321 | 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
|
1322 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1323 | tmp = g_strdup_printf(_("Info for Group %s"), gname); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1324 | |
| 15884 | 1325 | purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
| 10977 | 1326 | NULL, str->str, NULL, NULL); |
| 1327 | ||
| 1328 | g_free(tmp); | |
| 1329 | g_string_free(str, TRUE); | |
| 1330 | } | |
| 1331 | ||
| 1332 | ||
| 1333 | /** The normal blist menu prpl function doesn't get called for groups, | |
| 1334 | so we use the blist-node-extended-menu signal to trigger this | |
| 1335 | handler */ | |
| 15884 | 1336 | static void blist_node_menu_cb(PurpleBlistNode *node, |
| 1337 | GList **menu, struct mwPurplePluginData *pd) { | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1338 | const char *owner; |
| 15884 | 1339 | PurpleAccount *acct; |
| 1340 | PurpleMenuAction *act; | |
| 10977 | 1341 | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1342 | /* we only want groups */ |
| 15884 | 1343 | if(! PURPLE_BLIST_NODE_IS_GROUP(node)) return; |
| 1344 | ||
| 1345 | acct = purple_connection_get_account(pd->gc); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1346 | g_return_if_fail(acct != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1347 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1348 | /* better make sure we're connected */ |
| 15884 | 1349 | if(! purple_account_is_connected(acct)) return; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1350 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1351 | #if 0 |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1352 | /* 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
|
1353 | them all to a conference */ |
| 15884 | 1354 | if(purple_group_on_account(group, acct)) { |
| 1355 | act = purple_menu_action_new(_("Invite Group to Conference..."), | |
| 1356 | PURPLE_CALLBACK(blist_menu_group_invite), | |
| 13021 | 1357 | pd, NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1358 | *menu = g_list_append(*menu, NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1359 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1360 | #endif |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1361 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1362 | /* check if it's a NAB group for this account */ |
| 15884 | 1363 | owner = purple_blist_node_get_string(node, GROUP_KEY_OWNER); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
1364 | if(owner && purple_strequal(owner, purple_account_get_username(acct))) { |
| 15884 | 1365 | act = purple_menu_action_new(_("Get Notes Address Book Info"), |
| 1366 | PURPLE_CALLBACK(blist_menu_nab), pd, NULL); | |
| 10977 | 1367 | *menu = g_list_append(*menu, act); |
| 1368 | } | |
| 1369 | } | |
| 1370 | ||
| 1371 | ||
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1372 | /* 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
|
1373 | anymore. */ |
| 15884 | 1374 | static void blist_init(PurpleAccount *acct) { |
| 1375 | PurpleBlistNode *gnode, *cnode, *bnode; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1376 | GList *add_buds = NULL; |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1377 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1378 | for(gnode = purple_blist_get_root(); gnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1379 | gnode = purple_blist_node_get_sibling_next(gnode)) { |
| 15884 | 1380 | if(! PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1381 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1382 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1383 | cnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1384 | cnode = purple_blist_node_get_sibling_next(cnode)) { |
| 15884 | 1385 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1386 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1387 | for(bnode = purple_blist_node_get_first_child(cnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1388 | bnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1389 | bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 15884 | 1390 | PurpleBuddy *b; |
| 1391 | if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1392 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1393 | |
| 15884 | 1394 | b = (PurpleBuddy *)bnode; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1395 | if(purple_buddy_get_account(b) == acct) { |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1396 | add_buds = g_list_append(add_buds, b); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1397 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1398 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1399 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1400 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1401 | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1402 | if(add_buds) { |
| 15884 | 1403 | purple_account_add_buddies(acct, add_buds); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1404 | g_list_free(add_buds); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1405 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1406 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1407 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1408 | |
| 10977 | 1409 | /** Last thing to happen from a started session */ |
| 15884 | 1410 | static void services_starting(struct mwPurplePluginData *pd) { |
| 1411 | ||
| 1412 | PurpleConnection *gc; | |
| 1413 | PurpleAccount *acct; | |
| 10977 | 1414 | struct mwStorageUnit *unit; |
| 15884 | 1415 | PurpleBlistNode *l; |
| 10977 | 1416 | |
| 1417 | gc = pd->gc; | |
| 15884 | 1418 | acct = purple_connection_get_account(gc); |
| 10977 | 1419 | |
| 1420 | /* grab the buddy list from the server */ | |
| 1421 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1422 | mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
| 10977 | 1423 | |
| 1424 | /* 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
|
1425 | for(l = purple_blist_get_root(); l; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1426 | l = purple_blist_node_get_sibling_next(l)) { |
| 15884 | 1427 | PurpleGroup *group = (PurpleGroup *) l; |
| 10977 | 1428 | enum mwSametimeGroupType gt; |
| 1429 | const char *owner; | |
| 1430 | ||
| 15884 | 1431 | if(! PURPLE_BLIST_NODE_IS_GROUP(l)) continue; |
| 10977 | 1432 | |
| 1433 | /* if the group is ownerless, or has an owner and we're not it, | |
| 1434 | skip it */ | |
| 15884 | 1435 | owner = purple_blist_node_get_string(l, GROUP_KEY_OWNER); |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
1436 | if(!owner || !purple_strequal(owner, purple_account_get_username(acct))) |
| 10977 | 1437 | continue; |
| 1438 | ||
| 15884 | 1439 | gt = purple_blist_node_get_int(l, GROUP_KEY_TYPE); |
| 10977 | 1440 | if(gt == mwSametimeGroup_DYNAMIC) |
| 1441 | group_add(pd, group); | |
| 1442 | } | |
| 1443 | ||
| 1444 | /* set the aware attributes */ | |
| 1445 | /* indicate we understand what AV prefs are, but don't support any */ | |
| 1446 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1447 | mwAttribute_AV_PREFS_SET, TRUE); | |
| 1448 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE); | |
| 1449 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS); | |
| 1450 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA); | |
| 1451 | ||
| 1452 | /* ... but we can do file transfers! */ | |
| 1453 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1454 | mwAttribute_FILE_TRANSFER, TRUE); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1455 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1456 | blist_init(acct); |
| 10977 | 1457 | } |
| 1458 | ||
| 1459 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1460 | static void session_loginRedirect(struct mwSession *session, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1461 | const char *host) { |
| 15884 | 1462 | struct mwPurplePluginData *pd; |
| 1463 | PurpleConnection *gc; | |
| 1464 | PurpleAccount *account; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1465 | guint port; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1466 | const char *current_host; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1467 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1468 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1469 | gc = pd->gc; |
| 15884 | 1470 | account = purple_connection_get_account(gc); |
| 1471 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); | |
| 1472 | 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
|
1473 | MW_PLUGIN_DEFAULT_HOST); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1474 | |
| 15884 | 1475 | if(purple_account_get_bool(account, MW_KEY_FORCE, FALSE) || |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
1476 | !host || purple_strequal(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
|
1477 | (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
|
1478 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1479 | /* 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
|
1480 | 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
|
1481 | 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
|
1482 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1483 | mwSession_forceLogin(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1484 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1485 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1486 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1487 | |
| 15884 | 1488 | static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1489 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1490 | |
| 10977 | 1491 | /** called from mw_session_stateChange when the session's state is |
| 1492 | mwSession_STARTED. Any finalizing of start-up stuff should go | |
| 1493 | here */ | |
| 15884 | 1494 | static void session_started(struct mwPurplePluginData *pd) { |
| 1495 | PurpleStatus *status; | |
| 1496 | PurpleAccount *acct; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1497 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1498 | /* set out initial status */ |
| 15884 | 1499 | acct = purple_connection_get_account(pd->gc); |
| 1500 | status = purple_account_get_active_status(acct); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1501 | mw_prpl_set_status(acct, status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1502 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1503 | /* start watching for new conversations */ |
| 15884 | 1504 | purple_signal_connect(purple_conversations_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1505 | "conversation-created", pd, |
| 15884 | 1506 | PURPLE_CALLBACK(conversation_created_cb), pd); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1507 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1508 | /* watch for group extended menu items */ |
| 15884 | 1509 | purple_signal_connect(purple_blist_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1510 | "blist-node-extended-menu", pd, |
| 15884 | 1511 | PURPLE_CALLBACK(blist_node_menu_cb), pd); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1512 | |
| 10977 | 1513 | /* use our services to do neat things */ |
| 1514 | services_starting(pd); | |
| 1515 | } | |
| 1516 | ||
| 1517 | ||
| 15884 | 1518 | static void session_stopping(struct mwPurplePluginData *pd) { |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1519 | /* stop watching the signals from session_started */ |
| 15884 | 1520 | purple_signals_disconnect_by_handle(pd); |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1521 | } |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1522 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1523 | |
| 10977 | 1524 | static void mw_session_stateChange(struct mwSession *session, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1525 | enum mwSessionState state, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1526 | gpointer info) { |
| 15884 | 1527 | struct mwPurplePluginData *pd; |
| 1528 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1529 | const char *msg = NULL; |
| 10977 | 1530 | |
| 1531 | pd = mwSession_getClientData(session); | |
| 1532 | gc = pd->gc; | |
| 1533 | ||
| 1534 | switch(state) { | |
| 1535 | case mwSession_STARTING: | |
| 1536 | msg = _("Sending Handshake"); | |
| 15884 | 1537 | purple_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS); |
| 10977 | 1538 | break; |
| 1539 | ||
| 1540 | case mwSession_HANDSHAKE: | |
| 1541 | msg = _("Waiting for Handshake Acknowledgement"); | |
| 15884 | 1542 | purple_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS); |
| 10977 | 1543 | break; |
| 1544 | ||
| 1545 | case mwSession_HANDSHAKE_ACK: | |
| 1546 | msg = _("Handshake Acknowledged, Sending Login"); | |
| 15884 | 1547 | purple_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS); |
| 10977 | 1548 | break; |
| 1549 | ||
| 1550 | case mwSession_LOGIN: | |
| 1551 | msg = _("Waiting for Login Acknowledgement"); | |
| 15884 | 1552 | purple_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS); |
| 10977 | 1553 | break; |
| 1554 | ||
| 1555 | case mwSession_LOGIN_REDIR: | |
| 1556 | msg = _("Login Redirected"); | |
| 15884 | 1557 | 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
|
1558 | session_loginRedirect(session, info); |
| 10977 | 1559 | break; |
| 1560 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1561 | case mwSession_LOGIN_CONT: |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1562 | msg = _("Forcing Login"); |
| 15884 | 1563 | purple_connection_update_progress(gc, msg, 7, MW_CONNECT_STEPS); |
|
35966
d603bfb42fd9
Fix some coverity CWE-484 issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33782
diff
changeset
|
1564 | break; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1565 | |
| 10977 | 1566 | case mwSession_LOGIN_ACK: |
| 1567 | msg = _("Login Acknowledged"); | |
| 15884 | 1568 | purple_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS); |
| 10977 | 1569 | break; |
| 1570 | ||
| 1571 | case mwSession_STARTED: | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1572 | msg = _("Starting Services"); |
| 15884 | 1573 | purple_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS); |
| 10977 | 1574 | |
| 1575 | session_started(pd); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1576 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1577 | msg = _("Connected"); |
| 15884 | 1578 | purple_connection_update_progress(gc, msg, 10, MW_CONNECT_STEPS); |
| 1579 | purple_connection_set_state(gc, PURPLE_CONNECTED); | |
| 10977 | 1580 | break; |
| 1581 | ||
| 1582 | case mwSession_STOPPING: | |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1583 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1584 | session_stopping(pd); |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1585 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1586 | if(GPOINTER_TO_UINT(info) & ERR_FAILURE) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1587 | char *err = mwError(GPOINTER_TO_UINT(info)); |
| 21279 | 1588 | PurpleConnectionError reason; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1589 | switch (GPOINTER_TO_UINT(info)) { |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1590 | case VERSION_MISMATCH: |
| 21279 | 1591 | reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1592 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1593 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1594 | case USER_RESTRICTED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1595 | case INCORRECT_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1596 | case USER_UNREGISTERED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1597 | case GUEST_IN_USE: |
| 21279 | 1598 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1599 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1600 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1601 | case ENCRYPT_MISMATCH: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1602 | case ERR_ENCRYPT_NO_SUPPORT: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1603 | case ERR_NO_COMMON_ENCRYPT: |
| 21279 | 1604 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1605 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1606 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1607 | case VERIFICATION_DOWN: |
| 21279 | 1608 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1609 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1610 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1611 | case MULTI_SERVER_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1612 | case MULTI_SERVER_LOGIN2: |
| 21279 | 1613 | reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1614 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1615 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1616 | default: |
| 21279 | 1617 | reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1618 | } |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1619 | purple_connection_error_reason(gc, reason, err); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1620 | g_free(err); |
| 10977 | 1621 | } |
| 1622 | break; | |
| 1623 | ||
| 1624 | case mwSession_STOPPED: | |
| 1625 | break; | |
| 1626 | ||
| 1627 | case mwSession_UNKNOWN: | |
| 1628 | default: | |
| 1629 | DEBUG_WARN("session in unknown state\n"); | |
| 1630 | } | |
| 1631 | } | |
| 1632 | ||
| 1633 | ||
| 1634 | static void mw_session_setPrivacyInfo(struct mwSession *session) { | |
| 15884 | 1635 | struct mwPurplePluginData *pd; |
| 1636 | PurpleConnection *gc; | |
| 1637 | PurpleAccount *acct; | |
| 10977 | 1638 | struct mwPrivacyInfo *privacy; |
| 1639 | GSList *l, **ll; | |
| 1640 | guint count; | |
| 1641 | ||
| 1642 | DEBUG_INFO("privacy information set from server\n"); | |
| 1643 | ||
| 1644 | g_return_if_fail(session != NULL); | |
| 1645 | ||
| 1646 | pd = mwSession_getClientData(session); | |
| 1647 | g_return_if_fail(pd != NULL); | |
| 1648 | ||
| 1649 | gc = pd->gc; | |
| 1650 | g_return_if_fail(gc != NULL); | |
| 1651 | ||
| 15884 | 1652 | acct = purple_connection_get_account(gc); |
| 10977 | 1653 | g_return_if_fail(acct != NULL); |
| 1654 | ||
| 1655 | privacy = mwSession_getPrivacyInfo(session); | |
| 1656 | count = privacy->count; | |
| 1657 | ||
| 1658 | ll = (privacy->deny)? &acct->deny: &acct->permit; | |
| 1659 | for(l = *ll; l; l = l->next) g_free(l->data); | |
| 1660 | g_slist_free(*ll); | |
| 1661 | l = *ll = NULL; | |
| 1662 | ||
| 1663 | while(count--) { | |
| 1664 | struct mwUserItem *u = privacy->users + count; | |
| 1665 | l = g_slist_prepend(l, g_strdup(u->id)); | |
| 1666 | } | |
| 1667 | *ll = l; | |
| 1668 | } | |
| 1669 | ||
| 1670 | ||
| 1671 | static void mw_session_setUserStatus(struct mwSession *session) { | |
| 15884 | 1672 | struct mwPurplePluginData *pd; |
| 1673 | PurpleConnection *gc; | |
| 10977 | 1674 | struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL }; |
| 1675 | struct mwUserStatus *stat; | |
| 1676 | ||
| 1677 | g_return_if_fail(session != NULL); | |
| 1678 | ||
| 1679 | pd = mwSession_getClientData(session); | |
| 1680 | g_return_if_fail(pd != NULL); | |
| 1681 | ||
| 1682 | gc = pd->gc; | |
| 1683 | g_return_if_fail(gc != NULL); | |
| 1684 | ||
| 1685 | idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); | |
| 1686 | stat = mwSession_getUserStatus(session); | |
| 1687 | ||
| 1688 | /* trigger an update of our own status if we're in the buddy list */ | |
| 1689 | mwServiceAware_setStatus(pd->srvc_aware, &idb, stat); | |
| 1690 | } | |
| 1691 | ||
| 1692 | ||
| 1693 | static void mw_session_admin(struct mwSession *session, | |
| 1694 | const char *text) { | |
| 15884 | 1695 | PurpleConnection *gc; |
| 1696 | PurpleAccount *acct; | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1697 | const char *host; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1698 | const char *msg; |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1699 | char *prim; |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1700 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1701 | gc = session_to_gc(session); |
| 10977 | 1702 | g_return_if_fail(gc != NULL); |
| 1703 | ||
| 15884 | 1704 | acct = purple_connection_get_account(gc); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1705 | g_return_if_fail(acct != NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1706 | |
| 15884 | 1707 | 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
|
1708 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1709 | msg = _("A Sametime administrator has issued the following announcement" |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1710 | " on server %s"); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1711 | prim = g_strdup_printf(msg, NSTR(host)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1712 | |
| 15884 | 1713 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1714 | _("Sametime Administrator Announcement"), |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1715 | prim, text, NULL, NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1716 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1717 | g_free(prim); |
| 10977 | 1718 | } |
| 1719 | ||
| 1720 | ||
| 1721 | /** called from read_cb, attempts to read available data from sock and | |
| 1722 | pass it to the session, passing back the return code from the read | |
| 1723 | call for handling in read_cb */ | |
| 1724 | static int read_recv(struct mwSession *session, int sock) { | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1725 | guchar buf[BUF_LEN]; |
| 10977 | 1726 | int len; |
| 1727 | ||
| 1728 | 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
|
1729 | 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
|
1730 | 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
|
1731 | } |
| 10977 | 1732 | |
| 1733 | return len; | |
| 1734 | } | |
| 1735 | ||
| 1736 | ||
| 15884 | 1737 | /** callback triggered from purple_input_add, watches the socked for |
| 10977 | 1738 | available data to be processed by the session */ |
| 15884 | 1739 | static void read_cb(gpointer data, gint source, PurpleInputCondition cond) { |
| 1740 | struct mwPurplePluginData *pd = data; | |
| 10977 | 1741 | int ret = 0, err = 0; |
| 1742 | ||
| 1743 | g_return_if_fail(pd != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1744 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1745 | ret = read_recv(pd->session, pd->socket); |
| 10977 | 1746 | |
| 1747 | /* normal operation ends here */ | |
| 1748 | if(ret > 0) return; | |
| 1749 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1750 | /* fetch the global error value */ |
| 10977 | 1751 | err = errno; |
| 1752 | ||
| 14754 | 1753 | /* read problem occurred if we're here, so we'll need to take care of |
| 10977 | 1754 | it and clean up internal state */ |
| 1755 | ||
| 1756 | if(pd->socket) { | |
| 1757 | close(pd->socket); | |
| 1758 | pd->socket = 0; | |
| 1759 | } | |
| 1760 | ||
| 1761 | if(pd->gc->inpa) { | |
| 15884 | 1762 | purple_input_remove(pd->gc->inpa); |
| 10977 | 1763 | pd->gc->inpa = 0; |
| 1764 | } | |
| 1765 | ||
| 1766 | if(! ret) { | |
| 1767 | DEBUG_INFO("connection reset\n"); | |
| 21279 | 1768 | purple_connection_error_reason(pd->gc, |
| 1769 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1770 | _("Server closed the connection")); |
| 10977 | 1771 | |
| 1772 | } 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
|
1773 | 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
|
1774 | 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
|
1775 | |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1776 | 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
|
1777 | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1778 | msg = g_strdup_printf(_("Lost connection with server: %s"), err_str); |
| 21279 | 1779 | purple_connection_error_reason(pd->gc, |
| 1780 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
| 1781 | msg); | |
| 10977 | 1782 | g_free(msg); |
| 1783 | } | |
| 1784 | } | |
| 1785 | ||
| 1786 | ||
| 15884 | 1787 | /** Callback passed to purple_proxy_connect when an account is logged |
| 10977 | 1788 | 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
|
1789 | static void connect_cb(gpointer data, gint source, const gchar *error_message) { |
| 10977 | 1790 | |
| 15884 | 1791 | struct mwPurplePluginData *pd = data; |
| 1792 | PurpleConnection *gc = pd->gc; | |
| 10977 | 1793 | |
| 1794 | if(source < 0) { | |
| 1795 | /* connection failed */ | |
| 1796 | ||
| 1797 | if(pd->socket) { | |
| 1798 | /* this is a redirect connect, force login on existing socket */ | |
| 1799 | mwSession_forceLogin(pd->session); | |
| 1800 | ||
| 1801 | } else { | |
| 1802 | /* this is a regular connect, error out */ | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1803 | 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
|
1804 | error_message); |
| 21279 | 1805 | purple_connection_error_reason(pd->gc, |
| 1806 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1807 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1808 | g_free(tmp); |
| 10977 | 1809 | } |
| 1810 | ||
| 1811 | return; | |
| 1812 | } | |
| 1813 | ||
| 1814 | if(pd->socket) { | |
| 1815 | /* stop any existing login attempt */ | |
| 1816 | mwSession_stop(pd->session, ERR_SUCCESS); | |
| 1817 | } | |
| 1818 | ||
| 1819 | pd->socket = source; | |
| 15884 | 1820 | gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
1821 | read_cb, pd); |
| 10977 | 1822 | |
| 1823 | mwSession_start(pd->session); | |
| 1824 | } | |
| 1825 | ||
| 1826 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1827 | static void mw_session_announce(struct mwSession *s, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1828 | struct mwLoginInfo *from, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1829 | gboolean may_reply, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1830 | const char *text) { |
| 15884 | 1831 | struct mwPurplePluginData *pd; |
| 1832 | PurpleAccount *acct; | |
| 1833 | PurpleConversation *conv; | |
| 1834 | PurpleBuddy *buddy; | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1835 | char *who = from->user_id; |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1836 | char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1837 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1838 | pd = mwSession_getClientData(s); |
| 15884 | 1839 | acct = purple_connection_get_account(pd->gc); |
| 1840 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, acct); | |
| 1841 | if(! conv) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, who); | |
| 1842 | ||
| 1843 | buddy = purple_find_buddy(acct, who); | |
| 1844 | 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
|
1845 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1846 | who = g_strdup_printf(_("Announcement from %s"), who); |
| 15884 | 1847 | msg = purple_markup_linkify(text); |
| 1848 | ||
|
23979
936d7ef5cece
Add NULL checking to purple_markup_linkify().
Daniel Atallah <datallah@pidgin.im>
parents:
22973
diff
changeset
|
1849 | purple_conversation_write(conv, who, msg ? msg : "", PURPLE_MESSAGE_RECV, time(NULL)); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1850 | g_free(who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1851 | g_free(msg); |
| 10977 | 1852 | } |
| 1853 | ||
| 1854 | ||
| 1855 | static struct mwSessionHandler mw_session_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1856 | mw_session_io_write, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1857 | mw_session_io_close, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1858 | mw_session_clear, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1859 | mw_session_stateChange, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1860 | mw_session_setPrivacyInfo, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1861 | mw_session_setUserStatus, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1862 | mw_session_admin, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1863 | mw_session_announce, |
| 10977 | 1864 | }; |
| 1865 | ||
| 1866 | ||
| 1867 | static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
| 1868 | struct mwAwareAttribute *attrib) { | |
| 1869 | ||
| 1870 | ; /** @todo handle server attributes. There may be some stuff we | |
| 1871 | actually want to look for, but I'm not aware of anything right | |
| 1872 | now.*/ | |
| 1873 | } | |
| 1874 | ||
| 1875 | ||
| 1876 | static void mw_aware_clear(struct mwServiceAware *srvc) { | |
| 1877 | ; /* nothing for now */ | |
| 1878 | } | |
| 1879 | ||
| 1880 | ||
| 1881 | static struct mwAwareHandler mw_aware_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1882 | mw_aware_on_attrib, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1883 | mw_aware_clear, |
| 10977 | 1884 | }; |
| 1885 | ||
| 1886 | ||
| 1887 | static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
| 1888 | struct mwServiceAware *srvc; | |
| 1889 | srvc = mwServiceAware_new(s, &mw_aware_handler); | |
| 1890 | return srvc; | |
| 1891 | }; | |
| 1892 | ||
| 1893 | ||
| 1894 | static void mw_conf_invited(struct mwConference *conf, | |
| 1895 | struct mwLoginInfo *inviter, | |
| 1896 | const char *invitation) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1897 | |
| 10977 | 1898 | struct mwServiceConference *srvc; |
| 1899 | struct mwSession *session; | |
| 15884 | 1900 | struct mwPurplePluginData *pd; |
| 1901 | PurpleConnection *gc; | |
| 10977 | 1902 | |
| 1903 | char *c_inviter, *c_name, *c_topic, *c_invitation; | |
| 1904 | GHashTable *ht; | |
| 1905 | ||
| 1906 | srvc = mwConference_getService(conf); | |
| 1907 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1908 | pd = mwSession_getClientData(session); | |
| 1909 | gc = pd->gc; | |
| 1910 | ||
| 1911 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1912 | ||
| 1913 | c_inviter = g_strdup(inviter->user_id); | |
| 1914 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
| 1915 | ||
| 1916 | c_name = g_strdup(mwConference_getName(conf)); | |
| 1917 | g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
| 1918 | ||
| 1919 | c_topic = g_strdup(mwConference_getTitle(conf)); | |
| 1920 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
| 1921 | ||
| 1922 | c_invitation = g_strdup(invitation); | |
| 1923 | g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
| 1924 | ||
| 1925 | DEBUG_INFO("received invitation from '%s' to join ('%s','%s'): '%s'\n", | |
| 1926 | NSTR(c_inviter), NSTR(c_name), | |
| 1927 | NSTR(c_topic), NSTR(c_invitation)); | |
| 1928 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1929 | if(! c_topic) c_topic = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1930 | if(! c_invitation) c_invitation = "(no message)"; |
| 10977 | 1931 | serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
| 1932 | } | |
| 1933 | ||
| 1934 | ||
| 15884 | 1935 | /* The following mess helps us relate a mwConference to a PurpleConvChat |
| 10977 | 1936 | in the various forms by which either may be indicated */ |
| 1937 | ||
| 1938 | #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
| 1939 | #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
| 1940 | ||
| 15884 | 1941 | #define CHAT_TO_ID(chat) (purple_conv_chat_get_id(chat)) |
| 1942 | #define ID_TO_CHAT(id) (purple_find_chat(id)) | |
| 10977 | 1943 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1944 | #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
|
1945 | #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
| 10977 | 1946 | |
| 1947 | ||
| 1948 | static struct mwConference * | |
| 15884 | 1949 | conf_find_by_id(struct mwPurplePluginData *pd, int id) { |
| 10977 | 1950 | |
| 1951 | struct mwServiceConference *srvc = pd->srvc_conf; | |
| 1952 | struct mwConference *conf = NULL; | |
| 1953 | GList *l, *ll; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1954 | |
| 10977 | 1955 | ll = mwServiceConference_getConferences(srvc); |
| 1956 | for(l = ll; l; l = l->next) { | |
| 1957 | struct mwConference *c = l->data; | |
| 15884 | 1958 | PurpleConvChat *h = mwConference_getClientData(c); |
| 10977 | 1959 | |
| 1960 | if(CHAT_TO_ID(h) == id) { | |
| 1961 | conf = c; | |
| 1962 | break; | |
| 1963 | } | |
| 1964 | } | |
| 1965 | g_list_free(ll); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1966 | |
| 10977 | 1967 | return conf; |
| 1968 | } | |
| 1969 | ||
| 1970 | ||
| 1971 | static void mw_conf_opened(struct mwConference *conf, GList *members) { | |
| 1972 | struct mwServiceConference *srvc; | |
| 1973 | struct mwSession *session; | |
| 15884 | 1974 | struct mwPurplePluginData *pd; |
| 1975 | PurpleConnection *gc; | |
| 1976 | PurpleConversation *g_conf; | |
| 10977 | 1977 | |
| 1978 | const char *n = mwConference_getName(conf); | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1979 | const char *t = mwConference_getTitle(conf); |
| 10977 | 1980 | |
| 1981 | DEBUG_INFO("conf %s opened, %u initial members\n", | |
| 1982 | NSTR(n), g_list_length(members)); | |
| 1983 | ||
| 1984 | srvc = mwConference_getService(conf); | |
| 1985 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1986 | pd = mwSession_getClientData(session); | |
| 1987 | gc = pd->gc; | |
| 1988 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1989 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1990 | g_conf = serv_got_joined_chat(gc, CONF_TO_ID(conf), t); |
| 10977 | 1991 | |
| 15884 | 1992 | mwConference_setClientData(conf, PURPLE_CONV_CHAT(g_conf), NULL); |
| 10977 | 1993 | |
| 1994 | for(; members; members = members->next) { | |
| 1995 | struct mwLoginInfo *peer = members->data; | |
| 15884 | 1996 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(g_conf), peer->user_id, |
| 1997 | NULL, PURPLE_CBFLAGS_NONE, FALSE); | |
| 10977 | 1998 | } |
| 1999 | } | |
| 2000 | ||
| 2001 | ||
| 2002 | static void mw_conf_closed(struct mwConference *conf, guint32 reason) { | |
| 2003 | struct mwServiceConference *srvc; | |
| 2004 | struct mwSession *session; | |
| 15884 | 2005 | struct mwPurplePluginData *pd; |
| 2006 | PurpleConnection *gc; | |
| 10977 | 2007 | |
| 2008 | const char *n = mwConference_getName(conf); | |
| 2009 | char *msg = mwError(reason); | |
| 2010 | ||
| 2011 | DEBUG_INFO("conf %s closed, 0x%08x\n", NSTR(n), reason); | |
| 2012 | ||
| 2013 | srvc = mwConference_getService(conf); | |
| 2014 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2015 | pd = mwSession_getClientData(session); | |
| 2016 | gc = pd->gc; | |
| 2017 | ||
| 2018 | serv_got_chat_left(gc, CONF_TO_ID(conf)); | |
| 2019 | ||
| 15884 | 2020 | purple_notify_error(gc, _("Conference Closed"), NULL, msg); |
| 10977 | 2021 | g_free(msg); |
| 2022 | } | |
| 2023 | ||
| 2024 | ||
| 2025 | static void mw_conf_peer_joined(struct mwConference *conf, | |
| 2026 | struct mwLoginInfo *peer) { | |
| 2027 | ||
| 15884 | 2028 | PurpleConvChat *g_conf; |
| 10977 | 2029 | |
| 2030 | const char *n = mwConference_getName(conf); | |
| 2031 | ||
| 2032 | DEBUG_INFO("%s joined conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2033 | ||
| 2034 | g_conf = mwConference_getClientData(conf); | |
| 2035 | g_return_if_fail(g_conf != NULL); | |
| 2036 | ||
| 15884 | 2037 | purple_conv_chat_add_user(g_conf, peer->user_id, |
| 2038 | NULL, PURPLE_CBFLAGS_NONE, TRUE); | |
| 10977 | 2039 | } |
| 2040 | ||
| 2041 | ||
| 2042 | static void mw_conf_peer_parted(struct mwConference *conf, | |
| 2043 | struct mwLoginInfo *peer) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2044 | |
| 15884 | 2045 | PurpleConvChat *g_conf; |
| 10977 | 2046 | |
| 2047 | const char *n = mwConference_getName(conf); | |
| 2048 | ||
| 2049 | DEBUG_INFO("%s left conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2050 | ||
| 2051 | g_conf = mwConference_getClientData(conf); | |
| 2052 | g_return_if_fail(g_conf != NULL); | |
| 2053 | ||
| 15884 | 2054 | purple_conv_chat_remove_user(g_conf, peer->user_id, NULL); |
| 10977 | 2055 | } |
| 2056 | ||
| 2057 | ||
| 2058 | static void mw_conf_text(struct mwConference *conf, | |
| 2059 | struct mwLoginInfo *who, const char *text) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2060 | |
| 10977 | 2061 | struct mwServiceConference *srvc; |
| 2062 | struct mwSession *session; | |
| 15884 | 2063 | struct mwPurplePluginData *pd; |
| 2064 | PurpleConnection *gc; | |
| 10977 | 2065 | char *esc; |
| 2066 | ||
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2067 | if(! text) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2068 | |
| 10977 | 2069 | srvc = mwConference_getService(conf); |
| 2070 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2071 | pd = mwSession_getClientData(session); | |
| 2072 | gc = pd->gc; | |
| 2073 | ||
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2074 | esc = g_markup_escape_text(text, -1); |
| 10977 | 2075 | serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, 0, esc, time(NULL)); |
| 2076 | g_free(esc); | |
| 2077 | } | |
| 2078 | ||
| 2079 | ||
| 2080 | static void mw_conf_typing(struct mwConference *conf, | |
| 2081 | struct mwLoginInfo *who, gboolean typing) { | |
| 2082 | ||
| 15884 | 2083 | /* purple really has no good way to expose this to the user. */ |
| 10977 | 2084 | |
| 2085 | const char *n = mwConference_getName(conf); | |
| 2086 | const char *w = who->user_id; | |
| 2087 | ||
| 2088 | if(typing) { | |
| 2089 | DEBUG_INFO("%s in conf %s: <typing>\n", NSTR(w), NSTR(n)); | |
| 2090 | ||
| 2091 | } else { | |
| 2092 | DEBUG_INFO("%s in conf %s: <stopped typing>\n", NSTR(w), NSTR(n)); | |
| 2093 | } | |
| 2094 | } | |
| 2095 | ||
| 2096 | ||
| 2097 | static void mw_conf_clear(struct mwServiceConference *srvc) { | |
| 2098 | ; | |
| 2099 | } | |
| 2100 | ||
| 2101 | ||
| 2102 | static struct mwConferenceHandler mw_conference_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2103 | mw_conf_invited, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2104 | mw_conf_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2105 | mw_conf_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2106 | mw_conf_peer_joined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2107 | mw_conf_peer_parted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2108 | mw_conf_text, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2109 | mw_conf_typing, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2110 | mw_conf_clear, |
| 10977 | 2111 | }; |
| 2112 | ||
| 2113 | ||
| 2114 | static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) { | |
| 2115 | struct mwServiceConference *srvc; | |
| 2116 | srvc = mwServiceConference_new(s, &mw_conference_handler); | |
| 2117 | return srvc; | |
| 2118 | } | |
| 2119 | ||
| 2120 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2121 | /** size of an outgoing file transfer chunk */ |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2122 | #define MW_FT_LEN (BUF_LONG * 2) |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2123 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2124 | |
| 15884 | 2125 | static void ft_incoming_cancel(PurpleXfer *xfer) { |
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29304
diff
changeset
|
2126 | /* incoming transfer rejected or cancelled in-progress */ |
| 10977 | 2127 | struct mwFileTransfer *ft = xfer->data; |
| 2128 | if(ft) mwFileTransfer_reject(ft); | |
| 2129 | } | |
| 2130 | ||
| 2131 | ||
| 15884 | 2132 | static void ft_incoming_init(PurpleXfer *xfer) { |
| 10977 | 2133 | /* incoming transfer accepted */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2134 | |
| 10977 | 2135 | /* - accept the mwFileTransfer |
| 2136 | - open/create the local FILE "wb" | |
| 2137 | - stick the FILE's fp in xfer->dest_fp | |
| 2138 | */ | |
| 2139 | ||
| 2140 | struct mwFileTransfer *ft; | |
| 2141 | FILE *fp; | |
| 2142 | ||
| 2143 | ft = xfer->data; | |
| 2144 | ||
| 2145 | fp = g_fopen(xfer->local_filename, "wb"); | |
| 2146 | if(! fp) { | |
| 2147 | mwFileTransfer_cancel(ft); | |
| 2148 | return; | |
| 2149 | } | |
| 2150 | ||
| 2151 | xfer->dest_fp = fp; | |
| 2152 | mwFileTransfer_accept(ft); | |
| 2153 | } | |
| 2154 | ||
| 2155 | ||
| 2156 | static void mw_ft_offered(struct mwFileTransfer *ft) { | |
| 2157 | /* | |
| 15884 | 2158 | - create a purple ft object |
| 10977 | 2159 | - offer it |
| 2160 | */ | |
| 2161 | ||
| 2162 | struct mwServiceFileTransfer *srvc; | |
| 2163 | struct mwSession *session; | |
| 15884 | 2164 | struct mwPurplePluginData *pd; |
| 2165 | PurpleConnection *gc; | |
| 2166 | PurpleAccount *acct; | |
| 10977 | 2167 | const char *who; |
| 15884 | 2168 | PurpleXfer *xfer; |
| 10977 | 2169 | |
| 2170 | /* @todo add some safety checks */ | |
| 2171 | srvc = mwFileTransfer_getService(ft); | |
| 2172 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2173 | pd = mwSession_getClientData(session); | |
| 2174 | gc = pd->gc; | |
| 15884 | 2175 | acct = purple_connection_get_account(gc); |
| 10977 | 2176 | |
| 2177 | who = mwFileTransfer_getUser(ft)->user; | |
| 2178 | ||
| 2179 | DEBUG_INFO("file transfer %p offered\n", ft); | |
| 2180 | DEBUG_INFO(" from: %s\n", NSTR(who)); | |
| 2181 | DEBUG_INFO(" file: %s\n", NSTR(mwFileTransfer_getFileName(ft))); | |
| 2182 | DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft)); | |
| 2183 | DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft))); | |
| 2184 | ||
| 15884 | 2185 | xfer = purple_xfer_new(acct, PURPLE_XFER_RECEIVE, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2186 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2187 | { |
| 15884 | 2188 | purple_xfer_ref(xfer); |
| 2189 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2190 | xfer->data = ft; |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2191 | |
| 15884 | 2192 | purple_xfer_set_init_fnc(xfer, ft_incoming_init); |
| 2193 | purple_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); | |
| 2194 | purple_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); | |
| 2195 | ||
| 2196 | purple_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); | |
| 2197 | purple_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); | |
| 2198 | purple_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); | |
| 2199 | ||
| 2200 | purple_xfer_request(xfer); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2201 | } |
| 10977 | 2202 | } |
| 2203 | ||
| 2204 | ||
| 2205 | static void ft_send(struct mwFileTransfer *ft, FILE *fp) { | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2206 | 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
|
2207 | struct mwOpaque o = { MW_FT_LEN, buf }; |
| 10977 | 2208 | guint32 rem; |
| 15884 | 2209 | PurpleXfer *xfer; |
| 10977 | 2210 | |
| 2211 | xfer = mwFileTransfer_getClientData(ft); | |
| 2212 | ||
| 2213 | rem = mwFileTransfer_getRemaining(ft); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2214 | if(rem < MW_FT_LEN) o.len = rem; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2215 | |
|
36037
e2ef692ff10a
Fix outstaning Coverity bugs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35992
diff
changeset
|
2216 | if (fread(buf, (size_t)o.len, 1, fp) == 1) { |
| 10977 | 2217 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2218 | /* calculate progress and display it */ |
| 10977 | 2219 | xfer->bytes_sent += o.len; |
| 2220 | xfer->bytes_remaining -= o.len; | |
| 15884 | 2221 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2222 | |
| 10977 | 2223 | mwFileTransfer_send(ft, &o); |
| 2224 | ||
| 2225 | } else { | |
| 2226 | int err = errno; | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2227 | 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
|
2228 | NSTR(mwFileTransfer_getFileName(ft)), g_strerror(err)); |
| 10977 | 2229 | |
| 2230 | mwFileTransfer_cancel(ft); | |
| 2231 | } | |
| 2232 | } | |
| 2233 | ||
| 2234 | ||
| 2235 | static void mw_ft_opened(struct mwFileTransfer *ft) { | |
| 2236 | /* | |
| 15884 | 2237 | - get purple ft from client data in ft |
| 10977 | 2238 | - set the state to active |
| 2239 | */ | |
| 2240 | ||
| 15884 | 2241 | PurpleXfer *xfer; |
| 10977 | 2242 | |
| 2243 | xfer = mwFileTransfer_getClientData(ft); | |
| 2244 | ||
| 2245 | if(! xfer) { | |
| 2246 | mwFileTransfer_cancel(ft); | |
| 2247 | mwFileTransfer_free(ft); | |
| 2248 | g_return_if_reached(); | |
| 2249 | } | |
| 2250 | ||
| 15884 | 2251 | if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
| 10977 | 2252 | xfer->dest_fp = g_fopen(xfer->local_filename, "rb"); |
|
35992
34a67264df99
Fix some CWE-476 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35983
diff
changeset
|
2253 | if (xfer->dest_fp) |
|
34a67264df99
Fix some CWE-476 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35983
diff
changeset
|
2254 | ft_send(ft, xfer->dest_fp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2255 | } |
| 10977 | 2256 | } |
| 2257 | ||
| 2258 | ||
| 2259 | static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
| 2260 | /* | |
| 15884 | 2261 | - get purple ft from client data in ft |
| 10977 | 2262 | - indicate rejection/cancelation/completion |
| 2263 | - free the file transfer itself | |
| 2264 | */ | |
| 2265 | ||
| 15884 | 2266 | PurpleXfer *xfer; |
| 10977 | 2267 | |
| 2268 | xfer = mwFileTransfer_getClientData(ft); | |
| 2269 | if(xfer) { | |
| 2270 | xfer->data = NULL; | |
| 2271 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2272 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2273 | purple_xfer_set_completed(xfer, TRUE); |
| 2274 | purple_xfer_end(xfer); | |
| 10977 | 2275 | |
| 2276 | } else if(mwFileTransfer_isCancelLocal(ft)) { | |
| 15884 | 2277 | /* calling purple_xfer_cancel_local is redundant, since that's |
| 10977 | 2278 | probably what triggered this function to be called */ |
| 2279 | ; | |
| 2280 | ||
| 2281 | } else if(mwFileTransfer_isCancelRemote(ft)) { | |
| 2282 | /* steal the reference for the xfer */ | |
| 2283 | mwFileTransfer_setClientData(ft, NULL, NULL); | |
| 15884 | 2284 | purple_xfer_cancel_remote(xfer); |
| 10977 | 2285 | |
| 2286 | /* drop the stolen reference */ | |
| 15884 | 2287 | purple_xfer_unref(xfer); |
| 10977 | 2288 | return; |
| 2289 | } | |
| 2290 | } | |
| 2291 | ||
| 2292 | mwFileTransfer_free(ft); | |
| 2293 | } | |
| 2294 | ||
| 2295 | ||
| 2296 | static void mw_ft_recv(struct mwFileTransfer *ft, | |
| 2297 | struct mwOpaque *data) { | |
| 2298 | /* | |
| 15884 | 2299 | - get purple ft from client data in ft |
| 10977 | 2300 | - update transfered percentage |
| 15884 | 2301 | - if done, destroy the ft, disassociate from purple ft |
| 10977 | 2302 | */ |
| 2303 | ||
| 15884 | 2304 | PurpleXfer *xfer; |
| 10977 | 2305 | 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
|
2306 | size_t wc; |
| 10977 | 2307 | |
| 2308 | xfer = mwFileTransfer_getClientData(ft); | |
| 2309 | g_return_if_fail(xfer != NULL); | |
| 2310 | ||
| 2311 | fp = xfer->dest_fp; | |
| 2312 | g_return_if_fail(fp != NULL); | |
| 2313 | ||
| 2314 | /* 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
|
2315 | 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
|
2316 | 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
|
2317 | 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
|
2318 | 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
|
2319 | return; |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2320 | } |
| 10977 | 2321 | |
| 2322 | /* update the progress */ | |
| 2323 | xfer->bytes_sent += data->len; | |
| 2324 | xfer->bytes_remaining -= data->len; | |
| 15884 | 2325 | purple_xfer_update_progress(xfer); |
| 10977 | 2326 | |
| 2327 | /* let the other side know we got it, and to send some more */ | |
| 2328 | mwFileTransfer_ack(ft); | |
| 2329 | } | |
| 2330 | ||
| 2331 | ||
| 2332 | static void mw_ft_ack(struct mwFileTransfer *ft) { | |
| 15884 | 2333 | PurpleXfer *xfer; |
| 10977 | 2334 | |
| 2335 | xfer = mwFileTransfer_getClientData(ft); | |
| 2336 | g_return_if_fail(xfer != NULL); | |
| 2337 | g_return_if_fail(xfer->watcher == 0); | |
| 2338 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2339 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2340 | purple_xfer_set_completed(xfer, TRUE); |
| 2341 | purple_xfer_end(xfer); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2342 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2343 | } else if(mwFileTransfer_isOpen(ft)) { |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2344 | ft_send(ft, xfer->dest_fp); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2345 | } |
| 10977 | 2346 | } |
| 2347 | ||
| 2348 | ||
| 2349 | static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
| 2350 | ; | |
| 2351 | } | |
| 2352 | ||
| 2353 | ||
| 2354 | static struct mwFileTransferHandler mw_ft_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2355 | mw_ft_offered, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2356 | mw_ft_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2357 | mw_ft_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2358 | mw_ft_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2359 | mw_ft_ack, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2360 | mw_ft_clear, |
| 10977 | 2361 | }; |
| 2362 | ||
| 2363 | ||
| 2364 | static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
| 2365 | struct mwServiceFileTransfer *srvc; | |
| 2366 | GHashTable *ft_map; | |
| 2367 | ||
| 2368 | ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 2369 | ||
| 2370 | srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
| 2371 | mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
| 2372 | (GDestroyNotify) g_hash_table_destroy); | |
| 2373 | ||
| 2374 | return srvc; | |
| 2375 | } | |
| 2376 | ||
| 2377 | ||
| 2378 | static void convo_data_free(struct convo_data *cd) { | |
| 2379 | GList *l; | |
| 2380 | ||
| 2381 | /* clean the queue */ | |
| 2382 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2383 | struct convo_msg *m = l->data; | |
| 2384 | if(m->clear) m->clear(m->data); | |
| 2385 | g_free(m); | |
| 2386 | } | |
| 2387 | ||
| 2388 | g_free(cd); | |
| 2389 | } | |
| 2390 | ||
| 2391 | ||
| 2392 | /** allocates a convo_data structure and associates it with the | |
| 2393 | conversation in the client data slot */ | |
| 2394 | static void convo_data_new(struct mwConversation *conv) { | |
| 2395 | struct convo_data *cd; | |
| 2396 | ||
| 2397 | g_return_if_fail(conv != NULL); | |
| 2398 | ||
| 2399 | if(mwConversation_getClientData(conv)) | |
| 2400 | return; | |
| 2401 | ||
| 2402 | cd = g_new0(struct convo_data, 1); | |
| 2403 | cd->conv = conv; | |
| 2404 | ||
| 2405 | mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
| 2406 | } | |
| 2407 | ||
| 2408 | ||
| 15884 | 2409 | static PurpleConversation *convo_get_gconv(struct mwConversation *conv) { |
| 10977 | 2410 | struct mwServiceIm *srvc; |
| 2411 | struct mwSession *session; | |
| 15884 | 2412 | struct mwPurplePluginData *pd; |
| 2413 | PurpleConnection *gc; | |
| 2414 | PurpleAccount *acct; | |
| 10977 | 2415 | |
| 2416 | struct mwIdBlock *idb; | |
| 2417 | ||
| 2418 | srvc = mwConversation_getService(conv); | |
| 2419 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2420 | pd = mwSession_getClientData(session); | |
| 2421 | gc = pd->gc; | |
| 15884 | 2422 | acct = purple_connection_get_account(gc); |
| 10977 | 2423 | |
| 2424 | idb = mwConversation_getTarget(conv); | |
| 2425 | ||
| 15884 | 2426 | return purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2427 | idb->user, acct); |
| 10977 | 2428 | } |
| 2429 | ||
| 2430 | ||
| 2431 | static void convo_queue(struct mwConversation *conv, | |
| 2432 | enum mwImSendType type, gconstpointer data) { | |
| 2433 | ||
| 2434 | struct convo_data *cd; | |
| 2435 | struct convo_msg *m; | |
| 2436 | ||
| 2437 | convo_data_new(conv); | |
| 2438 | cd = mwConversation_getClientData(conv); | |
| 2439 | ||
| 2440 | m = g_new0(struct convo_msg, 1); | |
| 2441 | m->type = type; | |
| 2442 | ||
| 2443 | switch(type) { | |
| 2444 | case mwImSend_PLAIN: | |
| 2445 | m->data = g_strdup(data); | |
| 2446 | m->clear = g_free; | |
| 2447 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2448 | |
| 10977 | 2449 | case mwImSend_TYPING: |
| 2450 | default: | |
| 2451 | m->data = (gpointer) data; | |
| 2452 | m->clear = NULL; | |
| 2453 | } | |
| 2454 | ||
| 2455 | cd->queue = g_list_append(cd->queue, m); | |
| 2456 | } | |
| 2457 | ||
| 2458 | ||
| 2459 | /* Does what it takes to get an error displayed for a conversation */ | |
| 2460 | static void convo_error(struct mwConversation *conv, guint32 err) { | |
| 15884 | 2461 | PurpleConversation *gconv; |
| 10977 | 2462 | char *tmp, *text; |
| 2463 | struct mwIdBlock *idb; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2464 | |
| 10977 | 2465 | idb = mwConversation_getTarget(conv); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2466 | |
| 10977 | 2467 | tmp = mwError(err); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2468 | text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2469 | |
| 10977 | 2470 | gconv = convo_get_gconv(conv); |
| 15884 | 2471 | if(gconv && !purple_conv_present_error(idb->user, gconv->account, text)) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2472 | |
| 10977 | 2473 | g_free(text); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2474 | text = g_strdup_printf(_("Unable to send message to %s:"), |
| 10977 | 2475 | (idb->user)? idb->user: "(unknown)"); |
| 15884 | 2476 | purple_notify_error(purple_account_get_connection(gconv->account), |
| 10977 | 2477 | NULL, text, tmp); |
| 2478 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2479 | |
| 10977 | 2480 | g_free(tmp); |
| 2481 | g_free(text); | |
| 2482 | } | |
| 2483 | ||
| 2484 | ||
| 2485 | static void convo_queue_send(struct mwConversation *conv) { | |
| 2486 | struct convo_data *cd; | |
| 2487 | GList *l; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2488 | |
| 10977 | 2489 | cd = mwConversation_getClientData(conv); |
| 2490 | ||
| 2491 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2492 | struct convo_msg *m = l->data; | |
| 2493 | ||
| 2494 | mwConversation_send(conv, m->type, m->data); | |
| 2495 | ||
| 2496 | if(m->clear) m->clear(m->data); | |
| 2497 | g_free(m); | |
| 2498 | } | |
| 2499 | ||
| 2500 | cd->queue = NULL; | |
| 2501 | } | |
| 2502 | ||
| 2503 | ||
| 15884 | 2504 | /** called when a mw conversation leaves a purple conversation to |
| 2505 | inform the purple conversation that it's unsafe to offer any *cool* | |
| 10977 | 2506 | features. */ |
| 2507 | static void convo_nofeatures(struct mwConversation *conv) { | |
| 15884 | 2508 | PurpleConversation *gconv; |
| 2509 | PurpleConnection *gc; | |
| 10977 | 2510 | |
| 2511 | gconv = convo_get_gconv(conv); | |
| 2512 | if(! gconv) return; | |
| 2513 | ||
| 15884 | 2514 | gc = purple_conversation_get_gc(gconv); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2515 | if(! gc) return; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2516 | |
| 15884 | 2517 | purple_conversation_set_features(gconv, gc->flags); |
| 2518 | } | |
| 2519 | ||
| 2520 | ||
| 2521 | /** called when a mw conversation and purple conversation come together, | |
| 2522 | to inform the purple conversation of what features to offer the | |
| 10977 | 2523 | user */ |
| 2524 | static void convo_features(struct mwConversation *conv) { | |
| 15884 | 2525 | PurpleConversation *gconv; |
| 2526 | PurpleConnectionFlags feat; | |
| 10977 | 2527 | |
| 2528 | gconv = convo_get_gconv(conv); | |
| 2529 | if(! gconv) return; | |
| 2530 | ||
| 15884 | 2531 | feat = purple_conversation_get_features(gconv); |
| 10977 | 2532 | |
| 2533 | if(mwConversation_isOpen(conv)) { | |
| 2534 | if(mwConversation_supports(conv, mwImSend_HTML)) { | |
| 15884 | 2535 | feat |= PURPLE_CONNECTION_HTML; |
| 10977 | 2536 | } else { |
| 15884 | 2537 | feat &= ~PURPLE_CONNECTION_HTML; |
| 10977 | 2538 | } |
| 2539 | ||
| 2540 | if(mwConversation_supports(conv, mwImSend_MIME)) { | |
| 15884 | 2541 | feat &= ~PURPLE_CONNECTION_NO_IMAGES; |
| 10977 | 2542 | } else { |
| 15884 | 2543 | feat |= PURPLE_CONNECTION_NO_IMAGES; |
| 10977 | 2544 | } |
| 2545 | ||
| 2546 | DEBUG_INFO("conversation features set to 0x%04x\n", feat); | |
| 15884 | 2547 | purple_conversation_set_features(gconv, feat); |
| 10977 | 2548 | |
| 2549 | } else { | |
| 2550 | convo_nofeatures(conv); | |
| 2551 | } | |
| 2552 | } | |
| 2553 | ||
| 2554 | ||
| 2555 | static void mw_conversation_opened(struct mwConversation *conv) { | |
| 2556 | struct mwServiceIm *srvc; | |
| 2557 | struct mwSession *session; | |
| 15884 | 2558 | struct mwPurplePluginData *pd; |
| 2559 | PurpleConnection *gc; | |
| 2560 | PurpleAccount *acct; | |
| 10977 | 2561 | |
| 2562 | struct convo_dat *cd; | |
| 2563 | ||
| 2564 | srvc = mwConversation_getService(conv); | |
| 2565 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2566 | pd = mwSession_getClientData(session); | |
| 2567 | gc = pd->gc; | |
| 15884 | 2568 | acct = purple_connection_get_account(gc); |
| 10977 | 2569 | |
| 2570 | /* set up the queue */ | |
| 2571 | cd = mwConversation_getClientData(conv); | |
| 2572 | if(cd) { | |
| 2573 | convo_queue_send(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2574 | |
| 10977 | 2575 | if(! convo_get_gconv(conv)) { |
| 2576 | mwConversation_free(conv); | |
| 2577 | return; | |
| 2578 | } | |
| 2579 | ||
| 2580 | } else { | |
| 2581 | convo_data_new(conv); | |
| 2582 | } | |
| 2583 | ||
| 2584 | { /* record the client key for the buddy */ | |
| 15884 | 2585 | PurpleBuddy *buddy; |
| 10977 | 2586 | struct mwLoginInfo *info; |
| 2587 | info = mwConversation_getTargetInfo(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2588 | |
| 15884 | 2589 | buddy = purple_find_buddy(acct, info->user_id); |
| 10977 | 2590 | if(buddy) { |
| 15884 | 2591 | purple_blist_node_set_int((PurpleBlistNode *) buddy, |
| 10977 | 2592 | BUDDY_KEY_CLIENT, info->type); |
| 2593 | } | |
| 2594 | } | |
| 2595 | ||
| 2596 | convo_features(conv); | |
| 2597 | } | |
| 2598 | ||
| 2599 | ||
| 2600 | static void mw_conversation_closed(struct mwConversation *conv, | |
| 2601 | guint32 reason) { | |
| 2602 | ||
| 2603 | struct convo_data *cd; | |
| 2604 | ||
| 2605 | g_return_if_fail(conv != NULL); | |
| 2606 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2607 | /* 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
|
2608 | print an error message to the conversation */ |
| 10977 | 2609 | cd = mwConversation_getClientData(conv); |
| 2610 | if(reason && cd && cd->queue) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2611 | GList *l; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2612 | for(l = cd->queue; l; l = l->next) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2613 | struct convo_msg *m = l->data; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2614 | if(m->type != mwImSend_TYPING) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2615 | convo_error(conv, reason); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2616 | break; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2617 | } |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2618 | } |
| 10977 | 2619 | } |
| 2620 | ||
| 2621 | #if 0 | |
| 2622 | /* don't do this, to prevent the occasional weird sending of | |
| 2623 | formatted messages as plaintext when the other end closes the | |
| 2624 | conversation after we've begun composing the message */ | |
| 2625 | convo_nofeatures(conv); | |
| 2626 | #endif | |
| 2627 | ||
| 2628 | mwConversation_removeClientData(conv); | |
| 2629 | } | |
| 2630 | ||
| 2631 | ||
| 2632 | static void im_recv_text(struct mwConversation *conv, | |
| 15884 | 2633 | struct mwPurplePluginData *pd, |
| 10977 | 2634 | const char *msg) { |
| 2635 | ||
| 2636 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2637 | char *txt, *esc; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2638 | const char *t; |
| 10977 | 2639 | |
| 2640 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2641 | |
| 15884 | 2642 | txt = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2643 | t = txt? txt: msg; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2644 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2645 | esc = g_markup_escape_text(t, -1); |
| 10977 | 2646 | 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
|
2647 | g_free(esc); |
| 10977 | 2648 | |
| 2649 | g_free(txt); | |
| 2650 | } | |
| 2651 | ||
| 2652 | ||
| 2653 | static void im_recv_typing(struct mwConversation *conv, | |
| 15884 | 2654 | struct mwPurplePluginData *pd, |
| 10977 | 2655 | gboolean typing) { |
| 2656 | ||
| 2657 | struct mwIdBlock *idb; | |
| 2658 | idb = mwConversation_getTarget(conv); | |
| 2659 | ||
| 2660 | serv_got_typing(pd->gc, idb->user, 0, | |
| 15884 | 2661 | typing? PURPLE_TYPING: PURPLE_NOT_TYPING); |
| 10977 | 2662 | } |
| 2663 | ||
| 2664 | ||
| 2665 | static void im_recv_html(struct mwConversation *conv, | |
| 15884 | 2666 | struct mwPurplePluginData *pd, |
| 10977 | 2667 | const char *msg) { |
| 2668 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2669 | char *t1, *t2; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2670 | const char *t; |
| 10977 | 2671 | |
| 2672 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2673 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2674 | /* ensure we're receiving UTF8 */ |
| 15884 | 2675 | t1 = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2676 | t = t1? t1: msg; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2677 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2678 | /* convert entities to UTF8 so they'll log correctly */ |
| 15884 | 2679 | t2 = purple_utf8_ncr_decode(t); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2680 | t = t2? t2: t; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2681 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2682 | serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
| 10977 | 2683 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2684 | g_free(t1); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2685 | g_free(t2); |
| 10977 | 2686 | } |
| 2687 | ||
| 2688 | ||
| 2689 | static void im_recv_subj(struct mwConversation *conv, | |
| 15884 | 2690 | struct mwPurplePluginData *pd, |
| 10977 | 2691 | const char *subj) { |
| 2692 | ||
| 2693 | /** @todo somehow indicate receipt of a conversation subject. It | |
| 2694 | would also be nice if we added a /topic command for the | |
| 2695 | protocol */ | |
| 2696 | ; | |
| 2697 | } | |
| 2698 | ||
| 2699 | ||
| 2700 | /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */ | |
| 2701 | static char *make_cid(const char *cid) { | |
| 2702 | gsize n; | |
| 2703 | char *c, *d; | |
| 2704 | ||
| 2705 | g_return_val_if_fail(cid != NULL, NULL); | |
| 2706 | ||
| 2707 | n = strlen(cid); | |
| 2708 | g_return_val_if_fail(n > 2, NULL); | |
| 2709 | ||
| 2710 | c = g_strndup(cid+1, n-2); | |
| 2711 | d = g_strdup_printf("cid:%s", c); | |
| 2712 | ||
| 2713 | g_free(c); | |
| 2714 | return d; | |
| 2715 | } | |
| 2716 | ||
| 2717 | ||
| 2718 | static void im_recv_mime(struct mwConversation *conv, | |
| 15884 | 2719 | struct mwPurplePluginData *pd, |
| 10977 | 2720 | const char *data) { |
| 2721 | ||
| 2722 | GHashTable *img_by_cid; | |
| 2723 | GList *images; | |
| 2724 | ||
| 2725 | GString *str; | |
| 2726 | ||
| 15884 | 2727 | 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
|
2728 | GList *parts; |
| 10977 | 2729 | |
| 2730 | img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
| 2731 | images = NULL; | |
| 2732 | ||
| 2733 | /* don't want the contained string to ever be NULL */ | |
| 2734 | str = g_string_new(""); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2735 | |
| 15884 | 2736 | doc = purple_mime_document_parse(data); |
| 10977 | 2737 | |
| 2738 | /* handle all the MIME parts */ | |
| 15884 | 2739 | parts = purple_mime_document_get_parts(doc); |
| 10977 | 2740 | for(; parts; parts = parts->next) { |
| 15884 | 2741 | PurpleMimePart *part = parts->data; |
| 10977 | 2742 | const char *type; |
| 2743 | ||
| 15884 | 2744 | type = purple_mime_part_get_field(part, "content-type"); |
| 10977 | 2745 | DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type)); |
| 2746 | ||
| 2747 | if(! type) { | |
| 2748 | ; /* feh */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2749 | |
| 15884 | 2750 | } else if(purple_str_has_prefix(type, "image")) { |
| 10977 | 2751 | /* put images into the image store */ |
| 2752 | ||
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2753 | guchar *d_dat; |
| 10977 | 2754 | gsize d_len; |
| 2755 | char *cid; | |
| 2756 | int img; | |
| 2757 | ||
| 2758 | /* obtain and unencode the data */ | |
| 15884 | 2759 | 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
|
2760 | |
| 10977 | 2761 | /* look up the content id */ |
| 15884 | 2762 | cid = (char *) purple_mime_part_get_field(part, "Content-ID"); |
| 10977 | 2763 | cid = make_cid(cid); |
| 2764 | ||
| 15884 | 2765 | /* add image to the purple image store */ |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16121
diff
changeset
|
2766 | img = purple_imgstore_add_with_id(d_dat, d_len, cid); |
| 10977 | 2767 | |
| 2768 | /* map the cid to the image store identifier */ | |
| 2769 | g_hash_table_insert(img_by_cid, cid, GINT_TO_POINTER(img)); | |
| 2770 | ||
| 2771 | /* recall the image for dereferencing later */ | |
| 2772 | images = g_list_append(images, GINT_TO_POINTER(img)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2773 | |
| 15884 | 2774 | } else if(purple_str_has_prefix(type, "text")) { |
| 10977 | 2775 | |
| 2776 | /* concatenate all the text parts together */ | |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2777 | guchar *data; |
| 10977 | 2778 | gsize len; |
| 2779 | ||
| 15884 | 2780 | purple_mime_part_get_data_decoded(part, &data, &len); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2781 | g_string_append(str, (const char *)data); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2782 | g_free(data); |
| 10977 | 2783 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2784 | } |
| 10977 | 2785 | |
| 15884 | 2786 | purple_mime_document_free(doc); |
| 10977 | 2787 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2788 | /* @todo should put this in its own function */ |
| 10977 | 2789 | { /* replace each IMG tag's SRC attribute with an ID attribute. This |
| 2790 | actually modifies the contents of str */ | |
| 2791 | GData *attribs; | |
| 2792 | char *start, *end; | |
| 2793 | char *tmp = str->str; | |
| 2794 | ||
| 15884 | 2795 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 2796 | (const char **) &end, &attribs)) { |
| 2797 | ||
| 2798 | char *alt, *align, *border, *src; | |
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2799 | int img = 0; |
| 10977 | 2800 | |
| 2801 | alt = g_datalist_get_data(&attribs, "alt"); | |
| 2802 | align = g_datalist_get_data(&attribs, "align"); | |
| 2803 | border = g_datalist_get_data(&attribs, "border"); | |
| 2804 | src = g_datalist_get_data(&attribs, "src"); | |
| 2805 | ||
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2806 | if(src) |
|
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2807 | 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
|
2808 | |
| 10977 | 2809 | if(img) { |
| 2810 | GString *atstr; | |
| 2811 | gsize len = (end - start); | |
| 2812 | gsize mov; | |
| 2813 | ||
| 2814 | atstr = g_string_new(""); | |
| 2815 | if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt); | |
| 2816 | if(align) g_string_append_printf(atstr, " align=\"%s\"", align); | |
| 2817 | if(border) g_string_append_printf(atstr, " border=\"%s\"", border); | |
| 2818 | ||
| 2819 | mov = g_snprintf(start, len, "<img%s id=\"%i\"", atstr->str, img); | |
| 2820 | while(mov < len) start[mov++] = ' '; | |
| 2821 | ||
| 2822 | g_string_free(atstr, TRUE); | |
| 2823 | } | |
| 2824 | ||
| 2825 | g_datalist_clear(&attribs); | |
| 2826 | tmp = end + 1; | |
| 2827 | } | |
| 2828 | } | |
| 2829 | ||
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2830 | im_recv_html(conv, pd, str->str); |
| 10977 | 2831 | |
| 2832 | g_string_free(str, TRUE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2833 | |
| 10977 | 2834 | /* clean up the cid table */ |
| 2835 | g_hash_table_destroy(img_by_cid); | |
| 2836 | ||
| 2837 | /* dereference all the imgages */ | |
| 2838 | 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
|
2839 | purple_imgstore_unref_by_id(GPOINTER_TO_INT(images->data)); |
| 10977 | 2840 | images = g_list_delete_link(images, images); |
| 2841 | } | |
| 2842 | } | |
| 2843 | ||
| 2844 | ||
| 2845 | static void mw_conversation_recv(struct mwConversation *conv, | |
| 2846 | enum mwImSendType type, | |
| 2847 | gconstpointer msg) { | |
| 2848 | struct mwServiceIm *srvc; | |
| 2849 | struct mwSession *session; | |
| 15884 | 2850 | struct mwPurplePluginData *pd; |
| 10977 | 2851 | |
| 2852 | srvc = mwConversation_getService(conv); | |
| 2853 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2854 | pd = mwSession_getClientData(session); | |
| 2855 | ||
| 2856 | switch(type) { | |
| 2857 | case mwImSend_PLAIN: | |
| 2858 | im_recv_text(conv, pd, msg); | |
| 2859 | break; | |
| 2860 | ||
| 2861 | case mwImSend_TYPING: | |
| 2862 | im_recv_typing(conv, pd, !! msg); | |
| 2863 | break; | |
| 2864 | ||
| 2865 | case mwImSend_HTML: | |
| 2866 | im_recv_html(conv, pd, msg); | |
| 2867 | break; | |
| 2868 | ||
| 2869 | case mwImSend_SUBJECT: | |
| 2870 | im_recv_subj(conv, pd, msg); | |
| 2871 | break; | |
| 2872 | ||
| 2873 | case mwImSend_MIME: | |
| 2874 | im_recv_mime(conv, pd, msg); | |
| 2875 | break; | |
| 2876 | ||
| 2877 | default: | |
| 2878 | DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
| 2879 | ; /* erm... */ | |
| 2880 | } | |
| 2881 | } | |
| 2882 | ||
| 2883 | ||
| 2884 | static void mw_place_invite(struct mwConversation *conv, | |
| 2885 | const char *message, | |
| 2886 | const char *title, const char *name) { | |
| 2887 | struct mwServiceIm *srvc; | |
| 2888 | struct mwSession *session; | |
| 15884 | 2889 | struct mwPurplePluginData *pd; |
| 10977 | 2890 | |
| 2891 | struct mwIdBlock *idb; | |
| 2892 | GHashTable *ht; | |
| 2893 | ||
| 2894 | srvc = mwConversation_getService(conv); | |
| 2895 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2896 | pd = mwSession_getClientData(session); | |
| 2897 | ||
| 2898 | idb = mwConversation_getTarget(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2899 | |
| 10977 | 2900 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 2901 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
| 2902 | g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
| 2903 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
| 2904 | 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
|
2905 | g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
| 10977 | 2906 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2907 | if(! title) title = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2908 | if(! message) message = "(no message)"; |
| 10977 | 2909 | 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
|
2910 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2911 | mwConversation_close(conv, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2912 | mwConversation_free(conv); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2913 | } |
| 10977 | 2914 | |
| 2915 | ||
| 2916 | static void mw_im_clear(struct mwServiceIm *srvc) { | |
| 2917 | ; | |
| 2918 | } | |
| 2919 | ||
| 2920 | ||
| 2921 | static struct mwImHandler mw_im_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2922 | mw_conversation_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2923 | mw_conversation_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2924 | mw_conversation_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2925 | mw_place_invite, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2926 | mw_im_clear, |
| 10977 | 2927 | }; |
| 2928 | ||
| 2929 | ||
| 2930 | static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
| 2931 | struct mwServiceIm *srvc; | |
| 2932 | srvc = mwServiceIm_new(s, &mw_im_handler); | |
| 2933 | mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
| 2934 | return srvc; | |
| 2935 | } | |
| 2936 | ||
| 2937 | ||
| 15884 | 2938 | /* The following helps us relate a mwPlace to a PurpleConvChat in the |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2939 | 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
|
2940 | the similar macros from the conference service above */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2941 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2942 | #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2943 | #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
|
2944 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2945 | #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
|
2946 | #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
|
2947 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2948 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2949 | static struct mwPlace * |
| 15884 | 2950 | place_find_by_id(struct mwPurplePluginData *pd, int id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2951 | struct mwServicePlace *srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2952 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2953 | GList *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2954 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2955 | l = (GList *) mwServicePlace_getPlaces(srvc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2956 | for(; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2957 | struct mwPlace *p = l->data; |
| 15884 | 2958 | PurpleConvChat *h = PURPLE_CONV_CHAT(mwPlace_getClientData(p)); |
|
11943
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 | if(CHAT_TO_ID(h) == id) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2961 | place = p; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2962 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2963 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2964 | } |
|
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 | return place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2967 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2968 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2969 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2970 | static void mw_place_opened(struct mwPlace *place) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2971 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2972 | struct mwSession *session; |
| 15884 | 2973 | struct mwPurplePluginData *pd; |
| 2974 | PurpleConnection *gc; | |
| 2975 | PurpleConversation *gconf; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2976 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2977 | GList *members, *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2978 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2979 | const char *n = mwPlace_getName(place); |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2980 | const char *t = mwPlace_getTitle(place); |
|
11943
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 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2983 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2984 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2985 | gc = pd->gc; |
|
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 | members = mwPlace_getMembers(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2988 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2989 | DEBUG_INFO("place %s opened, %u initial members\n", |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2990 | NSTR(n), g_list_length(members)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2991 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2992 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2993 | 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
|
2994 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2995 | mwPlace_setClientData(place, gconf, NULL); |
|
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 | for(l = members; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2998 | struct mwIdBlock *idb = l->data; |
| 15884 | 2999 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(gconf), idb->user, |
| 3000 | NULL, PURPLE_CBFLAGS_NONE, FALSE); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3001 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3002 | g_list_free(members); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3003 | } |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3006 | static void mw_place_closed(struct mwPlace *place, guint32 code) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3007 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3008 | struct mwSession *session; |
| 15884 | 3009 | struct mwPurplePluginData *pd; |
| 3010 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3011 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3012 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3013 | char *msg = mwError(code); |
|
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 | 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
|
3016 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3017 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3018 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3019 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3020 | gc = pd->gc; |
|
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 | serv_got_chat_left(gc, PLACE_TO_ID(place)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3023 | |
| 15884 | 3024 | purple_notify_error(gc, _("Place Closed"), NULL, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3025 | g_free(msg); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3026 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3027 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3028 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3029 | static void mw_place_peerJoined(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3030 | const struct mwIdBlock *peer) { |
| 15884 | 3031 | PurpleConversation *gconf; |
|
11943
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 | const char *n = mwPlace_getName(place); |
|
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 | 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
|
3036 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3037 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3038 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3039 | |
| 15884 | 3040 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(gconf), peer->user, |
| 3041 | NULL, PURPLE_CBFLAGS_NONE, TRUE); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3042 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3043 | |
|
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 | static void mw_place_peerParted(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3046 | const struct mwIdBlock *peer) { |
| 15884 | 3047 | PurpleConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3048 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3049 | const char *n = mwPlace_getName(place); |
|
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 | 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
|
3052 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3053 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3054 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3055 | |
| 15884 | 3056 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(gconf), peer->user, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3057 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3058 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3059 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3060 | static void mw_place_peerSetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3061 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3062 | guint32 attr, struct mwOpaque *o) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3063 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3064 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3065 | |
|
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 | static void mw_place_peerUnsetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3068 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3069 | guint32 attr) { |
|
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 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3072 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3073 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3074 | static void mw_place_message(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3075 | const struct mwIdBlock *who, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3076 | const char *msg) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3077 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3078 | struct mwSession *session; |
| 15884 | 3079 | struct mwPurplePluginData *pd; |
| 3080 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3081 | char *esc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3082 | |
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3083 | if(! msg) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3084 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3085 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3086 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3087 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3088 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3089 | |
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
3090 | esc = g_markup_escape_text(msg, -1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3091 | 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
|
3092 | g_free(esc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3093 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3094 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3095 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3096 | static void mw_place_clear(struct mwServicePlace *srvc) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3097 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3098 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3099 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3100 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3101 | static struct mwPlaceHandler mw_place_handler = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3102 | mw_place_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3103 | mw_place_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3104 | mw_place_peerJoined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3105 | mw_place_peerParted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3106 | mw_place_peerSetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3107 | mw_place_peerUnsetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3108 | mw_place_message, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3109 | mw_place_clear, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3110 | }; |
|
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 | static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3114 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3115 | srvc = mwServicePlace_new(s, &mw_place_handler); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3116 | return srvc; |
|
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 | |
| 10977 | 3120 | static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
| 3121 | struct mwServiceResolve *srvc; | |
| 3122 | srvc = mwServiceResolve_new(s); | |
| 3123 | return srvc; | |
| 3124 | } | |
| 3125 | ||
| 3126 | ||
| 3127 | static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
| 3128 | struct mwServiceStorage *srvc; | |
| 3129 | srvc = mwServiceStorage_new(s); | |
| 3130 | return srvc; | |
| 3131 | } | |
| 3132 | ||
| 3133 | ||
| 15884 | 3134 | /** allocate and associate a mwPurplePluginData with a PurpleConnection */ |
| 3135 | static struct mwPurplePluginData *mwPurplePluginData_new(PurpleConnection *gc) { | |
| 3136 | struct mwPurplePluginData *pd; | |
| 10977 | 3137 | |
| 3138 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3139 | ||
| 15884 | 3140 | pd = g_new0(struct mwPurplePluginData, 1); |
| 10977 | 3141 | pd->gc = gc; |
| 3142 | pd->session = mwSession_new(&mw_session_handler); | |
| 3143 | pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
| 3144 | pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
| 3145 | pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
| 3146 | pd->srvc_im = mw_srvc_im_new(pd->session); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3147 | pd->srvc_place = mw_srvc_place_new(pd->session); |
| 10977 | 3148 | pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
| 3149 | pd->srvc_store = mw_srvc_store_new(pd->session); | |
| 3150 | pd->group_list_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 15884 | 3151 | pd->sock_buf = purple_circ_buffer_new(0); |
| 10977 | 3152 | |
| 3153 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
| 3154 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
| 3155 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
| 3156 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3157 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
| 10977 | 3158 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
| 3159 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
| 3160 | ||
| 3161 | 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
|
3162 | mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 10977 | 3163 | |
| 3164 | mwSession_setClientData(pd->session, pd, NULL); | |
| 3165 | gc->proto_data = pd; | |
| 3166 | ||
| 3167 | return pd; | |
| 3168 | } | |
| 3169 | ||
| 3170 | ||
| 15884 | 3171 | static void mwPurplePluginData_free(struct mwPurplePluginData *pd) { |
| 10977 | 3172 | g_return_if_fail(pd != NULL); |
| 3173 | ||
| 3174 | pd->gc->proto_data = NULL; | |
| 3175 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3176 | mwSession_removeService(pd->session, mwService_AWARE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3177 | mwSession_removeService(pd->session, mwService_CONFERENCE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3178 | mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3179 | mwSession_removeService(pd->session, mwService_IM); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3180 | mwSession_removeService(pd->session, mwService_PLACE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3181 | mwSession_removeService(pd->session, mwService_RESOLVE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3182 | mwSession_removeService(pd->session, mwService_STORAGE); |
| 10977 | 3183 | |
| 3184 | mwService_free(MW_SERVICE(pd->srvc_aware)); | |
| 3185 | mwService_free(MW_SERVICE(pd->srvc_conf)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3186 | mwService_free(MW_SERVICE(pd->srvc_ft)); |
| 10977 | 3187 | mwService_free(MW_SERVICE(pd->srvc_im)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3188 | mwService_free(MW_SERVICE(pd->srvc_place)); |
| 10977 | 3189 | mwService_free(MW_SERVICE(pd->srvc_resolve)); |
| 3190 | mwService_free(MW_SERVICE(pd->srvc_store)); | |
| 3191 | ||
| 3192 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3193 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
| 10977 | 3194 | |
| 3195 | mwSession_free(pd->session); | |
| 3196 | ||
| 3197 | g_hash_table_destroy(pd->group_list_map); | |
| 15884 | 3198 | purple_circ_buffer_destroy(pd->sock_buf); |
| 10977 | 3199 | |
| 3200 | g_free(pd); | |
| 3201 | } | |
| 3202 | ||
| 3203 | ||
| 15884 | 3204 | static const char *mw_prpl_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
| 10977 | 3205 | /* my little green dude is a chopped up version of the aim running |
| 3206 | guy. First, cut off the head and store someplace safe. Then, | |
| 3207 | take the left-half side of the body and throw it away. Make a | |
| 3208 | copy of the remaining body, and flip it horizontally. Now attach | |
| 3209 | the two pieces into an X shape, and drop the head back on the | |
| 3210 | top, being careful to center it. Then, just change the color | |
| 3211 | saturation to bring the red down a bit, and voila! */ | |
| 3212 | ||
| 3213 | /* then, throw all of that away and use sodipodi to make a new | |
| 3214 | icon. You know, LIKE A REAL MAN. */ | |
| 3215 | ||
| 3216 | return "meanwhile"; | |
| 3217 | } | |
| 3218 | ||
| 3219 | ||
| 15884 | 3220 | static const char* mw_prpl_list_emblem(PurpleBuddy *b) |
| 15524 | 3221 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3222 | if(buddy_is_external(b)) |
| 15524 | 3223 | return "external"; |
| 3224 | ||
| 3225 | return NULL; | |
| 10977 | 3226 | } |
| 3227 | ||
| 3228 | ||
| 15884 | 3229 | static char *mw_prpl_status_text(PurpleBuddy *b) { |
| 3230 | PurpleConnection *gc; | |
| 3231 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3232 | 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
|
3233 | 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
|
3234 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3235 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
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
|
3236 | && (pd = gc->proto_data)) |
|
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
|
3237 | 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
|
3238 | |
|
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
|
3239 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3240 | } |
| 3241 | ||
| 3242 | ||
| 15884 | 3243 | static const char *status_text(PurpleBuddy *b) { |
| 3244 | PurplePresence *presence; | |
| 3245 | PurpleStatus *status; | |
| 3246 | ||
| 3247 | presence = purple_buddy_get_presence(b); | |
| 3248 | status = purple_presence_get_active_status(presence); | |
| 3249 | ||
| 3250 | return purple_status_get_name(status); | |
| 10977 | 3251 | } |
| 3252 | ||
| 3253 | ||
| 3254 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3255 | const char *who, guint32 feature) { | |
| 3256 | ||
| 3257 | const struct mwAwareAttribute *attr; | |
| 3258 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3259 | ||
| 3260 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3261 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3262 | } | |
| 3263 | ||
| 3264 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3265 | 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
|
3266 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3267 | const char **f = feat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3268 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3269 | if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3270 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3271 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3272 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3273 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3274 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3275 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3276 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3277 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3278 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3279 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3280 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3281 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3282 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3283 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3284 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3285 | /* jenni loves siege */ |
| 10977 | 3286 | } |
| 3287 | ||
| 3288 | ||
| 15884 | 3289 | static void mw_prpl_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { |
| 3290 | PurpleConnection *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
|
3291 | struct mwPurplePluginData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3292 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3293 | |
|
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
|
3294 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3295 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3296 | char *tmp; |
| 10977 | 3297 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3298 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
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
|
3299 | && (pd = gc->proto_data)) |
|
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
|
3300 | 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
|
3301 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3302 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3303 | |
|
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
|
3304 | if(message != NULL && g_utf8_validate(message, -1, NULL) && purple_utf8_strcasecmp(status, message)) { |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3305 | tmp = g_markup_escape_text(message, -1); |
| 15884 | 3306 | purple_notify_user_info_add_pair(user_info, status, tmp); |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3307 | g_free(tmp); |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3308 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3309 | } else { |
| 15884 | 3310 | purple_notify_user_info_add_pair(user_info, _("Status"), status); |
| 10977 | 3311 | } |
| 3312 | ||
|
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
|
3313 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3314 | 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
|
3315 | if(tmp) { |
| 15884 | 3316 | purple_notify_user_info_add_pair(user_info, _("Supports"), tmp); |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3317 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3318 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3319 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3320 | if(buddy_is_external(b)) { |
| 15884 | 3321 | purple_notify_user_info_add_pair(user_info, NULL, _("External User")); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3322 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3323 | } |
| 10977 | 3324 | } |
| 3325 | ||
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3326 | static GList *mw_prpl_status_types(PurpleAccount *acct) |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3327 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3328 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3329 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3330 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3331 | 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
|
3332 | MW_STATE_ACTIVE, NULL, TRUE, TRUE, FALSE, |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3333 | MW_STATE_MESSAGE, _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3334 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3335 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3336 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3337 | 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
|
3338 | MW_STATE_AWAY, NULL, TRUE, TRUE, FALSE, |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3339 | MW_STATE_MESSAGE, _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3340 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3341 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3342 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3343 | 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
|
3344 | MW_STATE_BUSY, _("Do Not Disturb"), TRUE, TRUE, FALSE, |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3345 | MW_STATE_MESSAGE, _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3346 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3347 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3348 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3349 | 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
|
3350 | 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
|
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 | return types; |
| 10977 | 3354 | } |
| 3355 | ||
| 3356 | ||
| 15884 | 3357 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3358 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3359 | ; /* nothing to do */ |
| 10977 | 3360 | } |
| 3361 | ||
| 3362 | ||
| 15884 | 3363 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3364 | PurpleRequestFields *fields) { | |
| 3365 | PurpleAccount *acct; | |
| 3366 | PurpleConnection *gc; | |
| 3367 | struct mwPurplePluginData *pd; | |
| 10977 | 3368 | struct mwServiceConference *srvc; |
| 3369 | ||
| 15884 | 3370 | PurpleRequestField *f; |
| 10977 | 3371 | |
| 3372 | const char *topic, *invite; | |
| 3373 | struct mwConference *conf; | |
| 3374 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3375 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3376 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3377 | gc = purple_account_get_connection(acct); |
| 10977 | 3378 | pd = gc->proto_data; |
| 3379 | srvc = pd->srvc_conf; | |
| 3380 | ||
| 15884 | 3381 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3382 | topic = purple_request_field_string_get_value(f); | |
| 3383 | ||
| 3384 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3385 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3386 | |
| 3387 | conf = mwConference_new(srvc, topic); | |
| 3388 | mwConference_open(conf); | |
| 3389 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3390 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3391 | mwConference_invite(conf, &idb, invite); |
| 3392 | } | |
| 3393 | ||
| 3394 | ||
| 15884 | 3395 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3396 | ||
| 3397 | PurpleRequestFields *fields; | |
| 3398 | PurpleRequestFieldGroup *g; | |
| 3399 | PurpleRequestField *f; | |
| 3400 | ||
| 3401 | PurpleAccount *acct; | |
| 3402 | PurpleConnection *gc; | |
| 10977 | 3403 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3404 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3405 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3406 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3407 | |
| 10977 | 3408 | g_return_if_fail(buddy != NULL); |
| 3409 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3410 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3411 | g_return_if_fail(acct != NULL); |
| 3412 | ||
| 15884 | 3413 | gc = purple_account_get_connection(acct); |
| 10977 | 3414 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3415 | |
| 15884 | 3416 | fields = purple_request_fields_new(); |
| 3417 | ||
| 3418 | g = purple_request_field_group_new(NULL); | |
| 3419 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3420 | |
| 15884 | 3421 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3422 | purple_request_field_group_add_field(g, f); | |
| 3423 | ||
| 3424 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3425 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3426 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3427 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3428 | 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
|
3429 | " 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
|
3430 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3431 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3432 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3433 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3434 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3435 | _("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
|
3436 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3437 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3438 | g_free(msg1); |
| 10977 | 3439 | } |
| 3440 | ||
| 3441 | ||
| 15884 | 3442 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3443 | PurpleRequestFields *fields) { | |
| 10977 | 3444 | ; |
| 3445 | } | |
| 3446 | ||
| 3447 | ||
| 15884 | 3448 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3449 | PurpleRequestFields *fields) { | |
| 3450 | 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
|
3451 | GList *l; |
| 10977 | 3452 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3453 | |
| 15884 | 3454 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3455 | msg = purple_request_field_string_get_value(f); | |
| 3456 | ||
| 3457 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3458 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3459 | |
| 3460 | if(l) { | |
| 15884 | 3461 | 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
|
3462 | |
| 10977 | 3463 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3464 | blist_menu_conf_create(buddy, msg); | |
| 3465 | ||
| 3466 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3467 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3468 | mwConference_invite(d, &idb, msg); |
| 3469 | } | |
| 3470 | } | |
| 3471 | } | |
| 3472 | ||
| 3473 | ||
| 15884 | 3474 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3475 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3476 | |
| 15884 | 3477 | PurpleRequestFields *fields; |
| 3478 | PurpleRequestFieldGroup *g; | |
| 3479 | PurpleRequestField *f; | |
| 3480 | ||
| 3481 | PurpleAccount *acct; | |
| 3482 | PurpleConnection *gc; | |
| 10977 | 3483 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3484 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3485 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3486 | char *msg; |
| 10977 | 3487 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3488 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3489 | g_return_if_fail(acct != NULL); |
| 3490 | ||
| 15884 | 3491 | gc = purple_account_get_connection(acct); |
| 10977 | 3492 | g_return_if_fail(gc != NULL); |
| 3493 | ||
| 15884 | 3494 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3495 | |
| 15884 | 3496 | g = purple_request_field_group_new(NULL); |
| 3497 | purple_request_fields_add_group(fields, g); | |
| 3498 | ||
| 3499 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3500 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3501 | for(; confs; confs = confs->next) { |
| 3502 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3503 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3504 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3505 | 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
|
3506 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3507 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3508 | |
| 15884 | 3509 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3510 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3511 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3512 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3513 | 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
|
3514 | " 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
|
3515 | " 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
|
3516 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3517 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3518 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3519 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3520 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3521 | _("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
|
3522 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3523 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3524 | g_free(msg); |
| 10977 | 3525 | } |
| 3526 | ||
| 3527 | ||
| 15884 | 3528 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 3529 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3530 | PurpleAccount *acct; | |
| 3531 | PurpleConnection *gc; | |
| 3532 | struct mwPurplePluginData *pd; | |
| 10977 | 3533 | GList *l; |
| 3534 | ||
| 3535 | g_return_if_fail(node != NULL); | |
| 15884 | 3536 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 10977 | 3537 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3538 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3539 | g_return_if_fail(acct != NULL); |
| 3540 | ||
| 15884 | 3541 | gc = purple_account_get_connection(acct); |
| 10977 | 3542 | g_return_if_fail(gc != NULL); |
| 3543 | ||
| 3544 | pd = gc->proto_data; | |
| 3545 | g_return_if_fail(pd != NULL); | |
| 3546 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3547 | /* |
| 10977 | 3548 | - get a list of all conferences on this session |
| 3549 | - if none, prompt to create one, and invite buddy to it | |
| 3550 | - else, prompt to select a conference or create one | |
| 3551 | */ | |
| 3552 | ||
| 3553 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3554 | if(l) { | |
| 3555 | blist_menu_conf_list(buddy, l); | |
| 3556 | g_list_free(l); | |
| 3557 | ||
| 3558 | } else { | |
| 3559 | blist_menu_conf_create(buddy, NULL); | |
| 3560 | } | |
| 3561 | } | |
| 3562 | ||
| 3563 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3564 | #if 0 |
| 15884 | 3565 | static void blist_menu_announce(PurpleBlistNode *node, gpointer data) { |
| 3566 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3567 | PurpleAccount *acct; | |
| 3568 | PurpleConnection *gc; | |
| 3569 | struct mwPurplePluginData *pd; | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3570 | struct mwSession *session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3571 | char *rcpt_name; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3572 | GList *rcpt; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3573 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3574 | g_return_if_fail(node != NULL); |
| 15884 | 3575 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3576 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3577 | acct = buddy->account; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3578 | g_return_if_fail(acct != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3579 | |
| 15884 | 3580 | gc = purple_account_get_connection(acct); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3581 | g_return_if_fail(gc != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3582 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3583 | pd = gc->proto_data; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3584 | g_return_if_fail(pd != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3585 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3586 | rcpt_name = g_strdup_printf("@U %s", buddy->name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3587 | rcpt = g_list_prepend(NULL, rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3588 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3589 | session = pd->session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3590 | mwSession_sendAnnounce(session, FALSE, |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3591 | "This is a TEST announcement. Please ignore.", |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3592 | rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3593 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3594 | g_list_free(rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3595 | g_free(rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3596 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3597 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3598 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3599 | |
| 15884 | 3600 | static GList *mw_prpl_blist_node_menu(PurpleBlistNode *node) { |
| 10977 | 3601 | GList *l = NULL; |
| 15884 | 3602 | PurpleMenuAction *act; |
| 3603 | ||
| 3604 | if(! PURPLE_BLIST_NODE_IS_BUDDY(node)) | |
| 10977 | 3605 | return l; |
| 3606 | ||
| 3607 | l = g_list_append(l, NULL); | |
| 3608 | ||
| 15884 | 3609 | act = purple_menu_action_new(_("Invite to Conference..."), |
| 3610 | PURPLE_CALLBACK(blist_menu_conf), NULL, NULL); | |
| 10977 | 3611 | l = g_list_append(l, act); |
| 3612 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3613 | #if 0 |
| 15884 | 3614 | act = purple_menu_action_new(_("Send TEST Announcement"), |
| 3615 | PURPLE_CALLBACK(blist_menu_announce), NULL, NULL); | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3616 | l = g_list_append(l, act); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3617 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3618 | |
| 15884 | 3619 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3620 | blist-node-extended-menu signal for that. The function |
| 3621 | blist_node_menu_cb is assigned to this signal in the function | |
| 3622 | services_starting */ | |
| 3623 | ||
| 3624 | return l; | |
| 3625 | } | |
| 3626 | ||
| 3627 | ||
| 15884 | 3628 | static GList *mw_prpl_chat_info(PurpleConnection *gc) { |
| 10977 | 3629 | GList *l = NULL; |
| 3630 | struct proto_chat_entry *pce; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3631 | |
| 10977 | 3632 | pce = g_new0(struct proto_chat_entry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3633 | pce->label = _("Topic:"); |
| 10977 | 3634 | pce->identifier = CHAT_KEY_TOPIC; |
| 3635 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3636 | |
| 10977 | 3637 | return l; |
| 3638 | } | |
| 3639 | ||
| 3640 | ||
| 15884 | 3641 | static GHashTable *mw_prpl_chat_info_defaults(PurpleConnection *gc, |
| 10977 | 3642 | const char *name) { |
| 3643 | GHashTable *table; | |
| 3644 | ||
| 3645 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3646 | ||
| 3647 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3648 | NULL, g_free); | |
| 3649 | ||
| 3650 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3651 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3652 | ||
| 3653 | return table; | |
| 3654 | } | |
| 3655 | ||
| 3656 | ||
| 15884 | 3657 | static void mw_prpl_login(PurpleAccount *acct); |
| 3658 | ||
| 3659 | ||
| 3660 | static void mw_prpl_login(PurpleAccount *account) { | |
| 3661 | PurpleConnection *gc; | |
| 3662 | struct mwPurplePluginData *pd; | |
| 10977 | 3663 | |
| 3664 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3665 | guint port; |
| 10977 | 3666 | |
| 15884 | 3667 | gc = purple_account_get_connection(account); |
| 3668 | pd = mwPurplePluginData_new(gc); | |
| 10977 | 3669 | |
| 3670 | /* while we do support images, the default is to not offer it */ | |
| 15884 | 3671 | gc->flags |= PURPLE_CONNECTION_NO_IMAGES; |
| 3672 | ||
| 3673 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3674 | |
| 3675 | host = strrchr(user, ':'); | |
| 3676 | if(host) { | |
| 3677 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3678 | *host++ = '\0'; | |
| 15884 | 3679 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3680 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3681 | |
| 10977 | 3682 | } else { |
| 15884 | 3683 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3684 | MW_PLUGIN_DEFAULT_HOST); |
| 3685 | } | |
| 3686 | ||
| 3687 | if(! host || ! *host) { | |
| 3688 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3689 | 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
|
3690 | g_free(user); |
|
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
|
3691 | purple_connection_error_reason(gc, |
|
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
|
3692 | 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
|
3693 | _("A server is required to connect this account")); |
| 10977 | 3694 | return; |
| 3695 | } | |
| 3696 | ||
|
25292
5b4e719c5bbb
Fix a potential leak "KuSh" discovered using "cppcheck". Fixes #7862.
Daniel Atallah <datallah@pidgin.im>
parents:
25181
diff
changeset
|
3697 | pass = g_strdup(purple_account_get_password(account)); |
| 15884 | 3698 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3699 | |
| 3700 | DEBUG_INFO("user: '%s'\n", user); | |
| 3701 | DEBUG_INFO("host: '%s'\n", host); | |
| 3702 | DEBUG_INFO("port: %u\n", port); | |
| 3703 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3704 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3705 | (char *) no_secret, NULL); |
| 3706 | 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
|
3707 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3708 | |
| 15884 | 3709 | 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
|
3710 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3711 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3712 | /* 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
|
3713 | 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
|
3714 | |
| 15884 | 3715 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3716 | 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
|
3717 | 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
|
3718 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3719 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3720 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3721 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3722 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3723 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3724 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3725 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3726 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3727 | GUINT_TO_POINTER(major), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3728 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3729 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3730 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3731 | } |
| 10977 | 3732 | |
| 15884 | 3733 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3734 | ||
| 3735 | if (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL) { | |
| 21279 | 3736 | purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
3737 | _("Unable to connect")); |
| 10977 | 3738 | } |
| 3739 | } | |
| 3740 | ||
| 3741 | ||
| 15884 | 3742 | static void mw_prpl_close(PurpleConnection *gc) { |
| 3743 | struct mwPurplePluginData *pd; | |
| 10977 | 3744 | |
| 3745 | g_return_if_fail(gc != NULL); | |
| 3746 | ||
| 3747 | pd = gc->proto_data; | |
| 3748 | g_return_if_fail(pd != NULL); | |
| 3749 | ||
| 3750 | /* get rid of the blist save timeout */ | |
| 3751 | if(pd->save_event) { | |
| 15884 | 3752 | purple_timeout_remove(pd->save_event); |
| 10977 | 3753 | pd->save_event = 0; |
| 3754 | blist_store(pd); | |
| 3755 | } | |
| 3756 | ||
| 3757 | /* stop the session */ | |
| 3758 | mwSession_stop(pd->session, 0x00); | |
| 3759 | ||
| 3760 | /* no longer necessary */ | |
| 3761 | gc->proto_data = NULL; | |
| 3762 | ||
| 3763 | /* stop watching the socket */ | |
| 3764 | if(gc->inpa) { | |
| 15884 | 3765 | purple_input_remove(gc->inpa); |
| 10977 | 3766 | gc->inpa = 0; |
| 3767 | } | |
| 3768 | ||
| 3769 | /* clean up the rest */ | |
| 15884 | 3770 | mwPurplePluginData_free(pd); |
| 10977 | 3771 | } |
| 3772 | ||
| 3773 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21947
diff
changeset
|
3774 | static int mw_rand(void) { |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3775 | static int seed = 0; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3776 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3777 | /* for diversity, not security. don't touch */ |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3778 | srand(time(NULL) ^ seed); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3779 | seed = rand(); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3780 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3781 | return seed; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3782 | } |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3783 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3784 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3785 | /** 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
|
3786 | static char *im_mime_content_id(void) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3787 | return g_strdup_printf("%03x@%05xmeanwhile", |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3788 | mw_rand() & 0xfff, mw_rand() & 0xfffff); |
| 10977 | 3789 | } |
| 3790 | ||
| 3791 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3792 | /** generates a multipart/related content type with a random-ish |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3793 | 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
|
3794 | static char *im_mime_content_type(void) { |
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3795 | 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
|
3796 | mw_rand() & 0xfff, mw_rand() & 0xffff); |
| 10977 | 3797 | } |
| 3798 | ||
| 3799 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3800 | /** determine content type from extension. Not so happy about this, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3801 | but I don't want to actually write image type detection */ |
| 15884 | 3802 | static char *im_mime_img_content_type(PurpleStoredImage *img) { |
| 3803 | const char *fn = purple_imgstore_get_filename(img); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3804 | const char *ct = NULL; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3805 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3806 | ct = strrchr(fn, '.'); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3807 | if(! ct) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3808 | ct = "image"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3809 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3810 | } else if(purple_strequal(".png", ct)) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3811 | ct = "image/png"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3812 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3813 | } else if(purple_strequal(".jpg", ct)) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3814 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3815 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3816 | } else if(purple_strequal(".jpeg", ct)) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3817 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3818 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3819 | } else if(purple_strequal(".gif", ct)) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3820 | ct = "image/gif"; |
| 10977 | 3821 | |
| 3822 | } else { | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3823 | ct = "image"; |
| 10977 | 3824 | } |
|
12105
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 | return g_strdup_printf("%s; name=\"%s\"", ct, fn); |
| 10977 | 3827 | } |
| 3828 | ||
| 3829 | ||
| 15884 | 3830 | static char *im_mime_img_content_disp(PurpleStoredImage *img) { |
| 3831 | const char *fn = purple_imgstore_get_filename(img); | |
| 10977 | 3832 | return g_strdup_printf("attachment; filename=\"%s\"", fn); |
| 3833 | } | |
| 3834 | ||
| 3835 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3836 | /** turn an IM with embedded images into a multi-part mime document */ |
| 15884 | 3837 | static char *im_mime_convert(PurpleConnection *gc, |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3838 | struct mwConversation *conv, |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3839 | const char *message) { |
| 10977 | 3840 | GString *str; |
| 15884 | 3841 | PurpleMimeDocument *doc; |
| 3842 | PurpleMimePart *part; | |
| 10977 | 3843 | |
| 3844 | GData *attr; | |
| 3845 | char *tmp, *start, *end; | |
| 3846 | ||
| 3847 | str = g_string_new(NULL); | |
| 3848 | ||
| 15884 | 3849 | doc = purple_mime_document_new(); |
| 3850 | ||
| 3851 | purple_mime_document_set_field(doc, "Mime-Version", "1.0"); | |
| 3852 | purple_mime_document_set_field(doc, "Content-Disposition", "inline"); | |
| 10977 | 3853 | |
| 3854 | tmp = im_mime_content_type(); | |
| 15884 | 3855 | purple_mime_document_set_field(doc, "Content-Type", tmp); |
| 10977 | 3856 | g_free(tmp); |
| 3857 | ||
| 3858 | tmp = (char *) message; | |
| 15884 | 3859 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 3860 | (const char **) &end, &attr)) { |
| 3861 | char *id; | |
| 15884 | 3862 | PurpleStoredImage *img = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3863 | |
| 10977 | 3864 | gsize len = (start - tmp); |
| 3865 | ||
| 3866 | /* append the in-between-tags text */ | |
| 3867 | if(len) g_string_append_len(str, tmp, len); | |
| 3868 | ||
| 3869 | /* find the imgstore data by the id tag */ | |
| 3870 | id = g_datalist_get_data(&attr, "id"); | |
| 3871 | 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
|
3872 | img = purple_imgstore_find_by_id(atoi(id)); |
| 10977 | 3873 | |
| 3874 | if(img) { | |
| 3875 | char *cid; | |
| 3876 | gpointer data; | |
| 3877 | size_t size; | |
| 3878 | ||
| 15884 | 3879 | part = purple_mime_part_new(doc); |
| 10977 | 3880 | |
| 3881 | data = im_mime_img_content_disp(img); | |
| 15884 | 3882 | purple_mime_part_set_field(part, "Content-Disposition", data); |
| 10977 | 3883 | g_free(data); |
| 3884 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3885 | data = im_mime_img_content_type(img); |
| 15884 | 3886 | purple_mime_part_set_field(part, "Content-Type", data); |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3887 | g_free(data); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3888 | |
| 10977 | 3889 | cid = im_mime_content_id(); |
| 3890 | data = g_strdup_printf("<%s>", cid); | |
| 15884 | 3891 | purple_mime_part_set_field(part, "Content-ID", data); |
| 10977 | 3892 | g_free(data); |
| 3893 | ||
| 15884 | 3894 | purple_mime_part_set_field(part, "Content-transfer-encoding", "base64"); |
| 10977 | 3895 | |
| 3896 | /* obtain and base64 encode the image data, and put it in the | |
| 3897 | mime part */ | |
| 15884 | 3898 | 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
|
3899 | data = purple_base64_encode(purple_imgstore_get_data(img), (gsize) size); |
| 15884 | 3900 | purple_mime_part_set_data(part, data); |
| 10977 | 3901 | g_free(data); |
| 3902 | ||
| 3903 | /* append the modified tag */ | |
| 3904 | g_string_append_printf(str, "<img src=\"cid:%s\">", cid); | |
| 3905 | g_free(cid); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3906 | |
| 10977 | 3907 | } else { |
| 3908 | /* append the literal image tag, since we couldn't find a | |
| 3909 | relative imgstore object */ | |
| 3910 | gsize len = (end - start) + 1; | |
| 3911 | g_string_append_len(str, start, len); | |
| 3912 | } | |
| 3913 | ||
| 3914 | g_datalist_clear(&attr); | |
| 3915 | tmp = end + 1; | |
| 3916 | } | |
| 3917 | ||
| 3918 | /* append left-overs */ | |
| 3919 | g_string_append(str, tmp); | |
| 3920 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3921 | /* add the text/html part */ |
| 15884 | 3922 | part = purple_mime_part_new(doc); |
| 3923 | purple_mime_part_set_field(part, "Content-Disposition", "inline"); | |
| 3924 | ||
| 3925 | tmp = purple_utf8_ncr_encode(str->str); | |
| 3926 | purple_mime_part_set_field(part, "Content-Type", "text/html"); | |
| 3927 | purple_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); | |
| 3928 | purple_mime_part_set_data(part, tmp); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3929 | g_free(tmp); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3930 | |
| 10977 | 3931 | g_string_free(str, TRUE); |
| 3932 | ||
| 3933 | str = g_string_new(NULL); | |
| 15884 | 3934 | purple_mime_document_write(doc, str); |
|
42954
a98ee2d89a0a
Use the result of g_string_free(..., FALSE)
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40427
diff
changeset
|
3935 | return g_string_free(str, FALSE); |
| 10977 | 3936 | } |
| 3937 | ||
| 3938 | ||
| 15884 | 3939 | static int mw_prpl_send_im(PurpleConnection *gc, |
| 10977 | 3940 | const char *name, |
| 3941 | const char *message, | |
| 15884 | 3942 | PurpleMessageFlags flags) { |
| 3943 | ||
| 3944 | struct mwPurplePluginData *pd; | |
| 10977 | 3945 | struct mwIdBlock who = { (char *) name, NULL }; |
| 3946 | struct mwConversation *conv; | |
| 3947 | ||
| 3948 | g_return_val_if_fail(gc != NULL, 0); | |
| 3949 | pd = gc->proto_data; | |
| 3950 | ||
| 3951 | g_return_val_if_fail(pd != NULL, 0); | |
| 3952 | ||
| 3953 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 3954 | ||
| 3955 | /* this detection of features to determine how to send the message | |
| 3956 | (plain, html, or mime) is flawed because the other end of the | |
| 3957 | conversation could close their channel at any time, rendering any | |
| 3958 | existing formatting in an outgoing message innapropriate. The end | |
| 3959 | result is that it may be possible that the other side of the | |
| 3960 | conversation will receive a plaintext message with html contents, | |
| 3961 | which is bad. I'm not sure how to fix this correctly. */ | |
| 3962 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3963 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 3964 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 3965 | |
| 3966 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3967 | char *tmp; |
| 10977 | 3968 | int ret; |
| 3969 | ||
| 15884 | 3970 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 3971 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3972 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3973 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3974 | tmp = im_mime_convert(gc, conv, message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3975 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3976 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3977 | |
| 10977 | 3978 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3979 | /* send an HTML message */ |
| 10977 | 3980 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3981 | char *ncr; |
| 15884 | 3982 | ncr = purple_utf8_ncr_encode(message); |
| 3983 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3984 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3985 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3986 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3987 | g_free(tmp); |
| 10977 | 3988 | |
| 3989 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3990 | /* default to text */ |
| 15884 | 3991 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
3992 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3993 | g_free(tmp); |
| 10977 | 3994 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3995 | |
| 10977 | 3996 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3997 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3998 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3999 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4000 | /* queue up the message safely as plain text */ |
| 15884 | 4001 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4002 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4003 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4004 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4005 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4006 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4007 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4008 | return 1; |
| 10977 | 4009 | } |
| 4010 | } | |
| 4011 | ||
| 4012 | ||
| 15884 | 4013 | static unsigned int mw_prpl_send_typing(PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4014 | const char *name, |
| 15884 | 4015 | PurpleTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4016 | |
| 15884 | 4017 | struct mwPurplePluginData *pd; |
| 10977 | 4018 | struct mwIdBlock who = { (char *) name, NULL }; |
| 4019 | struct mwConversation *conv; | |
| 4020 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
4021 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 4022 | |
| 4023 | g_return_val_if_fail(gc != NULL, 0); | |
| 4024 | pd = gc->proto_data; | |
| 4025 | ||
| 4026 | g_return_val_if_fail(pd != NULL, 0); | |
| 4027 | ||
| 4028 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 4029 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4030 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4031 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4032 | |
| 15884 | 4033 | } else if((state == PURPLE_TYPING) || (state == PURPLE_TYPED)) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4034 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4035 | 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
|
4036 | 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
|
4037 | |
| 10977 | 4038 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4039 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4040 | if(! mwConversation_isPending(conv)) { |
| 10977 | 4041 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4042 | } |
| 10977 | 4043 | } |
| 4044 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4045 | return 0; |
| 10977 | 4046 | } |
| 4047 | ||
| 4048 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4049 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4050 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4051 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4052 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4053 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4054 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4055 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4056 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4057 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4058 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4059 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4060 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4061 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4062 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4063 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4064 | return "Lotus Sametime Links"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4065 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4066 | case mwLogin_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4067 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4068 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4069 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4070 | return "Lotus Notes Client"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4071 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4072 | case mwLogin_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4073 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4074 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4075 | return "IBM Community Tools"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4076 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4077 | case mwLogin_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4078 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4079 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4080 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4081 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4082 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4083 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4084 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4085 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4086 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4087 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4088 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4089 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4090 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4091 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4092 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4093 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4094 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4095 | return "Trillian"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4096 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4097 | case mwLogin_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4098 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4099 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4100 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4101 | return NULL; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4102 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4103 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4104 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4105 | |
| 15884 | 4106 | static void mw_prpl_get_info(PurpleConnection *gc, const char *who) { |
| 10977 | 4107 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4108 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4109 | |
| 15884 | 4110 | struct mwPurplePluginData *pd; |
| 4111 | PurpleAccount *acct; | |
| 4112 | PurpleBuddy *b; | |
| 4113 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4114 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4115 | const char *tmp2; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4116 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4117 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4118 | g_return_if_fail(*who != '\0'); |
| 10977 | 4119 | |
| 4120 | pd = gc->proto_data; | |
| 4121 | ||
| 15884 | 4122 | acct = purple_connection_get_account(gc); |
| 4123 | b = purple_find_buddy(acct, who); | |
| 4124 | user_info = purple_notify_user_info_new(); | |
| 4125 | ||
| 4126 | if(purple_str_has_prefix(who, "@E ")) { | |
| 4127 | purple_notify_user_info_add_pair(user_info, _("External User"), NULL); | |
| 10977 | 4128 | } |
| 4129 | ||
| 15884 | 4130 | purple_notify_user_info_add_pair(user_info, _("User ID"), who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4131 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4132 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4133 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4134 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4135 | if(purple_buddy_get_server_alias(b)) { |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4136 | purple_notify_user_info_add_pair(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
|
4137 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4138 | |
| 15884 | 4139 | 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
|
4140 | if(type) { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4141 | tmp = g_strdup(mw_client_name(type)); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4142 | if (!tmp) |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4143 | tmp = g_strdup_printf(_("Unknown (0x%04x)<br>"), type); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4144 | |
| 15884 | 4145 | purple_notify_user_info_add_pair(user_info, _("Last Known Client"), tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4146 | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4147 | g_free(tmp); |
| 10977 | 4148 | } |
| 4149 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4150 | |
| 10977 | 4151 | tmp = user_supports_text(pd->srvc_aware, who); |
| 4152 | if(tmp) { | |
| 15884 | 4153 | purple_notify_user_info_add_pair(user_info, _("Supports"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4154 | g_free(tmp); |
| 10977 | 4155 | } |
| 4156 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4157 | if(b) { |
| 15884 | 4158 | purple_notify_user_info_add_pair(user_info, _("Status"), status_text(b)); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4159 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4160 | /* 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
|
4161 | 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
|
4162 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4163 | tmp = g_markup_escape_text(tmp2, -1); |
| 15884 | 4164 | purple_notify_user_info_add_section_break(user_info); |
| 4165 | purple_notify_user_info_add_pair(user_info, NULL, tmp); | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4166 | g_free(tmp); |
|
12496
788b20ccec91
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4167 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4168 | } |
| 10977 | 4169 | |
| 4170 | /* @todo emit a signal to allow a plugin to override the display of | |
| 4171 | this notification, so that it can create its own */ | |
| 4172 | ||
| 15884 | 4173 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 4174 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 4175 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4176 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4177 | |
| 15884 | 4178 | static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status) { |
| 4179 | PurpleConnection *gc; | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4180 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
4181 | char *message = NULL; |
| 10977 | 4182 | struct mwSession *session; |
| 4183 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4184 | |
| 10977 | 4185 | g_return_if_fail(acct != NULL); |
| 15884 | 4186 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4187 | |
| 15884 | 4188 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4189 | |
| 15884 | 4190 | 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
|
4191 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4192 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4193 | |
| 10977 | 4194 | session = gc_to_session(gc); |
| 4195 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4196 | |
| 10977 | 4197 | /* get a working copy of the current status */ |
| 4198 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4199 | |
| 10977 | 4200 | /* determine the state */ |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4201 | if(purple_strequal(state, MW_STATE_ACTIVE)) { |
| 10977 | 4202 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4203 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4204 | } else if(purple_strequal(state, MW_STATE_AWAY)) { |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4205 | stat.status = mwStatus_AWAY; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4206 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4207 | } else if(purple_strequal(state, MW_STATE_BUSY)) { |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4208 | stat.status = mwStatus_BUSY; |
| 10977 | 4209 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4210 | |
| 10977 | 4211 | /* determine the message */ |
| 15884 | 4212 | 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
|
4213 | |
| 10977 | 4214 | if(message) { |
| 4215 | /* all the possible non-NULL values of message up to this point | |
| 4216 | are const, so we don't need to free them */ | |
| 15884 | 4217 | message = purple_markup_strip_html(message); |
| 10977 | 4218 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4219 | |
| 10977 | 4220 | /* out with the old */ |
| 4221 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4222 | |
| 10977 | 4223 | /* in with the new */ |
| 4224 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4225 | |
| 10977 | 4226 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4227 | mwUserStatus_clear(&stat); |
| 10977 | 4228 | } |
| 4229 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4230 | |
| 15884 | 4231 | static void mw_prpl_set_idle(PurpleConnection *gc, int t) { |
| 10977 | 4232 | struct mwSession *session; |
| 4233 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4234 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4235 | |
| 10977 | 4236 | session = gc_to_session(gc); |
| 4237 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4238 | |
| 10977 | 4239 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4240 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4241 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4242 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4243 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4244 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4245 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4246 | stat.time = 0; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4247 | } |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4248 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4249 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4250 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4251 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4252 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4253 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4254 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4255 | stat.status = mwStatus_ACTIVE; |
| 4256 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4257 | |
| 10977 | 4258 | mwSession_setUserStatus(session, &stat); |
| 4259 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4260 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4261 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4262 | |
| 15884 | 4263 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4264 | PurpleAccount *acct; | |
| 4265 | PurpleConversation *conv; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4266 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4267 | |
| 15884 | 4268 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4269 | id = g_list_nth_data(row, 1); |
| 15884 | 4270 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, id, acct); |
| 4271 | if(! conv) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, id); | |
| 4272 | purple_conversation_present(conv); | |
| 4273 | } | |
| 4274 | ||
| 4275 | ||
| 4276 | 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
|
4277 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4278 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4279 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4280 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4281 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4282 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4283 | |
| 15884 | 4284 | 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
|
4285 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4286 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4287 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4288 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4289 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4290 | static void notify_close(gpointer data) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4291 | if (data) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4292 | g_free(data); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4293 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4294 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4295 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4296 | |
| 10977 | 4297 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4298 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4299 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4300 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4301 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4302 | char *msg; |
| 10977 | 4303 | |
| 15884 | 4304 | PurpleNotifySearchResults *sres; |
| 4305 | PurpleNotifySearchColumn *scol; | |
| 4306 | ||
| 4307 | sres = purple_notify_searchresults_new(); | |
| 4308 | ||
| 4309 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4310 | purple_notify_searchresults_column_add(sres, scol); | |
| 4311 | ||
| 4312 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4313 | purple_notify_searchresults_column_add(sres, scol); | |
| 4314 | ||
| 4315 | 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
|
4316 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4317 | |
| 15884 | 4318 | 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
|
4319 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4320 | |
| 10977 | 4321 | for(l = result->matches; l; l = l->next) { |
| 4322 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4323 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4324 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4325 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4326 | NSTR(match->id), NSTR(match->name)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4327 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4328 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4329 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4330 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4331 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4332 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4333 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4334 | } |
| 10977 | 4335 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4336 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4337 | 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
|
4338 | " 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
|
4339 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4340 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4341 | |
| 15884 | 4342 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4343 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4344 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4345 | g_free(msg); |
| 10977 | 4346 | } |
| 4347 | ||
| 4348 | ||
| 4349 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4350 | guint32 id, guint32 code, GList *results, | |
| 4351 | gpointer b) { | |
| 4352 | ||
| 4353 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4354 | BuddyAddData *data = b; |
| 15884 | 4355 | PurpleBuddy *buddy = NULL; |
| 4356 | PurpleConnection *gc; | |
| 4357 | struct mwPurplePluginData *pd; | |
| 10977 | 4358 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4359 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4360 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4361 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4362 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4363 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
| 10977 | 4364 | pd = gc->proto_data; |
| 4365 | ||
| 4366 | if(results) | |
| 4367 | res = results->data; | |
| 4368 | ||
| 4369 | 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
|
4370 | if(!res->matches->next) { |
| 10977 | 4371 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4372 | |
| 10977 | 4373 | /* only one? that might be the right one! */ |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4374 | if(!purple_strequal(res->name, match->id)) { |
| 10977 | 4375 | /* uh oh, the single result isn't identical to the search |
| 4376 | term, better safe then sorry, so let's make sure it's who | |
| 4377 | the user meant to add */ | |
| 15884 | 4378 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4379 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4380 | |
| 10977 | 4381 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4382 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4383 | /* same person, set the server alias */ |
| 15884 | 4384 | purple_blist_server_alias_buddy(buddy, match->name); |
| 4385 | purple_blist_node_set_string((PurpleBlistNode *) buddy, | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4386 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4387 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4388 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4389 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4390 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4391 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4392 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4393 | g_free(data); |
| 10977 | 4394 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4395 | |
| 10977 | 4396 | } else { |
| 4397 | /* prompt user if more than one match was returned */ | |
| 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); |
| 10977 | 4400 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4401 | |
| 10977 | 4402 | return; |
| 4403 | } | |
| 4404 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4405 | #if 0 |
| 10977 | 4406 | /* fall-through indicates that we couldn't find a matching user in |
| 4407 | the resolve service (ether error or zero results), so we remove | |
| 4408 | this buddy */ | |
| 4409 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4410 | /* 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
|
4411 | 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
|
4412 | 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
|
4413 | 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
|
4414 | 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
|
4415 | |
| 10977 | 4416 | DEBUG_INFO("no such buddy in community\n"); |
| 15884 | 4417 | purple_blist_remove_buddy(buddy); |
| 10977 | 4418 | blist_schedule(pd); |
| 4419 | ||
| 4420 | if(res && res->name) { | |
| 4421 | /* compose and display an error message */ | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4422 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4423 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4424 | char *msg; |
| 10977 | 4425 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4426 | msgA = _("Unable to add user: user not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4427 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4428 | 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
|
4429 | " Sametime community. This entry has been removed from" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4430 | " your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4431 | msg = g_strdup_printf(msgB, NSTR(res->name)); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4432 | |
| 15884 | 4433 | purple_notify_error(gc, _("Unable to add user"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4434 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4435 | g_free(msg); |
| 10977 | 4436 | } |
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4437 | #endif |
| 10977 | 4438 | } |
| 4439 | ||
| 4440 | ||
| 15884 | 4441 | static void mw_prpl_add_buddy(PurpleConnection *gc, |
| 4442 | PurpleBuddy *buddy, | |
| 4443 | PurpleGroup *group) { | |
| 4444 | ||
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4445 | struct mwPurplePluginData *pd = gc->proto_data; |
| 10977 | 4446 | struct mwServiceResolve *srvc; |
| 4447 | GList *query; | |
| 4448 | enum mwResolveFlag flags; | |
| 4449 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4450 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4451 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4452 | /* 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
|
4453 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4454 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4455 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4456 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4457 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4458 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4459 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4460 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4461 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4462 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4463 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4464 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4465 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4466 | ||
| 4467 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4468 | data, NULL); |
| 10977 | 4469 | g_list_free(query); |
| 4470 | ||
| 4471 | if(req == SEARCH_ERROR) { | |
| 15884 | 4472 | purple_blist_remove_buddy(buddy); |
| 10977 | 4473 | blist_schedule(pd); |
| 4474 | } | |
| 4475 | } | |
| 4476 | ||
| 4477 | ||
| 15884 | 4478 | static void foreach_add_buddies(PurpleGroup *group, GList *buddies, |
| 4479 | struct mwPurplePluginData *pd) { | |
| 10977 | 4480 | struct mwAwareList *list; |
| 4481 | ||
| 4482 | list = list_ensure(pd, group); | |
| 4483 | mwAwareList_addAware(list, buddies); | |
| 4484 | g_list_free(buddies); | |
| 4485 | } | |
| 4486 | ||
| 4487 | ||
| 15884 | 4488 | static void mw_prpl_add_buddies(PurpleConnection *gc, |
| 10977 | 4489 | GList *buddies, |
| 4490 | GList *groups) { | |
| 4491 | ||
| 15884 | 4492 | struct mwPurplePluginData *pd; |
| 10977 | 4493 | GHashTable *group_sets; |
| 4494 | struct mwAwareIdBlock *idbs, *idb; | |
| 4495 | ||
| 4496 | pd = gc->proto_data; | |
| 4497 | ||
| 15884 | 4498 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4499 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4500 | ||
| 4501 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4502 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4503 | ||
| 4504 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4505 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4506 | PurpleBuddy *b = buddies->data; |
| 4507 | PurpleGroup *g; | |
| 10977 | 4508 | const char *fn; |
| 4509 | GList *l; | |
| 4510 | ||
| 4511 | /* nab the saved server alias and stick it on the buddy */ | |
| 15884 | 4512 | fn = purple_blist_node_get_string((PurpleBlistNode *) b, BUDDY_KEY_NAME); |
| 4513 | purple_blist_server_alias_buddy(b, fn); | |
| 4514 | ||
| 4515 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4516 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4517 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4518 | idb->community = NULL; |
| 4519 | ||
| 4520 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4521 | g = purple_buddy_get_group(b); |
| 10977 | 4522 | l = g_hash_table_lookup(group_sets, g); |
| 4523 | l = g_list_prepend(l, idb++); | |
| 4524 | g_hash_table_insert(group_sets, g, l); | |
| 4525 | } | |
| 4526 | ||
| 4527 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4528 | for saving */ | |
| 4529 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4530 | blist_schedule(pd); | |
| 4531 | ||
| 4532 | /* cleanup */ | |
| 4533 | g_hash_table_destroy(group_sets); | |
| 4534 | g_free(idbs); | |
| 4535 | } | |
| 4536 | ||
| 4537 | ||
| 15884 | 4538 | static void mw_prpl_remove_buddy(PurpleConnection *gc, |
| 4539 | PurpleBuddy *buddy, PurpleGroup *group) { | |
| 4540 | ||
| 4541 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4542 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4543 | struct mwAwareList *list; |
| 4544 | ||
| 4545 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4546 | ||
| 4547 | pd = gc->proto_data; | |
| 15884 | 4548 | group = purple_buddy_get_group(buddy); |
| 10977 | 4549 | list = list_ensure(pd, group); |
| 4550 | ||
| 4551 | mwAwareList_removeAware(list, rem); | |
| 4552 | blist_schedule(pd); | |
| 4553 | ||
| 4554 | g_list_free(rem); | |
| 4555 | } | |
| 4556 | ||
| 4557 | ||
| 4558 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4559 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4560 | |
| 10977 | 4561 | struct mwUserItem *u; |
| 4562 | guint count; | |
| 4563 | ||
| 4564 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4565 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4566 | |
| 4567 | priv->count = count; | |
| 4568 | priv->users = g_new0(struct mwUserItem, count); | |
| 4569 | ||
| 4570 | while(count--) { | |
| 4571 | u = priv->users + count; | |
| 4572 | u->id = members->data; | |
| 4573 | members = members->next; | |
| 4574 | } | |
| 4575 | } | |
| 4576 | ||
| 4577 | ||
| 15884 | 4578 | static void mw_prpl_set_permit_deny(PurpleConnection *gc) { |
| 4579 | PurpleAccount *acct; | |
| 4580 | struct mwPurplePluginData *pd; | |
| 10977 | 4581 | struct mwSession *session; |
| 4582 | ||
| 4583 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4584 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4585 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4586 | NULL, /* users */ |
| 10977 | 4587 | }; |
| 4588 | ||
| 4589 | g_return_if_fail(gc != NULL); | |
| 4590 | ||
| 15884 | 4591 | acct = purple_connection_get_account(gc); |
| 10977 | 4592 | g_return_if_fail(acct != NULL); |
| 4593 | ||
| 4594 | pd = gc->proto_data; | |
| 4595 | g_return_if_fail(pd != NULL); | |
| 4596 | ||
| 4597 | session = pd->session; | |
| 4598 | g_return_if_fail(session != NULL); | |
| 4599 | ||
| 4600 | switch(acct->perm_deny) { | |
| 15884 | 4601 | case PURPLE_PRIVACY_DENY_USERS: |
| 4602 | DEBUG_INFO("PURPLE_PRIVACY_DENY_USERS\n"); | |
| 10977 | 4603 | privacy_fill(&privacy, acct->deny); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4604 | privacy.deny = TRUE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4605 | break; |
| 10977 | 4606 | |
| 15884 | 4607 | case PURPLE_PRIVACY_ALLOW_ALL: |
| 4608 | DEBUG_INFO("PURPLE_PRIVACY_ALLOW_ALL\n"); | |
| 10977 | 4609 | privacy.deny = TRUE; |
| 4610 | break; | |
| 4611 | ||
| 15884 | 4612 | case PURPLE_PRIVACY_ALLOW_USERS: |
| 4613 | DEBUG_INFO("PURPLE_PRIVACY_ALLOW_USERS\n"); | |
| 10977 | 4614 | privacy_fill(&privacy, acct->permit); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4615 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4616 | break; |
| 10977 | 4617 | |
| 15884 | 4618 | case PURPLE_PRIVACY_DENY_ALL: |
| 4619 | DEBUG_INFO("PURPLE_PRIVACY_DENY_ALL\n"); | |
| 10977 | 4620 | privacy.deny = FALSE; |
| 4621 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4622 | |
| 10977 | 4623 | default: |
| 4624 | DEBUG_INFO("acct->perm_deny is 0x%x\n", acct->perm_deny); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4625 | return; |
| 10977 | 4626 | } |
| 4627 | ||
| 4628 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4629 | g_free(privacy.users); | |
| 4630 | } | |
| 4631 | ||
| 4632 | ||
| 15884 | 4633 | static void mw_prpl_add_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4634 | mw_prpl_set_permit_deny(gc); |
| 4635 | } | |
| 4636 | ||
| 4637 | ||
| 15884 | 4638 | static void mw_prpl_add_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4639 | mw_prpl_set_permit_deny(gc); |
| 4640 | } | |
| 4641 | ||
| 4642 | ||
| 15884 | 4643 | static void mw_prpl_rem_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4644 | mw_prpl_set_permit_deny(gc); |
| 4645 | } | |
| 4646 | ||
| 4647 | ||
| 15884 | 4648 | static void mw_prpl_rem_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4649 | mw_prpl_set_permit_deny(gc); |
| 4650 | } | |
| 4651 | ||
| 4652 | ||
| 4653 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4654 | const char *name) { | |
| 4655 | GList *l, *ll; | |
| 4656 | struct mwConference *conf = NULL; | |
| 4657 | ||
| 4658 | ll = mwServiceConference_getConferences(srvc); | |
| 4659 | for(l = ll; l; l = l->next) { | |
| 4660 | struct mwConference *c = l->data; | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4661 | if(purple_strequal(name, mwConference_getName(c))) { |
| 10977 | 4662 | conf = c; |
| 4663 | break; | |
| 4664 | } | |
| 4665 | } | |
| 4666 | g_list_free(ll); | |
| 4667 | ||
| 4668 | return conf; | |
| 4669 | } | |
| 4670 | ||
| 4671 | ||
| 15884 | 4672 | static void mw_prpl_join_chat(PurpleConnection *gc, |
| 10977 | 4673 | GHashTable *components) { |
| 4674 | ||
| 15884 | 4675 | struct mwPurplePluginData *pd; |
| 10977 | 4676 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4677 | |
| 10977 | 4678 | pd = gc->proto_data; |
| 4679 | ||
| 4680 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4681 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4682 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4683 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4684 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4685 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4686 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4687 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4688 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4689 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4690 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4691 | |
| 10977 | 4692 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4693 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4694 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4695 | struct mwConference *conf = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4696 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4697 | srvc = pd->srvc_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4698 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4699 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4700 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4701 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4702 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4703 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4704 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4705 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4706 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4707 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4708 | } |
| 10977 | 4709 | } |
| 4710 | } | |
| 4711 | ||
| 4712 | ||
| 15884 | 4713 | static void mw_prpl_reject_chat(PurpleConnection *gc, |
| 10977 | 4714 | GHashTable *components) { |
| 4715 | ||
| 15884 | 4716 | struct mwPurplePluginData *pd; |
| 10977 | 4717 | struct mwServiceConference *srvc; |
| 4718 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4719 | |
| 10977 | 4720 | pd = gc->proto_data; |
| 4721 | srvc = pd->srvc_conf; | |
| 4722 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4723 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4724 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4725 | |
|
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 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4728 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4729 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4730 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4731 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4732 | } |
| 10977 | 4733 | } |
| 4734 | } | |
| 4735 | ||
| 4736 | ||
| 4737 | static char *mw_prpl_get_chat_name(GHashTable *components) { | |
| 4738 | return g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4739 | } | |
| 4740 | ||
| 4741 | ||
| 15884 | 4742 | static void mw_prpl_chat_invite(PurpleConnection *gc, |
| 10977 | 4743 | int id, |
| 4744 | const char *invitation, | |
| 4745 | const char *who) { | |
| 4746 | ||
| 15884 | 4747 | struct mwPurplePluginData *pd; |
| 10977 | 4748 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4749 | struct mwPlace *place; |
| 10977 | 4750 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4751 | ||
| 4752 | pd = gc->proto_data; | |
| 4753 | g_return_if_fail(pd != NULL); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4754 | |
| 10977 | 4755 | conf = ID_TO_CONF(pd, id); |
| 4756 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4757 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4758 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4759 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4760 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4761 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4762 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4763 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4764 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4765 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4766 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4767 | } |
| 4768 | ||
| 4769 | ||
| 15884 | 4770 | static void mw_prpl_chat_leave(PurpleConnection *gc, |
| 10977 | 4771 | int id) { |
| 4772 | ||
| 15884 | 4773 | struct mwPurplePluginData *pd; |
| 10977 | 4774 | struct mwConference *conf; |
| 4775 | ||
| 4776 | pd = gc->proto_data; | |
| 4777 | ||
| 4778 | g_return_if_fail(pd != NULL); | |
| 4779 | conf = ID_TO_CONF(pd, id); | |
| 4780 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4781 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4782 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4783 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4784 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4785 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4786 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4787 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4788 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4789 | } |
| 10977 | 4790 | } |
| 4791 | ||
| 4792 | ||
| 15884 | 4793 | static void mw_prpl_chat_whisper(PurpleConnection *gc, |
| 10977 | 4794 | int id, |
| 4795 | const char *who, | |
| 4796 | const char *message) { | |
| 4797 | ||
| 4798 | mw_prpl_send_im(gc, who, message, 0); | |
| 4799 | } | |
| 4800 | ||
| 4801 | ||
| 15884 | 4802 | static int mw_prpl_chat_send(PurpleConnection *gc, |
| 10977 | 4803 | int id, |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4804 | const char *message, |
| 15884 | 4805 | PurpleMessageFlags flags) { |
| 4806 | ||
| 4807 | struct mwPurplePluginData *pd; | |
| 10977 | 4808 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4809 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4810 | int ret; |
| 10977 | 4811 | |
| 4812 | pd = gc->proto_data; | |
| 4813 | ||
| 4814 | g_return_val_if_fail(pd != NULL, 0); | |
| 4815 | conf = ID_TO_CONF(pd, id); | |
| 4816 | ||
| 15884 | 4817 | msg = purple_markup_strip_html(message); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4818 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4819 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4820 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4821 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4822 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4823 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4824 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4825 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4826 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4827 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4828 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4829 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4830 | return ret; |
| 10977 | 4831 | } |
| 4832 | ||
| 4833 | ||
| 15884 | 4834 | static void mw_prpl_keepalive(PurpleConnection *gc) { |
| 10977 | 4835 | struct mwSession *session; |
| 4836 | ||
| 4837 | g_return_if_fail(gc != NULL); | |
| 4838 | ||
| 4839 | session = gc_to_session(gc); | |
| 4840 | g_return_if_fail(session != NULL); | |
| 4841 | ||
| 4842 | mwSession_sendKeepalive(session); | |
| 4843 | } | |
| 4844 | ||
| 4845 | ||
| 15884 | 4846 | static void mw_prpl_alias_buddy(PurpleConnection *gc, |
| 10977 | 4847 | const char *who, |
| 4848 | const char *alias) { | |
| 4849 | ||
| 15884 | 4850 | struct mwPurplePluginData *pd = gc->proto_data; |
| 10977 | 4851 | g_return_if_fail(pd != NULL); |
| 4852 | ||
| 4853 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4854 | the server copy */ | |
| 4855 | ||
| 4856 | blist_schedule(pd); | |
| 4857 | } | |
| 4858 | ||
| 4859 | ||
| 15884 | 4860 | static void mw_prpl_group_buddy(PurpleConnection *gc, |
| 10977 | 4861 | const char *who, |
| 4862 | const char *old_group, | |
| 4863 | const char *new_group) { | |
| 4864 | ||
| 4865 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 4866 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4867 | ||
| 15884 | 4868 | struct mwPurplePluginData *pd = gc->proto_data; |
| 4869 | PurpleGroup *group; | |
| 10977 | 4870 | struct mwAwareList *list; |
| 4871 | ||
| 4872 | /* add who to new_group's aware list */ | |
| 15884 | 4873 | group = purple_find_group(new_group); |
| 10977 | 4874 | list = list_ensure(pd, group); |
| 4875 | mwAwareList_addAware(list, gl); | |
| 4876 | ||
| 4877 | /* remove who from old_group's aware list */ | |
| 15884 | 4878 | group = purple_find_group(old_group); |
| 10977 | 4879 | list = list_ensure(pd, group); |
| 4880 | mwAwareList_removeAware(list, gl); | |
| 4881 | ||
| 4882 | g_list_free(gl); | |
| 4883 | ||
| 4884 | /* schedule the changes to be saved */ | |
| 4885 | blist_schedule(pd); | |
| 4886 | } | |
| 4887 | ||
| 4888 | ||
| 15884 | 4889 | static void mw_prpl_rename_group(PurpleConnection *gc, |
| 10977 | 4890 | const char *old, |
| 15884 | 4891 | PurpleGroup *group, |
| 10977 | 4892 | GList *buddies) { |
| 4893 | ||
| 15884 | 4894 | struct mwPurplePluginData *pd = gc->proto_data; |
| 10977 | 4895 | g_return_if_fail(pd != NULL); |
| 4896 | ||
| 4897 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4898 | the server copy. Also, having this function should prevent all | |
| 4899 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4900 | give a crap what the group is named in Purple other than to record |
| 10977 | 4901 | that as the group name/alias */ |
| 4902 | ||
| 4903 | blist_schedule(pd); | |
| 4904 | } | |
| 4905 | ||
| 4906 | ||
| 15884 | 4907 | static void mw_prpl_buddy_free(PurpleBuddy *buddy) { |
| 10977 | 4908 | /* I don't think we have any cleanup for buddies yet */ |
| 4909 | ; | |
| 4910 | } | |
| 4911 | ||
| 4912 | ||
| 15884 | 4913 | static void mw_prpl_convo_closed(PurpleConnection *gc, const char *who) { |
| 4914 | struct mwPurplePluginData *pd = gc->proto_data; | |
| 10977 | 4915 | struct mwServiceIm *srvc; |
| 4916 | struct mwConversation *conv; | |
| 4917 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4918 | ||
| 4919 | g_return_if_fail(pd != NULL); | |
| 4920 | ||
| 4921 | srvc = pd->srvc_im; | |
| 4922 | g_return_if_fail(srvc != NULL); | |
| 4923 | ||
| 4924 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 4925 | if(! conv) return; | |
| 4926 | ||
| 4927 | if(mwConversation_isOpen(conv)) | |
| 4928 | mwConversation_free(conv); | |
| 4929 | } | |
| 4930 | ||
| 4931 | ||
| 15884 | 4932 | static const char *mw_prpl_normalize(const PurpleAccount *account, |
| 10977 | 4933 | const char *id) { |
| 4934 | ||
| 4935 | /* code elsewhere assumes that the return value points to different | |
| 4936 | memory than the passed value, but it won't free the normalized | |
| 4937 | data. wtf? */ | |
| 4938 | ||
| 4939 | 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
|
4940 | g_strlcpy(buf, id, sizeof(buf)); |
| 10977 | 4941 | return buf; |
| 4942 | } | |
| 4943 | ||
| 4944 | ||
| 15884 | 4945 | static void mw_prpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { |
| 4946 | struct mwPurplePluginData *pd; | |
| 10977 | 4947 | struct mwAwareList *list; |
| 4948 | ||
| 4949 | pd = gc->proto_data; | |
| 4950 | g_return_if_fail(pd != NULL); | |
| 4951 | g_return_if_fail(pd->group_list_map != NULL); | |
| 4952 | ||
| 4953 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 4954 | ||
| 4955 | if(list) { | |
| 4956 | g_hash_table_remove(pd->group_list_map, list); | |
| 4957 | g_hash_table_remove(pd->group_list_map, group); | |
| 4958 | mwAwareList_free(list); | |
| 4959 | ||
| 4960 | blist_schedule(pd); | |
| 4961 | } | |
| 4962 | } | |
| 4963 | ||
| 4964 | ||
| 15884 | 4965 | static gboolean mw_prpl_can_receive_file(PurpleConnection *gc, |
| 10977 | 4966 | const char *who) { |
| 15884 | 4967 | struct mwPurplePluginData *pd; |
| 10977 | 4968 | struct mwServiceAware *srvc; |
| 15884 | 4969 | PurpleAccount *acct; |
| 10977 | 4970 | |
| 4971 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 4972 | ||
| 4973 | pd = gc->proto_data; | |
| 4974 | g_return_val_if_fail(pd != NULL, FALSE); | |
| 4975 | ||
| 4976 | srvc = pd->srvc_aware; | |
| 4977 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4978 | |
| 15884 | 4979 | acct = purple_connection_get_account(gc); |
| 10977 | 4980 | g_return_val_if_fail(acct != NULL, FALSE); |
| 4981 | ||
| 15884 | 4982 | return purple_find_buddy(acct, who) && |
| 10977 | 4983 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 4984 | } | |
| 4985 | ||
| 4986 | ||
| 15884 | 4987 | static void ft_outgoing_init(PurpleXfer *xfer) { |
| 4988 | PurpleAccount *acct; | |
| 4989 | PurpleConnection *gc; | |
| 4990 | ||
| 4991 | struct mwPurplePluginData *pd; | |
| 10977 | 4992 | struct mwServiceFileTransfer *srvc; |
| 4993 | struct mwFileTransfer *ft; | |
| 4994 | ||
| 4995 | const char *filename; | |
| 4996 | gsize filesize; | |
| 4997 | FILE *fp; | |
| 4998 | ||
| 4999 | struct mwIdBlock idb = { NULL, NULL }; | |
| 5000 | ||
| 5001 | DEBUG_INFO("ft_outgoing_init\n"); | |
| 5002 | ||
| 15884 | 5003 | acct = purple_xfer_get_account(xfer); |
| 5004 | gc = purple_account_get_connection(acct); | |
| 10977 | 5005 | pd = gc->proto_data; |
| 5006 | srvc = pd->srvc_ft; | |
| 5007 | ||
| 15884 | 5008 | filename = purple_xfer_get_local_filename(xfer); |
| 5009 | filesize = purple_xfer_get_size(xfer); | |
| 10977 | 5010 | idb.user = xfer->who; |
| 5011 | ||
| 15884 | 5012 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5013 | |
| 10977 | 5014 | /* test that we can actually send the file */ |
| 5015 | fp = g_fopen(filename, "rb"); | |
| 5016 | if(! fp) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5017 | 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
|
5018 | filename, g_strerror(errno)); |
| 15884 | 5019 | purple_xfer_error(purple_xfer_get_type(xfer), acct, xfer->who, msg); |
| 10977 | 5020 | g_free(msg); |
| 5021 | return; | |
| 5022 | } | |
| 5023 | fclose(fp); | |
| 5024 | ||
| 5025 | { | |
| 5026 | char *tmp = strrchr(filename, G_DIR_SEPARATOR); | |
| 5027 | if(tmp++) filename = tmp; | |
| 5028 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5029 | |
| 10977 | 5030 | ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); |
| 5031 | ||
| 15884 | 5032 | purple_xfer_ref(xfer); |
| 5033 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
| 10977 | 5034 | xfer->data = ft; |
| 5035 | ||
| 5036 | mwFileTransfer_offer(ft); | |
| 5037 | } | |
| 5038 | ||
| 5039 | ||
| 15884 | 5040 | static void ft_outgoing_cancel(PurpleXfer *xfer) { |
| 10977 | 5041 | struct mwFileTransfer *ft = xfer->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5042 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5043 | DEBUG_INFO("ft_outgoing_cancel called\n"); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5044 | |
| 10977 | 5045 | if(ft) mwFileTransfer_cancel(ft); |
| 5046 | } | |
| 5047 | ||
| 5048 | ||
| 15884 | 5049 | static PurpleXfer *mw_prpl_new_xfer(PurpleConnection *gc, const char *who) { |
| 5050 | PurpleAccount *acct; | |
| 5051 | PurpleXfer *xfer; | |
| 5052 | ||
| 5053 | acct = purple_connection_get_account(gc); | |
| 5054 | ||
| 5055 | xfer = purple_xfer_new(acct, PURPLE_XFER_SEND, who); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5056 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5057 | { |
| 15884 | 5058 | purple_xfer_set_init_fnc(xfer, ft_outgoing_init); |
| 5059 | purple_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5060 | } |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5061 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5062 | return xfer; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5063 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5064 | |
| 15884 | 5065 | static void mw_prpl_send_file(PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5066 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5067 | |
| 15884 | 5068 | PurpleXfer *xfer = mw_prpl_new_xfer(gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5069 | |
| 10977 | 5070 | if(file) { |
| 5071 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 5072 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 5073 | |
| 5074 | } else { | |
| 5075 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 5076 | purple_xfer_request(xfer); |
| 10977 | 5077 | } |
| 5078 | } | |
| 5079 | ||
| 5080 | ||
| 15884 | 5081 | static PurplePluginProtocolInfo mw_prpl_info = { |
|
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
|
5082 | OPT_PROTO_IM_IMAGE, |
|
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
|
5083 | NULL, /*< set in mw_plugin_init */ |
|
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
|
5084 | NULL, /*< set in mw_plugin_init */ |
|
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
|
5085 | NO_BUDDY_ICONS, |
|
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
|
5086 | mw_prpl_list_icon, |
|
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
|
5087 | mw_prpl_list_emblem, |
|
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
|
5088 | mw_prpl_status_text, |
|
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
|
5089 | mw_prpl_tooltip_text, |
|
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
|
5090 | mw_prpl_status_types, |
|
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
|
5091 | mw_prpl_blist_node_menu, |
|
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
|
5092 | mw_prpl_chat_info, |
|
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
|
5093 | mw_prpl_chat_info_defaults, |
|
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
|
5094 | mw_prpl_login, |
|
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
|
5095 | mw_prpl_close, |
|
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
|
5096 | mw_prpl_send_im, |
|
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
|
5097 | 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
|
5098 | mw_prpl_send_typing, |
|
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
|
5099 | mw_prpl_get_info, |
|
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
|
5100 | mw_prpl_set_status, |
|
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
|
5101 | mw_prpl_set_idle, |
|
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
|
5102 | 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
|
5103 | mw_prpl_add_buddy, |
|
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
|
5104 | mw_prpl_add_buddies, |
|
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
|
5105 | mw_prpl_remove_buddy, |
|
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
|
5106 | 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
|
5107 | mw_prpl_add_permit, |
|
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
|
5108 | mw_prpl_add_deny, |
|
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
|
5109 | mw_prpl_rem_permit, |
|
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
|
5110 | mw_prpl_rem_deny, |
|
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
|
5111 | mw_prpl_set_permit_deny, |
|
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
|
5112 | mw_prpl_join_chat, |
|
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
|
5113 | mw_prpl_reject_chat, |
|
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
|
5114 | mw_prpl_get_chat_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
|
5115 | mw_prpl_chat_invite, |
|
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
|
5116 | mw_prpl_chat_leave, |
|
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
|
5117 | mw_prpl_chat_whisper, |
|
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
|
5118 | mw_prpl_chat_send, |
|
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
|
5119 | mw_prpl_keepalive, |
|
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
|
5120 | 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
|
5121 | 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
|
5122 | 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
|
5123 | mw_prpl_alias_buddy, |
|
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
|
5124 | mw_prpl_group_buddy, |
|
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
|
5125 | mw_prpl_rename_group, |
|
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
|
5126 | mw_prpl_buddy_free, |
|
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
|
5127 | mw_prpl_convo_closed, |
|
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
|
5128 | mw_prpl_normalize, |
|
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
|
5129 | 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
|
5130 | mw_prpl_remove_group, |
|
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
|
5131 | 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
|
5132 | 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
|
5133 | 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
|
5134 | 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
|
5135 | 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
|
5136 | 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
|
5137 | mw_prpl_can_receive_file, |
|
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
|
5138 | mw_prpl_send_file, |
|
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
|
5139 | mw_prpl_new_xfer, |
|
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
|
5140 | 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
|
5141 | 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
|
5142 | 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
|
5143 | 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
|
5144 | 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
|
5145 | 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
|
5146 | 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
|
5147 | sizeof(PurplePluginProtocolInfo), |
|
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
|
5148 | 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
|
5149 | 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
|
5150 | 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
|
5151 | 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
|
5152 | 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
|
5153 | 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
|
5154 | NULL, |
|
38977
9fb01eaac544
sametime: Add missing initializer for .get_cb_alias() method
David Woodhouse <dwmw2@infradead.org>
parents:
38259
diff
changeset
|
5155 | NULL, |
|
40426
159344ba2a49
Make PurplePluginProtocolInfo definitions consistent
David Woodhouse <dwmw2@infradead.org>
parents:
38977
diff
changeset
|
5156 | NULL, /* get_cb_alias */ |
|
40427
93bf0203f935
Add chat_send_file() facility
David Woodhouse <dwmw2@infradead.org>
parents:
40426
diff
changeset
|
5157 | NULL, /* chat_can_receive_file */ |
|
93bf0203f935
Add chat_send_file() facility
David Woodhouse <dwmw2@infradead.org>
parents:
40426
diff
changeset
|
5158 | NULL, /* chat_send_file */ |
| 10977 | 5159 | }; |
| 5160 | ||
| 5161 | ||
| 15884 | 5162 | static PurplePluginPrefFrame * |
| 5163 | mw_plugin_get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 5164 | PurplePluginPrefFrame *frame; | |
| 5165 | PurplePluginPref *pref; | |
| 5166 | ||
| 5167 | frame = purple_plugin_pref_frame_new(); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5168 | |
| 15884 | 5169 | pref = purple_plugin_pref_new_with_label(_("Remotely Stored Buddy List")); |
| 5170 | purple_plugin_pref_frame_add(frame, pref); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5171 | |
| 10977 | 5172 | |
| 15884 | 5173 | pref = purple_plugin_pref_new_with_name(MW_PRPL_OPT_BLIST_ACTION); |
| 5174 | purple_plugin_pref_set_label(pref, _("Buddy List Storage Mode")); | |
| 5175 | ||
| 5176 | purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE); | |
| 5177 | 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
|
5178 | GINT_TO_POINTER(blist_choice_LOCAL)); |
| 15884 | 5179 | 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
|
5180 | GINT_TO_POINTER(blist_choice_MERGE)); |
| 15884 | 5181 | 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
|
5182 | GINT_TO_POINTER(blist_choice_STORE)); |
| 15884 | 5183 | 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
|
5184 | GINT_TO_POINTER(blist_choice_SYNCH)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5185 | |
| 15884 | 5186 | purple_plugin_pref_frame_add(frame, pref); |
| 10977 | 5187 | |
| 5188 | return frame; | |
| 5189 | } | |
| 5190 | ||
| 5191 | ||
| 15884 | 5192 | static PurplePluginUiInfo mw_plugin_ui_info = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5193 | mw_plugin_get_plugin_pref_frame, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5194 | 0, /* page_num */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5195 | NULL, /* frame */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5196 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5197 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5198 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5199 | NULL |
| 10977 | 5200 | }; |
| 5201 | ||
| 5202 | ||
| 15884 | 5203 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5204 | struct mwSametimeList *l; |
| 5205 | ||
| 5206 | FILE *file; | |
| 5207 | char buf[BUF_LEN]; | |
| 5208 | size_t len; | |
| 5209 | ||
| 5210 | GString *str; | |
| 5211 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5212 | file = g_fopen(filename, "r"); |
| 10977 | 5213 | g_return_if_fail(file != NULL); |
| 5214 | ||
| 5215 | str = g_string_new(NULL); | |
| 5216 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 5217 | g_string_append_len(str, buf, len); | |
| 5218 | } | |
| 5219 | ||
| 5220 | fclose(file); | |
| 5221 | ||
| 5222 | l = mwSametimeList_load(str->str); | |
| 5223 | g_string_free(str, TRUE); | |
| 5224 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5225 | blist_merge(gc, l); |
| 10977 | 5226 | mwSametimeList_free(l); |
| 5227 | } | |
| 5228 | ||
| 5229 | ||
| 5230 | /** prompts for a file to import blist from */ | |
| 15884 | 5231 | static void st_import_action(PurplePluginAction *act) { |
| 5232 | PurpleConnection *gc; | |
| 5233 | PurpleAccount *account; | |
| 10977 | 5234 | char *title; |
| 5235 | ||
| 5236 | gc = act->context; | |
| 15884 | 5237 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5238 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 5239 | purple_account_get_username(account)); |
| 5240 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5241 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 5242 | 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
|
5243 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5244 | gc); |
| 10977 | 5245 | |
| 5246 | g_free(title); | |
| 5247 | } | |
| 5248 | ||
| 5249 | ||
| 15884 | 5250 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5251 | struct mwSametimeList *l; |
| 5252 | char *str; | |
| 5253 | FILE *file; | |
| 5254 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5255 | file = g_fopen(filename, "w"); |
| 10977 | 5256 | g_return_if_fail(file != NULL); |
| 5257 | ||
| 5258 | l = mwSametimeList_new(); | |
| 5259 | blist_export(gc, l); | |
| 5260 | str = mwSametimeList_store(l); | |
| 5261 | mwSametimeList_free(l); | |
| 5262 | ||
| 5263 | fprintf(file, "%s", str); | |
| 5264 | fclose(file); | |
| 5265 | ||
| 5266 | g_free(str); | |
| 5267 | } | |
| 5268 | ||
| 5269 | ||
| 5270 | /** prompts for a file to export blist to */ | |
| 15884 | 5271 | static void st_export_action(PurplePluginAction *act) { |
| 5272 | PurpleConnection *gc; | |
| 5273 | PurpleAccount *account; | |
| 10977 | 5274 | char *title; |
| 5275 | ||
| 5276 | gc = act->context; | |
| 15884 | 5277 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5278 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 5279 | purple_account_get_username(account)); |
| 5280 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5281 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 5282 | 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
|
5283 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5284 | gc); |
| 10977 | 5285 | |
| 5286 | g_free(title); | |
| 5287 | } | |
| 5288 | ||
| 5289 | ||
| 5290 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 5291 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5292 | |
| 15884 | 5293 | 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
|
5294 | GList *l; |
| 10977 | 5295 | |
| 15884 | 5296 | f = purple_request_fields_get_field(fields, "group"); |
| 5297 | l = purple_request_field_list_get_items(f); | |
| 10977 | 5298 | |
| 5299 | for(; l; l = l->next) { | |
| 5300 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5301 | struct named_id *res; |
| 10977 | 5302 | |
| 15884 | 5303 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5304 | |
| 5305 | g_free(res->id); | |
| 5306 | g_free(res->name); | |
| 5307 | g_free(res); | |
| 5308 | } | |
| 5309 | } | |
| 5310 | ||
| 5311 | ||
| 15884 | 5312 | static void remote_group_done(struct mwPurplePluginData *pd, |
| 10977 | 5313 | const char *id, const char *name) { |
| 15884 | 5314 | PurpleConnection *gc; |
| 5315 | PurpleAccount *acct; | |
| 5316 | PurpleGroup *group; | |
| 5317 | PurpleBlistNode *gn; | |
| 10977 | 5318 | const char *owner; |
| 5319 | ||
| 5320 | g_return_if_fail(pd != NULL); | |
| 5321 | ||
| 5322 | gc = pd->gc; | |
| 15884 | 5323 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5324 | |
| 10977 | 5325 | /* collision checking */ |
| 15884 | 5326 | group = purple_find_group(name); |
| 10977 | 5327 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5328 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5329 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5330 | char *msg; |
| 10977 | 5331 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5332 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5333 | 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
|
5334 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5335 | |
| 15884 | 5336 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5337 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5338 | g_free(msg); |
| 10977 | 5339 | return; |
| 5340 | } | |
| 5341 | ||
| 15884 | 5342 | group = purple_group_new(name); |
| 5343 | gn = (PurpleBlistNode *) group; | |
| 5344 | ||
| 5345 | owner = purple_account_get_username(acct); | |
| 5346 | ||
| 5347 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 5348 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 5349 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 5350 | purple_blist_add_group(group, NULL); | |
| 10977 | 5351 | |
| 5352 | group_add(pd, group); | |
| 5353 | blist_schedule(pd); | |
| 5354 | } | |
| 5355 | ||
| 5356 | ||
| 15884 | 5357 | static void remote_group_multi_cb(struct mwPurplePluginData *pd, |
| 5358 | PurpleRequestFields *fields) { | |
| 5359 | 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
|
5360 | GList *l; |
| 10977 | 5361 | |
| 15884 | 5362 | f = purple_request_fields_get_field(fields, "group"); |
| 5363 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 5364 | |
| 5365 | if(l) { | |
| 5366 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5367 | struct named_id *res; |
| 10977 | 5368 | |
| 15884 | 5369 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5370 | remote_group_done(pd, res->id, res->name); |
| 5371 | } | |
| 5372 | ||
| 5373 | remote_group_multi_cleanup(NULL, fields); | |
| 5374 | } | |
| 5375 | ||
| 5376 | ||
| 5377 | static void remote_group_multi(struct mwResolveResult *result, | |
| 15884 | 5378 | struct mwPurplePluginData *pd) { |
| 5379 | ||
| 5380 | PurpleRequestFields *fields; | |
| 5381 | PurpleRequestFieldGroup *g; | |
| 5382 | PurpleRequestField *f; | |
| 10977 | 5383 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5384 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5385 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5386 | char *msg; |
| 10977 | 5387 | |
| 15884 | 5388 | PurpleConnection *gc = pd->gc; |
| 5389 | ||
| 5390 | fields = purple_request_fields_new(); | |
| 5391 | ||
| 5392 | g = purple_request_field_group_new(NULL); | |
| 5393 | purple_request_fields_add_group(fields, g); | |
| 5394 | ||
| 5395 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 5396 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 5397 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 5398 | |
| 5399 | for(l = result->matches; l; l = l->next) { | |
| 5400 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5401 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 5402 | |
| 5403 | res->id = g_strdup(match->id); | |
| 5404 | res->name = g_strdup(match->name); | |
| 5405 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
5406 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 5407 | } |
| 5408 | ||
| 15884 | 5409 | purple_request_field_group_add_field(g, f); |
| 10977 | 5410 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5411 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5412 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 5413 | " Notes Address Book groups. Please select the correct group from" |
| 5414 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5415 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 5416 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5417 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5418 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5419 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5420 | _("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
|
5421 | purple_connection_get_account(gc), result->name, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5422 | pd); |
| 10977 | 5423 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5424 | g_free(msg); |
| 10977 | 5425 | } |
| 5426 | ||
| 5427 | ||
| 5428 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 5429 | guint32 id, guint32 code, GList *results, | |
| 5430 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5431 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5432 | struct mwResolveResult *res = NULL; |
| 10977 | 5433 | struct mwSession *session; |
| 15884 | 5434 | struct mwPurplePluginData *pd; |
| 5435 | PurpleConnection *gc; | |
| 10977 | 5436 | |
| 5437 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5438 | g_return_if_fail(session != NULL); | |
| 5439 | ||
| 5440 | pd = mwSession_getClientData(session); | |
| 5441 | g_return_if_fail(pd != NULL); | |
| 5442 | ||
| 5443 | gc = pd->gc; | |
| 5444 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5445 | |
| 10977 | 5446 | if(!code && results) { |
| 5447 | res = results->data; | |
| 5448 | ||
| 5449 | if(res->matches) { | |
| 5450 | remote_group_multi(res, pd); | |
| 5451 | return; | |
| 5452 | } | |
| 5453 | } | |
| 5454 | ||
| 5455 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5456 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5457 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5458 | char *msg; |
| 10977 | 5459 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5460 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5461 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5462 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5463 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5464 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5465 | |
| 15884 | 5466 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5467 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5468 | g_free(msg); |
| 10977 | 5469 | } |
| 5470 | } | |
| 5471 | ||
| 5472 | ||
| 15884 | 5473 | static void remote_group_action_cb(PurpleConnection *gc, const char *name) { |
| 5474 | struct mwPurplePluginData *pd; | |
| 10977 | 5475 | struct mwServiceResolve *srvc; |
| 5476 | GList *query; | |
| 5477 | enum mwResolveFlag flags; | |
| 5478 | guint32 req; | |
| 5479 | ||
| 5480 | pd = gc->proto_data; | |
| 5481 | srvc = pd->srvc_resolve; | |
| 5482 | ||
| 5483 | query = g_list_prepend(NULL, (char *) name); | |
| 5484 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5485 | |
| 10977 | 5486 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5487 | NULL, NULL); | |
| 5488 | g_list_free(query); | |
| 5489 | ||
| 5490 | if(req == SEARCH_ERROR) { | |
| 5491 | /** @todo display error */ | |
| 5492 | } | |
| 5493 | } | |
| 5494 | ||
| 5495 | ||
| 15884 | 5496 | static void remote_group_action(PurplePluginAction *act) { |
| 5497 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5498 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5499 | const char *msgB; |
| 10977 | 5500 | |
| 5501 | gc = act->context; | |
| 5502 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5503 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5504 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5505 | " to add the group and its members to your buddy list."); |
| 5506 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5507 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5508 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5509 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5510 | _("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
|
5511 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5512 | gc); |
| 10977 | 5513 | } |
| 5514 | ||
| 5515 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5516 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5517 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5518 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5519 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5520 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5521 | char *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5522 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5523 | |
| 15884 | 5524 | PurpleNotifySearchResults *sres; |
| 5525 | PurpleNotifySearchColumn *scol; | |
| 5526 | ||
| 5527 | sres = purple_notify_searchresults_new(); | |
| 5528 | ||
| 5529 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5530 | purple_notify_searchresults_column_add(sres, scol); | |
| 5531 | ||
| 5532 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5533 | purple_notify_searchresults_column_add(sres, scol); | |
| 5534 | ||
| 5535 | 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
|
5536 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5537 | |
| 15884 | 5538 | 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
|
5539 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5540 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5541 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5542 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5543 | GList *row = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5544 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5545 | if(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5546 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5547 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5548 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5549 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5550 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5551 | } |
|
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 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5554 | 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
|
5555 | " 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
|
5556 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5557 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5558 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5559 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5560 | |
| 15884 | 5561 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5562 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5563 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5564 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5565 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5566 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5567 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5568 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5569 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5570 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5571 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5572 | |
| 15884 | 5573 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5574 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5575 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5576 | if(results) res = results->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5577 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5578 | if(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5579 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5580 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5581 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5582 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5583 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5584 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5585 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5586 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5587 | 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
|
5588 | " Sametime community."); |
|
20228
ce019944d765
applied changes from 9d35dde0c779cca73548172223ba557f27d61882
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
5589 | 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
|
5590 | |
| 15884 | 5591 | purple_notify_error(gc, _("No Matches"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5592 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5593 | g_free(msg); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5594 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5595 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5596 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5597 | |
| 15884 | 5598 | static void search_action_cb(PurpleConnection *gc, const char *name) { |
| 5599 | struct mwPurplePluginData *pd; | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5600 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5601 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5602 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5603 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5604 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5605 | pd = gc->proto_data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5606 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5607 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5608 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5609 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5610 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5611 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5612 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5613 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5614 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5615 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5616 | /** @todo display error */ |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5617 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5618 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5619 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5620 | |
| 15884 | 5621 | static void search_action(PurplePluginAction *act) { |
| 5622 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5623 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5624 | const char *msgB; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5625 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5626 | gc = act->context; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5627 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5628 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5629 | 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
|
5630 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5631 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5632 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5633 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5634 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5635 | _("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
|
5636 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5637 | gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5638 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5639 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5640 | |
| 15884 | 5641 | static GList *mw_plugin_actions(PurplePlugin *plugin, gpointer context) { |
| 5642 | PurplePluginAction *act; | |
| 10977 | 5643 | GList *l = NULL; |
| 5644 | ||
| 15884 | 5645 | act = purple_plugin_action_new(_("Import Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5646 | st_import_action); |
| 10977 | 5647 | l = g_list_append(l, act); |
| 5648 | ||
| 15884 | 5649 | act = purple_plugin_action_new(_("Export Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5650 | st_export_action); |
| 10977 | 5651 | l = g_list_append(l, act); |
| 5652 | ||
| 15884 | 5653 | act = purple_plugin_action_new(_("Add Notes Address Book Group..."), |
| 10977 | 5654 | remote_group_action); |
| 5655 | l = g_list_append(l, act); | |
| 5656 | ||
| 15884 | 5657 | act = purple_plugin_action_new(_("User Search..."), |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5658 | search_action); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5659 | l = g_list_append(l, act); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5660 | |
| 10977 | 5661 | return l; |
| 5662 | } | |
| 5663 | ||
| 5664 | ||
| 15884 | 5665 | static gboolean mw_plugin_load(PurplePlugin *plugin) { |
| 10977 | 5666 | return TRUE; |
| 5667 | } | |
| 5668 | ||
| 5669 | ||
| 15884 | 5670 | static gboolean mw_plugin_unload(PurplePlugin *plugin) { |
| 10977 | 5671 | return TRUE; |
| 5672 | } | |
| 5673 | ||
| 5674 | ||
| 15884 | 5675 | static void mw_plugin_destroy(PurplePlugin *plugin) { |
| 10977 | 5676 | g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); |
| 5677 | g_log_remove_handler("meanwhile", log_handler[1]); | |
| 5678 | } | |
| 5679 | ||
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5680 | static PurplePluginInfo mw_plugin_info = |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5681 | { |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5682 | PURPLE_PLUGIN_MAGIC, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5683 | PURPLE_MAJOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5684 | PURPLE_MINOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5685 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5686 | NULL, /**< ui_requirement */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5687 | 0, /**< flags */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5688 | NULL, /**< dependencies */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5689 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5690 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5691 | PLUGIN_ID, /**< id */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5692 | PLUGIN_NAME, /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20228
diff
changeset
|
5693 | DISPLAY_VERSION, /**< version */ |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5694 | PLUGIN_SUMMARY, /**< summary */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5695 | PLUGIN_DESC, /**< description */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5696 | PLUGIN_AUTHOR, /**< author */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5697 | PLUGIN_HOMEPAGE, /**< homepage */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5698 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5699 | mw_plugin_load, /**< load */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5700 | mw_plugin_unload, /**< unload */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5701 | mw_plugin_destroy, /**< destroy */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5702 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5703 | NULL, /**< ui_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5704 | &mw_prpl_info, /**< extra_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5705 | &mw_plugin_ui_info, /**< prefs_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5706 | mw_plugin_actions, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5707 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5708 | /* padding */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5709 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5710 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5711 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5712 | NULL |
| 10977 | 5713 | }; |
| 5714 | ||
| 5715 | ||
| 5716 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5717 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5718 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5719 | if(! (msg && *msg)) return; |
| 10977 | 5720 | |
| 15884 | 5721 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5722 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5723 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5724 | |
| 5725 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5726 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5727 | |
| 5728 | } else { | |
| 15884 | 5729 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5730 | } |
| 5731 | } | |
| 5732 | ||
| 5733 | ||
| 15884 | 5734 | static void mw_plugin_init(PurplePlugin *plugin) { |
|
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
|
5735 | PurpleAccountUserSplit *split; |
| 15884 | 5736 | PurpleAccountOption *opt; |
| 10977 | 5737 | GList *l = NULL; |
| 5738 | ||
| 5739 | GLogLevelFlags logflags = | |
| 5740 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5741 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5742 | /* set up the preferences */ |
| 15884 | 5743 | purple_prefs_add_none(MW_PRPL_OPT_BASE); |
| 5744 | purple_prefs_add_int(MW_PRPL_OPT_BLIST_ACTION, BLIST_CHOICE_DEFAULT); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5745 | |
|
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
|
5746 | /* 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
|
5747 | 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
|
5748 | MW_PLUGIN_DEFAULT_HOST, ':'); |
|
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
|
5749 | mw_prpl_info.user_splits = g_list_append(mw_prpl_info.user_splits, split); |
|
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
|
5750 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5751 | /* remove dead preferences */ |
| 15884 | 5752 | purple_prefs_remove(MW_PRPL_OPT_PSYCHIC); |
| 5753 | purple_prefs_remove(MW_PRPL_OPT_SAVE_DYNAMIC); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5754 | |
| 10977 | 5755 | /* port to connect to */ |
| 15884 | 5756 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
| 10977 | 5757 | MW_PLUGIN_DEFAULT_PORT); |
| 5758 | l = g_list_append(l, opt); | |
| 5759 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5760 | { /* 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
|
5761 | 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
|
5762 | than one account that wants to check for it. */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5763 | gboolean b = FALSE; |
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12422
diff
changeset
|
5764 | const char *label = _("Force login (ignore server redirects)"); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5765 | |
| 15884 | 5766 | if(purple_prefs_exists(MW_PRPL_OPT_FORCE_LOGIN)) |
| 5767 | b = purple_prefs_get_bool(MW_PRPL_OPT_FORCE_LOGIN); | |
| 5768 | ||
| 5769 | 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
|
5770 | l = g_list_append(l, opt); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5771 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5772 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5773 | /* pretend to be Sametime Connect */ |
| 15884 | 5774 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5775 | MW_KEY_FAKE_IT, FALSE); |
|
12312
470a1452d009
[gaim-migrate @ 14616]
Christopher O'Brien <siege@pidgin.im>
parents:
12311
diff
changeset
|
5776 | l = g_list_append(l, opt); |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5777 | |
| 10977 | 5778 | mw_prpl_info.protocol_options = l; |
| 5779 | l = NULL; | |
| 5780 | ||
| 15884 | 5781 | /* forward all our g_log messages to purple. Generally all the logging |
| 5782 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5783 | get caught here */ |
| 5784 | log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags, | |
| 5785 | mw_log_handler, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5786 | |
| 15884 | 5787 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5788 | log_handler[1] = g_log_set_handler("meanwhile", logflags, |
| 5789 | mw_log_handler, NULL); | |
| 5790 | } | |
| 5791 | ||
| 5792 | ||
| 15884 | 5793 | PURPLE_INIT_PLUGIN(sametime, mw_plugin_init, mw_plugin_info); |
| 10977 | 5794 | /* The End. */ |
| 5795 |