Sat, 01 Oct 2011 23:29:40 +0000
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
back a username split that was removed just about forever ago. Fixes #14608.
committer: John Bailey <rekkanoryo@rekkanoryo.org>
| 10977 | 1 | |
| 2 | /* | |
| 15884 | 3 | Meanwhile Protocol Plugin for Purple |
| 4 | Adds Lotus Sametime support to Purple using the Meanwhile library | |
| 10977 | 5 | |
| 6 | Copyright (C) 2004 Christopher (siege) O'Brien <siege@preoccupied.net> | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
7 | |
| 10977 | 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by | |
| 10 | the Free Software Foundation; either version 2 of the License, or (at | |
| 11 | your option) any later version. | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
12 | |
| 10977 | 13 | This program is distributed in the hope that it will be useful, but |
| 14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 16 | General Public License for more details. | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
17 | |
| 10977 | 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19586
diff
changeset
|
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, |
| 10977 | 21 | USA. |
| 22 | */ | |
| 23 | ||
|
28981
4e3922ab4844
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
24 | #include "internal.h" |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
25 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
26 | /* system includes */ |
| 10977 | 27 | #include <stdlib.h> |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
28 | #include <time.h> |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
29 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
30 | /* glib includes */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
31 | #include <glib.h> |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
32 | |
| 15884 | 33 | /* purple includes */ |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
34 | #include "account.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
35 | #include "accountopt.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
36 | #include "circbuffer.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
37 | #include "conversation.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
38 | #include "debug.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
39 | #include "ft.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
40 | #include "imgstore.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
41 | #include "mime.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
42 | #include "notify.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
43 | #include "plugin.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
44 | #include "privacy.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
45 | #include "prpl.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
46 | #include "request.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
47 | #include "util.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
48 | #include "version.h" |
| 10977 | 49 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
50 | /* meanwhile includes */ |
| 10977 | 51 | #include <mw_cipher.h> |
| 52 | #include <mw_common.h> | |
| 53 | #include <mw_error.h> | |
| 54 | #include <mw_service.h> | |
| 55 | #include <mw_session.h> | |
| 56 | #include <mw_srvc_aware.h> | |
| 57 | #include <mw_srvc_conf.h> | |
| 58 | #include <mw_srvc_ft.h> | |
| 59 | #include <mw_srvc_im.h> | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
60 | #include <mw_srvc_place.h> |
| 10977 | 61 | #include <mw_srvc_resolve.h> |
| 62 | #include <mw_srvc_store.h> | |
| 63 | #include <mw_st_list.h> | |
| 64 | ||
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
65 | /* plugin includes */ |
| 10977 | 66 | #include "sametime.h" |
| 67 | ||
| 68 | ||
| 69 | /* considering that there's no display of this information for prpls, | |
| 70 | I don't know why I even bother providing these. Oh valiant reader, | |
| 71 | I do it all for you. */ | |
| 72 | /* scratch that, I just added it to the prpl options panel */ | |
|
14052
861fddc53217
[gaim-migrate @ 16563]
Evan Schoenberg <evands@pidgin.im>
parents:
14032
diff
changeset
|
73 | #define PLUGIN_ID "prpl-meanwhile" |
| 10977 | 74 | #define PLUGIN_NAME "Sametime" |
| 75 | #define PLUGIN_SUMMARY "Sametime Protocol Plugin" | |
| 76 | #define PLUGIN_DESC "Open implementation of a Lotus Sametime client" | |
| 77 | #define PLUGIN_AUTHOR "Christopher (siege) O'Brien <siege@preoccupied.net>" | |
| 78 | #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/" | |
| 79 | ||
| 80 | ||
| 81 | /* plugin preference names */ | |
| 82 | #define MW_PRPL_OPT_BASE "/plugins/prpl/meanwhile" | |
| 83 | #define MW_PRPL_OPT_BLIST_ACTION MW_PRPL_OPT_BASE "/blist_action" | |
| 84 | #define MW_PRPL_OPT_PSYCHIC MW_PRPL_OPT_BASE "/psychic" | |
| 85 | #define MW_PRPL_OPT_FORCE_LOGIN MW_PRPL_OPT_BASE "/force_login" | |
| 86 | #define MW_PRPL_OPT_SAVE_DYNAMIC MW_PRPL_OPT_BASE "/save_dynamic" | |
| 87 | ||
| 88 | ||
| 89 | /* stages of connecting-ness */ | |
|
13779
410869639392
[gaim-migrate @ 16189]
Christopher O'Brien <siege@pidgin.im>
parents:
13713
diff
changeset
|
90 | #define MW_CONNECT_STEPS 11 |
| 10977 | 91 | |
| 92 | ||
| 93 | /* stages of conciousness */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
94 | #define MW_STATE_OFFLINE "offline" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
95 | #define MW_STATE_ACTIVE "active" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
96 | #define MW_STATE_AWAY "away" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
97 | #define MW_STATE_BUSY "dnd" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
98 | #define MW_STATE_MESSAGE "message" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
99 | #define MW_STATE_ENLIGHTENED "buddha" |
| 10977 | 100 | |
| 101 | ||
| 102 | /* keys to get/set chat information */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
103 | #define CHAT_KEY_CREATOR "chat.creator" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
104 | #define CHAT_KEY_NAME "chat.name" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
105 | #define CHAT_KEY_TOPIC "chat.topic" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
106 | #define CHAT_KEY_INVITE "chat.invite" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
107 | #define CHAT_KEY_IS_PLACE "chat.is_place" |
| 10977 | 108 | |
| 109 | ||
| 110 | /* key for associating a mwLoginType with a buddy */ | |
| 111 | #define BUDDY_KEY_CLIENT "meanwhile.client" | |
| 112 | ||
| 113 | /* store the remote alias so that we can re-create it easily */ | |
| 114 | #define BUDDY_KEY_NAME "meanwhile.shortname" | |
| 115 | ||
| 116 | /* enum mwSametimeUserType */ | |
| 117 | #define BUDDY_KEY_TYPE "meanwhile.type" | |
| 118 | ||
| 119 | ||
| 120 | /* key for the real group name for a meanwhile group */ | |
| 121 | #define GROUP_KEY_NAME "meanwhile.group" | |
| 122 | ||
| 123 | /* enum mwSametimeGroupType */ | |
| 124 | #define GROUP_KEY_TYPE "meanwhile.type" | |
| 125 | ||
| 126 | /* NAB group owning account */ | |
| 127 | #define GROUP_KEY_OWNER "meanwhile.account" | |
| 128 | ||
| 129 | /* key gtk blist uses to indicate a collapsed group */ | |
| 130 | #define GROUP_KEY_COLLAPSED "collapsed" | |
| 131 | ||
| 132 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
133 | /* verification replacement */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
134 | #define mwSession_NO_SECRET "meanwhile.no_secret" |
| 10977 | 135 | |
| 136 | ||
| 15884 | 137 | /* keys to get/set purple plugin information */ |
| 10977 | 138 | #define MW_KEY_HOST "server" |
| 139 | #define MW_KEY_PORT "port" | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
140 | #define MW_KEY_FORCE "force_login" |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
141 | #define MW_KEY_FAKE_IT "fake_client_id" |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
142 | #define MW_KEY_CLIENT "client_id_val" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
143 | #define MW_KEY_MAJOR "client_major" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
144 | #define MW_KEY_MINOR "client_minor" |
| 10977 | 145 | |
| 146 | ||
| 147 | /** number of seconds from the first blist change before a save to the | |
| 148 | storage service occurs. */ | |
| 149 | #define BLIST_SAVE_SECONDS 15 | |
| 150 | ||
| 151 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
152 | /** the possible buddy list storage settings */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
153 | enum blist_choice { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
154 | blist_choice_LOCAL = 1, /**< local only */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
155 | blist_choice_MERGE = 2, /**< merge from server */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
156 | blist_choice_STORE = 3, /**< merge from and save to server */ |
|
25105
fe13c190ca13
Remove the commas at the end of enumerator lists. This resolves warnings
Florian Quèze <florian@instantbird.org>
parents:
24816
diff
changeset
|
157 | blist_choice_SYNCH = 4 /**< sync with server */ |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
158 | }; |
| 10977 | 159 | |
| 160 | ||
| 161 | /** the default blist storage option */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
162 | #define BLIST_CHOICE_DEFAULT blist_choice_SYNCH |
| 10977 | 163 | |
| 164 | ||
| 165 | /* testing for the above */ | |
| 15884 | 166 | #define BLIST_PREF_IS(n) (purple_prefs_get_int(MW_PRPL_OPT_BLIST_ACTION)==(n)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
167 | #define BLIST_PREF_IS_LOCAL() BLIST_PREF_IS(blist_choice_LOCAL) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
168 | #define BLIST_PREF_IS_MERGE() BLIST_PREF_IS(blist_choice_MERGE) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
169 | #define BLIST_PREF_IS_STORE() BLIST_PREF_IS(blist_choice_STORE) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
170 | #define BLIST_PREF_IS_SYNCH() BLIST_PREF_IS(blist_choice_SYNCH) |
| 10977 | 171 | |
| 172 | ||
| 173 | /* debugging output */ | |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
174 | #define DEBUG_ERROR(...) purple_debug_error(G_LOG_DOMAIN, __VA_ARGS__) |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
175 | #define DEBUG_INFO(...) purple_debug_info(G_LOG_DOMAIN, __VA_ARGS__) |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
176 | #define DEBUG_MISC(...) purple_debug_misc(G_LOG_DOMAIN, __VA_ARGS__) |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
177 | #define DEBUG_WARN(...) purple_debug_warning(G_LOG_DOMAIN, __VA_ARGS__) |
| 10977 | 178 | |
| 179 | ||
| 180 | /** ensure non-null strings */ | |
| 181 | #ifndef NSTR | |
| 182 | # define NSTR(str) ((str)? (str): "(null)") | |
| 183 | #endif | |
| 184 | ||
| 185 | ||
| 186 | /** calibrates distinct secure channel nomenclature */ | |
| 187 | static const unsigned char no_secret[] = { | |
| 188 | 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65, | |
| 189 | 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a, | |
| 190 | 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64, | |
| 191 | 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00, | |
| 192 | }; | |
| 193 | ||
| 194 | ||
| 195 | /** handler IDs from g_log_set_handler in mw_plugin_init */ | |
| 196 | static guint log_handler[2] = { 0, 0 }; | |
| 197 | ||
| 198 | ||
| 15884 | 199 | /** the purple plugin data. |
| 10977 | 200 | available as gc->proto_data and mwSession_getClientData */ |
| 15884 | 201 | struct mwPurplePluginData { |
| 10977 | 202 | struct mwSession *session; |
| 203 | ||
| 204 | struct mwServiceAware *srvc_aware; | |
| 205 | struct mwServiceConference *srvc_conf; | |
| 206 | struct mwServiceFileTransfer *srvc_ft; | |
| 207 | struct mwServiceIm *srvc_im; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
208 | struct mwServicePlace *srvc_place; |
| 10977 | 209 | struct mwServiceResolve *srvc_resolve; |
| 210 | struct mwServiceStorage *srvc_store; | |
| 211 | ||
| 15884 | 212 | /** map of PurpleGroup:mwAwareList and mwAwareList:PurpleGroup */ |
| 10977 | 213 | GHashTable *group_list_map; |
| 214 | ||
| 215 | /** event id for the buddy list save callback */ | |
| 216 | guint save_event; | |
| 217 | ||
| 218 | /** socket fd */ | |
| 219 | int socket; | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
220 | gint outpa; /* like inpa, but the other way */ |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
221 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
222 | /** circular buffer for outgoing data */ |
| 15884 | 223 | PurpleCircBuffer *sock_buf; |
| 224 | ||
| 225 | PurpleConnection *gc; | |
| 10977 | 226 | }; |
| 227 | ||
| 228 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
229 | typedef struct { |
| 15884 | 230 | PurpleBuddy *buddy; |
| 231 | PurpleGroup *group; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
232 | } BuddyAddData; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
233 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
234 | |
| 10977 | 235 | /* blist and aware functions */ |
| 236 | ||
| 15884 | 237 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist); |
| 238 | ||
| 239 | static void blist_store(struct mwPurplePluginData *pd); | |
| 240 | ||
| 241 | static void blist_schedule(struct mwPurplePluginData *pd); | |
| 242 | ||
| 243 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 244 | ||
| 245 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 246 | ||
| 247 | static gboolean buddy_is_external(PurpleBuddy *b); | |
| 248 | ||
| 249 | static void buddy_add(struct mwPurplePluginData *pd, PurpleBuddy *buddy); | |
| 250 | ||
| 251 | static PurpleBuddy * | |
| 252 | buddy_ensure(PurpleConnection *gc, PurpleGroup *group, | |
| 10977 | 253 | struct mwSametimeUser *stuser); |
| 254 | ||
| 15884 | 255 | static void group_add(struct mwPurplePluginData *pd, PurpleGroup *group); |
| 256 | ||
| 257 | static PurpleGroup * | |
| 258 | group_ensure(PurpleConnection *gc, struct mwSametimeGroup *stgroup); | |
| 10977 | 259 | |
| 260 | static struct mwAwareList * | |
| 15884 | 261 | list_ensure(struct mwPurplePluginData *pd, PurpleGroup *group); |
| 10977 | 262 | |
| 263 | ||
| 264 | /* session functions */ | |
| 265 | ||
| 266 | static struct mwSession * | |
| 15884 | 267 | gc_to_session(PurpleConnection *gc); |
| 268 | ||
| 269 | static PurpleConnection *session_to_gc(struct mwSession *session); | |
| 10977 | 270 | |
| 271 | ||
| 272 | /* conference functions */ | |
| 273 | ||
| 274 | static struct mwConference * | |
| 15884 | 275 | conf_find_by_id(struct mwPurplePluginData *pd, int id); |
| 10977 | 276 | |
| 277 | ||
| 278 | /* conversation functions */ | |
| 279 | ||
| 280 | struct convo_msg { | |
| 281 | enum mwImSendType type; | |
| 282 | gpointer data; | |
| 283 | GDestroyNotify clear; | |
| 284 | }; | |
| 285 | ||
| 286 | ||
| 287 | struct convo_data { | |
| 288 | struct mwConversation *conv; | |
| 289 | GList *queue; /**< outgoing message queue, list of convo_msg */ | |
| 290 | }; | |
| 291 | ||
| 292 | static void convo_data_new(struct mwConversation *conv); | |
| 293 | ||
| 294 | static void convo_data_free(struct convo_data *conv); | |
| 295 | ||
| 296 | static void convo_features(struct mwConversation *conv); | |
| 297 | ||
| 15884 | 298 | static PurpleConversation *convo_get_gconv(struct mwConversation *conv); |
| 10977 | 299 | |
| 300 | ||
|
12629
14aae7d5da6b
[gaim-migrate @ 14965]
Richard Laager <rlaager@pidgin.im>
parents:
12624
diff
changeset
|
301 | /* name and id */ |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
302 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
303 | struct named_id { |
| 10977 | 304 | char *id; |
| 305 | char *name; | |
| 306 | }; | |
| 307 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
308 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
309 | /* connection functions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
310 | |
|
14178
d12b287697c9
[gaim-migrate @ 16750]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
311 | static void connect_cb(gpointer data, gint source, const gchar *error_message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
312 | |
| 10977 | 313 | |
| 314 | /* ----- session ------ */ | |
| 315 | ||
| 316 | ||
| 15884 | 317 | /** resolves a mwSession from a PurpleConnection */ |
| 318 | static struct mwSession *gc_to_session(PurpleConnection *gc) { | |
| 319 | struct mwPurplePluginData *pd; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
320 | |
| 10977 | 321 | g_return_val_if_fail(gc != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
322 | |
| 10977 | 323 | pd = gc->proto_data; |
| 324 | g_return_val_if_fail(pd != NULL, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
325 | |
| 10977 | 326 | return pd->session; |
| 327 | } | |
| 328 | ||
| 329 | ||
| 15884 | 330 | /** resolves a PurpleConnection from a mwSession */ |
| 331 | static PurpleConnection *session_to_gc(struct mwSession *session) { | |
| 332 | struct mwPurplePluginData *pd; | |
| 10977 | 333 | |
| 334 | g_return_val_if_fail(session != NULL, NULL); | |
| 335 | ||
| 336 | pd = mwSession_getClientData(session); | |
| 337 | g_return_val_if_fail(pd != NULL, NULL); | |
| 338 | ||
| 339 | return pd->gc; | |
| 340 | } | |
| 341 | ||
| 342 | ||
| 15884 | 343 | static void write_cb(gpointer data, gint source, PurpleInputCondition cond) { |
| 344 | struct mwPurplePluginData *pd = data; | |
| 345 | PurpleCircBuffer *circ = pd->sock_buf; | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
346 | gsize avail; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
347 | int ret; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
348 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
349 | DEBUG_INFO("write_cb\n"); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
350 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
351 | g_return_if_fail(circ != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
352 | |
| 15884 | 353 | avail = purple_circ_buffer_get_max_read(circ); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
354 | if(BUF_LONG < avail) avail = BUF_LONG; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
355 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
356 | while(avail) { |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
357 | ret = write(pd->socket, circ->outptr, avail); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
358 | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
359 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
360 | break; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
361 | |
| 15884 | 362 | purple_circ_buffer_mark_read(circ, ret); |
| 363 | avail = purple_circ_buffer_get_max_read(circ); | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
364 | if(BUF_LONG < avail) avail = BUF_LONG; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
365 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
366 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
367 | if(! avail) { |
| 15884 | 368 | purple_input_remove(pd->outpa); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
369 | pd->outpa = 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
370 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
371 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
372 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
373 | |
| 10977 | 374 | static int mw_session_io_write(struct mwSession *session, |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
375 | const guchar *buf, gsize len) { |
| 15884 | 376 | struct mwPurplePluginData *pd; |
|
22709
6bd336964410
Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
377 | gssize ret = 0; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
378 | int err = 0; |
| 10977 | 379 | |
| 380 | pd = mwSession_getClientData(session); | |
| 381 | ||
| 382 | /* socket was already closed. */ | |
| 383 | if(pd->socket == 0) | |
| 384 | return 1; | |
| 385 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
386 | if(pd->outpa) { |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
387 | DEBUG_INFO("already pending INPUT_WRITE, buffering\n"); |
| 15884 | 388 | purple_circ_buffer_append(pd->sock_buf, buf, len); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
389 | return 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
390 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
391 | |
| 10977 | 392 | while(len) { |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
393 | ret = write(pd->socket, buf, (len > BUF_LEN)? BUF_LEN: len); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
394 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
395 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
396 | break; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
397 | |
| 10977 | 398 | len -= ret; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
399 | buf += ret; |
| 10977 | 400 | } |
| 401 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
402 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
403 | err = errno; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
404 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
405 | if(err == EAGAIN) { |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
406 | /* append remainder to circular buffer */ |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
407 | DEBUG_INFO("EAGAIN\n"); |
| 15884 | 408 | purple_circ_buffer_append(pd->sock_buf, buf, len); |
| 409 | pd->outpa = purple_input_add(pd->socket, PURPLE_INPUT_WRITE, write_cb, pd); | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
410 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
411 | } else if(len > 0) { |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
412 | gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
413 | g_strerror(errno)); |
|
22709
6bd336964410
Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
414 | DEBUG_ERROR("write returned %" G_GSSIZE_FORMAT ", %" G_GSIZE_FORMAT |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22277
diff
changeset
|
415 | " bytes left unwritten\n", ret, len); |
| 21279 | 416 | purple_connection_error_reason(pd->gc, |
| 417 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
418 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
419 | g_free(tmp); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
420 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
421 | #if 0 |
| 10977 | 422 | close(pd->socket); |
| 423 | pd->socket = 0; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
424 | #endif |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
425 | |
| 10977 | 426 | return -1; |
| 427 | } | |
| 428 | ||
| 429 | return 0; | |
| 430 | } | |
| 431 | ||
| 432 | ||
| 433 | static void mw_session_io_close(struct mwSession *session) { | |
| 15884 | 434 | struct mwPurplePluginData *pd; |
| 435 | PurpleConnection *gc; | |
| 10977 | 436 | |
| 437 | pd = mwSession_getClientData(session); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
438 | g_return_if_fail(pd != NULL); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
439 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
440 | gc = pd->gc; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
441 | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
442 | if(pd->outpa) { |
| 15884 | 443 | purple_input_remove(pd->outpa); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
444 | pd->outpa = 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
445 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
446 | |
| 10977 | 447 | if(pd->socket) { |
| 448 | close(pd->socket); | |
| 449 | pd->socket = 0; | |
| 450 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
451 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
452 | if(gc->inpa) { |
| 15884 | 453 | purple_input_remove(gc->inpa); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
454 | gc->inpa = 0; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
455 | } |
| 10977 | 456 | } |
| 457 | ||
| 458 | ||
| 459 | static void mw_session_clear(struct mwSession *session) { | |
| 460 | ; /* nothing for now */ | |
| 461 | } | |
| 462 | ||
| 463 | ||
| 464 | /* ----- aware list ----- */ | |
| 465 | ||
| 466 | ||
| 467 | static void blist_resolve_alias_cb(struct mwServiceResolve *srvc, | |
| 468 | guint32 id, guint32 code, GList *results, | |
| 469 | gpointer data) { | |
| 470 | struct mwResolveResult *result; | |
| 471 | struct mwResolveMatch *match; | |
| 472 | ||
| 473 | g_return_if_fail(results != NULL); | |
| 474 | ||
| 475 | result = results->data; | |
| 476 | g_return_if_fail(result != NULL); | |
| 477 | g_return_if_fail(result->matches != NULL); | |
| 478 | ||
| 479 | match = result->matches->data; | |
| 480 | g_return_if_fail(match != NULL); | |
| 481 | ||
| 15884 | 482 | purple_blist_server_alias_buddy(data, match->name); |
| 483 | purple_blist_node_set_string(data, BUDDY_KEY_NAME, match->name); | |
| 10977 | 484 | } |
| 485 | ||
| 486 | ||
| 487 | static void mw_aware_list_on_aware(struct mwAwareList *list, | |
| 488 | struct mwAwareSnapshot *aware) { | |
| 489 | ||
| 15884 | 490 | PurpleConnection *gc; |
| 491 | PurpleAccount *acct; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
492 | |
| 15884 | 493 | struct mwPurplePluginData *pd; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
494 | guint32 idle; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
495 | guint stat; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
496 | const char *id; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
497 | const char *status = MW_STATE_ACTIVE; |
| 10977 | 498 | |
| 499 | gc = mwAwareList_getClientData(list); | |
| 15884 | 500 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
501 | |
| 10977 | 502 | pd = gc->proto_data; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
503 | idle = aware->status.time; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
504 | stat = aware->status.status; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
505 | id = aware->id.user; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
506 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
507 | if(idle) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
508 | guint32 idle_len; /*< how long a client has been idle */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
509 | guint32 ugly_idle_len; /*< how long a broken client has been idle */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
510 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
511 | DEBUG_INFO("%s has idle value 0x%x\n", NSTR(id), idle); |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
512 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
513 | idle_len = time(NULL) - idle; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
514 | ugly_idle_len = ((time(NULL) * 1000) - idle) / 1000; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
515 | |
|
25181
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
516 | if(idle > ugly_idle_len) |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
517 | ugly_idle_len = 0; |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
518 | else |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
519 | ugly_idle_len = (ugly_idle_len - idle) / 1000; |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
520 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
521 | /* |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
522 | what's the deal here? Well, good clients are smart enough to |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
523 | publish their idle time by using an attribute to indicate that |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
524 | they went idle at some time UTC, in seconds since epoch. Bad |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
525 | clients use milliseconds since epoch. So we're going to compute |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
526 | the idle time for either method, then figure out the lower of |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
527 | the two and use that. Blame the ST 7.5 development team for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
528 | this. |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
529 | */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
530 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
531 | DEBUG_INFO("idle time: %u, ugly idle time: %u\n", idle_len, ugly_idle_len); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
532 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
533 | #if 1 |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
534 | if(idle_len <= ugly_idle_len) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
535 | ; /* DEBUG_INFO("sane idle value, let's use it\n"); */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
536 | } else { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
537 | idle = time(NULL) - ugly_idle_len; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
538 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
539 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
540 | #else |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
541 | if(idle < 0 || idle > time(NULL)) { |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
542 | DEBUG_INFO("hiding a messy idle value 0x%x\n", NSTR(id), idle); |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
543 | idle = -1; |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
544 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
545 | #endif |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
546 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
547 | |
| 10977 | 548 | switch(stat) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
549 | case mwStatus_ACTIVE: |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
550 | status = MW_STATE_ACTIVE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
551 | idle = 0; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
552 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
553 | |
| 10977 | 554 | case mwStatus_IDLE: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
555 | if(! idle) idle = -1; |
| 10977 | 556 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
557 | |
| 10977 | 558 | case mwStatus_AWAY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
559 | status = MW_STATE_AWAY; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
560 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
561 | |
| 10977 | 562 | case mwStatus_BUSY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
563 | status = MW_STATE_BUSY; |
| 10977 | 564 | break; |
| 565 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
566 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
567 | /* NAB group members */ |
| 10977 | 568 | if(aware->group) { |
| 15884 | 569 | PurpleGroup *group; |
| 570 | PurpleBuddy *buddy; | |
| 571 | PurpleBlistNode *bnode; | |
| 10977 | 572 | |
| 573 | group = g_hash_table_lookup(pd->group_list_map, list); | |
| 15884 | 574 | buddy = purple_find_buddy_in_group(acct, id, group); |
| 575 | bnode = (PurpleBlistNode *) buddy; | |
| 10977 | 576 | |
| 577 | if(! buddy) { | |
| 578 | struct mwServiceResolve *srvc; | |
| 579 | GList *query; | |
| 580 | ||
| 15884 | 581 | buddy = purple_buddy_new(acct, id, NULL); |
| 582 | purple_blist_add_buddy(buddy, NULL, group, NULL); | |
| 583 | ||
| 584 | bnode = (PurpleBlistNode *) buddy; | |
| 10977 | 585 | |
| 586 | srvc = pd->srvc_resolve; | |
| 587 | query = g_list_append(NULL, (char *) id); | |
| 588 | ||
| 589 | mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS, | |
| 590 | blist_resolve_alias_cb, buddy, NULL); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
591 | g_list_free(query); |
| 10977 | 592 | } |
| 593 | ||
| 15884 | 594 | purple_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL); |
| 10977 | 595 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
596 | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
597 | if(aware->online) { |
| 15884 | 598 | purple_prpl_got_user_status(acct, id, status, NULL); |
| 599 | purple_prpl_got_user_idle(acct, id, !!idle, (time_t) idle); | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
600 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
601 | } else { |
| 15884 | 602 | purple_prpl_got_user_status(acct, id, MW_STATE_OFFLINE, NULL); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
603 | } |
| 10977 | 604 | } |
| 605 | ||
| 606 | ||
| 607 | static void mw_aware_list_on_attrib(struct mwAwareList *list, | |
| 608 | struct mwAwareIdBlock *id, | |
| 609 | struct mwAwareAttribute *attrib) { | |
| 610 | ||
| 611 | ; /* nothing. We'll get attribute data as we need it */ | |
| 612 | } | |
| 613 | ||
| 614 | ||
| 615 | static void mw_aware_list_clear(struct mwAwareList *list) { | |
| 616 | ; /* nothing for now */ | |
| 617 | } | |
| 618 | ||
| 619 | ||
| 620 | static struct mwAwareListHandler mw_aware_list_handler = { | |
|
17157
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
621 | mw_aware_list_on_aware, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
622 | mw_aware_list_on_attrib, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
623 | mw_aware_list_clear, |
| 10977 | 624 | }; |
| 625 | ||
| 626 | ||
| 627 | /** Ensures that an Aware List is associated with the given group, and | |
| 628 | returns that list. */ | |
| 629 | static struct mwAwareList * | |
| 15884 | 630 | list_ensure(struct mwPurplePluginData *pd, PurpleGroup *group) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
631 | |
| 10977 | 632 | struct mwAwareList *list; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
633 | |
| 10977 | 634 | g_return_val_if_fail(pd != NULL, NULL); |
| 635 | g_return_val_if_fail(group != NULL, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
636 | |
| 10977 | 637 | list = g_hash_table_lookup(pd->group_list_map, group); |
| 638 | if(! list) { | |
| 639 | list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler); | |
| 640 | mwAwareList_setClientData(list, pd->gc, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
641 | |
| 10977 | 642 | mwAwareList_watchAttributes(list, |
| 643 | mwAttribute_AV_PREFS_SET, | |
| 644 | mwAttribute_MICROPHONE, | |
| 645 | mwAttribute_SPEAKERS, | |
| 646 | mwAttribute_VIDEO_CAMERA, | |
| 647 | mwAttribute_FILE_TRANSFER, | |
| 648 | NULL); | |
| 649 | ||
| 650 | g_hash_table_replace(pd->group_list_map, group, list); | |
| 651 | g_hash_table_insert(pd->group_list_map, list, group); | |
| 652 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
653 | |
| 10977 | 654 | return list; |
| 655 | } | |
| 656 | ||
| 657 | ||
| 15884 | 658 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 10977 | 659 | /* - find the account for this connection |
| 660 | - iterate through the buddy list | |
| 661 | - add each buddy matching this account to the stlist | |
| 662 | */ | |
| 663 | ||
| 15884 | 664 | PurpleAccount *acct; |
| 665 | PurpleBlistNode *gn, *cn, *bn; | |
| 666 | PurpleGroup *grp; | |
| 667 | PurpleBuddy *bdy; | |
| 10977 | 668 | |
| 669 | struct mwSametimeGroup *stg = NULL; | |
| 670 | struct mwIdBlock idb = { NULL, NULL }; | |
| 671 | ||
| 15884 | 672 | acct = purple_connection_get_account(gc); |
| 10977 | 673 | g_return_if_fail(acct != NULL); |
| 674 | ||
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
675 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
676 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 10977 | 677 | const char *owner; |
| 678 | const char *gname; | |
| 679 | enum mwSametimeGroupType gtype; | |
| 680 | gboolean gopen; | |
| 681 | ||
| 15884 | 682 | if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; |
| 683 | grp = (PurpleGroup *) gn; | |
| 10977 | 684 | |
| 685 | /* the group's type (normal or dynamic) */ | |
| 15884 | 686 | gtype = purple_blist_node_get_int(gn, GROUP_KEY_TYPE); |
| 10977 | 687 | if(! gtype) gtype = mwSametimeGroup_NORMAL; |
| 688 | ||
| 689 | /* if it's a normal group with none of our people in it, skip it */ | |
| 15884 | 690 | if(gtype == mwSametimeGroup_NORMAL && !purple_group_on_account(grp, acct)) |
| 10977 | 691 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
692 | |
| 10977 | 693 | /* if the group has an owner and we're not it, skip it */ |
| 15884 | 694 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
| 695 | if(owner && strcmp(owner, purple_account_get_username(acct))) | |
| 10977 | 696 | continue; |
| 697 | ||
| 15884 | 698 | /* the group's actual name may be different from the purple group's |
| 10977 | 699 | name. Find whichever is there */ |
| 15884 | 700 | gname = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
701 | if(! gname) gname = purple_group_get_name(grp); |
| 10977 | 702 | |
| 703 | /* we save this, but never actually honor it */ | |
| 15884 | 704 | gopen = ! purple_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); |
| 10977 | 705 | |
| 706 | stg = mwSametimeGroup_new(stlist, gtype, gname); | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
707 | mwSametimeGroup_setAlias(stg, purple_group_get_name(grp)); |
| 10977 | 708 | mwSametimeGroup_setOpen(stg, gopen); |
| 709 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
710 | /* don't attempt to put buddies in a dynamic group, it breaks |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
711 | other clients */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
712 | if(gtype == mwSametimeGroup_DYNAMIC) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
713 | continue; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
714 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
715 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
716 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
717 | cn = purple_blist_node_get_sibling_next(cn)) { |
| 15884 | 718 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
| 10977 | 719 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
720 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
721 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
722 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 723 | if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; |
| 724 | if(! PURPLE_BLIST_NODE_SHOULD_SAVE(bn)) continue; | |
| 725 | ||
| 726 | bdy = (PurpleBuddy *) bn; | |
| 10977 | 727 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
728 | if(purple_buddy_get_account(bdy) == acct) { |
| 10977 | 729 | struct mwSametimeUser *stu; |
| 730 | enum mwSametimeUserType utype; | |
| 731 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
732 | idb.user = (char *)purple_buddy_get_name(bdy); |
| 10977 | 733 | |
| 15884 | 734 | utype = purple_blist_node_get_int(bn, BUDDY_KEY_TYPE); |
| 10977 | 735 | if(! utype) utype = mwSametimeUser_NORMAL; |
| 736 | ||
| 737 | stu = mwSametimeUser_new(stg, utype, &idb); | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
738 | mwSametimeUser_setShortName(stu, purple_buddy_get_server_alias(bdy)); |
|
24950
143f594f0cd0
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
739 | mwSametimeUser_setAlias(stu, purple_buddy_get_local_buddy_alias(bdy)); |
| 10977 | 740 | } |
| 741 | } | |
| 742 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
743 | } |
| 10977 | 744 | } |
| 745 | ||
| 746 | ||
| 15884 | 747 | static void blist_store(struct mwPurplePluginData *pd) { |
| 10977 | 748 | |
| 749 | struct mwSametimeList *stlist; | |
| 750 | struct mwServiceStorage *srvc; | |
| 751 | struct mwStorageUnit *unit; | |
| 752 | ||
| 15884 | 753 | PurpleConnection *gc; |
| 10977 | 754 | |
| 755 | struct mwPutBuffer *b; | |
| 756 | struct mwOpaque *o; | |
| 757 | ||
| 758 | g_return_if_fail(pd != NULL); | |
| 759 | ||
| 760 | srvc = pd->srvc_store; | |
| 761 | g_return_if_fail(srvc != NULL); | |
| 762 | ||
| 763 | gc = pd->gc; | |
| 764 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
765 | if(BLIST_PREF_IS_LOCAL() || BLIST_PREF_IS_MERGE()) { |
| 10977 | 766 | DEBUG_INFO("preferences indicate not to save remote blist\n"); |
| 767 | return; | |
| 768 | ||
| 769 | } else if(MW_SERVICE_IS_DEAD(srvc)) { | |
| 770 | DEBUG_INFO("aborting save of blist: storage service is not alive\n"); | |
| 771 | return; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
772 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
773 | } else if(BLIST_PREF_IS_STORE() || BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
774 | DEBUG_INFO("saving remote blist\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
775 | |
| 10977 | 776 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
777 | g_return_if_reached(); |
| 10977 | 778 | } |
| 779 | ||
| 780 | /* create and export to a list object */ | |
| 781 | stlist = mwSametimeList_new(); | |
| 782 | blist_export(gc, stlist); | |
| 783 | ||
| 784 | /* write it to a buffer */ | |
| 785 | b = mwPutBuffer_new(); | |
| 786 | mwSametimeList_put(b, stlist); | |
| 787 | mwSametimeList_free(stlist); | |
| 788 | ||
| 789 | /* put the buffer contents into a storage unit */ | |
| 790 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
| 791 | o = mwStorageUnit_asOpaque(unit); | |
| 792 | mwPutBuffer_finalize(o, b); | |
| 793 | ||
| 794 | /* save the storage unit to the service */ | |
| 795 | mwServiceStorage_save(srvc, unit, NULL, NULL, NULL); | |
| 796 | } | |
| 797 | ||
| 798 | ||
| 799 | static gboolean blist_save_cb(gpointer data) { | |
| 15884 | 800 | struct mwPurplePluginData *pd = data; |
| 10977 | 801 | |
| 802 | blist_store(pd); | |
| 803 | pd->save_event = 0; | |
| 804 | return FALSE; | |
| 805 | } | |
| 806 | ||
| 807 | ||
| 808 | /** schedules the buddy list to be saved to the server */ | |
| 15884 | 809 | static void blist_schedule(struct mwPurplePluginData *pd) { |
| 10977 | 810 | if(pd->save_event) return; |
| 811 | ||
|
25716
1b5be208d5ba
applied changes from a336cc1fd3a1ce815f97303b8d5ae8988f8cbd5b
Ethan Blanton <elb@pidgin.im>
parents:
25292
diff
changeset
|
812 | pd->save_event = purple_timeout_add_seconds(BLIST_SAVE_SECONDS, |
| 10977 | 813 | blist_save_cb, pd); |
| 814 | } | |
| 815 | ||
| 816 | ||
| 15884 | 817 | static gboolean buddy_is_external(PurpleBuddy *b) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
818 | g_return_val_if_fail(b != NULL, FALSE); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
819 | return purple_str_has_prefix(purple_buddy_get_name(b), "@E "); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
820 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
821 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
822 | |
| 10977 | 823 | /** Actually add a buddy to the aware service, and schedule the buddy |
| 824 | list to be saved to the server */ | |
| 15884 | 825 | static void buddy_add(struct mwPurplePluginData *pd, |
| 826 | PurpleBuddy *buddy) { | |
| 10977 | 827 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
828 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) purple_buddy_get_name(buddy), NULL }; |
| 10977 | 829 | struct mwAwareList *list; |
| 830 | ||
| 15884 | 831 | PurpleGroup *group; |
| 10977 | 832 | GList *add; |
| 833 | ||
| 834 | add = g_list_prepend(NULL, &idb); | |
| 835 | ||
| 15884 | 836 | group = purple_buddy_get_group(buddy); |
| 10977 | 837 | list = list_ensure(pd, group); |
| 838 | ||
| 839 | if(mwAwareList_addAware(list, add)) { | |
| 15884 | 840 | purple_blist_remove_buddy(buddy); |
| 10977 | 841 | } |
| 842 | ||
| 843 | blist_schedule(pd); | |
| 844 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
845 | g_list_free(add); |
| 10977 | 846 | } |
| 847 | ||
| 848 | ||
| 15884 | 849 | /** ensure that a PurpleBuddy exists in the group with data |
| 10977 | 850 | appropriately matching the st user entry from the st list */ |
| 15884 | 851 | static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, |
| 10977 | 852 | struct mwSametimeUser *stuser) { |
| 853 | ||
| 15884 | 854 | struct mwPurplePluginData *pd = gc->proto_data; |
| 855 | PurpleBuddy *buddy; | |
| 856 | PurpleAccount *acct = purple_connection_get_account(gc); | |
| 10977 | 857 | |
| 858 | const char *id = mwSametimeUser_getUser(stuser); | |
| 859 | const char *name = mwSametimeUser_getShortName(stuser); | |
| 860 | const char *alias = mwSametimeUser_getAlias(stuser); | |
| 861 | enum mwSametimeUserType type = mwSametimeUser_getType(stuser); | |
| 862 | ||
| 863 | g_return_val_if_fail(id != NULL, NULL); | |
| 864 | g_return_val_if_fail(strlen(id) > 0, NULL); | |
| 865 | ||
| 15884 | 866 | buddy = purple_find_buddy_in_group(acct, id, group); |
| 10977 | 867 | if(! buddy) { |
| 15884 | 868 | buddy = purple_buddy_new(acct, id, alias); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
869 | |
| 15884 | 870 | purple_blist_add_buddy(buddy, NULL, group, NULL); |
| 10977 | 871 | buddy_add(pd, buddy); |
| 872 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
873 | |
| 15884 | 874 | purple_blist_alias_buddy(buddy, alias); |
| 875 | purple_blist_server_alias_buddy(buddy, name); | |
| 876 | purple_blist_node_set_string((PurpleBlistNode *) buddy, BUDDY_KEY_NAME, name); | |
| 877 | purple_blist_node_set_int((PurpleBlistNode *) buddy, BUDDY_KEY_TYPE, type); | |
| 10977 | 878 | |
| 879 | return buddy; | |
| 880 | } | |
| 881 | ||
| 882 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
883 | /** add aware watch for a dynamic group */ |
| 15884 | 884 | static void group_add(struct mwPurplePluginData *pd, |
| 885 | PurpleGroup *group) { | |
| 10977 | 886 | |
| 887 | struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL }; | |
| 888 | struct mwAwareList *list; | |
| 889 | const char *n; | |
| 890 | GList *add; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
891 | |
| 15884 | 892 | n = purple_blist_node_get_string((PurpleBlistNode *) group, GROUP_KEY_NAME); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
893 | if(! n) n = purple_group_get_name(group); |
| 10977 | 894 | |
| 895 | idb.user = (char *) n; | |
| 896 | add = g_list_prepend(NULL, &idb); | |
| 897 | ||
| 898 | list = list_ensure(pd, group); | |
| 899 | mwAwareList_addAware(list, add); | |
| 900 | g_list_free(add); | |
| 901 | } | |
| 902 | ||
| 903 | ||
| 15884 | 904 | /** ensure that a PurpleGroup exists in the blist with data |
| 10977 | 905 | appropriately matching the st group entry from the st list */ |
| 15884 | 906 | static PurpleGroup *group_ensure(PurpleConnection *gc, |
| 10977 | 907 | struct mwSametimeGroup *stgroup) { |
| 15884 | 908 | PurpleAccount *acct; |
| 909 | PurpleGroup *group = NULL; | |
| 910 | PurpleBuddyList *blist; | |
| 911 | PurpleBlistNode *gn; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
912 | const char *name, *alias, *owner; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
913 | enum mwSametimeGroupType type; |
| 10977 | 914 | |
| 15884 | 915 | acct = purple_connection_get_account(gc); |
| 916 | owner = purple_account_get_username(acct); | |
| 917 | ||
| 918 | blist = purple_get_blist(); | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
919 | g_return_val_if_fail(blist != NULL, NULL); |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
920 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
921 | name = mwSametimeGroup_getName(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
922 | alias = mwSametimeGroup_getAlias(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
923 | type = mwSametimeGroup_getType(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
924 | |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
925 | if (!name) { |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
926 | DEBUG_WARN("Can't ensure a null group\n"); |
|
31991
efe4fb3772ad
Fix this compile warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
31983
diff
changeset
|
927 | return NULL; |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
928 | } |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
929 | |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
930 | if (!name) { |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
931 | DEBUG_WARN("Can't ensure a null group\n"); |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
932 | return NULL; |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
933 | } |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
934 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
935 | DEBUG_INFO("attempting to ensure group %s, called %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
936 | NSTR(name), NSTR(alias)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
937 | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
938 | /* first attempt at finding the group, by the name key */ |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
939 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
940 | gn = purple_blist_node_get_sibling_next(gn)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
941 | const char *n, *o; |
| 15884 | 942 | if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; |
| 943 | n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); | |
| 944 | o = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
945 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
946 | DEBUG_INFO("found group named %s, owned by %s\n", NSTR(n), NSTR(o)); |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
947 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
948 | if(n && !strcmp(n, name)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
949 | if(!o || !strcmp(o, owner)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
950 | DEBUG_INFO("that'll work\n"); |
| 15884 | 951 | group = (PurpleGroup *) gn; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
952 | break; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
953 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
954 | } |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
955 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
956 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
957 | /* try again, by alias */ |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
958 | if(! group) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
959 | DEBUG_INFO("searching for group by alias %s\n", NSTR(alias)); |
| 15884 | 960 | group = purple_find_group(alias); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
961 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
962 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
963 | /* oh well, no such group. Let's create it! */ |
| 10977 | 964 | if(! group) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
965 | DEBUG_INFO("creating group\n"); |
| 15884 | 966 | group = purple_group_new(alias); |
| 967 | purple_blist_add_group(group, NULL); | |
| 10977 | 968 | } |
| 969 | ||
| 15884 | 970 | gn = (PurpleBlistNode *) group; |
| 971 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); | |
| 972 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | |
| 10977 | 973 | |
| 974 | if(type == mwSametimeGroup_DYNAMIC) { | |
| 15884 | 975 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); |
| 10977 | 976 | group_add(gc->proto_data, group); |
| 977 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
978 | |
| 10977 | 979 | return group; |
| 980 | } | |
| 981 | ||
| 982 | ||
| 15884 | 983 | /** merge the entries from a st list into the purple blist */ |
| 984 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist) { | |
| 10977 | 985 | struct mwSametimeGroup *stgroup; |
| 986 | struct mwSametimeUser *stuser; | |
| 987 | ||
| 15884 | 988 | PurpleGroup *group; |
| 989 | PurpleBuddy *buddy; | |
| 10977 | 990 | |
| 991 | GList *gl, *gtl, *ul, *utl; | |
| 992 | ||
| 993 | gl = gtl = mwSametimeList_getGroups(stlist); | |
| 994 | for(; gl; gl = gl->next) { | |
| 995 | ||
| 996 | stgroup = (struct mwSametimeGroup *) gl->data; | |
| 997 | group = group_ensure(gc, stgroup); | |
| 998 | ||
| 999 | ul = utl = mwSametimeGroup_getUsers(stgroup); | |
| 1000 | for(; ul; ul = ul->next) { | |
| 1001 | ||
| 1002 | stuser = (struct mwSametimeUser *) ul->data; | |
| 1003 | buddy = buddy_ensure(gc, group, stuser); | |
| 1004 | } | |
| 1005 | g_list_free(utl); | |
| 1006 | } | |
| 1007 | g_list_free(gtl); | |
| 1008 | } | |
| 1009 | ||
| 1010 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1011 | /** 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
|
1012 | is left empty, remove group as well */ |
| 15884 | 1013 | static void group_clear(PurpleGroup *group, PurpleAccount *acct, gboolean del) { |
| 1014 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1015 | GList *prune = NULL; |
| 15884 | 1016 | PurpleBlistNode *gn, *cn, *bn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1017 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1018 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1019 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1020 | 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
|
1021 | |
| 15884 | 1022 | gc = purple_account_get_connection(acct); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1023 | g_return_if_fail(gc != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1024 | |
| 15884 | 1025 | gn = (PurpleBlistNode *) group; |
|
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(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1028 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1029 | cn = purple_blist_node_get_sibling_next(cn)) { |
| 15884 | 1030 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1031 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1032 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1033 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1034 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1035 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1036 | ||
| 1037 | if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1038 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1039 | 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
|
1040 | 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
|
1041 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1042 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1043 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1044 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1045 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1046 | /* quickly unsubscribe from presence for the entire group */ |
| 15884 | 1047 | purple_account_remove_group(acct, group); |
|
11943
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 | /* remove blist entries that need to go */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1050 | while(prune) { |
| 15884 | 1051 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1052 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1053 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1054 | DEBUG_INFO("cleared buddies\n"); |
|
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 | /* optionally remove group from blist */ |
| 15884 | 1057 | if(del && !purple_blist_get_group_size(group, TRUE)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1058 | DEBUG_INFO("removing empty group\n"); |
| 15884 | 1059 | purple_blist_remove_group(group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1060 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1061 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1062 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1063 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1064 | /** prune out group members that shouldn't be there */ |
| 15884 | 1065 | static void group_prune(PurpleConnection *gc, PurpleGroup *group, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1066 | struct mwSametimeGroup *stgroup) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1067 | |
| 15884 | 1068 | PurpleAccount *acct; |
| 1069 | PurpleBlistNode *gn, *cn, *bn; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1070 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1071 | GHashTable *stusers; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1072 | GList *prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1073 | GList *ul, *utl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1074 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1075 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1076 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1077 | 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
|
1078 | |
| 15884 | 1079 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1080 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1081 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1082 | 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
|
1083 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1084 | /* 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
|
1085 | contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1086 | utl = mwSametimeGroup_getUsers(stgroup); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1087 | for(ul = utl; ul; ul = ul->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1088 | const char *id = mwSametimeUser_getUser(ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1089 | g_hash_table_insert(stusers, (char *) id, ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1090 | DEBUG_INFO("server copy has %s\n", NSTR(id)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1091 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1092 | g_list_free(utl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1093 | |
| 15884 | 1094 | gn = (PurpleBlistNode *) group; |
|
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(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1097 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1098 | cn = purple_blist_node_get_sibling_next(cn)) { |
| 15884 | 1099 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1100 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1101 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1102 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1103 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1104 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1105 | ||
| 1106 | if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1107 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1108 | /* 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
|
1109 | them for pruning */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1110 | 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
|
1111 | 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
|
1112 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1113 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1114 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1115 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1116 | DEBUG_INFO("done marking\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1117 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1118 | g_hash_table_destroy(stusers); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1119 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1120 | if(prune) { |
| 15884 | 1121 | purple_account_remove_buddies(acct, prune, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1122 | while(prune) { |
| 15884 | 1123 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1124 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1125 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1126 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1127 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1128 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1129 | |
| 15884 | 1130 | /** 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
|
1131 | existing buddies that aren't in the st list */ |
| 15884 | 1132 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 1133 | ||
| 1134 | PurpleAccount *acct; | |
| 1135 | PurpleBuddyList *blist; | |
| 1136 | PurpleBlistNode *gn; | |
|
11943
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 | GHashTable *stgroups; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1139 | GList *g_prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1140 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1141 | GList *gl, *gtl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1142 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1143 | const char *acct_n; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1144 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1145 | DEBUG_INFO("synchronizing local buddy list from server list\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1146 | |
| 15884 | 1147 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1148 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1149 | |
| 15884 | 1150 | acct_n = purple_account_get_username(acct); |
| 1151 | ||
| 1152 | blist = purple_get_blist(); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1153 | g_return_if_fail(blist != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1154 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1155 | /* 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
|
1156 | list, mapping group name to group structure */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1157 | 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
|
1158 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1159 | gtl = mwSametimeList_getGroups(stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1160 | for(gl = gtl; gl; gl = gl->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1161 | const char *name = mwSametimeGroup_getName(gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1162 | g_hash_table_insert(stgroups, (char *) name, gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1163 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1164 | g_list_free(gtl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1165 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1166 | /* 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
|
1167 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1168 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 15884 | 1169 | PurpleGroup *grp = (PurpleGroup *) gn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1170 | const char *gname, *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1171 | struct mwSametimeGroup *stgrp; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1172 | |
| 15884 | 1173 | if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1174 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1175 | /* group not belonging to this account */ |
| 15884 | 1176 | if(! purple_group_on_account(grp, acct)) |
|
11943
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 | /* dynamic group belonging to this account. don't prune contents */ |
| 15884 | 1180 | 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
|
1181 | if(owner && !strcmp(owner, acct_n)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1182 | continue; |
|
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 | /* 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
|
1185 | title, which can be different things in the st list */ |
| 15884 | 1186 | 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
|
1187 | if(! gname) gname = purple_group_get_name(grp); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1188 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1189 | stgrp = g_hash_table_lookup(stgroups, gname); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1190 | if(! stgrp) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1191 | /* remove the whole group */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1192 | 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
|
1193 | g_prune = g_list_prepend(g_prune, grp); |
|
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 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1196 | /* synch the group contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1197 | group_prune(gc, grp, stgrp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1198 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1199 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1200 | DEBUG_INFO("done marking groups\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1201 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1202 | /* don't need this anymore */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1203 | g_hash_table_destroy(stgroups); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1204 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1205 | /* prune all marked groups */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1206 | while(g_prune) { |
| 15884 | 1207 | PurpleGroup *grp = g_prune->data; |
| 1208 | PurpleBlistNode *gn = (PurpleBlistNode *) grp; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1209 | const char *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1210 | gboolean del = TRUE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1211 | |
| 15884 | 1212 | 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
|
1213 | if(owner && strcmp(owner, acct_n)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1214 | /* 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
|
1215 | 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
|
1216 | del = FALSE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1217 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1218 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1219 | group_clear(g_prune->data, acct, del); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1220 | g_prune = g_list_delete_link(g_prune, g_prune); |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1223 | /* done with the pruning, let's merge in the additions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1224 | blist_merge(gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1225 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1226 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1227 | |
| 10977 | 1228 | /** callback passed to the storage service when it's told to load the |
| 1229 | st list */ | |
| 1230 | static void fetch_blist_cb(struct mwServiceStorage *srvc, | |
| 1231 | guint32 result, struct mwStorageUnit *item, | |
| 1232 | gpointer data) { | |
| 1233 | ||
| 15884 | 1234 | struct mwPurplePluginData *pd = data; |
| 10977 | 1235 | struct mwSametimeList *stlist; |
| 1236 | ||
| 1237 | struct mwGetBuffer *b; | |
| 1238 | ||
| 1239 | g_return_if_fail(result == ERR_SUCCESS); | |
| 1240 | ||
| 1241 | /* check our preferences for loading */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1242 | if(BLIST_PREF_IS_LOCAL()) { |
| 10977 | 1243 | DEBUG_INFO("preferences indicate not to load remote buddy list\n"); |
| 1244 | return; | |
| 1245 | } | |
| 1246 | ||
| 1247 | b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); | |
| 1248 | ||
| 1249 | stlist = mwSametimeList_new(); | |
| 1250 | mwSametimeList_get(b, stlist); | |
| 1251 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1252 | /* merge or synch depending on preferences */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1253 | if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1254 | blist_merge(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1255 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1256 | } else if(BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1257 | blist_sync(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1258 | } |
| 10977 | 1259 | |
| 1260 | mwSametimeList_free(stlist); | |
| 22973 | 1261 | mwGetBuffer_free(b); |
| 10977 | 1262 | } |
| 1263 | ||
| 1264 | ||
| 15884 | 1265 | /** signal triggered when a conversation is opened in Purple */ |
| 1266 | static void conversation_created_cb(PurpleConversation *g_conv, | |
| 1267 | struct mwPurplePluginData *pd) { | |
| 10977 | 1268 | |
| 1269 | /* we need to tell the IM service to negotiate features for the | |
| 1270 | conversation right away, otherwise it'll wait until the first | |
| 1271 | message is sent before offering NotesBuddy features. Therefore | |
| 15884 | 1272 | whenever Purple creates a conversation, we'll immediately open the |
| 10977 | 1273 | channel to the other side and figure out what the target can |
| 1274 | handle. Unfortunately, this makes us vulnerable to Psychic Mode, | |
| 1275 | 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
|
1276 | would not */ |
| 10977 | 1277 | |
| 15884 | 1278 | PurpleConnection *gc; |
| 10977 | 1279 | struct mwIdBlock who = { 0, 0 }; |
| 1280 | struct mwConversation *conv; | |
| 1281 | ||
| 15884 | 1282 | gc = purple_conversation_get_gc(g_conv); |
| 10977 | 1283 | if(pd->gc != gc) |
| 1284 | return; /* not ours */ | |
| 1285 | ||
| 15884 | 1286 | if(purple_conversation_get_type(g_conv) != PURPLE_CONV_TYPE_IM) |
| 10977 | 1287 | return; /* wrong type */ |
| 1288 | ||
| 15884 | 1289 | who.user = (char *) purple_conversation_get_name(g_conv); |
| 10977 | 1290 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 1291 | ||
| 1292 | convo_features(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1293 | |
| 10977 | 1294 | if(mwConversation_isClosed(conv)) |
| 1295 | mwConversation_open(conv); | |
| 1296 | } | |
| 1297 | ||
| 1298 | ||
| 15884 | 1299 | static void blist_menu_nab(PurpleBlistNode *node, gpointer data) { |
| 1300 | struct mwPurplePluginData *pd = data; | |
| 1301 | PurpleConnection *gc; | |
| 1302 | ||
| 1303 | PurpleGroup *group = (PurpleGroup *) node; | |
| 10977 | 1304 | |
| 1305 | GString *str; | |
| 1306 | char *tmp; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1307 | const char *gname; |
| 10977 | 1308 | |
| 1309 | g_return_if_fail(pd != NULL); | |
| 1310 | ||
| 1311 | gc = pd->gc; | |
| 1312 | g_return_if_fail(gc != NULL); | |
| 1313 | ||
| 15884 | 1314 | g_return_if_fail(PURPLE_BLIST_NODE_IS_GROUP(node)); |
| 10977 | 1315 | |
| 1316 | str = g_string_new(NULL); | |
| 1317 | ||
| 15884 | 1318 | 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
|
1319 | gname = purple_group_get_name(group); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1320 | |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1321 | 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
|
1322 | 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
|
1323 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1324 | tmp = g_strdup_printf(_("Info for Group %s"), gname); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1325 | |
| 15884 | 1326 | purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
| 10977 | 1327 | NULL, str->str, NULL, NULL); |
| 1328 | ||
| 1329 | g_free(tmp); | |
| 1330 | g_string_free(str, TRUE); | |
| 1331 | } | |
| 1332 | ||
| 1333 | ||
| 1334 | /** The normal blist menu prpl function doesn't get called for groups, | |
| 1335 | so we use the blist-node-extended-menu signal to trigger this | |
| 1336 | handler */ | |
| 15884 | 1337 | static void blist_node_menu_cb(PurpleBlistNode *node, |
| 1338 | GList **menu, struct mwPurplePluginData *pd) { | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1339 | const char *owner; |
| 15884 | 1340 | PurpleGroup *group; |
| 1341 | PurpleAccount *acct; | |
| 1342 | PurpleMenuAction *act; | |
| 10977 | 1343 | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1344 | /* we only want groups */ |
| 15884 | 1345 | if(! PURPLE_BLIST_NODE_IS_GROUP(node)) return; |
| 1346 | group = (PurpleGroup *) node; | |
| 1347 | ||
| 1348 | acct = purple_connection_get_account(pd->gc); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1349 | g_return_if_fail(acct != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1350 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1351 | /* better make sure we're connected */ |
| 15884 | 1352 | if(! purple_account_is_connected(acct)) return; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1353 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1354 | #if 0 |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1355 | /* 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
|
1356 | them all to a conference */ |
| 15884 | 1357 | if(purple_group_on_account(group, acct)) { |
| 1358 | act = purple_menu_action_new(_("Invite Group to Conference..."), | |
| 1359 | PURPLE_CALLBACK(blist_menu_group_invite), | |
| 13021 | 1360 | pd, NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1361 | *menu = g_list_append(*menu, NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1362 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1363 | #endif |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1364 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1365 | /* check if it's a NAB group for this account */ |
| 15884 | 1366 | owner = purple_blist_node_get_string(node, GROUP_KEY_OWNER); |
| 1367 | if(owner && !strcmp(owner, purple_account_get_username(acct))) { | |
| 1368 | act = purple_menu_action_new(_("Get Notes Address Book Info"), | |
| 1369 | PURPLE_CALLBACK(blist_menu_nab), pd, NULL); | |
| 10977 | 1370 | *menu = g_list_append(*menu, act); |
| 1371 | } | |
| 1372 | } | |
| 1373 | ||
| 1374 | ||
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1375 | /* lifted this from oldstatus, since HEAD doesn't do this at login |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1376 | anymore. */ |
| 15884 | 1377 | static void blist_init(PurpleAccount *acct) { |
| 1378 | PurpleBlistNode *gnode, *cnode, *bnode; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1379 | GList *add_buds = NULL; |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1380 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1381 | for(gnode = purple_blist_get_root(); gnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1382 | gnode = purple_blist_node_get_sibling_next(gnode)) { |
| 15884 | 1383 | if(! PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1384 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1385 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1386 | cnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1387 | cnode = purple_blist_node_get_sibling_next(cnode)) { |
| 15884 | 1388 | if(! PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1389 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1390 | for(bnode = purple_blist_node_get_first_child(cnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1391 | bnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1392 | bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 15884 | 1393 | PurpleBuddy *b; |
| 1394 | if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1395 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1396 | |
| 15884 | 1397 | b = (PurpleBuddy *)bnode; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1398 | if(purple_buddy_get_account(b) == acct) { |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1399 | add_buds = g_list_append(add_buds, b); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1400 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1401 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1402 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1403 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1404 | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1405 | if(add_buds) { |
| 15884 | 1406 | purple_account_add_buddies(acct, add_buds); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1407 | g_list_free(add_buds); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1408 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1409 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1410 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1411 | |
| 10977 | 1412 | /** Last thing to happen from a started session */ |
| 15884 | 1413 | static void services_starting(struct mwPurplePluginData *pd) { |
| 1414 | ||
| 1415 | PurpleConnection *gc; | |
| 1416 | PurpleAccount *acct; | |
| 10977 | 1417 | struct mwStorageUnit *unit; |
| 15884 | 1418 | PurpleBlistNode *l; |
| 10977 | 1419 | |
| 1420 | gc = pd->gc; | |
| 15884 | 1421 | acct = purple_connection_get_account(gc); |
| 10977 | 1422 | |
| 1423 | /* grab the buddy list from the server */ | |
| 1424 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1425 | mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
| 10977 | 1426 | |
| 1427 | /* find all the NAB groups and subscribe to them */ | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1428 | for(l = purple_blist_get_root(); l; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1429 | l = purple_blist_node_get_sibling_next(l)) { |
| 15884 | 1430 | PurpleGroup *group = (PurpleGroup *) l; |
| 10977 | 1431 | enum mwSametimeGroupType gt; |
| 1432 | const char *owner; | |
| 1433 | ||
| 15884 | 1434 | if(! PURPLE_BLIST_NODE_IS_GROUP(l)) continue; |
| 10977 | 1435 | |
| 1436 | /* if the group is ownerless, or has an owner and we're not it, | |
| 1437 | skip it */ | |
| 15884 | 1438 | owner = purple_blist_node_get_string(l, GROUP_KEY_OWNER); |
| 1439 | if(!owner || strcmp(owner, purple_account_get_username(acct))) | |
| 10977 | 1440 | continue; |
| 1441 | ||
| 15884 | 1442 | gt = purple_blist_node_get_int(l, GROUP_KEY_TYPE); |
| 10977 | 1443 | if(gt == mwSametimeGroup_DYNAMIC) |
| 1444 | group_add(pd, group); | |
| 1445 | } | |
| 1446 | ||
| 1447 | /* set the aware attributes */ | |
| 1448 | /* indicate we understand what AV prefs are, but don't support any */ | |
| 1449 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1450 | mwAttribute_AV_PREFS_SET, TRUE); | |
| 1451 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE); | |
| 1452 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS); | |
| 1453 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA); | |
| 1454 | ||
| 1455 | /* ... but we can do file transfers! */ | |
| 1456 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1457 | mwAttribute_FILE_TRANSFER, TRUE); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1458 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1459 | blist_init(acct); |
| 10977 | 1460 | } |
| 1461 | ||
| 1462 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1463 | static void session_loginRedirect(struct mwSession *session, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1464 | const char *host) { |
| 15884 | 1465 | struct mwPurplePluginData *pd; |
| 1466 | PurpleConnection *gc; | |
| 1467 | PurpleAccount *account; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1468 | guint port; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1469 | const char *current_host; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1470 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1471 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1472 | gc = pd->gc; |
| 15884 | 1473 | account = purple_connection_get_account(gc); |
| 1474 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); | |
| 1475 | current_host = purple_account_get_string(account, MW_KEY_HOST, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1476 | MW_PLUGIN_DEFAULT_HOST); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1477 | |
| 15884 | 1478 | if(purple_account_get_bool(account, MW_KEY_FORCE, FALSE) || |
|
24739
35f208241e4c
Patch from Raiko Nitzsche to fix a crash when processing a LOGIN_REDIRECT with unexpected output. References #7563.
Daniel Atallah <datallah@pidgin.im>
parents:
24591
diff
changeset
|
1479 | !host || (! strcmp(current_host, host)) || |
|
27343
8a367ee70456
Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents:
26752
diff
changeset
|
1480 | (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1481 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1482 | /* if we're configured to force logins, or if we're being |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1483 | redirected to the already configured host, or if we couldn't |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1484 | connect to the new host, we'll force the login instead */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1485 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1486 | mwSession_forceLogin(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1487 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1488 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1489 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1490 | |
| 15884 | 1491 | 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
|
1492 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1493 | |
| 10977 | 1494 | /** called from mw_session_stateChange when the session's state is |
| 1495 | mwSession_STARTED. Any finalizing of start-up stuff should go | |
| 1496 | here */ | |
| 15884 | 1497 | static void session_started(struct mwPurplePluginData *pd) { |
| 1498 | PurpleStatus *status; | |
| 1499 | PurpleAccount *acct; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1500 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1501 | /* set out initial status */ |
| 15884 | 1502 | acct = purple_connection_get_account(pd->gc); |
| 1503 | status = purple_account_get_active_status(acct); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1504 | mw_prpl_set_status(acct, status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1505 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1506 | /* start watching for new conversations */ |
| 15884 | 1507 | purple_signal_connect(purple_conversations_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1508 | "conversation-created", pd, |
| 15884 | 1509 | PURPLE_CALLBACK(conversation_created_cb), pd); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1510 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1511 | /* watch for group extended menu items */ |
| 15884 | 1512 | purple_signal_connect(purple_blist_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1513 | "blist-node-extended-menu", pd, |
| 15884 | 1514 | PURPLE_CALLBACK(blist_node_menu_cb), pd); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1515 | |
| 10977 | 1516 | /* use our services to do neat things */ |
| 1517 | services_starting(pd); | |
| 1518 | } | |
| 1519 | ||
| 1520 | ||
| 15884 | 1521 | static void session_stopping(struct mwPurplePluginData *pd) { |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1522 | /* stop watching the signals from session_started */ |
| 15884 | 1523 | purple_signals_disconnect_by_handle(pd); |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1524 | } |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1525 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1526 | |
| 10977 | 1527 | static void mw_session_stateChange(struct mwSession *session, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1528 | enum mwSessionState state, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1529 | gpointer info) { |
| 15884 | 1530 | struct mwPurplePluginData *pd; |
| 1531 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1532 | const char *msg = NULL; |
| 10977 | 1533 | |
| 1534 | pd = mwSession_getClientData(session); | |
| 1535 | gc = pd->gc; | |
| 1536 | ||
| 1537 | switch(state) { | |
| 1538 | case mwSession_STARTING: | |
| 1539 | msg = _("Sending Handshake"); | |
| 15884 | 1540 | purple_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS); |
| 10977 | 1541 | break; |
| 1542 | ||
| 1543 | case mwSession_HANDSHAKE: | |
| 1544 | msg = _("Waiting for Handshake Acknowledgement"); | |
| 15884 | 1545 | purple_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS); |
| 10977 | 1546 | break; |
| 1547 | ||
| 1548 | case mwSession_HANDSHAKE_ACK: | |
| 1549 | msg = _("Handshake Acknowledged, Sending Login"); | |
| 15884 | 1550 | purple_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS); |
| 10977 | 1551 | break; |
| 1552 | ||
| 1553 | case mwSession_LOGIN: | |
| 1554 | msg = _("Waiting for Login Acknowledgement"); | |
| 15884 | 1555 | purple_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS); |
| 10977 | 1556 | break; |
| 1557 | ||
| 1558 | case mwSession_LOGIN_REDIR: | |
| 1559 | msg = _("Login Redirected"); | |
| 15884 | 1560 | purple_connection_update_progress(gc, msg, 6, MW_CONNECT_STEPS); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1561 | session_loginRedirect(session, info); |
| 10977 | 1562 | break; |
| 1563 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1564 | case mwSession_LOGIN_CONT: |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1565 | msg = _("Forcing Login"); |
| 15884 | 1566 | purple_connection_update_progress(gc, msg, 7, MW_CONNECT_STEPS); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1567 | |
| 10977 | 1568 | case mwSession_LOGIN_ACK: |
| 1569 | msg = _("Login Acknowledged"); | |
| 15884 | 1570 | purple_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS); |
| 10977 | 1571 | break; |
| 1572 | ||
| 1573 | case mwSession_STARTED: | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1574 | msg = _("Starting Services"); |
| 15884 | 1575 | purple_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS); |
| 10977 | 1576 | |
| 1577 | session_started(pd); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1578 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1579 | msg = _("Connected"); |
| 15884 | 1580 | purple_connection_update_progress(gc, msg, 10, MW_CONNECT_STEPS); |
| 1581 | purple_connection_set_state(gc, PURPLE_CONNECTED); | |
| 10977 | 1582 | break; |
| 1583 | ||
| 1584 | case mwSession_STOPPING: | |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1585 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1586 | session_stopping(pd); |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1587 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1588 | if(GPOINTER_TO_UINT(info) & ERR_FAILURE) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1589 | char *err = mwError(GPOINTER_TO_UINT(info)); |
| 21279 | 1590 | PurpleConnectionError reason; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1591 | switch (GPOINTER_TO_UINT(info)) { |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1592 | case VERSION_MISMATCH: |
| 21279 | 1593 | reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1594 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1595 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1596 | case USER_RESTRICTED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1597 | case INCORRECT_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1598 | case USER_UNREGISTERED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1599 | case GUEST_IN_USE: |
| 21279 | 1600 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1601 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1602 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1603 | case ENCRYPT_MISMATCH: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1604 | case ERR_ENCRYPT_NO_SUPPORT: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1605 | case ERR_NO_COMMON_ENCRYPT: |
| 21279 | 1606 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1607 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1608 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1609 | case VERIFICATION_DOWN: |
| 21279 | 1610 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1611 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1612 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1613 | case MULTI_SERVER_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1614 | case MULTI_SERVER_LOGIN2: |
| 21279 | 1615 | reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1616 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1617 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1618 | default: |
| 21279 | 1619 | reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1620 | } |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1621 | purple_connection_error_reason(gc, reason, err); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1622 | g_free(err); |
| 10977 | 1623 | } |
| 1624 | break; | |
| 1625 | ||
| 1626 | case mwSession_STOPPED: | |
| 1627 | break; | |
| 1628 | ||
| 1629 | case mwSession_UNKNOWN: | |
| 1630 | default: | |
| 1631 | DEBUG_WARN("session in unknown state\n"); | |
| 1632 | } | |
| 1633 | } | |
| 1634 | ||
| 1635 | ||
| 1636 | static void mw_session_setPrivacyInfo(struct mwSession *session) { | |
| 15884 | 1637 | struct mwPurplePluginData *pd; |
| 1638 | PurpleConnection *gc; | |
| 1639 | PurpleAccount *acct; | |
| 10977 | 1640 | struct mwPrivacyInfo *privacy; |
| 1641 | GSList *l, **ll; | |
| 1642 | guint count; | |
| 1643 | ||
| 1644 | DEBUG_INFO("privacy information set from server\n"); | |
| 1645 | ||
| 1646 | g_return_if_fail(session != NULL); | |
| 1647 | ||
| 1648 | pd = mwSession_getClientData(session); | |
| 1649 | g_return_if_fail(pd != NULL); | |
| 1650 | ||
| 1651 | gc = pd->gc; | |
| 1652 | g_return_if_fail(gc != NULL); | |
| 1653 | ||
| 15884 | 1654 | acct = purple_connection_get_account(gc); |
| 10977 | 1655 | g_return_if_fail(acct != NULL); |
| 1656 | ||
| 1657 | privacy = mwSession_getPrivacyInfo(session); | |
| 1658 | count = privacy->count; | |
| 1659 | ||
| 1660 | ll = (privacy->deny)? &acct->deny: &acct->permit; | |
| 1661 | for(l = *ll; l; l = l->next) g_free(l->data); | |
| 1662 | g_slist_free(*ll); | |
| 1663 | l = *ll = NULL; | |
| 1664 | ||
| 1665 | while(count--) { | |
| 1666 | struct mwUserItem *u = privacy->users + count; | |
| 1667 | l = g_slist_prepend(l, g_strdup(u->id)); | |
| 1668 | } | |
| 1669 | *ll = l; | |
| 1670 | } | |
| 1671 | ||
| 1672 | ||
| 1673 | static void mw_session_setUserStatus(struct mwSession *session) { | |
| 15884 | 1674 | struct mwPurplePluginData *pd; |
| 1675 | PurpleConnection *gc; | |
| 10977 | 1676 | struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL }; |
| 1677 | struct mwUserStatus *stat; | |
| 1678 | ||
| 1679 | g_return_if_fail(session != NULL); | |
| 1680 | ||
| 1681 | pd = mwSession_getClientData(session); | |
| 1682 | g_return_if_fail(pd != NULL); | |
| 1683 | ||
| 1684 | gc = pd->gc; | |
| 1685 | g_return_if_fail(gc != NULL); | |
| 1686 | ||
| 1687 | idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); | |
| 1688 | stat = mwSession_getUserStatus(session); | |
| 1689 | ||
| 1690 | /* trigger an update of our own status if we're in the buddy list */ | |
| 1691 | mwServiceAware_setStatus(pd->srvc_aware, &idb, stat); | |
| 1692 | } | |
| 1693 | ||
| 1694 | ||
| 1695 | static void mw_session_admin(struct mwSession *session, | |
| 1696 | const char *text) { | |
| 15884 | 1697 | PurpleConnection *gc; |
| 1698 | PurpleAccount *acct; | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1699 | const char *host; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1700 | const char *msg; |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1701 | char *prim; |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1702 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1703 | gc = session_to_gc(session); |
| 10977 | 1704 | g_return_if_fail(gc != NULL); |
| 1705 | ||
| 15884 | 1706 | acct = purple_connection_get_account(gc); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1707 | g_return_if_fail(acct != NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1708 | |
| 15884 | 1709 | 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
|
1710 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1711 | msg = _("A Sametime administrator has issued the following announcement" |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1712 | " on server %s"); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1713 | prim = g_strdup_printf(msg, NSTR(host)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1714 | |
| 15884 | 1715 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1716 | _("Sametime Administrator Announcement"), |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1717 | prim, text, NULL, NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1718 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1719 | g_free(prim); |
| 10977 | 1720 | } |
| 1721 | ||
| 1722 | ||
| 1723 | /** called from read_cb, attempts to read available data from sock and | |
| 1724 | pass it to the session, passing back the return code from the read | |
| 1725 | call for handling in read_cb */ | |
| 1726 | static int read_recv(struct mwSession *session, int sock) { | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1727 | guchar buf[BUF_LEN]; |
| 10977 | 1728 | int len; |
| 1729 | ||
| 1730 | 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
|
1731 | 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
|
1732 | 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
|
1733 | } |
| 10977 | 1734 | |
| 1735 | return len; | |
| 1736 | } | |
| 1737 | ||
| 1738 | ||
| 15884 | 1739 | /** callback triggered from purple_input_add, watches the socked for |
| 10977 | 1740 | available data to be processed by the session */ |
| 15884 | 1741 | static void read_cb(gpointer data, gint source, PurpleInputCondition cond) { |
| 1742 | struct mwPurplePluginData *pd = data; | |
| 10977 | 1743 | int ret = 0, err = 0; |
| 1744 | ||
| 1745 | g_return_if_fail(pd != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1746 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1747 | ret = read_recv(pd->session, pd->socket); |
| 10977 | 1748 | |
| 1749 | /* normal operation ends here */ | |
| 1750 | if(ret > 0) return; | |
| 1751 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1752 | /* fetch the global error value */ |
| 10977 | 1753 | err = errno; |
| 1754 | ||
| 14754 | 1755 | /* read problem occurred if we're here, so we'll need to take care of |
| 10977 | 1756 | it and clean up internal state */ |
| 1757 | ||
| 1758 | if(pd->socket) { | |
| 1759 | close(pd->socket); | |
| 1760 | pd->socket = 0; | |
| 1761 | } | |
| 1762 | ||
| 1763 | if(pd->gc->inpa) { | |
| 15884 | 1764 | purple_input_remove(pd->gc->inpa); |
| 10977 | 1765 | pd->gc->inpa = 0; |
| 1766 | } | |
| 1767 | ||
| 1768 | if(! ret) { | |
| 1769 | DEBUG_INFO("connection reset\n"); | |
| 21279 | 1770 | purple_connection_error_reason(pd->gc, |
| 1771 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1772 | _("Server closed the connection")); |
| 10977 | 1773 | |
| 1774 | } 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
|
1775 | 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
|
1776 | 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
|
1777 | |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1778 | 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
|
1779 | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1780 | msg = g_strdup_printf(_("Lost connection with server: %s"), err_str); |
| 21279 | 1781 | purple_connection_error_reason(pd->gc, |
| 1782 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
| 1783 | msg); | |
| 10977 | 1784 | g_free(msg); |
| 1785 | } | |
| 1786 | } | |
| 1787 | ||
| 1788 | ||
| 15884 | 1789 | /** Callback passed to purple_proxy_connect when an account is logged |
| 10977 | 1790 | 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
|
1791 | static void connect_cb(gpointer data, gint source, const gchar *error_message) { |
| 10977 | 1792 | |
| 15884 | 1793 | struct mwPurplePluginData *pd = data; |
| 1794 | PurpleConnection *gc = pd->gc; | |
| 10977 | 1795 | |
| 1796 | if(source < 0) { | |
| 1797 | /* connection failed */ | |
| 1798 | ||
| 1799 | if(pd->socket) { | |
| 1800 | /* this is a redirect connect, force login on existing socket */ | |
| 1801 | mwSession_forceLogin(pd->session); | |
| 1802 | ||
| 1803 | } else { | |
| 1804 | /* this is a regular connect, error out */ | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1805 | 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
|
1806 | error_message); |
| 21279 | 1807 | purple_connection_error_reason(pd->gc, |
| 1808 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1809 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1810 | g_free(tmp); |
| 10977 | 1811 | } |
| 1812 | ||
| 1813 | return; | |
| 1814 | } | |
| 1815 | ||
| 1816 | if(pd->socket) { | |
| 1817 | /* stop any existing login attempt */ | |
| 1818 | mwSession_stop(pd->session, ERR_SUCCESS); | |
| 1819 | } | |
| 1820 | ||
| 1821 | pd->socket = source; | |
| 15884 | 1822 | gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
1823 | read_cb, pd); |
| 10977 | 1824 | |
| 1825 | mwSession_start(pd->session); | |
| 1826 | } | |
| 1827 | ||
| 1828 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1829 | static void mw_session_announce(struct mwSession *s, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1830 | struct mwLoginInfo *from, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1831 | gboolean may_reply, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1832 | const char *text) { |
| 15884 | 1833 | struct mwPurplePluginData *pd; |
| 1834 | PurpleAccount *acct; | |
| 1835 | PurpleConversation *conv; | |
| 1836 | PurpleBuddy *buddy; | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1837 | char *who = from->user_id; |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1838 | char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1839 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1840 | pd = mwSession_getClientData(s); |
| 15884 | 1841 | acct = purple_connection_get_account(pd->gc); |
| 1842 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, acct); | |
| 1843 | if(! conv) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, who); | |
| 1844 | ||
| 1845 | buddy = purple_find_buddy(acct, who); | |
| 1846 | 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
|
1847 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1848 | who = g_strdup_printf(_("Announcement from %s"), who); |
| 15884 | 1849 | msg = purple_markup_linkify(text); |
| 1850 | ||
|
23979
936d7ef5cece
Add NULL checking to purple_markup_linkify().
Daniel Atallah <datallah@pidgin.im>
parents:
22973
diff
changeset
|
1851 | 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
|
1852 | g_free(who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1853 | g_free(msg); |
| 10977 | 1854 | } |
| 1855 | ||
| 1856 | ||
| 1857 | static struct mwSessionHandler mw_session_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1858 | mw_session_io_write, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1859 | mw_session_io_close, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1860 | mw_session_clear, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1861 | mw_session_stateChange, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1862 | mw_session_setPrivacyInfo, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1863 | mw_session_setUserStatus, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1864 | mw_session_admin, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1865 | mw_session_announce, |
| 10977 | 1866 | }; |
| 1867 | ||
| 1868 | ||
| 1869 | static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
| 1870 | struct mwAwareAttribute *attrib) { | |
| 1871 | ||
| 1872 | ; /** @todo handle server attributes. There may be some stuff we | |
| 1873 | actually want to look for, but I'm not aware of anything right | |
| 1874 | now.*/ | |
| 1875 | } | |
| 1876 | ||
| 1877 | ||
| 1878 | static void mw_aware_clear(struct mwServiceAware *srvc) { | |
| 1879 | ; /* nothing for now */ | |
| 1880 | } | |
| 1881 | ||
| 1882 | ||
| 1883 | static struct mwAwareHandler mw_aware_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1884 | mw_aware_on_attrib, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1885 | mw_aware_clear, |
| 10977 | 1886 | }; |
| 1887 | ||
| 1888 | ||
| 1889 | static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
| 1890 | struct mwServiceAware *srvc; | |
| 1891 | srvc = mwServiceAware_new(s, &mw_aware_handler); | |
| 1892 | return srvc; | |
| 1893 | }; | |
| 1894 | ||
| 1895 | ||
| 1896 | static void mw_conf_invited(struct mwConference *conf, | |
| 1897 | struct mwLoginInfo *inviter, | |
| 1898 | const char *invitation) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1899 | |
| 10977 | 1900 | struct mwServiceConference *srvc; |
| 1901 | struct mwSession *session; | |
| 15884 | 1902 | struct mwPurplePluginData *pd; |
| 1903 | PurpleConnection *gc; | |
| 10977 | 1904 | |
| 1905 | char *c_inviter, *c_name, *c_topic, *c_invitation; | |
| 1906 | GHashTable *ht; | |
| 1907 | ||
| 1908 | srvc = mwConference_getService(conf); | |
| 1909 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1910 | pd = mwSession_getClientData(session); | |
| 1911 | gc = pd->gc; | |
| 1912 | ||
| 1913 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1914 | ||
| 1915 | c_inviter = g_strdup(inviter->user_id); | |
| 1916 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
| 1917 | ||
| 1918 | c_name = g_strdup(mwConference_getName(conf)); | |
| 1919 | g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
| 1920 | ||
| 1921 | c_topic = g_strdup(mwConference_getTitle(conf)); | |
| 1922 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
| 1923 | ||
| 1924 | c_invitation = g_strdup(invitation); | |
| 1925 | g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
| 1926 | ||
| 1927 | DEBUG_INFO("received invitation from '%s' to join ('%s','%s'): '%s'\n", | |
| 1928 | NSTR(c_inviter), NSTR(c_name), | |
| 1929 | NSTR(c_topic), NSTR(c_invitation)); | |
| 1930 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1931 | if(! c_topic) c_topic = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1932 | if(! c_invitation) c_invitation = "(no message)"; |
| 10977 | 1933 | serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
| 1934 | } | |
| 1935 | ||
| 1936 | ||
| 15884 | 1937 | /* The following mess helps us relate a mwConference to a PurpleConvChat |
| 10977 | 1938 | in the various forms by which either may be indicated */ |
| 1939 | ||
| 1940 | #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
| 1941 | #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
| 1942 | ||
| 15884 | 1943 | #define CHAT_TO_ID(chat) (purple_conv_chat_get_id(chat)) |
| 1944 | #define ID_TO_CHAT(id) (purple_find_chat(id)) | |
| 10977 | 1945 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1946 | #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
|
1947 | #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
| 10977 | 1948 | |
| 1949 | ||
| 1950 | static struct mwConference * | |
| 15884 | 1951 | conf_find_by_id(struct mwPurplePluginData *pd, int id) { |
| 10977 | 1952 | |
| 1953 | struct mwServiceConference *srvc = pd->srvc_conf; | |
| 1954 | struct mwConference *conf = NULL; | |
| 1955 | GList *l, *ll; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1956 | |
| 10977 | 1957 | ll = mwServiceConference_getConferences(srvc); |
| 1958 | for(l = ll; l; l = l->next) { | |
| 1959 | struct mwConference *c = l->data; | |
| 15884 | 1960 | PurpleConvChat *h = mwConference_getClientData(c); |
| 10977 | 1961 | |
| 1962 | if(CHAT_TO_ID(h) == id) { | |
| 1963 | conf = c; | |
| 1964 | break; | |
| 1965 | } | |
| 1966 | } | |
| 1967 | g_list_free(ll); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1968 | |
| 10977 | 1969 | return conf; |
| 1970 | } | |
| 1971 | ||
| 1972 | ||
| 1973 | static void mw_conf_opened(struct mwConference *conf, GList *members) { | |
| 1974 | struct mwServiceConference *srvc; | |
| 1975 | struct mwSession *session; | |
| 15884 | 1976 | struct mwPurplePluginData *pd; |
| 1977 | PurpleConnection *gc; | |
| 1978 | PurpleConversation *g_conf; | |
| 10977 | 1979 | |
| 1980 | const char *n = mwConference_getName(conf); | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1981 | const char *t = mwConference_getTitle(conf); |
| 10977 | 1982 | |
| 1983 | DEBUG_INFO("conf %s opened, %u initial members\n", | |
| 1984 | NSTR(n), g_list_length(members)); | |
| 1985 | ||
| 1986 | srvc = mwConference_getService(conf); | |
| 1987 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1988 | pd = mwSession_getClientData(session); | |
| 1989 | gc = pd->gc; | |
| 1990 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1991 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1992 | g_conf = serv_got_joined_chat(gc, CONF_TO_ID(conf), t); |
| 10977 | 1993 | |
| 15884 | 1994 | mwConference_setClientData(conf, PURPLE_CONV_CHAT(g_conf), NULL); |
| 10977 | 1995 | |
| 1996 | for(; members; members = members->next) { | |
| 1997 | struct mwLoginInfo *peer = members->data; | |
| 15884 | 1998 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(g_conf), peer->user_id, |
| 1999 | NULL, PURPLE_CBFLAGS_NONE, FALSE); | |
| 10977 | 2000 | } |
| 2001 | } | |
| 2002 | ||
| 2003 | ||
| 2004 | static void mw_conf_closed(struct mwConference *conf, guint32 reason) { | |
| 2005 | struct mwServiceConference *srvc; | |
| 2006 | struct mwSession *session; | |
| 15884 | 2007 | struct mwPurplePluginData *pd; |
| 2008 | PurpleConnection *gc; | |
| 10977 | 2009 | |
| 2010 | const char *n = mwConference_getName(conf); | |
| 2011 | char *msg = mwError(reason); | |
| 2012 | ||
| 2013 | DEBUG_INFO("conf %s closed, 0x%08x\n", NSTR(n), reason); | |
| 2014 | ||
| 2015 | srvc = mwConference_getService(conf); | |
| 2016 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2017 | pd = mwSession_getClientData(session); | |
| 2018 | gc = pd->gc; | |
| 2019 | ||
| 2020 | serv_got_chat_left(gc, CONF_TO_ID(conf)); | |
| 2021 | ||
| 15884 | 2022 | purple_notify_error(gc, _("Conference Closed"), NULL, msg); |
| 10977 | 2023 | g_free(msg); |
| 2024 | } | |
| 2025 | ||
| 2026 | ||
| 2027 | static void mw_conf_peer_joined(struct mwConference *conf, | |
| 2028 | struct mwLoginInfo *peer) { | |
| 2029 | ||
| 2030 | struct mwServiceConference *srvc; | |
| 2031 | struct mwSession *session; | |
| 15884 | 2032 | struct mwPurplePluginData *pd; |
| 2033 | PurpleConnection *gc; | |
| 2034 | PurpleConvChat *g_conf; | |
| 10977 | 2035 | |
| 2036 | const char *n = mwConference_getName(conf); | |
| 2037 | ||
| 2038 | DEBUG_INFO("%s joined conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2039 | ||
| 2040 | srvc = mwConference_getService(conf); | |
| 2041 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2042 | pd = mwSession_getClientData(session); | |
| 2043 | gc = pd->gc; | |
| 2044 | ||
| 2045 | g_conf = mwConference_getClientData(conf); | |
| 2046 | g_return_if_fail(g_conf != NULL); | |
| 2047 | ||
| 15884 | 2048 | purple_conv_chat_add_user(g_conf, peer->user_id, |
| 2049 | NULL, PURPLE_CBFLAGS_NONE, TRUE); | |
| 10977 | 2050 | } |
| 2051 | ||
| 2052 | ||
| 2053 | static void mw_conf_peer_parted(struct mwConference *conf, | |
| 2054 | struct mwLoginInfo *peer) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2055 | |
| 10977 | 2056 | struct mwServiceConference *srvc; |
| 2057 | struct mwSession *session; | |
| 15884 | 2058 | struct mwPurplePluginData *pd; |
| 2059 | PurpleConnection *gc; | |
| 2060 | PurpleConvChat *g_conf; | |
| 10977 | 2061 | |
| 2062 | const char *n = mwConference_getName(conf); | |
| 2063 | ||
| 2064 | DEBUG_INFO("%s left conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2065 | ||
| 2066 | srvc = mwConference_getService(conf); | |
| 2067 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2068 | pd = mwSession_getClientData(session); | |
| 2069 | gc = pd->gc; | |
| 2070 | ||
| 2071 | g_conf = mwConference_getClientData(conf); | |
| 2072 | g_return_if_fail(g_conf != NULL); | |
| 2073 | ||
| 15884 | 2074 | purple_conv_chat_remove_user(g_conf, peer->user_id, NULL); |
| 10977 | 2075 | } |
| 2076 | ||
| 2077 | ||
| 2078 | static void mw_conf_text(struct mwConference *conf, | |
| 2079 | struct mwLoginInfo *who, const char *text) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2080 | |
| 10977 | 2081 | struct mwServiceConference *srvc; |
| 2082 | struct mwSession *session; | |
| 15884 | 2083 | struct mwPurplePluginData *pd; |
| 2084 | PurpleConnection *gc; | |
| 10977 | 2085 | char *esc; |
| 2086 | ||
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2087 | if(! text) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2088 | |
| 10977 | 2089 | srvc = mwConference_getService(conf); |
| 2090 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2091 | pd = mwSession_getClientData(session); | |
| 2092 | gc = pd->gc; | |
| 2093 | ||
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2094 | esc = g_markup_escape_text(text, -1); |
| 10977 | 2095 | serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, 0, esc, time(NULL)); |
| 2096 | g_free(esc); | |
| 2097 | } | |
| 2098 | ||
| 2099 | ||
| 2100 | static void mw_conf_typing(struct mwConference *conf, | |
| 2101 | struct mwLoginInfo *who, gboolean typing) { | |
| 2102 | ||
| 15884 | 2103 | /* purple really has no good way to expose this to the user. */ |
| 10977 | 2104 | |
| 2105 | const char *n = mwConference_getName(conf); | |
| 2106 | const char *w = who->user_id; | |
| 2107 | ||
| 2108 | if(typing) { | |
| 2109 | DEBUG_INFO("%s in conf %s: <typing>\n", NSTR(w), NSTR(n)); | |
| 2110 | ||
| 2111 | } else { | |
| 2112 | DEBUG_INFO("%s in conf %s: <stopped typing>\n", NSTR(w), NSTR(n)); | |
| 2113 | } | |
| 2114 | } | |
| 2115 | ||
| 2116 | ||
| 2117 | static void mw_conf_clear(struct mwServiceConference *srvc) { | |
| 2118 | ; | |
| 2119 | } | |
| 2120 | ||
| 2121 | ||
| 2122 | static struct mwConferenceHandler mw_conference_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2123 | mw_conf_invited, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2124 | mw_conf_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2125 | mw_conf_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2126 | mw_conf_peer_joined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2127 | mw_conf_peer_parted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2128 | mw_conf_text, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2129 | mw_conf_typing, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2130 | mw_conf_clear, |
| 10977 | 2131 | }; |
| 2132 | ||
| 2133 | ||
| 2134 | static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) { | |
| 2135 | struct mwServiceConference *srvc; | |
| 2136 | srvc = mwServiceConference_new(s, &mw_conference_handler); | |
| 2137 | return srvc; | |
| 2138 | } | |
| 2139 | ||
| 2140 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2141 | /** size of an outgoing file transfer chunk */ |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2142 | #define MW_FT_LEN (BUF_LONG * 2) |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2143 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2144 | |
| 15884 | 2145 | static void ft_incoming_cancel(PurpleXfer *xfer) { |
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29304
diff
changeset
|
2146 | /* incoming transfer rejected or cancelled in-progress */ |
| 10977 | 2147 | struct mwFileTransfer *ft = xfer->data; |
| 2148 | if(ft) mwFileTransfer_reject(ft); | |
| 2149 | } | |
| 2150 | ||
| 2151 | ||
| 15884 | 2152 | static void ft_incoming_init(PurpleXfer *xfer) { |
| 10977 | 2153 | /* incoming transfer accepted */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2154 | |
| 10977 | 2155 | /* - accept the mwFileTransfer |
| 2156 | - open/create the local FILE "wb" | |
| 2157 | - stick the FILE's fp in xfer->dest_fp | |
| 2158 | */ | |
| 2159 | ||
| 2160 | struct mwFileTransfer *ft; | |
| 2161 | FILE *fp; | |
| 2162 | ||
| 2163 | ft = xfer->data; | |
| 2164 | ||
| 2165 | fp = g_fopen(xfer->local_filename, "wb"); | |
| 2166 | if(! fp) { | |
| 2167 | mwFileTransfer_cancel(ft); | |
| 2168 | return; | |
| 2169 | } | |
| 2170 | ||
| 2171 | xfer->dest_fp = fp; | |
| 2172 | mwFileTransfer_accept(ft); | |
| 2173 | } | |
| 2174 | ||
| 2175 | ||
| 2176 | static void mw_ft_offered(struct mwFileTransfer *ft) { | |
| 2177 | /* | |
| 15884 | 2178 | - create a purple ft object |
| 10977 | 2179 | - offer it |
| 2180 | */ | |
| 2181 | ||
| 2182 | struct mwServiceFileTransfer *srvc; | |
| 2183 | struct mwSession *session; | |
| 15884 | 2184 | struct mwPurplePluginData *pd; |
| 2185 | PurpleConnection *gc; | |
| 2186 | PurpleAccount *acct; | |
| 10977 | 2187 | const char *who; |
| 15884 | 2188 | PurpleXfer *xfer; |
| 10977 | 2189 | |
| 2190 | /* @todo add some safety checks */ | |
| 2191 | srvc = mwFileTransfer_getService(ft); | |
| 2192 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2193 | pd = mwSession_getClientData(session); | |
| 2194 | gc = pd->gc; | |
| 15884 | 2195 | acct = purple_connection_get_account(gc); |
| 10977 | 2196 | |
| 2197 | who = mwFileTransfer_getUser(ft)->user; | |
| 2198 | ||
| 2199 | DEBUG_INFO("file transfer %p offered\n", ft); | |
| 2200 | DEBUG_INFO(" from: %s\n", NSTR(who)); | |
| 2201 | DEBUG_INFO(" file: %s\n", NSTR(mwFileTransfer_getFileName(ft))); | |
| 2202 | DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft)); | |
| 2203 | DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft))); | |
| 2204 | ||
| 15884 | 2205 | xfer = purple_xfer_new(acct, PURPLE_XFER_RECEIVE, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2206 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2207 | { |
| 15884 | 2208 | purple_xfer_ref(xfer); |
| 2209 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2210 | xfer->data = ft; |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2211 | |
| 15884 | 2212 | purple_xfer_set_init_fnc(xfer, ft_incoming_init); |
| 2213 | purple_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); | |
| 2214 | purple_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); | |
| 2215 | ||
| 2216 | purple_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); | |
| 2217 | purple_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); | |
| 2218 | purple_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); | |
| 2219 | ||
| 2220 | purple_xfer_request(xfer); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2221 | } |
| 10977 | 2222 | } |
| 2223 | ||
| 2224 | ||
| 2225 | static void ft_send(struct mwFileTransfer *ft, FILE *fp) { | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2226 | guchar buf[MW_FT_LEN]; |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
2227 | struct mwOpaque o = { MW_FT_LEN, buf }; |
| 10977 | 2228 | guint32 rem; |
| 15884 | 2229 | PurpleXfer *xfer; |
| 10977 | 2230 | |
| 2231 | xfer = mwFileTransfer_getClientData(ft); | |
| 2232 | ||
| 2233 | rem = mwFileTransfer_getRemaining(ft); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2234 | if(rem < MW_FT_LEN) o.len = rem; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2235 | |
| 10977 | 2236 | if(fread(buf, (size_t) o.len, 1, fp)) { |
| 2237 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2238 | /* calculate progress and display it */ |
| 10977 | 2239 | xfer->bytes_sent += o.len; |
| 2240 | xfer->bytes_remaining -= o.len; | |
| 15884 | 2241 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2242 | |
| 10977 | 2243 | mwFileTransfer_send(ft, &o); |
| 2244 | ||
| 2245 | } else { | |
| 2246 | int err = errno; | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2247 | 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
|
2248 | NSTR(mwFileTransfer_getFileName(ft)), g_strerror(err)); |
| 10977 | 2249 | |
| 2250 | mwFileTransfer_cancel(ft); | |
| 2251 | } | |
| 2252 | } | |
| 2253 | ||
| 2254 | ||
| 2255 | static void mw_ft_opened(struct mwFileTransfer *ft) { | |
| 2256 | /* | |
| 15884 | 2257 | - get purple ft from client data in ft |
| 10977 | 2258 | - set the state to active |
| 2259 | */ | |
| 2260 | ||
| 15884 | 2261 | PurpleXfer *xfer; |
| 10977 | 2262 | |
| 2263 | xfer = mwFileTransfer_getClientData(ft); | |
| 2264 | ||
| 2265 | if(! xfer) { | |
| 2266 | mwFileTransfer_cancel(ft); | |
| 2267 | mwFileTransfer_free(ft); | |
| 2268 | g_return_if_reached(); | |
| 2269 | } | |
| 2270 | ||
| 15884 | 2271 | if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
| 10977 | 2272 | xfer->dest_fp = g_fopen(xfer->local_filename, "rb"); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2273 | ft_send(ft, xfer->dest_fp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2274 | } |
| 10977 | 2275 | } |
| 2276 | ||
| 2277 | ||
| 2278 | static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
| 2279 | /* | |
| 15884 | 2280 | - get purple ft from client data in ft |
| 10977 | 2281 | - indicate rejection/cancelation/completion |
| 2282 | - free the file transfer itself | |
| 2283 | */ | |
| 2284 | ||
| 15884 | 2285 | PurpleXfer *xfer; |
| 10977 | 2286 | |
| 2287 | xfer = mwFileTransfer_getClientData(ft); | |
| 2288 | if(xfer) { | |
| 2289 | xfer->data = NULL; | |
| 2290 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2291 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2292 | purple_xfer_set_completed(xfer, TRUE); |
| 2293 | purple_xfer_end(xfer); | |
| 10977 | 2294 | |
| 2295 | } else if(mwFileTransfer_isCancelLocal(ft)) { | |
| 15884 | 2296 | /* calling purple_xfer_cancel_local is redundant, since that's |
| 10977 | 2297 | probably what triggered this function to be called */ |
| 2298 | ; | |
| 2299 | ||
| 2300 | } else if(mwFileTransfer_isCancelRemote(ft)) { | |
| 2301 | /* steal the reference for the xfer */ | |
| 2302 | mwFileTransfer_setClientData(ft, NULL, NULL); | |
| 15884 | 2303 | purple_xfer_cancel_remote(xfer); |
| 10977 | 2304 | |
| 2305 | /* drop the stolen reference */ | |
| 15884 | 2306 | purple_xfer_unref(xfer); |
| 10977 | 2307 | return; |
| 2308 | } | |
| 2309 | } | |
| 2310 | ||
| 2311 | mwFileTransfer_free(ft); | |
| 2312 | } | |
| 2313 | ||
| 2314 | ||
| 2315 | static void mw_ft_recv(struct mwFileTransfer *ft, | |
| 2316 | struct mwOpaque *data) { | |
| 2317 | /* | |
| 15884 | 2318 | - get purple ft from client data in ft |
| 10977 | 2319 | - update transfered percentage |
| 15884 | 2320 | - if done, destroy the ft, disassociate from purple ft |
| 10977 | 2321 | */ |
| 2322 | ||
| 15884 | 2323 | PurpleXfer *xfer; |
| 10977 | 2324 | 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
|
2325 | size_t wc; |
| 10977 | 2326 | |
| 2327 | xfer = mwFileTransfer_getClientData(ft); | |
| 2328 | g_return_if_fail(xfer != NULL); | |
| 2329 | ||
| 2330 | fp = xfer->dest_fp; | |
| 2331 | g_return_if_fail(fp != NULL); | |
| 2332 | ||
| 2333 | /* 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
|
2334 | 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
|
2335 | 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
|
2336 | 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
|
2337 | 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
|
2338 | return; |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2339 | } |
| 10977 | 2340 | |
| 2341 | /* update the progress */ | |
| 2342 | xfer->bytes_sent += data->len; | |
| 2343 | xfer->bytes_remaining -= data->len; | |
| 15884 | 2344 | purple_xfer_update_progress(xfer); |
| 10977 | 2345 | |
| 2346 | /* let the other side know we got it, and to send some more */ | |
| 2347 | mwFileTransfer_ack(ft); | |
| 2348 | } | |
| 2349 | ||
| 2350 | ||
| 2351 | static void mw_ft_ack(struct mwFileTransfer *ft) { | |
| 15884 | 2352 | PurpleXfer *xfer; |
| 10977 | 2353 | |
| 2354 | xfer = mwFileTransfer_getClientData(ft); | |
| 2355 | g_return_if_fail(xfer != NULL); | |
| 2356 | g_return_if_fail(xfer->watcher == 0); | |
| 2357 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2358 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2359 | purple_xfer_set_completed(xfer, TRUE); |
| 2360 | purple_xfer_end(xfer); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2361 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2362 | } else if(mwFileTransfer_isOpen(ft)) { |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2363 | ft_send(ft, xfer->dest_fp); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2364 | } |
| 10977 | 2365 | } |
| 2366 | ||
| 2367 | ||
| 2368 | static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
| 2369 | ; | |
| 2370 | } | |
| 2371 | ||
| 2372 | ||
| 2373 | static struct mwFileTransferHandler mw_ft_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2374 | mw_ft_offered, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2375 | mw_ft_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2376 | mw_ft_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2377 | mw_ft_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2378 | mw_ft_ack, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2379 | mw_ft_clear, |
| 10977 | 2380 | }; |
| 2381 | ||
| 2382 | ||
| 2383 | static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
| 2384 | struct mwServiceFileTransfer *srvc; | |
| 2385 | GHashTable *ft_map; | |
| 2386 | ||
| 2387 | ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 2388 | ||
| 2389 | srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
| 2390 | mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
| 2391 | (GDestroyNotify) g_hash_table_destroy); | |
| 2392 | ||
| 2393 | return srvc; | |
| 2394 | } | |
| 2395 | ||
| 2396 | ||
| 2397 | static void convo_data_free(struct convo_data *cd) { | |
| 2398 | GList *l; | |
| 2399 | ||
| 2400 | /* clean the queue */ | |
| 2401 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2402 | struct convo_msg *m = l->data; | |
| 2403 | if(m->clear) m->clear(m->data); | |
| 2404 | g_free(m); | |
| 2405 | } | |
| 2406 | ||
| 2407 | g_free(cd); | |
| 2408 | } | |
| 2409 | ||
| 2410 | ||
| 2411 | /** allocates a convo_data structure and associates it with the | |
| 2412 | conversation in the client data slot */ | |
| 2413 | static void convo_data_new(struct mwConversation *conv) { | |
| 2414 | struct convo_data *cd; | |
| 2415 | ||
| 2416 | g_return_if_fail(conv != NULL); | |
| 2417 | ||
| 2418 | if(mwConversation_getClientData(conv)) | |
| 2419 | return; | |
| 2420 | ||
| 2421 | cd = g_new0(struct convo_data, 1); | |
| 2422 | cd->conv = conv; | |
| 2423 | ||
| 2424 | mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
| 2425 | } | |
| 2426 | ||
| 2427 | ||
| 15884 | 2428 | static PurpleConversation *convo_get_gconv(struct mwConversation *conv) { |
| 10977 | 2429 | struct mwServiceIm *srvc; |
| 2430 | struct mwSession *session; | |
| 15884 | 2431 | struct mwPurplePluginData *pd; |
| 2432 | PurpleConnection *gc; | |
| 2433 | PurpleAccount *acct; | |
| 10977 | 2434 | |
| 2435 | struct mwIdBlock *idb; | |
| 2436 | ||
| 2437 | srvc = mwConversation_getService(conv); | |
| 2438 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2439 | pd = mwSession_getClientData(session); | |
| 2440 | gc = pd->gc; | |
| 15884 | 2441 | acct = purple_connection_get_account(gc); |
| 10977 | 2442 | |
| 2443 | idb = mwConversation_getTarget(conv); | |
| 2444 | ||
| 15884 | 2445 | 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
|
2446 | idb->user, acct); |
| 10977 | 2447 | } |
| 2448 | ||
| 2449 | ||
| 2450 | static void convo_queue(struct mwConversation *conv, | |
| 2451 | enum mwImSendType type, gconstpointer data) { | |
| 2452 | ||
| 2453 | struct convo_data *cd; | |
| 2454 | struct convo_msg *m; | |
| 2455 | ||
| 2456 | convo_data_new(conv); | |
| 2457 | cd = mwConversation_getClientData(conv); | |
| 2458 | ||
| 2459 | m = g_new0(struct convo_msg, 1); | |
| 2460 | m->type = type; | |
| 2461 | ||
| 2462 | switch(type) { | |
| 2463 | case mwImSend_PLAIN: | |
| 2464 | m->data = g_strdup(data); | |
| 2465 | m->clear = g_free; | |
| 2466 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2467 | |
| 10977 | 2468 | case mwImSend_TYPING: |
| 2469 | default: | |
| 2470 | m->data = (gpointer) data; | |
| 2471 | m->clear = NULL; | |
| 2472 | } | |
| 2473 | ||
| 2474 | cd->queue = g_list_append(cd->queue, m); | |
| 2475 | } | |
| 2476 | ||
| 2477 | ||
| 2478 | /* Does what it takes to get an error displayed for a conversation */ | |
| 2479 | static void convo_error(struct mwConversation *conv, guint32 err) { | |
| 15884 | 2480 | PurpleConversation *gconv; |
| 10977 | 2481 | char *tmp, *text; |
| 2482 | struct mwIdBlock *idb; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2483 | |
| 10977 | 2484 | idb = mwConversation_getTarget(conv); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2485 | |
| 10977 | 2486 | tmp = mwError(err); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2487 | text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2488 | |
| 10977 | 2489 | gconv = convo_get_gconv(conv); |
| 15884 | 2490 | if(gconv && !purple_conv_present_error(idb->user, gconv->account, text)) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2491 | |
| 10977 | 2492 | g_free(text); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2493 | text = g_strdup_printf(_("Unable to send message to %s:"), |
| 10977 | 2494 | (idb->user)? idb->user: "(unknown)"); |
| 15884 | 2495 | purple_notify_error(purple_account_get_connection(gconv->account), |
| 10977 | 2496 | NULL, text, tmp); |
| 2497 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2498 | |
| 10977 | 2499 | g_free(tmp); |
| 2500 | g_free(text); | |
| 2501 | } | |
| 2502 | ||
| 2503 | ||
| 2504 | static void convo_queue_send(struct mwConversation *conv) { | |
| 2505 | struct convo_data *cd; | |
| 2506 | GList *l; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2507 | |
| 10977 | 2508 | cd = mwConversation_getClientData(conv); |
| 2509 | ||
| 2510 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2511 | struct convo_msg *m = l->data; | |
| 2512 | ||
| 2513 | mwConversation_send(conv, m->type, m->data); | |
| 2514 | ||
| 2515 | if(m->clear) m->clear(m->data); | |
| 2516 | g_free(m); | |
| 2517 | } | |
| 2518 | ||
| 2519 | cd->queue = NULL; | |
| 2520 | } | |
| 2521 | ||
| 2522 | ||
| 15884 | 2523 | /** called when a mw conversation leaves a purple conversation to |
| 2524 | inform the purple conversation that it's unsafe to offer any *cool* | |
| 10977 | 2525 | features. */ |
| 2526 | static void convo_nofeatures(struct mwConversation *conv) { | |
| 15884 | 2527 | PurpleConversation *gconv; |
| 2528 | PurpleConnection *gc; | |
| 10977 | 2529 | |
| 2530 | gconv = convo_get_gconv(conv); | |
| 2531 | if(! gconv) return; | |
| 2532 | ||
| 15884 | 2533 | gc = purple_conversation_get_gc(gconv); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2534 | if(! gc) return; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2535 | |
| 15884 | 2536 | purple_conversation_set_features(gconv, gc->flags); |
| 2537 | } | |
| 2538 | ||
| 2539 | ||
| 2540 | /** called when a mw conversation and purple conversation come together, | |
| 2541 | to inform the purple conversation of what features to offer the | |
| 10977 | 2542 | user */ |
| 2543 | static void convo_features(struct mwConversation *conv) { | |
| 15884 | 2544 | PurpleConversation *gconv; |
| 2545 | PurpleConnectionFlags feat; | |
| 10977 | 2546 | |
| 2547 | gconv = convo_get_gconv(conv); | |
| 2548 | if(! gconv) return; | |
| 2549 | ||
| 15884 | 2550 | feat = purple_conversation_get_features(gconv); |
| 10977 | 2551 | |
| 2552 | if(mwConversation_isOpen(conv)) { | |
| 2553 | if(mwConversation_supports(conv, mwImSend_HTML)) { | |
| 15884 | 2554 | feat |= PURPLE_CONNECTION_HTML; |
| 10977 | 2555 | } else { |
| 15884 | 2556 | feat &= ~PURPLE_CONNECTION_HTML; |
| 10977 | 2557 | } |
| 2558 | ||
| 2559 | if(mwConversation_supports(conv, mwImSend_MIME)) { | |
| 15884 | 2560 | feat &= ~PURPLE_CONNECTION_NO_IMAGES; |
| 10977 | 2561 | } else { |
| 15884 | 2562 | feat |= PURPLE_CONNECTION_NO_IMAGES; |
| 10977 | 2563 | } |
| 2564 | ||
| 2565 | DEBUG_INFO("conversation features set to 0x%04x\n", feat); | |
| 15884 | 2566 | purple_conversation_set_features(gconv, feat); |
| 10977 | 2567 | |
| 2568 | } else { | |
| 2569 | convo_nofeatures(conv); | |
| 2570 | } | |
| 2571 | } | |
| 2572 | ||
| 2573 | ||
| 2574 | static void mw_conversation_opened(struct mwConversation *conv) { | |
| 2575 | struct mwServiceIm *srvc; | |
| 2576 | struct mwSession *session; | |
| 15884 | 2577 | struct mwPurplePluginData *pd; |
| 2578 | PurpleConnection *gc; | |
| 2579 | PurpleAccount *acct; | |
| 10977 | 2580 | |
| 2581 | struct convo_dat *cd; | |
| 2582 | ||
| 2583 | srvc = mwConversation_getService(conv); | |
| 2584 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2585 | pd = mwSession_getClientData(session); | |
| 2586 | gc = pd->gc; | |
| 15884 | 2587 | acct = purple_connection_get_account(gc); |
| 10977 | 2588 | |
| 2589 | /* set up the queue */ | |
| 2590 | cd = mwConversation_getClientData(conv); | |
| 2591 | if(cd) { | |
| 2592 | convo_queue_send(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2593 | |
| 10977 | 2594 | if(! convo_get_gconv(conv)) { |
| 2595 | mwConversation_free(conv); | |
| 2596 | return; | |
| 2597 | } | |
| 2598 | ||
| 2599 | } else { | |
| 2600 | convo_data_new(conv); | |
| 2601 | } | |
| 2602 | ||
| 2603 | { /* record the client key for the buddy */ | |
| 15884 | 2604 | PurpleBuddy *buddy; |
| 10977 | 2605 | struct mwLoginInfo *info; |
| 2606 | info = mwConversation_getTargetInfo(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2607 | |
| 15884 | 2608 | buddy = purple_find_buddy(acct, info->user_id); |
| 10977 | 2609 | if(buddy) { |
| 15884 | 2610 | purple_blist_node_set_int((PurpleBlistNode *) buddy, |
| 10977 | 2611 | BUDDY_KEY_CLIENT, info->type); |
| 2612 | } | |
| 2613 | } | |
| 2614 | ||
| 2615 | convo_features(conv); | |
| 2616 | } | |
| 2617 | ||
| 2618 | ||
| 2619 | static void mw_conversation_closed(struct mwConversation *conv, | |
| 2620 | guint32 reason) { | |
| 2621 | ||
| 2622 | struct convo_data *cd; | |
| 2623 | ||
| 2624 | g_return_if_fail(conv != NULL); | |
| 2625 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2626 | /* 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
|
2627 | print an error message to the conversation */ |
| 10977 | 2628 | cd = mwConversation_getClientData(conv); |
| 2629 | if(reason && cd && cd->queue) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2630 | GList *l; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2631 | for(l = cd->queue; l; l = l->next) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2632 | struct convo_msg *m = l->data; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2633 | if(m->type != mwImSend_TYPING) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2634 | convo_error(conv, reason); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2635 | break; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2636 | } |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2637 | } |
| 10977 | 2638 | } |
| 2639 | ||
| 2640 | #if 0 | |
| 2641 | /* don't do this, to prevent the occasional weird sending of | |
| 2642 | formatted messages as plaintext when the other end closes the | |
| 2643 | conversation after we've begun composing the message */ | |
| 2644 | convo_nofeatures(conv); | |
| 2645 | #endif | |
| 2646 | ||
| 2647 | mwConversation_removeClientData(conv); | |
| 2648 | } | |
| 2649 | ||
| 2650 | ||
| 2651 | static void im_recv_text(struct mwConversation *conv, | |
| 15884 | 2652 | struct mwPurplePluginData *pd, |
| 10977 | 2653 | const char *msg) { |
| 2654 | ||
| 2655 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2656 | char *txt, *esc; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2657 | const char *t; |
| 10977 | 2658 | |
| 2659 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2660 | |
| 15884 | 2661 | txt = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2662 | t = txt? txt: msg; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2663 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2664 | esc = g_markup_escape_text(t, -1); |
| 10977 | 2665 | 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
|
2666 | g_free(esc); |
| 10977 | 2667 | |
| 2668 | g_free(txt); | |
| 2669 | } | |
| 2670 | ||
| 2671 | ||
| 2672 | static void im_recv_typing(struct mwConversation *conv, | |
| 15884 | 2673 | struct mwPurplePluginData *pd, |
| 10977 | 2674 | gboolean typing) { |
| 2675 | ||
| 2676 | struct mwIdBlock *idb; | |
| 2677 | idb = mwConversation_getTarget(conv); | |
| 2678 | ||
| 2679 | serv_got_typing(pd->gc, idb->user, 0, | |
| 15884 | 2680 | typing? PURPLE_TYPING: PURPLE_NOT_TYPING); |
| 10977 | 2681 | } |
| 2682 | ||
| 2683 | ||
| 2684 | static void im_recv_html(struct mwConversation *conv, | |
| 15884 | 2685 | struct mwPurplePluginData *pd, |
| 10977 | 2686 | const char *msg) { |
| 2687 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2688 | char *t1, *t2; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2689 | const char *t; |
| 10977 | 2690 | |
| 2691 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2692 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2693 | /* ensure we're receiving UTF8 */ |
| 15884 | 2694 | t1 = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2695 | t = t1? t1: msg; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2696 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2697 | /* convert entities to UTF8 so they'll log correctly */ |
| 15884 | 2698 | t2 = purple_utf8_ncr_decode(t); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2699 | t = t2? t2: t; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2700 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2701 | serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
| 10977 | 2702 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2703 | g_free(t1); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2704 | g_free(t2); |
| 10977 | 2705 | } |
| 2706 | ||
| 2707 | ||
| 2708 | static void im_recv_subj(struct mwConversation *conv, | |
| 15884 | 2709 | struct mwPurplePluginData *pd, |
| 10977 | 2710 | const char *subj) { |
| 2711 | ||
| 2712 | /** @todo somehow indicate receipt of a conversation subject. It | |
| 2713 | would also be nice if we added a /topic command for the | |
| 2714 | protocol */ | |
| 2715 | ; | |
| 2716 | } | |
| 2717 | ||
| 2718 | ||
| 2719 | /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */ | |
| 2720 | static char *make_cid(const char *cid) { | |
| 2721 | gsize n; | |
| 2722 | char *c, *d; | |
| 2723 | ||
| 2724 | g_return_val_if_fail(cid != NULL, NULL); | |
| 2725 | ||
| 2726 | n = strlen(cid); | |
| 2727 | g_return_val_if_fail(n > 2, NULL); | |
| 2728 | ||
| 2729 | c = g_strndup(cid+1, n-2); | |
| 2730 | d = g_strdup_printf("cid:%s", c); | |
| 2731 | ||
| 2732 | g_free(c); | |
| 2733 | return d; | |
| 2734 | } | |
| 2735 | ||
| 2736 | ||
| 2737 | static void im_recv_mime(struct mwConversation *conv, | |
| 15884 | 2738 | struct mwPurplePluginData *pd, |
| 10977 | 2739 | const char *data) { |
| 2740 | ||
| 2741 | GHashTable *img_by_cid; | |
| 2742 | GList *images; | |
| 2743 | ||
| 2744 | GString *str; | |
| 2745 | ||
| 15884 | 2746 | 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
|
2747 | GList *parts; |
| 10977 | 2748 | |
| 2749 | img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
| 2750 | images = NULL; | |
| 2751 | ||
| 2752 | /* don't want the contained string to ever be NULL */ | |
| 2753 | str = g_string_new(""); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2754 | |
| 15884 | 2755 | doc = purple_mime_document_parse(data); |
| 10977 | 2756 | |
| 2757 | /* handle all the MIME parts */ | |
| 15884 | 2758 | parts = purple_mime_document_get_parts(doc); |
| 10977 | 2759 | for(; parts; parts = parts->next) { |
| 15884 | 2760 | PurpleMimePart *part = parts->data; |
| 10977 | 2761 | const char *type; |
| 2762 | ||
| 15884 | 2763 | type = purple_mime_part_get_field(part, "content-type"); |
| 10977 | 2764 | DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type)); |
| 2765 | ||
| 2766 | if(! type) { | |
| 2767 | ; /* feh */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2768 | |
| 15884 | 2769 | } else if(purple_str_has_prefix(type, "image")) { |
| 10977 | 2770 | /* put images into the image store */ |
| 2771 | ||
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2772 | guchar *d_dat; |
| 10977 | 2773 | gsize d_len; |
| 2774 | char *cid; | |
| 2775 | int img; | |
| 2776 | ||
| 2777 | /* obtain and unencode the data */ | |
| 15884 | 2778 | 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
|
2779 | |
| 10977 | 2780 | /* look up the content id */ |
| 15884 | 2781 | cid = (char *) purple_mime_part_get_field(part, "Content-ID"); |
| 10977 | 2782 | cid = make_cid(cid); |
| 2783 | ||
| 15884 | 2784 | /* 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
|
2785 | img = purple_imgstore_add_with_id(d_dat, d_len, cid); |
| 10977 | 2786 | |
| 2787 | /* map the cid to the image store identifier */ | |
| 2788 | g_hash_table_insert(img_by_cid, cid, GINT_TO_POINTER(img)); | |
| 2789 | ||
| 2790 | /* recall the image for dereferencing later */ | |
| 2791 | images = g_list_append(images, GINT_TO_POINTER(img)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2792 | |
| 15884 | 2793 | } else if(purple_str_has_prefix(type, "text")) { |
| 10977 | 2794 | |
| 2795 | /* concatenate all the text parts together */ | |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2796 | guchar *data; |
| 10977 | 2797 | gsize len; |
| 2798 | ||
| 15884 | 2799 | purple_mime_part_get_data_decoded(part, &data, &len); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2800 | g_string_append(str, (const char *)data); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2801 | g_free(data); |
| 10977 | 2802 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2803 | } |
| 10977 | 2804 | |
| 15884 | 2805 | purple_mime_document_free(doc); |
| 10977 | 2806 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2807 | /* @todo should put this in its own function */ |
| 10977 | 2808 | { /* replace each IMG tag's SRC attribute with an ID attribute. This |
| 2809 | actually modifies the contents of str */ | |
| 2810 | GData *attribs; | |
| 2811 | char *start, *end; | |
| 2812 | char *tmp = str->str; | |
| 2813 | ||
| 15884 | 2814 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 2815 | (const char **) &end, &attribs)) { |
| 2816 | ||
| 2817 | char *alt, *align, *border, *src; | |
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2818 | int img = 0; |
| 10977 | 2819 | |
| 2820 | alt = g_datalist_get_data(&attribs, "alt"); | |
| 2821 | align = g_datalist_get_data(&attribs, "align"); | |
| 2822 | border = g_datalist_get_data(&attribs, "border"); | |
| 2823 | src = g_datalist_get_data(&attribs, "src"); | |
| 2824 | ||
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2825 | if(src) |
|
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2826 | 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
|
2827 | |
| 10977 | 2828 | if(img) { |
| 2829 | GString *atstr; | |
| 2830 | gsize len = (end - start); | |
| 2831 | gsize mov; | |
| 2832 | ||
| 2833 | atstr = g_string_new(""); | |
| 2834 | if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt); | |
| 2835 | if(align) g_string_append_printf(atstr, " align=\"%s\"", align); | |
| 2836 | if(border) g_string_append_printf(atstr, " border=\"%s\"", border); | |
| 2837 | ||
| 2838 | mov = g_snprintf(start, len, "<img%s id=\"%i\"", atstr->str, img); | |
| 2839 | while(mov < len) start[mov++] = ' '; | |
| 2840 | ||
| 2841 | g_string_free(atstr, TRUE); | |
| 2842 | } | |
| 2843 | ||
| 2844 | g_datalist_clear(&attribs); | |
| 2845 | tmp = end + 1; | |
| 2846 | } | |
| 2847 | } | |
| 2848 | ||
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2849 | im_recv_html(conv, pd, str->str); |
| 10977 | 2850 | |
| 2851 | g_string_free(str, TRUE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2852 | |
| 10977 | 2853 | /* clean up the cid table */ |
| 2854 | g_hash_table_destroy(img_by_cid); | |
| 2855 | ||
| 2856 | /* dereference all the imgages */ | |
| 2857 | 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
|
2858 | purple_imgstore_unref_by_id(GPOINTER_TO_INT(images->data)); |
| 10977 | 2859 | images = g_list_delete_link(images, images); |
| 2860 | } | |
| 2861 | } | |
| 2862 | ||
| 2863 | ||
| 2864 | static void mw_conversation_recv(struct mwConversation *conv, | |
| 2865 | enum mwImSendType type, | |
| 2866 | gconstpointer msg) { | |
| 2867 | struct mwServiceIm *srvc; | |
| 2868 | struct mwSession *session; | |
| 15884 | 2869 | struct mwPurplePluginData *pd; |
| 10977 | 2870 | |
| 2871 | srvc = mwConversation_getService(conv); | |
| 2872 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2873 | pd = mwSession_getClientData(session); | |
| 2874 | ||
| 2875 | switch(type) { | |
| 2876 | case mwImSend_PLAIN: | |
| 2877 | im_recv_text(conv, pd, msg); | |
| 2878 | break; | |
| 2879 | ||
| 2880 | case mwImSend_TYPING: | |
| 2881 | im_recv_typing(conv, pd, !! msg); | |
| 2882 | break; | |
| 2883 | ||
| 2884 | case mwImSend_HTML: | |
| 2885 | im_recv_html(conv, pd, msg); | |
| 2886 | break; | |
| 2887 | ||
| 2888 | case mwImSend_SUBJECT: | |
| 2889 | im_recv_subj(conv, pd, msg); | |
| 2890 | break; | |
| 2891 | ||
| 2892 | case mwImSend_MIME: | |
| 2893 | im_recv_mime(conv, pd, msg); | |
| 2894 | break; | |
| 2895 | ||
| 2896 | default: | |
| 2897 | DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
| 2898 | ; /* erm... */ | |
| 2899 | } | |
| 2900 | } | |
| 2901 | ||
| 2902 | ||
| 2903 | static void mw_place_invite(struct mwConversation *conv, | |
| 2904 | const char *message, | |
| 2905 | const char *title, const char *name) { | |
| 2906 | struct mwServiceIm *srvc; | |
| 2907 | struct mwSession *session; | |
| 15884 | 2908 | struct mwPurplePluginData *pd; |
| 10977 | 2909 | |
| 2910 | struct mwIdBlock *idb; | |
| 2911 | GHashTable *ht; | |
| 2912 | ||
| 2913 | srvc = mwConversation_getService(conv); | |
| 2914 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2915 | pd = mwSession_getClientData(session); | |
| 2916 | ||
| 2917 | idb = mwConversation_getTarget(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2918 | |
| 10977 | 2919 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 2920 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
| 2921 | g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
| 2922 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
| 2923 | 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
|
2924 | g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
| 10977 | 2925 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2926 | if(! title) title = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2927 | if(! message) message = "(no message)"; |
| 10977 | 2928 | 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
|
2929 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2930 | mwConversation_close(conv, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2931 | mwConversation_free(conv); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2932 | } |
| 10977 | 2933 | |
| 2934 | ||
| 2935 | static void mw_im_clear(struct mwServiceIm *srvc) { | |
| 2936 | ; | |
| 2937 | } | |
| 2938 | ||
| 2939 | ||
| 2940 | static struct mwImHandler mw_im_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2941 | mw_conversation_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2942 | mw_conversation_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2943 | mw_conversation_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2944 | mw_place_invite, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2945 | mw_im_clear, |
| 10977 | 2946 | }; |
| 2947 | ||
| 2948 | ||
| 2949 | static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
| 2950 | struct mwServiceIm *srvc; | |
| 2951 | srvc = mwServiceIm_new(s, &mw_im_handler); | |
| 2952 | mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
| 2953 | return srvc; | |
| 2954 | } | |
| 2955 | ||
| 2956 | ||
| 15884 | 2957 | /* 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
|
2958 | 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
|
2959 | the similar macros from the conference service above */ |
|
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 | #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2962 | #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
|
2963 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2964 | #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
|
2965 | #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
|
2966 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2967 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2968 | static struct mwPlace * |
| 15884 | 2969 | place_find_by_id(struct mwPurplePluginData *pd, int id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2970 | struct mwServicePlace *srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2971 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2972 | GList *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2973 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2974 | l = (GList *) mwServicePlace_getPlaces(srvc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2975 | for(; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2976 | struct mwPlace *p = l->data; |
| 15884 | 2977 | PurpleConvChat *h = PURPLE_CONV_CHAT(mwPlace_getClientData(p)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2978 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2979 | if(CHAT_TO_ID(h) == id) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2980 | place = p; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2981 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2982 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2983 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2984 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2985 | return place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2986 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2987 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2988 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2989 | static void mw_place_opened(struct mwPlace *place) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2990 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2991 | struct mwSession *session; |
| 15884 | 2992 | struct mwPurplePluginData *pd; |
| 2993 | PurpleConnection *gc; | |
| 2994 | PurpleConversation *gconf; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2995 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2996 | GList *members, *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2997 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2998 | const char *n = mwPlace_getName(place); |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2999 | const char *t = mwPlace_getTitle(place); |
|
11943
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 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3002 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3003 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3004 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3005 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3006 | members = mwPlace_getMembers(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3007 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3008 | DEBUG_INFO("place %s opened, %u initial members\n", |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3009 | NSTR(n), g_list_length(members)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3010 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
3011 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
3012 | 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
|
3013 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3014 | mwPlace_setClientData(place, gconf, NULL); |
|
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 | for(l = members; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3017 | struct mwIdBlock *idb = l->data; |
| 15884 | 3018 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(gconf), idb->user, |
| 3019 | NULL, PURPLE_CBFLAGS_NONE, FALSE); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3020 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3021 | g_list_free(members); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3022 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3023 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3024 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3025 | static void mw_place_closed(struct mwPlace *place, guint32 code) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3026 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3027 | struct mwSession *session; |
| 15884 | 3028 | struct mwPurplePluginData *pd; |
| 3029 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3030 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3031 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3032 | char *msg = mwError(code); |
|
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 | 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
|
3035 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3036 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3037 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3038 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3039 | gc = pd->gc; |
|
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 | serv_got_chat_left(gc, PLACE_TO_ID(place)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3042 | |
| 15884 | 3043 | purple_notify_error(gc, _("Place Closed"), NULL, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3044 | g_free(msg); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3045 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3046 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3047 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3048 | static void mw_place_peerJoined(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3049 | const struct mwIdBlock *peer) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3050 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3051 | struct mwSession *session; |
| 15884 | 3052 | struct mwPurplePluginData *pd; |
| 3053 | PurpleConnection *gc; | |
| 3054 | PurpleConversation *gconf; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3055 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3056 | const char *n = mwPlace_getName(place); |
|
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 | 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
|
3059 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3060 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3061 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3062 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3063 | gc = pd->gc; |
|
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 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3066 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3067 | |
| 15884 | 3068 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(gconf), peer->user, |
| 3069 | NULL, PURPLE_CBFLAGS_NONE, TRUE); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3070 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3071 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3072 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3073 | static void mw_place_peerParted(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3074 | const struct mwIdBlock *peer) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3075 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3076 | struct mwSession *session; |
| 15884 | 3077 | struct mwPurplePluginData *pd; |
| 3078 | PurpleConnection *gc; | |
| 3079 | PurpleConversation *gconf; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3080 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3081 | const char *n = mwPlace_getName(place); |
|
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 | 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
|
3084 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3085 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3086 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3087 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3088 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3089 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3090 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3091 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3092 | |
| 15884 | 3093 | 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
|
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_peerSetAttribute(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, struct mwOpaque *o) { |
|
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_peerUnsetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3105 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3106 | guint32 attr) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3107 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3108 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3109 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3110 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3111 | static void mw_place_message(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3112 | const struct mwIdBlock *who, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3113 | const char *msg) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3114 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3115 | struct mwSession *session; |
| 15884 | 3116 | struct mwPurplePluginData *pd; |
| 3117 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3118 | char *esc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3119 | |
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3120 | if(! msg) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3121 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3122 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3123 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3124 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3125 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3126 | |
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
3127 | esc = g_markup_escape_text(msg, -1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3128 | 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
|
3129 | g_free(esc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3130 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3131 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3132 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3133 | static void mw_place_clear(struct mwServicePlace *srvc) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3134 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3135 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3136 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3137 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3138 | static struct mwPlaceHandler mw_place_handler = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3139 | mw_place_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3140 | mw_place_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3141 | mw_place_peerJoined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3142 | mw_place_peerParted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3143 | mw_place_peerSetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3144 | mw_place_peerUnsetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3145 | mw_place_message, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3146 | mw_place_clear, |
|
11943
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3150 | static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3151 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3152 | srvc = mwServicePlace_new(s, &mw_place_handler); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3153 | return srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3154 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3155 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3156 | |
| 10977 | 3157 | static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
| 3158 | struct mwServiceResolve *srvc; | |
| 3159 | srvc = mwServiceResolve_new(s); | |
| 3160 | return srvc; | |
| 3161 | } | |
| 3162 | ||
| 3163 | ||
| 3164 | static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
| 3165 | struct mwServiceStorage *srvc; | |
| 3166 | srvc = mwServiceStorage_new(s); | |
| 3167 | return srvc; | |
| 3168 | } | |
| 3169 | ||
| 3170 | ||
| 15884 | 3171 | /** allocate and associate a mwPurplePluginData with a PurpleConnection */ |
| 3172 | static struct mwPurplePluginData *mwPurplePluginData_new(PurpleConnection *gc) { | |
| 3173 | struct mwPurplePluginData *pd; | |
| 10977 | 3174 | |
| 3175 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3176 | ||
| 15884 | 3177 | pd = g_new0(struct mwPurplePluginData, 1); |
| 10977 | 3178 | pd->gc = gc; |
| 3179 | pd->session = mwSession_new(&mw_session_handler); | |
| 3180 | pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
| 3181 | pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
| 3182 | pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
| 3183 | pd->srvc_im = mw_srvc_im_new(pd->session); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3184 | pd->srvc_place = mw_srvc_place_new(pd->session); |
| 10977 | 3185 | pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
| 3186 | pd->srvc_store = mw_srvc_store_new(pd->session); | |
| 3187 | pd->group_list_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 15884 | 3188 | pd->sock_buf = purple_circ_buffer_new(0); |
| 10977 | 3189 | |
| 3190 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
| 3191 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
| 3192 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
| 3193 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3194 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
| 10977 | 3195 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
| 3196 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
| 3197 | ||
| 3198 | 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
|
3199 | mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 10977 | 3200 | |
| 3201 | mwSession_setClientData(pd->session, pd, NULL); | |
| 3202 | gc->proto_data = pd; | |
| 3203 | ||
| 3204 | return pd; | |
| 3205 | } | |
| 3206 | ||
| 3207 | ||
| 15884 | 3208 | static void mwPurplePluginData_free(struct mwPurplePluginData *pd) { |
| 10977 | 3209 | g_return_if_fail(pd != NULL); |
| 3210 | ||
| 3211 | pd->gc->proto_data = NULL; | |
| 3212 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3213 | mwSession_removeService(pd->session, mwService_AWARE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3214 | mwSession_removeService(pd->session, mwService_CONFERENCE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3215 | mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3216 | mwSession_removeService(pd->session, mwService_IM); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3217 | mwSession_removeService(pd->session, mwService_PLACE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3218 | mwSession_removeService(pd->session, mwService_RESOLVE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3219 | mwSession_removeService(pd->session, mwService_STORAGE); |
| 10977 | 3220 | |
| 3221 | mwService_free(MW_SERVICE(pd->srvc_aware)); | |
| 3222 | mwService_free(MW_SERVICE(pd->srvc_conf)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3223 | mwService_free(MW_SERVICE(pd->srvc_ft)); |
| 10977 | 3224 | mwService_free(MW_SERVICE(pd->srvc_im)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3225 | mwService_free(MW_SERVICE(pd->srvc_place)); |
| 10977 | 3226 | mwService_free(MW_SERVICE(pd->srvc_resolve)); |
| 3227 | mwService_free(MW_SERVICE(pd->srvc_store)); | |
| 3228 | ||
| 3229 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3230 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
| 10977 | 3231 | |
| 3232 | mwSession_free(pd->session); | |
| 3233 | ||
| 3234 | g_hash_table_destroy(pd->group_list_map); | |
| 15884 | 3235 | purple_circ_buffer_destroy(pd->sock_buf); |
| 10977 | 3236 | |
| 3237 | g_free(pd); | |
| 3238 | } | |
| 3239 | ||
| 3240 | ||
| 15884 | 3241 | static const char *mw_prpl_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
| 10977 | 3242 | /* my little green dude is a chopped up version of the aim running |
| 3243 | guy. First, cut off the head and store someplace safe. Then, | |
| 3244 | take the left-half side of the body and throw it away. Make a | |
| 3245 | copy of the remaining body, and flip it horizontally. Now attach | |
| 3246 | the two pieces into an X shape, and drop the head back on the | |
| 3247 | top, being careful to center it. Then, just change the color | |
| 3248 | saturation to bring the red down a bit, and voila! */ | |
| 3249 | ||
| 3250 | /* then, throw all of that away and use sodipodi to make a new | |
| 3251 | icon. You know, LIKE A REAL MAN. */ | |
| 3252 | ||
| 3253 | return "meanwhile"; | |
| 3254 | } | |
| 3255 | ||
| 3256 | ||
| 15884 | 3257 | static const char* mw_prpl_list_emblem(PurpleBuddy *b) |
| 15524 | 3258 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3259 | if(buddy_is_external(b)) |
| 15524 | 3260 | return "external"; |
| 3261 | ||
| 3262 | return NULL; | |
| 10977 | 3263 | } |
| 3264 | ||
| 3265 | ||
| 15884 | 3266 | static char *mw_prpl_status_text(PurpleBuddy *b) { |
| 3267 | PurpleConnection *gc; | |
| 3268 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3269 | 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
|
3270 | 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
|
3271 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3272 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3273 | && (pd = gc->proto_data)) |
|
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3274 | 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
|
3275 | |
|
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
|
3276 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3277 | } |
| 3278 | ||
| 3279 | ||
| 15884 | 3280 | static const char *status_text(PurpleBuddy *b) { |
| 3281 | PurplePresence *presence; | |
| 3282 | PurpleStatus *status; | |
| 3283 | ||
| 3284 | presence = purple_buddy_get_presence(b); | |
| 3285 | status = purple_presence_get_active_status(presence); | |
| 3286 | ||
| 3287 | return purple_status_get_name(status); | |
| 10977 | 3288 | } |
| 3289 | ||
| 3290 | ||
| 3291 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3292 | const char *who, guint32 feature) { | |
| 3293 | ||
| 3294 | const struct mwAwareAttribute *attr; | |
| 3295 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3296 | ||
| 3297 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3298 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3299 | } | |
| 3300 | ||
| 3301 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3302 | 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
|
3303 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3304 | const char **f = feat; |
|
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(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3307 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3308 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3309 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3310 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3311 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3312 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3313 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3314 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3315 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3316 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3317 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3318 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3319 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3320 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3321 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3322 | /* jenni loves siege */ |
| 10977 | 3323 | } |
| 3324 | ||
| 3325 | ||
| 15884 | 3326 | static void mw_prpl_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { |
| 3327 | 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
|
3328 | struct mwPurplePluginData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3329 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3330 | |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3331 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3332 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3333 | char *tmp; |
| 10977 | 3334 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3335 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3336 | && (pd = gc->proto_data)) |
|
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3337 | 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
|
3338 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3339 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3340 | |
|
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
|
3341 | if(message != NULL && g_utf8_validate(message, -1, NULL) && purple_utf8_strcasecmp(status, message)) { |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3342 | tmp = g_markup_escape_text(message, -1); |
| 15884 | 3343 | purple_notify_user_info_add_pair(user_info, status, tmp); |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3344 | g_free(tmp); |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3345 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3346 | } else { |
| 15884 | 3347 | purple_notify_user_info_add_pair(user_info, _("Status"), status); |
| 10977 | 3348 | } |
| 3349 | ||
|
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
|
3350 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3351 | 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
|
3352 | if(tmp) { |
| 15884 | 3353 | purple_notify_user_info_add_pair(user_info, _("Supports"), tmp); |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3354 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3355 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3356 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3357 | if(buddy_is_external(b)) { |
| 15884 | 3358 | purple_notify_user_info_add_pair(user_info, NULL, _("External User")); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3359 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3360 | } |
| 10977 | 3361 | } |
| 3362 | ||
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3363 | 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
|
3364 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3365 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3366 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3367 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3368 | 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
|
3369 | 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
|
3370 | 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
|
3371 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3372 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3373 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3374 | 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
|
3375 | 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
|
3376 | 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
|
3377 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3378 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3379 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3380 | 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
|
3381 | 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
|
3382 | 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
|
3383 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3384 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3385 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3386 | 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
|
3387 | 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
|
3388 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3389 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3390 | return types; |
| 10977 | 3391 | } |
| 3392 | ||
| 3393 | ||
| 15884 | 3394 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3395 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3396 | ; /* nothing to do */ |
| 10977 | 3397 | } |
| 3398 | ||
| 3399 | ||
| 15884 | 3400 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3401 | PurpleRequestFields *fields) { | |
| 3402 | PurpleAccount *acct; | |
| 3403 | PurpleConnection *gc; | |
| 3404 | struct mwPurplePluginData *pd; | |
| 10977 | 3405 | struct mwServiceConference *srvc; |
| 3406 | ||
| 15884 | 3407 | PurpleRequestField *f; |
| 10977 | 3408 | |
| 3409 | const char *topic, *invite; | |
| 3410 | struct mwConference *conf; | |
| 3411 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3412 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3413 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3414 | gc = purple_account_get_connection(acct); |
| 10977 | 3415 | pd = gc->proto_data; |
| 3416 | srvc = pd->srvc_conf; | |
| 3417 | ||
| 15884 | 3418 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3419 | topic = purple_request_field_string_get_value(f); | |
| 3420 | ||
| 3421 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3422 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3423 | |
| 3424 | conf = mwConference_new(srvc, topic); | |
| 3425 | mwConference_open(conf); | |
| 3426 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3427 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3428 | mwConference_invite(conf, &idb, invite); |
| 3429 | } | |
| 3430 | ||
| 3431 | ||
| 15884 | 3432 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3433 | ||
| 3434 | PurpleRequestFields *fields; | |
| 3435 | PurpleRequestFieldGroup *g; | |
| 3436 | PurpleRequestField *f; | |
| 3437 | ||
| 3438 | PurpleAccount *acct; | |
| 3439 | PurpleConnection *gc; | |
| 10977 | 3440 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3441 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3442 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3443 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3444 | |
| 10977 | 3445 | g_return_if_fail(buddy != NULL); |
| 3446 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3447 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3448 | g_return_if_fail(acct != NULL); |
| 3449 | ||
| 15884 | 3450 | gc = purple_account_get_connection(acct); |
| 10977 | 3451 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3452 | |
| 15884 | 3453 | fields = purple_request_fields_new(); |
| 3454 | ||
| 3455 | g = purple_request_field_group_new(NULL); | |
| 3456 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3457 | |
| 15884 | 3458 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3459 | purple_request_field_group_add_field(g, f); | |
| 3460 | ||
| 3461 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3462 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3463 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3464 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3465 | 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
|
3466 | " 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
|
3467 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3468 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3469 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3470 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3471 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3472 | _("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
|
3473 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3474 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3475 | g_free(msg1); |
| 10977 | 3476 | } |
| 3477 | ||
| 3478 | ||
| 15884 | 3479 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3480 | PurpleRequestFields *fields) { | |
| 10977 | 3481 | ; |
| 3482 | } | |
| 3483 | ||
| 3484 | ||
| 15884 | 3485 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3486 | PurpleRequestFields *fields) { | |
| 3487 | 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
|
3488 | GList *l; |
| 10977 | 3489 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3490 | |
| 15884 | 3491 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3492 | msg = purple_request_field_string_get_value(f); | |
| 3493 | ||
| 3494 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3495 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3496 | |
| 3497 | if(l) { | |
| 15884 | 3498 | 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
|
3499 | |
| 10977 | 3500 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3501 | blist_menu_conf_create(buddy, msg); | |
| 3502 | ||
| 3503 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3504 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3505 | mwConference_invite(d, &idb, msg); |
| 3506 | } | |
| 3507 | } | |
| 3508 | } | |
| 3509 | ||
| 3510 | ||
| 15884 | 3511 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3512 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3513 | |
| 15884 | 3514 | PurpleRequestFields *fields; |
| 3515 | PurpleRequestFieldGroup *g; | |
| 3516 | PurpleRequestField *f; | |
| 3517 | ||
| 3518 | PurpleAccount *acct; | |
| 3519 | PurpleConnection *gc; | |
| 10977 | 3520 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3521 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3522 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3523 | char *msg; |
| 10977 | 3524 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3525 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3526 | g_return_if_fail(acct != NULL); |
| 3527 | ||
| 15884 | 3528 | gc = purple_account_get_connection(acct); |
| 10977 | 3529 | g_return_if_fail(gc != NULL); |
| 3530 | ||
| 15884 | 3531 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3532 | |
| 15884 | 3533 | g = purple_request_field_group_new(NULL); |
| 3534 | purple_request_fields_add_group(fields, g); | |
| 3535 | ||
| 3536 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3537 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3538 | for(; confs; confs = confs->next) { |
| 3539 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3540 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3541 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3542 | 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
|
3543 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3544 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3545 | |
| 15884 | 3546 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3547 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3548 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3549 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3550 | 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
|
3551 | " 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
|
3552 | " 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
|
3553 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3554 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3555 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3556 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3557 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3558 | _("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
|
3559 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3560 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3561 | g_free(msg); |
| 10977 | 3562 | } |
| 3563 | ||
| 3564 | ||
| 15884 | 3565 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 3566 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3567 | PurpleAccount *acct; | |
| 3568 | PurpleConnection *gc; | |
| 3569 | struct mwPurplePluginData *pd; | |
| 10977 | 3570 | GList *l; |
| 3571 | ||
| 3572 | g_return_if_fail(node != NULL); | |
| 15884 | 3573 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 10977 | 3574 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3575 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3576 | g_return_if_fail(acct != NULL); |
| 3577 | ||
| 15884 | 3578 | gc = purple_account_get_connection(acct); |
| 10977 | 3579 | g_return_if_fail(gc != NULL); |
| 3580 | ||
| 3581 | pd = gc->proto_data; | |
| 3582 | g_return_if_fail(pd != NULL); | |
| 3583 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3584 | /* |
| 10977 | 3585 | - get a list of all conferences on this session |
| 3586 | - if none, prompt to create one, and invite buddy to it | |
| 3587 | - else, prompt to select a conference or create one | |
| 3588 | */ | |
| 3589 | ||
| 3590 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3591 | if(l) { | |
| 3592 | blist_menu_conf_list(buddy, l); | |
| 3593 | g_list_free(l); | |
| 3594 | ||
| 3595 | } else { | |
| 3596 | blist_menu_conf_create(buddy, NULL); | |
| 3597 | } | |
| 3598 | } | |
| 3599 | ||
| 3600 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3601 | #if 0 |
| 15884 | 3602 | static void blist_menu_announce(PurpleBlistNode *node, gpointer data) { |
| 3603 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3604 | PurpleAccount *acct; | |
| 3605 | PurpleConnection *gc; | |
| 3606 | struct mwPurplePluginData *pd; | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3607 | struct mwSession *session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3608 | char *rcpt_name; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3609 | GList *rcpt; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3610 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3611 | g_return_if_fail(node != NULL); |
| 15884 | 3612 | 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
|
3613 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3614 | acct = buddy->account; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3615 | g_return_if_fail(acct != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3616 | |
| 15884 | 3617 | gc = purple_account_get_connection(acct); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3618 | g_return_if_fail(gc != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3619 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3620 | pd = gc->proto_data; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3621 | g_return_if_fail(pd != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3622 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3623 | rcpt_name = g_strdup_printf("@U %s", buddy->name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3624 | rcpt = g_list_prepend(NULL, rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3625 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3626 | session = pd->session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3627 | mwSession_sendAnnounce(session, FALSE, |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3628 | "This is a TEST announcement. Please ignore.", |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3629 | rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3630 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3631 | g_list_free(rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3632 | g_free(rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3633 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3634 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3635 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3636 | |
| 15884 | 3637 | static GList *mw_prpl_blist_node_menu(PurpleBlistNode *node) { |
| 10977 | 3638 | GList *l = NULL; |
| 15884 | 3639 | PurpleMenuAction *act; |
| 3640 | ||
| 3641 | if(! PURPLE_BLIST_NODE_IS_BUDDY(node)) | |
| 10977 | 3642 | return l; |
| 3643 | ||
| 3644 | l = g_list_append(l, NULL); | |
| 3645 | ||
| 15884 | 3646 | act = purple_menu_action_new(_("Invite to Conference..."), |
| 3647 | PURPLE_CALLBACK(blist_menu_conf), NULL, NULL); | |
| 10977 | 3648 | l = g_list_append(l, act); |
| 3649 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3650 | #if 0 |
| 15884 | 3651 | act = purple_menu_action_new(_("Send TEST Announcement"), |
| 3652 | PURPLE_CALLBACK(blist_menu_announce), NULL, NULL); | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3653 | l = g_list_append(l, act); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3654 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3655 | |
| 15884 | 3656 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3657 | blist-node-extended-menu signal for that. The function |
| 3658 | blist_node_menu_cb is assigned to this signal in the function | |
| 3659 | services_starting */ | |
| 3660 | ||
| 3661 | return l; | |
| 3662 | } | |
| 3663 | ||
| 3664 | ||
| 15884 | 3665 | static GList *mw_prpl_chat_info(PurpleConnection *gc) { |
| 10977 | 3666 | GList *l = NULL; |
| 3667 | struct proto_chat_entry *pce; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3668 | |
| 10977 | 3669 | pce = g_new0(struct proto_chat_entry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3670 | pce->label = _("Topic:"); |
| 10977 | 3671 | pce->identifier = CHAT_KEY_TOPIC; |
| 3672 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3673 | |
| 10977 | 3674 | return l; |
| 3675 | } | |
| 3676 | ||
| 3677 | ||
| 15884 | 3678 | static GHashTable *mw_prpl_chat_info_defaults(PurpleConnection *gc, |
| 10977 | 3679 | const char *name) { |
| 3680 | GHashTable *table; | |
| 3681 | ||
| 3682 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3683 | ||
| 3684 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3685 | NULL, g_free); | |
| 3686 | ||
| 3687 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3688 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3689 | ||
| 3690 | return table; | |
| 3691 | } | |
| 3692 | ||
| 3693 | ||
| 15884 | 3694 | static void mw_prpl_login(PurpleAccount *acct); |
| 3695 | ||
| 3696 | ||
| 3697 | static void mw_prpl_login(PurpleAccount *account) { | |
| 3698 | PurpleConnection *gc; | |
| 3699 | struct mwPurplePluginData *pd; | |
| 10977 | 3700 | |
| 3701 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3702 | guint port; |
| 10977 | 3703 | |
| 15884 | 3704 | gc = purple_account_get_connection(account); |
| 3705 | pd = mwPurplePluginData_new(gc); | |
| 10977 | 3706 | |
| 3707 | /* while we do support images, the default is to not offer it */ | |
| 15884 | 3708 | gc->flags |= PURPLE_CONNECTION_NO_IMAGES; |
| 3709 | ||
| 3710 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3711 | |
| 3712 | host = strrchr(user, ':'); | |
| 3713 | if(host) { | |
| 3714 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3715 | *host++ = '\0'; | |
| 15884 | 3716 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3717 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3718 | |
| 10977 | 3719 | } else { |
| 15884 | 3720 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3721 | MW_PLUGIN_DEFAULT_HOST); |
| 3722 | } | |
| 3723 | ||
| 3724 | if(! host || ! *host) { | |
| 3725 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3726 | 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
|
3727 | g_free(user); |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
3728 | purple_connection_error_reason(gc, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
3729 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
3730 | _("A server is required to connect this account")); |
| 10977 | 3731 | return; |
| 3732 | } | |
| 3733 | ||
|
25292
5b4e719c5bbb
Fix a potential leak "KuSh" discovered using "cppcheck". Fixes #7862.
Daniel Atallah <datallah@pidgin.im>
parents:
25181
diff
changeset
|
3734 | pass = g_strdup(purple_account_get_password(account)); |
| 15884 | 3735 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3736 | |
| 3737 | DEBUG_INFO("user: '%s'\n", user); | |
| 3738 | DEBUG_INFO("host: '%s'\n", host); | |
| 3739 | DEBUG_INFO("port: %u\n", port); | |
| 3740 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3741 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3742 | (char *) no_secret, NULL); |
| 3743 | 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
|
3744 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3745 | |
| 15884 | 3746 | 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
|
3747 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3748 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3749 | /* 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
|
3750 | 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
|
3751 | |
| 15884 | 3752 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3753 | 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
|
3754 | 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
|
3755 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3756 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3757 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3758 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3759 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3760 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3761 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3762 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3763 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3764 | GUINT_TO_POINTER(major), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3765 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3766 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3767 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3768 | } |
| 10977 | 3769 | |
| 15884 | 3770 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3771 | ||
| 3772 | if (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL) { | |
| 21279 | 3773 | purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
3774 | _("Unable to connect")); |
| 10977 | 3775 | } |
| 3776 | } | |
| 3777 | ||
| 3778 | ||
| 15884 | 3779 | static void mw_prpl_close(PurpleConnection *gc) { |
| 3780 | struct mwPurplePluginData *pd; | |
| 10977 | 3781 | |
| 3782 | g_return_if_fail(gc != NULL); | |
| 3783 | ||
| 3784 | pd = gc->proto_data; | |
| 3785 | g_return_if_fail(pd != NULL); | |
| 3786 | ||
| 3787 | /* get rid of the blist save timeout */ | |
| 3788 | if(pd->save_event) { | |
| 15884 | 3789 | purple_timeout_remove(pd->save_event); |
| 10977 | 3790 | pd->save_event = 0; |
| 3791 | blist_store(pd); | |
| 3792 | } | |
| 3793 | ||
| 3794 | /* stop the session */ | |
| 3795 | mwSession_stop(pd->session, 0x00); | |
| 3796 | ||
| 3797 | /* no longer necessary */ | |
| 3798 | gc->proto_data = NULL; | |
| 3799 | ||
| 3800 | /* stop watching the socket */ | |
| 3801 | if(gc->inpa) { | |
| 15884 | 3802 | purple_input_remove(gc->inpa); |
| 10977 | 3803 | gc->inpa = 0; |
| 3804 | } | |
| 3805 | ||
| 3806 | /* clean up the rest */ | |
| 15884 | 3807 | mwPurplePluginData_free(pd); |
| 10977 | 3808 | } |
| 3809 | ||
| 3810 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21947
diff
changeset
|
3811 | static int mw_rand(void) { |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3812 | static int seed = 0; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3813 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3814 | /* for diversity, not security. don't touch */ |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3815 | srand(time(NULL) ^ seed); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3816 | seed = rand(); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3817 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3818 | return seed; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3819 | } |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3820 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3821 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3822 | /** 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
|
3823 | static char *im_mime_content_id(void) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3824 | return g_strdup_printf("%03x@%05xmeanwhile", |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3825 | mw_rand() & 0xfff, mw_rand() & 0xfffff); |
| 10977 | 3826 | } |
| 3827 | ||
| 3828 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3829 | /** generates a multipart/related content type with a random-ish |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3830 | 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
|
3831 | static char *im_mime_content_type(void) { |
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3832 | 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
|
3833 | mw_rand() & 0xfff, mw_rand() & 0xffff); |
| 10977 | 3834 | } |
| 3835 | ||
| 3836 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3837 | /** determine content type from extension. Not so happy about this, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3838 | but I don't want to actually write image type detection */ |
| 15884 | 3839 | static char *im_mime_img_content_type(PurpleStoredImage *img) { |
| 3840 | const char *fn = purple_imgstore_get_filename(img); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3841 | const char *ct = NULL; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3842 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3843 | ct = strrchr(fn, '.'); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3844 | if(! ct) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3845 | ct = "image"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3846 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3847 | } else if(! strcmp(".png", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3848 | ct = "image/png"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3849 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3850 | } else if(! strcmp(".jpg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3851 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3852 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3853 | } else if(! strcmp(".jpeg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3854 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3855 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3856 | } else if(! strcmp(".gif", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3857 | ct = "image/gif"; |
| 10977 | 3858 | |
| 3859 | } else { | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3860 | ct = "image"; |
| 10977 | 3861 | } |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3862 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3863 | return g_strdup_printf("%s; name=\"%s\"", ct, fn); |
| 10977 | 3864 | } |
| 3865 | ||
| 3866 | ||
| 15884 | 3867 | static char *im_mime_img_content_disp(PurpleStoredImage *img) { |
| 3868 | const char *fn = purple_imgstore_get_filename(img); | |
| 10977 | 3869 | return g_strdup_printf("attachment; filename=\"%s\"", fn); |
| 3870 | } | |
| 3871 | ||
| 3872 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3873 | /** turn an IM with embedded images into a multi-part mime document */ |
| 15884 | 3874 | static char *im_mime_convert(PurpleConnection *gc, |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3875 | struct mwConversation *conv, |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3876 | const char *message) { |
| 10977 | 3877 | GString *str; |
| 15884 | 3878 | PurpleMimeDocument *doc; |
| 3879 | PurpleMimePart *part; | |
| 10977 | 3880 | |
| 3881 | GData *attr; | |
| 3882 | char *tmp, *start, *end; | |
| 3883 | ||
| 3884 | str = g_string_new(NULL); | |
| 3885 | ||
| 15884 | 3886 | doc = purple_mime_document_new(); |
| 3887 | ||
| 3888 | purple_mime_document_set_field(doc, "Mime-Version", "1.0"); | |
| 3889 | purple_mime_document_set_field(doc, "Content-Disposition", "inline"); | |
| 10977 | 3890 | |
| 3891 | tmp = im_mime_content_type(); | |
| 15884 | 3892 | purple_mime_document_set_field(doc, "Content-Type", tmp); |
| 10977 | 3893 | g_free(tmp); |
| 3894 | ||
| 3895 | tmp = (char *) message; | |
| 15884 | 3896 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 3897 | (const char **) &end, &attr)) { |
| 3898 | char *id; | |
| 15884 | 3899 | PurpleStoredImage *img = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3900 | |
| 10977 | 3901 | gsize len = (start - tmp); |
| 3902 | ||
| 3903 | /* append the in-between-tags text */ | |
| 3904 | if(len) g_string_append_len(str, tmp, len); | |
| 3905 | ||
| 3906 | /* find the imgstore data by the id tag */ | |
| 3907 | id = g_datalist_get_data(&attr, "id"); | |
| 3908 | 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
|
3909 | img = purple_imgstore_find_by_id(atoi(id)); |
| 10977 | 3910 | |
| 3911 | if(img) { | |
| 3912 | char *cid; | |
| 3913 | gpointer data; | |
| 3914 | size_t size; | |
| 3915 | ||
| 15884 | 3916 | part = purple_mime_part_new(doc); |
| 10977 | 3917 | |
| 3918 | data = im_mime_img_content_disp(img); | |
| 15884 | 3919 | purple_mime_part_set_field(part, "Content-Disposition", data); |
| 10977 | 3920 | g_free(data); |
| 3921 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3922 | data = im_mime_img_content_type(img); |
| 15884 | 3923 | purple_mime_part_set_field(part, "Content-Type", data); |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3924 | g_free(data); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3925 | |
| 10977 | 3926 | cid = im_mime_content_id(); |
| 3927 | data = g_strdup_printf("<%s>", cid); | |
| 15884 | 3928 | purple_mime_part_set_field(part, "Content-ID", data); |
| 10977 | 3929 | g_free(data); |
| 3930 | ||
| 15884 | 3931 | purple_mime_part_set_field(part, "Content-transfer-encoding", "base64"); |
| 10977 | 3932 | |
| 3933 | /* obtain and base64 encode the image data, and put it in the | |
| 3934 | mime part */ | |
| 15884 | 3935 | 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
|
3936 | data = purple_base64_encode(purple_imgstore_get_data(img), (gsize) size); |
| 15884 | 3937 | purple_mime_part_set_data(part, data); |
| 10977 | 3938 | g_free(data); |
| 3939 | ||
| 3940 | /* append the modified tag */ | |
| 3941 | g_string_append_printf(str, "<img src=\"cid:%s\">", cid); | |
| 3942 | g_free(cid); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3943 | |
| 10977 | 3944 | } else { |
| 3945 | /* append the literal image tag, since we couldn't find a | |
| 3946 | relative imgstore object */ | |
| 3947 | gsize len = (end - start) + 1; | |
| 3948 | g_string_append_len(str, start, len); | |
| 3949 | } | |
| 3950 | ||
| 3951 | g_datalist_clear(&attr); | |
| 3952 | tmp = end + 1; | |
| 3953 | } | |
| 3954 | ||
| 3955 | /* append left-overs */ | |
| 3956 | g_string_append(str, tmp); | |
| 3957 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3958 | /* add the text/html part */ |
| 15884 | 3959 | part = purple_mime_part_new(doc); |
| 3960 | purple_mime_part_set_field(part, "Content-Disposition", "inline"); | |
| 3961 | ||
| 3962 | tmp = purple_utf8_ncr_encode(str->str); | |
| 3963 | purple_mime_part_set_field(part, "Content-Type", "text/html"); | |
| 3964 | purple_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); | |
| 3965 | purple_mime_part_set_data(part, tmp); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3966 | g_free(tmp); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3967 | |
| 10977 | 3968 | g_string_free(str, TRUE); |
| 3969 | ||
| 3970 | str = g_string_new(NULL); | |
| 15884 | 3971 | purple_mime_document_write(doc, str); |
| 10977 | 3972 | tmp = str->str; |
| 3973 | g_string_free(str, FALSE); | |
| 3974 | ||
| 3975 | return tmp; | |
| 3976 | } | |
| 3977 | ||
| 3978 | ||
| 15884 | 3979 | static int mw_prpl_send_im(PurpleConnection *gc, |
| 10977 | 3980 | const char *name, |
| 3981 | const char *message, | |
| 15884 | 3982 | PurpleMessageFlags flags) { |
| 3983 | ||
| 3984 | struct mwPurplePluginData *pd; | |
| 10977 | 3985 | struct mwIdBlock who = { (char *) name, NULL }; |
| 3986 | struct mwConversation *conv; | |
| 3987 | ||
| 3988 | g_return_val_if_fail(gc != NULL, 0); | |
| 3989 | pd = gc->proto_data; | |
| 3990 | ||
| 3991 | g_return_val_if_fail(pd != NULL, 0); | |
| 3992 | ||
| 3993 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 3994 | ||
| 3995 | /* this detection of features to determine how to send the message | |
| 3996 | (plain, html, or mime) is flawed because the other end of the | |
| 3997 | conversation could close their channel at any time, rendering any | |
| 3998 | existing formatting in an outgoing message innapropriate. The end | |
| 3999 | result is that it may be possible that the other side of the | |
| 4000 | conversation will receive a plaintext message with html contents, | |
| 4001 | which is bad. I'm not sure how to fix this correctly. */ | |
| 4002 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4003 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 4004 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 4005 | |
| 4006 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4007 | char *tmp; |
| 10977 | 4008 | int ret; |
| 4009 | ||
| 15884 | 4010 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 4011 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4012 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4013 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4014 | tmp = im_mime_convert(gc, conv, message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4015 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4016 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4017 | |
| 10977 | 4018 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4019 | /* send an HTML message */ |
| 10977 | 4020 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4021 | char *ncr; |
| 15884 | 4022 | ncr = purple_utf8_ncr_encode(message); |
| 4023 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4024 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
4025 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4026 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4027 | g_free(tmp); |
| 10977 | 4028 | |
| 4029 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4030 | /* default to text */ |
| 15884 | 4031 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4032 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4033 | g_free(tmp); |
| 10977 | 4034 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4035 | |
| 10977 | 4036 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4037 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4038 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4039 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4040 | /* queue up the message safely as plain text */ |
| 15884 | 4041 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4042 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4043 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4044 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4045 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4046 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4047 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4048 | return 1; |
| 10977 | 4049 | } |
| 4050 | } | |
| 4051 | ||
| 4052 | ||
| 15884 | 4053 | static unsigned int mw_prpl_send_typing(PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4054 | const char *name, |
| 15884 | 4055 | PurpleTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4056 | |
| 15884 | 4057 | struct mwPurplePluginData *pd; |
| 10977 | 4058 | struct mwIdBlock who = { (char *) name, NULL }; |
| 4059 | struct mwConversation *conv; | |
| 4060 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
4061 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 4062 | |
| 4063 | g_return_val_if_fail(gc != NULL, 0); | |
| 4064 | pd = gc->proto_data; | |
| 4065 | ||
| 4066 | g_return_val_if_fail(pd != NULL, 0); | |
| 4067 | ||
| 4068 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 4069 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4070 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4071 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4072 | |
| 15884 | 4073 | } else if((state == PURPLE_TYPING) || (state == PURPLE_TYPED)) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4074 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4075 | 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
|
4076 | 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
|
4077 | |
| 10977 | 4078 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4079 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4080 | if(! mwConversation_isPending(conv)) { |
| 10977 | 4081 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4082 | } |
| 10977 | 4083 | } |
| 4084 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4085 | return 0; |
| 10977 | 4086 | } |
| 4087 | ||
| 4088 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4089 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4090 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4091 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4092 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4093 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4094 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4095 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4096 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4097 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4098 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4099 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4100 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4101 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4102 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4103 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4104 | return "Lotus Sametime Links"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4105 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4106 | case mwLogin_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4107 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4108 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4109 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4110 | return "Lotus Notes Client"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4111 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4112 | case mwLogin_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4113 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4114 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4115 | return "IBM Community Tools"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4116 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4117 | case mwLogin_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4118 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4119 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4120 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4121 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4122 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4123 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4124 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4125 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4126 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4127 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4128 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4129 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4130 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4131 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4132 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4133 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4134 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4135 | return "Trillian"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4136 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4137 | case mwLogin_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4138 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4139 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4140 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4141 | return NULL; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4142 | } |
|
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 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4145 | |
| 15884 | 4146 | static void mw_prpl_get_info(PurpleConnection *gc, const char *who) { |
| 10977 | 4147 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4148 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4149 | |
| 15884 | 4150 | struct mwPurplePluginData *pd; |
| 4151 | PurpleAccount *acct; | |
| 4152 | PurpleBuddy *b; | |
| 4153 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4154 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4155 | const char *tmp2; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4156 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4157 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4158 | g_return_if_fail(*who != '\0'); |
| 10977 | 4159 | |
| 4160 | pd = gc->proto_data; | |
| 4161 | ||
| 15884 | 4162 | acct = purple_connection_get_account(gc); |
| 4163 | b = purple_find_buddy(acct, who); | |
| 4164 | user_info = purple_notify_user_info_new(); | |
| 4165 | ||
| 4166 | if(purple_str_has_prefix(who, "@E ")) { | |
| 4167 | purple_notify_user_info_add_pair(user_info, _("External User"), NULL); | |
| 10977 | 4168 | } |
| 4169 | ||
| 15884 | 4170 | purple_notify_user_info_add_pair(user_info, _("User ID"), who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4171 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4172 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4173 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4174 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4175 | if(purple_buddy_get_server_alias(b)) { |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4176 | purple_notify_user_info_add_pair(user_info, _("Full Name"), purple_buddy_get_server_alias(b)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4177 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4178 | |
| 15884 | 4179 | 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
|
4180 | if(type) { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4181 | tmp = g_strdup(mw_client_name(type)); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4182 | if (!tmp) |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4183 | tmp = g_strdup_printf(_("Unknown (0x%04x)<br>"), type); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4184 | |
| 15884 | 4185 | purple_notify_user_info_add_pair(user_info, _("Last Known Client"), tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4186 | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4187 | g_free(tmp); |
| 10977 | 4188 | } |
| 4189 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4190 | |
| 10977 | 4191 | tmp = user_supports_text(pd->srvc_aware, who); |
| 4192 | if(tmp) { | |
| 15884 | 4193 | purple_notify_user_info_add_pair(user_info, _("Supports"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4194 | g_free(tmp); |
| 10977 | 4195 | } |
| 4196 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4197 | if(b) { |
| 15884 | 4198 | purple_notify_user_info_add_pair(user_info, _("Status"), status_text(b)); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4199 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4200 | /* 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
|
4201 | 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
|
4202 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4203 | tmp = g_markup_escape_text(tmp2, -1); |
| 15884 | 4204 | purple_notify_user_info_add_section_break(user_info); |
| 4205 | purple_notify_user_info_add_pair(user_info, NULL, tmp); | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4206 | g_free(tmp); |
|
12496
788b20ccec91
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4207 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4208 | } |
| 10977 | 4209 | |
| 4210 | /* @todo emit a signal to allow a plugin to override the display of | |
| 4211 | this notification, so that it can create its own */ | |
| 4212 | ||
| 15884 | 4213 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 4214 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 4215 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4216 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4217 | |
| 15884 | 4218 | static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status) { |
| 4219 | PurpleConnection *gc; | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4220 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
4221 | char *message = NULL; |
| 10977 | 4222 | struct mwSession *session; |
| 4223 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4224 | |
| 10977 | 4225 | g_return_if_fail(acct != NULL); |
| 15884 | 4226 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4227 | |
| 15884 | 4228 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4229 | |
| 15884 | 4230 | 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
|
4231 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4232 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4233 | |
| 10977 | 4234 | session = gc_to_session(gc); |
| 4235 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4236 | |
| 10977 | 4237 | /* get a working copy of the current status */ |
| 4238 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4239 | |
| 10977 | 4240 | /* determine the state */ |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4241 | if(! strcmp(state, MW_STATE_ACTIVE)) { |
| 10977 | 4242 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4243 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4244 | } else if(! strcmp(state, MW_STATE_AWAY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4245 | stat.status = mwStatus_AWAY; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4246 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4247 | } else if(! strcmp(state, MW_STATE_BUSY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4248 | stat.status = mwStatus_BUSY; |
| 10977 | 4249 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4250 | |
| 10977 | 4251 | /* determine the message */ |
| 15884 | 4252 | 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
|
4253 | |
| 10977 | 4254 | if(message) { |
| 4255 | /* all the possible non-NULL values of message up to this point | |
| 4256 | are const, so we don't need to free them */ | |
| 15884 | 4257 | message = purple_markup_strip_html(message); |
| 10977 | 4258 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4259 | |
| 10977 | 4260 | /* out with the old */ |
| 4261 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4262 | |
| 10977 | 4263 | /* in with the new */ |
| 4264 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4265 | |
| 10977 | 4266 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4267 | mwUserStatus_clear(&stat); |
| 10977 | 4268 | } |
| 4269 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4270 | |
| 15884 | 4271 | static void mw_prpl_set_idle(PurpleConnection *gc, int t) { |
| 10977 | 4272 | struct mwSession *session; |
| 4273 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4274 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4275 | |
| 10977 | 4276 | session = gc_to_session(gc); |
| 4277 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4278 | |
| 10977 | 4279 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4280 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4281 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4282 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4283 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4284 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4285 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4286 | stat.time = 0; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4287 | } |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4288 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4289 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4290 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4291 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4292 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4293 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4294 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4295 | stat.status = mwStatus_ACTIVE; |
| 4296 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4297 | |
| 10977 | 4298 | mwSession_setUserStatus(session, &stat); |
| 4299 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4300 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4301 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4302 | |
| 15884 | 4303 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4304 | PurpleAccount *acct; | |
| 4305 | PurpleConversation *conv; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4306 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4307 | |
| 15884 | 4308 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4309 | id = g_list_nth_data(row, 1); |
| 15884 | 4310 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, id, acct); |
| 4311 | if(! conv) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, id); | |
| 4312 | purple_conversation_present(conv); | |
| 4313 | } | |
| 4314 | ||
| 4315 | ||
| 4316 | 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
|
4317 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4318 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4319 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4320 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4321 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4322 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4323 | |
| 15884 | 4324 | 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
|
4325 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4326 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4327 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4328 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4329 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4330 | static void notify_close(gpointer data) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4331 | if (data) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4332 | g_free(data); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4333 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4334 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4335 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4336 | |
| 10977 | 4337 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4338 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4339 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4340 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4341 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4342 | char *msg; |
| 10977 | 4343 | |
| 15884 | 4344 | PurpleNotifySearchResults *sres; |
| 4345 | PurpleNotifySearchColumn *scol; | |
| 4346 | ||
| 4347 | sres = purple_notify_searchresults_new(); | |
| 4348 | ||
| 4349 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4350 | purple_notify_searchresults_column_add(sres, scol); | |
| 4351 | ||
| 4352 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4353 | purple_notify_searchresults_column_add(sres, scol); | |
| 4354 | ||
| 4355 | 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
|
4356 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4357 | |
| 15884 | 4358 | 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
|
4359 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4360 | |
| 10977 | 4361 | for(l = result->matches; l; l = l->next) { |
| 4362 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4363 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4364 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4365 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4366 | NSTR(match->id), NSTR(match->name)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4367 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4368 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4369 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4370 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4371 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4372 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4373 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4374 | } |
| 10977 | 4375 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4376 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4377 | 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
|
4378 | " 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
|
4379 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4380 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4381 | |
| 15884 | 4382 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4383 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4384 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4385 | g_free(msg); |
| 10977 | 4386 | } |
| 4387 | ||
| 4388 | ||
| 4389 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4390 | guint32 id, guint32 code, GList *results, | |
| 4391 | gpointer b) { | |
| 4392 | ||
| 4393 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4394 | BuddyAddData *data = b; |
| 15884 | 4395 | PurpleBuddy *buddy = NULL; |
| 4396 | PurpleConnection *gc; | |
| 4397 | struct mwPurplePluginData *pd; | |
| 10977 | 4398 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4399 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4400 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4401 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4402 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4403 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
| 10977 | 4404 | pd = gc->proto_data; |
| 4405 | ||
| 4406 | if(results) | |
| 4407 | res = results->data; | |
| 4408 | ||
| 4409 | 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
|
4410 | if(!res->matches->next) { |
| 10977 | 4411 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4412 | |
| 10977 | 4413 | /* only one? that might be the right one! */ |
| 4414 | if(strcmp(res->name, match->id)) { | |
| 4415 | /* uh oh, the single result isn't identical to the search | |
| 4416 | term, better safe then sorry, so let's make sure it's who | |
| 4417 | the user meant to add */ | |
| 15884 | 4418 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4419 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4420 | |
| 10977 | 4421 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4422 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4423 | /* same person, set the server alias */ |
| 15884 | 4424 | purple_blist_server_alias_buddy(buddy, match->name); |
| 4425 | purple_blist_node_set_string((PurpleBlistNode *) buddy, | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4426 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4427 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4428 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4429 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4430 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4431 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4432 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4433 | g_free(data); |
| 10977 | 4434 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4435 | |
| 10977 | 4436 | } else { |
| 4437 | /* prompt user if more than one match was returned */ | |
| 15884 | 4438 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4439 | multi_resolved_query(res, gc, data); |
| 10977 | 4440 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4441 | |
| 10977 | 4442 | return; |
| 4443 | } | |
| 4444 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4445 | #if 0 |
| 10977 | 4446 | /* fall-through indicates that we couldn't find a matching user in |
| 4447 | the resolve service (ether error or zero results), so we remove | |
| 4448 | this buddy */ | |
| 4449 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4450 | /* 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
|
4451 | 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
|
4452 | 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
|
4453 | 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
|
4454 | 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
|
4455 | |
| 10977 | 4456 | DEBUG_INFO("no such buddy in community\n"); |
| 15884 | 4457 | purple_blist_remove_buddy(buddy); |
| 10977 | 4458 | blist_schedule(pd); |
| 4459 | ||
| 4460 | if(res && res->name) { | |
| 4461 | /* compose and display an error message */ | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4462 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4463 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4464 | char *msg; |
| 10977 | 4465 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4466 | msgA = _("Unable to add user: user not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4467 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4468 | 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
|
4469 | " Sametime community. This entry has been removed from" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4470 | " your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4471 | msg = g_strdup_printf(msgB, NSTR(res->name)); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4472 | |
| 15884 | 4473 | purple_notify_error(gc, _("Unable to add user"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4474 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4475 | g_free(msg); |
| 10977 | 4476 | } |
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4477 | #endif |
| 10977 | 4478 | } |
| 4479 | ||
| 4480 | ||
| 15884 | 4481 | static void mw_prpl_add_buddy(PurpleConnection *gc, |
| 4482 | PurpleBuddy *buddy, | |
| 4483 | PurpleGroup *group) { | |
| 4484 | ||
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4485 | struct mwPurplePluginData *pd = gc->proto_data; |
| 10977 | 4486 | struct mwServiceResolve *srvc; |
| 4487 | GList *query; | |
| 4488 | enum mwResolveFlag flags; | |
| 4489 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4490 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4491 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4492 | /* 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
|
4493 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4494 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4495 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4496 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4497 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4498 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4499 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4500 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4501 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4502 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4503 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4504 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4505 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4506 | ||
| 4507 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4508 | data, NULL); |
| 10977 | 4509 | g_list_free(query); |
| 4510 | ||
| 4511 | if(req == SEARCH_ERROR) { | |
| 15884 | 4512 | purple_blist_remove_buddy(buddy); |
| 10977 | 4513 | blist_schedule(pd); |
| 4514 | } | |
| 4515 | } | |
| 4516 | ||
| 4517 | ||
| 15884 | 4518 | static void foreach_add_buddies(PurpleGroup *group, GList *buddies, |
| 4519 | struct mwPurplePluginData *pd) { | |
| 10977 | 4520 | struct mwAwareList *list; |
| 4521 | ||
| 4522 | list = list_ensure(pd, group); | |
| 4523 | mwAwareList_addAware(list, buddies); | |
| 4524 | g_list_free(buddies); | |
| 4525 | } | |
| 4526 | ||
| 4527 | ||
| 15884 | 4528 | static void mw_prpl_add_buddies(PurpleConnection *gc, |
| 10977 | 4529 | GList *buddies, |
| 4530 | GList *groups) { | |
| 4531 | ||
| 15884 | 4532 | struct mwPurplePluginData *pd; |
| 10977 | 4533 | GHashTable *group_sets; |
| 4534 | struct mwAwareIdBlock *idbs, *idb; | |
| 4535 | ||
| 4536 | pd = gc->proto_data; | |
| 4537 | ||
| 15884 | 4538 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4539 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4540 | ||
| 4541 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4542 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4543 | ||
| 4544 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4545 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4546 | PurpleBuddy *b = buddies->data; |
| 4547 | PurpleGroup *g; | |
| 10977 | 4548 | const char *fn; |
| 4549 | GList *l; | |
| 4550 | ||
| 4551 | /* nab the saved server alias and stick it on the buddy */ | |
| 15884 | 4552 | fn = purple_blist_node_get_string((PurpleBlistNode *) b, BUDDY_KEY_NAME); |
| 4553 | purple_blist_server_alias_buddy(b, fn); | |
| 4554 | ||
| 4555 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4556 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4557 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4558 | idb->community = NULL; |
| 4559 | ||
| 4560 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4561 | g = purple_buddy_get_group(b); |
| 10977 | 4562 | l = g_hash_table_lookup(group_sets, g); |
| 4563 | l = g_list_prepend(l, idb++); | |
| 4564 | g_hash_table_insert(group_sets, g, l); | |
| 4565 | } | |
| 4566 | ||
| 4567 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4568 | for saving */ | |
| 4569 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4570 | blist_schedule(pd); | |
| 4571 | ||
| 4572 | /* cleanup */ | |
| 4573 | g_hash_table_destroy(group_sets); | |
| 4574 | g_free(idbs); | |
| 4575 | } | |
| 4576 | ||
| 4577 | ||
| 15884 | 4578 | static void mw_prpl_remove_buddy(PurpleConnection *gc, |
| 4579 | PurpleBuddy *buddy, PurpleGroup *group) { | |
| 4580 | ||
| 4581 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4582 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4583 | struct mwAwareList *list; |
| 4584 | ||
| 4585 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4586 | ||
| 4587 | pd = gc->proto_data; | |
| 15884 | 4588 | group = purple_buddy_get_group(buddy); |
| 10977 | 4589 | list = list_ensure(pd, group); |
| 4590 | ||
| 4591 | mwAwareList_removeAware(list, rem); | |
| 4592 | blist_schedule(pd); | |
| 4593 | ||
| 4594 | g_list_free(rem); | |
| 4595 | } | |
| 4596 | ||
| 4597 | ||
| 4598 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4599 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4600 | |
| 10977 | 4601 | struct mwUserItem *u; |
| 4602 | guint count; | |
| 4603 | ||
| 4604 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4605 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4606 | |
| 4607 | priv->count = count; | |
| 4608 | priv->users = g_new0(struct mwUserItem, count); | |
| 4609 | ||
| 4610 | while(count--) { | |
| 4611 | u = priv->users + count; | |
| 4612 | u->id = members->data; | |
| 4613 | members = members->next; | |
| 4614 | } | |
| 4615 | } | |
| 4616 | ||
| 4617 | ||
| 15884 | 4618 | static void mw_prpl_set_permit_deny(PurpleConnection *gc) { |
| 4619 | PurpleAccount *acct; | |
| 4620 | struct mwPurplePluginData *pd; | |
| 10977 | 4621 | struct mwSession *session; |
| 4622 | ||
| 4623 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4624 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4625 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4626 | NULL, /* users */ |
| 10977 | 4627 | }; |
| 4628 | ||
| 4629 | g_return_if_fail(gc != NULL); | |
| 4630 | ||
| 15884 | 4631 | acct = purple_connection_get_account(gc); |
| 10977 | 4632 | g_return_if_fail(acct != NULL); |
| 4633 | ||
| 4634 | pd = gc->proto_data; | |
| 4635 | g_return_if_fail(pd != NULL); | |
| 4636 | ||
| 4637 | session = pd->session; | |
| 4638 | g_return_if_fail(session != NULL); | |
| 4639 | ||
| 4640 | switch(acct->perm_deny) { | |
| 15884 | 4641 | case PURPLE_PRIVACY_DENY_USERS: |
| 4642 | DEBUG_INFO("PURPLE_PRIVACY_DENY_USERS\n"); | |
| 10977 | 4643 | privacy_fill(&privacy, acct->deny); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4644 | privacy.deny = TRUE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4645 | break; |
| 10977 | 4646 | |
| 15884 | 4647 | case PURPLE_PRIVACY_ALLOW_ALL: |
| 4648 | DEBUG_INFO("PURPLE_PRIVACY_ALLOW_ALL\n"); | |
| 10977 | 4649 | privacy.deny = TRUE; |
| 4650 | break; | |
| 4651 | ||
| 15884 | 4652 | case PURPLE_PRIVACY_ALLOW_USERS: |
| 4653 | DEBUG_INFO("PURPLE_PRIVACY_ALLOW_USERS\n"); | |
| 10977 | 4654 | privacy_fill(&privacy, acct->permit); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4655 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4656 | break; |
| 10977 | 4657 | |
| 15884 | 4658 | case PURPLE_PRIVACY_DENY_ALL: |
| 4659 | DEBUG_INFO("PURPLE_PRIVACY_DENY_ALL\n"); | |
| 10977 | 4660 | privacy.deny = FALSE; |
| 4661 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4662 | |
| 10977 | 4663 | default: |
| 4664 | DEBUG_INFO("acct->perm_deny is 0x%x\n", acct->perm_deny); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4665 | return; |
| 10977 | 4666 | } |
| 4667 | ||
| 4668 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4669 | g_free(privacy.users); | |
| 4670 | } | |
| 4671 | ||
| 4672 | ||
| 15884 | 4673 | static void mw_prpl_add_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4674 | mw_prpl_set_permit_deny(gc); |
| 4675 | } | |
| 4676 | ||
| 4677 | ||
| 15884 | 4678 | static void mw_prpl_add_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4679 | mw_prpl_set_permit_deny(gc); |
| 4680 | } | |
| 4681 | ||
| 4682 | ||
| 15884 | 4683 | static void mw_prpl_rem_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4684 | mw_prpl_set_permit_deny(gc); |
| 4685 | } | |
| 4686 | ||
| 4687 | ||
| 15884 | 4688 | static void mw_prpl_rem_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4689 | mw_prpl_set_permit_deny(gc); |
| 4690 | } | |
| 4691 | ||
| 4692 | ||
| 4693 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4694 | const char *name) { | |
| 4695 | GList *l, *ll; | |
| 4696 | struct mwConference *conf = NULL; | |
| 4697 | ||
| 4698 | ll = mwServiceConference_getConferences(srvc); | |
| 4699 | for(l = ll; l; l = l->next) { | |
| 4700 | struct mwConference *c = l->data; | |
| 4701 | if(! strcmp(name, mwConference_getName(c))) { | |
| 4702 | conf = c; | |
| 4703 | break; | |
| 4704 | } | |
| 4705 | } | |
| 4706 | g_list_free(ll); | |
| 4707 | ||
| 4708 | return conf; | |
| 4709 | } | |
| 4710 | ||
| 4711 | ||
| 15884 | 4712 | static void mw_prpl_join_chat(PurpleConnection *gc, |
| 10977 | 4713 | GHashTable *components) { |
| 4714 | ||
| 15884 | 4715 | struct mwPurplePluginData *pd; |
| 10977 | 4716 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4717 | |
| 10977 | 4718 | pd = gc->proto_data; |
| 4719 | ||
| 4720 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4721 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4722 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4723 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4724 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4725 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4726 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4727 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4728 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4729 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4730 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4731 | |
| 10977 | 4732 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4733 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4734 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4735 | struct mwConference *conf = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4736 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4737 | srvc = pd->srvc_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4738 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4739 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4740 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4741 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4742 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4743 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4744 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4745 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4746 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4747 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4748 | } |
| 10977 | 4749 | } |
| 4750 | } | |
| 4751 | ||
| 4752 | ||
| 15884 | 4753 | static void mw_prpl_reject_chat(PurpleConnection *gc, |
| 10977 | 4754 | GHashTable *components) { |
| 4755 | ||
| 15884 | 4756 | struct mwPurplePluginData *pd; |
| 10977 | 4757 | struct mwServiceConference *srvc; |
| 4758 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4759 | |
| 10977 | 4760 | pd = gc->proto_data; |
| 4761 | srvc = pd->srvc_conf; | |
| 4762 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4763 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4764 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4765 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4766 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4767 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4768 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4769 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4770 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4771 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4772 | } |
| 10977 | 4773 | } |
| 4774 | } | |
| 4775 | ||
| 4776 | ||
| 4777 | static char *mw_prpl_get_chat_name(GHashTable *components) { | |
| 4778 | return g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4779 | } | |
| 4780 | ||
| 4781 | ||
| 15884 | 4782 | static void mw_prpl_chat_invite(PurpleConnection *gc, |
| 10977 | 4783 | int id, |
| 4784 | const char *invitation, | |
| 4785 | const char *who) { | |
| 4786 | ||
| 15884 | 4787 | struct mwPurplePluginData *pd; |
| 10977 | 4788 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4789 | struct mwPlace *place; |
| 10977 | 4790 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4791 | ||
| 4792 | pd = gc->proto_data; | |
| 4793 | g_return_if_fail(pd != NULL); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4794 | |
| 10977 | 4795 | conf = ID_TO_CONF(pd, id); |
| 4796 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4797 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4798 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4799 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4800 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4801 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4802 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4803 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4804 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4805 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4806 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4807 | } |
| 4808 | ||
| 4809 | ||
| 15884 | 4810 | static void mw_prpl_chat_leave(PurpleConnection *gc, |
| 10977 | 4811 | int id) { |
| 4812 | ||
| 15884 | 4813 | struct mwPurplePluginData *pd; |
| 10977 | 4814 | struct mwConference *conf; |
| 4815 | ||
| 4816 | pd = gc->proto_data; | |
| 4817 | ||
| 4818 | g_return_if_fail(pd != NULL); | |
| 4819 | conf = ID_TO_CONF(pd, id); | |
| 4820 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4821 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4822 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4823 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4824 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4825 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4826 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4827 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4828 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4829 | } |
| 10977 | 4830 | } |
| 4831 | ||
| 4832 | ||
| 15884 | 4833 | static void mw_prpl_chat_whisper(PurpleConnection *gc, |
| 10977 | 4834 | int id, |
| 4835 | const char *who, | |
| 4836 | const char *message) { | |
| 4837 | ||
| 4838 | mw_prpl_send_im(gc, who, message, 0); | |
| 4839 | } | |
| 4840 | ||
| 4841 | ||
| 15884 | 4842 | static int mw_prpl_chat_send(PurpleConnection *gc, |
| 10977 | 4843 | int id, |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4844 | const char *message, |
| 15884 | 4845 | PurpleMessageFlags flags) { |
| 4846 | ||
| 4847 | struct mwPurplePluginData *pd; | |
| 10977 | 4848 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4849 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4850 | int ret; |
| 10977 | 4851 | |
| 4852 | pd = gc->proto_data; | |
| 4853 | ||
| 4854 | g_return_val_if_fail(pd != NULL, 0); | |
| 4855 | conf = ID_TO_CONF(pd, id); | |
| 4856 | ||
| 15884 | 4857 | msg = purple_markup_strip_html(message); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4858 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4859 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4860 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4861 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4862 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4863 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4864 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4865 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4866 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4867 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4868 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4869 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4870 | return ret; |
| 10977 | 4871 | } |
| 4872 | ||
| 4873 | ||
| 15884 | 4874 | static void mw_prpl_keepalive(PurpleConnection *gc) { |
| 10977 | 4875 | struct mwSession *session; |
| 4876 | ||
| 4877 | g_return_if_fail(gc != NULL); | |
| 4878 | ||
| 4879 | session = gc_to_session(gc); | |
| 4880 | g_return_if_fail(session != NULL); | |
| 4881 | ||
| 4882 | mwSession_sendKeepalive(session); | |
| 4883 | } | |
| 4884 | ||
| 4885 | ||
| 15884 | 4886 | static void mw_prpl_alias_buddy(PurpleConnection *gc, |
| 10977 | 4887 | const char *who, |
| 4888 | const char *alias) { | |
| 4889 | ||
| 15884 | 4890 | struct mwPurplePluginData *pd = gc->proto_data; |
| 10977 | 4891 | g_return_if_fail(pd != NULL); |
| 4892 | ||
| 4893 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4894 | the server copy */ | |
| 4895 | ||
| 4896 | blist_schedule(pd); | |
| 4897 | } | |
| 4898 | ||
| 4899 | ||
| 15884 | 4900 | static void mw_prpl_group_buddy(PurpleConnection *gc, |
| 10977 | 4901 | const char *who, |
| 4902 | const char *old_group, | |
| 4903 | const char *new_group) { | |
| 4904 | ||
| 4905 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 4906 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4907 | ||
| 15884 | 4908 | struct mwPurplePluginData *pd = gc->proto_data; |
| 4909 | PurpleGroup *group; | |
| 10977 | 4910 | struct mwAwareList *list; |
| 4911 | ||
| 4912 | /* add who to new_group's aware list */ | |
| 15884 | 4913 | group = purple_find_group(new_group); |
| 10977 | 4914 | list = list_ensure(pd, group); |
| 4915 | mwAwareList_addAware(list, gl); | |
| 4916 | ||
| 4917 | /* remove who from old_group's aware list */ | |
| 15884 | 4918 | group = purple_find_group(old_group); |
| 10977 | 4919 | list = list_ensure(pd, group); |
| 4920 | mwAwareList_removeAware(list, gl); | |
| 4921 | ||
| 4922 | g_list_free(gl); | |
| 4923 | ||
| 4924 | /* schedule the changes to be saved */ | |
| 4925 | blist_schedule(pd); | |
| 4926 | } | |
| 4927 | ||
| 4928 | ||
| 15884 | 4929 | static void mw_prpl_rename_group(PurpleConnection *gc, |
| 10977 | 4930 | const char *old, |
| 15884 | 4931 | PurpleGroup *group, |
| 10977 | 4932 | GList *buddies) { |
| 4933 | ||
| 15884 | 4934 | struct mwPurplePluginData *pd = gc->proto_data; |
| 10977 | 4935 | g_return_if_fail(pd != NULL); |
| 4936 | ||
| 4937 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4938 | the server copy. Also, having this function should prevent all | |
| 4939 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4940 | give a crap what the group is named in Purple other than to record |
| 10977 | 4941 | that as the group name/alias */ |
| 4942 | ||
| 4943 | blist_schedule(pd); | |
| 4944 | } | |
| 4945 | ||
| 4946 | ||
| 15884 | 4947 | static void mw_prpl_buddy_free(PurpleBuddy *buddy) { |
| 10977 | 4948 | /* I don't think we have any cleanup for buddies yet */ |
| 4949 | ; | |
| 4950 | } | |
| 4951 | ||
| 4952 | ||
| 15884 | 4953 | static void mw_prpl_convo_closed(PurpleConnection *gc, const char *who) { |
| 4954 | struct mwPurplePluginData *pd = gc->proto_data; | |
| 10977 | 4955 | struct mwServiceIm *srvc; |
| 4956 | struct mwConversation *conv; | |
| 4957 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4958 | ||
| 4959 | g_return_if_fail(pd != NULL); | |
| 4960 | ||
| 4961 | srvc = pd->srvc_im; | |
| 4962 | g_return_if_fail(srvc != NULL); | |
| 4963 | ||
| 4964 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 4965 | if(! conv) return; | |
| 4966 | ||
| 4967 | if(mwConversation_isOpen(conv)) | |
| 4968 | mwConversation_free(conv); | |
| 4969 | } | |
| 4970 | ||
| 4971 | ||
| 15884 | 4972 | static const char *mw_prpl_normalize(const PurpleAccount *account, |
| 10977 | 4973 | const char *id) { |
| 4974 | ||
| 4975 | /* code elsewhere assumes that the return value points to different | |
| 4976 | memory than the passed value, but it won't free the normalized | |
| 4977 | data. wtf? */ | |
| 4978 | ||
| 4979 | static char buf[BUF_LEN]; | |
| 4980 | strncpy(buf, id, sizeof(buf)); | |
| 4981 | return buf; | |
| 4982 | } | |
| 4983 | ||
| 4984 | ||
| 15884 | 4985 | static void mw_prpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { |
| 4986 | struct mwPurplePluginData *pd; | |
| 10977 | 4987 | struct mwAwareList *list; |
| 4988 | ||
| 4989 | pd = gc->proto_data; | |
| 4990 | g_return_if_fail(pd != NULL); | |
| 4991 | g_return_if_fail(pd->group_list_map != NULL); | |
| 4992 | ||
| 4993 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 4994 | ||
| 4995 | if(list) { | |
| 4996 | g_hash_table_remove(pd->group_list_map, list); | |
| 4997 | g_hash_table_remove(pd->group_list_map, group); | |
| 4998 | mwAwareList_free(list); | |
| 4999 | ||
| 5000 | blist_schedule(pd); | |
| 5001 | } | |
| 5002 | } | |
| 5003 | ||
| 5004 | ||
| 15884 | 5005 | static gboolean mw_prpl_can_receive_file(PurpleConnection *gc, |
| 10977 | 5006 | const char *who) { |
| 15884 | 5007 | struct mwPurplePluginData *pd; |
| 10977 | 5008 | struct mwServiceAware *srvc; |
| 15884 | 5009 | PurpleAccount *acct; |
| 10977 | 5010 | |
| 5011 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 5012 | ||
| 5013 | pd = gc->proto_data; | |
| 5014 | g_return_val_if_fail(pd != NULL, FALSE); | |
| 5015 | ||
| 5016 | srvc = pd->srvc_aware; | |
| 5017 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5018 | |
| 15884 | 5019 | acct = purple_connection_get_account(gc); |
| 10977 | 5020 | g_return_val_if_fail(acct != NULL, FALSE); |
| 5021 | ||
| 15884 | 5022 | return purple_find_buddy(acct, who) && |
| 10977 | 5023 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 5024 | } | |
| 5025 | ||
| 5026 | ||
| 15884 | 5027 | static void ft_outgoing_init(PurpleXfer *xfer) { |
| 5028 | PurpleAccount *acct; | |
| 5029 | PurpleConnection *gc; | |
| 5030 | ||
| 5031 | struct mwPurplePluginData *pd; | |
| 10977 | 5032 | struct mwServiceFileTransfer *srvc; |
| 5033 | struct mwFileTransfer *ft; | |
| 5034 | ||
| 5035 | const char *filename; | |
| 5036 | gsize filesize; | |
| 5037 | FILE *fp; | |
| 5038 | ||
| 5039 | struct mwIdBlock idb = { NULL, NULL }; | |
| 5040 | ||
| 5041 | DEBUG_INFO("ft_outgoing_init\n"); | |
| 5042 | ||
| 15884 | 5043 | acct = purple_xfer_get_account(xfer); |
| 5044 | gc = purple_account_get_connection(acct); | |
| 10977 | 5045 | pd = gc->proto_data; |
| 5046 | srvc = pd->srvc_ft; | |
| 5047 | ||
| 15884 | 5048 | filename = purple_xfer_get_local_filename(xfer); |
| 5049 | filesize = purple_xfer_get_size(xfer); | |
| 10977 | 5050 | idb.user = xfer->who; |
| 5051 | ||
| 15884 | 5052 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5053 | |
| 10977 | 5054 | /* test that we can actually send the file */ |
| 5055 | fp = g_fopen(filename, "rb"); | |
| 5056 | if(! fp) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5057 | 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
|
5058 | filename, g_strerror(errno)); |
| 15884 | 5059 | purple_xfer_error(purple_xfer_get_type(xfer), acct, xfer->who, msg); |
| 10977 | 5060 | g_free(msg); |
| 5061 | return; | |
| 5062 | } | |
| 5063 | fclose(fp); | |
| 5064 | ||
| 5065 | { | |
| 5066 | char *tmp = strrchr(filename, G_DIR_SEPARATOR); | |
| 5067 | if(tmp++) filename = tmp; | |
| 5068 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5069 | |
| 10977 | 5070 | ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); |
| 5071 | ||
| 15884 | 5072 | purple_xfer_ref(xfer); |
| 5073 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
| 10977 | 5074 | xfer->data = ft; |
| 5075 | ||
| 5076 | mwFileTransfer_offer(ft); | |
| 5077 | } | |
| 5078 | ||
| 5079 | ||
| 15884 | 5080 | static void ft_outgoing_cancel(PurpleXfer *xfer) { |
| 10977 | 5081 | struct mwFileTransfer *ft = xfer->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5082 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5083 | DEBUG_INFO("ft_outgoing_cancel called\n"); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5084 | |
| 10977 | 5085 | if(ft) mwFileTransfer_cancel(ft); |
| 5086 | } | |
| 5087 | ||
| 5088 | ||
| 15884 | 5089 | static PurpleXfer *mw_prpl_new_xfer(PurpleConnection *gc, const char *who) { |
| 5090 | PurpleAccount *acct; | |
| 5091 | PurpleXfer *xfer; | |
| 5092 | ||
| 5093 | acct = purple_connection_get_account(gc); | |
| 5094 | ||
| 5095 | xfer = purple_xfer_new(acct, PURPLE_XFER_SEND, who); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5096 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5097 | { |
| 15884 | 5098 | purple_xfer_set_init_fnc(xfer, ft_outgoing_init); |
| 5099 | purple_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5100 | } |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5101 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5102 | return xfer; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5103 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5104 | |
| 15884 | 5105 | static void mw_prpl_send_file(PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5106 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5107 | |
| 15884 | 5108 | PurpleXfer *xfer = mw_prpl_new_xfer(gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5109 | |
| 10977 | 5110 | if(file) { |
| 5111 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 5112 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 5113 | |
| 5114 | } else { | |
| 5115 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 5116 | purple_xfer_request(xfer); |
| 10977 | 5117 | } |
| 5118 | } | |
| 5119 | ||
| 5120 | ||
| 15884 | 5121 | static PurplePluginProtocolInfo mw_prpl_info = { |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5122 | OPT_PROTO_IM_IMAGE, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5123 | NULL, /*< set in mw_plugin_init */ |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5124 | NULL, /*< set in mw_plugin_init */ |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5125 | NO_BUDDY_ICONS, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5126 | mw_prpl_list_icon, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5127 | mw_prpl_list_emblem, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5128 | mw_prpl_status_text, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5129 | mw_prpl_tooltip_text, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5130 | mw_prpl_status_types, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5131 | mw_prpl_blist_node_menu, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5132 | mw_prpl_chat_info, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5133 | mw_prpl_chat_info_defaults, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5134 | mw_prpl_login, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5135 | mw_prpl_close, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5136 | mw_prpl_send_im, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5137 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5138 | mw_prpl_send_typing, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5139 | mw_prpl_get_info, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5140 | mw_prpl_set_status, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5141 | mw_prpl_set_idle, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5142 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5143 | mw_prpl_add_buddy, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5144 | mw_prpl_add_buddies, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5145 | mw_prpl_remove_buddy, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5146 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5147 | mw_prpl_add_permit, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5148 | mw_prpl_add_deny, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5149 | mw_prpl_rem_permit, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5150 | mw_prpl_rem_deny, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5151 | mw_prpl_set_permit_deny, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5152 | mw_prpl_join_chat, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5153 | mw_prpl_reject_chat, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5154 | mw_prpl_get_chat_name, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5155 | mw_prpl_chat_invite, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5156 | mw_prpl_chat_leave, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5157 | mw_prpl_chat_whisper, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5158 | mw_prpl_chat_send, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5159 | mw_prpl_keepalive, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5160 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5161 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5162 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5163 | mw_prpl_alias_buddy, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5164 | mw_prpl_group_buddy, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5165 | mw_prpl_rename_group, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5166 | mw_prpl_buddy_free, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5167 | mw_prpl_convo_closed, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5168 | mw_prpl_normalize, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5169 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5170 | mw_prpl_remove_group, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5171 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5172 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5173 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5174 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5175 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5176 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5177 | mw_prpl_can_receive_file, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5178 | mw_prpl_send_file, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5179 | mw_prpl_new_xfer, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5180 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5181 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5182 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5183 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5184 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5185 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5186 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5187 | sizeof(PurplePluginProtocolInfo), |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5188 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5189 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5190 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5191 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5192 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5193 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5194 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5195 | NULL |
| 10977 | 5196 | }; |
| 5197 | ||
| 5198 | ||
| 15884 | 5199 | static PurplePluginPrefFrame * |
| 5200 | mw_plugin_get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 5201 | PurplePluginPrefFrame *frame; | |
| 5202 | PurplePluginPref *pref; | |
| 5203 | ||
| 5204 | frame = purple_plugin_pref_frame_new(); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5205 | |
| 15884 | 5206 | pref = purple_plugin_pref_new_with_label(_("Remotely Stored Buddy List")); |
| 5207 | purple_plugin_pref_frame_add(frame, pref); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5208 | |
| 10977 | 5209 | |
| 15884 | 5210 | pref = purple_plugin_pref_new_with_name(MW_PRPL_OPT_BLIST_ACTION); |
| 5211 | purple_plugin_pref_set_label(pref, _("Buddy List Storage Mode")); | |
| 5212 | ||
| 5213 | purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE); | |
| 5214 | 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
|
5215 | GINT_TO_POINTER(blist_choice_LOCAL)); |
| 15884 | 5216 | 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
|
5217 | GINT_TO_POINTER(blist_choice_MERGE)); |
| 15884 | 5218 | 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
|
5219 | GINT_TO_POINTER(blist_choice_STORE)); |
| 15884 | 5220 | 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
|
5221 | GINT_TO_POINTER(blist_choice_SYNCH)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5222 | |
| 15884 | 5223 | purple_plugin_pref_frame_add(frame, pref); |
| 10977 | 5224 | |
| 5225 | return frame; | |
| 5226 | } | |
| 5227 | ||
| 5228 | ||
| 15884 | 5229 | static PurplePluginUiInfo mw_plugin_ui_info = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5230 | mw_plugin_get_plugin_pref_frame, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5231 | 0, /* page_num */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5232 | NULL, /* frame */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5233 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5234 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5235 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5236 | NULL |
| 10977 | 5237 | }; |
| 5238 | ||
| 5239 | ||
| 15884 | 5240 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5241 | struct mwSametimeList *l; |
| 5242 | ||
| 5243 | FILE *file; | |
| 5244 | char buf[BUF_LEN]; | |
| 5245 | size_t len; | |
| 5246 | ||
| 5247 | GString *str; | |
| 5248 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5249 | file = g_fopen(filename, "r"); |
| 10977 | 5250 | g_return_if_fail(file != NULL); |
| 5251 | ||
| 5252 | str = g_string_new(NULL); | |
| 5253 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 5254 | g_string_append_len(str, buf, len); | |
| 5255 | } | |
| 5256 | ||
| 5257 | fclose(file); | |
| 5258 | ||
| 5259 | l = mwSametimeList_load(str->str); | |
| 5260 | g_string_free(str, TRUE); | |
| 5261 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5262 | blist_merge(gc, l); |
| 10977 | 5263 | mwSametimeList_free(l); |
| 5264 | } | |
| 5265 | ||
| 5266 | ||
| 5267 | /** prompts for a file to import blist from */ | |
| 15884 | 5268 | static void st_import_action(PurplePluginAction *act) { |
| 5269 | PurpleConnection *gc; | |
| 5270 | PurpleAccount *account; | |
| 10977 | 5271 | char *title; |
| 5272 | ||
| 5273 | gc = act->context; | |
| 15884 | 5274 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5275 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 5276 | purple_account_get_username(account)); |
| 5277 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5278 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 5279 | 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
|
5280 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5281 | gc); |
| 10977 | 5282 | |
| 5283 | g_free(title); | |
| 5284 | } | |
| 5285 | ||
| 5286 | ||
| 15884 | 5287 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5288 | struct mwSametimeList *l; |
| 5289 | char *str; | |
| 5290 | FILE *file; | |
| 5291 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5292 | file = g_fopen(filename, "w"); |
| 10977 | 5293 | g_return_if_fail(file != NULL); |
| 5294 | ||
| 5295 | l = mwSametimeList_new(); | |
| 5296 | blist_export(gc, l); | |
| 5297 | str = mwSametimeList_store(l); | |
| 5298 | mwSametimeList_free(l); | |
| 5299 | ||
| 5300 | fprintf(file, "%s", str); | |
| 5301 | fclose(file); | |
| 5302 | ||
| 5303 | g_free(str); | |
| 5304 | } | |
| 5305 | ||
| 5306 | ||
| 5307 | /** prompts for a file to export blist to */ | |
| 15884 | 5308 | static void st_export_action(PurplePluginAction *act) { |
| 5309 | PurpleConnection *gc; | |
| 5310 | PurpleAccount *account; | |
| 10977 | 5311 | char *title; |
| 5312 | ||
| 5313 | gc = act->context; | |
| 15884 | 5314 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5315 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 5316 | purple_account_get_username(account)); |
| 5317 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5318 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 5319 | 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
|
5320 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5321 | gc); |
| 10977 | 5322 | |
| 5323 | g_free(title); | |
| 5324 | } | |
| 5325 | ||
| 5326 | ||
| 5327 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 5328 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5329 | |
| 15884 | 5330 | 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
|
5331 | GList *l; |
| 10977 | 5332 | |
| 15884 | 5333 | f = purple_request_fields_get_field(fields, "group"); |
| 5334 | l = purple_request_field_list_get_items(f); | |
| 10977 | 5335 | |
| 5336 | for(; l; l = l->next) { | |
| 5337 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5338 | struct named_id *res; |
| 10977 | 5339 | |
| 15884 | 5340 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5341 | |
| 5342 | g_free(res->id); | |
| 5343 | g_free(res->name); | |
| 5344 | g_free(res); | |
| 5345 | } | |
| 5346 | } | |
| 5347 | ||
| 5348 | ||
| 15884 | 5349 | static void remote_group_done(struct mwPurplePluginData *pd, |
| 10977 | 5350 | const char *id, const char *name) { |
| 15884 | 5351 | PurpleConnection *gc; |
| 5352 | PurpleAccount *acct; | |
| 5353 | PurpleGroup *group; | |
| 5354 | PurpleBlistNode *gn; | |
| 10977 | 5355 | const char *owner; |
| 5356 | ||
| 5357 | g_return_if_fail(pd != NULL); | |
| 5358 | ||
| 5359 | gc = pd->gc; | |
| 15884 | 5360 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5361 | |
| 10977 | 5362 | /* collision checking */ |
| 15884 | 5363 | group = purple_find_group(name); |
| 10977 | 5364 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5365 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5366 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5367 | char *msg; |
| 10977 | 5368 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5369 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5370 | 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
|
5371 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5372 | |
| 15884 | 5373 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5374 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5375 | g_free(msg); |
| 10977 | 5376 | return; |
| 5377 | } | |
| 5378 | ||
| 15884 | 5379 | group = purple_group_new(name); |
| 5380 | gn = (PurpleBlistNode *) group; | |
| 5381 | ||
| 5382 | owner = purple_account_get_username(acct); | |
| 5383 | ||
| 5384 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 5385 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 5386 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 5387 | purple_blist_add_group(group, NULL); | |
| 10977 | 5388 | |
| 5389 | group_add(pd, group); | |
| 5390 | blist_schedule(pd); | |
| 5391 | } | |
| 5392 | ||
| 5393 | ||
| 15884 | 5394 | static void remote_group_multi_cb(struct mwPurplePluginData *pd, |
| 5395 | PurpleRequestFields *fields) { | |
| 5396 | 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
|
5397 | GList *l; |
| 10977 | 5398 | |
| 15884 | 5399 | f = purple_request_fields_get_field(fields, "group"); |
| 5400 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 5401 | |
| 5402 | if(l) { | |
| 5403 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5404 | struct named_id *res; |
| 10977 | 5405 | |
| 15884 | 5406 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5407 | remote_group_done(pd, res->id, res->name); |
| 5408 | } | |
| 5409 | ||
| 5410 | remote_group_multi_cleanup(NULL, fields); | |
| 5411 | } | |
| 5412 | ||
| 5413 | ||
| 5414 | static void remote_group_multi(struct mwResolveResult *result, | |
| 15884 | 5415 | struct mwPurplePluginData *pd) { |
| 5416 | ||
| 5417 | PurpleRequestFields *fields; | |
| 5418 | PurpleRequestFieldGroup *g; | |
| 5419 | PurpleRequestField *f; | |
| 10977 | 5420 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5421 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5422 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5423 | char *msg; |
| 10977 | 5424 | |
| 15884 | 5425 | PurpleConnection *gc = pd->gc; |
| 5426 | ||
| 5427 | fields = purple_request_fields_new(); | |
| 5428 | ||
| 5429 | g = purple_request_field_group_new(NULL); | |
| 5430 | purple_request_fields_add_group(fields, g); | |
| 5431 | ||
| 5432 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 5433 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 5434 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 5435 | |
| 5436 | for(l = result->matches; l; l = l->next) { | |
| 5437 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5438 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 5439 | |
| 5440 | res->id = g_strdup(match->id); | |
| 5441 | res->name = g_strdup(match->name); | |
| 5442 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
5443 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 5444 | } |
| 5445 | ||
| 15884 | 5446 | purple_request_field_group_add_field(g, f); |
| 10977 | 5447 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5448 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5449 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 5450 | " Notes Address Book groups. Please select the correct group from" |
| 5451 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5452 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 5453 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5454 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5455 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5456 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5457 | _("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
|
5458 | purple_connection_get_account(gc), result->name, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5459 | pd); |
| 10977 | 5460 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5461 | g_free(msg); |
| 10977 | 5462 | } |
| 5463 | ||
| 5464 | ||
| 5465 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 5466 | guint32 id, guint32 code, GList *results, | |
| 5467 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5468 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5469 | struct mwResolveResult *res = NULL; |
| 10977 | 5470 | struct mwSession *session; |
| 15884 | 5471 | struct mwPurplePluginData *pd; |
| 5472 | PurpleConnection *gc; | |
| 10977 | 5473 | |
| 5474 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5475 | g_return_if_fail(session != NULL); | |
| 5476 | ||
| 5477 | pd = mwSession_getClientData(session); | |
| 5478 | g_return_if_fail(pd != NULL); | |
| 5479 | ||
| 5480 | gc = pd->gc; | |
| 5481 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5482 | |
| 10977 | 5483 | if(!code && results) { |
| 5484 | res = results->data; | |
| 5485 | ||
| 5486 | if(res->matches) { | |
| 5487 | remote_group_multi(res, pd); | |
| 5488 | return; | |
| 5489 | } | |
| 5490 | } | |
| 5491 | ||
| 5492 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5493 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5494 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5495 | char *msg; |
| 10977 | 5496 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5497 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5498 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5499 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5500 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5501 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5502 | |
| 15884 | 5503 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5504 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5505 | g_free(msg); |
| 10977 | 5506 | } |
| 5507 | } | |
| 5508 | ||
| 5509 | ||
| 15884 | 5510 | static void remote_group_action_cb(PurpleConnection *gc, const char *name) { |
| 5511 | struct mwPurplePluginData *pd; | |
| 10977 | 5512 | struct mwServiceResolve *srvc; |
| 5513 | GList *query; | |
| 5514 | enum mwResolveFlag flags; | |
| 5515 | guint32 req; | |
| 5516 | ||
| 5517 | pd = gc->proto_data; | |
| 5518 | srvc = pd->srvc_resolve; | |
| 5519 | ||
| 5520 | query = g_list_prepend(NULL, (char *) name); | |
| 5521 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5522 | |
| 10977 | 5523 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5524 | NULL, NULL); | |
| 5525 | g_list_free(query); | |
| 5526 | ||
| 5527 | if(req == SEARCH_ERROR) { | |
| 5528 | /** @todo display error */ | |
| 5529 | } | |
| 5530 | } | |
| 5531 | ||
| 5532 | ||
| 15884 | 5533 | static void remote_group_action(PurplePluginAction *act) { |
| 5534 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5535 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5536 | const char *msgB; |
| 10977 | 5537 | |
| 5538 | gc = act->context; | |
| 5539 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5540 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5541 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5542 | " to add the group and its members to your buddy list."); |
| 5543 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5544 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5545 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5546 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5547 | _("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
|
5548 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5549 | gc); |
| 10977 | 5550 | } |
| 5551 | ||
| 5552 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5553 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5554 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5555 | GList *l; |
|
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; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5558 | char *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5559 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5560 | |
| 15884 | 5561 | PurpleNotifySearchResults *sres; |
| 5562 | PurpleNotifySearchColumn *scol; | |
| 5563 | ||
| 5564 | sres = purple_notify_searchresults_new(); | |
| 5565 | ||
| 5566 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5567 | purple_notify_searchresults_column_add(sres, scol); | |
| 5568 | ||
| 5569 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5570 | purple_notify_searchresults_column_add(sres, scol); | |
| 5571 | ||
| 5572 | 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
|
5573 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5574 | |
| 15884 | 5575 | 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
|
5576 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5577 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5578 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5579 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5580 | GList *row = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5581 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5582 | if(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5583 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5584 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5585 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5586 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5587 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5588 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5589 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5590 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5591 | 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
|
5592 | " 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
|
5593 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5594 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5595 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5596 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5597 | |
| 15884 | 5598 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5599 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5600 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5601 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5602 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5603 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5604 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5605 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5606 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5607 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5608 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5609 | |
| 15884 | 5610 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5611 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5612 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5613 | if(results) res = results->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5614 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5615 | if(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5616 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5617 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5618 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5619 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5620 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5621 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5622 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5623 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5624 | 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
|
5625 | " Sametime community."); |
|
20228
ce019944d765
applied changes from 9d35dde0c779cca73548172223ba557f27d61882
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
5626 | 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
|
5627 | |
| 15884 | 5628 | purple_notify_error(gc, _("No Matches"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5629 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5630 | g_free(msg); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5631 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5632 | } |
|
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 | |
| 15884 | 5635 | static void search_action_cb(PurpleConnection *gc, const char *name) { |
| 5636 | struct mwPurplePluginData *pd; | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5637 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5638 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5639 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5640 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5641 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5642 | pd = gc->proto_data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5643 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5644 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5645 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5646 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5647 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5648 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5649 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5650 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5651 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5652 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5653 | /** @todo display error */ |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5654 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5655 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5656 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5657 | |
| 15884 | 5658 | static void search_action(PurplePluginAction *act) { |
| 5659 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5660 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5661 | const char *msgB; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5662 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5663 | gc = act->context; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5664 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5665 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5666 | 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
|
5667 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5668 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5669 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5670 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5671 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5672 | _("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
|
5673 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5674 | gc); |
|
12630
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 | |
| 15884 | 5678 | static GList *mw_plugin_actions(PurplePlugin *plugin, gpointer context) { |
| 5679 | PurplePluginAction *act; | |
| 10977 | 5680 | GList *l = NULL; |
| 5681 | ||
| 15884 | 5682 | act = purple_plugin_action_new(_("Import Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5683 | st_import_action); |
| 10977 | 5684 | l = g_list_append(l, act); |
| 5685 | ||
| 15884 | 5686 | act = purple_plugin_action_new(_("Export Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5687 | st_export_action); |
| 10977 | 5688 | l = g_list_append(l, act); |
| 5689 | ||
| 15884 | 5690 | act = purple_plugin_action_new(_("Add Notes Address Book Group..."), |
| 10977 | 5691 | remote_group_action); |
| 5692 | l = g_list_append(l, act); | |
| 5693 | ||
| 15884 | 5694 | act = purple_plugin_action_new(_("User Search..."), |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5695 | search_action); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5696 | l = g_list_append(l, act); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5697 | |
| 10977 | 5698 | return l; |
| 5699 | } | |
| 5700 | ||
| 5701 | ||
| 15884 | 5702 | static gboolean mw_plugin_load(PurplePlugin *plugin) { |
| 10977 | 5703 | return TRUE; |
| 5704 | } | |
| 5705 | ||
| 5706 | ||
| 15884 | 5707 | static gboolean mw_plugin_unload(PurplePlugin *plugin) { |
| 10977 | 5708 | return TRUE; |
| 5709 | } | |
| 5710 | ||
| 5711 | ||
| 15884 | 5712 | static void mw_plugin_destroy(PurplePlugin *plugin) { |
| 10977 | 5713 | g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); |
| 5714 | g_log_remove_handler("meanwhile", log_handler[1]); | |
| 5715 | } | |
| 5716 | ||
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5717 | static PurplePluginInfo mw_plugin_info = |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5718 | { |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5719 | PURPLE_PLUGIN_MAGIC, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5720 | PURPLE_MAJOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5721 | PURPLE_MINOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5722 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5723 | NULL, /**< ui_requirement */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5724 | 0, /**< flags */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5725 | NULL, /**< dependencies */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5726 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5727 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5728 | PLUGIN_ID, /**< id */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5729 | PLUGIN_NAME, /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20228
diff
changeset
|
5730 | DISPLAY_VERSION, /**< version */ |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5731 | PLUGIN_SUMMARY, /**< summary */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5732 | PLUGIN_DESC, /**< description */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5733 | PLUGIN_AUTHOR, /**< author */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5734 | PLUGIN_HOMEPAGE, /**< homepage */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5735 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5736 | mw_plugin_load, /**< load */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5737 | mw_plugin_unload, /**< unload */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5738 | mw_plugin_destroy, /**< destroy */ |
|
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 | NULL, /**< ui_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5741 | &mw_prpl_info, /**< extra_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5742 | &mw_plugin_ui_info, /**< prefs_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5743 | mw_plugin_actions, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5744 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5745 | /* padding */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5746 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5747 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5748 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5749 | NULL |
| 10977 | 5750 | }; |
| 5751 | ||
| 5752 | ||
| 5753 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5754 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5755 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5756 | if(! (msg && *msg)) return; |
| 10977 | 5757 | |
| 15884 | 5758 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5759 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5760 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5761 | |
| 5762 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5763 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5764 | |
| 5765 | } else { | |
| 15884 | 5766 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5767 | } |
| 5768 | } | |
| 5769 | ||
| 5770 | ||
| 15884 | 5771 | static void mw_plugin_init(PurplePlugin *plugin) { |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5772 | PurpleAccountUserSplit *split; |
| 15884 | 5773 | PurpleAccountOption *opt; |
| 10977 | 5774 | GList *l = NULL; |
| 5775 | ||
| 5776 | GLogLevelFlags logflags = | |
| 5777 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5778 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5779 | /* set up the preferences */ |
| 15884 | 5780 | purple_prefs_add_none(MW_PRPL_OPT_BASE); |
| 5781 | 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
|
5782 | |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5783 | /* set up account ID as user:server */ |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5784 | split = purple_account_user_split_new(_("Server"), |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5785 | MW_PLUGIN_DEFAULT_HOST, ':'); |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5786 | mw_prpl_info.user_splits = g_list_append(mw_prpl_info.user_splits, split); |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5787 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5788 | /* remove dead preferences */ |
| 15884 | 5789 | purple_prefs_remove(MW_PRPL_OPT_PSYCHIC); |
| 5790 | purple_prefs_remove(MW_PRPL_OPT_SAVE_DYNAMIC); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5791 | |
| 10977 | 5792 | /* port to connect to */ |
| 15884 | 5793 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
| 10977 | 5794 | MW_PLUGIN_DEFAULT_PORT); |
| 5795 | l = g_list_append(l, opt); | |
| 5796 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5797 | { /* 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
|
5798 | 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
|
5799 | than one account that wants to check for it. */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5800 | gboolean b = FALSE; |
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12422
diff
changeset
|
5801 | const char *label = _("Force login (ignore server redirects)"); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5802 | |
| 15884 | 5803 | if(purple_prefs_exists(MW_PRPL_OPT_FORCE_LOGIN)) |
| 5804 | b = purple_prefs_get_bool(MW_PRPL_OPT_FORCE_LOGIN); | |
| 5805 | ||
| 5806 | 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
|
5807 | l = g_list_append(l, opt); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5808 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5809 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5810 | /* pretend to be Sametime Connect */ |
| 15884 | 5811 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5812 | MW_KEY_FAKE_IT, FALSE); |
|
12312
470a1452d009
[gaim-migrate @ 14616]
Christopher O'Brien <siege@pidgin.im>
parents:
12311
diff
changeset
|
5813 | l = g_list_append(l, opt); |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5814 | |
| 10977 | 5815 | mw_prpl_info.protocol_options = l; |
| 5816 | l = NULL; | |
| 5817 | ||
| 15884 | 5818 | /* forward all our g_log messages to purple. Generally all the logging |
| 5819 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5820 | get caught here */ |
| 5821 | log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags, | |
| 5822 | mw_log_handler, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5823 | |
| 15884 | 5824 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5825 | log_handler[1] = g_log_set_handler("meanwhile", logflags, |
| 5826 | mw_log_handler, NULL); | |
| 5827 | } | |
| 5828 | ||
| 5829 | ||
| 15884 | 5830 | PURPLE_INIT_PLUGIN(sametime, mw_plugin_init, mw_plugin_info); |
| 10977 | 5831 | /* The End. */ |
| 5832 |