Thu, 21 Jul 2011 05:55:03 +0000
sametime: Compile! (other build environment apparently lacked libmeanwhile...)
| 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 */ | |
| 15884 | 174 | #define DEBUG_ERROR(a...) purple_debug_error(G_LOG_DOMAIN, a) |
| 175 | #define DEBUG_INFO(a...) purple_debug_info(G_LOG_DOMAIN, a) | |
| 176 | #define DEBUG_MISC(a...) purple_debug_misc(G_LOG_DOMAIN, a) | |
| 177 | #define DEBUG_WARN(a...) purple_debug_warning(G_LOG_DOMAIN, a) | |
| 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); |
| 695 | if(owner && strcmp(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"); |
|
31983
4fa9bac19d37
sametime: Compile! (other build environment apparently lacked libmeanwhile...)
Paul Aurich <darkrain42@pidgin.im>
parents:
31979
diff
changeset
|
927 | return; |
|
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 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
930 | DEBUG_INFO("attempting to ensure group %s, called %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
931 | NSTR(name), NSTR(alias)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
932 | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
933 | /* 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
|
934 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
935 | gn = purple_blist_node_get_sibling_next(gn)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
936 | const char *n, *o; |
| 15884 | 937 | if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; |
| 938 | n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); | |
| 939 | 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
|
940 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
941 | 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
|
942 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
943 | if(n && !strcmp(n, name)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
944 | if(!o || !strcmp(o, owner)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
945 | DEBUG_INFO("that'll work\n"); |
| 15884 | 946 | group = (PurpleGroup *) gn; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
947 | break; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
948 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
949 | } |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
950 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
951 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
952 | /* try again, by alias */ |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
953 | if(! group) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
954 | DEBUG_INFO("searching for group by alias %s\n", NSTR(alias)); |
| 15884 | 955 | group = purple_find_group(alias); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
956 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
957 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
958 | /* oh well, no such group. Let's create it! */ |
| 10977 | 959 | if(! group) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
960 | DEBUG_INFO("creating group\n"); |
| 15884 | 961 | group = purple_group_new(alias); |
| 962 | purple_blist_add_group(group, NULL); | |
| 10977 | 963 | } |
| 964 | ||
| 15884 | 965 | gn = (PurpleBlistNode *) group; |
| 966 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); | |
| 967 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | |
| 10977 | 968 | |
| 969 | if(type == mwSametimeGroup_DYNAMIC) { | |
| 15884 | 970 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); |
| 10977 | 971 | group_add(gc->proto_data, group); |
| 972 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
973 | |
| 10977 | 974 | return group; |
| 975 | } | |
| 976 | ||
| 977 | ||
| 15884 | 978 | /** merge the entries from a st list into the purple blist */ |
| 979 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist) { | |
| 10977 | 980 | struct mwSametimeGroup *stgroup; |
| 981 | struct mwSametimeUser *stuser; | |
| 982 | ||
| 15884 | 983 | PurpleGroup *group; |
| 984 | PurpleBuddy *buddy; | |
| 10977 | 985 | |
| 986 | GList *gl, *gtl, *ul, *utl; | |
| 987 | ||
| 988 | gl = gtl = mwSametimeList_getGroups(stlist); | |
| 989 | for(; gl; gl = gl->next) { | |
| 990 | ||
| 991 | stgroup = (struct mwSametimeGroup *) gl->data; | |
| 992 | group = group_ensure(gc, stgroup); | |
| 993 | ||
| 994 | ul = utl = mwSametimeGroup_getUsers(stgroup); | |
| 995 | for(; ul; ul = ul->next) { | |
| 996 | ||
| 997 | stuser = (struct mwSametimeUser *) ul->data; | |
| 998 | buddy = buddy_ensure(gc, group, stuser); | |
| 999 | } | |
| 1000 | g_list_free(utl); | |
| 1001 | } | |
| 1002 | g_list_free(gtl); | |
| 1003 | } | |
| 1004 | ||
| 1005 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1006 | /** 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
|
1007 | is left empty, remove group as well */ |
| 15884 | 1008 | static void group_clear(PurpleGroup *group, PurpleAccount *acct, gboolean del) { |
| 1009 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1010 | GList *prune = NULL; |
| 15884 | 1011 | PurpleBlistNode *gn, *cn, *bn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1012 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1013 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1014 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1015 | 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
|
1016 | |
| 15884 | 1017 | gc = purple_account_get_connection(acct); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1018 | g_return_if_fail(gc != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1019 | |
| 15884 | 1020 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1021 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1022 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1023 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1024 | cn = purple_blist_node_get_sibling_next(cn)) { |
| 15884 | 1025 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1026 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1027 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1028 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1029 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1030 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1031 | ||
| 1032 | if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1033 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1034 | 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
|
1035 | 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
|
1036 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1037 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1038 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1039 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1040 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1041 | /* quickly unsubscribe from presence for the entire group */ |
| 15884 | 1042 | purple_account_remove_group(acct, group); |
|
11943
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 | /* remove blist entries that need to go */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1045 | while(prune) { |
| 15884 | 1046 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1047 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1048 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1049 | DEBUG_INFO("cleared buddies\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1050 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1051 | /* optionally remove group from blist */ |
| 15884 | 1052 | if(del && !purple_blist_get_group_size(group, TRUE)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1053 | DEBUG_INFO("removing empty group\n"); |
| 15884 | 1054 | purple_blist_remove_group(group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1055 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1056 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1057 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1058 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1059 | /** prune out group members that shouldn't be there */ |
| 15884 | 1060 | static void group_prune(PurpleConnection *gc, PurpleGroup *group, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1061 | struct mwSametimeGroup *stgroup) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1062 | |
| 15884 | 1063 | PurpleAccount *acct; |
| 1064 | PurpleBlistNode *gn, *cn, *bn; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1065 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1066 | GHashTable *stusers; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1067 | GList *prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1068 | GList *ul, *utl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1069 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1070 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1071 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1072 | 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
|
1073 | |
| 15884 | 1074 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1075 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1076 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1077 | 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
|
1078 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1079 | /* 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
|
1080 | contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1081 | utl = mwSametimeGroup_getUsers(stgroup); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1082 | for(ul = utl; ul; ul = ul->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1083 | const char *id = mwSametimeUser_getUser(ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1084 | g_hash_table_insert(stusers, (char *) id, ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1085 | DEBUG_INFO("server copy has %s\n", NSTR(id)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1086 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1087 | g_list_free(utl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1088 | |
| 15884 | 1089 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1090 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1091 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1092 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1093 | cn = purple_blist_node_get_sibling_next(cn)) { |
| 15884 | 1094 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1095 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1096 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1097 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1098 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1099 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1100 | ||
| 1101 | if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1102 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1103 | /* 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
|
1104 | them for pruning */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1105 | 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
|
1106 | 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
|
1107 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1108 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1109 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1110 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1111 | DEBUG_INFO("done marking\n"); |
|
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 | g_hash_table_destroy(stusers); |
|
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 | if(prune) { |
| 15884 | 1116 | purple_account_remove_buddies(acct, prune, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1117 | while(prune) { |
| 15884 | 1118 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1119 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1120 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1121 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1122 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1123 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1124 | |
| 15884 | 1125 | /** 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
|
1126 | existing buddies that aren't in the st list */ |
| 15884 | 1127 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 1128 | ||
| 1129 | PurpleAccount *acct; | |
| 1130 | PurpleBuddyList *blist; | |
| 1131 | PurpleBlistNode *gn; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1132 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1133 | GHashTable *stgroups; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1134 | GList *g_prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1135 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1136 | GList *gl, *gtl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1137 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1138 | const char *acct_n; |
|
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 | DEBUG_INFO("synchronizing local buddy list from server list\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1141 | |
| 15884 | 1142 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1143 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1144 | |
| 15884 | 1145 | acct_n = purple_account_get_username(acct); |
| 1146 | ||
| 1147 | blist = purple_get_blist(); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1148 | g_return_if_fail(blist != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1149 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1150 | /* 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
|
1151 | list, mapping group name to group structure */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1152 | 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
|
1153 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1154 | gtl = mwSametimeList_getGroups(stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1155 | for(gl = gtl; gl; gl = gl->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1156 | const char *name = mwSametimeGroup_getName(gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1157 | g_hash_table_insert(stgroups, (char *) name, gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1158 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1159 | g_list_free(gtl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1160 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1161 | /* 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
|
1162 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1163 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 15884 | 1164 | PurpleGroup *grp = (PurpleGroup *) gn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1165 | const char *gname, *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1166 | struct mwSametimeGroup *stgrp; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1167 | |
| 15884 | 1168 | if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1169 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1170 | /* group not belonging to this account */ |
| 15884 | 1171 | if(! purple_group_on_account(grp, acct)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1172 | continue; |
|
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 | /* dynamic group belonging to this account. don't prune contents */ |
| 15884 | 1175 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1176 | if(owner && !strcmp(owner, acct_n)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1177 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1178 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1179 | /* 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
|
1180 | title, which can be different things in the st list */ |
| 15884 | 1181 | 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
|
1182 | if(! gname) gname = purple_group_get_name(grp); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1183 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1184 | stgrp = g_hash_table_lookup(stgroups, gname); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1185 | if(! stgrp) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1186 | /* remove the whole group */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1187 | 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
|
1188 | g_prune = g_list_prepend(g_prune, grp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1189 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1190 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1191 | /* synch the group contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1192 | group_prune(gc, grp, stgrp); |
|
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 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1195 | DEBUG_INFO("done marking groups\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1196 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1197 | /* don't need this anymore */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1198 | g_hash_table_destroy(stgroups); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1199 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1200 | /* prune all marked groups */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1201 | while(g_prune) { |
| 15884 | 1202 | PurpleGroup *grp = g_prune->data; |
| 1203 | PurpleBlistNode *gn = (PurpleBlistNode *) grp; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1204 | const char *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1205 | gboolean del = TRUE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1206 | |
| 15884 | 1207 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1208 | if(owner && strcmp(owner, acct_n)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1209 | /* 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
|
1210 | 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
|
1211 | del = FALSE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1212 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1213 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1214 | group_clear(g_prune->data, acct, del); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1215 | g_prune = g_list_delete_link(g_prune, g_prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1216 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1217 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1218 | /* done with the pruning, let's merge in the additions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1219 | blist_merge(gc, stlist); |
|
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 | |
| 10977 | 1223 | /** callback passed to the storage service when it's told to load the |
| 1224 | st list */ | |
| 1225 | static void fetch_blist_cb(struct mwServiceStorage *srvc, | |
| 1226 | guint32 result, struct mwStorageUnit *item, | |
| 1227 | gpointer data) { | |
| 1228 | ||
| 15884 | 1229 | struct mwPurplePluginData *pd = data; |
| 10977 | 1230 | struct mwSametimeList *stlist; |
| 1231 | ||
| 1232 | struct mwGetBuffer *b; | |
| 1233 | ||
| 1234 | g_return_if_fail(result == ERR_SUCCESS); | |
| 1235 | ||
| 1236 | /* check our preferences for loading */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1237 | if(BLIST_PREF_IS_LOCAL()) { |
| 10977 | 1238 | DEBUG_INFO("preferences indicate not to load remote buddy list\n"); |
| 1239 | return; | |
| 1240 | } | |
| 1241 | ||
| 1242 | b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); | |
| 1243 | ||
| 1244 | stlist = mwSametimeList_new(); | |
| 1245 | mwSametimeList_get(b, stlist); | |
| 1246 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1247 | /* merge or synch depending on preferences */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1248 | if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1249 | blist_merge(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1250 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1251 | } else if(BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1252 | blist_sync(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1253 | } |
| 10977 | 1254 | |
| 1255 | mwSametimeList_free(stlist); | |
| 22973 | 1256 | mwGetBuffer_free(b); |
| 10977 | 1257 | } |
| 1258 | ||
| 1259 | ||
| 15884 | 1260 | /** signal triggered when a conversation is opened in Purple */ |
| 1261 | static void conversation_created_cb(PurpleConversation *g_conv, | |
| 1262 | struct mwPurplePluginData *pd) { | |
| 10977 | 1263 | |
| 1264 | /* we need to tell the IM service to negotiate features for the | |
| 1265 | conversation right away, otherwise it'll wait until the first | |
| 1266 | message is sent before offering NotesBuddy features. Therefore | |
| 15884 | 1267 | whenever Purple creates a conversation, we'll immediately open the |
| 10977 | 1268 | channel to the other side and figure out what the target can |
| 1269 | handle. Unfortunately, this makes us vulnerable to Psychic Mode, | |
| 1270 | 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
|
1271 | would not */ |
| 10977 | 1272 | |
| 15884 | 1273 | PurpleConnection *gc; |
| 10977 | 1274 | struct mwIdBlock who = { 0, 0 }; |
| 1275 | struct mwConversation *conv; | |
| 1276 | ||
| 15884 | 1277 | gc = purple_conversation_get_gc(g_conv); |
| 10977 | 1278 | if(pd->gc != gc) |
| 1279 | return; /* not ours */ | |
| 1280 | ||
| 15884 | 1281 | if(purple_conversation_get_type(g_conv) != PURPLE_CONV_TYPE_IM) |
| 10977 | 1282 | return; /* wrong type */ |
| 1283 | ||
| 15884 | 1284 | who.user = (char *) purple_conversation_get_name(g_conv); |
| 10977 | 1285 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 1286 | ||
| 1287 | convo_features(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1288 | |
| 10977 | 1289 | if(mwConversation_isClosed(conv)) |
| 1290 | mwConversation_open(conv); | |
| 1291 | } | |
| 1292 | ||
| 1293 | ||
| 15884 | 1294 | static void blist_menu_nab(PurpleBlistNode *node, gpointer data) { |
| 1295 | struct mwPurplePluginData *pd = data; | |
| 1296 | PurpleConnection *gc; | |
| 1297 | ||
| 1298 | PurpleGroup *group = (PurpleGroup *) node; | |
| 10977 | 1299 | |
| 1300 | GString *str; | |
| 1301 | char *tmp; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1302 | const char *gname; |
| 10977 | 1303 | |
| 1304 | g_return_if_fail(pd != NULL); | |
| 1305 | ||
| 1306 | gc = pd->gc; | |
| 1307 | g_return_if_fail(gc != NULL); | |
| 1308 | ||
| 15884 | 1309 | g_return_if_fail(PURPLE_BLIST_NODE_IS_GROUP(node)); |
| 10977 | 1310 | |
| 1311 | str = g_string_new(NULL); | |
| 1312 | ||
| 15884 | 1313 | 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
|
1314 | gname = purple_group_get_name(group); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1315 | |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1316 | 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
|
1317 | 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
|
1318 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1319 | tmp = g_strdup_printf(_("Info for Group %s"), gname); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1320 | |
| 15884 | 1321 | purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
| 10977 | 1322 | NULL, str->str, NULL, NULL); |
| 1323 | ||
| 1324 | g_free(tmp); | |
| 1325 | g_string_free(str, TRUE); | |
| 1326 | } | |
| 1327 | ||
| 1328 | ||
| 1329 | /** The normal blist menu prpl function doesn't get called for groups, | |
| 1330 | so we use the blist-node-extended-menu signal to trigger this | |
| 1331 | handler */ | |
| 15884 | 1332 | static void blist_node_menu_cb(PurpleBlistNode *node, |
| 1333 | GList **menu, struct mwPurplePluginData *pd) { | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1334 | const char *owner; |
| 15884 | 1335 | PurpleGroup *group; |
| 1336 | PurpleAccount *acct; | |
| 1337 | PurpleMenuAction *act; | |
| 10977 | 1338 | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1339 | /* we only want groups */ |
| 15884 | 1340 | if(! PURPLE_BLIST_NODE_IS_GROUP(node)) return; |
| 1341 | group = (PurpleGroup *) node; | |
| 1342 | ||
| 1343 | acct = purple_connection_get_account(pd->gc); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1344 | g_return_if_fail(acct != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1345 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1346 | /* better make sure we're connected */ |
| 15884 | 1347 | if(! purple_account_is_connected(acct)) return; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1348 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1349 | #if 0 |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1350 | /* 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
|
1351 | them all to a conference */ |
| 15884 | 1352 | if(purple_group_on_account(group, acct)) { |
| 1353 | act = purple_menu_action_new(_("Invite Group to Conference..."), | |
| 1354 | PURPLE_CALLBACK(blist_menu_group_invite), | |
| 13021 | 1355 | pd, NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1356 | *menu = g_list_append(*menu, NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1357 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1358 | #endif |
|
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 | /* check if it's a NAB group for this account */ |
| 15884 | 1361 | owner = purple_blist_node_get_string(node, GROUP_KEY_OWNER); |
| 1362 | if(owner && !strcmp(owner, purple_account_get_username(acct))) { | |
| 1363 | act = purple_menu_action_new(_("Get Notes Address Book Info"), | |
| 1364 | PURPLE_CALLBACK(blist_menu_nab), pd, NULL); | |
| 10977 | 1365 | *menu = g_list_append(*menu, act); |
| 1366 | } | |
| 1367 | } | |
| 1368 | ||
| 1369 | ||
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1370 | /* 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
|
1371 | anymore. */ |
| 15884 | 1372 | static void blist_init(PurpleAccount *acct) { |
| 1373 | PurpleBlistNode *gnode, *cnode, *bnode; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1374 | GList *add_buds = NULL; |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1375 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1376 | for(gnode = purple_blist_get_root(); gnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1377 | gnode = purple_blist_node_get_sibling_next(gnode)) { |
| 15884 | 1378 | if(! PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1379 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1380 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1381 | cnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1382 | cnode = purple_blist_node_get_sibling_next(cnode)) { |
| 15884 | 1383 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1384 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1385 | for(bnode = purple_blist_node_get_first_child(cnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1386 | bnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1387 | bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 15884 | 1388 | PurpleBuddy *b; |
| 1389 | if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1390 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1391 | |
| 15884 | 1392 | b = (PurpleBuddy *)bnode; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1393 | if(purple_buddy_get_account(b) == acct) { |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1394 | add_buds = g_list_append(add_buds, b); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1395 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1396 | } |
|
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 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1399 | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1400 | if(add_buds) { |
| 15884 | 1401 | purple_account_add_buddies(acct, add_buds); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1402 | g_list_free(add_buds); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1403 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1404 | } |
|
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 | |
| 10977 | 1407 | /** Last thing to happen from a started session */ |
| 15884 | 1408 | static void services_starting(struct mwPurplePluginData *pd) { |
| 1409 | ||
| 1410 | PurpleConnection *gc; | |
| 1411 | PurpleAccount *acct; | |
| 10977 | 1412 | struct mwStorageUnit *unit; |
| 15884 | 1413 | PurpleBlistNode *l; |
| 10977 | 1414 | |
| 1415 | gc = pd->gc; | |
| 15884 | 1416 | acct = purple_connection_get_account(gc); |
| 10977 | 1417 | |
| 1418 | /* grab the buddy list from the server */ | |
| 1419 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1420 | mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
| 10977 | 1421 | |
| 1422 | /* 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
|
1423 | for(l = purple_blist_get_root(); l; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1424 | l = purple_blist_node_get_sibling_next(l)) { |
| 15884 | 1425 | PurpleGroup *group = (PurpleGroup *) l; |
| 10977 | 1426 | enum mwSametimeGroupType gt; |
| 1427 | const char *owner; | |
| 1428 | ||
| 15884 | 1429 | if(! PURPLE_BLIST_NODE_IS_GROUP(l)) continue; |
| 10977 | 1430 | |
| 1431 | /* if the group is ownerless, or has an owner and we're not it, | |
| 1432 | skip it */ | |
| 15884 | 1433 | owner = purple_blist_node_get_string(l, GROUP_KEY_OWNER); |
| 1434 | if(!owner || strcmp(owner, purple_account_get_username(acct))) | |
| 10977 | 1435 | continue; |
| 1436 | ||
| 15884 | 1437 | gt = purple_blist_node_get_int(l, GROUP_KEY_TYPE); |
| 10977 | 1438 | if(gt == mwSametimeGroup_DYNAMIC) |
| 1439 | group_add(pd, group); | |
| 1440 | } | |
| 1441 | ||
| 1442 | /* set the aware attributes */ | |
| 1443 | /* indicate we understand what AV prefs are, but don't support any */ | |
| 1444 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1445 | mwAttribute_AV_PREFS_SET, TRUE); | |
| 1446 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE); | |
| 1447 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS); | |
| 1448 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA); | |
| 1449 | ||
| 1450 | /* ... but we can do file transfers! */ | |
| 1451 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1452 | mwAttribute_FILE_TRANSFER, TRUE); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1453 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1454 | blist_init(acct); |
| 10977 | 1455 | } |
| 1456 | ||
| 1457 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1458 | static void session_loginRedirect(struct mwSession *session, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1459 | const char *host) { |
| 15884 | 1460 | struct mwPurplePluginData *pd; |
| 1461 | PurpleConnection *gc; | |
| 1462 | PurpleAccount *account; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1463 | guint port; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1464 | const char *current_host; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1465 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1466 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1467 | gc = pd->gc; |
| 15884 | 1468 | account = purple_connection_get_account(gc); |
| 1469 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); | |
| 1470 | 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
|
1471 | MW_PLUGIN_DEFAULT_HOST); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1472 | |
| 15884 | 1473 | if(purple_account_get_bool(account, MW_KEY_FORCE, FALSE) || |
|
24739
35f208241e4c
Patch from Raiko Nitzsche to fix a crash when processing a LOGIN_REDIRECT with unexpected output. References #7563.
Daniel Atallah <datallah@pidgin.im>
parents:
24591
diff
changeset
|
1474 | !host || (! strcmp(current_host, host)) || |
|
27343
8a367ee70456
Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents:
26752
diff
changeset
|
1475 | (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
|
1476 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1477 | /* 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
|
1478 | 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
|
1479 | 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
|
1480 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1481 | mwSession_forceLogin(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1482 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1483 | } |
|
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 | |
| 15884 | 1486 | 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
|
1487 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1488 | |
| 10977 | 1489 | /** called from mw_session_stateChange when the session's state is |
| 1490 | mwSession_STARTED. Any finalizing of start-up stuff should go | |
| 1491 | here */ | |
| 15884 | 1492 | static void session_started(struct mwPurplePluginData *pd) { |
| 1493 | PurpleStatus *status; | |
| 1494 | PurpleAccount *acct; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1495 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1496 | /* set out initial status */ |
| 15884 | 1497 | acct = purple_connection_get_account(pd->gc); |
| 1498 | status = purple_account_get_active_status(acct); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1499 | mw_prpl_set_status(acct, status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1500 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1501 | /* start watching for new conversations */ |
| 15884 | 1502 | purple_signal_connect(purple_conversations_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1503 | "conversation-created", pd, |
| 15884 | 1504 | PURPLE_CALLBACK(conversation_created_cb), pd); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1505 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1506 | /* watch for group extended menu items */ |
| 15884 | 1507 | purple_signal_connect(purple_blist_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1508 | "blist-node-extended-menu", pd, |
| 15884 | 1509 | PURPLE_CALLBACK(blist_node_menu_cb), pd); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1510 | |
| 10977 | 1511 | /* use our services to do neat things */ |
| 1512 | services_starting(pd); | |
| 1513 | } | |
| 1514 | ||
| 1515 | ||
| 15884 | 1516 | static void session_stopping(struct mwPurplePluginData *pd) { |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1517 | /* stop watching the signals from session_started */ |
| 15884 | 1518 | purple_signals_disconnect_by_handle(pd); |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1519 | } |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1520 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1521 | |
| 10977 | 1522 | static void mw_session_stateChange(struct mwSession *session, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1523 | enum mwSessionState state, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1524 | gpointer info) { |
| 15884 | 1525 | struct mwPurplePluginData *pd; |
| 1526 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1527 | const char *msg = NULL; |
| 10977 | 1528 | |
| 1529 | pd = mwSession_getClientData(session); | |
| 1530 | gc = pd->gc; | |
| 1531 | ||
| 1532 | switch(state) { | |
| 1533 | case mwSession_STARTING: | |
| 1534 | msg = _("Sending Handshake"); | |
| 15884 | 1535 | purple_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS); |
| 10977 | 1536 | break; |
| 1537 | ||
| 1538 | case mwSession_HANDSHAKE: | |
| 1539 | msg = _("Waiting for Handshake Acknowledgement"); | |
| 15884 | 1540 | purple_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS); |
| 10977 | 1541 | break; |
| 1542 | ||
| 1543 | case mwSession_HANDSHAKE_ACK: | |
| 1544 | msg = _("Handshake Acknowledged, Sending Login"); | |
| 15884 | 1545 | purple_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS); |
| 10977 | 1546 | break; |
| 1547 | ||
| 1548 | case mwSession_LOGIN: | |
| 1549 | msg = _("Waiting for Login Acknowledgement"); | |
| 15884 | 1550 | purple_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS); |
| 10977 | 1551 | break; |
| 1552 | ||
| 1553 | case mwSession_LOGIN_REDIR: | |
| 1554 | msg = _("Login Redirected"); | |
| 15884 | 1555 | 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
|
1556 | session_loginRedirect(session, info); |
| 10977 | 1557 | break; |
| 1558 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1559 | case mwSession_LOGIN_CONT: |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1560 | msg = _("Forcing Login"); |
| 15884 | 1561 | purple_connection_update_progress(gc, msg, 7, MW_CONNECT_STEPS); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1562 | |
| 10977 | 1563 | case mwSession_LOGIN_ACK: |
| 1564 | msg = _("Login Acknowledged"); | |
| 15884 | 1565 | purple_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS); |
| 10977 | 1566 | break; |
| 1567 | ||
| 1568 | case mwSession_STARTED: | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1569 | msg = _("Starting Services"); |
| 15884 | 1570 | purple_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS); |
| 10977 | 1571 | |
| 1572 | session_started(pd); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1573 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1574 | msg = _("Connected"); |
| 15884 | 1575 | purple_connection_update_progress(gc, msg, 10, MW_CONNECT_STEPS); |
| 1576 | purple_connection_set_state(gc, PURPLE_CONNECTED); | |
| 10977 | 1577 | break; |
| 1578 | ||
| 1579 | case mwSession_STOPPING: | |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1580 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1581 | session_stopping(pd); |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1582 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1583 | if(GPOINTER_TO_UINT(info) & ERR_FAILURE) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1584 | char *err = mwError(GPOINTER_TO_UINT(info)); |
| 21279 | 1585 | PurpleConnectionError reason; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1586 | switch (GPOINTER_TO_UINT(info)) { |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1587 | case VERSION_MISMATCH: |
| 21279 | 1588 | reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1589 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1590 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1591 | case USER_RESTRICTED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1592 | case INCORRECT_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1593 | case USER_UNREGISTERED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1594 | case GUEST_IN_USE: |
| 21279 | 1595 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1596 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1597 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1598 | case ENCRYPT_MISMATCH: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1599 | case ERR_ENCRYPT_NO_SUPPORT: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1600 | case ERR_NO_COMMON_ENCRYPT: |
| 21279 | 1601 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1602 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1603 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1604 | case VERIFICATION_DOWN: |
| 21279 | 1605 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1606 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1607 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1608 | case MULTI_SERVER_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1609 | case MULTI_SERVER_LOGIN2: |
| 21279 | 1610 | reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1611 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1612 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1613 | default: |
| 21279 | 1614 | reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
20455
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 | purple_connection_error_reason(gc, reason, err); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1617 | g_free(err); |
| 10977 | 1618 | } |
| 1619 | break; | |
| 1620 | ||
| 1621 | case mwSession_STOPPED: | |
| 1622 | break; | |
| 1623 | ||
| 1624 | case mwSession_UNKNOWN: | |
| 1625 | default: | |
| 1626 | DEBUG_WARN("session in unknown state\n"); | |
| 1627 | } | |
| 1628 | } | |
| 1629 | ||
| 1630 | ||
| 1631 | static void mw_session_setPrivacyInfo(struct mwSession *session) { | |
| 15884 | 1632 | struct mwPurplePluginData *pd; |
| 1633 | PurpleConnection *gc; | |
| 1634 | PurpleAccount *acct; | |
| 10977 | 1635 | struct mwPrivacyInfo *privacy; |
| 1636 | GSList *l, **ll; | |
| 1637 | guint count; | |
| 1638 | ||
| 1639 | DEBUG_INFO("privacy information set from server\n"); | |
| 1640 | ||
| 1641 | g_return_if_fail(session != NULL); | |
| 1642 | ||
| 1643 | pd = mwSession_getClientData(session); | |
| 1644 | g_return_if_fail(pd != NULL); | |
| 1645 | ||
| 1646 | gc = pd->gc; | |
| 1647 | g_return_if_fail(gc != NULL); | |
| 1648 | ||
| 15884 | 1649 | acct = purple_connection_get_account(gc); |
| 10977 | 1650 | g_return_if_fail(acct != NULL); |
| 1651 | ||
| 1652 | privacy = mwSession_getPrivacyInfo(session); | |
| 1653 | count = privacy->count; | |
| 1654 | ||
| 1655 | ll = (privacy->deny)? &acct->deny: &acct->permit; | |
| 1656 | for(l = *ll; l; l = l->next) g_free(l->data); | |
| 1657 | g_slist_free(*ll); | |
| 1658 | l = *ll = NULL; | |
| 1659 | ||
| 1660 | while(count--) { | |
| 1661 | struct mwUserItem *u = privacy->users + count; | |
| 1662 | l = g_slist_prepend(l, g_strdup(u->id)); | |
| 1663 | } | |
| 1664 | *ll = l; | |
| 1665 | } | |
| 1666 | ||
| 1667 | ||
| 1668 | static void mw_session_setUserStatus(struct mwSession *session) { | |
| 15884 | 1669 | struct mwPurplePluginData *pd; |
| 1670 | PurpleConnection *gc; | |
| 10977 | 1671 | struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL }; |
| 1672 | struct mwUserStatus *stat; | |
| 1673 | ||
| 1674 | g_return_if_fail(session != NULL); | |
| 1675 | ||
| 1676 | pd = mwSession_getClientData(session); | |
| 1677 | g_return_if_fail(pd != NULL); | |
| 1678 | ||
| 1679 | gc = pd->gc; | |
| 1680 | g_return_if_fail(gc != NULL); | |
| 1681 | ||
| 1682 | idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); | |
| 1683 | stat = mwSession_getUserStatus(session); | |
| 1684 | ||
| 1685 | /* trigger an update of our own status if we're in the buddy list */ | |
| 1686 | mwServiceAware_setStatus(pd->srvc_aware, &idb, stat); | |
| 1687 | } | |
| 1688 | ||
| 1689 | ||
| 1690 | static void mw_session_admin(struct mwSession *session, | |
| 1691 | const char *text) { | |
| 15884 | 1692 | PurpleConnection *gc; |
| 1693 | PurpleAccount *acct; | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1694 | const char *host; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1695 | const char *msg; |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1696 | char *prim; |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1697 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1698 | gc = session_to_gc(session); |
| 10977 | 1699 | g_return_if_fail(gc != NULL); |
| 1700 | ||
| 15884 | 1701 | acct = purple_connection_get_account(gc); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1702 | g_return_if_fail(acct != NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1703 | |
| 15884 | 1704 | 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
|
1705 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1706 | msg = _("A Sametime administrator has issued the following announcement" |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1707 | " on server %s"); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1708 | prim = g_strdup_printf(msg, NSTR(host)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1709 | |
| 15884 | 1710 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1711 | _("Sametime Administrator Announcement"), |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1712 | prim, text, NULL, NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1713 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1714 | g_free(prim); |
| 10977 | 1715 | } |
| 1716 | ||
| 1717 | ||
| 1718 | /** called from read_cb, attempts to read available data from sock and | |
| 1719 | pass it to the session, passing back the return code from the read | |
| 1720 | call for handling in read_cb */ | |
| 1721 | static int read_recv(struct mwSession *session, int sock) { | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1722 | guchar buf[BUF_LEN]; |
| 10977 | 1723 | int len; |
| 1724 | ||
| 1725 | 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
|
1726 | 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
|
1727 | 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
|
1728 | } |
| 10977 | 1729 | |
| 1730 | return len; | |
| 1731 | } | |
| 1732 | ||
| 1733 | ||
| 15884 | 1734 | /** callback triggered from purple_input_add, watches the socked for |
| 10977 | 1735 | available data to be processed by the session */ |
| 15884 | 1736 | static void read_cb(gpointer data, gint source, PurpleInputCondition cond) { |
| 1737 | struct mwPurplePluginData *pd = data; | |
| 10977 | 1738 | int ret = 0, err = 0; |
| 1739 | ||
| 1740 | g_return_if_fail(pd != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1741 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1742 | ret = read_recv(pd->session, pd->socket); |
| 10977 | 1743 | |
| 1744 | /* normal operation ends here */ | |
| 1745 | if(ret > 0) return; | |
| 1746 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1747 | /* fetch the global error value */ |
| 10977 | 1748 | err = errno; |
| 1749 | ||
| 14754 | 1750 | /* read problem occurred if we're here, so we'll need to take care of |
| 10977 | 1751 | it and clean up internal state */ |
| 1752 | ||
| 1753 | if(pd->socket) { | |
| 1754 | close(pd->socket); | |
| 1755 | pd->socket = 0; | |
| 1756 | } | |
| 1757 | ||
| 1758 | if(pd->gc->inpa) { | |
| 15884 | 1759 | purple_input_remove(pd->gc->inpa); |
| 10977 | 1760 | pd->gc->inpa = 0; |
| 1761 | } | |
| 1762 | ||
| 1763 | if(! ret) { | |
| 1764 | DEBUG_INFO("connection reset\n"); | |
| 21279 | 1765 | purple_connection_error_reason(pd->gc, |
| 1766 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1767 | _("Server closed the connection")); |
| 10977 | 1768 | |
| 1769 | } 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
|
1770 | 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
|
1771 | 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
|
1772 | |
|
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 | 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
|
1774 | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1775 | msg = g_strdup_printf(_("Lost connection with server: %s"), err_str); |
| 21279 | 1776 | purple_connection_error_reason(pd->gc, |
| 1777 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
| 1778 | msg); | |
| 10977 | 1779 | g_free(msg); |
| 1780 | } | |
| 1781 | } | |
| 1782 | ||
| 1783 | ||
| 15884 | 1784 | /** Callback passed to purple_proxy_connect when an account is logged |
| 10977 | 1785 | 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
|
1786 | static void connect_cb(gpointer data, gint source, const gchar *error_message) { |
| 10977 | 1787 | |
| 15884 | 1788 | struct mwPurplePluginData *pd = data; |
| 1789 | PurpleConnection *gc = pd->gc; | |
| 10977 | 1790 | |
| 1791 | if(source < 0) { | |
| 1792 | /* connection failed */ | |
| 1793 | ||
| 1794 | if(pd->socket) { | |
| 1795 | /* this is a redirect connect, force login on existing socket */ | |
| 1796 | mwSession_forceLogin(pd->session); | |
| 1797 | ||
| 1798 | } else { | |
| 1799 | /* this is a regular connect, error out */ | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1800 | 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
|
1801 | error_message); |
| 21279 | 1802 | purple_connection_error_reason(pd->gc, |
| 1803 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1804 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1805 | g_free(tmp); |
| 10977 | 1806 | } |
| 1807 | ||
| 1808 | return; | |
| 1809 | } | |
| 1810 | ||
| 1811 | if(pd->socket) { | |
| 1812 | /* stop any existing login attempt */ | |
| 1813 | mwSession_stop(pd->session, ERR_SUCCESS); | |
| 1814 | } | |
| 1815 | ||
| 1816 | pd->socket = source; | |
| 15884 | 1817 | gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
1818 | read_cb, pd); |
| 10977 | 1819 | |
| 1820 | mwSession_start(pd->session); | |
| 1821 | } | |
| 1822 | ||
| 1823 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1824 | static void mw_session_announce(struct mwSession *s, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1825 | struct mwLoginInfo *from, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1826 | gboolean may_reply, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1827 | const char *text) { |
| 15884 | 1828 | struct mwPurplePluginData *pd; |
| 1829 | PurpleAccount *acct; | |
| 1830 | PurpleConversation *conv; | |
| 1831 | PurpleBuddy *buddy; | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1832 | char *who = from->user_id; |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1833 | char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1834 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1835 | pd = mwSession_getClientData(s); |
| 15884 | 1836 | acct = purple_connection_get_account(pd->gc); |
| 1837 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, acct); | |
| 1838 | if(! conv) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, who); | |
| 1839 | ||
| 1840 | buddy = purple_find_buddy(acct, who); | |
| 1841 | 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
|
1842 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1843 | who = g_strdup_printf(_("Announcement from %s"), who); |
| 15884 | 1844 | msg = purple_markup_linkify(text); |
| 1845 | ||
|
23979
936d7ef5cece
Add NULL checking to purple_markup_linkify().
Daniel Atallah <datallah@pidgin.im>
parents:
22973
diff
changeset
|
1846 | 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
|
1847 | g_free(who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1848 | g_free(msg); |
| 10977 | 1849 | } |
| 1850 | ||
| 1851 | ||
| 1852 | static struct mwSessionHandler mw_session_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1853 | mw_session_io_write, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1854 | mw_session_io_close, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1855 | mw_session_clear, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1856 | mw_session_stateChange, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1857 | mw_session_setPrivacyInfo, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1858 | mw_session_setUserStatus, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1859 | mw_session_admin, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1860 | mw_session_announce, |
| 10977 | 1861 | }; |
| 1862 | ||
| 1863 | ||
| 1864 | static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
| 1865 | struct mwAwareAttribute *attrib) { | |
| 1866 | ||
| 1867 | ; /** @todo handle server attributes. There may be some stuff we | |
| 1868 | actually want to look for, but I'm not aware of anything right | |
| 1869 | now.*/ | |
| 1870 | } | |
| 1871 | ||
| 1872 | ||
| 1873 | static void mw_aware_clear(struct mwServiceAware *srvc) { | |
| 1874 | ; /* nothing for now */ | |
| 1875 | } | |
| 1876 | ||
| 1877 | ||
| 1878 | static struct mwAwareHandler mw_aware_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1879 | mw_aware_on_attrib, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1880 | mw_aware_clear, |
| 10977 | 1881 | }; |
| 1882 | ||
| 1883 | ||
| 1884 | static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
| 1885 | struct mwServiceAware *srvc; | |
| 1886 | srvc = mwServiceAware_new(s, &mw_aware_handler); | |
| 1887 | return srvc; | |
| 1888 | }; | |
| 1889 | ||
| 1890 | ||
| 1891 | static void mw_conf_invited(struct mwConference *conf, | |
| 1892 | struct mwLoginInfo *inviter, | |
| 1893 | const char *invitation) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1894 | |
| 10977 | 1895 | struct mwServiceConference *srvc; |
| 1896 | struct mwSession *session; | |
| 15884 | 1897 | struct mwPurplePluginData *pd; |
| 1898 | PurpleConnection *gc; | |
| 10977 | 1899 | |
| 1900 | char *c_inviter, *c_name, *c_topic, *c_invitation; | |
| 1901 | GHashTable *ht; | |
| 1902 | ||
| 1903 | srvc = mwConference_getService(conf); | |
| 1904 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1905 | pd = mwSession_getClientData(session); | |
| 1906 | gc = pd->gc; | |
| 1907 | ||
| 1908 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1909 | ||
| 1910 | c_inviter = g_strdup(inviter->user_id); | |
| 1911 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
| 1912 | ||
| 1913 | c_name = g_strdup(mwConference_getName(conf)); | |
| 1914 | g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
| 1915 | ||
| 1916 | c_topic = g_strdup(mwConference_getTitle(conf)); | |
| 1917 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
| 1918 | ||
| 1919 | c_invitation = g_strdup(invitation); | |
| 1920 | g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
| 1921 | ||
| 1922 | DEBUG_INFO("received invitation from '%s' to join ('%s','%s'): '%s'\n", | |
| 1923 | NSTR(c_inviter), NSTR(c_name), | |
| 1924 | NSTR(c_topic), NSTR(c_invitation)); | |
| 1925 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1926 | if(! c_topic) c_topic = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1927 | if(! c_invitation) c_invitation = "(no message)"; |
| 10977 | 1928 | serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
| 1929 | } | |
| 1930 | ||
| 1931 | ||
| 15884 | 1932 | /* The following mess helps us relate a mwConference to a PurpleConvChat |
| 10977 | 1933 | in the various forms by which either may be indicated */ |
| 1934 | ||
| 1935 | #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
| 1936 | #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
| 1937 | ||
| 15884 | 1938 | #define CHAT_TO_ID(chat) (purple_conv_chat_get_id(chat)) |
| 1939 | #define ID_TO_CHAT(id) (purple_find_chat(id)) | |
| 10977 | 1940 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1941 | #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
|
1942 | #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
| 10977 | 1943 | |
| 1944 | ||
| 1945 | static struct mwConference * | |
| 15884 | 1946 | conf_find_by_id(struct mwPurplePluginData *pd, int id) { |
| 10977 | 1947 | |
| 1948 | struct mwServiceConference *srvc = pd->srvc_conf; | |
| 1949 | struct mwConference *conf = NULL; | |
| 1950 | GList *l, *ll; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1951 | |
| 10977 | 1952 | ll = mwServiceConference_getConferences(srvc); |
| 1953 | for(l = ll; l; l = l->next) { | |
| 1954 | struct mwConference *c = l->data; | |
| 15884 | 1955 | PurpleConvChat *h = mwConference_getClientData(c); |
| 10977 | 1956 | |
| 1957 | if(CHAT_TO_ID(h) == id) { | |
| 1958 | conf = c; | |
| 1959 | break; | |
| 1960 | } | |
| 1961 | } | |
| 1962 | g_list_free(ll); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1963 | |
| 10977 | 1964 | return conf; |
| 1965 | } | |
| 1966 | ||
| 1967 | ||
| 1968 | static void mw_conf_opened(struct mwConference *conf, GList *members) { | |
| 1969 | struct mwServiceConference *srvc; | |
| 1970 | struct mwSession *session; | |
| 15884 | 1971 | struct mwPurplePluginData *pd; |
| 1972 | PurpleConnection *gc; | |
| 1973 | PurpleConversation *g_conf; | |
| 10977 | 1974 | |
| 1975 | const char *n = mwConference_getName(conf); | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1976 | const char *t = mwConference_getTitle(conf); |
| 10977 | 1977 | |
| 1978 | DEBUG_INFO("conf %s opened, %u initial members\n", | |
| 1979 | NSTR(n), g_list_length(members)); | |
| 1980 | ||
| 1981 | srvc = mwConference_getService(conf); | |
| 1982 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1983 | pd = mwSession_getClientData(session); | |
| 1984 | gc = pd->gc; | |
| 1985 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1986 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1987 | g_conf = serv_got_joined_chat(gc, CONF_TO_ID(conf), t); |
| 10977 | 1988 | |
| 15884 | 1989 | mwConference_setClientData(conf, PURPLE_CONV_CHAT(g_conf), NULL); |
| 10977 | 1990 | |
| 1991 | for(; members; members = members->next) { | |
| 1992 | struct mwLoginInfo *peer = members->data; | |
| 15884 | 1993 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(g_conf), peer->user_id, |
| 1994 | NULL, PURPLE_CBFLAGS_NONE, FALSE); | |
| 10977 | 1995 | } |
| 1996 | } | |
| 1997 | ||
| 1998 | ||
| 1999 | static void mw_conf_closed(struct mwConference *conf, guint32 reason) { | |
| 2000 | struct mwServiceConference *srvc; | |
| 2001 | struct mwSession *session; | |
| 15884 | 2002 | struct mwPurplePluginData *pd; |
| 2003 | PurpleConnection *gc; | |
| 10977 | 2004 | |
| 2005 | const char *n = mwConference_getName(conf); | |
| 2006 | char *msg = mwError(reason); | |
| 2007 | ||
| 2008 | DEBUG_INFO("conf %s closed, 0x%08x\n", NSTR(n), reason); | |
| 2009 | ||
| 2010 | srvc = mwConference_getService(conf); | |
| 2011 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2012 | pd = mwSession_getClientData(session); | |
| 2013 | gc = pd->gc; | |
| 2014 | ||
| 2015 | serv_got_chat_left(gc, CONF_TO_ID(conf)); | |
| 2016 | ||
| 15884 | 2017 | purple_notify_error(gc, _("Conference Closed"), NULL, msg); |
| 10977 | 2018 | g_free(msg); |
| 2019 | } | |
| 2020 | ||
| 2021 | ||
| 2022 | static void mw_conf_peer_joined(struct mwConference *conf, | |
| 2023 | struct mwLoginInfo *peer) { | |
| 2024 | ||
| 2025 | struct mwServiceConference *srvc; | |
| 2026 | struct mwSession *session; | |
| 15884 | 2027 | struct mwPurplePluginData *pd; |
| 2028 | PurpleConnection *gc; | |
| 2029 | PurpleConvChat *g_conf; | |
| 10977 | 2030 | |
| 2031 | const char *n = mwConference_getName(conf); | |
| 2032 | ||
| 2033 | DEBUG_INFO("%s joined conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2034 | ||
| 2035 | srvc = mwConference_getService(conf); | |
| 2036 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2037 | pd = mwSession_getClientData(session); | |
| 2038 | gc = pd->gc; | |
| 2039 | ||
| 2040 | g_conf = mwConference_getClientData(conf); | |
| 2041 | g_return_if_fail(g_conf != NULL); | |
| 2042 | ||
| 15884 | 2043 | purple_conv_chat_add_user(g_conf, peer->user_id, |
| 2044 | NULL, PURPLE_CBFLAGS_NONE, TRUE); | |
| 10977 | 2045 | } |
| 2046 | ||
| 2047 | ||
| 2048 | static void mw_conf_peer_parted(struct mwConference *conf, | |
| 2049 | struct mwLoginInfo *peer) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2050 | |
| 10977 | 2051 | struct mwServiceConference *srvc; |
| 2052 | struct mwSession *session; | |
| 15884 | 2053 | struct mwPurplePluginData *pd; |
| 2054 | PurpleConnection *gc; | |
| 2055 | PurpleConvChat *g_conf; | |
| 10977 | 2056 | |
| 2057 | const char *n = mwConference_getName(conf); | |
| 2058 | ||
| 2059 | DEBUG_INFO("%s left conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2060 | ||
| 2061 | srvc = mwConference_getService(conf); | |
| 2062 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2063 | pd = mwSession_getClientData(session); | |
| 2064 | gc = pd->gc; | |
| 2065 | ||
| 2066 | g_conf = mwConference_getClientData(conf); | |
| 2067 | g_return_if_fail(g_conf != NULL); | |
| 2068 | ||
| 15884 | 2069 | purple_conv_chat_remove_user(g_conf, peer->user_id, NULL); |
| 10977 | 2070 | } |
| 2071 | ||
| 2072 | ||
| 2073 | static void mw_conf_text(struct mwConference *conf, | |
| 2074 | struct mwLoginInfo *who, const char *text) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2075 | |
| 10977 | 2076 | struct mwServiceConference *srvc; |
| 2077 | struct mwSession *session; | |
| 15884 | 2078 | struct mwPurplePluginData *pd; |
| 2079 | PurpleConnection *gc; | |
| 10977 | 2080 | char *esc; |
| 2081 | ||
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2082 | if(! text) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2083 | |
| 10977 | 2084 | srvc = mwConference_getService(conf); |
| 2085 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2086 | pd = mwSession_getClientData(session); | |
| 2087 | gc = pd->gc; | |
| 2088 | ||
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2089 | esc = g_markup_escape_text(text, -1); |
| 10977 | 2090 | serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, 0, esc, time(NULL)); |
| 2091 | g_free(esc); | |
| 2092 | } | |
| 2093 | ||
| 2094 | ||
| 2095 | static void mw_conf_typing(struct mwConference *conf, | |
| 2096 | struct mwLoginInfo *who, gboolean typing) { | |
| 2097 | ||
| 15884 | 2098 | /* purple really has no good way to expose this to the user. */ |
| 10977 | 2099 | |
| 2100 | const char *n = mwConference_getName(conf); | |
| 2101 | const char *w = who->user_id; | |
| 2102 | ||
| 2103 | if(typing) { | |
| 2104 | DEBUG_INFO("%s in conf %s: <typing>\n", NSTR(w), NSTR(n)); | |
| 2105 | ||
| 2106 | } else { | |
| 2107 | DEBUG_INFO("%s in conf %s: <stopped typing>\n", NSTR(w), NSTR(n)); | |
| 2108 | } | |
| 2109 | } | |
| 2110 | ||
| 2111 | ||
| 2112 | static void mw_conf_clear(struct mwServiceConference *srvc) { | |
| 2113 | ; | |
| 2114 | } | |
| 2115 | ||
| 2116 | ||
| 2117 | static struct mwConferenceHandler mw_conference_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2118 | mw_conf_invited, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2119 | mw_conf_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2120 | mw_conf_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2121 | mw_conf_peer_joined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2122 | mw_conf_peer_parted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2123 | mw_conf_text, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2124 | mw_conf_typing, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2125 | mw_conf_clear, |
| 10977 | 2126 | }; |
| 2127 | ||
| 2128 | ||
| 2129 | static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) { | |
| 2130 | struct mwServiceConference *srvc; | |
| 2131 | srvc = mwServiceConference_new(s, &mw_conference_handler); | |
| 2132 | return srvc; | |
| 2133 | } | |
| 2134 | ||
| 2135 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2136 | /** size of an outgoing file transfer chunk */ |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2137 | #define MW_FT_LEN (BUF_LONG * 2) |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2138 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2139 | |
| 15884 | 2140 | static void ft_incoming_cancel(PurpleXfer *xfer) { |
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29304
diff
changeset
|
2141 | /* incoming transfer rejected or cancelled in-progress */ |
| 10977 | 2142 | struct mwFileTransfer *ft = xfer->data; |
| 2143 | if(ft) mwFileTransfer_reject(ft); | |
| 2144 | } | |
| 2145 | ||
| 2146 | ||
| 15884 | 2147 | static void ft_incoming_init(PurpleXfer *xfer) { |
| 10977 | 2148 | /* incoming transfer accepted */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2149 | |
| 10977 | 2150 | /* - accept the mwFileTransfer |
| 2151 | - open/create the local FILE "wb" | |
| 2152 | - stick the FILE's fp in xfer->dest_fp | |
| 2153 | */ | |
| 2154 | ||
| 2155 | struct mwFileTransfer *ft; | |
| 2156 | FILE *fp; | |
| 2157 | ||
| 2158 | ft = xfer->data; | |
| 2159 | ||
| 2160 | fp = g_fopen(xfer->local_filename, "wb"); | |
| 2161 | if(! fp) { | |
| 2162 | mwFileTransfer_cancel(ft); | |
| 2163 | return; | |
| 2164 | } | |
| 2165 | ||
| 2166 | xfer->dest_fp = fp; | |
| 2167 | mwFileTransfer_accept(ft); | |
| 2168 | } | |
| 2169 | ||
| 2170 | ||
| 2171 | static void mw_ft_offered(struct mwFileTransfer *ft) { | |
| 2172 | /* | |
| 15884 | 2173 | - create a purple ft object |
| 10977 | 2174 | - offer it |
| 2175 | */ | |
| 2176 | ||
| 2177 | struct mwServiceFileTransfer *srvc; | |
| 2178 | struct mwSession *session; | |
| 15884 | 2179 | struct mwPurplePluginData *pd; |
| 2180 | PurpleConnection *gc; | |
| 2181 | PurpleAccount *acct; | |
| 10977 | 2182 | const char *who; |
| 15884 | 2183 | PurpleXfer *xfer; |
| 10977 | 2184 | |
| 2185 | /* @todo add some safety checks */ | |
| 2186 | srvc = mwFileTransfer_getService(ft); | |
| 2187 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2188 | pd = mwSession_getClientData(session); | |
| 2189 | gc = pd->gc; | |
| 15884 | 2190 | acct = purple_connection_get_account(gc); |
| 10977 | 2191 | |
| 2192 | who = mwFileTransfer_getUser(ft)->user; | |
| 2193 | ||
| 2194 | DEBUG_INFO("file transfer %p offered\n", ft); | |
| 2195 | DEBUG_INFO(" from: %s\n", NSTR(who)); | |
| 2196 | DEBUG_INFO(" file: %s\n", NSTR(mwFileTransfer_getFileName(ft))); | |
| 2197 | DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft)); | |
| 2198 | DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft))); | |
| 2199 | ||
| 15884 | 2200 | xfer = purple_xfer_new(acct, PURPLE_XFER_RECEIVE, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2201 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2202 | { |
| 15884 | 2203 | purple_xfer_ref(xfer); |
| 2204 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2205 | xfer->data = ft; |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2206 | |
| 15884 | 2207 | purple_xfer_set_init_fnc(xfer, ft_incoming_init); |
| 2208 | purple_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); | |
| 2209 | purple_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); | |
| 2210 | ||
| 2211 | purple_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); | |
| 2212 | purple_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); | |
| 2213 | purple_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); | |
| 2214 | ||
| 2215 | purple_xfer_request(xfer); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2216 | } |
| 10977 | 2217 | } |
| 2218 | ||
| 2219 | ||
| 2220 | static void ft_send(struct mwFileTransfer *ft, FILE *fp) { | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2221 | guchar buf[MW_FT_LEN]; |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2222 | struct mwOpaque o = { .data = buf, .len = MW_FT_LEN }; |
| 10977 | 2223 | guint32 rem; |
| 15884 | 2224 | PurpleXfer *xfer; |
| 10977 | 2225 | |
| 2226 | xfer = mwFileTransfer_getClientData(ft); | |
| 2227 | ||
| 2228 | rem = mwFileTransfer_getRemaining(ft); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2229 | if(rem < MW_FT_LEN) o.len = rem; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2230 | |
| 10977 | 2231 | if(fread(buf, (size_t) o.len, 1, fp)) { |
| 2232 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2233 | /* calculate progress and display it */ |
| 10977 | 2234 | xfer->bytes_sent += o.len; |
| 2235 | xfer->bytes_remaining -= o.len; | |
| 15884 | 2236 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2237 | |
| 10977 | 2238 | mwFileTransfer_send(ft, &o); |
| 2239 | ||
| 2240 | } else { | |
| 2241 | int err = errno; | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2242 | 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
|
2243 | NSTR(mwFileTransfer_getFileName(ft)), g_strerror(err)); |
| 10977 | 2244 | |
| 2245 | mwFileTransfer_cancel(ft); | |
| 2246 | } | |
| 2247 | } | |
| 2248 | ||
| 2249 | ||
| 2250 | static void mw_ft_opened(struct mwFileTransfer *ft) { | |
| 2251 | /* | |
| 15884 | 2252 | - get purple ft from client data in ft |
| 10977 | 2253 | - set the state to active |
| 2254 | */ | |
| 2255 | ||
| 15884 | 2256 | PurpleXfer *xfer; |
| 10977 | 2257 | |
| 2258 | xfer = mwFileTransfer_getClientData(ft); | |
| 2259 | ||
| 2260 | if(! xfer) { | |
| 2261 | mwFileTransfer_cancel(ft); | |
| 2262 | mwFileTransfer_free(ft); | |
| 2263 | g_return_if_reached(); | |
| 2264 | } | |
| 2265 | ||
| 15884 | 2266 | if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
| 10977 | 2267 | xfer->dest_fp = g_fopen(xfer->local_filename, "rb"); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2268 | ft_send(ft, xfer->dest_fp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2269 | } |
| 10977 | 2270 | } |
| 2271 | ||
| 2272 | ||
| 2273 | static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
| 2274 | /* | |
| 15884 | 2275 | - get purple ft from client data in ft |
| 10977 | 2276 | - indicate rejection/cancelation/completion |
| 2277 | - free the file transfer itself | |
| 2278 | */ | |
| 2279 | ||
| 15884 | 2280 | PurpleXfer *xfer; |
| 10977 | 2281 | |
| 2282 | xfer = mwFileTransfer_getClientData(ft); | |
| 2283 | if(xfer) { | |
| 2284 | xfer->data = NULL; | |
| 2285 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2286 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2287 | purple_xfer_set_completed(xfer, TRUE); |
| 2288 | purple_xfer_end(xfer); | |
| 10977 | 2289 | |
| 2290 | } else if(mwFileTransfer_isCancelLocal(ft)) { | |
| 15884 | 2291 | /* calling purple_xfer_cancel_local is redundant, since that's |
| 10977 | 2292 | probably what triggered this function to be called */ |
| 2293 | ; | |
| 2294 | ||
| 2295 | } else if(mwFileTransfer_isCancelRemote(ft)) { | |
| 2296 | /* steal the reference for the xfer */ | |
| 2297 | mwFileTransfer_setClientData(ft, NULL, NULL); | |
| 15884 | 2298 | purple_xfer_cancel_remote(xfer); |
| 10977 | 2299 | |
| 2300 | /* drop the stolen reference */ | |
| 15884 | 2301 | purple_xfer_unref(xfer); |
| 10977 | 2302 | return; |
| 2303 | } | |
| 2304 | } | |
| 2305 | ||
| 2306 | mwFileTransfer_free(ft); | |
| 2307 | } | |
| 2308 | ||
| 2309 | ||
| 2310 | static void mw_ft_recv(struct mwFileTransfer *ft, | |
| 2311 | struct mwOpaque *data) { | |
| 2312 | /* | |
| 15884 | 2313 | - get purple ft from client data in ft |
| 10977 | 2314 | - update transfered percentage |
| 15884 | 2315 | - if done, destroy the ft, disassociate from purple ft |
| 10977 | 2316 | */ |
| 2317 | ||
| 15884 | 2318 | PurpleXfer *xfer; |
| 10977 | 2319 | 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
|
2320 | size_t wc; |
| 10977 | 2321 | |
| 2322 | xfer = mwFileTransfer_getClientData(ft); | |
| 2323 | g_return_if_fail(xfer != NULL); | |
| 2324 | ||
| 2325 | fp = xfer->dest_fp; | |
| 2326 | g_return_if_fail(fp != NULL); | |
| 2327 | ||
| 2328 | /* 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
|
2329 | 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
|
2330 | 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
|
2331 | 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
|
2332 | 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
|
2333 | return; |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2334 | } |
| 10977 | 2335 | |
| 2336 | /* update the progress */ | |
| 2337 | xfer->bytes_sent += data->len; | |
| 2338 | xfer->bytes_remaining -= data->len; | |
| 15884 | 2339 | purple_xfer_update_progress(xfer); |
| 10977 | 2340 | |
| 2341 | /* let the other side know we got it, and to send some more */ | |
| 2342 | mwFileTransfer_ack(ft); | |
| 2343 | } | |
| 2344 | ||
| 2345 | ||
| 2346 | static void mw_ft_ack(struct mwFileTransfer *ft) { | |
| 15884 | 2347 | PurpleXfer *xfer; |
| 10977 | 2348 | |
| 2349 | xfer = mwFileTransfer_getClientData(ft); | |
| 2350 | g_return_if_fail(xfer != NULL); | |
| 2351 | g_return_if_fail(xfer->watcher == 0); | |
| 2352 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2353 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2354 | purple_xfer_set_completed(xfer, TRUE); |
| 2355 | purple_xfer_end(xfer); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2356 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2357 | } else if(mwFileTransfer_isOpen(ft)) { |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2358 | ft_send(ft, xfer->dest_fp); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2359 | } |
| 10977 | 2360 | } |
| 2361 | ||
| 2362 | ||
| 2363 | static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
| 2364 | ; | |
| 2365 | } | |
| 2366 | ||
| 2367 | ||
| 2368 | static struct mwFileTransferHandler mw_ft_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2369 | mw_ft_offered, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2370 | mw_ft_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2371 | mw_ft_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2372 | mw_ft_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2373 | mw_ft_ack, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2374 | mw_ft_clear, |
| 10977 | 2375 | }; |
| 2376 | ||
| 2377 | ||
| 2378 | static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
| 2379 | struct mwServiceFileTransfer *srvc; | |
| 2380 | GHashTable *ft_map; | |
| 2381 | ||
| 2382 | ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 2383 | ||
| 2384 | srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
| 2385 | mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
| 2386 | (GDestroyNotify) g_hash_table_destroy); | |
| 2387 | ||
| 2388 | return srvc; | |
| 2389 | } | |
| 2390 | ||
| 2391 | ||
| 2392 | static void convo_data_free(struct convo_data *cd) { | |
| 2393 | GList *l; | |
| 2394 | ||
| 2395 | /* clean the queue */ | |
| 2396 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2397 | struct convo_msg *m = l->data; | |
| 2398 | if(m->clear) m->clear(m->data); | |
| 2399 | g_free(m); | |
| 2400 | } | |
| 2401 | ||
| 2402 | g_free(cd); | |
| 2403 | } | |
| 2404 | ||
| 2405 | ||
| 2406 | /** allocates a convo_data structure and associates it with the | |
| 2407 | conversation in the client data slot */ | |
| 2408 | static void convo_data_new(struct mwConversation *conv) { | |
| 2409 | struct convo_data *cd; | |
| 2410 | ||
| 2411 | g_return_if_fail(conv != NULL); | |
| 2412 | ||
| 2413 | if(mwConversation_getClientData(conv)) | |
| 2414 | return; | |
| 2415 | ||
| 2416 | cd = g_new0(struct convo_data, 1); | |
| 2417 | cd->conv = conv; | |
| 2418 | ||
| 2419 | mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
| 2420 | } | |
| 2421 | ||
| 2422 | ||
| 15884 | 2423 | static PurpleConversation *convo_get_gconv(struct mwConversation *conv) { |
| 10977 | 2424 | struct mwServiceIm *srvc; |
| 2425 | struct mwSession *session; | |
| 15884 | 2426 | struct mwPurplePluginData *pd; |
| 2427 | PurpleConnection *gc; | |
| 2428 | PurpleAccount *acct; | |
| 10977 | 2429 | |
| 2430 | struct mwIdBlock *idb; | |
| 2431 | ||
| 2432 | srvc = mwConversation_getService(conv); | |
| 2433 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2434 | pd = mwSession_getClientData(session); | |
| 2435 | gc = pd->gc; | |
| 15884 | 2436 | acct = purple_connection_get_account(gc); |
| 10977 | 2437 | |
| 2438 | idb = mwConversation_getTarget(conv); | |
| 2439 | ||
| 15884 | 2440 | 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
|
2441 | idb->user, acct); |
| 10977 | 2442 | } |
| 2443 | ||
| 2444 | ||
| 2445 | static void convo_queue(struct mwConversation *conv, | |
| 2446 | enum mwImSendType type, gconstpointer data) { | |
| 2447 | ||
| 2448 | struct convo_data *cd; | |
| 2449 | struct convo_msg *m; | |
| 2450 | ||
| 2451 | convo_data_new(conv); | |
| 2452 | cd = mwConversation_getClientData(conv); | |
| 2453 | ||
| 2454 | m = g_new0(struct convo_msg, 1); | |
| 2455 | m->type = type; | |
| 2456 | ||
| 2457 | switch(type) { | |
| 2458 | case mwImSend_PLAIN: | |
| 2459 | m->data = g_strdup(data); | |
| 2460 | m->clear = g_free; | |
| 2461 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2462 | |
| 10977 | 2463 | case mwImSend_TYPING: |
| 2464 | default: | |
| 2465 | m->data = (gpointer) data; | |
| 2466 | m->clear = NULL; | |
| 2467 | } | |
| 2468 | ||
| 2469 | cd->queue = g_list_append(cd->queue, m); | |
| 2470 | } | |
| 2471 | ||
| 2472 | ||
| 2473 | /* Does what it takes to get an error displayed for a conversation */ | |
| 2474 | static void convo_error(struct mwConversation *conv, guint32 err) { | |
| 15884 | 2475 | PurpleConversation *gconv; |
| 10977 | 2476 | char *tmp, *text; |
| 2477 | struct mwIdBlock *idb; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2478 | |
| 10977 | 2479 | idb = mwConversation_getTarget(conv); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2480 | |
| 10977 | 2481 | tmp = mwError(err); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2482 | text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2483 | |
| 10977 | 2484 | gconv = convo_get_gconv(conv); |
| 15884 | 2485 | 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
|
2486 | |
| 10977 | 2487 | g_free(text); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2488 | text = g_strdup_printf(_("Unable to send message to %s:"), |
| 10977 | 2489 | (idb->user)? idb->user: "(unknown)"); |
| 15884 | 2490 | purple_notify_error(purple_account_get_connection(gconv->account), |
| 10977 | 2491 | NULL, text, tmp); |
| 2492 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2493 | |
| 10977 | 2494 | g_free(tmp); |
| 2495 | g_free(text); | |
| 2496 | } | |
| 2497 | ||
| 2498 | ||
| 2499 | static void convo_queue_send(struct mwConversation *conv) { | |
| 2500 | struct convo_data *cd; | |
| 2501 | GList *l; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2502 | |
| 10977 | 2503 | cd = mwConversation_getClientData(conv); |
| 2504 | ||
| 2505 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2506 | struct convo_msg *m = l->data; | |
| 2507 | ||
| 2508 | mwConversation_send(conv, m->type, m->data); | |
| 2509 | ||
| 2510 | if(m->clear) m->clear(m->data); | |
| 2511 | g_free(m); | |
| 2512 | } | |
| 2513 | ||
| 2514 | cd->queue = NULL; | |
| 2515 | } | |
| 2516 | ||
| 2517 | ||
| 15884 | 2518 | /** called when a mw conversation leaves a purple conversation to |
| 2519 | inform the purple conversation that it's unsafe to offer any *cool* | |
| 10977 | 2520 | features. */ |
| 2521 | static void convo_nofeatures(struct mwConversation *conv) { | |
| 15884 | 2522 | PurpleConversation *gconv; |
| 2523 | PurpleConnection *gc; | |
| 10977 | 2524 | |
| 2525 | gconv = convo_get_gconv(conv); | |
| 2526 | if(! gconv) return; | |
| 2527 | ||
| 15884 | 2528 | gc = purple_conversation_get_gc(gconv); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2529 | if(! gc) return; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2530 | |
| 15884 | 2531 | purple_conversation_set_features(gconv, gc->flags); |
| 2532 | } | |
| 2533 | ||
| 2534 | ||
| 2535 | /** called when a mw conversation and purple conversation come together, | |
| 2536 | to inform the purple conversation of what features to offer the | |
| 10977 | 2537 | user */ |
| 2538 | static void convo_features(struct mwConversation *conv) { | |
| 15884 | 2539 | PurpleConversation *gconv; |
| 2540 | PurpleConnectionFlags feat; | |
| 10977 | 2541 | |
| 2542 | gconv = convo_get_gconv(conv); | |
| 2543 | if(! gconv) return; | |
| 2544 | ||
| 15884 | 2545 | feat = purple_conversation_get_features(gconv); |
| 10977 | 2546 | |
| 2547 | if(mwConversation_isOpen(conv)) { | |
| 2548 | if(mwConversation_supports(conv, mwImSend_HTML)) { | |
| 15884 | 2549 | feat |= PURPLE_CONNECTION_HTML; |
| 10977 | 2550 | } else { |
| 15884 | 2551 | feat &= ~PURPLE_CONNECTION_HTML; |
| 10977 | 2552 | } |
| 2553 | ||
| 2554 | if(mwConversation_supports(conv, mwImSend_MIME)) { | |
| 15884 | 2555 | feat &= ~PURPLE_CONNECTION_NO_IMAGES; |
| 10977 | 2556 | } else { |
| 15884 | 2557 | feat |= PURPLE_CONNECTION_NO_IMAGES; |
| 10977 | 2558 | } |
| 2559 | ||
| 2560 | DEBUG_INFO("conversation features set to 0x%04x\n", feat); | |
| 15884 | 2561 | purple_conversation_set_features(gconv, feat); |
| 10977 | 2562 | |
| 2563 | } else { | |
| 2564 | convo_nofeatures(conv); | |
| 2565 | } | |
| 2566 | } | |
| 2567 | ||
| 2568 | ||
| 2569 | static void mw_conversation_opened(struct mwConversation *conv) { | |
| 2570 | struct mwServiceIm *srvc; | |
| 2571 | struct mwSession *session; | |
| 15884 | 2572 | struct mwPurplePluginData *pd; |
| 2573 | PurpleConnection *gc; | |
| 2574 | PurpleAccount *acct; | |
| 10977 | 2575 | |
| 2576 | struct convo_dat *cd; | |
| 2577 | ||
| 2578 | srvc = mwConversation_getService(conv); | |
| 2579 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2580 | pd = mwSession_getClientData(session); | |
| 2581 | gc = pd->gc; | |
| 15884 | 2582 | acct = purple_connection_get_account(gc); |
| 10977 | 2583 | |
| 2584 | /* set up the queue */ | |
| 2585 | cd = mwConversation_getClientData(conv); | |
| 2586 | if(cd) { | |
| 2587 | convo_queue_send(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2588 | |
| 10977 | 2589 | if(! convo_get_gconv(conv)) { |
| 2590 | mwConversation_free(conv); | |
| 2591 | return; | |
| 2592 | } | |
| 2593 | ||
| 2594 | } else { | |
| 2595 | convo_data_new(conv); | |
| 2596 | } | |
| 2597 | ||
| 2598 | { /* record the client key for the buddy */ | |
| 15884 | 2599 | PurpleBuddy *buddy; |
| 10977 | 2600 | struct mwLoginInfo *info; |
| 2601 | info = mwConversation_getTargetInfo(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2602 | |
| 15884 | 2603 | buddy = purple_find_buddy(acct, info->user_id); |
| 10977 | 2604 | if(buddy) { |
| 15884 | 2605 | purple_blist_node_set_int((PurpleBlistNode *) buddy, |
| 10977 | 2606 | BUDDY_KEY_CLIENT, info->type); |
| 2607 | } | |
| 2608 | } | |
| 2609 | ||
| 2610 | convo_features(conv); | |
| 2611 | } | |
| 2612 | ||
| 2613 | ||
| 2614 | static void mw_conversation_closed(struct mwConversation *conv, | |
| 2615 | guint32 reason) { | |
| 2616 | ||
| 2617 | struct convo_data *cd; | |
| 2618 | ||
| 2619 | g_return_if_fail(conv != NULL); | |
| 2620 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2621 | /* 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
|
2622 | print an error message to the conversation */ |
| 10977 | 2623 | cd = mwConversation_getClientData(conv); |
| 2624 | if(reason && cd && cd->queue) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2625 | GList *l; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2626 | for(l = cd->queue; l; l = l->next) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2627 | struct convo_msg *m = l->data; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2628 | if(m->type != mwImSend_TYPING) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2629 | convo_error(conv, reason); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2630 | break; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2631 | } |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2632 | } |
| 10977 | 2633 | } |
| 2634 | ||
| 2635 | #if 0 | |
| 2636 | /* don't do this, to prevent the occasional weird sending of | |
| 2637 | formatted messages as plaintext when the other end closes the | |
| 2638 | conversation after we've begun composing the message */ | |
| 2639 | convo_nofeatures(conv); | |
| 2640 | #endif | |
| 2641 | ||
| 2642 | mwConversation_removeClientData(conv); | |
| 2643 | } | |
| 2644 | ||
| 2645 | ||
| 2646 | static void im_recv_text(struct mwConversation *conv, | |
| 15884 | 2647 | struct mwPurplePluginData *pd, |
| 10977 | 2648 | const char *msg) { |
| 2649 | ||
| 2650 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2651 | char *txt, *esc; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2652 | const char *t; |
| 10977 | 2653 | |
| 2654 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2655 | |
| 15884 | 2656 | txt = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2657 | t = txt? txt: msg; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2658 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2659 | esc = g_markup_escape_text(t, -1); |
| 10977 | 2660 | 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
|
2661 | g_free(esc); |
| 10977 | 2662 | |
| 2663 | g_free(txt); | |
| 2664 | } | |
| 2665 | ||
| 2666 | ||
| 2667 | static void im_recv_typing(struct mwConversation *conv, | |
| 15884 | 2668 | struct mwPurplePluginData *pd, |
| 10977 | 2669 | gboolean typing) { |
| 2670 | ||
| 2671 | struct mwIdBlock *idb; | |
| 2672 | idb = mwConversation_getTarget(conv); | |
| 2673 | ||
| 2674 | serv_got_typing(pd->gc, idb->user, 0, | |
| 15884 | 2675 | typing? PURPLE_TYPING: PURPLE_NOT_TYPING); |
| 10977 | 2676 | } |
| 2677 | ||
| 2678 | ||
| 2679 | static void im_recv_html(struct mwConversation *conv, | |
| 15884 | 2680 | struct mwPurplePluginData *pd, |
| 10977 | 2681 | const char *msg) { |
| 2682 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2683 | char *t1, *t2; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2684 | const char *t; |
| 10977 | 2685 | |
| 2686 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2687 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2688 | /* ensure we're receiving UTF8 */ |
| 15884 | 2689 | t1 = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2690 | t = t1? t1: msg; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2691 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2692 | /* convert entities to UTF8 so they'll log correctly */ |
| 15884 | 2693 | t2 = purple_utf8_ncr_decode(t); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2694 | t = t2? t2: t; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2695 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2696 | serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
| 10977 | 2697 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2698 | g_free(t1); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2699 | g_free(t2); |
| 10977 | 2700 | } |
| 2701 | ||
| 2702 | ||
| 2703 | static void im_recv_subj(struct mwConversation *conv, | |
| 15884 | 2704 | struct mwPurplePluginData *pd, |
| 10977 | 2705 | const char *subj) { |
| 2706 | ||
| 2707 | /** @todo somehow indicate receipt of a conversation subject. It | |
| 2708 | would also be nice if we added a /topic command for the | |
| 2709 | protocol */ | |
| 2710 | ; | |
| 2711 | } | |
| 2712 | ||
| 2713 | ||
| 2714 | /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */ | |
| 2715 | static char *make_cid(const char *cid) { | |
| 2716 | gsize n; | |
| 2717 | char *c, *d; | |
| 2718 | ||
| 2719 | g_return_val_if_fail(cid != NULL, NULL); | |
| 2720 | ||
| 2721 | n = strlen(cid); | |
| 2722 | g_return_val_if_fail(n > 2, NULL); | |
| 2723 | ||
| 2724 | c = g_strndup(cid+1, n-2); | |
| 2725 | d = g_strdup_printf("cid:%s", c); | |
| 2726 | ||
| 2727 | g_free(c); | |
| 2728 | return d; | |
| 2729 | } | |
| 2730 | ||
| 2731 | ||
| 2732 | static void im_recv_mime(struct mwConversation *conv, | |
| 15884 | 2733 | struct mwPurplePluginData *pd, |
| 10977 | 2734 | const char *data) { |
| 2735 | ||
| 2736 | GHashTable *img_by_cid; | |
| 2737 | GList *images; | |
| 2738 | ||
| 2739 | GString *str; | |
| 2740 | ||
| 15884 | 2741 | 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
|
2742 | GList *parts; |
| 10977 | 2743 | |
| 2744 | img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
| 2745 | images = NULL; | |
| 2746 | ||
| 2747 | /* don't want the contained string to ever be NULL */ | |
| 2748 | str = g_string_new(""); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2749 | |
| 15884 | 2750 | doc = purple_mime_document_parse(data); |
| 10977 | 2751 | |
| 2752 | /* handle all the MIME parts */ | |
| 15884 | 2753 | parts = purple_mime_document_get_parts(doc); |
| 10977 | 2754 | for(; parts; parts = parts->next) { |
| 15884 | 2755 | PurpleMimePart *part = parts->data; |
| 10977 | 2756 | const char *type; |
| 2757 | ||
| 15884 | 2758 | type = purple_mime_part_get_field(part, "content-type"); |
| 10977 | 2759 | DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type)); |
| 2760 | ||
| 2761 | if(! type) { | |
| 2762 | ; /* feh */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2763 | |
| 15884 | 2764 | } else if(purple_str_has_prefix(type, "image")) { |
| 10977 | 2765 | /* put images into the image store */ |
| 2766 | ||
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2767 | guchar *d_dat; |
| 10977 | 2768 | gsize d_len; |
| 2769 | char *cid; | |
| 2770 | int img; | |
| 2771 | ||
| 2772 | /* obtain and unencode the data */ | |
| 15884 | 2773 | 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
|
2774 | |
| 10977 | 2775 | /* look up the content id */ |
| 15884 | 2776 | cid = (char *) purple_mime_part_get_field(part, "Content-ID"); |
| 10977 | 2777 | cid = make_cid(cid); |
| 2778 | ||
| 15884 | 2779 | /* 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
|
2780 | img = purple_imgstore_add_with_id(d_dat, d_len, cid); |
| 10977 | 2781 | |
| 2782 | /* map the cid to the image store identifier */ | |
| 2783 | g_hash_table_insert(img_by_cid, cid, GINT_TO_POINTER(img)); | |
| 2784 | ||
| 2785 | /* recall the image for dereferencing later */ | |
| 2786 | images = g_list_append(images, GINT_TO_POINTER(img)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2787 | |
| 15884 | 2788 | } else if(purple_str_has_prefix(type, "text")) { |
| 10977 | 2789 | |
| 2790 | /* concatenate all the text parts together */ | |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2791 | guchar *data; |
| 10977 | 2792 | gsize len; |
| 2793 | ||
| 15884 | 2794 | purple_mime_part_get_data_decoded(part, &data, &len); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2795 | g_string_append(str, (const char *)data); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2796 | g_free(data); |
| 10977 | 2797 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2798 | } |
| 10977 | 2799 | |
| 15884 | 2800 | purple_mime_document_free(doc); |
| 10977 | 2801 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2802 | /* @todo should put this in its own function */ |
| 10977 | 2803 | { /* replace each IMG tag's SRC attribute with an ID attribute. This |
| 2804 | actually modifies the contents of str */ | |
| 2805 | GData *attribs; | |
| 2806 | char *start, *end; | |
| 2807 | char *tmp = str->str; | |
| 2808 | ||
| 15884 | 2809 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 2810 | (const char **) &end, &attribs)) { |
| 2811 | ||
| 2812 | char *alt, *align, *border, *src; | |
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2813 | int img = 0; |
| 10977 | 2814 | |
| 2815 | alt = g_datalist_get_data(&attribs, "alt"); | |
| 2816 | align = g_datalist_get_data(&attribs, "align"); | |
| 2817 | border = g_datalist_get_data(&attribs, "border"); | |
| 2818 | src = g_datalist_get_data(&attribs, "src"); | |
| 2819 | ||
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2820 | if(src) |
|
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2821 | 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
|
2822 | |
| 10977 | 2823 | if(img) { |
| 2824 | GString *atstr; | |
| 2825 | gsize len = (end - start); | |
| 2826 | gsize mov; | |
| 2827 | ||
| 2828 | atstr = g_string_new(""); | |
| 2829 | if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt); | |
| 2830 | if(align) g_string_append_printf(atstr, " align=\"%s\"", align); | |
| 2831 | if(border) g_string_append_printf(atstr, " border=\"%s\"", border); | |
| 2832 | ||
| 2833 | mov = g_snprintf(start, len, "<img%s id=\"%i\"", atstr->str, img); | |
| 2834 | while(mov < len) start[mov++] = ' '; | |
| 2835 | ||
| 2836 | g_string_free(atstr, TRUE); | |
| 2837 | } | |
| 2838 | ||
| 2839 | g_datalist_clear(&attribs); | |
| 2840 | tmp = end + 1; | |
| 2841 | } | |
| 2842 | } | |
| 2843 | ||
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2844 | im_recv_html(conv, pd, str->str); |
| 10977 | 2845 | |
| 2846 | g_string_free(str, TRUE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2847 | |
| 10977 | 2848 | /* clean up the cid table */ |
| 2849 | g_hash_table_destroy(img_by_cid); | |
| 2850 | ||
| 2851 | /* dereference all the imgages */ | |
| 2852 | 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
|
2853 | purple_imgstore_unref_by_id(GPOINTER_TO_INT(images->data)); |
| 10977 | 2854 | images = g_list_delete_link(images, images); |
| 2855 | } | |
| 2856 | } | |
| 2857 | ||
| 2858 | ||
| 2859 | static void mw_conversation_recv(struct mwConversation *conv, | |
| 2860 | enum mwImSendType type, | |
| 2861 | gconstpointer msg) { | |
| 2862 | struct mwServiceIm *srvc; | |
| 2863 | struct mwSession *session; | |
| 15884 | 2864 | struct mwPurplePluginData *pd; |
| 10977 | 2865 | |
| 2866 | srvc = mwConversation_getService(conv); | |
| 2867 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2868 | pd = mwSession_getClientData(session); | |
| 2869 | ||
| 2870 | switch(type) { | |
| 2871 | case mwImSend_PLAIN: | |
| 2872 | im_recv_text(conv, pd, msg); | |
| 2873 | break; | |
| 2874 | ||
| 2875 | case mwImSend_TYPING: | |
| 2876 | im_recv_typing(conv, pd, !! msg); | |
| 2877 | break; | |
| 2878 | ||
| 2879 | case mwImSend_HTML: | |
| 2880 | im_recv_html(conv, pd, msg); | |
| 2881 | break; | |
| 2882 | ||
| 2883 | case mwImSend_SUBJECT: | |
| 2884 | im_recv_subj(conv, pd, msg); | |
| 2885 | break; | |
| 2886 | ||
| 2887 | case mwImSend_MIME: | |
| 2888 | im_recv_mime(conv, pd, msg); | |
| 2889 | break; | |
| 2890 | ||
| 2891 | default: | |
| 2892 | DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
| 2893 | ; /* erm... */ | |
| 2894 | } | |
| 2895 | } | |
| 2896 | ||
| 2897 | ||
| 2898 | static void mw_place_invite(struct mwConversation *conv, | |
| 2899 | const char *message, | |
| 2900 | const char *title, const char *name) { | |
| 2901 | struct mwServiceIm *srvc; | |
| 2902 | struct mwSession *session; | |
| 15884 | 2903 | struct mwPurplePluginData *pd; |
| 10977 | 2904 | |
| 2905 | struct mwIdBlock *idb; | |
| 2906 | GHashTable *ht; | |
| 2907 | ||
| 2908 | srvc = mwConversation_getService(conv); | |
| 2909 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2910 | pd = mwSession_getClientData(session); | |
| 2911 | ||
| 2912 | idb = mwConversation_getTarget(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2913 | |
| 10977 | 2914 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 2915 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
| 2916 | g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
| 2917 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
| 2918 | 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
|
2919 | g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
| 10977 | 2920 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2921 | if(! title) title = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2922 | if(! message) message = "(no message)"; |
| 10977 | 2923 | 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
|
2924 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2925 | mwConversation_close(conv, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2926 | mwConversation_free(conv); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2927 | } |
| 10977 | 2928 | |
| 2929 | ||
| 2930 | static void mw_im_clear(struct mwServiceIm *srvc) { | |
| 2931 | ; | |
| 2932 | } | |
| 2933 | ||
| 2934 | ||
| 2935 | static struct mwImHandler mw_im_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2936 | mw_conversation_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2937 | mw_conversation_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2938 | mw_conversation_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2939 | mw_place_invite, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2940 | mw_im_clear, |
| 10977 | 2941 | }; |
| 2942 | ||
| 2943 | ||
| 2944 | static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
| 2945 | struct mwServiceIm *srvc; | |
| 2946 | srvc = mwServiceIm_new(s, &mw_im_handler); | |
| 2947 | mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
| 2948 | return srvc; | |
| 2949 | } | |
| 2950 | ||
| 2951 | ||
| 15884 | 2952 | /* 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
|
2953 | 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
|
2954 | the similar macros from the conference service above */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2955 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2956 | #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2957 | #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
|
2958 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2959 | #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
|
2960 | #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
|
2961 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2962 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2963 | static struct mwPlace * |
| 15884 | 2964 | place_find_by_id(struct mwPurplePluginData *pd, int id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2965 | struct mwServicePlace *srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2966 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2967 | GList *l; |
|
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 | l = (GList *) mwServicePlace_getPlaces(srvc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2970 | for(; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2971 | struct mwPlace *p = l->data; |
| 15884 | 2972 | PurpleConvChat *h = PURPLE_CONV_CHAT(mwPlace_getClientData(p)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2973 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2974 | if(CHAT_TO_ID(h) == id) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2975 | place = p; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2976 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2977 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2978 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2979 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2980 | return place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2981 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2982 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2983 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2984 | static void mw_place_opened(struct mwPlace *place) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2985 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2986 | struct mwSession *session; |
| 15884 | 2987 | struct mwPurplePluginData *pd; |
| 2988 | PurpleConnection *gc; | |
| 2989 | PurpleConversation *gconf; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2990 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2991 | GList *members, *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2992 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2993 | const char *n = mwPlace_getName(place); |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2994 | const char *t = mwPlace_getTitle(place); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2995 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2996 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2997 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2998 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2999 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3000 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3001 | members = mwPlace_getMembers(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3002 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3003 | DEBUG_INFO("place %s opened, %u initial members\n", |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3004 | NSTR(n), g_list_length(members)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3005 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
3006 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
3007 | 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
|
3008 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3009 | mwPlace_setClientData(place, gconf, NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3010 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3011 | for(l = members; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3012 | struct mwIdBlock *idb = l->data; |
| 15884 | 3013 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(gconf), idb->user, |
| 3014 | NULL, PURPLE_CBFLAGS_NONE, FALSE); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3015 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3016 | g_list_free(members); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3017 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3018 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3019 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3020 | static void mw_place_closed(struct mwPlace *place, guint32 code) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3021 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3022 | struct mwSession *session; |
| 15884 | 3023 | struct mwPurplePluginData *pd; |
| 3024 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3025 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3026 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3027 | char *msg = mwError(code); |
|
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 | 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
|
3030 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3031 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3032 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3033 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3034 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3035 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3036 | serv_got_chat_left(gc, PLACE_TO_ID(place)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3037 | |
| 15884 | 3038 | purple_notify_error(gc, _("Place Closed"), NULL, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3039 | g_free(msg); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3040 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3041 | |
|
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 | static void mw_place_peerJoined(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3044 | const struct mwIdBlock *peer) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3045 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3046 | struct mwSession *session; |
| 15884 | 3047 | struct mwPurplePluginData *pd; |
| 3048 | PurpleConnection *gc; | |
| 3049 | PurpleConversation *gconf; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3050 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3051 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3052 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3053 | DEBUG_INFO("%s joined place %s\n", NSTR(peer->user), NSTR(n)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3054 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3055 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3056 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3057 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3058 | gc = pd->gc; |
|
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 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3061 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3062 | |
| 15884 | 3063 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(gconf), peer->user, |
| 3064 | NULL, PURPLE_CBFLAGS_NONE, TRUE); | |
|
11943
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3068 | static void mw_place_peerParted(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3069 | const struct mwIdBlock *peer) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3070 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3071 | struct mwSession *session; |
| 15884 | 3072 | struct mwPurplePluginData *pd; |
| 3073 | PurpleConnection *gc; | |
| 3074 | PurpleConversation *gconf; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3075 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3076 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3077 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3078 | 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
|
3079 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3080 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3081 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3082 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3083 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3084 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3085 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3086 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3087 | |
| 15884 | 3088 | 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
|
3089 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3090 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3091 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3092 | static void mw_place_peerSetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3093 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3094 | guint32 attr, struct mwOpaque *o) { |
|
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 | } |
|
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 | static void mw_place_peerUnsetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3100 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3101 | guint32 attr) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3102 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3103 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3104 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3105 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3106 | static void mw_place_message(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3107 | const struct mwIdBlock *who, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3108 | const char *msg) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3109 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3110 | struct mwSession *session; |
| 15884 | 3111 | struct mwPurplePluginData *pd; |
| 3112 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3113 | char *esc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3114 | |
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3115 | if(! msg) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3116 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3117 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3118 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3119 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3120 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3121 | |
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
3122 | esc = g_markup_escape_text(msg, -1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3123 | 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
|
3124 | g_free(esc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3125 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3126 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3127 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3128 | static void mw_place_clear(struct mwServicePlace *srvc) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3129 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3130 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3131 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3132 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3133 | static struct mwPlaceHandler mw_place_handler = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3134 | mw_place_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3135 | mw_place_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3136 | mw_place_peerJoined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3137 | mw_place_peerParted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3138 | mw_place_peerSetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3139 | mw_place_peerUnsetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3140 | mw_place_message, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3141 | mw_place_clear, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3142 | }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3143 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3144 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3145 | static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3146 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3147 | srvc = mwServicePlace_new(s, &mw_place_handler); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3148 | return srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3149 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3150 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3151 | |
| 10977 | 3152 | static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
| 3153 | struct mwServiceResolve *srvc; | |
| 3154 | srvc = mwServiceResolve_new(s); | |
| 3155 | return srvc; | |
| 3156 | } | |
| 3157 | ||
| 3158 | ||
| 3159 | static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
| 3160 | struct mwServiceStorage *srvc; | |
| 3161 | srvc = mwServiceStorage_new(s); | |
| 3162 | return srvc; | |
| 3163 | } | |
| 3164 | ||
| 3165 | ||
| 15884 | 3166 | /** allocate and associate a mwPurplePluginData with a PurpleConnection */ |
| 3167 | static struct mwPurplePluginData *mwPurplePluginData_new(PurpleConnection *gc) { | |
| 3168 | struct mwPurplePluginData *pd; | |
| 10977 | 3169 | |
| 3170 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3171 | ||
| 15884 | 3172 | pd = g_new0(struct mwPurplePluginData, 1); |
| 10977 | 3173 | pd->gc = gc; |
| 3174 | pd->session = mwSession_new(&mw_session_handler); | |
| 3175 | pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
| 3176 | pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
| 3177 | pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
| 3178 | pd->srvc_im = mw_srvc_im_new(pd->session); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3179 | pd->srvc_place = mw_srvc_place_new(pd->session); |
| 10977 | 3180 | pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
| 3181 | pd->srvc_store = mw_srvc_store_new(pd->session); | |
| 3182 | pd->group_list_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 15884 | 3183 | pd->sock_buf = purple_circ_buffer_new(0); |
| 10977 | 3184 | |
| 3185 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
| 3186 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
| 3187 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
| 3188 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3189 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
| 10977 | 3190 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
| 3191 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
| 3192 | ||
| 3193 | 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
|
3194 | mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 10977 | 3195 | |
| 3196 | mwSession_setClientData(pd->session, pd, NULL); | |
| 3197 | gc->proto_data = pd; | |
| 3198 | ||
| 3199 | return pd; | |
| 3200 | } | |
| 3201 | ||
| 3202 | ||
| 15884 | 3203 | static void mwPurplePluginData_free(struct mwPurplePluginData *pd) { |
| 10977 | 3204 | g_return_if_fail(pd != NULL); |
| 3205 | ||
| 3206 | pd->gc->proto_data = NULL; | |
| 3207 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3208 | mwSession_removeService(pd->session, mwService_AWARE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3209 | mwSession_removeService(pd->session, mwService_CONFERENCE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3210 | mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3211 | mwSession_removeService(pd->session, mwService_IM); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3212 | mwSession_removeService(pd->session, mwService_PLACE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3213 | mwSession_removeService(pd->session, mwService_RESOLVE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3214 | mwSession_removeService(pd->session, mwService_STORAGE); |
| 10977 | 3215 | |
| 3216 | mwService_free(MW_SERVICE(pd->srvc_aware)); | |
| 3217 | mwService_free(MW_SERVICE(pd->srvc_conf)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3218 | mwService_free(MW_SERVICE(pd->srvc_ft)); |
| 10977 | 3219 | mwService_free(MW_SERVICE(pd->srvc_im)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3220 | mwService_free(MW_SERVICE(pd->srvc_place)); |
| 10977 | 3221 | mwService_free(MW_SERVICE(pd->srvc_resolve)); |
| 3222 | mwService_free(MW_SERVICE(pd->srvc_store)); | |
| 3223 | ||
| 3224 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3225 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
| 10977 | 3226 | |
| 3227 | mwSession_free(pd->session); | |
| 3228 | ||
| 3229 | g_hash_table_destroy(pd->group_list_map); | |
| 15884 | 3230 | purple_circ_buffer_destroy(pd->sock_buf); |
| 10977 | 3231 | |
| 3232 | g_free(pd); | |
| 3233 | } | |
| 3234 | ||
| 3235 | ||
| 15884 | 3236 | static const char *mw_prpl_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
| 10977 | 3237 | /* my little green dude is a chopped up version of the aim running |
| 3238 | guy. First, cut off the head and store someplace safe. Then, | |
| 3239 | take the left-half side of the body and throw it away. Make a | |
| 3240 | copy of the remaining body, and flip it horizontally. Now attach | |
| 3241 | the two pieces into an X shape, and drop the head back on the | |
| 3242 | top, being careful to center it. Then, just change the color | |
| 3243 | saturation to bring the red down a bit, and voila! */ | |
| 3244 | ||
| 3245 | /* then, throw all of that away and use sodipodi to make a new | |
| 3246 | icon. You know, LIKE A REAL MAN. */ | |
| 3247 | ||
| 3248 | return "meanwhile"; | |
| 3249 | } | |
| 3250 | ||
| 3251 | ||
| 15884 | 3252 | static const char* mw_prpl_list_emblem(PurpleBuddy *b) |
| 15524 | 3253 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3254 | if(buddy_is_external(b)) |
| 15524 | 3255 | return "external"; |
| 3256 | ||
| 3257 | return NULL; | |
| 10977 | 3258 | } |
| 3259 | ||
| 3260 | ||
| 15884 | 3261 | static char *mw_prpl_status_text(PurpleBuddy *b) { |
| 3262 | PurpleConnection *gc; | |
| 3263 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3264 | 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
|
3265 | 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
|
3266 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3267 | 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
|
3268 | && (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
|
3269 | 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
|
3270 | |
|
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
|
3271 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3272 | } |
| 3273 | ||
| 3274 | ||
| 15884 | 3275 | static const char *status_text(PurpleBuddy *b) { |
| 3276 | PurplePresence *presence; | |
| 3277 | PurpleStatus *status; | |
| 3278 | ||
| 3279 | presence = purple_buddy_get_presence(b); | |
| 3280 | status = purple_presence_get_active_status(presence); | |
| 3281 | ||
| 3282 | return purple_status_get_name(status); | |
| 10977 | 3283 | } |
| 3284 | ||
| 3285 | ||
| 3286 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3287 | const char *who, guint32 feature) { | |
| 3288 | ||
| 3289 | const struct mwAwareAttribute *attr; | |
| 3290 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3291 | ||
| 3292 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3293 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3294 | } | |
| 3295 | ||
| 3296 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3297 | 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
|
3298 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3299 | const char **f = feat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3300 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3301 | if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3302 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3303 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3304 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3305 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3306 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3307 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3308 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3309 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3310 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3311 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3312 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3313 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3314 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3315 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3316 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3317 | /* jenni loves siege */ |
| 10977 | 3318 | } |
| 3319 | ||
| 3320 | ||
| 15884 | 3321 | static void mw_prpl_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { |
| 3322 | 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
|
3323 | struct mwPurplePluginData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3324 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3325 | |
|
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
|
3326 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3327 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3328 | char *tmp; |
| 10977 | 3329 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3330 | 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
|
3331 | && (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
|
3332 | 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
|
3333 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3334 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3335 | |
|
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
|
3336 | 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
|
3337 | tmp = g_markup_escape_text(message, -1); |
| 15884 | 3338 | purple_notify_user_info_add_pair(user_info, status, tmp); |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3339 | g_free(tmp); |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3340 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3341 | } else { |
| 15884 | 3342 | purple_notify_user_info_add_pair(user_info, _("Status"), status); |
| 10977 | 3343 | } |
| 3344 | ||
|
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
|
3345 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3346 | 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
|
3347 | if(tmp) { |
| 15884 | 3348 | purple_notify_user_info_add_pair(user_info, _("Supports"), tmp); |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3349 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3350 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3351 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3352 | if(buddy_is_external(b)) { |
| 15884 | 3353 | 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
|
3354 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3355 | } |
| 10977 | 3356 | } |
| 3357 | ||
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3358 | 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
|
3359 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3360 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3361 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3362 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3363 | 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
|
3364 | 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
|
3365 | 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
|
3366 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3367 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3368 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3369 | 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
|
3370 | 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
|
3371 | 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
|
3372 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3373 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3374 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3375 | 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
|
3376 | 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
|
3377 | 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
|
3378 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3379 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3380 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3381 | 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
|
3382 | 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
|
3383 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3384 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3385 | return types; |
| 10977 | 3386 | } |
| 3387 | ||
| 3388 | ||
| 15884 | 3389 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3390 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3391 | ; /* nothing to do */ |
| 10977 | 3392 | } |
| 3393 | ||
| 3394 | ||
| 15884 | 3395 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3396 | PurpleRequestFields *fields) { | |
| 3397 | PurpleAccount *acct; | |
| 3398 | PurpleConnection *gc; | |
| 3399 | struct mwPurplePluginData *pd; | |
| 10977 | 3400 | struct mwServiceConference *srvc; |
| 3401 | ||
| 15884 | 3402 | PurpleRequestField *f; |
| 10977 | 3403 | |
| 3404 | const char *topic, *invite; | |
| 3405 | struct mwConference *conf; | |
| 3406 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3407 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3408 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3409 | gc = purple_account_get_connection(acct); |
| 10977 | 3410 | pd = gc->proto_data; |
| 3411 | srvc = pd->srvc_conf; | |
| 3412 | ||
| 15884 | 3413 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3414 | topic = purple_request_field_string_get_value(f); | |
| 3415 | ||
| 3416 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3417 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3418 | |
| 3419 | conf = mwConference_new(srvc, topic); | |
| 3420 | mwConference_open(conf); | |
| 3421 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3422 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3423 | mwConference_invite(conf, &idb, invite); |
| 3424 | } | |
| 3425 | ||
| 3426 | ||
| 15884 | 3427 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3428 | ||
| 3429 | PurpleRequestFields *fields; | |
| 3430 | PurpleRequestFieldGroup *g; | |
| 3431 | PurpleRequestField *f; | |
| 3432 | ||
| 3433 | PurpleAccount *acct; | |
| 3434 | PurpleConnection *gc; | |
| 10977 | 3435 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3436 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3437 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3438 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3439 | |
| 10977 | 3440 | g_return_if_fail(buddy != NULL); |
| 3441 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3442 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3443 | g_return_if_fail(acct != NULL); |
| 3444 | ||
| 15884 | 3445 | gc = purple_account_get_connection(acct); |
| 10977 | 3446 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3447 | |
| 15884 | 3448 | fields = purple_request_fields_new(); |
| 3449 | ||
| 3450 | g = purple_request_field_group_new(NULL); | |
| 3451 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3452 | |
| 15884 | 3453 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3454 | purple_request_field_group_add_field(g, f); | |
| 3455 | ||
| 3456 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3457 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3458 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3459 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3460 | 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
|
3461 | " 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
|
3462 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3463 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3464 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3465 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3466 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3467 | _("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
|
3468 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3469 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3470 | g_free(msg1); |
| 10977 | 3471 | } |
| 3472 | ||
| 3473 | ||
| 15884 | 3474 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3475 | PurpleRequestFields *fields) { | |
| 10977 | 3476 | ; |
| 3477 | } | |
| 3478 | ||
| 3479 | ||
| 15884 | 3480 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3481 | PurpleRequestFields *fields) { | |
| 3482 | 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
|
3483 | GList *l; |
| 10977 | 3484 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3485 | |
| 15884 | 3486 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3487 | msg = purple_request_field_string_get_value(f); | |
| 3488 | ||
| 3489 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3490 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3491 | |
| 3492 | if(l) { | |
| 15884 | 3493 | 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
|
3494 | |
| 10977 | 3495 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3496 | blist_menu_conf_create(buddy, msg); | |
| 3497 | ||
| 3498 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3499 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3500 | mwConference_invite(d, &idb, msg); |
| 3501 | } | |
| 3502 | } | |
| 3503 | } | |
| 3504 | ||
| 3505 | ||
| 15884 | 3506 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3507 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3508 | |
| 15884 | 3509 | PurpleRequestFields *fields; |
| 3510 | PurpleRequestFieldGroup *g; | |
| 3511 | PurpleRequestField *f; | |
| 3512 | ||
| 3513 | PurpleAccount *acct; | |
| 3514 | PurpleConnection *gc; | |
| 10977 | 3515 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3516 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3517 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3518 | char *msg; |
| 10977 | 3519 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3520 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3521 | g_return_if_fail(acct != NULL); |
| 3522 | ||
| 15884 | 3523 | gc = purple_account_get_connection(acct); |
| 10977 | 3524 | g_return_if_fail(gc != NULL); |
| 3525 | ||
| 15884 | 3526 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3527 | |
| 15884 | 3528 | g = purple_request_field_group_new(NULL); |
| 3529 | purple_request_fields_add_group(fields, g); | |
| 3530 | ||
| 3531 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3532 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3533 | for(; confs; confs = confs->next) { |
| 3534 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3535 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3536 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3537 | 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
|
3538 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3539 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3540 | |
| 15884 | 3541 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3542 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3543 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3544 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3545 | 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
|
3546 | " 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
|
3547 | " 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
|
3548 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3549 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3550 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3551 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3552 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3553 | _("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
|
3554 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3555 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3556 | g_free(msg); |
| 10977 | 3557 | } |
| 3558 | ||
| 3559 | ||
| 15884 | 3560 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 3561 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3562 | PurpleAccount *acct; | |
| 3563 | PurpleConnection *gc; | |
| 3564 | struct mwPurplePluginData *pd; | |
| 10977 | 3565 | GList *l; |
| 3566 | ||
| 3567 | g_return_if_fail(node != NULL); | |
| 15884 | 3568 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 10977 | 3569 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3570 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3571 | g_return_if_fail(acct != NULL); |
| 3572 | ||
| 15884 | 3573 | gc = purple_account_get_connection(acct); |
| 10977 | 3574 | g_return_if_fail(gc != NULL); |
| 3575 | ||
| 3576 | pd = gc->proto_data; | |
| 3577 | g_return_if_fail(pd != NULL); | |
| 3578 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3579 | /* |
| 10977 | 3580 | - get a list of all conferences on this session |
| 3581 | - if none, prompt to create one, and invite buddy to it | |
| 3582 | - else, prompt to select a conference or create one | |
| 3583 | */ | |
| 3584 | ||
| 3585 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3586 | if(l) { | |
| 3587 | blist_menu_conf_list(buddy, l); | |
| 3588 | g_list_free(l); | |
| 3589 | ||
| 3590 | } else { | |
| 3591 | blist_menu_conf_create(buddy, NULL); | |
| 3592 | } | |
| 3593 | } | |
| 3594 | ||
| 3595 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3596 | #if 0 |
| 15884 | 3597 | static void blist_menu_announce(PurpleBlistNode *node, gpointer data) { |
| 3598 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3599 | PurpleAccount *acct; | |
| 3600 | PurpleConnection *gc; | |
| 3601 | struct mwPurplePluginData *pd; | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3602 | struct mwSession *session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3603 | char *rcpt_name; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3604 | GList *rcpt; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3605 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3606 | g_return_if_fail(node != NULL); |
| 15884 | 3607 | 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
|
3608 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3609 | acct = buddy->account; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3610 | g_return_if_fail(acct != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3611 | |
| 15884 | 3612 | gc = purple_account_get_connection(acct); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3613 | g_return_if_fail(gc != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3614 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3615 | pd = gc->proto_data; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3616 | g_return_if_fail(pd != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3617 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3618 | rcpt_name = g_strdup_printf("@U %s", buddy->name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3619 | rcpt = g_list_prepend(NULL, rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3620 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3621 | session = pd->session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3622 | mwSession_sendAnnounce(session, FALSE, |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3623 | "This is a TEST announcement. Please ignore.", |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3624 | rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3625 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3626 | g_list_free(rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3627 | g_free(rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3628 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3629 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3630 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3631 | |
| 15884 | 3632 | static GList *mw_prpl_blist_node_menu(PurpleBlistNode *node) { |
| 10977 | 3633 | GList *l = NULL; |
| 15884 | 3634 | PurpleMenuAction *act; |
| 3635 | ||
| 3636 | if(! PURPLE_BLIST_NODE_IS_BUDDY(node)) | |
| 10977 | 3637 | return l; |
| 3638 | ||
| 3639 | l = g_list_append(l, NULL); | |
| 3640 | ||
| 15884 | 3641 | act = purple_menu_action_new(_("Invite to Conference..."), |
| 3642 | PURPLE_CALLBACK(blist_menu_conf), NULL, NULL); | |
| 10977 | 3643 | l = g_list_append(l, act); |
| 3644 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3645 | #if 0 |
| 15884 | 3646 | act = purple_menu_action_new(_("Send TEST Announcement"), |
| 3647 | PURPLE_CALLBACK(blist_menu_announce), NULL, NULL); | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3648 | l = g_list_append(l, act); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3649 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3650 | |
| 15884 | 3651 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3652 | blist-node-extended-menu signal for that. The function |
| 3653 | blist_node_menu_cb is assigned to this signal in the function | |
| 3654 | services_starting */ | |
| 3655 | ||
| 3656 | return l; | |
| 3657 | } | |
| 3658 | ||
| 3659 | ||
| 15884 | 3660 | static GList *mw_prpl_chat_info(PurpleConnection *gc) { |
| 10977 | 3661 | GList *l = NULL; |
| 3662 | struct proto_chat_entry *pce; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3663 | |
| 10977 | 3664 | pce = g_new0(struct proto_chat_entry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3665 | pce->label = _("Topic:"); |
| 10977 | 3666 | pce->identifier = CHAT_KEY_TOPIC; |
| 3667 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3668 | |
| 10977 | 3669 | return l; |
| 3670 | } | |
| 3671 | ||
| 3672 | ||
| 15884 | 3673 | static GHashTable *mw_prpl_chat_info_defaults(PurpleConnection *gc, |
| 10977 | 3674 | const char *name) { |
| 3675 | GHashTable *table; | |
| 3676 | ||
| 3677 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3678 | ||
| 3679 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3680 | NULL, g_free); | |
| 3681 | ||
| 3682 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3683 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3684 | ||
| 3685 | return table; | |
| 3686 | } | |
| 3687 | ||
| 3688 | ||
| 15884 | 3689 | static void mw_prpl_login(PurpleAccount *acct); |
| 3690 | ||
| 3691 | ||
| 3692 | static void prompt_host_cancel_cb(PurpleConnection *gc) { | |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
3693 | const char *msg = _("No Sametime Community Server specified"); |
| 21279 | 3694 | purple_connection_error_reason(gc, |
| 3695 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, | |
| 3696 | msg); | |
| 15884 | 3697 | } |
| 3698 | ||
| 3699 | ||
| 3700 | static void prompt_host_ok_cb(PurpleConnection *gc, const char *host) { | |
| 10977 | 3701 | if(host && *host) { |
| 15884 | 3702 | PurpleAccount *acct = purple_connection_get_account(gc); |
| 3703 | purple_account_set_string(acct, MW_KEY_HOST, host); | |
|
11837
2f1206084fef
[gaim-migrate @ 14128]
Mark Doliner <markdoliner@pidgin.im>
parents:
11718
diff
changeset
|
3704 | mw_prpl_login(acct); |
| 10977 | 3705 | |
| 3706 | } else { | |
| 3707 | prompt_host_cancel_cb(gc); | |
| 3708 | } | |
| 3709 | } | |
| 3710 | ||
| 3711 | ||
| 15884 | 3712 | static void prompt_host(PurpleConnection *gc) { |
| 3713 | PurpleAccount *acct; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3714 | const char *msgA; |
| 10977 | 3715 | char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3716 | |
| 15884 | 3717 | acct = purple_connection_get_account(gc); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3718 | msgA = _("No host or IP address has been configured for the" |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3719 | " Meanwhile account %s. Please enter one below to" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3720 | " continue logging in."); |
| 15884 | 3721 | msg = g_strdup_printf(msgA, NSTR(purple_account_get_username(acct))); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3722 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3723 | purple_request_input(gc, _("Meanwhile Connection Setup"), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3724 | _("No Sametime Community Server Specified"), msg, |
| 10977 | 3725 | MW_PLUGIN_DEFAULT_HOST, FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3726 | _("Connect"), G_CALLBACK(prompt_host_ok_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3727 | _("Cancel"), G_CALLBACK(prompt_host_cancel_cb), |
|
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
|
3728 | acct, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3729 | gc); |
| 10977 | 3730 | |
| 3731 | g_free(msg); | |
| 3732 | } | |
| 3733 | ||
| 3734 | ||
| 15884 | 3735 | static void mw_prpl_login(PurpleAccount *account) { |
| 3736 | PurpleConnection *gc; | |
| 3737 | struct mwPurplePluginData *pd; | |
| 10977 | 3738 | |
| 3739 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3740 | guint port; |
| 10977 | 3741 | |
| 15884 | 3742 | gc = purple_account_get_connection(account); |
| 3743 | pd = mwPurplePluginData_new(gc); | |
| 10977 | 3744 | |
| 3745 | /* while we do support images, the default is to not offer it */ | |
| 15884 | 3746 | gc->flags |= PURPLE_CONNECTION_NO_IMAGES; |
| 3747 | ||
| 3748 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3749 | |
| 3750 | host = strrchr(user, ':'); | |
| 3751 | if(host) { | |
| 3752 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3753 | *host++ = '\0'; | |
| 15884 | 3754 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3755 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3756 | |
| 10977 | 3757 | } else { |
| 15884 | 3758 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3759 | MW_PLUGIN_DEFAULT_HOST); |
| 3760 | } | |
| 3761 | ||
| 3762 | if(! host || ! *host) { | |
| 3763 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3764 | 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
|
3765 | g_free(user); |
| 10977 | 3766 | prompt_host(gc); |
| 3767 | return; | |
| 3768 | } | |
| 3769 | ||
|
25292
5b4e719c5bbb
Fix a potential leak "KuSh" discovered using "cppcheck". Fixes #7862.
Daniel Atallah <datallah@pidgin.im>
parents:
25181
diff
changeset
|
3770 | pass = g_strdup(purple_account_get_password(account)); |
| 15884 | 3771 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3772 | |
| 3773 | DEBUG_INFO("user: '%s'\n", user); | |
| 3774 | DEBUG_INFO("host: '%s'\n", host); | |
| 3775 | DEBUG_INFO("port: %u\n", port); | |
| 3776 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3777 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3778 | (char *) no_secret, NULL); |
| 3779 | 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
|
3780 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3781 | |
| 15884 | 3782 | 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
|
3783 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3784 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3785 | /* 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
|
3786 | 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
|
3787 | |
| 15884 | 3788 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3789 | 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
|
3790 | 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
|
3791 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3792 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3793 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3794 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3795 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3796 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3797 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3798 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3799 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3800 | GUINT_TO_POINTER(major), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3801 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3802 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3803 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3804 | } |
| 10977 | 3805 | |
| 15884 | 3806 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3807 | ||
| 3808 | if (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL) { | |
| 21279 | 3809 | 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
|
3810 | _("Unable to connect")); |
| 10977 | 3811 | } |
| 3812 | } | |
| 3813 | ||
| 3814 | ||
| 15884 | 3815 | static void mw_prpl_close(PurpleConnection *gc) { |
| 3816 | struct mwPurplePluginData *pd; | |
| 10977 | 3817 | |
| 3818 | g_return_if_fail(gc != NULL); | |
| 3819 | ||
| 3820 | pd = gc->proto_data; | |
| 3821 | g_return_if_fail(pd != NULL); | |
| 3822 | ||
| 3823 | /* get rid of the blist save timeout */ | |
| 3824 | if(pd->save_event) { | |
| 15884 | 3825 | purple_timeout_remove(pd->save_event); |
| 10977 | 3826 | pd->save_event = 0; |
| 3827 | blist_store(pd); | |
| 3828 | } | |
| 3829 | ||
| 3830 | /* stop the session */ | |
| 3831 | mwSession_stop(pd->session, 0x00); | |
| 3832 | ||
| 3833 | /* no longer necessary */ | |
| 3834 | gc->proto_data = NULL; | |
| 3835 | ||
| 3836 | /* stop watching the socket */ | |
| 3837 | if(gc->inpa) { | |
| 15884 | 3838 | purple_input_remove(gc->inpa); |
| 10977 | 3839 | gc->inpa = 0; |
| 3840 | } | |
| 3841 | ||
| 3842 | /* clean up the rest */ | |
| 15884 | 3843 | mwPurplePluginData_free(pd); |
| 10977 | 3844 | } |
| 3845 | ||
| 3846 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21947
diff
changeset
|
3847 | static int mw_rand(void) { |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3848 | static int seed = 0; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3849 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3850 | /* for diversity, not security. don't touch */ |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3851 | srand(time(NULL) ^ seed); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3852 | seed = rand(); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3853 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3854 | return seed; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3855 | } |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3856 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3857 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3858 | /** 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
|
3859 | static char *im_mime_content_id(void) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3860 | return g_strdup_printf("%03x@%05xmeanwhile", |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3861 | mw_rand() & 0xfff, mw_rand() & 0xfffff); |
| 10977 | 3862 | } |
| 3863 | ||
| 3864 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3865 | /** generates a multipart/related content type with a random-ish |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3866 | 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
|
3867 | static char *im_mime_content_type(void) { |
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3868 | 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
|
3869 | mw_rand() & 0xfff, mw_rand() & 0xffff); |
| 10977 | 3870 | } |
| 3871 | ||
| 3872 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3873 | /** determine content type from extension. Not so happy about this, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3874 | but I don't want to actually write image type detection */ |
| 15884 | 3875 | static char *im_mime_img_content_type(PurpleStoredImage *img) { |
| 3876 | const char *fn = purple_imgstore_get_filename(img); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3877 | const char *ct = NULL; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3878 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3879 | ct = strrchr(fn, '.'); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3880 | if(! ct) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3881 | ct = "image"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3882 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3883 | } else if(! strcmp(".png", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3884 | ct = "image/png"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3885 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3886 | } else if(! strcmp(".jpg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3887 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3888 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3889 | } else if(! strcmp(".jpeg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3890 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3891 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3892 | } else if(! strcmp(".gif", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3893 | ct = "image/gif"; |
| 10977 | 3894 | |
| 3895 | } else { | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3896 | ct = "image"; |
| 10977 | 3897 | } |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3898 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3899 | return g_strdup_printf("%s; name=\"%s\"", ct, fn); |
| 10977 | 3900 | } |
| 3901 | ||
| 3902 | ||
| 15884 | 3903 | static char *im_mime_img_content_disp(PurpleStoredImage *img) { |
| 3904 | const char *fn = purple_imgstore_get_filename(img); | |
| 10977 | 3905 | return g_strdup_printf("attachment; filename=\"%s\"", fn); |
| 3906 | } | |
| 3907 | ||
| 3908 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3909 | /** turn an IM with embedded images into a multi-part mime document */ |
| 15884 | 3910 | static char *im_mime_convert(PurpleConnection *gc, |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3911 | struct mwConversation *conv, |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3912 | const char *message) { |
| 10977 | 3913 | GString *str; |
| 15884 | 3914 | PurpleMimeDocument *doc; |
| 3915 | PurpleMimePart *part; | |
| 10977 | 3916 | |
| 3917 | GData *attr; | |
| 3918 | char *tmp, *start, *end; | |
| 3919 | ||
| 3920 | str = g_string_new(NULL); | |
| 3921 | ||
| 15884 | 3922 | doc = purple_mime_document_new(); |
| 3923 | ||
| 3924 | purple_mime_document_set_field(doc, "Mime-Version", "1.0"); | |
| 3925 | purple_mime_document_set_field(doc, "Content-Disposition", "inline"); | |
| 10977 | 3926 | |
| 3927 | tmp = im_mime_content_type(); | |
| 15884 | 3928 | purple_mime_document_set_field(doc, "Content-Type", tmp); |
| 10977 | 3929 | g_free(tmp); |
| 3930 | ||
| 3931 | tmp = (char *) message; | |
| 15884 | 3932 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 3933 | (const char **) &end, &attr)) { |
| 3934 | char *id; | |
| 15884 | 3935 | PurpleStoredImage *img = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3936 | |
| 10977 | 3937 | gsize len = (start - tmp); |
| 3938 | ||
| 3939 | /* append the in-between-tags text */ | |
| 3940 | if(len) g_string_append_len(str, tmp, len); | |
| 3941 | ||
| 3942 | /* find the imgstore data by the id tag */ | |
| 3943 | id = g_datalist_get_data(&attr, "id"); | |
| 3944 | 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
|
3945 | img = purple_imgstore_find_by_id(atoi(id)); |
| 10977 | 3946 | |
| 3947 | if(img) { | |
| 3948 | char *cid; | |
| 3949 | gpointer data; | |
| 3950 | size_t size; | |
| 3951 | ||
| 15884 | 3952 | part = purple_mime_part_new(doc); |
| 10977 | 3953 | |
| 3954 | data = im_mime_img_content_disp(img); | |
| 15884 | 3955 | purple_mime_part_set_field(part, "Content-Disposition", data); |
| 10977 | 3956 | g_free(data); |
| 3957 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3958 | data = im_mime_img_content_type(img); |
| 15884 | 3959 | purple_mime_part_set_field(part, "Content-Type", data); |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3960 | g_free(data); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3961 | |
| 10977 | 3962 | cid = im_mime_content_id(); |
| 3963 | data = g_strdup_printf("<%s>", cid); | |
| 15884 | 3964 | purple_mime_part_set_field(part, "Content-ID", data); |
| 10977 | 3965 | g_free(data); |
| 3966 | ||
| 15884 | 3967 | purple_mime_part_set_field(part, "Content-transfer-encoding", "base64"); |
| 10977 | 3968 | |
| 3969 | /* obtain and base64 encode the image data, and put it in the | |
| 3970 | mime part */ | |
| 15884 | 3971 | 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
|
3972 | data = purple_base64_encode(purple_imgstore_get_data(img), (gsize) size); |
| 15884 | 3973 | purple_mime_part_set_data(part, data); |
| 10977 | 3974 | g_free(data); |
| 3975 | ||
| 3976 | /* append the modified tag */ | |
| 3977 | g_string_append_printf(str, "<img src=\"cid:%s\">", cid); | |
| 3978 | g_free(cid); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3979 | |
| 10977 | 3980 | } else { |
| 3981 | /* append the literal image tag, since we couldn't find a | |
| 3982 | relative imgstore object */ | |
| 3983 | gsize len = (end - start) + 1; | |
| 3984 | g_string_append_len(str, start, len); | |
| 3985 | } | |
| 3986 | ||
| 3987 | g_datalist_clear(&attr); | |
| 3988 | tmp = end + 1; | |
| 3989 | } | |
| 3990 | ||
| 3991 | /* append left-overs */ | |
| 3992 | g_string_append(str, tmp); | |
| 3993 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3994 | /* add the text/html part */ |
| 15884 | 3995 | part = purple_mime_part_new(doc); |
| 3996 | purple_mime_part_set_field(part, "Content-Disposition", "inline"); | |
| 3997 | ||
| 3998 | tmp = purple_utf8_ncr_encode(str->str); | |
| 3999 | purple_mime_part_set_field(part, "Content-Type", "text/html"); | |
| 4000 | purple_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); | |
| 4001 | purple_mime_part_set_data(part, tmp); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4002 | g_free(tmp); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4003 | |
| 10977 | 4004 | g_string_free(str, TRUE); |
| 4005 | ||
| 4006 | str = g_string_new(NULL); | |
| 15884 | 4007 | purple_mime_document_write(doc, str); |
| 10977 | 4008 | tmp = str->str; |
| 4009 | g_string_free(str, FALSE); | |
| 4010 | ||
| 4011 | return tmp; | |
| 4012 | } | |
| 4013 | ||
| 4014 | ||
| 15884 | 4015 | static int mw_prpl_send_im(PurpleConnection *gc, |
| 10977 | 4016 | const char *name, |
| 4017 | const char *message, | |
| 15884 | 4018 | PurpleMessageFlags flags) { |
| 4019 | ||
| 4020 | struct mwPurplePluginData *pd; | |
| 10977 | 4021 | struct mwIdBlock who = { (char *) name, NULL }; |
| 4022 | struct mwConversation *conv; | |
| 4023 | ||
| 4024 | g_return_val_if_fail(gc != NULL, 0); | |
| 4025 | pd = gc->proto_data; | |
| 4026 | ||
| 4027 | g_return_val_if_fail(pd != NULL, 0); | |
| 4028 | ||
| 4029 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 4030 | ||
| 4031 | /* this detection of features to determine how to send the message | |
| 4032 | (plain, html, or mime) is flawed because the other end of the | |
| 4033 | conversation could close their channel at any time, rendering any | |
| 4034 | existing formatting in an outgoing message innapropriate. The end | |
| 4035 | result is that it may be possible that the other side of the | |
| 4036 | conversation will receive a plaintext message with html contents, | |
| 4037 | which is bad. I'm not sure how to fix this correctly. */ | |
| 4038 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4039 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 4040 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 4041 | |
| 4042 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4043 | char *tmp; |
| 10977 | 4044 | int ret; |
| 4045 | ||
| 15884 | 4046 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 4047 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4048 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4049 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4050 | tmp = im_mime_convert(gc, conv, message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4051 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4052 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4053 | |
| 10977 | 4054 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4055 | /* send an HTML message */ |
| 10977 | 4056 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4057 | char *ncr; |
| 15884 | 4058 | ncr = purple_utf8_ncr_encode(message); |
| 4059 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4060 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4061 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4062 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4063 | g_free(tmp); |
| 10977 | 4064 | |
| 4065 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4066 | /* default to text */ |
| 15884 | 4067 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4068 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4069 | g_free(tmp); |
| 10977 | 4070 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4071 | |
| 10977 | 4072 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4073 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4074 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4075 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4076 | /* queue up the message safely as plain text */ |
| 15884 | 4077 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4078 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4079 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4080 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4081 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4082 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4083 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4084 | return 1; |
| 10977 | 4085 | } |
| 4086 | } | |
| 4087 | ||
| 4088 | ||
| 15884 | 4089 | static unsigned int mw_prpl_send_typing(PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4090 | const char *name, |
| 15884 | 4091 | PurpleTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4092 | |
| 15884 | 4093 | struct mwPurplePluginData *pd; |
| 10977 | 4094 | struct mwIdBlock who = { (char *) name, NULL }; |
| 4095 | struct mwConversation *conv; | |
| 4096 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
4097 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 4098 | |
| 4099 | g_return_val_if_fail(gc != NULL, 0); | |
| 4100 | pd = gc->proto_data; | |
| 4101 | ||
| 4102 | g_return_val_if_fail(pd != NULL, 0); | |
| 4103 | ||
| 4104 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 4105 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4106 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4107 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4108 | |
| 15884 | 4109 | } else if((state == PURPLE_TYPING) || (state == PURPLE_TYPED)) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4110 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4111 | 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
|
4112 | 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
|
4113 | |
| 10977 | 4114 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4115 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4116 | if(! mwConversation_isPending(conv)) { |
| 10977 | 4117 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4118 | } |
| 10977 | 4119 | } |
| 4120 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4121 | return 0; |
| 10977 | 4122 | } |
| 4123 | ||
| 4124 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4125 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4126 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4127 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4128 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4129 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4130 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4131 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4132 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4133 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4134 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4135 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4136 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4137 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4138 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4139 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4140 | return "Lotus Sametime Links"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4141 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4142 | case mwLogin_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4143 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4144 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4145 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4146 | return "Lotus Notes Client"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4147 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4148 | case mwLogin_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4149 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4150 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4151 | return "IBM Community Tools"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4152 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4153 | case mwLogin_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4154 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4155 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4156 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4157 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4158 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4159 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4160 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4161 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4162 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4163 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4164 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4165 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4166 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4167 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4168 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4169 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4170 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4171 | return "Trillian"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4172 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4173 | case mwLogin_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4174 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4175 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4176 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4177 | return NULL; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4178 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4179 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4180 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4181 | |
| 15884 | 4182 | static void mw_prpl_get_info(PurpleConnection *gc, const char *who) { |
| 10977 | 4183 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4184 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4185 | |
| 15884 | 4186 | struct mwPurplePluginData *pd; |
| 4187 | PurpleAccount *acct; | |
| 4188 | PurpleBuddy *b; | |
| 4189 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4190 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4191 | const char *tmp2; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4192 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4193 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4194 | g_return_if_fail(*who != '\0'); |
| 10977 | 4195 | |
| 4196 | pd = gc->proto_data; | |
| 4197 | ||
| 15884 | 4198 | acct = purple_connection_get_account(gc); |
| 4199 | b = purple_find_buddy(acct, who); | |
| 4200 | user_info = purple_notify_user_info_new(); | |
| 4201 | ||
| 4202 | if(purple_str_has_prefix(who, "@E ")) { | |
| 4203 | purple_notify_user_info_add_pair(user_info, _("External User"), NULL); | |
| 10977 | 4204 | } |
| 4205 | ||
| 15884 | 4206 | 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
|
4207 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4208 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4209 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4210 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4211 | 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
|
4212 | 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
|
4213 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4214 | |
| 15884 | 4215 | 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
|
4216 | if(type) { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4217 | tmp = g_strdup(mw_client_name(type)); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4218 | if (!tmp) |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4219 | tmp = g_strdup_printf(_("Unknown (0x%04x)<br>"), type); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4220 | |
| 15884 | 4221 | 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
|
4222 | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4223 | g_free(tmp); |
| 10977 | 4224 | } |
| 4225 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4226 | |
| 10977 | 4227 | tmp = user_supports_text(pd->srvc_aware, who); |
| 4228 | if(tmp) { | |
| 15884 | 4229 | purple_notify_user_info_add_pair(user_info, _("Supports"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4230 | g_free(tmp); |
| 10977 | 4231 | } |
| 4232 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4233 | if(b) { |
| 15884 | 4234 | 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
|
4235 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4236 | /* 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
|
4237 | 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
|
4238 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4239 | tmp = g_markup_escape_text(tmp2, -1); |
| 15884 | 4240 | purple_notify_user_info_add_section_break(user_info); |
| 4241 | purple_notify_user_info_add_pair(user_info, NULL, tmp); | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4242 | g_free(tmp); |
|
12496
788b20ccec91
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4243 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4244 | } |
| 10977 | 4245 | |
| 4246 | /* @todo emit a signal to allow a plugin to override the display of | |
| 4247 | this notification, so that it can create its own */ | |
| 4248 | ||
| 15884 | 4249 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 4250 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 4251 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4252 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4253 | |
| 15884 | 4254 | static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status) { |
| 4255 | PurpleConnection *gc; | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4256 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
4257 | char *message = NULL; |
| 10977 | 4258 | struct mwSession *session; |
| 4259 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4260 | |
| 10977 | 4261 | g_return_if_fail(acct != NULL); |
| 15884 | 4262 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4263 | |
| 15884 | 4264 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4265 | |
| 15884 | 4266 | 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
|
4267 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4268 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4269 | |
| 10977 | 4270 | session = gc_to_session(gc); |
| 4271 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4272 | |
| 10977 | 4273 | /* get a working copy of the current status */ |
| 4274 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4275 | |
| 10977 | 4276 | /* determine the state */ |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4277 | if(! strcmp(state, MW_STATE_ACTIVE)) { |
| 10977 | 4278 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4279 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4280 | } else if(! strcmp(state, MW_STATE_AWAY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4281 | stat.status = mwStatus_AWAY; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4282 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4283 | } else if(! strcmp(state, MW_STATE_BUSY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4284 | stat.status = mwStatus_BUSY; |
| 10977 | 4285 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4286 | |
| 10977 | 4287 | /* determine the message */ |
| 15884 | 4288 | 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
|
4289 | |
| 10977 | 4290 | if(message) { |
| 4291 | /* all the possible non-NULL values of message up to this point | |
| 4292 | are const, so we don't need to free them */ | |
| 15884 | 4293 | message = purple_markup_strip_html(message); |
| 10977 | 4294 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4295 | |
| 10977 | 4296 | /* out with the old */ |
| 4297 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4298 | |
| 10977 | 4299 | /* in with the new */ |
| 4300 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4301 | |
| 10977 | 4302 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4303 | mwUserStatus_clear(&stat); |
| 10977 | 4304 | } |
| 4305 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4306 | |
| 15884 | 4307 | static void mw_prpl_set_idle(PurpleConnection *gc, int t) { |
| 10977 | 4308 | struct mwSession *session; |
| 4309 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4310 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4311 | |
| 10977 | 4312 | session = gc_to_session(gc); |
| 4313 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4314 | |
| 10977 | 4315 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4316 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4317 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4318 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4319 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4320 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4321 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4322 | stat.time = 0; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4323 | } |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4324 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4325 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4326 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4327 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4328 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4329 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4330 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4331 | stat.status = mwStatus_ACTIVE; |
| 4332 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4333 | |
| 10977 | 4334 | mwSession_setUserStatus(session, &stat); |
| 4335 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4336 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4337 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4338 | |
| 15884 | 4339 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4340 | PurpleAccount *acct; | |
| 4341 | PurpleConversation *conv; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4342 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4343 | |
| 15884 | 4344 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4345 | id = g_list_nth_data(row, 1); |
| 15884 | 4346 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, id, acct); |
| 4347 | if(! conv) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, id); | |
| 4348 | purple_conversation_present(conv); | |
| 4349 | } | |
| 4350 | ||
| 4351 | ||
| 4352 | 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
|
4353 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4354 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4355 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4356 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4357 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4358 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4359 | |
| 15884 | 4360 | 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
|
4361 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4362 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4363 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4364 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4365 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4366 | static void notify_close(gpointer data) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4367 | if (data) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4368 | g_free(data); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4369 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4370 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4371 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4372 | |
| 10977 | 4373 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4374 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4375 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4376 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4377 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4378 | char *msg; |
| 10977 | 4379 | |
| 15884 | 4380 | PurpleNotifySearchResults *sres; |
| 4381 | PurpleNotifySearchColumn *scol; | |
| 4382 | ||
| 4383 | sres = purple_notify_searchresults_new(); | |
| 4384 | ||
| 4385 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4386 | purple_notify_searchresults_column_add(sres, scol); | |
| 4387 | ||
| 4388 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4389 | purple_notify_searchresults_column_add(sres, scol); | |
| 4390 | ||
| 4391 | 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
|
4392 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4393 | |
| 15884 | 4394 | 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
|
4395 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4396 | |
| 10977 | 4397 | for(l = result->matches; l; l = l->next) { |
| 4398 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4399 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4400 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4401 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4402 | NSTR(match->id), NSTR(match->name)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4403 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4404 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4405 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4406 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4407 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4408 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4409 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4410 | } |
| 10977 | 4411 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4412 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4413 | 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
|
4414 | " 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
|
4415 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4416 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4417 | |
| 15884 | 4418 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4419 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4420 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4421 | g_free(msg); |
| 10977 | 4422 | } |
| 4423 | ||
| 4424 | ||
| 4425 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4426 | guint32 id, guint32 code, GList *results, | |
| 4427 | gpointer b) { | |
| 4428 | ||
| 4429 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4430 | BuddyAddData *data = b; |
| 15884 | 4431 | PurpleBuddy *buddy = NULL; |
| 4432 | PurpleConnection *gc; | |
| 4433 | struct mwPurplePluginData *pd; | |
| 10977 | 4434 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4435 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4436 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4437 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4438 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4439 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
| 10977 | 4440 | pd = gc->proto_data; |
| 4441 | ||
| 4442 | if(results) | |
| 4443 | res = results->data; | |
| 4444 | ||
| 4445 | 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
|
4446 | if(!res->matches->next) { |
| 10977 | 4447 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4448 | |
| 10977 | 4449 | /* only one? that might be the right one! */ |
| 4450 | if(strcmp(res->name, match->id)) { | |
| 4451 | /* uh oh, the single result isn't identical to the search | |
| 4452 | term, better safe then sorry, so let's make sure it's who | |
| 4453 | the user meant to add */ | |
| 15884 | 4454 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4455 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4456 | |
| 10977 | 4457 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4458 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4459 | /* same person, set the server alias */ |
| 15884 | 4460 | purple_blist_server_alias_buddy(buddy, match->name); |
| 4461 | purple_blist_node_set_string((PurpleBlistNode *) buddy, | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4462 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4463 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4464 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4465 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4466 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4467 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4468 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4469 | g_free(data); |
| 10977 | 4470 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4471 | |
| 10977 | 4472 | } else { |
| 4473 | /* prompt user if more than one match was returned */ | |
| 15884 | 4474 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4475 | multi_resolved_query(res, gc, data); |
| 10977 | 4476 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4477 | |
| 10977 | 4478 | return; |
| 4479 | } | |
| 4480 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4481 | #if 0 |
| 10977 | 4482 | /* fall-through indicates that we couldn't find a matching user in |
| 4483 | the resolve service (ether error or zero results), so we remove | |
| 4484 | this buddy */ | |
| 4485 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4486 | /* 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
|
4487 | 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
|
4488 | 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
|
4489 | 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
|
4490 | 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
|
4491 | |
| 10977 | 4492 | DEBUG_INFO("no such buddy in community\n"); |
| 15884 | 4493 | purple_blist_remove_buddy(buddy); |
| 10977 | 4494 | blist_schedule(pd); |
| 4495 | ||
| 4496 | if(res && res->name) { | |
| 4497 | /* compose and display an error message */ | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4498 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4499 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4500 | char *msg; |
| 10977 | 4501 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4502 | msgA = _("Unable to add user: user not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4503 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4504 | 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
|
4505 | " Sametime community. This entry has been removed from" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4506 | " your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4507 | msg = g_strdup_printf(msgB, NSTR(res->name)); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4508 | |
| 15884 | 4509 | purple_notify_error(gc, _("Unable to add user"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4510 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4511 | g_free(msg); |
| 10977 | 4512 | } |
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4513 | #endif |
| 10977 | 4514 | } |
| 4515 | ||
| 4516 | ||
| 15884 | 4517 | static void mw_prpl_add_buddy(PurpleConnection *gc, |
| 4518 | PurpleBuddy *buddy, | |
| 4519 | PurpleGroup *group) { | |
| 4520 | ||
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4521 | struct mwPurplePluginData *pd = gc->proto_data; |
| 10977 | 4522 | struct mwServiceResolve *srvc; |
| 4523 | GList *query; | |
| 4524 | enum mwResolveFlag flags; | |
| 4525 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4526 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4527 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4528 | /* 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
|
4529 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4530 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4531 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4532 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4533 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4534 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4535 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4536 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4537 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4538 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4539 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4540 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4541 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4542 | ||
| 4543 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4544 | data, NULL); |
| 10977 | 4545 | g_list_free(query); |
| 4546 | ||
| 4547 | if(req == SEARCH_ERROR) { | |
| 15884 | 4548 | purple_blist_remove_buddy(buddy); |
| 10977 | 4549 | blist_schedule(pd); |
| 4550 | } | |
| 4551 | } | |
| 4552 | ||
| 4553 | ||
| 15884 | 4554 | static void foreach_add_buddies(PurpleGroup *group, GList *buddies, |
| 4555 | struct mwPurplePluginData *pd) { | |
| 10977 | 4556 | struct mwAwareList *list; |
| 4557 | ||
| 4558 | list = list_ensure(pd, group); | |
| 4559 | mwAwareList_addAware(list, buddies); | |
| 4560 | g_list_free(buddies); | |
| 4561 | } | |
| 4562 | ||
| 4563 | ||
| 15884 | 4564 | static void mw_prpl_add_buddies(PurpleConnection *gc, |
| 10977 | 4565 | GList *buddies, |
| 4566 | GList *groups) { | |
| 4567 | ||
| 15884 | 4568 | struct mwPurplePluginData *pd; |
| 10977 | 4569 | GHashTable *group_sets; |
| 4570 | struct mwAwareIdBlock *idbs, *idb; | |
| 4571 | ||
| 4572 | pd = gc->proto_data; | |
| 4573 | ||
| 15884 | 4574 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4575 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4576 | ||
| 4577 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4578 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4579 | ||
| 4580 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4581 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4582 | PurpleBuddy *b = buddies->data; |
| 4583 | PurpleGroup *g; | |
| 10977 | 4584 | const char *fn; |
| 4585 | GList *l; | |
| 4586 | ||
| 4587 | /* nab the saved server alias and stick it on the buddy */ | |
| 15884 | 4588 | fn = purple_blist_node_get_string((PurpleBlistNode *) b, BUDDY_KEY_NAME); |
| 4589 | purple_blist_server_alias_buddy(b, fn); | |
| 4590 | ||
| 4591 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4592 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4593 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4594 | idb->community = NULL; |
| 4595 | ||
| 4596 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4597 | g = purple_buddy_get_group(b); |
| 10977 | 4598 | l = g_hash_table_lookup(group_sets, g); |
| 4599 | l = g_list_prepend(l, idb++); | |
| 4600 | g_hash_table_insert(group_sets, g, l); | |
| 4601 | } | |
| 4602 | ||
| 4603 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4604 | for saving */ | |
| 4605 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4606 | blist_schedule(pd); | |
| 4607 | ||
| 4608 | /* cleanup */ | |
| 4609 | g_hash_table_destroy(group_sets); | |
| 4610 | g_free(idbs); | |
| 4611 | } | |
| 4612 | ||
| 4613 | ||
| 15884 | 4614 | static void mw_prpl_remove_buddy(PurpleConnection *gc, |
| 4615 | PurpleBuddy *buddy, PurpleGroup *group) { | |
| 4616 | ||
| 4617 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4618 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4619 | struct mwAwareList *list; |
| 4620 | ||
| 4621 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4622 | ||
| 4623 | pd = gc->proto_data; | |
| 15884 | 4624 | group = purple_buddy_get_group(buddy); |
| 10977 | 4625 | list = list_ensure(pd, group); |
| 4626 | ||
| 4627 | mwAwareList_removeAware(list, rem); | |
| 4628 | blist_schedule(pd); | |
| 4629 | ||
| 4630 | g_list_free(rem); | |
| 4631 | } | |
| 4632 | ||
| 4633 | ||
| 4634 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4635 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4636 | |
| 10977 | 4637 | struct mwUserItem *u; |
| 4638 | guint count; | |
| 4639 | ||
| 4640 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4641 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4642 | |
| 4643 | priv->count = count; | |
| 4644 | priv->users = g_new0(struct mwUserItem, count); | |
| 4645 | ||
| 4646 | while(count--) { | |
| 4647 | u = priv->users + count; | |
| 4648 | u->id = members->data; | |
| 4649 | members = members->next; | |
| 4650 | } | |
| 4651 | } | |
| 4652 | ||
| 4653 | ||
| 15884 | 4654 | static void mw_prpl_set_permit_deny(PurpleConnection *gc) { |
| 4655 | PurpleAccount *acct; | |
| 4656 | struct mwPurplePluginData *pd; | |
| 10977 | 4657 | struct mwSession *session; |
| 4658 | ||
| 4659 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4660 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4661 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4662 | NULL, /* users */ |
| 10977 | 4663 | }; |
| 4664 | ||
| 4665 | g_return_if_fail(gc != NULL); | |
| 4666 | ||
| 15884 | 4667 | acct = purple_connection_get_account(gc); |
| 10977 | 4668 | g_return_if_fail(acct != NULL); |
| 4669 | ||
| 4670 | pd = gc->proto_data; | |
| 4671 | g_return_if_fail(pd != NULL); | |
| 4672 | ||
| 4673 | session = pd->session; | |
| 4674 | g_return_if_fail(session != NULL); | |
| 4675 | ||
| 4676 | switch(acct->perm_deny) { | |
| 15884 | 4677 | case PURPLE_PRIVACY_DENY_USERS: |
| 4678 | DEBUG_INFO("PURPLE_PRIVACY_DENY_USERS\n"); | |
| 10977 | 4679 | privacy_fill(&privacy, acct->deny); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4680 | privacy.deny = TRUE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4681 | break; |
| 10977 | 4682 | |
| 15884 | 4683 | case PURPLE_PRIVACY_ALLOW_ALL: |
| 4684 | DEBUG_INFO("PURPLE_PRIVACY_ALLOW_ALL\n"); | |
| 10977 | 4685 | privacy.deny = TRUE; |
| 4686 | break; | |
| 4687 | ||
| 15884 | 4688 | case PURPLE_PRIVACY_ALLOW_USERS: |
| 4689 | DEBUG_INFO("PURPLE_PRIVACY_ALLOW_USERS\n"); | |
| 10977 | 4690 | privacy_fill(&privacy, acct->permit); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4691 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4692 | break; |
| 10977 | 4693 | |
| 15884 | 4694 | case PURPLE_PRIVACY_DENY_ALL: |
| 4695 | DEBUG_INFO("PURPLE_PRIVACY_DENY_ALL\n"); | |
| 10977 | 4696 | privacy.deny = FALSE; |
| 4697 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4698 | |
| 10977 | 4699 | default: |
| 4700 | 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
|
4701 | return; |
| 10977 | 4702 | } |
| 4703 | ||
| 4704 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4705 | g_free(privacy.users); | |
| 4706 | } | |
| 4707 | ||
| 4708 | ||
| 15884 | 4709 | static void mw_prpl_add_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4710 | mw_prpl_set_permit_deny(gc); |
| 4711 | } | |
| 4712 | ||
| 4713 | ||
| 15884 | 4714 | static void mw_prpl_add_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4715 | mw_prpl_set_permit_deny(gc); |
| 4716 | } | |
| 4717 | ||
| 4718 | ||
| 15884 | 4719 | static void mw_prpl_rem_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4720 | mw_prpl_set_permit_deny(gc); |
| 4721 | } | |
| 4722 | ||
| 4723 | ||
| 15884 | 4724 | static void mw_prpl_rem_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4725 | mw_prpl_set_permit_deny(gc); |
| 4726 | } | |
| 4727 | ||
| 4728 | ||
| 4729 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4730 | const char *name) { | |
| 4731 | GList *l, *ll; | |
| 4732 | struct mwConference *conf = NULL; | |
| 4733 | ||
| 4734 | ll = mwServiceConference_getConferences(srvc); | |
| 4735 | for(l = ll; l; l = l->next) { | |
| 4736 | struct mwConference *c = l->data; | |
| 4737 | if(! strcmp(name, mwConference_getName(c))) { | |
| 4738 | conf = c; | |
| 4739 | break; | |
| 4740 | } | |
| 4741 | } | |
| 4742 | g_list_free(ll); | |
| 4743 | ||
| 4744 | return conf; | |
| 4745 | } | |
| 4746 | ||
| 4747 | ||
| 15884 | 4748 | static void mw_prpl_join_chat(PurpleConnection *gc, |
| 10977 | 4749 | GHashTable *components) { |
| 4750 | ||
| 15884 | 4751 | struct mwPurplePluginData *pd; |
| 10977 | 4752 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4753 | |
| 10977 | 4754 | pd = gc->proto_data; |
| 4755 | ||
| 4756 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4757 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4758 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4759 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4760 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4761 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4762 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4763 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4764 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4765 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4766 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4767 | |
| 10977 | 4768 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4769 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4770 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4771 | struct mwConference *conf = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4772 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4773 | srvc = pd->srvc_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4774 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4775 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4776 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4777 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4778 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4779 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4780 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4781 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4782 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4783 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4784 | } |
| 10977 | 4785 | } |
| 4786 | } | |
| 4787 | ||
| 4788 | ||
| 15884 | 4789 | static void mw_prpl_reject_chat(PurpleConnection *gc, |
| 10977 | 4790 | GHashTable *components) { |
| 4791 | ||
| 15884 | 4792 | struct mwPurplePluginData *pd; |
| 10977 | 4793 | struct mwServiceConference *srvc; |
| 4794 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4795 | |
| 10977 | 4796 | pd = gc->proto_data; |
| 4797 | srvc = pd->srvc_conf; | |
| 4798 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4799 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4800 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4801 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4802 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4803 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4804 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4805 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4806 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4807 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4808 | } |
| 10977 | 4809 | } |
| 4810 | } | |
| 4811 | ||
| 4812 | ||
| 4813 | static char *mw_prpl_get_chat_name(GHashTable *components) { | |
| 4814 | return g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4815 | } | |
| 4816 | ||
| 4817 | ||
| 15884 | 4818 | static void mw_prpl_chat_invite(PurpleConnection *gc, |
| 10977 | 4819 | int id, |
| 4820 | const char *invitation, | |
| 4821 | const char *who) { | |
| 4822 | ||
| 15884 | 4823 | struct mwPurplePluginData *pd; |
| 10977 | 4824 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4825 | struct mwPlace *place; |
| 10977 | 4826 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4827 | ||
| 4828 | pd = gc->proto_data; | |
| 4829 | g_return_if_fail(pd != NULL); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4830 | |
| 10977 | 4831 | conf = ID_TO_CONF(pd, id); |
| 4832 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4833 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4834 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4835 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4836 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4837 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4838 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4839 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4840 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4841 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4842 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4843 | } |
| 4844 | ||
| 4845 | ||
| 15884 | 4846 | static void mw_prpl_chat_leave(PurpleConnection *gc, |
| 10977 | 4847 | int id) { |
| 4848 | ||
| 15884 | 4849 | struct mwPurplePluginData *pd; |
| 10977 | 4850 | struct mwConference *conf; |
| 4851 | ||
| 4852 | pd = gc->proto_data; | |
| 4853 | ||
| 4854 | g_return_if_fail(pd != NULL); | |
| 4855 | conf = ID_TO_CONF(pd, id); | |
| 4856 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4857 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4858 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4859 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4860 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4861 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4862 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4863 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4864 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4865 | } |
| 10977 | 4866 | } |
| 4867 | ||
| 4868 | ||
| 15884 | 4869 | static void mw_prpl_chat_whisper(PurpleConnection *gc, |
| 10977 | 4870 | int id, |
| 4871 | const char *who, | |
| 4872 | const char *message) { | |
| 4873 | ||
| 4874 | mw_prpl_send_im(gc, who, message, 0); | |
| 4875 | } | |
| 4876 | ||
| 4877 | ||
| 15884 | 4878 | static int mw_prpl_chat_send(PurpleConnection *gc, |
| 10977 | 4879 | int id, |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4880 | const char *message, |
| 15884 | 4881 | PurpleMessageFlags flags) { |
| 4882 | ||
| 4883 | struct mwPurplePluginData *pd; | |
| 10977 | 4884 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4885 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4886 | int ret; |
| 10977 | 4887 | |
| 4888 | pd = gc->proto_data; | |
| 4889 | ||
| 4890 | g_return_val_if_fail(pd != NULL, 0); | |
| 4891 | conf = ID_TO_CONF(pd, id); | |
| 4892 | ||
| 15884 | 4893 | msg = purple_markup_strip_html(message); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4894 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4895 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4896 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4897 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4898 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4899 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4900 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4901 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4902 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4903 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4904 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4905 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4906 | return ret; |
| 10977 | 4907 | } |
| 4908 | ||
| 4909 | ||
| 15884 | 4910 | static void mw_prpl_keepalive(PurpleConnection *gc) { |
| 10977 | 4911 | struct mwSession *session; |
| 4912 | ||
| 4913 | g_return_if_fail(gc != NULL); | |
| 4914 | ||
| 4915 | session = gc_to_session(gc); | |
| 4916 | g_return_if_fail(session != NULL); | |
| 4917 | ||
| 4918 | mwSession_sendKeepalive(session); | |
| 4919 | } | |
| 4920 | ||
| 4921 | ||
| 15884 | 4922 | static void mw_prpl_alias_buddy(PurpleConnection *gc, |
| 10977 | 4923 | const char *who, |
| 4924 | const char *alias) { | |
| 4925 | ||
| 15884 | 4926 | struct mwPurplePluginData *pd = gc->proto_data; |
| 10977 | 4927 | g_return_if_fail(pd != NULL); |
| 4928 | ||
| 4929 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4930 | the server copy */ | |
| 4931 | ||
| 4932 | blist_schedule(pd); | |
| 4933 | } | |
| 4934 | ||
| 4935 | ||
| 15884 | 4936 | static void mw_prpl_group_buddy(PurpleConnection *gc, |
| 10977 | 4937 | const char *who, |
| 4938 | const char *old_group, | |
| 4939 | const char *new_group) { | |
| 4940 | ||
| 4941 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 4942 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4943 | ||
| 15884 | 4944 | struct mwPurplePluginData *pd = gc->proto_data; |
| 4945 | PurpleGroup *group; | |
| 10977 | 4946 | struct mwAwareList *list; |
| 4947 | ||
| 4948 | /* add who to new_group's aware list */ | |
| 15884 | 4949 | group = purple_find_group(new_group); |
| 10977 | 4950 | list = list_ensure(pd, group); |
| 4951 | mwAwareList_addAware(list, gl); | |
| 4952 | ||
| 4953 | /* remove who from old_group's aware list */ | |
| 15884 | 4954 | group = purple_find_group(old_group); |
| 10977 | 4955 | list = list_ensure(pd, group); |
| 4956 | mwAwareList_removeAware(list, gl); | |
| 4957 | ||
| 4958 | g_list_free(gl); | |
| 4959 | ||
| 4960 | /* schedule the changes to be saved */ | |
| 4961 | blist_schedule(pd); | |
| 4962 | } | |
| 4963 | ||
| 4964 | ||
| 15884 | 4965 | static void mw_prpl_rename_group(PurpleConnection *gc, |
| 10977 | 4966 | const char *old, |
| 15884 | 4967 | PurpleGroup *group, |
| 10977 | 4968 | GList *buddies) { |
| 4969 | ||
| 15884 | 4970 | struct mwPurplePluginData *pd = gc->proto_data; |
| 10977 | 4971 | g_return_if_fail(pd != NULL); |
| 4972 | ||
| 4973 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4974 | the server copy. Also, having this function should prevent all | |
| 4975 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4976 | give a crap what the group is named in Purple other than to record |
| 10977 | 4977 | that as the group name/alias */ |
| 4978 | ||
| 4979 | blist_schedule(pd); | |
| 4980 | } | |
| 4981 | ||
| 4982 | ||
| 15884 | 4983 | static void mw_prpl_buddy_free(PurpleBuddy *buddy) { |
| 10977 | 4984 | /* I don't think we have any cleanup for buddies yet */ |
| 4985 | ; | |
| 4986 | } | |
| 4987 | ||
| 4988 | ||
| 15884 | 4989 | static void mw_prpl_convo_closed(PurpleConnection *gc, const char *who) { |
| 4990 | struct mwPurplePluginData *pd = gc->proto_data; | |
| 10977 | 4991 | struct mwServiceIm *srvc; |
| 4992 | struct mwConversation *conv; | |
| 4993 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4994 | ||
| 4995 | g_return_if_fail(pd != NULL); | |
| 4996 | ||
| 4997 | srvc = pd->srvc_im; | |
| 4998 | g_return_if_fail(srvc != NULL); | |
| 4999 | ||
| 5000 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 5001 | if(! conv) return; | |
| 5002 | ||
| 5003 | if(mwConversation_isOpen(conv)) | |
| 5004 | mwConversation_free(conv); | |
| 5005 | } | |
| 5006 | ||
| 5007 | ||
| 15884 | 5008 | static const char *mw_prpl_normalize(const PurpleAccount *account, |
| 10977 | 5009 | const char *id) { |
| 5010 | ||
| 5011 | /* code elsewhere assumes that the return value points to different | |
| 5012 | memory than the passed value, but it won't free the normalized | |
| 5013 | data. wtf? */ | |
| 5014 | ||
| 5015 | static char buf[BUF_LEN]; | |
| 5016 | strncpy(buf, id, sizeof(buf)); | |
| 5017 | return buf; | |
| 5018 | } | |
| 5019 | ||
| 5020 | ||
| 15884 | 5021 | static void mw_prpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { |
| 5022 | struct mwPurplePluginData *pd; | |
| 10977 | 5023 | struct mwAwareList *list; |
| 5024 | ||
| 5025 | pd = gc->proto_data; | |
| 5026 | g_return_if_fail(pd != NULL); | |
| 5027 | g_return_if_fail(pd->group_list_map != NULL); | |
| 5028 | ||
| 5029 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 5030 | ||
| 5031 | if(list) { | |
| 5032 | g_hash_table_remove(pd->group_list_map, list); | |
| 5033 | g_hash_table_remove(pd->group_list_map, group); | |
| 5034 | mwAwareList_free(list); | |
| 5035 | ||
| 5036 | blist_schedule(pd); | |
| 5037 | } | |
| 5038 | } | |
| 5039 | ||
| 5040 | ||
| 15884 | 5041 | static gboolean mw_prpl_can_receive_file(PurpleConnection *gc, |
| 10977 | 5042 | const char *who) { |
| 15884 | 5043 | struct mwPurplePluginData *pd; |
| 10977 | 5044 | struct mwServiceAware *srvc; |
| 15884 | 5045 | PurpleAccount *acct; |
| 10977 | 5046 | |
| 5047 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 5048 | ||
| 5049 | pd = gc->proto_data; | |
| 5050 | g_return_val_if_fail(pd != NULL, FALSE); | |
| 5051 | ||
| 5052 | srvc = pd->srvc_aware; | |
| 5053 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5054 | |
| 15884 | 5055 | acct = purple_connection_get_account(gc); |
| 10977 | 5056 | g_return_val_if_fail(acct != NULL, FALSE); |
| 5057 | ||
| 15884 | 5058 | return purple_find_buddy(acct, who) && |
| 10977 | 5059 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 5060 | } | |
| 5061 | ||
| 5062 | ||
| 15884 | 5063 | static void ft_outgoing_init(PurpleXfer *xfer) { |
| 5064 | PurpleAccount *acct; | |
| 5065 | PurpleConnection *gc; | |
| 5066 | ||
| 5067 | struct mwPurplePluginData *pd; | |
| 10977 | 5068 | struct mwServiceFileTransfer *srvc; |
| 5069 | struct mwFileTransfer *ft; | |
| 5070 | ||
| 5071 | const char *filename; | |
| 5072 | gsize filesize; | |
| 5073 | FILE *fp; | |
| 5074 | ||
| 5075 | struct mwIdBlock idb = { NULL, NULL }; | |
| 5076 | ||
| 5077 | DEBUG_INFO("ft_outgoing_init\n"); | |
| 5078 | ||
| 15884 | 5079 | acct = purple_xfer_get_account(xfer); |
| 5080 | gc = purple_account_get_connection(acct); | |
| 10977 | 5081 | pd = gc->proto_data; |
| 5082 | srvc = pd->srvc_ft; | |
| 5083 | ||
| 15884 | 5084 | filename = purple_xfer_get_local_filename(xfer); |
| 5085 | filesize = purple_xfer_get_size(xfer); | |
| 10977 | 5086 | idb.user = xfer->who; |
| 5087 | ||
| 15884 | 5088 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5089 | |
| 10977 | 5090 | /* test that we can actually send the file */ |
| 5091 | fp = g_fopen(filename, "rb"); | |
| 5092 | if(! fp) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5093 | 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
|
5094 | filename, g_strerror(errno)); |
| 15884 | 5095 | purple_xfer_error(purple_xfer_get_type(xfer), acct, xfer->who, msg); |
| 10977 | 5096 | g_free(msg); |
| 5097 | return; | |
| 5098 | } | |
| 5099 | fclose(fp); | |
| 5100 | ||
| 5101 | { | |
| 5102 | char *tmp = strrchr(filename, G_DIR_SEPARATOR); | |
| 5103 | if(tmp++) filename = tmp; | |
| 5104 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5105 | |
| 10977 | 5106 | ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); |
| 5107 | ||
| 15884 | 5108 | purple_xfer_ref(xfer); |
| 5109 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
| 10977 | 5110 | xfer->data = ft; |
| 5111 | ||
| 5112 | mwFileTransfer_offer(ft); | |
| 5113 | } | |
| 5114 | ||
| 5115 | ||
| 15884 | 5116 | static void ft_outgoing_cancel(PurpleXfer *xfer) { |
| 10977 | 5117 | struct mwFileTransfer *ft = xfer->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5118 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5119 | DEBUG_INFO("ft_outgoing_cancel called\n"); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5120 | |
| 10977 | 5121 | if(ft) mwFileTransfer_cancel(ft); |
| 5122 | } | |
| 5123 | ||
| 5124 | ||
| 15884 | 5125 | static PurpleXfer *mw_prpl_new_xfer(PurpleConnection *gc, const char *who) { |
| 5126 | PurpleAccount *acct; | |
| 5127 | PurpleXfer *xfer; | |
| 5128 | ||
| 5129 | acct = purple_connection_get_account(gc); | |
| 5130 | ||
| 5131 | xfer = purple_xfer_new(acct, PURPLE_XFER_SEND, who); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5132 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5133 | { |
| 15884 | 5134 | purple_xfer_set_init_fnc(xfer, ft_outgoing_init); |
| 5135 | purple_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5136 | } |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5137 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5138 | return xfer; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5139 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5140 | |
| 15884 | 5141 | static void mw_prpl_send_file(PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5142 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5143 | |
| 15884 | 5144 | PurpleXfer *xfer = mw_prpl_new_xfer(gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5145 | |
| 10977 | 5146 | if(file) { |
| 5147 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 5148 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 5149 | |
| 5150 | } else { | |
| 5151 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 5152 | purple_xfer_request(xfer); |
| 10977 | 5153 | } |
| 5154 | } | |
| 5155 | ||
| 5156 | ||
| 15884 | 5157 | static PurplePluginProtocolInfo mw_prpl_info = { |
| 10977 | 5158 | .options = OPT_PROTO_IM_IMAGE, |
| 5159 | .user_splits = NULL, /*< set in mw_plugin_init */ | |
| 5160 | .protocol_options = NULL, /*< set in mw_plugin_init */ | |
| 5161 | .icon_spec = NO_BUDDY_ICONS, | |
| 5162 | .list_icon = mw_prpl_list_icon, | |
| 15524 | 5163 | .list_emblem = mw_prpl_list_emblem, |
| 10977 | 5164 | .status_text = mw_prpl_status_text, |
| 5165 | .tooltip_text = mw_prpl_tooltip_text, | |
| 5166 | .status_types = mw_prpl_status_types, | |
| 5167 | .blist_node_menu = mw_prpl_blist_node_menu, | |
| 5168 | .chat_info = mw_prpl_chat_info, | |
| 5169 | .chat_info_defaults = mw_prpl_chat_info_defaults, | |
| 5170 | .login = mw_prpl_login, | |
| 5171 | .close = mw_prpl_close, | |
| 5172 | .send_im = mw_prpl_send_im, | |
| 5173 | .set_info = NULL, | |
| 5174 | .send_typing = mw_prpl_send_typing, | |
| 5175 | .get_info = mw_prpl_get_info, | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
5176 | .set_status = mw_prpl_set_status, |
| 10977 | 5177 | .set_idle = mw_prpl_set_idle, |
| 5178 | .change_passwd = NULL, | |
| 5179 | .add_buddy = mw_prpl_add_buddy, | |
| 5180 | .add_buddies = mw_prpl_add_buddies, | |
| 5181 | .remove_buddy = mw_prpl_remove_buddy, | |
| 5182 | .remove_buddies = NULL, | |
| 5183 | .add_permit = mw_prpl_add_permit, | |
| 5184 | .add_deny = mw_prpl_add_deny, | |
| 5185 | .rem_permit = mw_prpl_rem_permit, | |
| 5186 | .rem_deny = mw_prpl_rem_deny, | |
| 5187 | .set_permit_deny = mw_prpl_set_permit_deny, | |
| 5188 | .join_chat = mw_prpl_join_chat, | |
| 5189 | .reject_chat = mw_prpl_reject_chat, | |
| 5190 | .get_chat_name = mw_prpl_get_chat_name, | |
| 5191 | .chat_invite = mw_prpl_chat_invite, | |
| 5192 | .chat_leave = mw_prpl_chat_leave, | |
| 5193 | .chat_whisper = mw_prpl_chat_whisper, | |
| 5194 | .chat_send = mw_prpl_chat_send, | |
| 5195 | .keepalive = mw_prpl_keepalive, | |
| 5196 | .register_user = NULL, | |
| 5197 | .get_cb_info = NULL, | |
| 5198 | .get_cb_away = NULL, | |
| 5199 | .alias_buddy = mw_prpl_alias_buddy, | |
| 5200 | .group_buddy = mw_prpl_group_buddy, | |
| 5201 | .rename_group = mw_prpl_rename_group, | |
| 5202 | .buddy_free = mw_prpl_buddy_free, | |
| 5203 | .convo_closed = mw_prpl_convo_closed, | |
| 5204 | .normalize = mw_prpl_normalize, | |
| 5205 | .set_buddy_icon = NULL, | |
| 5206 | .remove_group = mw_prpl_remove_group, | |
| 5207 | .get_cb_real_name = NULL, | |
| 5208 | .set_chat_topic = NULL, | |
| 5209 | .find_blist_chat = NULL, | |
| 5210 | .roomlist_get_list = NULL, | |
| 5211 | .roomlist_expand_category = NULL, | |
| 5212 | .can_receive_file = mw_prpl_can_receive_file, | |
| 5213 | .send_file = mw_prpl_send_file, | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5214 | .new_xfer = mw_prpl_new_xfer, |
|
12650
ca70a14f4994
[gaim-migrate @ 14988]
Mark Doliner <markdoliner@pidgin.im>
parents:
12631
diff
changeset
|
5215 | .offline_message = NULL, |
|
ca70a14f4994
[gaim-migrate @ 14988]
Mark Doliner <markdoliner@pidgin.im>
parents:
12631
diff
changeset
|
5216 | .whiteboard_prpl_ops = NULL, |
|
19882
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19586
diff
changeset
|
5217 | .send_raw = NULL, |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5218 | .struct_size = sizeof(PurplePluginProtocolInfo) |
| 10977 | 5219 | }; |
| 5220 | ||
| 5221 | ||
| 15884 | 5222 | static PurplePluginPrefFrame * |
| 5223 | mw_plugin_get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 5224 | PurplePluginPrefFrame *frame; | |
| 5225 | PurplePluginPref *pref; | |
| 5226 | ||
| 5227 | frame = purple_plugin_pref_frame_new(); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5228 | |
| 15884 | 5229 | pref = purple_plugin_pref_new_with_label(_("Remotely Stored Buddy List")); |
| 5230 | purple_plugin_pref_frame_add(frame, pref); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5231 | |
| 10977 | 5232 | |
| 15884 | 5233 | pref = purple_plugin_pref_new_with_name(MW_PRPL_OPT_BLIST_ACTION); |
| 5234 | purple_plugin_pref_set_label(pref, _("Buddy List Storage Mode")); | |
| 5235 | ||
| 5236 | purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE); | |
| 5237 | 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
|
5238 | GINT_TO_POINTER(blist_choice_LOCAL)); |
| 15884 | 5239 | 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
|
5240 | GINT_TO_POINTER(blist_choice_MERGE)); |
| 15884 | 5241 | 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
|
5242 | GINT_TO_POINTER(blist_choice_STORE)); |
| 15884 | 5243 | 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
|
5244 | GINT_TO_POINTER(blist_choice_SYNCH)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5245 | |
| 15884 | 5246 | purple_plugin_pref_frame_add(frame, pref); |
| 10977 | 5247 | |
| 5248 | return frame; | |
| 5249 | } | |
| 5250 | ||
| 5251 | ||
| 15884 | 5252 | static PurplePluginUiInfo mw_plugin_ui_info = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5253 | mw_plugin_get_plugin_pref_frame, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5254 | 0, /* page_num */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5255 | NULL, /* frame */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5256 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5257 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5258 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5259 | NULL |
| 10977 | 5260 | }; |
| 5261 | ||
| 5262 | ||
| 15884 | 5263 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5264 | struct mwSametimeList *l; |
| 5265 | ||
| 5266 | FILE *file; | |
| 5267 | char buf[BUF_LEN]; | |
| 5268 | size_t len; | |
| 5269 | ||
| 5270 | GString *str; | |
| 5271 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5272 | file = g_fopen(filename, "r"); |
| 10977 | 5273 | g_return_if_fail(file != NULL); |
| 5274 | ||
| 5275 | str = g_string_new(NULL); | |
| 5276 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 5277 | g_string_append_len(str, buf, len); | |
| 5278 | } | |
| 5279 | ||
| 5280 | fclose(file); | |
| 5281 | ||
| 5282 | l = mwSametimeList_load(str->str); | |
| 5283 | g_string_free(str, TRUE); | |
| 5284 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5285 | blist_merge(gc, l); |
| 10977 | 5286 | mwSametimeList_free(l); |
| 5287 | } | |
| 5288 | ||
| 5289 | ||
| 5290 | /** prompts for a file to import blist from */ | |
| 15884 | 5291 | static void st_import_action(PurplePluginAction *act) { |
| 5292 | PurpleConnection *gc; | |
| 5293 | PurpleAccount *account; | |
| 10977 | 5294 | char *title; |
| 5295 | ||
| 5296 | gc = act->context; | |
| 15884 | 5297 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5298 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 5299 | purple_account_get_username(account)); |
| 5300 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5301 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 5302 | 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
|
5303 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5304 | gc); |
| 10977 | 5305 | |
| 5306 | g_free(title); | |
| 5307 | } | |
| 5308 | ||
| 5309 | ||
| 15884 | 5310 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5311 | struct mwSametimeList *l; |
| 5312 | char *str; | |
| 5313 | FILE *file; | |
| 5314 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5315 | file = g_fopen(filename, "w"); |
| 10977 | 5316 | g_return_if_fail(file != NULL); |
| 5317 | ||
| 5318 | l = mwSametimeList_new(); | |
| 5319 | blist_export(gc, l); | |
| 5320 | str = mwSametimeList_store(l); | |
| 5321 | mwSametimeList_free(l); | |
| 5322 | ||
| 5323 | fprintf(file, "%s", str); | |
| 5324 | fclose(file); | |
| 5325 | ||
| 5326 | g_free(str); | |
| 5327 | } | |
| 5328 | ||
| 5329 | ||
| 5330 | /** prompts for a file to export blist to */ | |
| 15884 | 5331 | static void st_export_action(PurplePluginAction *act) { |
| 5332 | PurpleConnection *gc; | |
| 5333 | PurpleAccount *account; | |
| 10977 | 5334 | char *title; |
| 5335 | ||
| 5336 | gc = act->context; | |
| 15884 | 5337 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5338 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 5339 | purple_account_get_username(account)); |
| 5340 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5341 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 5342 | 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
|
5343 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5344 | gc); |
| 10977 | 5345 | |
| 5346 | g_free(title); | |
| 5347 | } | |
| 5348 | ||
| 5349 | ||
| 5350 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 5351 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5352 | |
| 15884 | 5353 | 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
|
5354 | GList *l; |
| 10977 | 5355 | |
| 15884 | 5356 | f = purple_request_fields_get_field(fields, "group"); |
| 5357 | l = purple_request_field_list_get_items(f); | |
| 10977 | 5358 | |
| 5359 | for(; l; l = l->next) { | |
| 5360 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5361 | struct named_id *res; |
| 10977 | 5362 | |
| 15884 | 5363 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5364 | |
| 5365 | g_free(res->id); | |
| 5366 | g_free(res->name); | |
| 5367 | g_free(res); | |
| 5368 | } | |
| 5369 | } | |
| 5370 | ||
| 5371 | ||
| 15884 | 5372 | static void remote_group_done(struct mwPurplePluginData *pd, |
| 10977 | 5373 | const char *id, const char *name) { |
| 15884 | 5374 | PurpleConnection *gc; |
| 5375 | PurpleAccount *acct; | |
| 5376 | PurpleGroup *group; | |
| 5377 | PurpleBlistNode *gn; | |
| 10977 | 5378 | const char *owner; |
| 5379 | ||
| 5380 | g_return_if_fail(pd != NULL); | |
| 5381 | ||
| 5382 | gc = pd->gc; | |
| 15884 | 5383 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5384 | |
| 10977 | 5385 | /* collision checking */ |
| 15884 | 5386 | group = purple_find_group(name); |
| 10977 | 5387 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5388 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5389 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5390 | char *msg; |
| 10977 | 5391 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5392 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5393 | 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
|
5394 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5395 | |
| 15884 | 5396 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5397 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5398 | g_free(msg); |
| 10977 | 5399 | return; |
| 5400 | } | |
| 5401 | ||
| 15884 | 5402 | group = purple_group_new(name); |
| 5403 | gn = (PurpleBlistNode *) group; | |
| 5404 | ||
| 5405 | owner = purple_account_get_username(acct); | |
| 5406 | ||
| 5407 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 5408 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 5409 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 5410 | purple_blist_add_group(group, NULL); | |
| 10977 | 5411 | |
| 5412 | group_add(pd, group); | |
| 5413 | blist_schedule(pd); | |
| 5414 | } | |
| 5415 | ||
| 5416 | ||
| 15884 | 5417 | static void remote_group_multi_cb(struct mwPurplePluginData *pd, |
| 5418 | PurpleRequestFields *fields) { | |
| 5419 | 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
|
5420 | GList *l; |
| 10977 | 5421 | |
| 15884 | 5422 | f = purple_request_fields_get_field(fields, "group"); |
| 5423 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 5424 | |
| 5425 | if(l) { | |
| 5426 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5427 | struct named_id *res; |
| 10977 | 5428 | |
| 15884 | 5429 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5430 | remote_group_done(pd, res->id, res->name); |
| 5431 | } | |
| 5432 | ||
| 5433 | remote_group_multi_cleanup(NULL, fields); | |
| 5434 | } | |
| 5435 | ||
| 5436 | ||
| 5437 | static void remote_group_multi(struct mwResolveResult *result, | |
| 15884 | 5438 | struct mwPurplePluginData *pd) { |
| 5439 | ||
| 5440 | PurpleRequestFields *fields; | |
| 5441 | PurpleRequestFieldGroup *g; | |
| 5442 | PurpleRequestField *f; | |
| 10977 | 5443 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5444 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5445 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5446 | char *msg; |
| 10977 | 5447 | |
| 15884 | 5448 | PurpleConnection *gc = pd->gc; |
| 5449 | ||
| 5450 | fields = purple_request_fields_new(); | |
| 5451 | ||
| 5452 | g = purple_request_field_group_new(NULL); | |
| 5453 | purple_request_fields_add_group(fields, g); | |
| 5454 | ||
| 5455 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 5456 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 5457 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 5458 | |
| 5459 | for(l = result->matches; l; l = l->next) { | |
| 5460 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5461 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 5462 | |
| 5463 | res->id = g_strdup(match->id); | |
| 5464 | res->name = g_strdup(match->name); | |
| 5465 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
5466 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 5467 | } |
| 5468 | ||
| 15884 | 5469 | purple_request_field_group_add_field(g, f); |
| 10977 | 5470 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5471 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5472 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 5473 | " Notes Address Book groups. Please select the correct group from" |
| 5474 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5475 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 5476 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5477 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5478 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5479 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5480 | _("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
|
5481 | purple_connection_get_account(gc), result->name, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5482 | pd); |
| 10977 | 5483 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5484 | g_free(msg); |
| 10977 | 5485 | } |
| 5486 | ||
| 5487 | ||
| 5488 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 5489 | guint32 id, guint32 code, GList *results, | |
| 5490 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5491 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5492 | struct mwResolveResult *res = NULL; |
| 10977 | 5493 | struct mwSession *session; |
| 15884 | 5494 | struct mwPurplePluginData *pd; |
| 5495 | PurpleConnection *gc; | |
| 10977 | 5496 | |
| 5497 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5498 | g_return_if_fail(session != NULL); | |
| 5499 | ||
| 5500 | pd = mwSession_getClientData(session); | |
| 5501 | g_return_if_fail(pd != NULL); | |
| 5502 | ||
| 5503 | gc = pd->gc; | |
| 5504 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5505 | |
| 10977 | 5506 | if(!code && results) { |
| 5507 | res = results->data; | |
| 5508 | ||
| 5509 | if(res->matches) { | |
| 5510 | remote_group_multi(res, pd); | |
| 5511 | return; | |
| 5512 | } | |
| 5513 | } | |
| 5514 | ||
| 5515 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5516 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5517 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5518 | char *msg; |
| 10977 | 5519 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5520 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5521 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5522 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5523 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5524 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5525 | |
| 15884 | 5526 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5527 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5528 | g_free(msg); |
| 10977 | 5529 | } |
| 5530 | } | |
| 5531 | ||
| 5532 | ||
| 15884 | 5533 | static void remote_group_action_cb(PurpleConnection *gc, const char *name) { |
| 5534 | struct mwPurplePluginData *pd; | |
| 10977 | 5535 | struct mwServiceResolve *srvc; |
| 5536 | GList *query; | |
| 5537 | enum mwResolveFlag flags; | |
| 5538 | guint32 req; | |
| 5539 | ||
| 5540 | pd = gc->proto_data; | |
| 5541 | srvc = pd->srvc_resolve; | |
| 5542 | ||
| 5543 | query = g_list_prepend(NULL, (char *) name); | |
| 5544 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5545 | |
| 10977 | 5546 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5547 | NULL, NULL); | |
| 5548 | g_list_free(query); | |
| 5549 | ||
| 5550 | if(req == SEARCH_ERROR) { | |
| 5551 | /** @todo display error */ | |
| 5552 | } | |
| 5553 | } | |
| 5554 | ||
| 5555 | ||
| 15884 | 5556 | static void remote_group_action(PurplePluginAction *act) { |
| 5557 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5558 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5559 | const char *msgB; |
| 10977 | 5560 | |
| 5561 | gc = act->context; | |
| 5562 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5563 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5564 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5565 | " to add the group and its members to your buddy list."); |
| 5566 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5567 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5568 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5569 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5570 | _("Cancel"), NULL, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16121
diff
changeset
|
5571 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5572 | gc); |
| 10977 | 5573 | } |
| 5574 | ||
| 5575 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5576 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5577 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5578 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5579 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5580 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5581 | char *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5582 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5583 | |
| 15884 | 5584 | PurpleNotifySearchResults *sres; |
| 5585 | PurpleNotifySearchColumn *scol; | |
| 5586 | ||
| 5587 | sres = purple_notify_searchresults_new(); | |
| 5588 | ||
| 5589 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5590 | purple_notify_searchresults_column_add(sres, scol); | |
| 5591 | ||
| 5592 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5593 | purple_notify_searchresults_column_add(sres, scol); | |
| 5594 | ||
| 5595 | 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
|
5596 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5597 | |
| 15884 | 5598 | 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
|
5599 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5600 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5601 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5602 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5603 | GList *row = NULL; |
|
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 | if(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5606 | continue; |
|
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 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5609 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5610 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5611 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5612 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5613 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5614 | 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
|
5615 | " 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
|
5616 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5617 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5618 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5619 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5620 | |
| 15884 | 5621 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5622 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5623 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5624 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5625 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5626 | } |
|
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 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5629 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5630 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5631 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5632 | |
| 15884 | 5633 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5634 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5635 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5636 | if(results) res = results->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5637 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5638 | if(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5639 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5640 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5641 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5642 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5643 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5644 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5645 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5646 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5647 | 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
|
5648 | " Sametime community."); |
|
20228
ce019944d765
applied changes from 9d35dde0c779cca73548172223ba557f27d61882
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
5649 | 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
|
5650 | |
| 15884 | 5651 | purple_notify_error(gc, _("No Matches"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5652 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5653 | g_free(msg); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5654 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5655 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5656 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5657 | |
| 15884 | 5658 | static void search_action_cb(PurpleConnection *gc, const char *name) { |
| 5659 | struct mwPurplePluginData *pd; | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5660 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5661 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5662 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5663 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5664 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5665 | pd = gc->proto_data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5666 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5667 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5668 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5669 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5670 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5671 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5672 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5673 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5674 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5675 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5676 | /** @todo display error */ |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5677 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5678 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5679 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5680 | |
| 15884 | 5681 | static void search_action(PurplePluginAction *act) { |
| 5682 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5683 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5684 | const char *msgB; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5685 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5686 | gc = act->context; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5687 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5688 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5689 | 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
|
5690 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5691 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5692 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5693 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5694 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5695 | _("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
|
5696 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5697 | gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5698 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5699 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5700 | |
| 15884 | 5701 | static GList *mw_plugin_actions(PurplePlugin *plugin, gpointer context) { |
| 5702 | PurplePluginAction *act; | |
| 10977 | 5703 | GList *l = NULL; |
| 5704 | ||
| 15884 | 5705 | act = purple_plugin_action_new(_("Import Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5706 | st_import_action); |
| 10977 | 5707 | l = g_list_append(l, act); |
| 5708 | ||
| 15884 | 5709 | act = purple_plugin_action_new(_("Export Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5710 | st_export_action); |
| 10977 | 5711 | l = g_list_append(l, act); |
| 5712 | ||
| 15884 | 5713 | act = purple_plugin_action_new(_("Add Notes Address Book Group..."), |
| 10977 | 5714 | remote_group_action); |
| 5715 | l = g_list_append(l, act); | |
| 5716 | ||
| 15884 | 5717 | act = purple_plugin_action_new(_("User Search..."), |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5718 | search_action); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5719 | l = g_list_append(l, act); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5720 | |
| 10977 | 5721 | return l; |
| 5722 | } | |
| 5723 | ||
| 5724 | ||
| 15884 | 5725 | static gboolean mw_plugin_load(PurplePlugin *plugin) { |
| 10977 | 5726 | return TRUE; |
| 5727 | } | |
| 5728 | ||
| 5729 | ||
| 15884 | 5730 | static gboolean mw_plugin_unload(PurplePlugin *plugin) { |
| 10977 | 5731 | return TRUE; |
| 5732 | } | |
| 5733 | ||
| 5734 | ||
| 15884 | 5735 | static void mw_plugin_destroy(PurplePlugin *plugin) { |
| 10977 | 5736 | g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); |
| 5737 | g_log_remove_handler("meanwhile", log_handler[1]); | |
| 5738 | } | |
| 5739 | ||
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5740 | static PurplePluginInfo mw_plugin_info = |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5741 | { |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5742 | PURPLE_PLUGIN_MAGIC, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5743 | PURPLE_MAJOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5744 | PURPLE_MINOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5745 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5746 | NULL, /**< ui_requirement */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5747 | 0, /**< flags */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5748 | NULL, /**< dependencies */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5749 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5750 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5751 | PLUGIN_ID, /**< id */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5752 | PLUGIN_NAME, /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20228
diff
changeset
|
5753 | DISPLAY_VERSION, /**< version */ |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5754 | PLUGIN_SUMMARY, /**< summary */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5755 | PLUGIN_DESC, /**< description */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5756 | PLUGIN_AUTHOR, /**< author */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5757 | PLUGIN_HOMEPAGE, /**< homepage */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5758 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5759 | mw_plugin_load, /**< load */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5760 | mw_plugin_unload, /**< unload */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5761 | mw_plugin_destroy, /**< destroy */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5762 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5763 | NULL, /**< ui_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5764 | &mw_prpl_info, /**< extra_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5765 | &mw_plugin_ui_info, /**< prefs_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5766 | mw_plugin_actions, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5767 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5768 | /* padding */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5769 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5770 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5771 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5772 | NULL |
| 10977 | 5773 | }; |
| 5774 | ||
| 5775 | ||
| 5776 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5777 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5778 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5779 | if(! (msg && *msg)) return; |
| 10977 | 5780 | |
| 15884 | 5781 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5782 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5783 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5784 | |
| 5785 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5786 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5787 | |
| 5788 | } else { | |
| 15884 | 5789 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5790 | } |
| 5791 | } | |
| 5792 | ||
| 5793 | ||
| 15884 | 5794 | static void mw_plugin_init(PurplePlugin *plugin) { |
| 5795 | PurpleAccountOption *opt; | |
| 10977 | 5796 | GList *l = NULL; |
| 5797 | ||
| 5798 | GLogLevelFlags logflags = | |
| 5799 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5800 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5801 | /* set up the preferences */ |
| 15884 | 5802 | purple_prefs_add_none(MW_PRPL_OPT_BASE); |
| 5803 | 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
|
5804 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5805 | /* remove dead preferences */ |
| 15884 | 5806 | purple_prefs_remove(MW_PRPL_OPT_PSYCHIC); |
| 5807 | purple_prefs_remove(MW_PRPL_OPT_SAVE_DYNAMIC); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5808 | |
| 10977 | 5809 | /* host to connect to */ |
| 15884 | 5810 | opt = purple_account_option_string_new(_("Server"), MW_KEY_HOST, |
| 10977 | 5811 | MW_PLUGIN_DEFAULT_HOST); |
| 5812 | l = g_list_append(l, opt); | |
| 5813 | ||
| 5814 | /* port to connect to */ | |
| 15884 | 5815 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
| 10977 | 5816 | MW_PLUGIN_DEFAULT_PORT); |
| 5817 | l = g_list_append(l, opt); | |
| 5818 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5819 | { /* 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
|
5820 | 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
|
5821 | than one account that wants to check for it. */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5822 | gboolean b = FALSE; |
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12422
diff
changeset
|
5823 | const char *label = _("Force login (ignore server redirects)"); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5824 | |
| 15884 | 5825 | if(purple_prefs_exists(MW_PRPL_OPT_FORCE_LOGIN)) |
| 5826 | b = purple_prefs_get_bool(MW_PRPL_OPT_FORCE_LOGIN); | |
| 5827 | ||
| 5828 | 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
|
5829 | l = g_list_append(l, opt); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5830 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5831 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5832 | /* pretend to be Sametime Connect */ |
| 15884 | 5833 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5834 | MW_KEY_FAKE_IT, FALSE); |
|
12312
470a1452d009
[gaim-migrate @ 14616]
Christopher O'Brien <siege@pidgin.im>
parents:
12311
diff
changeset
|
5835 | l = g_list_append(l, opt); |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5836 | |
| 10977 | 5837 | mw_prpl_info.protocol_options = l; |
| 5838 | l = NULL; | |
| 5839 | ||
| 15884 | 5840 | /* forward all our g_log messages to purple. Generally all the logging |
| 5841 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5842 | get caught here */ |
| 5843 | log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags, | |
| 5844 | mw_log_handler, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5845 | |
| 15884 | 5846 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5847 | log_handler[1] = g_log_set_handler("meanwhile", logflags, |
| 5848 | mw_log_handler, NULL); | |
| 5849 | } | |
| 5850 | ||
| 5851 | ||
| 15884 | 5852 | PURPLE_INIT_PLUGIN(sametime, mw_plugin_init, mw_plugin_info); |
| 10977 | 5853 | /* The End. */ |
| 5854 |