Sat, 01 Oct 2011 18:21:43 +0000
Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
| 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. |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
200 | available as purple_connection_get_protocol_data(gc) 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 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
323 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 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); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
416 | purple_connection_error(pd->gc, |
| 21279 | 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 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
502 | pd = purple_connection_get_protocol_data(gc); |
|
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 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
854 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 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); | |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
864 | g_return_val_if_fail(*id, NULL); |
| 10977 | 865 | |
| 15884 | 866 | buddy = purple_find_buddy_in_group(acct, id, group); |
| 10977 | 867 | if(! buddy) { |
| 15884 | 868 | buddy = purple_buddy_new(acct, id, alias); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
869 | |
| 15884 | 870 | purple_blist_add_buddy(buddy, NULL, group, NULL); |
| 10977 | 871 | buddy_add(pd, buddy); |
| 872 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
873 | |
| 15884 | 874 | purple_blist_alias_buddy(buddy, alias); |
| 875 | purple_blist_server_alias_buddy(buddy, name); | |
| 876 | purple_blist_node_set_string((PurpleBlistNode *) buddy, BUDDY_KEY_NAME, name); | |
| 877 | purple_blist_node_set_int((PurpleBlistNode *) buddy, BUDDY_KEY_TYPE, type); | |
| 10977 | 878 | |
| 879 | return buddy; | |
| 880 | } | |
| 881 | ||
| 882 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
883 | /** add aware watch for a dynamic group */ |
| 15884 | 884 | static void group_add(struct mwPurplePluginData *pd, |
| 885 | PurpleGroup *group) { | |
| 10977 | 886 | |
| 887 | struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL }; | |
| 888 | struct mwAwareList *list; | |
| 889 | const char *n; | |
| 890 | GList *add; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
891 | |
| 15884 | 892 | n = purple_blist_node_get_string((PurpleBlistNode *) group, GROUP_KEY_NAME); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
893 | if(! n) n = purple_group_get_name(group); |
| 10977 | 894 | |
| 895 | idb.user = (char *) n; | |
| 896 | add = g_list_prepend(NULL, &idb); | |
| 897 | ||
| 898 | list = list_ensure(pd, group); | |
| 899 | mwAwareList_addAware(list, add); | |
| 900 | g_list_free(add); | |
| 901 | } | |
| 902 | ||
| 903 | ||
| 15884 | 904 | /** ensure that a PurpleGroup exists in the blist with data |
| 10977 | 905 | appropriately matching the st group entry from the st list */ |
| 15884 | 906 | static PurpleGroup *group_ensure(PurpleConnection *gc, |
| 10977 | 907 | struct mwSametimeGroup *stgroup) { |
| 15884 | 908 | PurpleAccount *acct; |
| 909 | PurpleGroup *group = NULL; | |
| 910 | PurpleBuddyList *blist; | |
| 911 | PurpleBlistNode *gn; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
912 | const char *name, *alias, *owner; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
913 | enum mwSametimeGroupType type; |
| 10977 | 914 | |
| 15884 | 915 | acct = purple_connection_get_account(gc); |
| 916 | owner = purple_account_get_username(acct); | |
| 917 | ||
| 918 | blist = purple_get_blist(); | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
919 | g_return_val_if_fail(blist != NULL, NULL); |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
920 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
921 | name = mwSametimeGroup_getName(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
922 | alias = mwSametimeGroup_getAlias(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
923 | type = mwSametimeGroup_getType(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
924 | |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
925 | if (!name) { |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
926 | DEBUG_WARN("Can't ensure a null group\n"); |
|
31991
efe4fb3772ad
Fix this compile warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
31983
diff
changeset
|
927 | return NULL; |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
928 | } |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
929 | |
|
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); |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
971 | group_add(purple_connection_get_protocol_data(gc), group); |
| 10977 | 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) { |
|
32319
ab70b05e538b
sametime: fix build (add_buddies added param)
Paul Aurich <darkrain42@pidgin.im>
parents:
32316
diff
changeset
|
1401 | purple_account_add_buddies(acct, add_buds, NULL); |
|
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 | } |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1616 | purple_connection_error(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"); | |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1765 | purple_connection_error(pd->gc, |
| 21279 | 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); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1776 | purple_connection_error(pd->gc, |
| 21279 | 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); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1802 | purple_connection_error(pd->gc, |
| 21279 | 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 */ |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2142 | struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
| 10977 | 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 | ||
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2158 | ft = purple_xfer_get_protocol_data(xfer); |
| 10977 | 2159 | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2160 | fp = g_fopen(purple_xfer_get_local_filename(xfer), "wb"); |
| 10977 | 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); | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2205 | purple_xfer_set_protocol_data(xfer, ft); |
|
15345
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 */ |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2234 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + o.len); |
| 15884 | 2235 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2236 | |
| 10977 | 2237 | mwFileTransfer_send(ft, &o); |
| 2238 | ||
| 2239 | } else { | |
| 2240 | int err = errno; | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2241 | 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
|
2242 | NSTR(mwFileTransfer_getFileName(ft)), g_strerror(err)); |
| 10977 | 2243 | |
| 2244 | mwFileTransfer_cancel(ft); | |
| 2245 | } | |
| 2246 | } | |
| 2247 | ||
| 2248 | ||
| 2249 | static void mw_ft_opened(struct mwFileTransfer *ft) { | |
| 2250 | /* | |
| 15884 | 2251 | - get purple ft from client data in ft |
| 10977 | 2252 | - set the state to active |
| 2253 | */ | |
| 2254 | ||
| 15884 | 2255 | PurpleXfer *xfer; |
| 10977 | 2256 | |
| 2257 | xfer = mwFileTransfer_getClientData(ft); | |
| 2258 | ||
| 2259 | if(! xfer) { | |
| 2260 | mwFileTransfer_cancel(ft); | |
| 2261 | mwFileTransfer_free(ft); | |
| 2262 | g_return_if_reached(); | |
| 2263 | } | |
| 2264 | ||
| 15884 | 2265 | if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2266 | xfer->dest_fp = g_fopen(purple_xfer_get_local_filename(xfer), "rb"); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2267 | ft_send(ft, xfer->dest_fp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2268 | } |
| 10977 | 2269 | } |
| 2270 | ||
| 2271 | ||
| 2272 | static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
| 2273 | /* | |
| 15884 | 2274 | - get purple ft from client data in ft |
| 10977 | 2275 | - indicate rejection/cancelation/completion |
| 2276 | - free the file transfer itself | |
| 2277 | */ | |
| 2278 | ||
| 15884 | 2279 | PurpleXfer *xfer; |
| 10977 | 2280 | |
| 2281 | xfer = mwFileTransfer_getClientData(ft); | |
| 2282 | if(xfer) { | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2283 | purple_xfer_set_protocol_data(xfer, NULL); |
| 10977 | 2284 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2285 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2286 | purple_xfer_set_completed(xfer, TRUE); |
| 2287 | purple_xfer_end(xfer); | |
| 10977 | 2288 | |
| 2289 | } else if(mwFileTransfer_isCancelLocal(ft)) { | |
| 15884 | 2290 | /* calling purple_xfer_cancel_local is redundant, since that's |
| 10977 | 2291 | probably what triggered this function to be called */ |
| 2292 | ; | |
| 2293 | ||
| 2294 | } else if(mwFileTransfer_isCancelRemote(ft)) { | |
| 2295 | /* steal the reference for the xfer */ | |
| 2296 | mwFileTransfer_setClientData(ft, NULL, NULL); | |
| 15884 | 2297 | purple_xfer_cancel_remote(xfer); |
| 10977 | 2298 | |
| 2299 | /* drop the stolen reference */ | |
| 15884 | 2300 | purple_xfer_unref(xfer); |
| 10977 | 2301 | return; |
| 2302 | } | |
| 2303 | } | |
| 2304 | ||
| 2305 | mwFileTransfer_free(ft); | |
| 2306 | } | |
| 2307 | ||
| 2308 | ||
| 2309 | static void mw_ft_recv(struct mwFileTransfer *ft, | |
| 2310 | struct mwOpaque *data) { | |
| 2311 | /* | |
| 15884 | 2312 | - get purple ft from client data in ft |
| 10977 | 2313 | - update transfered percentage |
| 15884 | 2314 | - if done, destroy the ft, disassociate from purple ft |
| 10977 | 2315 | */ |
| 2316 | ||
| 15884 | 2317 | PurpleXfer *xfer; |
| 10977 | 2318 | 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
|
2319 | size_t wc; |
| 10977 | 2320 | |
| 2321 | xfer = mwFileTransfer_getClientData(ft); | |
| 2322 | g_return_if_fail(xfer != NULL); | |
| 2323 | ||
| 2324 | fp = xfer->dest_fp; | |
| 2325 | g_return_if_fail(fp != NULL); | |
| 2326 | ||
| 2327 | /* 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
|
2328 | 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
|
2329 | 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
|
2330 | 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
|
2331 | 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
|
2332 | return; |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2333 | } |
| 10977 | 2334 | |
| 2335 | /* update the progress */ | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2336 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + data->len); |
| 15884 | 2337 | purple_xfer_update_progress(xfer); |
| 10977 | 2338 | |
| 2339 | /* let the other side know we got it, and to send some more */ | |
| 2340 | mwFileTransfer_ack(ft); | |
| 2341 | } | |
| 2342 | ||
| 2343 | ||
| 2344 | static void mw_ft_ack(struct mwFileTransfer *ft) { | |
| 15884 | 2345 | PurpleXfer *xfer; |
| 10977 | 2346 | |
| 2347 | xfer = mwFileTransfer_getClientData(ft); | |
| 2348 | g_return_if_fail(xfer != NULL); | |
| 2349 | g_return_if_fail(xfer->watcher == 0); | |
| 2350 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2351 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2352 | purple_xfer_set_completed(xfer, TRUE); |
| 2353 | purple_xfer_end(xfer); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2354 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2355 | } else if(mwFileTransfer_isOpen(ft)) { |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2356 | ft_send(ft, xfer->dest_fp); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2357 | } |
| 10977 | 2358 | } |
| 2359 | ||
| 2360 | ||
| 2361 | static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
| 2362 | ; | |
| 2363 | } | |
| 2364 | ||
| 2365 | ||
| 2366 | static struct mwFileTransferHandler mw_ft_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2367 | mw_ft_offered, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2368 | mw_ft_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2369 | mw_ft_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2370 | mw_ft_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2371 | mw_ft_ack, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2372 | mw_ft_clear, |
| 10977 | 2373 | }; |
| 2374 | ||
| 2375 | ||
| 2376 | static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
| 2377 | struct mwServiceFileTransfer *srvc; | |
| 2378 | GHashTable *ft_map; | |
| 2379 | ||
| 2380 | ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 2381 | ||
| 2382 | srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
| 2383 | mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
| 2384 | (GDestroyNotify) g_hash_table_destroy); | |
| 2385 | ||
| 2386 | return srvc; | |
| 2387 | } | |
| 2388 | ||
| 2389 | ||
| 2390 | static void convo_data_free(struct convo_data *cd) { | |
| 2391 | GList *l; | |
| 2392 | ||
| 2393 | /* clean the queue */ | |
| 2394 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2395 | struct convo_msg *m = l->data; | |
| 2396 | if(m->clear) m->clear(m->data); | |
| 2397 | g_free(m); | |
| 2398 | } | |
| 2399 | ||
| 2400 | g_free(cd); | |
| 2401 | } | |
| 2402 | ||
| 2403 | ||
| 2404 | /** allocates a convo_data structure and associates it with the | |
| 2405 | conversation in the client data slot */ | |
| 2406 | static void convo_data_new(struct mwConversation *conv) { | |
| 2407 | struct convo_data *cd; | |
| 2408 | ||
| 2409 | g_return_if_fail(conv != NULL); | |
| 2410 | ||
| 2411 | if(mwConversation_getClientData(conv)) | |
| 2412 | return; | |
| 2413 | ||
| 2414 | cd = g_new0(struct convo_data, 1); | |
| 2415 | cd->conv = conv; | |
| 2416 | ||
| 2417 | mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
| 2418 | } | |
| 2419 | ||
| 2420 | ||
| 15884 | 2421 | static PurpleConversation *convo_get_gconv(struct mwConversation *conv) { |
| 10977 | 2422 | struct mwServiceIm *srvc; |
| 2423 | struct mwSession *session; | |
| 15884 | 2424 | struct mwPurplePluginData *pd; |
| 2425 | PurpleConnection *gc; | |
| 2426 | PurpleAccount *acct; | |
| 10977 | 2427 | |
| 2428 | struct mwIdBlock *idb; | |
| 2429 | ||
| 2430 | srvc = mwConversation_getService(conv); | |
| 2431 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2432 | pd = mwSession_getClientData(session); | |
| 2433 | gc = pd->gc; | |
| 15884 | 2434 | acct = purple_connection_get_account(gc); |
| 10977 | 2435 | |
| 2436 | idb = mwConversation_getTarget(conv); | |
| 2437 | ||
| 15884 | 2438 | 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
|
2439 | idb->user, acct); |
| 10977 | 2440 | } |
| 2441 | ||
| 2442 | ||
| 2443 | static void convo_queue(struct mwConversation *conv, | |
| 2444 | enum mwImSendType type, gconstpointer data) { | |
| 2445 | ||
| 2446 | struct convo_data *cd; | |
| 2447 | struct convo_msg *m; | |
| 2448 | ||
| 2449 | convo_data_new(conv); | |
| 2450 | cd = mwConversation_getClientData(conv); | |
| 2451 | ||
| 2452 | m = g_new0(struct convo_msg, 1); | |
| 2453 | m->type = type; | |
| 2454 | ||
| 2455 | switch(type) { | |
| 2456 | case mwImSend_PLAIN: | |
| 2457 | m->data = g_strdup(data); | |
| 2458 | m->clear = g_free; | |
| 2459 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2460 | |
| 10977 | 2461 | case mwImSend_TYPING: |
| 2462 | default: | |
| 2463 | m->data = (gpointer) data; | |
| 2464 | m->clear = NULL; | |
| 2465 | } | |
| 2466 | ||
| 2467 | cd->queue = g_list_append(cd->queue, m); | |
| 2468 | } | |
| 2469 | ||
| 2470 | ||
| 2471 | /* Does what it takes to get an error displayed for a conversation */ | |
| 2472 | static void convo_error(struct mwConversation *conv, guint32 err) { | |
| 15884 | 2473 | PurpleConversation *gconv; |
| 10977 | 2474 | char *tmp, *text; |
| 2475 | struct mwIdBlock *idb; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2476 | |
| 10977 | 2477 | idb = mwConversation_getTarget(conv); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2478 | |
| 10977 | 2479 | tmp = mwError(err); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2480 | text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2481 | |
| 10977 | 2482 | gconv = convo_get_gconv(conv); |
|
32617
c74b4bd27e37
Use purple_conversation accessor methods.
Andrew Victor <andrew.victor@mxit.com>
parents:
32338
diff
changeset
|
2483 | if(gconv && !purple_conv_present_error(idb->user, purple_conversation_get_account(gconv), text)) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2484 | |
| 10977 | 2485 | g_free(text); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2486 | text = g_strdup_printf(_("Unable to send message to %s:"), |
| 10977 | 2487 | (idb->user)? idb->user: "(unknown)"); |
|
32617
c74b4bd27e37
Use purple_conversation accessor methods.
Andrew Victor <andrew.victor@mxit.com>
parents:
32338
diff
changeset
|
2488 | purple_notify_error(purple_account_get_connection(purple_conversation_get_account(gconv)), |
| 10977 | 2489 | NULL, text, tmp); |
| 2490 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2491 | |
| 10977 | 2492 | g_free(tmp); |
| 2493 | g_free(text); | |
| 2494 | } | |
| 2495 | ||
| 2496 | ||
| 2497 | static void convo_queue_send(struct mwConversation *conv) { | |
| 2498 | struct convo_data *cd; | |
| 2499 | GList *l; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2500 | |
| 10977 | 2501 | cd = mwConversation_getClientData(conv); |
| 2502 | ||
| 2503 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2504 | struct convo_msg *m = l->data; | |
| 2505 | ||
| 2506 | mwConversation_send(conv, m->type, m->data); | |
| 2507 | ||
| 2508 | if(m->clear) m->clear(m->data); | |
| 2509 | g_free(m); | |
| 2510 | } | |
| 2511 | ||
| 2512 | cd->queue = NULL; | |
| 2513 | } | |
| 2514 | ||
| 2515 | ||
| 15884 | 2516 | /** called when a mw conversation leaves a purple conversation to |
| 2517 | inform the purple conversation that it's unsafe to offer any *cool* | |
| 10977 | 2518 | features. */ |
| 2519 | static void convo_nofeatures(struct mwConversation *conv) { | |
| 15884 | 2520 | PurpleConversation *gconv; |
| 2521 | PurpleConnection *gc; | |
| 10977 | 2522 | |
| 2523 | gconv = convo_get_gconv(conv); | |
| 2524 | if(! gconv) return; | |
| 2525 | ||
| 15884 | 2526 | gc = purple_conversation_get_gc(gconv); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2527 | if(! gc) return; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2528 | |
| 15884 | 2529 | purple_conversation_set_features(gconv, gc->flags); |
| 2530 | } | |
| 2531 | ||
| 2532 | ||
| 2533 | /** called when a mw conversation and purple conversation come together, | |
| 2534 | to inform the purple conversation of what features to offer the | |
| 10977 | 2535 | user */ |
| 2536 | static void convo_features(struct mwConversation *conv) { | |
| 15884 | 2537 | PurpleConversation *gconv; |
| 2538 | PurpleConnectionFlags feat; | |
| 10977 | 2539 | |
| 2540 | gconv = convo_get_gconv(conv); | |
| 2541 | if(! gconv) return; | |
| 2542 | ||
| 15884 | 2543 | feat = purple_conversation_get_features(gconv); |
| 10977 | 2544 | |
| 2545 | if(mwConversation_isOpen(conv)) { | |
| 2546 | if(mwConversation_supports(conv, mwImSend_HTML)) { | |
| 15884 | 2547 | feat |= PURPLE_CONNECTION_HTML; |
| 10977 | 2548 | } else { |
| 15884 | 2549 | feat &= ~PURPLE_CONNECTION_HTML; |
| 10977 | 2550 | } |
| 2551 | ||
| 2552 | if(mwConversation_supports(conv, mwImSend_MIME)) { | |
| 15884 | 2553 | feat &= ~PURPLE_CONNECTION_NO_IMAGES; |
| 10977 | 2554 | } else { |
| 15884 | 2555 | feat |= PURPLE_CONNECTION_NO_IMAGES; |
| 10977 | 2556 | } |
| 2557 | ||
| 2558 | DEBUG_INFO("conversation features set to 0x%04x\n", feat); | |
| 15884 | 2559 | purple_conversation_set_features(gconv, feat); |
| 10977 | 2560 | |
| 2561 | } else { | |
| 2562 | convo_nofeatures(conv); | |
| 2563 | } | |
| 2564 | } | |
| 2565 | ||
| 2566 | ||
| 2567 | static void mw_conversation_opened(struct mwConversation *conv) { | |
| 2568 | struct mwServiceIm *srvc; | |
| 2569 | struct mwSession *session; | |
| 15884 | 2570 | struct mwPurplePluginData *pd; |
| 2571 | PurpleConnection *gc; | |
| 2572 | PurpleAccount *acct; | |
| 10977 | 2573 | |
| 2574 | struct convo_dat *cd; | |
| 2575 | ||
| 2576 | srvc = mwConversation_getService(conv); | |
| 2577 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2578 | pd = mwSession_getClientData(session); | |
| 2579 | gc = pd->gc; | |
| 15884 | 2580 | acct = purple_connection_get_account(gc); |
| 10977 | 2581 | |
| 2582 | /* set up the queue */ | |
| 2583 | cd = mwConversation_getClientData(conv); | |
| 2584 | if(cd) { | |
| 2585 | convo_queue_send(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2586 | |
| 10977 | 2587 | if(! convo_get_gconv(conv)) { |
| 2588 | mwConversation_free(conv); | |
| 2589 | return; | |
| 2590 | } | |
| 2591 | ||
| 2592 | } else { | |
| 2593 | convo_data_new(conv); | |
| 2594 | } | |
| 2595 | ||
| 2596 | { /* record the client key for the buddy */ | |
| 15884 | 2597 | PurpleBuddy *buddy; |
| 10977 | 2598 | struct mwLoginInfo *info; |
| 2599 | info = mwConversation_getTargetInfo(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2600 | |
| 15884 | 2601 | buddy = purple_find_buddy(acct, info->user_id); |
| 10977 | 2602 | if(buddy) { |
| 15884 | 2603 | purple_blist_node_set_int((PurpleBlistNode *) buddy, |
| 10977 | 2604 | BUDDY_KEY_CLIENT, info->type); |
| 2605 | } | |
| 2606 | } | |
| 2607 | ||
| 2608 | convo_features(conv); | |
| 2609 | } | |
| 2610 | ||
| 2611 | ||
| 2612 | static void mw_conversation_closed(struct mwConversation *conv, | |
| 2613 | guint32 reason) { | |
| 2614 | ||
| 2615 | struct convo_data *cd; | |
| 2616 | ||
| 2617 | g_return_if_fail(conv != NULL); | |
| 2618 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2619 | /* 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
|
2620 | print an error message to the conversation */ |
| 10977 | 2621 | cd = mwConversation_getClientData(conv); |
| 2622 | if(reason && cd && cd->queue) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2623 | GList *l; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2624 | for(l = cd->queue; l; l = l->next) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2625 | struct convo_msg *m = l->data; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2626 | if(m->type != mwImSend_TYPING) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2627 | convo_error(conv, reason); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2628 | break; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2629 | } |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2630 | } |
| 10977 | 2631 | } |
| 2632 | ||
| 2633 | #if 0 | |
| 2634 | /* don't do this, to prevent the occasional weird sending of | |
| 2635 | formatted messages as plaintext when the other end closes the | |
| 2636 | conversation after we've begun composing the message */ | |
| 2637 | convo_nofeatures(conv); | |
| 2638 | #endif | |
| 2639 | ||
| 2640 | mwConversation_removeClientData(conv); | |
| 2641 | } | |
| 2642 | ||
| 2643 | ||
| 2644 | static void im_recv_text(struct mwConversation *conv, | |
| 15884 | 2645 | struct mwPurplePluginData *pd, |
| 10977 | 2646 | const char *msg) { |
| 2647 | ||
| 2648 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2649 | char *txt, *esc; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2650 | const char *t; |
| 10977 | 2651 | |
| 2652 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2653 | |
| 15884 | 2654 | txt = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2655 | t = txt? txt: msg; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2656 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2657 | esc = g_markup_escape_text(t, -1); |
| 10977 | 2658 | 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
|
2659 | g_free(esc); |
| 10977 | 2660 | |
| 2661 | g_free(txt); | |
| 2662 | } | |
| 2663 | ||
| 2664 | ||
| 2665 | static void im_recv_typing(struct mwConversation *conv, | |
| 15884 | 2666 | struct mwPurplePluginData *pd, |
| 10977 | 2667 | gboolean typing) { |
| 2668 | ||
| 2669 | struct mwIdBlock *idb; | |
| 2670 | idb = mwConversation_getTarget(conv); | |
| 2671 | ||
| 2672 | serv_got_typing(pd->gc, idb->user, 0, | |
| 15884 | 2673 | typing? PURPLE_TYPING: PURPLE_NOT_TYPING); |
| 10977 | 2674 | } |
| 2675 | ||
| 2676 | ||
| 2677 | static void im_recv_html(struct mwConversation *conv, | |
| 15884 | 2678 | struct mwPurplePluginData *pd, |
| 10977 | 2679 | const char *msg) { |
| 2680 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2681 | char *t1, *t2; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2682 | const char *t; |
| 10977 | 2683 | |
| 2684 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2685 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2686 | /* ensure we're receiving UTF8 */ |
| 15884 | 2687 | t1 = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2688 | t = t1? t1: msg; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2689 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2690 | /* convert entities to UTF8 so they'll log correctly */ |
| 15884 | 2691 | t2 = purple_utf8_ncr_decode(t); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2692 | t = t2? t2: t; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2693 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2694 | serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
| 10977 | 2695 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2696 | g_free(t1); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2697 | g_free(t2); |
| 10977 | 2698 | } |
| 2699 | ||
| 2700 | ||
| 2701 | static void im_recv_subj(struct mwConversation *conv, | |
| 15884 | 2702 | struct mwPurplePluginData *pd, |
| 10977 | 2703 | const char *subj) { |
| 2704 | ||
| 2705 | /** @todo somehow indicate receipt of a conversation subject. It | |
| 2706 | would also be nice if we added a /topic command for the | |
| 2707 | protocol */ | |
| 2708 | ; | |
| 2709 | } | |
| 2710 | ||
| 2711 | ||
| 2712 | /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */ | |
| 2713 | static char *make_cid(const char *cid) { | |
| 2714 | gsize n; | |
| 2715 | char *c, *d; | |
| 2716 | ||
| 2717 | g_return_val_if_fail(cid != NULL, NULL); | |
| 2718 | ||
| 2719 | n = strlen(cid); | |
| 2720 | g_return_val_if_fail(n > 2, NULL); | |
| 2721 | ||
| 2722 | c = g_strndup(cid+1, n-2); | |
| 2723 | d = g_strdup_printf("cid:%s", c); | |
| 2724 | ||
| 2725 | g_free(c); | |
| 2726 | return d; | |
| 2727 | } | |
| 2728 | ||
| 2729 | ||
| 2730 | static void im_recv_mime(struct mwConversation *conv, | |
| 15884 | 2731 | struct mwPurplePluginData *pd, |
| 10977 | 2732 | const char *data) { |
| 2733 | ||
| 2734 | GHashTable *img_by_cid; | |
| 2735 | GList *images; | |
| 2736 | ||
| 2737 | GString *str; | |
| 2738 | ||
| 15884 | 2739 | 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
|
2740 | GList *parts; |
| 10977 | 2741 | |
| 2742 | img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
| 2743 | images = NULL; | |
| 2744 | ||
| 2745 | /* don't want the contained string to ever be NULL */ | |
| 2746 | str = g_string_new(""); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2747 | |
| 15884 | 2748 | doc = purple_mime_document_parse(data); |
| 10977 | 2749 | |
| 2750 | /* handle all the MIME parts */ | |
| 15884 | 2751 | parts = purple_mime_document_get_parts(doc); |
| 10977 | 2752 | for(; parts; parts = parts->next) { |
| 15884 | 2753 | PurpleMimePart *part = parts->data; |
| 10977 | 2754 | const char *type; |
| 2755 | ||
| 15884 | 2756 | type = purple_mime_part_get_field(part, "content-type"); |
| 10977 | 2757 | DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type)); |
| 2758 | ||
| 2759 | if(! type) { | |
| 2760 | ; /* feh */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2761 | |
| 15884 | 2762 | } else if(purple_str_has_prefix(type, "image")) { |
| 10977 | 2763 | /* put images into the image store */ |
| 2764 | ||
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2765 | guchar *d_dat; |
| 10977 | 2766 | gsize d_len; |
| 2767 | char *cid; | |
| 2768 | int img; | |
| 2769 | ||
| 2770 | /* obtain and unencode the data */ | |
| 15884 | 2771 | 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
|
2772 | |
| 10977 | 2773 | /* look up the content id */ |
| 15884 | 2774 | cid = (char *) purple_mime_part_get_field(part, "Content-ID"); |
| 10977 | 2775 | cid = make_cid(cid); |
| 2776 | ||
| 15884 | 2777 | /* 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
|
2778 | img = purple_imgstore_add_with_id(d_dat, d_len, cid); |
| 10977 | 2779 | |
| 2780 | /* map the cid to the image store identifier */ | |
| 2781 | g_hash_table_insert(img_by_cid, cid, GINT_TO_POINTER(img)); | |
| 2782 | ||
| 2783 | /* recall the image for dereferencing later */ | |
| 2784 | images = g_list_append(images, GINT_TO_POINTER(img)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2785 | |
| 15884 | 2786 | } else if(purple_str_has_prefix(type, "text")) { |
| 10977 | 2787 | |
| 2788 | /* concatenate all the text parts together */ | |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2789 | guchar *data; |
| 10977 | 2790 | gsize len; |
| 2791 | ||
| 15884 | 2792 | purple_mime_part_get_data_decoded(part, &data, &len); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2793 | g_string_append(str, (const char *)data); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2794 | g_free(data); |
| 10977 | 2795 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2796 | } |
| 10977 | 2797 | |
| 15884 | 2798 | purple_mime_document_free(doc); |
| 10977 | 2799 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2800 | /* @todo should put this in its own function */ |
| 10977 | 2801 | { /* replace each IMG tag's SRC attribute with an ID attribute. This |
| 2802 | actually modifies the contents of str */ | |
| 2803 | GData *attribs; | |
| 2804 | char *start, *end; | |
| 2805 | char *tmp = str->str; | |
| 2806 | ||
| 15884 | 2807 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 2808 | (const char **) &end, &attribs)) { |
| 2809 | ||
| 2810 | char *alt, *align, *border, *src; | |
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2811 | int img = 0; |
| 10977 | 2812 | |
| 2813 | alt = g_datalist_get_data(&attribs, "alt"); | |
| 2814 | align = g_datalist_get_data(&attribs, "align"); | |
| 2815 | border = g_datalist_get_data(&attribs, "border"); | |
| 2816 | src = g_datalist_get_data(&attribs, "src"); | |
| 2817 | ||
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2818 | if(src) |
|
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2819 | 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
|
2820 | |
| 10977 | 2821 | if(img) { |
| 2822 | GString *atstr; | |
| 2823 | gsize len = (end - start); | |
| 2824 | gsize mov; | |
| 2825 | ||
| 2826 | atstr = g_string_new(""); | |
| 2827 | if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt); | |
| 2828 | if(align) g_string_append_printf(atstr, " align=\"%s\"", align); | |
| 2829 | if(border) g_string_append_printf(atstr, " border=\"%s\"", border); | |
| 2830 | ||
| 2831 | mov = g_snprintf(start, len, "<img%s id=\"%i\"", atstr->str, img); | |
| 2832 | while(mov < len) start[mov++] = ' '; | |
| 2833 | ||
| 2834 | g_string_free(atstr, TRUE); | |
| 2835 | } | |
| 2836 | ||
| 2837 | g_datalist_clear(&attribs); | |
| 2838 | tmp = end + 1; | |
| 2839 | } | |
| 2840 | } | |
| 2841 | ||
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2842 | im_recv_html(conv, pd, str->str); |
| 10977 | 2843 | |
| 2844 | g_string_free(str, TRUE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2845 | |
| 10977 | 2846 | /* clean up the cid table */ |
| 2847 | g_hash_table_destroy(img_by_cid); | |
| 2848 | ||
| 2849 | /* dereference all the imgages */ | |
| 2850 | 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
|
2851 | purple_imgstore_unref_by_id(GPOINTER_TO_INT(images->data)); |
| 10977 | 2852 | images = g_list_delete_link(images, images); |
| 2853 | } | |
| 2854 | } | |
| 2855 | ||
| 2856 | ||
| 2857 | static void mw_conversation_recv(struct mwConversation *conv, | |
| 2858 | enum mwImSendType type, | |
| 2859 | gconstpointer msg) { | |
| 2860 | struct mwServiceIm *srvc; | |
| 2861 | struct mwSession *session; | |
| 15884 | 2862 | struct mwPurplePluginData *pd; |
| 10977 | 2863 | |
| 2864 | srvc = mwConversation_getService(conv); | |
| 2865 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2866 | pd = mwSession_getClientData(session); | |
| 2867 | ||
| 2868 | switch(type) { | |
| 2869 | case mwImSend_PLAIN: | |
| 2870 | im_recv_text(conv, pd, msg); | |
| 2871 | break; | |
| 2872 | ||
| 2873 | case mwImSend_TYPING: | |
| 2874 | im_recv_typing(conv, pd, !! msg); | |
| 2875 | break; | |
| 2876 | ||
| 2877 | case mwImSend_HTML: | |
| 2878 | im_recv_html(conv, pd, msg); | |
| 2879 | break; | |
| 2880 | ||
| 2881 | case mwImSend_SUBJECT: | |
| 2882 | im_recv_subj(conv, pd, msg); | |
| 2883 | break; | |
| 2884 | ||
| 2885 | case mwImSend_MIME: | |
| 2886 | im_recv_mime(conv, pd, msg); | |
| 2887 | break; | |
| 2888 | ||
| 2889 | default: | |
| 2890 | DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
| 2891 | ; /* erm... */ | |
| 2892 | } | |
| 2893 | } | |
| 2894 | ||
| 2895 | ||
| 2896 | static void mw_place_invite(struct mwConversation *conv, | |
| 2897 | const char *message, | |
| 2898 | const char *title, const char *name) { | |
| 2899 | struct mwServiceIm *srvc; | |
| 2900 | struct mwSession *session; | |
| 15884 | 2901 | struct mwPurplePluginData *pd; |
| 10977 | 2902 | |
| 2903 | struct mwIdBlock *idb; | |
| 2904 | GHashTable *ht; | |
| 2905 | ||
| 2906 | srvc = mwConversation_getService(conv); | |
| 2907 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2908 | pd = mwSession_getClientData(session); | |
| 2909 | ||
| 2910 | idb = mwConversation_getTarget(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2911 | |
| 10977 | 2912 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 2913 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
| 2914 | g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
| 2915 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
| 2916 | 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
|
2917 | g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
| 10977 | 2918 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2919 | if(! title) title = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2920 | if(! message) message = "(no message)"; |
| 10977 | 2921 | 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
|
2922 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2923 | mwConversation_close(conv, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2924 | mwConversation_free(conv); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2925 | } |
| 10977 | 2926 | |
| 2927 | ||
| 2928 | static void mw_im_clear(struct mwServiceIm *srvc) { | |
| 2929 | ; | |
| 2930 | } | |
| 2931 | ||
| 2932 | ||
| 2933 | static struct mwImHandler mw_im_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2934 | mw_conversation_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2935 | mw_conversation_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2936 | mw_conversation_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2937 | mw_place_invite, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2938 | mw_im_clear, |
| 10977 | 2939 | }; |
| 2940 | ||
| 2941 | ||
| 2942 | static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
| 2943 | struct mwServiceIm *srvc; | |
| 2944 | srvc = mwServiceIm_new(s, &mw_im_handler); | |
| 2945 | mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
| 2946 | return srvc; | |
| 2947 | } | |
| 2948 | ||
| 2949 | ||
| 15884 | 2950 | /* 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
|
2951 | 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
|
2952 | the similar macros from the conference service above */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2953 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2954 | #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2955 | #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
|
2956 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2957 | #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
|
2958 | #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
|
2959 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2960 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2961 | static struct mwPlace * |
| 15884 | 2962 | place_find_by_id(struct mwPurplePluginData *pd, int id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2963 | struct mwServicePlace *srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2964 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2965 | GList *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2966 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2967 | l = (GList *) mwServicePlace_getPlaces(srvc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2968 | for(; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2969 | struct mwPlace *p = l->data; |
| 15884 | 2970 | PurpleConvChat *h = PURPLE_CONV_CHAT(mwPlace_getClientData(p)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2971 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2972 | if(CHAT_TO_ID(h) == id) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2973 | place = p; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2974 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2975 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2976 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2977 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2978 | return place; |
|
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 | |
|
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 | static void mw_place_opened(struct mwPlace *place) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2983 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2984 | struct mwSession *session; |
| 15884 | 2985 | struct mwPurplePluginData *pd; |
| 2986 | PurpleConnection *gc; | |
| 2987 | PurpleConversation *gconf; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2988 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2989 | GList *members, *l; |
|
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 | const char *n = mwPlace_getName(place); |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2992 | const char *t = mwPlace_getTitle(place); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2993 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2994 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2995 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2996 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2997 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2998 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2999 | members = mwPlace_getMembers(place); |
|
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 | DEBUG_INFO("place %s opened, %u initial members\n", |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3002 | NSTR(n), g_list_length(members)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3003 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
3004 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
3005 | 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
|
3006 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3007 | mwPlace_setClientData(place, gconf, NULL); |
|
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 | for(l = members; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3010 | struct mwIdBlock *idb = l->data; |
| 15884 | 3011 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(gconf), idb->user, |
| 3012 | NULL, PURPLE_CBFLAGS_NONE, FALSE); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3013 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3014 | g_list_free(members); |
|
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 | |
|
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 | static void mw_place_closed(struct mwPlace *place, guint32 code) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3019 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3020 | struct mwSession *session; |
| 15884 | 3021 | struct mwPurplePluginData *pd; |
| 3022 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3023 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3024 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3025 | char *msg = mwError(code); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3026 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3027 | 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
|
3028 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3029 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3030 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3031 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3032 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3033 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3034 | serv_got_chat_left(gc, PLACE_TO_ID(place)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3035 | |
| 15884 | 3036 | purple_notify_error(gc, _("Place Closed"), NULL, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3037 | g_free(msg); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3038 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3039 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3040 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3041 | static void mw_place_peerJoined(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3042 | const struct mwIdBlock *peer) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3043 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3044 | struct mwSession *session; |
| 15884 | 3045 | struct mwPurplePluginData *pd; |
| 3046 | PurpleConnection *gc; | |
| 3047 | PurpleConversation *gconf; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3048 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3049 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3050 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3051 | DEBUG_INFO("%s joined place %s\n", NSTR(peer->user), NSTR(n)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3052 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3053 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3054 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3055 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3056 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3057 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3058 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3059 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3060 | |
| 15884 | 3061 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(gconf), peer->user, |
| 3062 | NULL, PURPLE_CBFLAGS_NONE, TRUE); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3063 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3064 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3065 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3066 | static void mw_place_peerParted(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3067 | const struct mwIdBlock *peer) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3068 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3069 | struct mwSession *session; |
| 15884 | 3070 | struct mwPurplePluginData *pd; |
| 3071 | PurpleConnection *gc; | |
| 3072 | PurpleConversation *gconf; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3073 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3074 | const char *n = mwPlace_getName(place); |
|
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 | 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
|
3077 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3078 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3079 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3080 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3081 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3082 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3083 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3084 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3085 | |
| 15884 | 3086 | 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
|
3087 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3088 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3089 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3090 | static void mw_place_peerSetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3091 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3092 | guint32 attr, struct mwOpaque *o) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3093 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3094 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3095 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3096 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3097 | static void mw_place_peerUnsetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3098 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3099 | guint32 attr) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3100 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3101 | } |
|
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 | static void mw_place_message(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3105 | const struct mwIdBlock *who, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3106 | const char *msg) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3107 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3108 | struct mwSession *session; |
| 15884 | 3109 | struct mwPurplePluginData *pd; |
| 3110 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3111 | char *esc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3112 | |
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3113 | if(! msg) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3114 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3115 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3116 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3117 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3118 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3119 | |
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
3120 | esc = g_markup_escape_text(msg, -1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3121 | 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
|
3122 | g_free(esc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3123 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3124 | |
|
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 | static void mw_place_clear(struct mwServicePlace *srvc) { |
|
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 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3129 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3130 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3131 | static struct mwPlaceHandler mw_place_handler = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3132 | mw_place_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3133 | mw_place_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3134 | mw_place_peerJoined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3135 | mw_place_peerParted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3136 | mw_place_peerSetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3137 | mw_place_peerUnsetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3138 | mw_place_message, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3139 | mw_place_clear, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3140 | }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3141 | |
|
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 | static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3144 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3145 | srvc = mwServicePlace_new(s, &mw_place_handler); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3146 | return srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3147 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3148 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3149 | |
| 10977 | 3150 | static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
| 3151 | struct mwServiceResolve *srvc; | |
| 3152 | srvc = mwServiceResolve_new(s); | |
| 3153 | return srvc; | |
| 3154 | } | |
| 3155 | ||
| 3156 | ||
| 3157 | static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
| 3158 | struct mwServiceStorage *srvc; | |
| 3159 | srvc = mwServiceStorage_new(s); | |
| 3160 | return srvc; | |
| 3161 | } | |
| 3162 | ||
| 3163 | ||
| 15884 | 3164 | /** allocate and associate a mwPurplePluginData with a PurpleConnection */ |
| 3165 | static struct mwPurplePluginData *mwPurplePluginData_new(PurpleConnection *gc) { | |
| 3166 | struct mwPurplePluginData *pd; | |
| 10977 | 3167 | |
| 3168 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3169 | ||
| 15884 | 3170 | pd = g_new0(struct mwPurplePluginData, 1); |
| 10977 | 3171 | pd->gc = gc; |
| 3172 | pd->session = mwSession_new(&mw_session_handler); | |
| 3173 | pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
| 3174 | pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
| 3175 | pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
| 3176 | pd->srvc_im = mw_srvc_im_new(pd->session); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3177 | pd->srvc_place = mw_srvc_place_new(pd->session); |
| 10977 | 3178 | pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
| 3179 | pd->srvc_store = mw_srvc_store_new(pd->session); | |
| 3180 | pd->group_list_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 15884 | 3181 | pd->sock_buf = purple_circ_buffer_new(0); |
| 10977 | 3182 | |
| 3183 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
| 3184 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
| 3185 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
| 3186 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3187 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
| 10977 | 3188 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
| 3189 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
| 3190 | ||
| 3191 | 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
|
3192 | mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 10977 | 3193 | |
| 3194 | mwSession_setClientData(pd->session, pd, NULL); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3195 | purple_connection_set_protocol_data(gc, pd); |
| 10977 | 3196 | |
| 3197 | return pd; | |
| 3198 | } | |
| 3199 | ||
| 3200 | ||
| 15884 | 3201 | static void mwPurplePluginData_free(struct mwPurplePluginData *pd) { |
| 10977 | 3202 | g_return_if_fail(pd != NULL); |
| 3203 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3204 | purple_connection_set_protocol_data(pd->gc, NULL); |
| 10977 | 3205 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3206 | mwSession_removeService(pd->session, mwService_AWARE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3207 | mwSession_removeService(pd->session, mwService_CONFERENCE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3208 | mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3209 | mwSession_removeService(pd->session, mwService_IM); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3210 | mwSession_removeService(pd->session, mwService_PLACE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3211 | mwSession_removeService(pd->session, mwService_RESOLVE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3212 | mwSession_removeService(pd->session, mwService_STORAGE); |
| 10977 | 3213 | |
| 3214 | mwService_free(MW_SERVICE(pd->srvc_aware)); | |
| 3215 | mwService_free(MW_SERVICE(pd->srvc_conf)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3216 | mwService_free(MW_SERVICE(pd->srvc_ft)); |
| 10977 | 3217 | mwService_free(MW_SERVICE(pd->srvc_im)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3218 | mwService_free(MW_SERVICE(pd->srvc_place)); |
| 10977 | 3219 | mwService_free(MW_SERVICE(pd->srvc_resolve)); |
| 3220 | mwService_free(MW_SERVICE(pd->srvc_store)); | |
| 3221 | ||
| 3222 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3223 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
| 10977 | 3224 | |
| 3225 | mwSession_free(pd->session); | |
| 3226 | ||
| 3227 | g_hash_table_destroy(pd->group_list_map); | |
| 15884 | 3228 | purple_circ_buffer_destroy(pd->sock_buf); |
| 10977 | 3229 | |
| 3230 | g_free(pd); | |
| 3231 | } | |
| 3232 | ||
| 3233 | ||
| 15884 | 3234 | static const char *mw_prpl_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
| 10977 | 3235 | /* my little green dude is a chopped up version of the aim running |
| 3236 | guy. First, cut off the head and store someplace safe. Then, | |
| 3237 | take the left-half side of the body and throw it away. Make a | |
| 3238 | copy of the remaining body, and flip it horizontally. Now attach | |
| 3239 | the two pieces into an X shape, and drop the head back on the | |
| 3240 | top, being careful to center it. Then, just change the color | |
| 3241 | saturation to bring the red down a bit, and voila! */ | |
| 3242 | ||
| 3243 | /* then, throw all of that away and use sodipodi to make a new | |
| 3244 | icon. You know, LIKE A REAL MAN. */ | |
| 3245 | ||
| 3246 | return "meanwhile"; | |
| 3247 | } | |
| 3248 | ||
| 3249 | ||
| 15884 | 3250 | static const char* mw_prpl_list_emblem(PurpleBuddy *b) |
| 15524 | 3251 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3252 | if(buddy_is_external(b)) |
| 15524 | 3253 | return "external"; |
| 3254 | ||
| 3255 | return NULL; | |
| 10977 | 3256 | } |
| 3257 | ||
| 3258 | ||
| 15884 | 3259 | static char *mw_prpl_status_text(PurpleBuddy *b) { |
| 3260 | PurpleConnection *gc; | |
| 3261 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3262 | 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
|
3263 | 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
|
3264 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3265 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3266 | && (pd = purple_connection_get_protocol_data(gc))) |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3267 | 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
|
3268 | |
|
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
|
3269 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3270 | } |
| 3271 | ||
| 3272 | ||
| 15884 | 3273 | static const char *status_text(PurpleBuddy *b) { |
| 3274 | PurplePresence *presence; | |
| 3275 | PurpleStatus *status; | |
| 3276 | ||
| 3277 | presence = purple_buddy_get_presence(b); | |
| 3278 | status = purple_presence_get_active_status(presence); | |
| 3279 | ||
| 3280 | return purple_status_get_name(status); | |
| 10977 | 3281 | } |
| 3282 | ||
| 3283 | ||
| 3284 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3285 | const char *who, guint32 feature) { | |
| 3286 | ||
| 3287 | const struct mwAwareAttribute *attr; | |
| 3288 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3289 | ||
| 3290 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3291 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3292 | } | |
| 3293 | ||
| 3294 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3295 | 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
|
3296 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3297 | const char **f = feat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3298 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3299 | if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3300 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3301 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3302 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3303 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3304 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3305 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3306 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3307 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3308 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3309 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3310 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3311 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3312 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3313 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3314 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3315 | /* jenni loves siege */ |
| 10977 | 3316 | } |
| 3317 | ||
| 3318 | ||
| 15884 | 3319 | static void mw_prpl_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { |
| 3320 | 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
|
3321 | struct mwPurplePluginData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3322 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3323 | |
|
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
|
3324 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3325 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3326 | char *tmp; |
| 10977 | 3327 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3328 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3329 | && (pd = purple_connection_get_protocol_data(gc))) |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3330 | 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
|
3331 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3332 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3333 | |
|
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
|
3334 | if(message != NULL && g_utf8_validate(message, -1, NULL) && purple_utf8_strcasecmp(status, message)) { |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
3335 | purple_notify_user_info_add_pair_plaintext(user_info, status, message); |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3336 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3337 | } else { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
3338 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status); |
| 10977 | 3339 | } |
| 3340 | ||
|
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
|
3341 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3342 | 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
|
3343 | if(tmp) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
3344 | purple_notify_user_info_add_pair_plaintext(user_info, _("Supports"), tmp); |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3345 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3346 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3347 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3348 | if(buddy_is_external(b)) { |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
3349 | purple_notify_user_info_add_pair_plaintext(user_info, NULL, _("External User")); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3350 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3351 | } |
| 10977 | 3352 | } |
| 3353 | ||
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3354 | 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
|
3355 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3356 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3357 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3358 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3359 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3360 | 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
|
3361 | 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
|
3362 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3363 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3364 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3365 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY, |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3366 | 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
|
3367 | 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
|
3368 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3369 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3370 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3371 | 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
|
3372 | 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
|
3373 | 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
|
3374 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3375 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3376 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3377 | 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
|
3378 | 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
|
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 | return types; |
| 10977 | 3382 | } |
| 3383 | ||
| 3384 | ||
| 15884 | 3385 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3386 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3387 | ; /* nothing to do */ |
| 10977 | 3388 | } |
| 3389 | ||
| 3390 | ||
| 15884 | 3391 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3392 | PurpleRequestFields *fields) { | |
| 3393 | PurpleAccount *acct; | |
| 3394 | PurpleConnection *gc; | |
| 3395 | struct mwPurplePluginData *pd; | |
| 10977 | 3396 | struct mwServiceConference *srvc; |
| 3397 | ||
| 15884 | 3398 | PurpleRequestField *f; |
| 10977 | 3399 | |
| 3400 | const char *topic, *invite; | |
| 3401 | struct mwConference *conf; | |
| 3402 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3403 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3404 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3405 | gc = purple_account_get_connection(acct); |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3406 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3407 | srvc = pd->srvc_conf; |
| 3408 | ||
| 15884 | 3409 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3410 | topic = purple_request_field_string_get_value(f); | |
| 3411 | ||
| 3412 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3413 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3414 | |
| 3415 | conf = mwConference_new(srvc, topic); | |
| 3416 | mwConference_open(conf); | |
| 3417 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3418 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3419 | mwConference_invite(conf, &idb, invite); |
| 3420 | } | |
| 3421 | ||
| 3422 | ||
| 15884 | 3423 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3424 | ||
| 3425 | PurpleRequestFields *fields; | |
| 3426 | PurpleRequestFieldGroup *g; | |
| 3427 | PurpleRequestField *f; | |
| 3428 | ||
| 3429 | PurpleAccount *acct; | |
| 3430 | PurpleConnection *gc; | |
| 10977 | 3431 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3432 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3433 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3434 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3435 | |
| 10977 | 3436 | g_return_if_fail(buddy != NULL); |
| 3437 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3438 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3439 | g_return_if_fail(acct != NULL); |
| 3440 | ||
| 15884 | 3441 | gc = purple_account_get_connection(acct); |
| 10977 | 3442 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3443 | |
| 15884 | 3444 | fields = purple_request_fields_new(); |
| 3445 | ||
| 3446 | g = purple_request_field_group_new(NULL); | |
| 3447 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3448 | |
| 15884 | 3449 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3450 | purple_request_field_group_add_field(g, f); | |
| 3451 | ||
| 3452 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3453 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3454 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3455 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3456 | 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
|
3457 | " 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
|
3458 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3459 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3460 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3461 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3462 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3463 | _("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
|
3464 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3465 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3466 | g_free(msg1); |
| 10977 | 3467 | } |
| 3468 | ||
| 3469 | ||
| 15884 | 3470 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3471 | PurpleRequestFields *fields) { | |
| 10977 | 3472 | ; |
| 3473 | } | |
| 3474 | ||
| 3475 | ||
| 15884 | 3476 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3477 | PurpleRequestFields *fields) { | |
| 3478 | 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
|
3479 | GList *l; |
| 10977 | 3480 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3481 | |
| 15884 | 3482 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3483 | msg = purple_request_field_string_get_value(f); | |
| 3484 | ||
| 3485 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3486 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3487 | |
| 3488 | if(l) { | |
| 15884 | 3489 | 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
|
3490 | |
| 10977 | 3491 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3492 | blist_menu_conf_create(buddy, msg); | |
| 3493 | ||
| 3494 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3495 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3496 | mwConference_invite(d, &idb, msg); |
| 3497 | } | |
| 3498 | } | |
| 3499 | } | |
| 3500 | ||
| 3501 | ||
| 15884 | 3502 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3503 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3504 | |
| 15884 | 3505 | PurpleRequestFields *fields; |
| 3506 | PurpleRequestFieldGroup *g; | |
| 3507 | PurpleRequestField *f; | |
| 3508 | ||
| 3509 | PurpleAccount *acct; | |
| 3510 | PurpleConnection *gc; | |
| 10977 | 3511 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3512 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3513 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3514 | char *msg; |
| 10977 | 3515 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3516 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3517 | g_return_if_fail(acct != NULL); |
| 3518 | ||
| 15884 | 3519 | gc = purple_account_get_connection(acct); |
| 10977 | 3520 | g_return_if_fail(gc != NULL); |
| 3521 | ||
| 15884 | 3522 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3523 | |
| 15884 | 3524 | g = purple_request_field_group_new(NULL); |
| 3525 | purple_request_fields_add_group(fields, g); | |
| 3526 | ||
| 3527 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3528 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3529 | for(; confs; confs = confs->next) { |
| 3530 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3531 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3532 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3533 | 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
|
3534 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3535 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3536 | |
| 15884 | 3537 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3538 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3539 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3540 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3541 | 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
|
3542 | " 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
|
3543 | " 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
|
3544 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3545 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3546 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3547 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3548 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3549 | _("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
|
3550 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3551 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3552 | g_free(msg); |
| 10977 | 3553 | } |
| 3554 | ||
| 3555 | ||
| 15884 | 3556 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 3557 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3558 | PurpleAccount *acct; | |
| 3559 | PurpleConnection *gc; | |
| 3560 | struct mwPurplePluginData *pd; | |
| 10977 | 3561 | GList *l; |
| 3562 | ||
| 3563 | g_return_if_fail(node != NULL); | |
| 15884 | 3564 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 10977 | 3565 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3566 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3567 | g_return_if_fail(acct != NULL); |
| 3568 | ||
| 15884 | 3569 | gc = purple_account_get_connection(acct); |
| 10977 | 3570 | g_return_if_fail(gc != NULL); |
| 3571 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3572 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3573 | g_return_if_fail(pd != NULL); |
| 3574 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3575 | /* |
| 10977 | 3576 | - get a list of all conferences on this session |
| 3577 | - if none, prompt to create one, and invite buddy to it | |
| 3578 | - else, prompt to select a conference or create one | |
| 3579 | */ | |
| 3580 | ||
| 3581 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3582 | if(l) { | |
| 3583 | blist_menu_conf_list(buddy, l); | |
| 3584 | g_list_free(l); | |
| 3585 | ||
| 3586 | } else { | |
| 3587 | blist_menu_conf_create(buddy, NULL); | |
| 3588 | } | |
| 3589 | } | |
| 3590 | ||
| 3591 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3592 | #if 0 |
| 15884 | 3593 | static void blist_menu_announce(PurpleBlistNode *node, gpointer data) { |
| 3594 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3595 | PurpleAccount *acct; | |
| 3596 | PurpleConnection *gc; | |
| 3597 | struct mwPurplePluginData *pd; | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3598 | struct mwSession *session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3599 | char *rcpt_name; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3600 | GList *rcpt; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3601 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3602 | g_return_if_fail(node != NULL); |
| 15884 | 3603 | 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
|
3604 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3605 | acct = buddy->account; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3606 | g_return_if_fail(acct != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3607 | |
| 15884 | 3608 | gc = purple_account_get_connection(acct); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3609 | g_return_if_fail(gc != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3610 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3611 | pd = purple_connection_get_protocol_data(gc); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3612 | g_return_if_fail(pd != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3613 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3614 | rcpt_name = g_strdup_printf("@U %s", buddy->name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3615 | rcpt = g_list_prepend(NULL, rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3616 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3617 | session = pd->session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3618 | mwSession_sendAnnounce(session, FALSE, |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3619 | "This is a TEST announcement. Please ignore.", |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3620 | rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3621 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3622 | g_list_free(rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3623 | g_free(rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3624 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3625 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3626 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3627 | |
| 15884 | 3628 | static GList *mw_prpl_blist_node_menu(PurpleBlistNode *node) { |
| 10977 | 3629 | GList *l = NULL; |
| 15884 | 3630 | PurpleMenuAction *act; |
| 3631 | ||
| 3632 | if(! PURPLE_BLIST_NODE_IS_BUDDY(node)) | |
| 10977 | 3633 | return l; |
| 3634 | ||
| 3635 | l = g_list_append(l, NULL); | |
| 3636 | ||
| 15884 | 3637 | act = purple_menu_action_new(_("Invite to Conference..."), |
| 3638 | PURPLE_CALLBACK(blist_menu_conf), NULL, NULL); | |
| 10977 | 3639 | l = g_list_append(l, act); |
| 3640 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3641 | #if 0 |
| 15884 | 3642 | act = purple_menu_action_new(_("Send TEST Announcement"), |
| 3643 | PURPLE_CALLBACK(blist_menu_announce), NULL, NULL); | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3644 | l = g_list_append(l, act); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3645 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3646 | |
| 15884 | 3647 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3648 | blist-node-extended-menu signal for that. The function |
| 3649 | blist_node_menu_cb is assigned to this signal in the function | |
| 3650 | services_starting */ | |
| 3651 | ||
| 3652 | return l; | |
| 3653 | } | |
| 3654 | ||
| 3655 | ||
| 15884 | 3656 | static GList *mw_prpl_chat_info(PurpleConnection *gc) { |
| 10977 | 3657 | GList *l = NULL; |
| 3658 | struct proto_chat_entry *pce; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3659 | |
| 10977 | 3660 | pce = g_new0(struct proto_chat_entry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3661 | pce->label = _("Topic:"); |
| 10977 | 3662 | pce->identifier = CHAT_KEY_TOPIC; |
| 3663 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3664 | |
| 10977 | 3665 | return l; |
| 3666 | } | |
| 3667 | ||
| 3668 | ||
| 15884 | 3669 | static GHashTable *mw_prpl_chat_info_defaults(PurpleConnection *gc, |
| 10977 | 3670 | const char *name) { |
| 3671 | GHashTable *table; | |
| 3672 | ||
| 3673 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3674 | ||
| 3675 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3676 | NULL, g_free); | |
| 3677 | ||
| 3678 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3679 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3680 | ||
| 3681 | return table; | |
| 3682 | } | |
| 3683 | ||
| 3684 | ||
| 15884 | 3685 | static void mw_prpl_login(PurpleAccount *acct); |
| 3686 | ||
| 3687 | ||
| 3688 | static void prompt_host_cancel_cb(PurpleConnection *gc) { | |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
3689 | const char *msg = _("No Sametime Community Server specified"); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
3690 | purple_connection_error(gc, |
| 21279 | 3691 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, |
| 3692 | msg); | |
| 15884 | 3693 | } |
| 3694 | ||
| 3695 | ||
| 3696 | static void prompt_host_ok_cb(PurpleConnection *gc, const char *host) { | |
| 10977 | 3697 | if(host && *host) { |
| 15884 | 3698 | PurpleAccount *acct = purple_connection_get_account(gc); |
| 3699 | purple_account_set_string(acct, MW_KEY_HOST, host); | |
|
11837
2f1206084fef
[gaim-migrate @ 14128]
Mark Doliner <markdoliner@pidgin.im>
parents:
11718
diff
changeset
|
3700 | mw_prpl_login(acct); |
| 10977 | 3701 | |
| 3702 | } else { | |
| 3703 | prompt_host_cancel_cb(gc); | |
| 3704 | } | |
| 3705 | } | |
| 3706 | ||
| 3707 | ||
| 15884 | 3708 | static void prompt_host(PurpleConnection *gc) { |
| 3709 | PurpleAccount *acct; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3710 | const char *msgA; |
| 10977 | 3711 | char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3712 | |
| 15884 | 3713 | acct = purple_connection_get_account(gc); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3714 | 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
|
3715 | " Meanwhile account %s. Please enter one below to" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3716 | " continue logging in."); |
| 15884 | 3717 | 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
|
3718 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3719 | purple_request_input(gc, _("Meanwhile Connection Setup"), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3720 | _("No Sametime Community Server Specified"), msg, |
| 10977 | 3721 | MW_PLUGIN_DEFAULT_HOST, FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3722 | _("Connect"), G_CALLBACK(prompt_host_ok_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3723 | _("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
|
3724 | acct, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3725 | gc); |
| 10977 | 3726 | |
| 3727 | g_free(msg); | |
| 3728 | } | |
| 3729 | ||
| 3730 | ||
| 15884 | 3731 | static void mw_prpl_login(PurpleAccount *account) { |
| 3732 | PurpleConnection *gc; | |
| 3733 | struct mwPurplePluginData *pd; | |
| 10977 | 3734 | |
| 3735 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3736 | guint port; |
| 10977 | 3737 | |
| 15884 | 3738 | gc = purple_account_get_connection(account); |
| 3739 | pd = mwPurplePluginData_new(gc); | |
| 10977 | 3740 | |
| 3741 | /* while we do support images, the default is to not offer it */ | |
| 15884 | 3742 | gc->flags |= PURPLE_CONNECTION_NO_IMAGES; |
| 3743 | ||
| 3744 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3745 | |
| 3746 | host = strrchr(user, ':'); | |
| 3747 | if(host) { | |
| 3748 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3749 | *host++ = '\0'; | |
| 15884 | 3750 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3751 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3752 | |
| 10977 | 3753 | } else { |
| 15884 | 3754 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3755 | MW_PLUGIN_DEFAULT_HOST); |
| 3756 | } | |
| 3757 | ||
| 3758 | if(! host || ! *host) { | |
| 3759 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3760 | 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
|
3761 | g_free(user); |
| 10977 | 3762 | prompt_host(gc); |
| 3763 | return; | |
| 3764 | } | |
| 3765 | ||
|
25292
5b4e719c5bbb
Fix a potential leak "KuSh" discovered using "cppcheck". Fixes #7862.
Daniel Atallah <datallah@pidgin.im>
parents:
25181
diff
changeset
|
3766 | pass = g_strdup(purple_account_get_password(account)); |
| 15884 | 3767 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3768 | |
| 3769 | DEBUG_INFO("user: '%s'\n", user); | |
| 3770 | DEBUG_INFO("host: '%s'\n", host); | |
| 3771 | DEBUG_INFO("port: %u\n", port); | |
| 3772 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3773 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3774 | (char *) no_secret, NULL); |
| 3775 | 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
|
3776 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3777 | |
| 15884 | 3778 | 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
|
3779 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3780 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3781 | /* 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
|
3782 | 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
|
3783 | |
| 15884 | 3784 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3785 | 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
|
3786 | 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
|
3787 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3788 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3789 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3790 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3791 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3792 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3793 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3794 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3795 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3796 | GUINT_TO_POINTER(major), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3797 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3798 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3799 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3800 | } |
| 10977 | 3801 | |
| 15884 | 3802 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3803 | ||
| 3804 | if (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL) { | |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
3805 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
3806 | _("Unable to connect")); |
| 10977 | 3807 | } |
| 3808 | } | |
| 3809 | ||
| 3810 | ||
| 15884 | 3811 | static void mw_prpl_close(PurpleConnection *gc) { |
| 3812 | struct mwPurplePluginData *pd; | |
| 10977 | 3813 | |
| 3814 | g_return_if_fail(gc != NULL); | |
| 3815 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3816 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3817 | g_return_if_fail(pd != NULL); |
| 3818 | ||
| 3819 | /* get rid of the blist save timeout */ | |
| 3820 | if(pd->save_event) { | |
| 15884 | 3821 | purple_timeout_remove(pd->save_event); |
| 10977 | 3822 | pd->save_event = 0; |
| 3823 | blist_store(pd); | |
| 3824 | } | |
| 3825 | ||
| 3826 | /* stop the session */ | |
| 3827 | mwSession_stop(pd->session, 0x00); | |
| 3828 | ||
| 3829 | /* no longer necessary */ | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3830 | purple_connection_set_protocol_data(gc, NULL); |
| 10977 | 3831 | |
| 3832 | /* stop watching the socket */ | |
| 3833 | if(gc->inpa) { | |
| 15884 | 3834 | purple_input_remove(gc->inpa); |
| 10977 | 3835 | gc->inpa = 0; |
| 3836 | } | |
| 3837 | ||
| 3838 | /* clean up the rest */ | |
| 15884 | 3839 | mwPurplePluginData_free(pd); |
| 10977 | 3840 | } |
| 3841 | ||
| 3842 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21947
diff
changeset
|
3843 | static int mw_rand(void) { |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3844 | static int seed = 0; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3845 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3846 | /* for diversity, not security. don't touch */ |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3847 | srand(time(NULL) ^ seed); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3848 | seed = rand(); |
|
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 | return seed; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3851 | } |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3852 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3853 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3854 | /** 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
|
3855 | static char *im_mime_content_id(void) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3856 | return g_strdup_printf("%03x@%05xmeanwhile", |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3857 | mw_rand() & 0xfff, mw_rand() & 0xfffff); |
| 10977 | 3858 | } |
| 3859 | ||
| 3860 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3861 | /** generates a multipart/related content type with a random-ish |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3862 | 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
|
3863 | static char *im_mime_content_type(void) { |
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3864 | 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
|
3865 | mw_rand() & 0xfff, mw_rand() & 0xffff); |
| 10977 | 3866 | } |
| 3867 | ||
| 3868 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3869 | /** determine content type from extension. Not so happy about this, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3870 | but I don't want to actually write image type detection */ |
| 15884 | 3871 | static char *im_mime_img_content_type(PurpleStoredImage *img) { |
| 3872 | const char *fn = purple_imgstore_get_filename(img); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3873 | const char *ct = NULL; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3874 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3875 | ct = strrchr(fn, '.'); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3876 | if(! ct) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3877 | ct = "image"; |
|
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 | } else if(! strcmp(".png", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3880 | ct = "image/png"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3881 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3882 | } else if(! strcmp(".jpg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3883 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3884 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3885 | } else if(! strcmp(".jpeg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3886 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3887 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3888 | } else if(! strcmp(".gif", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3889 | ct = "image/gif"; |
| 10977 | 3890 | |
| 3891 | } else { | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3892 | ct = "image"; |
| 10977 | 3893 | } |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3894 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3895 | return g_strdup_printf("%s; name=\"%s\"", ct, fn); |
| 10977 | 3896 | } |
| 3897 | ||
| 3898 | ||
| 15884 | 3899 | static char *im_mime_img_content_disp(PurpleStoredImage *img) { |
| 3900 | const char *fn = purple_imgstore_get_filename(img); | |
| 10977 | 3901 | return g_strdup_printf("attachment; filename=\"%s\"", fn); |
| 3902 | } | |
| 3903 | ||
| 3904 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3905 | /** turn an IM with embedded images into a multi-part mime document */ |
| 15884 | 3906 | static char *im_mime_convert(PurpleConnection *gc, |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3907 | struct mwConversation *conv, |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3908 | const char *message) { |
| 10977 | 3909 | GString *str; |
| 15884 | 3910 | PurpleMimeDocument *doc; |
| 3911 | PurpleMimePart *part; | |
| 10977 | 3912 | |
| 3913 | GData *attr; | |
| 3914 | char *tmp, *start, *end; | |
| 3915 | ||
| 3916 | str = g_string_new(NULL); | |
| 3917 | ||
| 15884 | 3918 | doc = purple_mime_document_new(); |
| 3919 | ||
| 3920 | purple_mime_document_set_field(doc, "Mime-Version", "1.0"); | |
| 3921 | purple_mime_document_set_field(doc, "Content-Disposition", "inline"); | |
| 10977 | 3922 | |
| 3923 | tmp = im_mime_content_type(); | |
| 15884 | 3924 | purple_mime_document_set_field(doc, "Content-Type", tmp); |
| 10977 | 3925 | g_free(tmp); |
| 3926 | ||
| 3927 | tmp = (char *) message; | |
| 15884 | 3928 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 3929 | (const char **) &end, &attr)) { |
| 3930 | char *id; | |
| 15884 | 3931 | PurpleStoredImage *img = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3932 | |
| 10977 | 3933 | gsize len = (start - tmp); |
| 3934 | ||
| 3935 | /* append the in-between-tags text */ | |
| 3936 | if(len) g_string_append_len(str, tmp, len); | |
| 3937 | ||
| 3938 | /* find the imgstore data by the id tag */ | |
| 3939 | id = g_datalist_get_data(&attr, "id"); | |
| 3940 | 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
|
3941 | img = purple_imgstore_find_by_id(atoi(id)); |
| 10977 | 3942 | |
| 3943 | if(img) { | |
| 3944 | char *cid; | |
| 3945 | gpointer data; | |
| 3946 | size_t size; | |
| 3947 | ||
| 15884 | 3948 | part = purple_mime_part_new(doc); |
| 10977 | 3949 | |
| 3950 | data = im_mime_img_content_disp(img); | |
| 15884 | 3951 | purple_mime_part_set_field(part, "Content-Disposition", data); |
| 10977 | 3952 | g_free(data); |
| 3953 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3954 | data = im_mime_img_content_type(img); |
| 15884 | 3955 | purple_mime_part_set_field(part, "Content-Type", data); |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3956 | g_free(data); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3957 | |
| 10977 | 3958 | cid = im_mime_content_id(); |
| 3959 | data = g_strdup_printf("<%s>", cid); | |
| 15884 | 3960 | purple_mime_part_set_field(part, "Content-ID", data); |
| 10977 | 3961 | g_free(data); |
| 3962 | ||
| 15884 | 3963 | purple_mime_part_set_field(part, "Content-transfer-encoding", "base64"); |
| 10977 | 3964 | |
| 3965 | /* obtain and base64 encode the image data, and put it in the | |
| 3966 | mime part */ | |
| 15884 | 3967 | 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
|
3968 | data = purple_base64_encode(purple_imgstore_get_data(img), (gsize) size); |
| 15884 | 3969 | purple_mime_part_set_data(part, data); |
| 10977 | 3970 | g_free(data); |
| 3971 | ||
| 3972 | /* append the modified tag */ | |
| 3973 | g_string_append_printf(str, "<img src=\"cid:%s\">", cid); | |
| 3974 | g_free(cid); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3975 | |
| 10977 | 3976 | } else { |
| 3977 | /* append the literal image tag, since we couldn't find a | |
| 3978 | relative imgstore object */ | |
| 3979 | gsize len = (end - start) + 1; | |
| 3980 | g_string_append_len(str, start, len); | |
| 3981 | } | |
| 3982 | ||
| 3983 | g_datalist_clear(&attr); | |
| 3984 | tmp = end + 1; | |
| 3985 | } | |
| 3986 | ||
| 3987 | /* append left-overs */ | |
| 3988 | g_string_append(str, tmp); | |
| 3989 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3990 | /* add the text/html part */ |
| 15884 | 3991 | part = purple_mime_part_new(doc); |
| 3992 | purple_mime_part_set_field(part, "Content-Disposition", "inline"); | |
| 3993 | ||
| 3994 | tmp = purple_utf8_ncr_encode(str->str); | |
| 3995 | purple_mime_part_set_field(part, "Content-Type", "text/html"); | |
| 3996 | purple_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); | |
| 3997 | purple_mime_part_set_data(part, tmp); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3998 | g_free(tmp); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3999 | |
| 10977 | 4000 | g_string_free(str, TRUE); |
| 4001 | ||
| 4002 | str = g_string_new(NULL); | |
| 15884 | 4003 | purple_mime_document_write(doc, str); |
| 10977 | 4004 | tmp = str->str; |
| 4005 | g_string_free(str, FALSE); | |
| 4006 | ||
| 4007 | return tmp; | |
| 4008 | } | |
| 4009 | ||
| 4010 | ||
| 15884 | 4011 | static int mw_prpl_send_im(PurpleConnection *gc, |
| 10977 | 4012 | const char *name, |
| 4013 | const char *message, | |
| 15884 | 4014 | PurpleMessageFlags flags) { |
| 4015 | ||
| 4016 | struct mwPurplePluginData *pd; | |
| 10977 | 4017 | struct mwIdBlock who = { (char *) name, NULL }; |
| 4018 | struct mwConversation *conv; | |
| 4019 | ||
| 4020 | g_return_val_if_fail(gc != NULL, 0); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4021 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4022 | |
| 4023 | g_return_val_if_fail(pd != NULL, 0); | |
| 4024 | ||
| 4025 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 4026 | ||
| 4027 | /* this detection of features to determine how to send the message | |
| 4028 | (plain, html, or mime) is flawed because the other end of the | |
| 4029 | conversation could close their channel at any time, rendering any | |
| 4030 | existing formatting in an outgoing message innapropriate. The end | |
| 4031 | result is that it may be possible that the other side of the | |
| 4032 | conversation will receive a plaintext message with html contents, | |
| 4033 | which is bad. I'm not sure how to fix this correctly. */ | |
| 4034 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4035 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 4036 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 4037 | |
| 4038 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4039 | char *tmp; |
| 10977 | 4040 | int ret; |
| 4041 | ||
| 15884 | 4042 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 4043 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4044 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4045 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4046 | tmp = im_mime_convert(gc, conv, message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4047 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4048 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4049 | |
| 10977 | 4050 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4051 | /* send an HTML message */ |
| 10977 | 4052 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4053 | char *ncr; |
| 15884 | 4054 | ncr = purple_utf8_ncr_encode(message); |
| 4055 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4056 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4057 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4058 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4059 | g_free(tmp); |
| 10977 | 4060 | |
| 4061 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4062 | /* default to text */ |
| 15884 | 4063 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4064 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4065 | g_free(tmp); |
| 10977 | 4066 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4067 | |
| 10977 | 4068 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4069 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4070 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4071 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4072 | /* queue up the message safely as plain text */ |
| 15884 | 4073 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4074 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4075 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4076 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4077 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4078 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4079 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4080 | return 1; |
| 10977 | 4081 | } |
| 4082 | } | |
| 4083 | ||
| 4084 | ||
| 15884 | 4085 | static unsigned int mw_prpl_send_typing(PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4086 | const char *name, |
| 15884 | 4087 | PurpleTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4088 | |
| 15884 | 4089 | struct mwPurplePluginData *pd; |
| 10977 | 4090 | struct mwIdBlock who = { (char *) name, NULL }; |
| 4091 | struct mwConversation *conv; | |
| 4092 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
4093 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 4094 | |
| 4095 | g_return_val_if_fail(gc != NULL, 0); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4096 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4097 | |
| 4098 | g_return_val_if_fail(pd != NULL, 0); | |
| 4099 | ||
| 4100 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 4101 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4102 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4103 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4104 | |
| 15884 | 4105 | } else if((state == PURPLE_TYPING) || (state == PURPLE_TYPED)) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4106 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4107 | 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
|
4108 | 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
|
4109 | |
| 10977 | 4110 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4111 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4112 | if(! mwConversation_isPending(conv)) { |
| 10977 | 4113 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4114 | } |
| 10977 | 4115 | } |
| 4116 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4117 | return 0; |
| 10977 | 4118 | } |
| 4119 | ||
| 4120 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4121 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4122 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4123 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4124 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4125 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4126 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4127 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4128 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4129 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4130 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4131 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4132 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4133 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4134 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4135 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4136 | return "Lotus Sametime Links"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4137 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4138 | case mwLogin_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4139 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4140 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4141 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4142 | return "Lotus Notes Client"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4143 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4144 | case mwLogin_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4145 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4146 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4147 | return "IBM Community Tools"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4148 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4149 | case mwLogin_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4150 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4151 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4152 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4153 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4154 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4155 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4156 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4157 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4158 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4159 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4160 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4161 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4162 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4163 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4164 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4165 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4166 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4167 | return "Trillian"; |
|
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_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4170 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4171 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4172 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4173 | return NULL; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4174 | } |
|
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 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4177 | |
| 15884 | 4178 | static void mw_prpl_get_info(PurpleConnection *gc, const char *who) { |
| 10977 | 4179 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4180 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4181 | |
| 15884 | 4182 | struct mwPurplePluginData *pd; |
| 4183 | PurpleAccount *acct; | |
| 4184 | PurpleBuddy *b; | |
| 4185 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4186 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4187 | const char *tmp2; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4188 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4189 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4190 | g_return_if_fail(*who != '\0'); |
| 10977 | 4191 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4192 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4193 | |
| 15884 | 4194 | acct = purple_connection_get_account(gc); |
| 4195 | b = purple_find_buddy(acct, who); | |
| 4196 | user_info = purple_notify_user_info_new(); | |
| 4197 | ||
| 4198 | if(purple_str_has_prefix(who, "@E ")) { | |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
4199 | purple_notify_user_info_add_pair_html(user_info, _("External User"), NULL); |
| 10977 | 4200 | } |
| 4201 | ||
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4202 | purple_notify_user_info_add_pair_plaintext(user_info, _("User ID"), who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4203 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4204 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4205 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4206 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4207 | if(purple_buddy_get_server_alias(b)) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4208 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4209 | or if we should be using add_pair_plaintext */ |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
4210 | purple_notify_user_info_add_pair_html(user_info, _("Full Name"), purple_buddy_get_server_alias(b)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4211 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4212 | |
| 15884 | 4213 | 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
|
4214 | if(type) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4215 | tmp2 = mw_client_name(type); |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4216 | if (tmp2) { |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4217 | purple_notify_user_info_add_pair_plaintext(user_info, _("Last Known Client"), tmp2); |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4218 | } else { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4219 | tmp = g_strdup_printf(_("Unknown (0x%04x)<br>"), type); |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
4220 | purple_notify_user_info_add_pair_html(user_info, _("Last Known Client"), tmp); |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4221 | g_free(tmp); |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4222 | } |
| 10977 | 4223 | } |
| 4224 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4225 | |
| 10977 | 4226 | tmp = user_supports_text(pd->srvc_aware, who); |
| 4227 | if(tmp) { | |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4228 | purple_notify_user_info_add_pair_plaintext(user_info, _("Supports"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4229 | g_free(tmp); |
| 10977 | 4230 | } |
| 4231 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4232 | if(b) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4233 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status_text(b)); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4234 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4235 | /* 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
|
4236 | 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
|
4237 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
| 15884 | 4238 | purple_notify_user_info_add_section_break(user_info); |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4239 | purple_notify_user_info_add_pair_plaintext(user_info, NULL, tmp2); |
|
12496
788b20ccec91
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4240 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4241 | } |
| 10977 | 4242 | |
| 4243 | /* @todo emit a signal to allow a plugin to override the display of | |
| 4244 | this notification, so that it can create its own */ | |
| 4245 | ||
| 15884 | 4246 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 4247 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 4248 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4249 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4250 | |
| 15884 | 4251 | static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status) { |
| 4252 | PurpleConnection *gc; | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4253 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
4254 | char *message = NULL; |
| 10977 | 4255 | struct mwSession *session; |
| 4256 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4257 | |
| 10977 | 4258 | g_return_if_fail(acct != NULL); |
| 15884 | 4259 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4260 | |
| 15884 | 4261 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4262 | |
| 15884 | 4263 | 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
|
4264 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4265 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4266 | |
| 10977 | 4267 | session = gc_to_session(gc); |
| 4268 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4269 | |
| 10977 | 4270 | /* get a working copy of the current status */ |
| 4271 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4272 | |
| 10977 | 4273 | /* determine the state */ |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4274 | if(! strcmp(state, MW_STATE_ACTIVE)) { |
| 10977 | 4275 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4276 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4277 | } else if(! strcmp(state, MW_STATE_AWAY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4278 | stat.status = mwStatus_AWAY; |
|
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_BUSY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4281 | stat.status = mwStatus_BUSY; |
| 10977 | 4282 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4283 | |
| 10977 | 4284 | /* determine the message */ |
| 15884 | 4285 | 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
|
4286 | |
| 10977 | 4287 | if(message) { |
| 4288 | /* all the possible non-NULL values of message up to this point | |
| 4289 | are const, so we don't need to free them */ | |
| 15884 | 4290 | message = purple_markup_strip_html(message); |
| 10977 | 4291 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4292 | |
| 10977 | 4293 | /* out with the old */ |
| 4294 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4295 | |
| 10977 | 4296 | /* in with the new */ |
| 4297 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4298 | |
| 10977 | 4299 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4300 | mwUserStatus_clear(&stat); |
| 10977 | 4301 | } |
| 4302 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4303 | |
| 15884 | 4304 | static void mw_prpl_set_idle(PurpleConnection *gc, int t) { |
| 10977 | 4305 | struct mwSession *session; |
| 4306 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4307 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4308 | |
| 10977 | 4309 | session = gc_to_session(gc); |
| 4310 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4311 | |
| 10977 | 4312 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4313 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4314 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4315 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4316 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4317 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4318 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4319 | stat.time = 0; |
|
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 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4322 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4323 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4324 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4325 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4326 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4327 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4328 | stat.status = mwStatus_ACTIVE; |
| 4329 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4330 | |
| 10977 | 4331 | mwSession_setUserStatus(session, &stat); |
| 4332 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4333 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4334 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4335 | |
| 15884 | 4336 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4337 | PurpleAccount *acct; | |
| 4338 | PurpleConversation *conv; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4339 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4340 | |
| 15884 | 4341 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4342 | id = g_list_nth_data(row, 1); |
| 15884 | 4343 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, id, acct); |
| 4344 | if(! conv) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, id); | |
| 4345 | purple_conversation_present(conv); | |
| 4346 | } | |
| 4347 | ||
| 4348 | ||
| 4349 | 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
|
4350 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4351 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4352 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4353 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4354 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4355 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4356 | |
| 15884 | 4357 | 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
|
4358 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4359 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4360 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4361 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4362 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4363 | static void notify_close(gpointer data) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4364 | if (data) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4365 | g_free(data); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4366 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4367 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4368 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4369 | |
| 10977 | 4370 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4371 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4372 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4373 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4374 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4375 | char *msg; |
| 10977 | 4376 | |
| 15884 | 4377 | PurpleNotifySearchResults *sres; |
| 4378 | PurpleNotifySearchColumn *scol; | |
| 4379 | ||
| 4380 | sres = purple_notify_searchresults_new(); | |
| 4381 | ||
| 4382 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4383 | purple_notify_searchresults_column_add(sres, scol); | |
| 4384 | ||
| 4385 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4386 | purple_notify_searchresults_column_add(sres, scol); | |
| 4387 | ||
| 4388 | 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
|
4389 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4390 | |
| 15884 | 4391 | 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
|
4392 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4393 | |
| 10977 | 4394 | for(l = result->matches; l; l = l->next) { |
| 4395 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4396 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4397 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4398 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4399 | NSTR(match->id), NSTR(match->name)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4400 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4401 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4402 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4403 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4404 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4405 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4406 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4407 | } |
| 10977 | 4408 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4409 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4410 | 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
|
4411 | " 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
|
4412 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4413 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4414 | |
| 15884 | 4415 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4416 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4417 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4418 | g_free(msg); |
| 10977 | 4419 | } |
| 4420 | ||
| 4421 | ||
| 4422 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4423 | guint32 id, guint32 code, GList *results, | |
| 4424 | gpointer b) { | |
| 4425 | ||
| 4426 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4427 | BuddyAddData *data = b; |
| 15884 | 4428 | PurpleBuddy *buddy = NULL; |
| 4429 | PurpleConnection *gc; | |
| 4430 | struct mwPurplePluginData *pd; | |
| 10977 | 4431 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4432 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4433 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4434 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4435 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4436 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4437 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4438 | |
| 4439 | if(results) | |
| 4440 | res = results->data; | |
| 4441 | ||
| 4442 | 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
|
4443 | if(!res->matches->next) { |
| 10977 | 4444 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4445 | |
| 10977 | 4446 | /* only one? that might be the right one! */ |
| 4447 | if(strcmp(res->name, match->id)) { | |
| 4448 | /* uh oh, the single result isn't identical to the search | |
| 4449 | term, better safe then sorry, so let's make sure it's who | |
| 4450 | the user meant to add */ | |
| 15884 | 4451 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4452 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4453 | |
| 10977 | 4454 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4455 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4456 | /* same person, set the server alias */ |
| 15884 | 4457 | purple_blist_server_alias_buddy(buddy, match->name); |
| 4458 | purple_blist_node_set_string((PurpleBlistNode *) buddy, | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4459 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4460 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4461 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4462 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4463 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4464 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4465 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4466 | g_free(data); |
| 10977 | 4467 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4468 | |
| 10977 | 4469 | } else { |
| 4470 | /* prompt user if more than one match was returned */ | |
| 15884 | 4471 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4472 | multi_resolved_query(res, gc, data); |
| 10977 | 4473 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4474 | |
| 10977 | 4475 | return; |
| 4476 | } | |
| 4477 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4478 | #if 0 |
| 10977 | 4479 | /* fall-through indicates that we couldn't find a matching user in |
| 4480 | the resolve service (ether error or zero results), so we remove | |
| 4481 | this buddy */ | |
| 4482 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4483 | /* 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
|
4484 | 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
|
4485 | 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
|
4486 | 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
|
4487 | 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
|
4488 | |
| 10977 | 4489 | DEBUG_INFO("no such buddy in community\n"); |
| 15884 | 4490 | purple_blist_remove_buddy(buddy); |
| 10977 | 4491 | blist_schedule(pd); |
| 4492 | ||
| 4493 | if(res && res->name) { | |
| 4494 | /* compose and display an error message */ | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4495 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4496 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4497 | char *msg; |
| 10977 | 4498 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4499 | msgA = _("Unable to add user: user not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4500 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4501 | 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
|
4502 | " Sametime community. This entry has been removed from" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4503 | " your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4504 | msg = g_strdup_printf(msgB, NSTR(res->name)); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4505 | |
| 15884 | 4506 | purple_notify_error(gc, _("Unable to add user"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4507 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4508 | g_free(msg); |
| 10977 | 4509 | } |
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4510 | #endif |
| 10977 | 4511 | } |
| 4512 | ||
| 4513 | ||
| 15884 | 4514 | static void mw_prpl_add_buddy(PurpleConnection *gc, |
| 4515 | PurpleBuddy *buddy, | |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4516 | PurpleGroup *group, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4517 | const char *message) { |
| 15884 | 4518 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4519 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4520 | struct mwServiceResolve *srvc; |
| 4521 | GList *query; | |
| 4522 | enum mwResolveFlag flags; | |
| 4523 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4524 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4525 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4526 | /* 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
|
4527 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4528 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4529 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4530 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4531 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4532 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4533 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4534 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4535 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4536 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4537 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4538 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4539 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4540 | ||
| 4541 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4542 | data, NULL); |
| 10977 | 4543 | g_list_free(query); |
| 4544 | ||
| 4545 | if(req == SEARCH_ERROR) { | |
| 15884 | 4546 | purple_blist_remove_buddy(buddy); |
| 10977 | 4547 | blist_schedule(pd); |
| 4548 | } | |
| 4549 | } | |
| 4550 | ||
| 4551 | ||
| 15884 | 4552 | static void foreach_add_buddies(PurpleGroup *group, GList *buddies, |
| 4553 | struct mwPurplePluginData *pd) { | |
| 10977 | 4554 | struct mwAwareList *list; |
| 4555 | ||
| 4556 | list = list_ensure(pd, group); | |
| 4557 | mwAwareList_addAware(list, buddies); | |
| 4558 | g_list_free(buddies); | |
| 4559 | } | |
| 4560 | ||
| 4561 | ||
| 15884 | 4562 | static void mw_prpl_add_buddies(PurpleConnection *gc, |
| 10977 | 4563 | GList *buddies, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4564 | GList *groups, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4565 | const char *message) { |
| 10977 | 4566 | |
| 15884 | 4567 | struct mwPurplePluginData *pd; |
| 10977 | 4568 | GHashTable *group_sets; |
| 4569 | struct mwAwareIdBlock *idbs, *idb; | |
| 4570 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4571 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4572 | |
| 15884 | 4573 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4574 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4575 | ||
| 4576 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4577 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4578 | ||
| 4579 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4580 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4581 | PurpleBuddy *b = buddies->data; |
| 4582 | PurpleGroup *g; | |
| 10977 | 4583 | const char *fn; |
| 4584 | GList *l; | |
| 4585 | ||
| 4586 | /* nab the saved server alias and stick it on the buddy */ | |
| 15884 | 4587 | fn = purple_blist_node_get_string((PurpleBlistNode *) b, BUDDY_KEY_NAME); |
| 4588 | purple_blist_server_alias_buddy(b, fn); | |
| 4589 | ||
| 4590 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4591 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4592 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4593 | idb->community = NULL; |
| 4594 | ||
| 4595 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4596 | g = purple_buddy_get_group(b); |
| 10977 | 4597 | l = g_hash_table_lookup(group_sets, g); |
| 4598 | l = g_list_prepend(l, idb++); | |
| 4599 | g_hash_table_insert(group_sets, g, l); | |
| 4600 | } | |
| 4601 | ||
| 4602 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4603 | for saving */ | |
| 4604 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4605 | blist_schedule(pd); | |
| 4606 | ||
| 4607 | /* cleanup */ | |
| 4608 | g_hash_table_destroy(group_sets); | |
| 4609 | g_free(idbs); | |
| 4610 | } | |
| 4611 | ||
| 4612 | ||
| 15884 | 4613 | static void mw_prpl_remove_buddy(PurpleConnection *gc, |
| 4614 | PurpleBuddy *buddy, PurpleGroup *group) { | |
| 4615 | ||
| 4616 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4617 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4618 | struct mwAwareList *list; |
| 4619 | ||
| 4620 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4621 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4622 | pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4623 | group = purple_buddy_get_group(buddy); |
| 10977 | 4624 | list = list_ensure(pd, group); |
| 4625 | ||
| 4626 | mwAwareList_removeAware(list, rem); | |
| 4627 | blist_schedule(pd); | |
| 4628 | ||
| 4629 | g_list_free(rem); | |
| 4630 | } | |
| 4631 | ||
| 4632 | ||
| 4633 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4634 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4635 | |
| 10977 | 4636 | struct mwUserItem *u; |
| 4637 | guint count; | |
| 4638 | ||
| 4639 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4640 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4641 | |
| 4642 | priv->count = count; | |
| 4643 | priv->users = g_new0(struct mwUserItem, count); | |
| 4644 | ||
| 4645 | while(count--) { | |
| 4646 | u = priv->users + count; | |
| 4647 | u->id = members->data; | |
| 4648 | members = members->next; | |
| 4649 | } | |
| 4650 | } | |
| 4651 | ||
| 4652 | ||
| 15884 | 4653 | static void mw_prpl_set_permit_deny(PurpleConnection *gc) { |
| 4654 | PurpleAccount *acct; | |
| 4655 | struct mwPurplePluginData *pd; | |
| 10977 | 4656 | struct mwSession *session; |
| 4657 | ||
| 4658 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4659 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4660 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4661 | NULL, /* users */ |
| 10977 | 4662 | }; |
| 4663 | ||
| 4664 | g_return_if_fail(gc != NULL); | |
| 4665 | ||
| 15884 | 4666 | acct = purple_connection_get_account(gc); |
| 10977 | 4667 | g_return_if_fail(acct != NULL); |
| 4668 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4669 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4670 | g_return_if_fail(pd != NULL); |
| 4671 | ||
| 4672 | session = pd->session; | |
| 4673 | g_return_if_fail(session != NULL); | |
| 4674 | ||
|
32623
547eacef0b63
Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
32617
diff
changeset
|
4675 | switch(purple_account_get_privacy_type(acct)) { |
| 15884 | 4676 | case PURPLE_PRIVACY_DENY_USERS: |
| 4677 | DEBUG_INFO("PURPLE_PRIVACY_DENY_USERS\n"); | |
| 10977 | 4678 | privacy_fill(&privacy, acct->deny); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4679 | privacy.deny = TRUE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4680 | break; |
| 10977 | 4681 | |
| 15884 | 4682 | case PURPLE_PRIVACY_ALLOW_ALL: |
| 4683 | DEBUG_INFO("PURPLE_PRIVACY_ALLOW_ALL\n"); | |
| 10977 | 4684 | privacy.deny = TRUE; |
| 4685 | break; | |
| 4686 | ||
| 15884 | 4687 | case PURPLE_PRIVACY_ALLOW_USERS: |
| 4688 | DEBUG_INFO("PURPLE_PRIVACY_ALLOW_USERS\n"); | |
| 10977 | 4689 | privacy_fill(&privacy, acct->permit); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4690 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4691 | break; |
| 10977 | 4692 | |
| 15884 | 4693 | case PURPLE_PRIVACY_DENY_ALL: |
| 4694 | DEBUG_INFO("PURPLE_PRIVACY_DENY_ALL\n"); | |
| 10977 | 4695 | privacy.deny = FALSE; |
| 4696 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4697 | |
| 10977 | 4698 | default: |
|
32623
547eacef0b63
Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
32617
diff
changeset
|
4699 | DEBUG_INFO("acct->perm_deny is 0x%x\n", purple_account_get_privacy_type(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4700 | return; |
| 10977 | 4701 | } |
| 4702 | ||
| 4703 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4704 | g_free(privacy.users); | |
| 4705 | } | |
| 4706 | ||
| 4707 | ||
| 15884 | 4708 | static void mw_prpl_add_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4709 | mw_prpl_set_permit_deny(gc); |
| 4710 | } | |
| 4711 | ||
| 4712 | ||
| 15884 | 4713 | static void mw_prpl_add_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4714 | mw_prpl_set_permit_deny(gc); |
| 4715 | } | |
| 4716 | ||
| 4717 | ||
| 15884 | 4718 | static void mw_prpl_rem_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4719 | mw_prpl_set_permit_deny(gc); |
| 4720 | } | |
| 4721 | ||
| 4722 | ||
| 15884 | 4723 | static void mw_prpl_rem_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4724 | mw_prpl_set_permit_deny(gc); |
| 4725 | } | |
| 4726 | ||
| 4727 | ||
| 4728 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4729 | const char *name) { | |
| 4730 | GList *l, *ll; | |
| 4731 | struct mwConference *conf = NULL; | |
| 4732 | ||
| 4733 | ll = mwServiceConference_getConferences(srvc); | |
| 4734 | for(l = ll; l; l = l->next) { | |
| 4735 | struct mwConference *c = l->data; | |
| 4736 | if(! strcmp(name, mwConference_getName(c))) { | |
| 4737 | conf = c; | |
| 4738 | break; | |
| 4739 | } | |
| 4740 | } | |
| 4741 | g_list_free(ll); | |
| 4742 | ||
| 4743 | return conf; | |
| 4744 | } | |
| 4745 | ||
| 4746 | ||
| 15884 | 4747 | static void mw_prpl_join_chat(PurpleConnection *gc, |
| 10977 | 4748 | GHashTable *components) { |
| 4749 | ||
| 15884 | 4750 | struct mwPurplePluginData *pd; |
| 10977 | 4751 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4752 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4753 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4754 | |
| 4755 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4756 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4757 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4758 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4759 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4760 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4761 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4762 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4763 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4764 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4765 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4766 | |
| 10977 | 4767 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4768 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4769 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4770 | struct mwConference *conf = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4771 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4772 | srvc = pd->srvc_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4773 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4774 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4775 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4776 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4777 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4778 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4779 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4780 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4781 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4782 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4783 | } |
| 10977 | 4784 | } |
| 4785 | } | |
| 4786 | ||
| 4787 | ||
| 15884 | 4788 | static void mw_prpl_reject_chat(PurpleConnection *gc, |
| 10977 | 4789 | GHashTable *components) { |
| 4790 | ||
| 15884 | 4791 | struct mwPurplePluginData *pd; |
| 10977 | 4792 | struct mwServiceConference *srvc; |
| 4793 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4794 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4795 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4796 | srvc = pd->srvc_conf; |
| 4797 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4798 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4799 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4800 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4801 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4802 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4803 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4804 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4805 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4806 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4807 | } |
| 10977 | 4808 | } |
| 4809 | } | |
| 4810 | ||
| 4811 | ||
| 4812 | static char *mw_prpl_get_chat_name(GHashTable *components) { | |
| 4813 | return g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4814 | } | |
| 4815 | ||
| 4816 | ||
| 15884 | 4817 | static void mw_prpl_chat_invite(PurpleConnection *gc, |
| 10977 | 4818 | int id, |
| 4819 | const char *invitation, | |
| 4820 | const char *who) { | |
| 4821 | ||
| 15884 | 4822 | struct mwPurplePluginData *pd; |
| 10977 | 4823 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4824 | struct mwPlace *place; |
| 10977 | 4825 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4826 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4827 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4828 | g_return_if_fail(pd != NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4829 | |
| 10977 | 4830 | conf = ID_TO_CONF(pd, id); |
| 4831 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4832 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4833 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4834 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4835 | } |
|
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 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4838 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4839 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4840 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4841 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4842 | } |
| 4843 | ||
| 4844 | ||
| 15884 | 4845 | static void mw_prpl_chat_leave(PurpleConnection *gc, |
| 10977 | 4846 | int id) { |
| 4847 | ||
| 15884 | 4848 | struct mwPurplePluginData *pd; |
| 10977 | 4849 | struct mwConference *conf; |
| 4850 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4851 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4852 | |
| 4853 | g_return_if_fail(pd != NULL); | |
| 4854 | conf = ID_TO_CONF(pd, id); | |
| 4855 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4856 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4857 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4858 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4859 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4860 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4861 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4862 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4863 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4864 | } |
| 10977 | 4865 | } |
| 4866 | ||
| 4867 | ||
| 15884 | 4868 | static void mw_prpl_chat_whisper(PurpleConnection *gc, |
| 10977 | 4869 | int id, |
| 4870 | const char *who, | |
| 4871 | const char *message) { | |
| 4872 | ||
| 4873 | mw_prpl_send_im(gc, who, message, 0); | |
| 4874 | } | |
| 4875 | ||
| 4876 | ||
| 15884 | 4877 | static int mw_prpl_chat_send(PurpleConnection *gc, |
| 10977 | 4878 | int id, |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4879 | const char *message, |
| 15884 | 4880 | PurpleMessageFlags flags) { |
| 4881 | ||
| 4882 | struct mwPurplePluginData *pd; | |
| 10977 | 4883 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4884 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4885 | int ret; |
| 10977 | 4886 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4887 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4888 | |
| 4889 | g_return_val_if_fail(pd != NULL, 0); | |
| 4890 | conf = ID_TO_CONF(pd, id); | |
| 4891 | ||
| 15884 | 4892 | msg = purple_markup_strip_html(message); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4893 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4894 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4895 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4896 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4897 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4898 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4899 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4900 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4901 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4902 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4903 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4904 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4905 | return ret; |
| 10977 | 4906 | } |
| 4907 | ||
| 4908 | ||
| 15884 | 4909 | static void mw_prpl_keepalive(PurpleConnection *gc) { |
| 10977 | 4910 | struct mwSession *session; |
| 4911 | ||
| 4912 | g_return_if_fail(gc != NULL); | |
| 4913 | ||
| 4914 | session = gc_to_session(gc); | |
| 4915 | g_return_if_fail(session != NULL); | |
| 4916 | ||
| 4917 | mwSession_sendKeepalive(session); | |
| 4918 | } | |
| 4919 | ||
| 4920 | ||
| 15884 | 4921 | static void mw_prpl_alias_buddy(PurpleConnection *gc, |
| 10977 | 4922 | const char *who, |
| 4923 | const char *alias) { | |
| 4924 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4925 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4926 | g_return_if_fail(pd != NULL); |
| 4927 | ||
| 4928 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4929 | the server copy */ | |
| 4930 | ||
| 4931 | blist_schedule(pd); | |
| 4932 | } | |
| 4933 | ||
| 4934 | ||
| 15884 | 4935 | static void mw_prpl_group_buddy(PurpleConnection *gc, |
| 10977 | 4936 | const char *who, |
| 4937 | const char *old_group, | |
| 4938 | const char *new_group) { | |
| 4939 | ||
| 4940 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 4941 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4942 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4943 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4944 | PurpleGroup *group; |
| 10977 | 4945 | struct mwAwareList *list; |
| 4946 | ||
| 4947 | /* add who to new_group's aware list */ | |
| 15884 | 4948 | group = purple_find_group(new_group); |
| 10977 | 4949 | list = list_ensure(pd, group); |
| 4950 | mwAwareList_addAware(list, gl); | |
| 4951 | ||
| 4952 | /* remove who from old_group's aware list */ | |
| 15884 | 4953 | group = purple_find_group(old_group); |
| 10977 | 4954 | list = list_ensure(pd, group); |
| 4955 | mwAwareList_removeAware(list, gl); | |
| 4956 | ||
| 4957 | g_list_free(gl); | |
| 4958 | ||
| 4959 | /* schedule the changes to be saved */ | |
| 4960 | blist_schedule(pd); | |
| 4961 | } | |
| 4962 | ||
| 4963 | ||
| 15884 | 4964 | static void mw_prpl_rename_group(PurpleConnection *gc, |
| 10977 | 4965 | const char *old, |
| 15884 | 4966 | PurpleGroup *group, |
| 10977 | 4967 | GList *buddies) { |
| 4968 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4969 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4970 | g_return_if_fail(pd != NULL); |
| 4971 | ||
| 4972 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4973 | the server copy. Also, having this function should prevent all | |
| 4974 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4975 | give a crap what the group is named in Purple other than to record |
| 10977 | 4976 | that as the group name/alias */ |
| 4977 | ||
| 4978 | blist_schedule(pd); | |
| 4979 | } | |
| 4980 | ||
| 4981 | ||
| 15884 | 4982 | static void mw_prpl_buddy_free(PurpleBuddy *buddy) { |
| 10977 | 4983 | /* I don't think we have any cleanup for buddies yet */ |
| 4984 | ; | |
| 4985 | } | |
| 4986 | ||
| 4987 | ||
| 15884 | 4988 | static void mw_prpl_convo_closed(PurpleConnection *gc, const char *who) { |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4989 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4990 | struct mwServiceIm *srvc; |
| 4991 | struct mwConversation *conv; | |
| 4992 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4993 | ||
| 4994 | g_return_if_fail(pd != NULL); | |
| 4995 | ||
| 4996 | srvc = pd->srvc_im; | |
| 4997 | g_return_if_fail(srvc != NULL); | |
| 4998 | ||
| 4999 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 5000 | if(! conv) return; | |
| 5001 | ||
| 5002 | if(mwConversation_isOpen(conv)) | |
| 5003 | mwConversation_free(conv); | |
| 5004 | } | |
| 5005 | ||
| 5006 | ||
| 15884 | 5007 | static const char *mw_prpl_normalize(const PurpleAccount *account, |
| 10977 | 5008 | const char *id) { |
| 5009 | ||
| 5010 | /* code elsewhere assumes that the return value points to different | |
| 5011 | memory than the passed value, but it won't free the normalized | |
| 5012 | data. wtf? */ | |
| 5013 | ||
| 5014 | static char buf[BUF_LEN]; | |
| 5015 | strncpy(buf, id, sizeof(buf)); | |
| 5016 | return buf; | |
| 5017 | } | |
| 5018 | ||
| 5019 | ||
| 15884 | 5020 | static void mw_prpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { |
| 5021 | struct mwPurplePluginData *pd; | |
| 10977 | 5022 | struct mwAwareList *list; |
| 5023 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5024 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5025 | g_return_if_fail(pd != NULL); |
| 5026 | g_return_if_fail(pd->group_list_map != NULL); | |
| 5027 | ||
| 5028 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 5029 | ||
| 5030 | if(list) { | |
| 5031 | g_hash_table_remove(pd->group_list_map, list); | |
| 5032 | g_hash_table_remove(pd->group_list_map, group); | |
| 5033 | mwAwareList_free(list); | |
| 5034 | ||
| 5035 | blist_schedule(pd); | |
| 5036 | } | |
| 5037 | } | |
| 5038 | ||
| 5039 | ||
| 15884 | 5040 | static gboolean mw_prpl_can_receive_file(PurpleConnection *gc, |
| 10977 | 5041 | const char *who) { |
| 15884 | 5042 | struct mwPurplePluginData *pd; |
| 10977 | 5043 | struct mwServiceAware *srvc; |
| 15884 | 5044 | PurpleAccount *acct; |
| 10977 | 5045 | |
| 5046 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 5047 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5048 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5049 | g_return_val_if_fail(pd != NULL, FALSE); |
| 5050 | ||
| 5051 | srvc = pd->srvc_aware; | |
| 5052 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5053 | |
| 15884 | 5054 | acct = purple_connection_get_account(gc); |
| 10977 | 5055 | g_return_val_if_fail(acct != NULL, FALSE); |
| 5056 | ||
| 15884 | 5057 | return purple_find_buddy(acct, who) && |
| 10977 | 5058 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 5059 | } | |
| 5060 | ||
| 5061 | ||
| 15884 | 5062 | static void ft_outgoing_init(PurpleXfer *xfer) { |
| 5063 | PurpleAccount *acct; | |
| 5064 | PurpleConnection *gc; | |
| 5065 | ||
| 5066 | struct mwPurplePluginData *pd; | |
| 10977 | 5067 | struct mwServiceFileTransfer *srvc; |
| 5068 | struct mwFileTransfer *ft; | |
| 5069 | ||
| 5070 | const char *filename; | |
| 5071 | gsize filesize; | |
| 5072 | FILE *fp; | |
| 5073 | ||
| 5074 | struct mwIdBlock idb = { NULL, NULL }; | |
| 5075 | ||
| 5076 | DEBUG_INFO("ft_outgoing_init\n"); | |
| 5077 | ||
| 15884 | 5078 | acct = purple_xfer_get_account(xfer); |
| 5079 | gc = purple_account_get_connection(acct); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5080 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5081 | srvc = pd->srvc_ft; |
| 5082 | ||
| 15884 | 5083 | filename = purple_xfer_get_local_filename(xfer); |
| 5084 | filesize = purple_xfer_get_size(xfer); | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
5085 | idb.user = purple_xfer_get_remote_user(xfer); |
| 10977 | 5086 | |
| 15884 | 5087 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5088 | |
| 10977 | 5089 | /* test that we can actually send the file */ |
| 5090 | fp = g_fopen(filename, "rb"); | |
| 5091 | if(! fp) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5092 | 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
|
5093 | filename, g_strerror(errno)); |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
5094 | purple_xfer_error(purple_xfer_get_type(xfer), acct, purple_xfer_get_remote_user(xfer), msg); |
| 10977 | 5095 | g_free(msg); |
| 5096 | return; | |
| 5097 | } | |
| 5098 | fclose(fp); | |
| 5099 | ||
| 5100 | { | |
| 5101 | char *tmp = strrchr(filename, G_DIR_SEPARATOR); | |
| 5102 | if(tmp++) filename = tmp; | |
| 5103 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5104 | |
| 10977 | 5105 | ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); |
| 5106 | ||
| 15884 | 5107 | purple_xfer_ref(xfer); |
| 5108 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
5109 | purple_xfer_set_protocol_data(xfer, ft); |
| 10977 | 5110 | |
| 5111 | mwFileTransfer_offer(ft); | |
| 5112 | } | |
| 5113 | ||
| 5114 | ||
| 15884 | 5115 | static void ft_outgoing_cancel(PurpleXfer *xfer) { |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
5116 | struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5117 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5118 | DEBUG_INFO("ft_outgoing_cancel called\n"); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5119 | |
| 10977 | 5120 | if(ft) mwFileTransfer_cancel(ft); |
| 5121 | } | |
| 5122 | ||
| 5123 | ||
| 15884 | 5124 | static PurpleXfer *mw_prpl_new_xfer(PurpleConnection *gc, const char *who) { |
| 5125 | PurpleAccount *acct; | |
| 5126 | PurpleXfer *xfer; | |
| 5127 | ||
| 5128 | acct = purple_connection_get_account(gc); | |
| 5129 | ||
| 5130 | xfer = purple_xfer_new(acct, PURPLE_XFER_SEND, who); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5131 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5132 | { |
| 15884 | 5133 | purple_xfer_set_init_fnc(xfer, ft_outgoing_init); |
| 5134 | purple_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5135 | } |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5136 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5137 | return xfer; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5138 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5139 | |
| 15884 | 5140 | static void mw_prpl_send_file(PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5141 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5142 | |
| 15884 | 5143 | PurpleXfer *xfer = mw_prpl_new_xfer(gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5144 | |
| 10977 | 5145 | if(file) { |
| 5146 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 5147 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 5148 | |
| 5149 | } else { | |
| 5150 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 5151 | purple_xfer_request(xfer); |
| 10977 | 5152 | } |
| 5153 | } | |
| 5154 | ||
| 5155 | ||
| 15884 | 5156 | static PurplePluginProtocolInfo mw_prpl_info = { |
|
32316
21dab55b4699
Move struct_size to the beginning of the struct. Even if we don't
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32315
diff
changeset
|
5157 | .struct_size = sizeof(PurplePluginProtocolInfo), |
| 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 | .alias_buddy = mw_prpl_alias_buddy, | |
| 5199 | .group_buddy = mw_prpl_group_buddy, | |
| 5200 | .rename_group = mw_prpl_rename_group, | |
| 5201 | .buddy_free = mw_prpl_buddy_free, | |
| 5202 | .convo_closed = mw_prpl_convo_closed, | |
| 5203 | .normalize = mw_prpl_normalize, | |
| 5204 | .set_buddy_icon = NULL, | |
| 5205 | .remove_group = mw_prpl_remove_group, | |
| 5206 | .get_cb_real_name = NULL, | |
| 5207 | .set_chat_topic = NULL, | |
| 5208 | .find_blist_chat = NULL, | |
| 5209 | .roomlist_get_list = NULL, | |
| 5210 | .roomlist_expand_category = NULL, | |
| 5211 | .can_receive_file = mw_prpl_can_receive_file, | |
| 5212 | .send_file = mw_prpl_send_file, | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5213 | .new_xfer = mw_prpl_new_xfer, |
|
12650
ca70a14f4994
[gaim-migrate @ 14988]
Mark Doliner <markdoliner@pidgin.im>
parents:
12631
diff
changeset
|
5214 | .offline_message = NULL, |
|
ca70a14f4994
[gaim-migrate @ 14988]
Mark Doliner <markdoliner@pidgin.im>
parents:
12631
diff
changeset
|
5215 | .whiteboard_prpl_ops = NULL, |
|
32316
21dab55b4699
Move struct_size to the beginning of the struct. Even if we don't
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32315
diff
changeset
|
5216 | .send_raw = NULL |
| 10977 | 5217 | }; |
| 5218 | ||
| 5219 | ||
| 15884 | 5220 | static PurplePluginPrefFrame * |
| 5221 | mw_plugin_get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 5222 | PurplePluginPrefFrame *frame; | |
| 5223 | PurplePluginPref *pref; | |
| 5224 | ||
| 5225 | frame = purple_plugin_pref_frame_new(); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5226 | |
| 15884 | 5227 | pref = purple_plugin_pref_new_with_label(_("Remotely Stored Buddy List")); |
| 5228 | purple_plugin_pref_frame_add(frame, pref); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5229 | |
| 10977 | 5230 | |
| 15884 | 5231 | pref = purple_plugin_pref_new_with_name(MW_PRPL_OPT_BLIST_ACTION); |
| 5232 | purple_plugin_pref_set_label(pref, _("Buddy List Storage Mode")); | |
| 5233 | ||
| 5234 | purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE); | |
| 5235 | 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
|
5236 | GINT_TO_POINTER(blist_choice_LOCAL)); |
| 15884 | 5237 | 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
|
5238 | GINT_TO_POINTER(blist_choice_MERGE)); |
| 15884 | 5239 | 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
|
5240 | GINT_TO_POINTER(blist_choice_STORE)); |
| 15884 | 5241 | 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
|
5242 | GINT_TO_POINTER(blist_choice_SYNCH)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5243 | |
| 15884 | 5244 | purple_plugin_pref_frame_add(frame, pref); |
| 10977 | 5245 | |
| 5246 | return frame; | |
| 5247 | } | |
| 5248 | ||
| 5249 | ||
| 15884 | 5250 | static PurplePluginUiInfo mw_plugin_ui_info = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5251 | mw_plugin_get_plugin_pref_frame, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5252 | 0, /* page_num */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5253 | NULL, /* frame */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5254 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5255 | NULL, |
|
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 |
| 10977 | 5258 | }; |
| 5259 | ||
| 5260 | ||
| 15884 | 5261 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5262 | struct mwSametimeList *l; |
| 5263 | ||
| 5264 | FILE *file; | |
| 5265 | char buf[BUF_LEN]; | |
| 5266 | size_t len; | |
| 5267 | ||
| 5268 | GString *str; | |
| 5269 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5270 | file = g_fopen(filename, "r"); |
| 10977 | 5271 | g_return_if_fail(file != NULL); |
| 5272 | ||
| 5273 | str = g_string_new(NULL); | |
| 5274 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 5275 | g_string_append_len(str, buf, len); | |
| 5276 | } | |
| 5277 | ||
| 5278 | fclose(file); | |
| 5279 | ||
| 5280 | l = mwSametimeList_load(str->str); | |
| 5281 | g_string_free(str, TRUE); | |
| 5282 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5283 | blist_merge(gc, l); |
| 10977 | 5284 | mwSametimeList_free(l); |
| 5285 | } | |
| 5286 | ||
| 5287 | ||
| 5288 | /** prompts for a file to import blist from */ | |
| 15884 | 5289 | static void st_import_action(PurplePluginAction *act) { |
| 5290 | PurpleConnection *gc; | |
| 5291 | PurpleAccount *account; | |
| 10977 | 5292 | char *title; |
| 5293 | ||
| 5294 | gc = act->context; | |
| 15884 | 5295 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5296 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 5297 | purple_account_get_username(account)); |
| 5298 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5299 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 5300 | 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
|
5301 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5302 | gc); |
| 10977 | 5303 | |
| 5304 | g_free(title); | |
| 5305 | } | |
| 5306 | ||
| 5307 | ||
| 15884 | 5308 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5309 | struct mwSametimeList *l; |
| 5310 | char *str; | |
| 5311 | FILE *file; | |
| 5312 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5313 | file = g_fopen(filename, "w"); |
| 10977 | 5314 | g_return_if_fail(file != NULL); |
| 5315 | ||
| 5316 | l = mwSametimeList_new(); | |
| 5317 | blist_export(gc, l); | |
| 5318 | str = mwSametimeList_store(l); | |
| 5319 | mwSametimeList_free(l); | |
| 5320 | ||
| 5321 | fprintf(file, "%s", str); | |
| 5322 | fclose(file); | |
| 5323 | ||
| 5324 | g_free(str); | |
| 5325 | } | |
| 5326 | ||
| 5327 | ||
| 5328 | /** prompts for a file to export blist to */ | |
| 15884 | 5329 | static void st_export_action(PurplePluginAction *act) { |
| 5330 | PurpleConnection *gc; | |
| 5331 | PurpleAccount *account; | |
| 10977 | 5332 | char *title; |
| 5333 | ||
| 5334 | gc = act->context; | |
| 15884 | 5335 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5336 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 5337 | purple_account_get_username(account)); |
| 5338 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5339 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 5340 | 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
|
5341 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5342 | gc); |
| 10977 | 5343 | |
| 5344 | g_free(title); | |
| 5345 | } | |
| 5346 | ||
| 5347 | ||
| 5348 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 5349 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5350 | |
| 15884 | 5351 | 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
|
5352 | GList *l; |
| 10977 | 5353 | |
| 15884 | 5354 | f = purple_request_fields_get_field(fields, "group"); |
| 5355 | l = purple_request_field_list_get_items(f); | |
| 10977 | 5356 | |
| 5357 | for(; l; l = l->next) { | |
| 5358 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5359 | struct named_id *res; |
| 10977 | 5360 | |
| 15884 | 5361 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5362 | |
| 5363 | g_free(res->id); | |
| 5364 | g_free(res->name); | |
| 5365 | g_free(res); | |
| 5366 | } | |
| 5367 | } | |
| 5368 | ||
| 5369 | ||
| 15884 | 5370 | static void remote_group_done(struct mwPurplePluginData *pd, |
| 10977 | 5371 | const char *id, const char *name) { |
| 15884 | 5372 | PurpleConnection *gc; |
| 5373 | PurpleAccount *acct; | |
| 5374 | PurpleGroup *group; | |
| 5375 | PurpleBlistNode *gn; | |
| 10977 | 5376 | const char *owner; |
| 5377 | ||
| 5378 | g_return_if_fail(pd != NULL); | |
| 5379 | ||
| 5380 | gc = pd->gc; | |
| 15884 | 5381 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5382 | |
| 10977 | 5383 | /* collision checking */ |
| 15884 | 5384 | group = purple_find_group(name); |
| 10977 | 5385 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5386 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5387 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5388 | char *msg; |
| 10977 | 5389 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5390 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5391 | 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
|
5392 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5393 | |
| 15884 | 5394 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5395 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5396 | g_free(msg); |
| 10977 | 5397 | return; |
| 5398 | } | |
| 5399 | ||
| 15884 | 5400 | group = purple_group_new(name); |
| 5401 | gn = (PurpleBlistNode *) group; | |
| 5402 | ||
| 5403 | owner = purple_account_get_username(acct); | |
| 5404 | ||
| 5405 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 5406 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 5407 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 5408 | purple_blist_add_group(group, NULL); | |
| 10977 | 5409 | |
| 5410 | group_add(pd, group); | |
| 5411 | blist_schedule(pd); | |
| 5412 | } | |
| 5413 | ||
| 5414 | ||
| 15884 | 5415 | static void remote_group_multi_cb(struct mwPurplePluginData *pd, |
| 5416 | PurpleRequestFields *fields) { | |
| 5417 | 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
|
5418 | GList *l; |
| 10977 | 5419 | |
| 15884 | 5420 | f = purple_request_fields_get_field(fields, "group"); |
| 5421 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 5422 | |
| 5423 | if(l) { | |
| 5424 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5425 | struct named_id *res; |
| 10977 | 5426 | |
| 15884 | 5427 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5428 | remote_group_done(pd, res->id, res->name); |
| 5429 | } | |
| 5430 | ||
| 5431 | remote_group_multi_cleanup(NULL, fields); | |
| 5432 | } | |
| 5433 | ||
| 5434 | ||
| 5435 | static void remote_group_multi(struct mwResolveResult *result, | |
| 15884 | 5436 | struct mwPurplePluginData *pd) { |
| 5437 | ||
| 5438 | PurpleRequestFields *fields; | |
| 5439 | PurpleRequestFieldGroup *g; | |
| 5440 | PurpleRequestField *f; | |
| 10977 | 5441 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5442 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5443 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5444 | char *msg; |
| 10977 | 5445 | |
| 15884 | 5446 | PurpleConnection *gc = pd->gc; |
| 5447 | ||
| 5448 | fields = purple_request_fields_new(); | |
| 5449 | ||
| 5450 | g = purple_request_field_group_new(NULL); | |
| 5451 | purple_request_fields_add_group(fields, g); | |
| 5452 | ||
| 5453 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 5454 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 5455 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 5456 | |
| 5457 | for(l = result->matches; l; l = l->next) { | |
| 5458 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5459 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 5460 | |
| 5461 | res->id = g_strdup(match->id); | |
| 5462 | res->name = g_strdup(match->name); | |
| 5463 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
5464 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 5465 | } |
| 5466 | ||
| 15884 | 5467 | purple_request_field_group_add_field(g, f); |
| 10977 | 5468 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5469 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5470 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 5471 | " Notes Address Book groups. Please select the correct group from" |
| 5472 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5473 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 5474 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5475 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5476 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5477 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5478 | _("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
|
5479 | purple_connection_get_account(gc), result->name, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5480 | pd); |
| 10977 | 5481 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5482 | g_free(msg); |
| 10977 | 5483 | } |
| 5484 | ||
| 5485 | ||
| 5486 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 5487 | guint32 id, guint32 code, GList *results, | |
| 5488 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5489 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5490 | struct mwResolveResult *res = NULL; |
| 10977 | 5491 | struct mwSession *session; |
| 15884 | 5492 | struct mwPurplePluginData *pd; |
| 5493 | PurpleConnection *gc; | |
| 10977 | 5494 | |
| 5495 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5496 | g_return_if_fail(session != NULL); | |
| 5497 | ||
| 5498 | pd = mwSession_getClientData(session); | |
| 5499 | g_return_if_fail(pd != NULL); | |
| 5500 | ||
| 5501 | gc = pd->gc; | |
| 5502 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5503 | |
| 10977 | 5504 | if(!code && results) { |
| 5505 | res = results->data; | |
| 5506 | ||
| 5507 | if(res->matches) { | |
| 5508 | remote_group_multi(res, pd); | |
| 5509 | return; | |
| 5510 | } | |
| 5511 | } | |
| 5512 | ||
| 5513 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5514 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5515 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5516 | char *msg; |
| 10977 | 5517 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5518 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5519 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5520 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5521 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5522 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5523 | |
| 15884 | 5524 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5525 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5526 | g_free(msg); |
| 10977 | 5527 | } |
| 5528 | } | |
| 5529 | ||
| 5530 | ||
| 15884 | 5531 | static void remote_group_action_cb(PurpleConnection *gc, const char *name) { |
| 5532 | struct mwPurplePluginData *pd; | |
| 10977 | 5533 | struct mwServiceResolve *srvc; |
| 5534 | GList *query; | |
| 5535 | enum mwResolveFlag flags; | |
| 5536 | guint32 req; | |
| 5537 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5538 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5539 | srvc = pd->srvc_resolve; |
| 5540 | ||
| 5541 | query = g_list_prepend(NULL, (char *) name); | |
| 5542 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5543 | |
| 10977 | 5544 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5545 | NULL, NULL); | |
| 5546 | g_list_free(query); | |
| 5547 | ||
| 5548 | if(req == SEARCH_ERROR) { | |
| 5549 | /** @todo display error */ | |
| 5550 | } | |
| 5551 | } | |
| 5552 | ||
| 5553 | ||
| 15884 | 5554 | static void remote_group_action(PurplePluginAction *act) { |
| 5555 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5556 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5557 | const char *msgB; |
| 10977 | 5558 | |
| 5559 | gc = act->context; | |
| 5560 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5561 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5562 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5563 | " to add the group and its members to your buddy list."); |
| 5564 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5565 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5566 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5567 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5568 | _("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
|
5569 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5570 | gc); |
| 10977 | 5571 | } |
| 5572 | ||
| 5573 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5574 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5575 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5576 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5577 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5578 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5579 | char *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5580 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5581 | |
| 15884 | 5582 | PurpleNotifySearchResults *sres; |
| 5583 | PurpleNotifySearchColumn *scol; | |
| 5584 | ||
| 5585 | sres = purple_notify_searchresults_new(); | |
| 5586 | ||
| 5587 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5588 | purple_notify_searchresults_column_add(sres, scol); | |
| 5589 | ||
| 5590 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5591 | purple_notify_searchresults_column_add(sres, scol); | |
| 5592 | ||
| 5593 | 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
|
5594 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5595 | |
| 15884 | 5596 | 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
|
5597 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5598 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5599 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5600 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5601 | GList *row = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5602 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5603 | if(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5604 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5605 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5606 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5607 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5608 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5609 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5610 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5611 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5612 | 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
|
5613 | " 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
|
5614 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5615 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5616 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5617 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5618 | |
| 15884 | 5619 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5620 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5621 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5622 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5623 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5624 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5625 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5626 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5627 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5628 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5629 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5630 | |
| 15884 | 5631 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5632 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5633 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5634 | if(results) res = results->data; |
|
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(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5637 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5638 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5639 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5640 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5641 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5642 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5643 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5644 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5645 | 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
|
5646 | " Sametime community."); |
|
20228
ce019944d765
applied changes from 9d35dde0c779cca73548172223ba557f27d61882
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
5647 | 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
|
5648 | |
| 15884 | 5649 | purple_notify_error(gc, _("No Matches"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5650 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5651 | g_free(msg); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5652 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5653 | } |
|
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 | |
| 15884 | 5656 | static void search_action_cb(PurpleConnection *gc, const char *name) { |
| 5657 | struct mwPurplePluginData *pd; | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5658 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5659 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5660 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5661 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5662 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5663 | pd = purple_connection_get_protocol_data(gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5664 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5665 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5666 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5667 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5668 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5669 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5670 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5671 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5672 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5673 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5674 | /** @todo display error */ |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5675 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5676 | } |
|
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 | |
| 15884 | 5679 | static void search_action(PurplePluginAction *act) { |
| 5680 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5681 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5682 | const char *msgB; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5683 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5684 | gc = act->context; |
|
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 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5687 | 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
|
5688 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5689 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5690 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5691 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5692 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5693 | _("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
|
5694 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5695 | gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5696 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5697 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5698 | |
| 15884 | 5699 | static GList *mw_plugin_actions(PurplePlugin *plugin, gpointer context) { |
| 5700 | PurplePluginAction *act; | |
| 10977 | 5701 | GList *l = NULL; |
| 5702 | ||
| 15884 | 5703 | act = purple_plugin_action_new(_("Import Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5704 | st_import_action); |
| 10977 | 5705 | l = g_list_append(l, act); |
| 5706 | ||
| 15884 | 5707 | act = purple_plugin_action_new(_("Export Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5708 | st_export_action); |
| 10977 | 5709 | l = g_list_append(l, act); |
| 5710 | ||
| 15884 | 5711 | act = purple_plugin_action_new(_("Add Notes Address Book Group..."), |
| 10977 | 5712 | remote_group_action); |
| 5713 | l = g_list_append(l, act); | |
| 5714 | ||
| 15884 | 5715 | act = purple_plugin_action_new(_("User Search..."), |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5716 | search_action); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5717 | l = g_list_append(l, act); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5718 | |
| 10977 | 5719 | return l; |
| 5720 | } | |
| 5721 | ||
| 5722 | ||
| 15884 | 5723 | static gboolean mw_plugin_load(PurplePlugin *plugin) { |
| 10977 | 5724 | return TRUE; |
| 5725 | } | |
| 5726 | ||
| 5727 | ||
| 15884 | 5728 | static gboolean mw_plugin_unload(PurplePlugin *plugin) { |
| 10977 | 5729 | return TRUE; |
| 5730 | } | |
| 5731 | ||
| 5732 | ||
| 15884 | 5733 | static void mw_plugin_destroy(PurplePlugin *plugin) { |
| 10977 | 5734 | g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); |
| 5735 | g_log_remove_handler("meanwhile", log_handler[1]); | |
| 5736 | } | |
| 5737 | ||
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5738 | static PurplePluginInfo mw_plugin_info = |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5739 | { |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5740 | PURPLE_PLUGIN_MAGIC, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5741 | PURPLE_MAJOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5742 | PURPLE_MINOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5743 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5744 | NULL, /**< ui_requirement */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5745 | 0, /**< flags */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5746 | NULL, /**< dependencies */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5747 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5748 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5749 | PLUGIN_ID, /**< id */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5750 | PLUGIN_NAME, /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20228
diff
changeset
|
5751 | DISPLAY_VERSION, /**< version */ |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5752 | PLUGIN_SUMMARY, /**< summary */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5753 | PLUGIN_DESC, /**< description */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5754 | PLUGIN_AUTHOR, /**< author */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5755 | PLUGIN_HOMEPAGE, /**< homepage */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5756 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5757 | mw_plugin_load, /**< load */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5758 | mw_plugin_unload, /**< unload */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5759 | mw_plugin_destroy, /**< destroy */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5760 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5761 | NULL, /**< ui_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5762 | &mw_prpl_info, /**< extra_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5763 | &mw_plugin_ui_info, /**< prefs_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5764 | mw_plugin_actions, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5765 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5766 | /* padding */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5767 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5768 | NULL, |
|
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 |
| 10977 | 5771 | }; |
| 5772 | ||
| 5773 | ||
| 5774 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5775 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5776 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5777 | if(! (msg && *msg)) return; |
| 10977 | 5778 | |
| 15884 | 5779 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5780 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5781 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5782 | |
| 5783 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5784 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5785 | |
| 5786 | } else { | |
| 15884 | 5787 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5788 | } |
| 5789 | } | |
| 5790 | ||
| 5791 | ||
| 15884 | 5792 | static void mw_plugin_init(PurplePlugin *plugin) { |
| 5793 | PurpleAccountOption *opt; | |
| 10977 | 5794 | GList *l = NULL; |
| 5795 | ||
| 5796 | GLogLevelFlags logflags = | |
| 5797 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5798 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5799 | /* set up the preferences */ |
| 15884 | 5800 | purple_prefs_add_none(MW_PRPL_OPT_BASE); |
| 5801 | 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
|
5802 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5803 | /* remove dead preferences */ |
| 15884 | 5804 | purple_prefs_remove(MW_PRPL_OPT_PSYCHIC); |
| 5805 | purple_prefs_remove(MW_PRPL_OPT_SAVE_DYNAMIC); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5806 | |
| 10977 | 5807 | /* host to connect to */ |
| 15884 | 5808 | opt = purple_account_option_string_new(_("Server"), MW_KEY_HOST, |
| 10977 | 5809 | MW_PLUGIN_DEFAULT_HOST); |
| 5810 | l = g_list_append(l, opt); | |
| 5811 | ||
| 5812 | /* port to connect to */ | |
| 15884 | 5813 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
| 10977 | 5814 | MW_PLUGIN_DEFAULT_PORT); |
| 5815 | l = g_list_append(l, opt); | |
| 5816 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5817 | { /* 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
|
5818 | 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
|
5819 | than one account that wants to check for it. */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5820 | gboolean b = FALSE; |
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12422
diff
changeset
|
5821 | const char *label = _("Force login (ignore server redirects)"); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5822 | |
| 15884 | 5823 | if(purple_prefs_exists(MW_PRPL_OPT_FORCE_LOGIN)) |
| 5824 | b = purple_prefs_get_bool(MW_PRPL_OPT_FORCE_LOGIN); | |
| 5825 | ||
| 5826 | 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
|
5827 | l = g_list_append(l, opt); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5828 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5829 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5830 | /* pretend to be Sametime Connect */ |
| 15884 | 5831 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5832 | MW_KEY_FAKE_IT, FALSE); |
|
12312
470a1452d009
[gaim-migrate @ 14616]
Christopher O'Brien <siege@pidgin.im>
parents:
12311
diff
changeset
|
5833 | l = g_list_append(l, opt); |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5834 | |
| 10977 | 5835 | mw_prpl_info.protocol_options = l; |
| 5836 | l = NULL; | |
| 5837 | ||
| 15884 | 5838 | /* forward all our g_log messages to purple. Generally all the logging |
| 5839 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5840 | get caught here */ |
| 5841 | log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags, | |
| 5842 | mw_log_handler, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5843 | |
| 15884 | 5844 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5845 | log_handler[1] = g_log_set_handler("meanwhile", logflags, |
| 5846 | mw_log_handler, NULL); | |
| 5847 | } | |
| 5848 | ||
| 5849 | ||
| 15884 | 5850 | PURPLE_INIT_PLUGIN(sametime, mw_plugin_init, mw_plugin_info); |
| 10977 | 5851 | /* The End. */ |
| 5852 |