Fri, 02 Aug 2013 03:19:58 +0530
Merged soc.2013.gobjectification branch
| 10977 | 1 | |
| 2 | /* | |
| 15884 | 3 | Meanwhile Protocol Plugin for Purple |
| 4 | Adds Lotus Sametime support to Purple using the Meanwhile library | |
| 10977 | 5 | |
| 6 | Copyright (C) 2004 Christopher (siege) O'Brien <siege@preoccupied.net> | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
7 | |
| 10977 | 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by | |
| 10 | the Free Software Foundation; either version 2 of the License, or (at | |
| 11 | your option) any later version. | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
12 | |
| 10977 | 13 | This program is distributed in the hope that it will be useful, but |
| 14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 16 | General Public License for more details. | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
17 | |
| 10977 | 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19586
diff
changeset
|
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, |
| 10977 | 21 | USA. |
| 22 | */ | |
| 23 | ||
|
28981
4e3922ab4844
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
24 | #include "internal.h" |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
25 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
26 | /* system includes */ |
| 10977 | 27 | #include <stdlib.h> |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
28 | #include <time.h> |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
29 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
30 | /* glib includes */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
31 | #include <glib.h> |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
32 | |
| 15884 | 33 | /* purple includes */ |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
34 | #include "account.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
35 | #include "accountopt.h" |
|
34570
ac513e5901eb
Rename circbuffer files to circularbuffer files to match the object name
Ankit Vani <a@nevitus.org>
parents:
34529
diff
changeset
|
36 | #include "circularbuffer.h" |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
37 | #include "conversation.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
38 | #include "debug.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
39 | #include "ft.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
40 | #include "imgstore.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
41 | #include "mime.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
42 | #include "notify.h" |
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
34865
diff
changeset
|
43 | #include "plugins.h" |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
44 | #include "prpl.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
45 | #include "request.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
46 | #include "util.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
47 | #include "version.h" |
| 10977 | 48 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
49 | /* meanwhile includes */ |
| 10977 | 50 | #include <mw_cipher.h> |
| 51 | #include <mw_common.h> | |
| 52 | #include <mw_error.h> | |
| 53 | #include <mw_service.h> | |
| 54 | #include <mw_session.h> | |
| 55 | #include <mw_srvc_aware.h> | |
| 56 | #include <mw_srvc_conf.h> | |
| 57 | #include <mw_srvc_ft.h> | |
| 58 | #include <mw_srvc_im.h> | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
59 | #include <mw_srvc_place.h> |
| 10977 | 60 | #include <mw_srvc_resolve.h> |
| 61 | #include <mw_srvc_store.h> | |
| 62 | #include <mw_st_list.h> | |
| 63 | ||
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
64 | /* plugin includes */ |
| 10977 | 65 | #include "sametime.h" |
| 66 | ||
| 67 | ||
| 68 | /* considering that there's no display of this information for prpls, | |
| 69 | I don't know why I even bother providing these. Oh valiant reader, | |
| 70 | I do it all for you. */ | |
| 71 | /* 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
|
72 | #define PLUGIN_ID "prpl-meanwhile" |
| 10977 | 73 | #define PLUGIN_NAME "Sametime" |
| 74 | #define PLUGIN_SUMMARY "Sametime Protocol Plugin" | |
| 75 | #define PLUGIN_DESC "Open implementation of a Lotus Sametime client" | |
| 76 | #define PLUGIN_AUTHOR "Christopher (siege) O'Brien <siege@preoccupied.net>" | |
| 77 | #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/" | |
| 78 | ||
| 79 | ||
| 80 | /* plugin preference names */ | |
| 81 | #define MW_PRPL_OPT_BASE "/plugins/prpl/meanwhile" | |
| 82 | #define MW_PRPL_OPT_BLIST_ACTION MW_PRPL_OPT_BASE "/blist_action" | |
| 83 | #define MW_PRPL_OPT_PSYCHIC MW_PRPL_OPT_BASE "/psychic" | |
| 84 | #define MW_PRPL_OPT_FORCE_LOGIN MW_PRPL_OPT_BASE "/force_login" | |
| 85 | #define MW_PRPL_OPT_SAVE_DYNAMIC MW_PRPL_OPT_BASE "/save_dynamic" | |
| 86 | ||
| 87 | ||
| 88 | /* stages of connecting-ness */ | |
|
13779
410869639392
[gaim-migrate @ 16189]
Christopher O'Brien <siege@pidgin.im>
parents:
13713
diff
changeset
|
89 | #define MW_CONNECT_STEPS 11 |
| 10977 | 90 | |
| 91 | ||
| 92 | /* stages of conciousness */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
93 | #define MW_STATE_OFFLINE "offline" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
94 | #define MW_STATE_ACTIVE "active" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
95 | #define MW_STATE_AWAY "away" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
96 | #define MW_STATE_BUSY "dnd" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
97 | #define MW_STATE_MESSAGE "message" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
98 | #define MW_STATE_ENLIGHTENED "buddha" |
| 10977 | 99 | |
| 100 | ||
| 101 | /* keys to get/set chat information */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
102 | #define CHAT_KEY_CREATOR "chat.creator" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
103 | #define CHAT_KEY_NAME "chat.name" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
104 | #define CHAT_KEY_TOPIC "chat.topic" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
105 | #define CHAT_KEY_INVITE "chat.invite" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
106 | #define CHAT_KEY_IS_PLACE "chat.is_place" |
| 10977 | 107 | |
| 108 | ||
| 109 | /* key for associating a mwLoginType with a buddy */ | |
| 110 | #define BUDDY_KEY_CLIENT "meanwhile.client" | |
| 111 | ||
| 112 | /* store the remote alias so that we can re-create it easily */ | |
| 113 | #define BUDDY_KEY_NAME "meanwhile.shortname" | |
| 114 | ||
| 115 | /* enum mwSametimeUserType */ | |
| 116 | #define BUDDY_KEY_TYPE "meanwhile.type" | |
| 117 | ||
| 118 | ||
| 119 | /* key for the real group name for a meanwhile group */ | |
| 120 | #define GROUP_KEY_NAME "meanwhile.group" | |
| 121 | ||
| 122 | /* enum mwSametimeGroupType */ | |
| 123 | #define GROUP_KEY_TYPE "meanwhile.type" | |
| 124 | ||
| 125 | /* NAB group owning account */ | |
| 126 | #define GROUP_KEY_OWNER "meanwhile.account" | |
| 127 | ||
| 128 | /* key gtk blist uses to indicate a collapsed group */ | |
| 129 | #define GROUP_KEY_COLLAPSED "collapsed" | |
| 130 | ||
| 131 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
132 | /* verification replacement */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
133 | #define mwSession_NO_SECRET "meanwhile.no_secret" |
| 10977 | 134 | |
| 135 | ||
| 15884 | 136 | /* keys to get/set purple plugin information */ |
| 10977 | 137 | #define MW_KEY_HOST "server" |
| 138 | #define MW_KEY_PORT "port" | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
139 | #define MW_KEY_FORCE "force_login" |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
140 | #define MW_KEY_FAKE_IT "fake_client_id" |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
141 | #define MW_KEY_CLIENT "client_id_val" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
142 | #define MW_KEY_MAJOR "client_major" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
143 | #define MW_KEY_MINOR "client_minor" |
| 10977 | 144 | |
| 145 | ||
| 146 | /** number of seconds from the first blist change before a save to the | |
| 147 | storage service occurs. */ | |
| 148 | #define BLIST_SAVE_SECONDS 15 | |
| 149 | ||
| 150 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
151 | /** the possible buddy list storage settings */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
152 | enum blist_choice { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
153 | blist_choice_LOCAL = 1, /**< local only */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
154 | blist_choice_MERGE = 2, /**< merge from server */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
155 | 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
|
156 | blist_choice_SYNCH = 4 /**< sync with server */ |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
157 | }; |
| 10977 | 158 | |
| 159 | ||
| 160 | /** the default blist storage option */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
161 | #define BLIST_CHOICE_DEFAULT blist_choice_SYNCH |
| 10977 | 162 | |
| 163 | ||
| 164 | /* testing for the above */ | |
| 15884 | 165 | #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
|
166 | #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
|
167 | #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
|
168 | #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
|
169 | #define BLIST_PREF_IS_SYNCH() BLIST_PREF_IS(blist_choice_SYNCH) |
| 10977 | 170 | |
| 171 | ||
| 172 | /* 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
|
173 | #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
|
174 | #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
|
175 | #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
|
176 | #define DEBUG_WARN(...) purple_debug_warning(G_LOG_DOMAIN, __VA_ARGS__) |
| 10977 | 177 | |
| 178 | ||
| 179 | /** ensure non-null strings */ | |
| 180 | #ifndef NSTR | |
| 181 | # define NSTR(str) ((str)? (str): "(null)") | |
| 182 | #endif | |
| 183 | ||
| 184 | ||
| 185 | /** calibrates distinct secure channel nomenclature */ | |
| 186 | static const unsigned char no_secret[] = { | |
| 187 | 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65, | |
| 188 | 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a, | |
| 189 | 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64, | |
| 190 | 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00, | |
| 191 | }; | |
| 192 | ||
| 193 | ||
| 194 | /** handler IDs from g_log_set_handler in mw_plugin_init */ | |
| 195 | static guint log_handler[2] = { 0, 0 }; | |
| 196 | ||
| 197 | ||
| 15884 | 198 | /** the purple plugin data. |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
199 | available as purple_connection_get_protocol_data(gc) and mwSession_getClientData */ |
| 15884 | 200 | struct mwPurplePluginData { |
| 10977 | 201 | struct mwSession *session; |
| 202 | ||
| 203 | struct mwServiceAware *srvc_aware; | |
| 204 | struct mwServiceConference *srvc_conf; | |
| 205 | struct mwServiceFileTransfer *srvc_ft; | |
| 206 | struct mwServiceIm *srvc_im; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
207 | struct mwServicePlace *srvc_place; |
| 10977 | 208 | struct mwServiceResolve *srvc_resolve; |
| 209 | struct mwServiceStorage *srvc_store; | |
| 210 | ||
| 15884 | 211 | /** map of PurpleGroup:mwAwareList and mwAwareList:PurpleGroup */ |
| 10977 | 212 | GHashTable *group_list_map; |
| 213 | ||
| 214 | /** event id for the buddy list save callback */ | |
| 215 | guint save_event; | |
| 216 | ||
| 217 | /** socket fd */ | |
| 218 | int socket; | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
219 | guint inpa; /* input watcher */ |
|
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 */ |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
223 | PurpleCircularBuffer *sock_buf; |
| 15884 | 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 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
298 | static PurpleIMConversation *convo_get_im(struct mwConversation *conv); |
| 10977 | 299 | |
| 300 | ||
|
12629
14aae7d5da6b
[gaim-migrate @ 14965]
Richard Laager <rlaager@pidgin.im>
parents:
12624
diff
changeset
|
301 | /* name and id */ |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
302 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
303 | struct named_id { |
| 10977 | 304 | char *id; |
| 305 | char *name; | |
| 306 | }; | |
| 307 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
308 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
309 | /* connection functions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
310 | |
|
14178
d12b287697c9
[gaim-migrate @ 16750]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
311 | static void connect_cb(gpointer data, gint source, const gchar *error_message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
312 | |
| 10977 | 313 | |
| 314 | /* ----- session ------ */ | |
| 315 | ||
| 316 | ||
| 15884 | 317 | /** resolves a mwSession from a PurpleConnection */ |
| 318 | static struct mwSession *gc_to_session(PurpleConnection *gc) { | |
| 319 | struct mwPurplePluginData *pd; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
320 | |
| 10977 | 321 | g_return_val_if_fail(gc != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
322 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
323 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 324 | g_return_val_if_fail(pd != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
325 | |
| 10977 | 326 | return pd->session; |
| 327 | } | |
| 328 | ||
| 329 | ||
| 15884 | 330 | /** resolves a PurpleConnection from a mwSession */ |
| 331 | static PurpleConnection *session_to_gc(struct mwSession *session) { | |
| 332 | struct mwPurplePluginData *pd; | |
| 10977 | 333 | |
| 334 | g_return_val_if_fail(session != NULL, NULL); | |
| 335 | ||
| 336 | pd = mwSession_getClientData(session); | |
| 337 | g_return_val_if_fail(pd != NULL, NULL); | |
| 338 | ||
| 339 | return pd->gc; | |
| 340 | } | |
| 341 | ||
| 342 | ||
| 15884 | 343 | static void write_cb(gpointer data, gint source, PurpleInputCondition cond) { |
| 344 | struct mwPurplePluginData *pd = data; | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
345 | PurpleCircularBuffer *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 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
353 | avail = purple_circular_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) { |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
357 | ret = write(pd->socket, purple_circular_buffer_get_output(circ), avail); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
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 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
362 | purple_circular_buffer_mark_read(circ, ret); |
|
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
363 | avail = purple_circular_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"); |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
388 | purple_circular_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"); |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
408 | purple_circular_buffer_append(pd->sock_buf, buf, len); |
| 15884 | 409 | pd->outpa = purple_input_add(pd->socket, PURPLE_INPUT_WRITE, write_cb, pd); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
410 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
411 | } else if(len > 0) { |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
412 | gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
413 | g_strerror(errno)); |
|
22709
6bd336964410
Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
414 | DEBUG_ERROR("write returned %" G_GSSIZE_FORMAT ", %" G_GSIZE_FORMAT |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22277
diff
changeset
|
415 | " bytes left unwritten\n", ret, len); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
416 | purple_connection_error(pd->gc, |
| 21279 | 417 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
418 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
419 | g_free(tmp); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
420 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
421 | #if 0 |
| 10977 | 422 | close(pd->socket); |
| 423 | pd->socket = 0; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
424 | #endif |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
425 | |
| 10977 | 426 | return -1; |
| 427 | } | |
| 428 | ||
| 429 | return 0; | |
| 430 | } | |
| 431 | ||
| 432 | ||
| 433 | static void mw_session_io_close(struct mwSession *session) { | |
| 15884 | 434 | struct mwPurplePluginData *pd; |
| 10977 | 435 | |
| 436 | pd = mwSession_getClientData(session); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
437 | g_return_if_fail(pd != NULL); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
438 | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
439 | if(pd->outpa) { |
| 15884 | 440 | purple_input_remove(pd->outpa); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
441 | pd->outpa = 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
442 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
443 | |
| 10977 | 444 | if(pd->socket) { |
| 445 | close(pd->socket); | |
| 446 | pd->socket = 0; | |
| 447 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
448 | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
449 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
450 | purple_input_remove(pd->inpa); |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
451 | pd->inpa = 0; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
452 | } |
| 10977 | 453 | } |
| 454 | ||
| 455 | ||
| 456 | static void mw_session_clear(struct mwSession *session) { | |
| 457 | ; /* nothing for now */ | |
| 458 | } | |
| 459 | ||
| 460 | ||
| 461 | /* ----- aware list ----- */ | |
| 462 | ||
| 463 | ||
| 464 | static void blist_resolve_alias_cb(struct mwServiceResolve *srvc, | |
| 465 | guint32 id, guint32 code, GList *results, | |
| 466 | gpointer data) { | |
| 467 | struct mwResolveResult *result; | |
| 468 | struct mwResolveMatch *match; | |
| 469 | ||
| 470 | g_return_if_fail(results != NULL); | |
| 471 | ||
| 472 | result = results->data; | |
| 473 | g_return_if_fail(result != NULL); | |
| 474 | g_return_if_fail(result->matches != NULL); | |
| 475 | ||
| 476 | match = result->matches->data; | |
| 477 | g_return_if_fail(match != NULL); | |
| 478 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
479 | purple_buddy_set_server_alias(data, match->name); |
| 15884 | 480 | purple_blist_node_set_string(data, BUDDY_KEY_NAME, match->name); |
| 10977 | 481 | } |
| 482 | ||
| 483 | ||
| 484 | static void mw_aware_list_on_aware(struct mwAwareList *list, | |
| 485 | struct mwAwareSnapshot *aware) { | |
| 486 | ||
| 15884 | 487 | PurpleConnection *gc; |
| 488 | PurpleAccount *acct; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
489 | |
| 15884 | 490 | struct mwPurplePluginData *pd; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
491 | guint32 idle; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
492 | guint stat; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
493 | const char *id; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
494 | const char *status = MW_STATE_ACTIVE; |
| 10977 | 495 | |
| 496 | gc = mwAwareList_getClientData(list); | |
| 15884 | 497 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
498 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
499 | pd = purple_connection_get_protocol_data(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
500 | idle = aware->status.time; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
501 | stat = aware->status.status; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
502 | id = aware->id.user; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
503 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
504 | if(idle) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
505 | guint32 idle_len; /*< how long a client has been idle */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
506 | 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
|
507 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
508 | 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
|
509 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
510 | idle_len = time(NULL) - idle; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
511 | ugly_idle_len = ((time(NULL) * 1000) - idle) / 1000; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
512 | |
|
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
|
513 | 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
|
514 | 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
|
515 | 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
|
516 | 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
|
517 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
518 | /* |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
519 | 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
|
520 | 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
|
521 | 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
|
522 | 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
|
523 | 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
|
524 | 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
|
525 | this. |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
526 | */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
527 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
528 | 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
|
529 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
530 | #if 1 |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
531 | if(idle_len <= ugly_idle_len) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
532 | ; /* DEBUG_INFO("sane idle value, let's use it\n"); */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
533 | } else { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
534 | idle = time(NULL) - ugly_idle_len; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
535 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
536 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
537 | #else |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
538 | if(idle < 0 || idle > time(NULL)) { |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
539 | 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
|
540 | idle = -1; |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
541 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
542 | #endif |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
543 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
544 | |
| 10977 | 545 | switch(stat) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
546 | case mwStatus_ACTIVE: |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
547 | status = MW_STATE_ACTIVE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
548 | idle = 0; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
549 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
550 | |
| 10977 | 551 | case mwStatus_IDLE: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
552 | if(! idle) idle = -1; |
| 10977 | 553 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
554 | |
| 10977 | 555 | case mwStatus_AWAY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
556 | status = MW_STATE_AWAY; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
557 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
558 | |
| 10977 | 559 | case mwStatus_BUSY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
560 | status = MW_STATE_BUSY; |
| 10977 | 561 | break; |
| 562 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
563 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
564 | /* NAB group members */ |
| 10977 | 565 | if(aware->group) { |
| 15884 | 566 | PurpleGroup *group; |
| 567 | PurpleBuddy *buddy; | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
568 | PurpleBlistNode *bnode; |
| 10977 | 569 | |
| 570 | group = g_hash_table_lookup(pd->group_list_map, list); | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
571 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
572 | bnode = (PurpleBlistNode *) buddy; |
| 10977 | 573 | |
| 574 | if(! buddy) { | |
| 575 | struct mwServiceResolve *srvc; | |
| 576 | GList *query; | |
| 577 | ||
| 15884 | 578 | buddy = purple_buddy_new(acct, id, NULL); |
| 579 | purple_blist_add_buddy(buddy, NULL, group, NULL); | |
| 580 | ||
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
581 | bnode = (PurpleBlistNode *) buddy; |
| 10977 | 582 | |
| 583 | srvc = pd->srvc_resolve; | |
| 584 | query = g_list_append(NULL, (char *) id); | |
| 585 | ||
| 586 | mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS, | |
| 587 | blist_resolve_alias_cb, buddy, NULL); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
588 | g_list_free(query); |
| 10977 | 589 | } |
| 590 | ||
| 15884 | 591 | purple_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL); |
| 10977 | 592 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
593 | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
594 | if(aware->online) { |
| 15884 | 595 | purple_prpl_got_user_status(acct, id, status, NULL); |
| 596 | 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
|
597 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
598 | } else { |
| 15884 | 599 | 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
|
600 | } |
| 10977 | 601 | } |
| 602 | ||
| 603 | ||
| 604 | static void mw_aware_list_on_attrib(struct mwAwareList *list, | |
| 605 | struct mwAwareIdBlock *id, | |
| 606 | struct mwAwareAttribute *attrib) { | |
| 607 | ||
| 608 | ; /* nothing. We'll get attribute data as we need it */ | |
| 609 | } | |
| 610 | ||
| 611 | ||
| 612 | static void mw_aware_list_clear(struct mwAwareList *list) { | |
| 613 | ; /* nothing for now */ | |
| 614 | } | |
| 615 | ||
| 616 | ||
| 617 | static struct mwAwareListHandler mw_aware_list_handler = { | |
|
17157
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
618 | mw_aware_list_on_aware, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
619 | mw_aware_list_on_attrib, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
620 | mw_aware_list_clear, |
| 10977 | 621 | }; |
| 622 | ||
| 623 | ||
| 624 | /** Ensures that an Aware List is associated with the given group, and | |
| 625 | returns that list. */ | |
| 626 | static struct mwAwareList * | |
| 15884 | 627 | list_ensure(struct mwPurplePluginData *pd, PurpleGroup *group) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
628 | |
| 10977 | 629 | struct mwAwareList *list; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
630 | |
| 10977 | 631 | g_return_val_if_fail(pd != NULL, NULL); |
| 632 | g_return_val_if_fail(group != NULL, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
633 | |
| 10977 | 634 | list = g_hash_table_lookup(pd->group_list_map, group); |
| 635 | if(! list) { | |
| 636 | list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler); | |
| 637 | mwAwareList_setClientData(list, pd->gc, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
638 | |
| 10977 | 639 | mwAwareList_watchAttributes(list, |
| 640 | mwAttribute_AV_PREFS_SET, | |
| 641 | mwAttribute_MICROPHONE, | |
| 642 | mwAttribute_SPEAKERS, | |
| 643 | mwAttribute_VIDEO_CAMERA, | |
| 644 | mwAttribute_FILE_TRANSFER, | |
| 645 | NULL); | |
| 646 | ||
| 647 | g_hash_table_replace(pd->group_list_map, group, list); | |
| 648 | g_hash_table_insert(pd->group_list_map, list, group); | |
| 649 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
650 | |
| 10977 | 651 | return list; |
| 652 | } | |
| 653 | ||
| 654 | ||
| 15884 | 655 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 10977 | 656 | /* - find the account for this connection |
| 657 | - iterate through the buddy list | |
| 658 | - add each buddy matching this account to the stlist | |
| 659 | */ | |
| 660 | ||
| 15884 | 661 | PurpleAccount *acct; |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
662 | PurpleBlistNode *gn, *cn, *bn; |
| 15884 | 663 | PurpleGroup *grp; |
| 664 | PurpleBuddy *bdy; | |
| 10977 | 665 | |
| 666 | struct mwSametimeGroup *stg = NULL; | |
| 667 | struct mwIdBlock idb = { NULL, NULL }; | |
| 668 | ||
| 15884 | 669 | acct = purple_connection_get_account(gc); |
| 10977 | 670 | g_return_if_fail(acct != NULL); |
| 671 | ||
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
672 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
673 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 10977 | 674 | const char *owner; |
| 675 | const char *gname; | |
| 676 | enum mwSametimeGroupType gtype; | |
| 677 | gboolean gopen; | |
| 678 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
679 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 680 | grp = (PurpleGroup *) gn; |
| 10977 | 681 | |
| 682 | /* the group's type (normal or dynamic) */ | |
| 15884 | 683 | gtype = purple_blist_node_get_int(gn, GROUP_KEY_TYPE); |
| 10977 | 684 | if(! gtype) gtype = mwSametimeGroup_NORMAL; |
| 685 | ||
| 686 | /* if it's a normal group with none of our people in it, skip it */ | |
| 15884 | 687 | if(gtype == mwSametimeGroup_NORMAL && !purple_group_on_account(grp, acct)) |
| 10977 | 688 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
689 | |
| 10977 | 690 | /* if the group has an owner and we're not it, skip it */ |
| 15884 | 691 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
| 692 | if(owner && strcmp(owner, purple_account_get_username(acct))) | |
| 10977 | 693 | continue; |
| 694 | ||
| 15884 | 695 | /* the group's actual name may be different from the purple group's |
| 10977 | 696 | name. Find whichever is there */ |
| 15884 | 697 | 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
|
698 | if(! gname) gname = purple_group_get_name(grp); |
| 10977 | 699 | |
| 700 | /* we save this, but never actually honor it */ | |
| 15884 | 701 | gopen = ! purple_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); |
| 10977 | 702 | |
| 703 | 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
|
704 | mwSametimeGroup_setAlias(stg, purple_group_get_name(grp)); |
| 10977 | 705 | mwSametimeGroup_setOpen(stg, gopen); |
| 706 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
707 | /* 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
|
708 | other clients */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
709 | if(gtype == mwSametimeGroup_DYNAMIC) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
710 | continue; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
711 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
712 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
713 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
714 | cn = purple_blist_node_get_sibling_next(cn)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
715 | if(! PURPLE_IS_CONTACT(cn)) continue; |
| 10977 | 716 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
717 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
718 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
719 | bn = purple_blist_node_get_sibling_next(bn)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
720 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
34865
764a33b41ac7
Renamed blist node's dont_save to transient.
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
721 | if(purple_blist_node_is_transient(bn)) continue; |
| 15884 | 722 | |
| 723 | bdy = (PurpleBuddy *) bn; | |
| 10977 | 724 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
725 | if(purple_buddy_get_account(bdy) == acct) { |
| 10977 | 726 | struct mwSametimeUser *stu; |
| 727 | enum mwSametimeUserType utype; | |
| 728 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
729 | idb.user = (char *)purple_buddy_get_name(bdy); |
| 10977 | 730 | |
| 15884 | 731 | utype = purple_blist_node_get_int(bn, BUDDY_KEY_TYPE); |
| 10977 | 732 | if(! utype) utype = mwSametimeUser_NORMAL; |
| 733 | ||
| 734 | 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
|
735 | mwSametimeUser_setShortName(stu, purple_buddy_get_server_alias(bdy)); |
|
34717
b3e588adef5a
Global replace purple_buddy_get_local_buddy_alias() with purple_buddy_get_local_alias()
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
736 | mwSametimeUser_setAlias(stu, purple_buddy_get_local_alias(bdy)); |
| 10977 | 737 | } |
| 738 | } | |
| 739 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
740 | } |
| 10977 | 741 | } |
| 742 | ||
| 743 | ||
| 15884 | 744 | static void blist_store(struct mwPurplePluginData *pd) { |
| 10977 | 745 | |
| 746 | struct mwSametimeList *stlist; | |
| 747 | struct mwServiceStorage *srvc; | |
| 748 | struct mwStorageUnit *unit; | |
| 749 | ||
| 15884 | 750 | PurpleConnection *gc; |
| 10977 | 751 | |
| 752 | struct mwPutBuffer *b; | |
| 753 | struct mwOpaque *o; | |
| 754 | ||
| 755 | g_return_if_fail(pd != NULL); | |
| 756 | ||
| 757 | srvc = pd->srvc_store; | |
| 758 | g_return_if_fail(srvc != NULL); | |
| 759 | ||
| 760 | gc = pd->gc; | |
| 761 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
762 | if(BLIST_PREF_IS_LOCAL() || BLIST_PREF_IS_MERGE()) { |
| 10977 | 763 | DEBUG_INFO("preferences indicate not to save remote blist\n"); |
| 764 | return; | |
| 765 | ||
| 766 | } else if(MW_SERVICE_IS_DEAD(srvc)) { | |
| 767 | DEBUG_INFO("aborting save of blist: storage service is not alive\n"); | |
| 768 | return; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
769 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
770 | } else if(BLIST_PREF_IS_STORE() || BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
771 | DEBUG_INFO("saving remote blist\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
772 | |
| 10977 | 773 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
774 | g_return_if_reached(); |
| 10977 | 775 | } |
| 776 | ||
| 777 | /* create and export to a list object */ | |
| 778 | stlist = mwSametimeList_new(); | |
| 779 | blist_export(gc, stlist); | |
| 780 | ||
| 781 | /* write it to a buffer */ | |
| 782 | b = mwPutBuffer_new(); | |
| 783 | mwSametimeList_put(b, stlist); | |
| 784 | mwSametimeList_free(stlist); | |
| 785 | ||
| 786 | /* put the buffer contents into a storage unit */ | |
| 787 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
| 788 | o = mwStorageUnit_asOpaque(unit); | |
| 789 | mwPutBuffer_finalize(o, b); | |
| 790 | ||
| 791 | /* save the storage unit to the service */ | |
| 792 | mwServiceStorage_save(srvc, unit, NULL, NULL, NULL); | |
| 793 | } | |
| 794 | ||
| 795 | ||
| 796 | static gboolean blist_save_cb(gpointer data) { | |
| 15884 | 797 | struct mwPurplePluginData *pd = data; |
| 10977 | 798 | |
| 799 | blist_store(pd); | |
| 800 | pd->save_event = 0; | |
| 801 | return FALSE; | |
| 802 | } | |
| 803 | ||
| 804 | ||
| 805 | /** schedules the buddy list to be saved to the server */ | |
| 15884 | 806 | static void blist_schedule(struct mwPurplePluginData *pd) { |
| 10977 | 807 | if(pd->save_event) return; |
| 808 | ||
|
25716
1b5be208d5ba
applied changes from a336cc1fd3a1ce815f97303b8d5ae8988f8cbd5b
Ethan Blanton <elb@pidgin.im>
parents:
25292
diff
changeset
|
809 | pd->save_event = purple_timeout_add_seconds(BLIST_SAVE_SECONDS, |
| 10977 | 810 | blist_save_cb, pd); |
| 811 | } | |
| 812 | ||
| 813 | ||
| 15884 | 814 | static gboolean buddy_is_external(PurpleBuddy *b) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
815 | 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
|
816 | 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
|
817 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
818 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
819 | |
| 10977 | 820 | /** Actually add a buddy to the aware service, and schedule the buddy |
| 821 | list to be saved to the server */ | |
| 15884 | 822 | static void buddy_add(struct mwPurplePluginData *pd, |
| 823 | PurpleBuddy *buddy) { | |
| 10977 | 824 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
825 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) purple_buddy_get_name(buddy), NULL }; |
| 10977 | 826 | struct mwAwareList *list; |
| 827 | ||
| 15884 | 828 | PurpleGroup *group; |
| 10977 | 829 | GList *add; |
| 830 | ||
| 831 | add = g_list_prepend(NULL, &idb); | |
| 832 | ||
| 15884 | 833 | group = purple_buddy_get_group(buddy); |
| 10977 | 834 | list = list_ensure(pd, group); |
| 835 | ||
| 836 | if(mwAwareList_addAware(list, add)) { | |
| 15884 | 837 | purple_blist_remove_buddy(buddy); |
| 10977 | 838 | } |
| 839 | ||
| 840 | blist_schedule(pd); | |
| 841 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
842 | g_list_free(add); |
| 10977 | 843 | } |
| 844 | ||
| 845 | ||
| 15884 | 846 | /** ensure that a PurpleBuddy exists in the group with data |
| 10977 | 847 | appropriately matching the st user entry from the st list */ |
| 15884 | 848 | static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, |
| 10977 | 849 | struct mwSametimeUser *stuser) { |
| 850 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
851 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 852 | PurpleBuddy *buddy; |
| 853 | PurpleAccount *acct = purple_connection_get_account(gc); | |
| 10977 | 854 | |
| 855 | const char *id = mwSametimeUser_getUser(stuser); | |
| 856 | const char *name = mwSametimeUser_getShortName(stuser); | |
| 857 | const char *alias = mwSametimeUser_getAlias(stuser); | |
| 858 | enum mwSametimeUserType type = mwSametimeUser_getType(stuser); | |
| 859 | ||
| 860 | g_return_val_if_fail(id != NULL, NULL); | |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
861 | g_return_val_if_fail(*id, NULL); |
| 10977 | 862 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
863 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 10977 | 864 | if(! buddy) { |
| 15884 | 865 | buddy = purple_buddy_new(acct, id, alias); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
866 | |
| 15884 | 867 | purple_blist_add_buddy(buddy, NULL, group, NULL); |
| 10977 | 868 | buddy_add(pd, buddy); |
| 869 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
870 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
871 | purple_buddy_set_local_alias(buddy, alias); |
|
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
872 | purple_buddy_set_server_alias(buddy, name); |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
873 | purple_blist_node_set_string((PurpleBlistNode *) buddy, BUDDY_KEY_NAME, name); |
|
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
874 | purple_blist_node_set_int((PurpleBlistNode *) buddy, BUDDY_KEY_TYPE, type); |
| 10977 | 875 | |
| 876 | return buddy; | |
| 877 | } | |
| 878 | ||
| 879 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
880 | /** add aware watch for a dynamic group */ |
| 15884 | 881 | static void group_add(struct mwPurplePluginData *pd, |
| 882 | PurpleGroup *group) { | |
| 10977 | 883 | |
| 884 | struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL }; | |
| 885 | struct mwAwareList *list; | |
| 886 | const char *n; | |
| 887 | GList *add; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
888 | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
889 | 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
|
890 | if(! n) n = purple_group_get_name(group); |
| 10977 | 891 | |
| 892 | idb.user = (char *) n; | |
| 893 | add = g_list_prepend(NULL, &idb); | |
| 894 | ||
| 895 | list = list_ensure(pd, group); | |
| 896 | mwAwareList_addAware(list, add); | |
| 897 | g_list_free(add); | |
| 898 | } | |
| 899 | ||
| 900 | ||
| 15884 | 901 | /** ensure that a PurpleGroup exists in the blist with data |
| 10977 | 902 | appropriately matching the st group entry from the st list */ |
| 15884 | 903 | static PurpleGroup *group_ensure(PurpleConnection *gc, |
| 10977 | 904 | struct mwSametimeGroup *stgroup) { |
| 15884 | 905 | PurpleAccount *acct; |
| 906 | PurpleGroup *group = NULL; | |
| 907 | PurpleBuddyList *blist; | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
908 | PurpleBlistNode *gn; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
909 | const char *name, *alias, *owner; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
910 | enum mwSametimeGroupType type; |
| 10977 | 911 | |
| 15884 | 912 | acct = purple_connection_get_account(gc); |
| 913 | owner = purple_account_get_username(acct); | |
| 914 | ||
|
34726
af52ff6660c0
Replaced purple_get_blist() with purple_blist_get_buddy_list()
Ankit Vani <a@nevitus.org>
parents:
34723
diff
changeset
|
915 | blist = purple_blist_get_buddy_list(); |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
916 | g_return_val_if_fail(blist != NULL, NULL); |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
917 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
918 | name = mwSametimeGroup_getName(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
919 | alias = mwSametimeGroup_getAlias(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
920 | type = mwSametimeGroup_getType(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
921 | |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
922 | if (!name) { |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
923 | DEBUG_WARN("Can't ensure a null group\n"); |
|
31991
efe4fb3772ad
Fix this compile warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
31983
diff
changeset
|
924 | return NULL; |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
925 | } |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
926 | |
|
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
|
927 | 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
|
928 | 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
|
929 | 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
|
930 | } |
|
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 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
932 | DEBUG_INFO("attempting to ensure group %s, called %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
933 | NSTR(name), NSTR(alias)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
934 | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
935 | /* 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
|
936 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
937 | gn = purple_blist_node_get_sibling_next(gn)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
938 | const char *n, *o; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
939 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 940 | n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
| 941 | 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
|
942 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
943 | 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
|
944 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
945 | if(n && !strcmp(n, name)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
946 | if(!o || !strcmp(o, owner)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
947 | DEBUG_INFO("that'll work\n"); |
| 15884 | 948 | group = (PurpleGroup *) gn; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
949 | break; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
950 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
951 | } |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
952 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
953 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
954 | /* try again, by alias */ |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
955 | if(! group) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
956 | DEBUG_INFO("searching for group by alias %s\n", NSTR(alias)); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
957 | group = purple_blist_find_group(alias); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
958 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
959 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
960 | /* oh well, no such group. Let's create it! */ |
| 10977 | 961 | if(! group) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
962 | DEBUG_INFO("creating group\n"); |
| 15884 | 963 | group = purple_group_new(alias); |
| 964 | purple_blist_add_group(group, NULL); | |
| 10977 | 965 | } |
| 966 | ||
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
967 | gn = (PurpleBlistNode *) group; |
| 15884 | 968 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); |
| 969 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | |
| 10977 | 970 | |
| 971 | if(type == mwSametimeGroup_DYNAMIC) { | |
| 15884 | 972 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
973 | group_add(purple_connection_get_protocol_data(gc), group); |
| 10977 | 974 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
975 | |
| 10977 | 976 | return group; |
| 977 | } | |
| 978 | ||
| 979 | ||
| 15884 | 980 | /** merge the entries from a st list into the purple blist */ |
| 981 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist) { | |
| 10977 | 982 | struct mwSametimeGroup *stgroup; |
| 983 | struct mwSametimeUser *stuser; | |
| 984 | ||
| 15884 | 985 | PurpleGroup *group; |
| 10977 | 986 | |
| 987 | GList *gl, *gtl, *ul, *utl; | |
| 988 | ||
| 989 | gl = gtl = mwSametimeList_getGroups(stlist); | |
| 990 | for(; gl; gl = gl->next) { | |
| 991 | ||
| 992 | stgroup = (struct mwSametimeGroup *) gl->data; | |
| 993 | group = group_ensure(gc, stgroup); | |
| 994 | ||
| 995 | ul = utl = mwSametimeGroup_getUsers(stgroup); | |
| 996 | for(; ul; ul = ul->next) { | |
| 997 | ||
| 998 | stuser = (struct mwSametimeUser *) ul->data; | |
|
33782
1690e0b2c508
Fix a bunch of unused variables
Daniel Atallah <datallah@pidgin.im>
parents:
33745
diff
changeset
|
999 | buddy_ensure(gc, group, stuser); |
| 10977 | 1000 | } |
| 1001 | g_list_free(utl); | |
| 1002 | } | |
| 1003 | g_list_free(gtl); | |
| 1004 | } | |
| 1005 | ||
| 1006 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1007 | /** 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
|
1008 | is left empty, remove group as well */ |
| 15884 | 1009 | static void group_clear(PurpleGroup *group, PurpleAccount *acct, gboolean del) { |
| 1010 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1011 | GList *prune = NULL; |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1012 | PurpleBlistNode *gn, *cn, *bn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1013 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1014 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1015 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1016 | 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
|
1017 | |
| 15884 | 1018 | gc = purple_account_get_connection(acct); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1019 | g_return_if_fail(gc != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1020 | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1021 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1022 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1023 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1024 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1025 | cn = purple_blist_node_get_sibling_next(cn)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1026 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1027 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1028 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1029 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1030 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1031 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1032 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1033 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1034 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1035 | 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
|
1036 | 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
|
1037 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1038 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1039 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1040 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1041 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1042 | /* quickly unsubscribe from presence for the entire group */ |
| 15884 | 1043 | purple_account_remove_group(acct, group); |
|
11943
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 | /* remove blist entries that need to go */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1046 | while(prune) { |
| 15884 | 1047 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1048 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1049 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1050 | DEBUG_INFO("cleared buddies\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1051 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1052 | /* optionally remove group from blist */ |
|
34723
b496dd569514
Refactored libpurple plugins and protocols according to the blist API changes
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
1053 | if(del && !purple_counting_node_get_total_size(PURPLE_COUNTING_NODE(group))) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1054 | DEBUG_INFO("removing empty group\n"); |
| 15884 | 1055 | purple_blist_remove_group(group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1056 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1057 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1058 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1059 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1060 | /** prune out group members that shouldn't be there */ |
| 15884 | 1061 | static void group_prune(PurpleConnection *gc, PurpleGroup *group, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1062 | struct mwSametimeGroup *stgroup) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1063 | |
| 15884 | 1064 | PurpleAccount *acct; |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1065 | PurpleBlistNode *gn, *cn, *bn; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1066 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1067 | GHashTable *stusers; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1068 | GList *prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1069 | GList *ul, *utl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1070 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1071 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1072 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1073 | 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
|
1074 | |
| 15884 | 1075 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1076 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1077 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1078 | 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
|
1079 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1080 | /* 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
|
1081 | contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1082 | utl = mwSametimeGroup_getUsers(stgroup); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1083 | for(ul = utl; ul; ul = ul->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1084 | const char *id = mwSametimeUser_getUser(ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1085 | g_hash_table_insert(stusers, (char *) id, ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1086 | DEBUG_INFO("server copy has %s\n", NSTR(id)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1087 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1088 | g_list_free(utl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1089 | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1090 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1091 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1092 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1093 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1094 | cn = purple_blist_node_get_sibling_next(cn)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1095 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1096 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1097 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1098 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1099 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1100 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1101 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1102 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1103 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1104 | /* 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
|
1105 | them for pruning */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1106 | 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
|
1107 | 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
|
1108 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1109 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1110 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1111 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1112 | DEBUG_INFO("done marking\n"); |
|
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 | g_hash_table_destroy(stusers); |
|
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 | if(prune) { |
| 15884 | 1117 | purple_account_remove_buddies(acct, prune, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1118 | while(prune) { |
| 15884 | 1119 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1120 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1121 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1122 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1123 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1124 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1125 | |
| 15884 | 1126 | /** 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
|
1127 | existing buddies that aren't in the st list */ |
| 15884 | 1128 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 1129 | ||
| 1130 | PurpleAccount *acct; | |
| 1131 | PurpleBuddyList *blist; | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1132 | PurpleBlistNode *gn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1133 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1134 | GHashTable *stgroups; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1135 | GList *g_prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1136 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1137 | GList *gl, *gtl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1138 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1139 | const char *acct_n; |
|
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 | DEBUG_INFO("synchronizing local buddy list from server list\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1142 | |
| 15884 | 1143 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1144 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1145 | |
| 15884 | 1146 | acct_n = purple_account_get_username(acct); |
| 1147 | ||
|
34726
af52ff6660c0
Replaced purple_get_blist() with purple_blist_get_buddy_list()
Ankit Vani <a@nevitus.org>
parents:
34723
diff
changeset
|
1148 | blist = purple_blist_get_buddy_list(); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1149 | g_return_if_fail(blist != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1150 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1151 | /* 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
|
1152 | list, mapping group name to group structure */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1153 | 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
|
1154 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1155 | gtl = mwSametimeList_getGroups(stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1156 | for(gl = gtl; gl; gl = gl->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1157 | const char *name = mwSametimeGroup_getName(gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1158 | g_hash_table_insert(stgroups, (char *) name, gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1159 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1160 | g_list_free(gtl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1161 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1162 | /* 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
|
1163 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1164 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 15884 | 1165 | PurpleGroup *grp = (PurpleGroup *) gn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1166 | const char *gname, *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1167 | struct mwSametimeGroup *stgrp; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1168 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1169 | if(! PURPLE_IS_GROUP(gn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1170 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1171 | /* group not belonging to this account */ |
| 15884 | 1172 | if(! purple_group_on_account(grp, acct)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1173 | continue; |
|
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 | /* dynamic group belonging to this account. don't prune contents */ |
| 15884 | 1176 | 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
|
1177 | if(owner && !strcmp(owner, acct_n)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1178 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1179 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1180 | /* 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
|
1181 | title, which can be different things in the st list */ |
| 15884 | 1182 | 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
|
1183 | if(! gname) gname = purple_group_get_name(grp); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1184 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1185 | stgrp = g_hash_table_lookup(stgroups, gname); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1186 | if(! stgrp) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1187 | /* remove the whole group */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1188 | 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
|
1189 | g_prune = g_list_prepend(g_prune, grp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1190 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1191 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1192 | /* synch the group contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1193 | group_prune(gc, grp, stgrp); |
|
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 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1196 | DEBUG_INFO("done marking groups\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1197 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1198 | /* don't need this anymore */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1199 | g_hash_table_destroy(stgroups); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1200 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1201 | /* prune all marked groups */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1202 | while(g_prune) { |
| 15884 | 1203 | PurpleGroup *grp = g_prune->data; |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1204 | PurpleBlistNode *gn = (PurpleBlistNode *) grp; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1205 | const char *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1206 | gboolean del = TRUE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1207 | |
| 15884 | 1208 | 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
|
1209 | if(owner && strcmp(owner, acct_n)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1210 | /* 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
|
1211 | 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
|
1212 | del = FALSE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1213 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1214 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1215 | group_clear(g_prune->data, acct, del); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1216 | g_prune = g_list_delete_link(g_prune, g_prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1217 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1218 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1219 | /* done with the pruning, let's merge in the additions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1220 | blist_merge(gc, stlist); |
|
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 | |
| 10977 | 1224 | /** callback passed to the storage service when it's told to load the |
| 1225 | st list */ | |
| 1226 | static void fetch_blist_cb(struct mwServiceStorage *srvc, | |
| 1227 | guint32 result, struct mwStorageUnit *item, | |
| 1228 | gpointer data) { | |
| 1229 | ||
| 15884 | 1230 | struct mwPurplePluginData *pd = data; |
| 10977 | 1231 | struct mwSametimeList *stlist; |
| 1232 | ||
| 1233 | struct mwGetBuffer *b; | |
| 1234 | ||
| 1235 | g_return_if_fail(result == ERR_SUCCESS); | |
| 1236 | ||
| 1237 | /* check our preferences for loading */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1238 | if(BLIST_PREF_IS_LOCAL()) { |
| 10977 | 1239 | DEBUG_INFO("preferences indicate not to load remote buddy list\n"); |
| 1240 | return; | |
| 1241 | } | |
| 1242 | ||
| 1243 | b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); | |
| 1244 | ||
| 1245 | stlist = mwSametimeList_new(); | |
| 1246 | mwSametimeList_get(b, stlist); | |
| 1247 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1248 | /* merge or synch depending on preferences */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1249 | if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1250 | blist_merge(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1251 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1252 | } else if(BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1253 | blist_sync(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1254 | } |
| 10977 | 1255 | |
| 1256 | mwSametimeList_free(stlist); | |
| 22973 | 1257 | mwGetBuffer_free(b); |
| 10977 | 1258 | } |
| 1259 | ||
| 1260 | ||
| 15884 | 1261 | /** signal triggered when a conversation is opened in Purple */ |
| 1262 | static void conversation_created_cb(PurpleConversation *g_conv, | |
| 1263 | struct mwPurplePluginData *pd) { | |
| 10977 | 1264 | |
| 1265 | /* we need to tell the IM service to negotiate features for the | |
| 1266 | conversation right away, otherwise it'll wait until the first | |
| 1267 | message is sent before offering NotesBuddy features. Therefore | |
| 15884 | 1268 | whenever Purple creates a conversation, we'll immediately open the |
| 10977 | 1269 | channel to the other side and figure out what the target can |
| 1270 | handle. Unfortunately, this makes us vulnerable to Psychic Mode, | |
| 1271 | 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
|
1272 | would not */ |
| 10977 | 1273 | |
| 15884 | 1274 | PurpleConnection *gc; |
| 10977 | 1275 | struct mwIdBlock who = { 0, 0 }; |
| 1276 | struct mwConversation *conv; | |
| 1277 | ||
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1278 | gc = purple_conversation_get_connection(g_conv); |
| 10977 | 1279 | if(pd->gc != gc) |
| 1280 | return; /* not ours */ | |
| 1281 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1282 | if(PURPLE_IS_CHAT_CONVERSATION(g_conv)) |
| 10977 | 1283 | return; /* wrong type */ |
| 1284 | ||
| 15884 | 1285 | who.user = (char *) purple_conversation_get_name(g_conv); |
| 10977 | 1286 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 1287 | ||
| 1288 | convo_features(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1289 | |
| 10977 | 1290 | if(mwConversation_isClosed(conv)) |
| 1291 | mwConversation_open(conv); | |
| 1292 | } | |
| 1293 | ||
| 1294 | ||
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1295 | static void blist_menu_nab(PurpleBlistNode *node, gpointer data) { |
| 15884 | 1296 | struct mwPurplePluginData *pd = data; |
| 1297 | PurpleConnection *gc; | |
| 1298 | ||
| 1299 | PurpleGroup *group = (PurpleGroup *) node; | |
| 10977 | 1300 | |
| 1301 | GString *str; | |
| 1302 | char *tmp; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1303 | const char *gname; |
| 10977 | 1304 | |
| 1305 | g_return_if_fail(pd != NULL); | |
| 1306 | ||
| 1307 | gc = pd->gc; | |
| 1308 | g_return_if_fail(gc != NULL); | |
| 1309 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1310 | g_return_if_fail(PURPLE_IS_GROUP(node)); |
| 10977 | 1311 | |
| 1312 | str = g_string_new(NULL); | |
| 1313 | ||
| 15884 | 1314 | 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
|
1315 | gname = purple_group_get_name(group); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1316 | |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1317 | 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
|
1318 | 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
|
1319 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1320 | tmp = g_strdup_printf(_("Info for Group %s"), gname); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1321 | |
| 15884 | 1322 | purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
| 10977 | 1323 | NULL, str->str, NULL, NULL); |
| 1324 | ||
| 1325 | g_free(tmp); | |
| 1326 | g_string_free(str, TRUE); | |
| 1327 | } | |
| 1328 | ||
| 1329 | ||
| 1330 | /** The normal blist menu prpl function doesn't get called for groups, | |
| 1331 | so we use the blist-node-extended-menu signal to trigger this | |
| 1332 | handler */ | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1333 | static void blist_node_menu_cb(PurpleBlistNode *node, |
| 15884 | 1334 | GList **menu, struct mwPurplePluginData *pd) { |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1335 | const char *owner; |
| 15884 | 1336 | PurpleAccount *acct; |
| 1337 | PurpleMenuAction *act; | |
| 10977 | 1338 | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1339 | /* we only want groups */ |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1340 | if(! PURPLE_IS_GROUP(node)) return; |
| 15884 | 1341 | |
| 1342 | acct = purple_connection_get_account(pd->gc); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1343 | g_return_if_fail(acct != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1344 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1345 | /* better make sure we're connected */ |
| 15884 | 1346 | if(! purple_account_is_connected(acct)) return; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1347 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1348 | #if 0 |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1349 | /* 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
|
1350 | them all to a conference */ |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
1351 | group = (PurpleGroup *) node; |
| 15884 | 1352 | if(purple_group_on_account(group, acct)) { |
| 1353 | act = purple_menu_action_new(_("Invite Group to Conference..."), | |
| 1354 | PURPLE_CALLBACK(blist_menu_group_invite), | |
| 13021 | 1355 | pd, NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1356 | *menu = g_list_append(*menu, NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1357 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1358 | #endif |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1359 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1360 | /* check if it's a NAB group for this account */ |
| 15884 | 1361 | owner = purple_blist_node_get_string(node, GROUP_KEY_OWNER); |
| 1362 | if(owner && !strcmp(owner, purple_account_get_username(acct))) { | |
| 1363 | act = purple_menu_action_new(_("Get Notes Address Book Info"), | |
| 1364 | PURPLE_CALLBACK(blist_menu_nab), pd, NULL); | |
| 10977 | 1365 | *menu = g_list_append(*menu, act); |
| 1366 | } | |
| 1367 | } | |
| 1368 | ||
| 1369 | ||
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1370 | /* lifted this from oldstatus, since HEAD doesn't do this at login |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1371 | anymore. */ |
| 15884 | 1372 | static void blist_init(PurpleAccount *acct) { |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1373 | PurpleBlistNode *gnode, *cnode, *bnode; |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1374 | GList *add_buds = NULL; |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1375 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1376 | for(gnode = purple_blist_get_root(); gnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1377 | gnode = purple_blist_node_get_sibling_next(gnode)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1378 | if(! PURPLE_IS_GROUP(gnode)) continue; |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1379 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1380 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1381 | cnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1382 | cnode = purple_blist_node_get_sibling_next(cnode)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1383 | if(! PURPLE_IS_CONTACT(cnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1384 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1385 | for(bnode = purple_blist_node_get_first_child(cnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1386 | bnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1387 | bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 15884 | 1388 | PurpleBuddy *b; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1389 | if(!PURPLE_IS_BUDDY(bnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1390 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1391 | |
| 15884 | 1392 | b = (PurpleBuddy *)bnode; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1393 | if(purple_buddy_get_account(b) == acct) { |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1394 | add_buds = g_list_append(add_buds, b); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1395 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1396 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1397 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1398 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1399 | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1400 | if(add_buds) { |
|
32319
ab70b05e538b
sametime: fix build (add_buddies added param)
Paul Aurich <darkrain42@pidgin.im>
parents:
32316
diff
changeset
|
1401 | purple_account_add_buddies(acct, add_buds, NULL); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1402 | g_list_free(add_buds); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1403 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1404 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1405 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1406 | |
| 10977 | 1407 | /** Last thing to happen from a started session */ |
| 15884 | 1408 | static void services_starting(struct mwPurplePluginData *pd) { |
| 1409 | ||
| 1410 | PurpleConnection *gc; | |
| 1411 | PurpleAccount *acct; | |
| 10977 | 1412 | struct mwStorageUnit *unit; |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1413 | PurpleBlistNode *l; |
| 10977 | 1414 | |
| 1415 | gc = pd->gc; | |
| 15884 | 1416 | acct = purple_connection_get_account(gc); |
| 10977 | 1417 | |
| 1418 | /* grab the buddy list from the server */ | |
| 1419 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1420 | mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
| 10977 | 1421 | |
| 1422 | /* find all the NAB groups and subscribe to them */ | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1423 | for(l = purple_blist_get_root(); l; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1424 | l = purple_blist_node_get_sibling_next(l)) { |
| 15884 | 1425 | PurpleGroup *group = (PurpleGroup *) l; |
| 10977 | 1426 | enum mwSametimeGroupType gt; |
| 1427 | const char *owner; | |
| 1428 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1429 | if(! PURPLE_IS_GROUP(l)) continue; |
| 10977 | 1430 | |
| 1431 | /* if the group is ownerless, or has an owner and we're not it, | |
| 1432 | skip it */ | |
| 15884 | 1433 | owner = purple_blist_node_get_string(l, GROUP_KEY_OWNER); |
| 1434 | if(!owner || strcmp(owner, purple_account_get_username(acct))) | |
| 10977 | 1435 | continue; |
| 1436 | ||
| 15884 | 1437 | gt = purple_blist_node_get_int(l, GROUP_KEY_TYPE); |
| 10977 | 1438 | if(gt == mwSametimeGroup_DYNAMIC) |
| 1439 | group_add(pd, group); | |
| 1440 | } | |
| 1441 | ||
| 1442 | /* set the aware attributes */ | |
| 1443 | /* indicate we understand what AV prefs are, but don't support any */ | |
| 1444 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1445 | mwAttribute_AV_PREFS_SET, TRUE); | |
| 1446 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE); | |
| 1447 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS); | |
| 1448 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA); | |
| 1449 | ||
| 1450 | /* ... but we can do file transfers! */ | |
| 1451 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1452 | mwAttribute_FILE_TRANSFER, TRUE); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1453 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1454 | blist_init(acct); |
| 10977 | 1455 | } |
| 1456 | ||
| 1457 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1458 | static void session_loginRedirect(struct mwSession *session, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1459 | const char *host) { |
| 15884 | 1460 | struct mwPurplePluginData *pd; |
| 1461 | PurpleConnection *gc; | |
| 1462 | PurpleAccount *account; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1463 | guint port; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1464 | const char *current_host; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1465 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1466 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1467 | gc = pd->gc; |
| 15884 | 1468 | account = purple_connection_get_account(gc); |
| 1469 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); | |
| 1470 | current_host = purple_account_get_string(account, MW_KEY_HOST, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1471 | MW_PLUGIN_DEFAULT_HOST); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1472 | |
| 15884 | 1473 | if(purple_account_get_bool(account, MW_KEY_FORCE, FALSE) || |
|
24739
35f208241e4c
Patch from Raiko Nitzsche to fix a crash when processing a LOGIN_REDIRECT with unexpected output. References #7563.
Daniel Atallah <datallah@pidgin.im>
parents:
24591
diff
changeset
|
1474 | !host || (! strcmp(current_host, host)) || |
|
27343
8a367ee70456
Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents:
26752
diff
changeset
|
1475 | (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1476 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1477 | /* if we're configured to force logins, or if we're being |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1478 | redirected to the already configured host, or if we couldn't |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1479 | connect to the new host, we'll force the login instead */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1480 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1481 | mwSession_forceLogin(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1482 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1483 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1484 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1485 | |
| 15884 | 1486 | static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1487 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1488 | |
| 10977 | 1489 | /** called from mw_session_stateChange when the session's state is |
| 1490 | mwSession_STARTED. Any finalizing of start-up stuff should go | |
| 1491 | here */ | |
| 15884 | 1492 | static void session_started(struct mwPurplePluginData *pd) { |
| 1493 | PurpleStatus *status; | |
| 1494 | PurpleAccount *acct; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1495 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1496 | /* set out initial status */ |
| 15884 | 1497 | acct = purple_connection_get_account(pd->gc); |
| 1498 | status = purple_account_get_active_status(acct); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1499 | mw_prpl_set_status(acct, status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1500 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1501 | /* start watching for new conversations */ |
| 15884 | 1502 | purple_signal_connect(purple_conversations_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1503 | "conversation-created", pd, |
| 15884 | 1504 | PURPLE_CALLBACK(conversation_created_cb), pd); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1505 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1506 | /* watch for group extended menu items */ |
| 15884 | 1507 | purple_signal_connect(purple_blist_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1508 | "blist-node-extended-menu", pd, |
| 15884 | 1509 | PURPLE_CALLBACK(blist_node_menu_cb), pd); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1510 | |
| 10977 | 1511 | /* use our services to do neat things */ |
| 1512 | services_starting(pd); | |
| 1513 | } | |
| 1514 | ||
| 1515 | ||
| 15884 | 1516 | static void session_stopping(struct mwPurplePluginData *pd) { |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1517 | /* stop watching the signals from session_started */ |
| 15884 | 1518 | purple_signals_disconnect_by_handle(pd); |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1519 | } |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1520 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1521 | |
| 10977 | 1522 | static void mw_session_stateChange(struct mwSession *session, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1523 | enum mwSessionState state, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1524 | gpointer info) { |
| 15884 | 1525 | struct mwPurplePluginData *pd; |
| 1526 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1527 | const char *msg = NULL; |
| 10977 | 1528 | |
| 1529 | pd = mwSession_getClientData(session); | |
| 1530 | gc = pd->gc; | |
| 1531 | ||
| 1532 | switch(state) { | |
| 1533 | case mwSession_STARTING: | |
| 1534 | msg = _("Sending Handshake"); | |
| 15884 | 1535 | purple_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS); |
| 10977 | 1536 | break; |
| 1537 | ||
| 1538 | case mwSession_HANDSHAKE: | |
| 1539 | msg = _("Waiting for Handshake Acknowledgement"); | |
| 15884 | 1540 | purple_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS); |
| 10977 | 1541 | break; |
| 1542 | ||
| 1543 | case mwSession_HANDSHAKE_ACK: | |
| 1544 | msg = _("Handshake Acknowledged, Sending Login"); | |
| 15884 | 1545 | purple_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS); |
| 10977 | 1546 | break; |
| 1547 | ||
| 1548 | case mwSession_LOGIN: | |
| 1549 | msg = _("Waiting for Login Acknowledgement"); | |
| 15884 | 1550 | purple_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS); |
| 10977 | 1551 | break; |
| 1552 | ||
| 1553 | case mwSession_LOGIN_REDIR: | |
| 1554 | msg = _("Login Redirected"); | |
| 15884 | 1555 | purple_connection_update_progress(gc, msg, 6, MW_CONNECT_STEPS); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1556 | session_loginRedirect(session, info); |
| 10977 | 1557 | break; |
| 1558 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1559 | case mwSession_LOGIN_CONT: |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1560 | msg = _("Forcing Login"); |
| 15884 | 1561 | purple_connection_update_progress(gc, msg, 7, MW_CONNECT_STEPS); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1562 | |
| 10977 | 1563 | case mwSession_LOGIN_ACK: |
| 1564 | msg = _("Login Acknowledged"); | |
| 15884 | 1565 | purple_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS); |
| 10977 | 1566 | break; |
| 1567 | ||
| 1568 | case mwSession_STARTED: | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1569 | msg = _("Starting Services"); |
| 15884 | 1570 | purple_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS); |
| 10977 | 1571 | |
| 1572 | session_started(pd); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1573 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1574 | msg = _("Connected"); |
| 15884 | 1575 | purple_connection_update_progress(gc, msg, 10, MW_CONNECT_STEPS); |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1576 | purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED); |
| 10977 | 1577 | break; |
| 1578 | ||
| 1579 | case mwSession_STOPPING: | |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1580 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1581 | session_stopping(pd); |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1582 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1583 | if(GPOINTER_TO_UINT(info) & ERR_FAILURE) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1584 | char *err = mwError(GPOINTER_TO_UINT(info)); |
| 21279 | 1585 | PurpleConnectionError reason; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1586 | switch (GPOINTER_TO_UINT(info)) { |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1587 | case VERSION_MISMATCH: |
| 21279 | 1588 | reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1589 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1590 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1591 | case USER_RESTRICTED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1592 | case INCORRECT_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1593 | case USER_UNREGISTERED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1594 | case GUEST_IN_USE: |
| 21279 | 1595 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1596 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1597 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1598 | case ENCRYPT_MISMATCH: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1599 | case ERR_ENCRYPT_NO_SUPPORT: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1600 | case ERR_NO_COMMON_ENCRYPT: |
| 21279 | 1601 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1602 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1603 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1604 | case VERIFICATION_DOWN: |
| 21279 | 1605 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1606 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1607 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1608 | case MULTI_SERVER_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1609 | case MULTI_SERVER_LOGIN2: |
| 21279 | 1610 | reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1611 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1612 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1613 | default: |
| 21279 | 1614 | reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1615 | } |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1616 | purple_connection_error(gc, reason, err); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1617 | g_free(err); |
| 10977 | 1618 | } |
| 1619 | break; | |
| 1620 | ||
| 1621 | case mwSession_STOPPED: | |
| 1622 | break; | |
| 1623 | ||
| 1624 | case mwSession_UNKNOWN: | |
| 1625 | default: | |
| 1626 | DEBUG_WARN("session in unknown state\n"); | |
| 1627 | } | |
| 1628 | } | |
| 1629 | ||
| 1630 | ||
| 1631 | static void mw_session_setPrivacyInfo(struct mwSession *session) { | |
| 15884 | 1632 | struct mwPurplePluginData *pd; |
| 1633 | PurpleConnection *gc; | |
| 1634 | PurpleAccount *acct; | |
| 10977 | 1635 | struct mwPrivacyInfo *privacy; |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1636 | GSList *list; |
| 10977 | 1637 | guint count; |
| 1638 | ||
| 1639 | DEBUG_INFO("privacy information set from server\n"); | |
| 1640 | ||
| 1641 | g_return_if_fail(session != NULL); | |
| 1642 | ||
| 1643 | pd = mwSession_getClientData(session); | |
| 1644 | g_return_if_fail(pd != NULL); | |
| 1645 | ||
| 1646 | gc = pd->gc; | |
| 1647 | g_return_if_fail(gc != NULL); | |
| 1648 | ||
| 15884 | 1649 | acct = purple_connection_get_account(gc); |
| 10977 | 1650 | g_return_if_fail(acct != NULL); |
| 1651 | ||
| 1652 | privacy = mwSession_getPrivacyInfo(session); | |
| 1653 | count = privacy->count; | |
| 1654 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1655 | if (privacy->deny) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1656 | while ((list = purple_account_privacy_get_denied(acct))) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1657 | g_free(list->data); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1658 | purple_account_privacy_deny_remove(acct, list->data, TRUE); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1659 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1660 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1661 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1662 | purple_account_privacy_deny_add(acct, u->id, TRUE); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1663 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1664 | } else { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1665 | while ((list = purple_account_privacy_get_permitted(acct))) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1666 | g_free(list->data); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1667 | purple_account_privacy_permit_remove(acct, list->data, TRUE); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1668 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1669 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1670 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1671 | purple_account_privacy_permit_add(acct, u->id, TRUE); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1672 | } |
| 10977 | 1673 | } |
| 1674 | } | |
| 1675 | ||
| 1676 | ||
| 1677 | static void mw_session_setUserStatus(struct mwSession *session) { | |
| 15884 | 1678 | struct mwPurplePluginData *pd; |
| 1679 | PurpleConnection *gc; | |
| 10977 | 1680 | struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL }; |
| 1681 | struct mwUserStatus *stat; | |
| 1682 | ||
| 1683 | g_return_if_fail(session != NULL); | |
| 1684 | ||
| 1685 | pd = mwSession_getClientData(session); | |
| 1686 | g_return_if_fail(pd != NULL); | |
| 1687 | ||
| 1688 | gc = pd->gc; | |
| 1689 | g_return_if_fail(gc != NULL); | |
| 1690 | ||
| 1691 | idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); | |
| 1692 | stat = mwSession_getUserStatus(session); | |
| 1693 | ||
| 1694 | /* trigger an update of our own status if we're in the buddy list */ | |
| 1695 | mwServiceAware_setStatus(pd->srvc_aware, &idb, stat); | |
| 1696 | } | |
| 1697 | ||
| 1698 | ||
| 1699 | static void mw_session_admin(struct mwSession *session, | |
| 1700 | const char *text) { | |
| 15884 | 1701 | PurpleConnection *gc; |
| 1702 | PurpleAccount *acct; | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1703 | const char *host; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1704 | const char *msg; |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1705 | char *prim; |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1706 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1707 | gc = session_to_gc(session); |
| 10977 | 1708 | g_return_if_fail(gc != NULL); |
| 1709 | ||
| 15884 | 1710 | acct = purple_connection_get_account(gc); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1711 | g_return_if_fail(acct != NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1712 | |
| 15884 | 1713 | 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
|
1714 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1715 | msg = _("A Sametime administrator has issued the following announcement" |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1716 | " on server %s"); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1717 | prim = g_strdup_printf(msg, NSTR(host)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1718 | |
| 15884 | 1719 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1720 | _("Sametime Administrator Announcement"), |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1721 | prim, text, NULL, NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1722 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1723 | g_free(prim); |
| 10977 | 1724 | } |
| 1725 | ||
| 1726 | ||
| 1727 | /** called from read_cb, attempts to read available data from sock and | |
| 1728 | pass it to the session, passing back the return code from the read | |
| 1729 | call for handling in read_cb */ | |
| 1730 | static int read_recv(struct mwSession *session, int sock) { | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1731 | guchar buf[BUF_LEN]; |
| 10977 | 1732 | int len; |
| 1733 | ||
| 1734 | 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
|
1735 | 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
|
1736 | 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
|
1737 | } |
| 10977 | 1738 | |
| 1739 | return len; | |
| 1740 | } | |
| 1741 | ||
| 1742 | ||
| 15884 | 1743 | /** callback triggered from purple_input_add, watches the socked for |
| 10977 | 1744 | available data to be processed by the session */ |
| 15884 | 1745 | static void read_cb(gpointer data, gint source, PurpleInputCondition cond) { |
| 1746 | struct mwPurplePluginData *pd = data; | |
| 10977 | 1747 | int ret = 0, err = 0; |
| 1748 | ||
| 1749 | g_return_if_fail(pd != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1750 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1751 | ret = read_recv(pd->session, pd->socket); |
| 10977 | 1752 | |
| 1753 | /* normal operation ends here */ | |
| 1754 | if(ret > 0) return; | |
| 1755 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1756 | /* fetch the global error value */ |
| 10977 | 1757 | err = errno; |
| 1758 | ||
| 14754 | 1759 | /* read problem occurred if we're here, so we'll need to take care of |
| 10977 | 1760 | it and clean up internal state */ |
| 1761 | ||
| 1762 | if(pd->socket) { | |
| 1763 | close(pd->socket); | |
| 1764 | pd->socket = 0; | |
| 1765 | } | |
| 1766 | ||
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1767 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1768 | purple_input_remove(pd->inpa); |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1769 | pd->inpa = 0; |
| 10977 | 1770 | } |
| 1771 | ||
| 1772 | if(! ret) { | |
| 1773 | DEBUG_INFO("connection reset\n"); | |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1774 | purple_connection_error(pd->gc, |
| 21279 | 1775 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1776 | _("Server closed the connection")); |
| 10977 | 1777 | |
| 1778 | } 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
|
1779 | 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
|
1780 | 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
|
1781 | |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1782 | 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
|
1783 | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1784 | msg = g_strdup_printf(_("Lost connection with server: %s"), err_str); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1785 | purple_connection_error(pd->gc, |
| 21279 | 1786 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 1787 | msg); | |
| 10977 | 1788 | g_free(msg); |
| 1789 | } | |
| 1790 | } | |
| 1791 | ||
| 1792 | ||
| 15884 | 1793 | /** Callback passed to purple_proxy_connect when an account is logged |
| 10977 | 1794 | 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
|
1795 | static void connect_cb(gpointer data, gint source, const gchar *error_message) { |
| 10977 | 1796 | |
| 15884 | 1797 | struct mwPurplePluginData *pd = data; |
| 10977 | 1798 | |
| 1799 | if(source < 0) { | |
| 1800 | /* connection failed */ | |
| 1801 | ||
| 1802 | if(pd->socket) { | |
| 1803 | /* this is a redirect connect, force login on existing socket */ | |
| 1804 | mwSession_forceLogin(pd->session); | |
| 1805 | ||
| 1806 | } else { | |
| 1807 | /* this is a regular connect, error out */ | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1808 | 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
|
1809 | error_message); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1810 | purple_connection_error(pd->gc, |
| 21279 | 1811 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1812 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1813 | g_free(tmp); |
| 10977 | 1814 | } |
| 1815 | ||
| 1816 | return; | |
| 1817 | } | |
| 1818 | ||
| 1819 | if(pd->socket) { | |
| 1820 | /* stop any existing login attempt */ | |
| 1821 | mwSession_stop(pd->session, ERR_SUCCESS); | |
| 1822 | } | |
| 1823 | ||
| 1824 | pd->socket = source; | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1825 | pd->inpa = purple_input_add(source, PURPLE_INPUT_READ, |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
1826 | read_cb, pd); |
| 10977 | 1827 | |
| 1828 | mwSession_start(pd->session); | |
| 1829 | } | |
| 1830 | ||
| 1831 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1832 | static void mw_session_announce(struct mwSession *s, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1833 | struct mwLoginInfo *from, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1834 | gboolean may_reply, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1835 | const char *text) { |
| 15884 | 1836 | struct mwPurplePluginData *pd; |
| 1837 | PurpleAccount *acct; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1838 | PurpleIMConversation *im; |
| 15884 | 1839 | PurpleBuddy *buddy; |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1840 | char *who = from->user_id; |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1841 | char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1842 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1843 | pd = mwSession_getClientData(s); |
| 15884 | 1844 | acct = purple_connection_get_account(pd->gc); |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1845 | im = purple_conversations_find_im_with_account(who, acct); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1846 | if(! im) im = purple_im_conversation_new(acct, who); |
| 15884 | 1847 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
1848 | buddy = purple_blist_find_buddy(acct, who); |
| 15884 | 1849 | 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
|
1850 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1851 | who = g_strdup_printf(_("Announcement from %s"), who); |
| 15884 | 1852 | msg = purple_markup_linkify(text); |
| 1853 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1854 | purple_conversation_write(PURPLE_CONVERSATION(im), who, msg ? msg : "", |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1855 | PURPLE_MESSAGE_RECV, time(NULL)); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1856 | g_free(who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1857 | g_free(msg); |
| 10977 | 1858 | } |
| 1859 | ||
| 1860 | ||
| 1861 | static struct mwSessionHandler mw_session_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1862 | mw_session_io_write, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1863 | mw_session_io_close, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1864 | mw_session_clear, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1865 | mw_session_stateChange, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1866 | mw_session_setPrivacyInfo, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1867 | mw_session_setUserStatus, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1868 | mw_session_admin, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1869 | mw_session_announce, |
| 10977 | 1870 | }; |
| 1871 | ||
| 1872 | ||
| 1873 | static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
| 1874 | struct mwAwareAttribute *attrib) { | |
| 1875 | ||
| 1876 | ; /** @todo handle server attributes. There may be some stuff we | |
| 1877 | actually want to look for, but I'm not aware of anything right | |
| 1878 | now.*/ | |
| 1879 | } | |
| 1880 | ||
| 1881 | ||
| 1882 | static void mw_aware_clear(struct mwServiceAware *srvc) { | |
| 1883 | ; /* nothing for now */ | |
| 1884 | } | |
| 1885 | ||
| 1886 | ||
| 1887 | static struct mwAwareHandler mw_aware_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1888 | mw_aware_on_attrib, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1889 | mw_aware_clear, |
| 10977 | 1890 | }; |
| 1891 | ||
| 1892 | ||
| 1893 | static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
| 1894 | struct mwServiceAware *srvc; | |
| 1895 | srvc = mwServiceAware_new(s, &mw_aware_handler); | |
| 1896 | return srvc; | |
| 1897 | }; | |
| 1898 | ||
| 1899 | ||
| 1900 | static void mw_conf_invited(struct mwConference *conf, | |
| 1901 | struct mwLoginInfo *inviter, | |
| 1902 | const char *invitation) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1903 | |
| 10977 | 1904 | struct mwServiceConference *srvc; |
| 1905 | struct mwSession *session; | |
| 15884 | 1906 | struct mwPurplePluginData *pd; |
| 1907 | PurpleConnection *gc; | |
| 10977 | 1908 | |
| 1909 | char *c_inviter, *c_name, *c_topic, *c_invitation; | |
| 1910 | GHashTable *ht; | |
| 1911 | ||
| 1912 | srvc = mwConference_getService(conf); | |
| 1913 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1914 | pd = mwSession_getClientData(session); | |
| 1915 | gc = pd->gc; | |
| 1916 | ||
| 1917 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1918 | ||
| 1919 | c_inviter = g_strdup(inviter->user_id); | |
| 1920 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
| 1921 | ||
| 1922 | c_name = g_strdup(mwConference_getName(conf)); | |
| 1923 | g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
| 1924 | ||
| 1925 | c_topic = g_strdup(mwConference_getTitle(conf)); | |
| 1926 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
| 1927 | ||
| 1928 | c_invitation = g_strdup(invitation); | |
| 1929 | g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
| 1930 | ||
| 1931 | DEBUG_INFO("received invitation from '%s' to join ('%s','%s'): '%s'\n", | |
| 1932 | NSTR(c_inviter), NSTR(c_name), | |
| 1933 | NSTR(c_topic), NSTR(c_invitation)); | |
| 1934 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1935 | if(! c_topic) c_topic = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1936 | if(! c_invitation) c_invitation = "(no message)"; |
| 10977 | 1937 | serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
| 1938 | } | |
| 1939 | ||
| 1940 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1941 | /* The following mess helps us relate a mwConference to a PurpleChatConversation |
| 10977 | 1942 | in the various forms by which either may be indicated */ |
| 1943 | ||
| 1944 | #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
| 1945 | #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
| 1946 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1947 | #define CHAT_TO_ID(chat) (purple_chat_conversation_get_id(chat)) |
|
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1948 | #define ID_TO_CHAT(id) (purple_conversations_find_chat(id)) |
| 10977 | 1949 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1950 | #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
|
1951 | #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
| 10977 | 1952 | |
| 1953 | ||
| 1954 | static struct mwConference * | |
| 15884 | 1955 | conf_find_by_id(struct mwPurplePluginData *pd, int id) { |
| 10977 | 1956 | |
| 1957 | struct mwServiceConference *srvc = pd->srvc_conf; | |
| 1958 | struct mwConference *conf = NULL; | |
| 1959 | GList *l, *ll; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1960 | |
| 10977 | 1961 | ll = mwServiceConference_getConferences(srvc); |
| 1962 | for(l = ll; l; l = l->next) { | |
| 1963 | struct mwConference *c = l->data; | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1964 | PurpleChatConversation *h = mwConference_getClientData(c); |
| 10977 | 1965 | |
| 1966 | if(CHAT_TO_ID(h) == id) { | |
| 1967 | conf = c; | |
| 1968 | break; | |
| 1969 | } | |
| 1970 | } | |
| 1971 | g_list_free(ll); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1972 | |
| 10977 | 1973 | return conf; |
| 1974 | } | |
| 1975 | ||
| 1976 | ||
| 1977 | static void mw_conf_opened(struct mwConference *conf, GList *members) { | |
| 1978 | struct mwServiceConference *srvc; | |
| 1979 | struct mwSession *session; | |
| 15884 | 1980 | struct mwPurplePluginData *pd; |
| 1981 | PurpleConnection *gc; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1982 | PurpleChatConversation *g_conf; |
| 10977 | 1983 | |
| 1984 | const char *n = mwConference_getName(conf); | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1985 | const char *t = mwConference_getTitle(conf); |
| 10977 | 1986 | |
| 1987 | DEBUG_INFO("conf %s opened, %u initial members\n", | |
| 1988 | NSTR(n), g_list_length(members)); | |
| 1989 | ||
| 1990 | srvc = mwConference_getService(conf); | |
| 1991 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1992 | pd = mwSession_getClientData(session); | |
| 1993 | gc = pd->gc; | |
| 1994 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1995 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1996 | g_conf = serv_got_joined_chat(gc, CONF_TO_ID(conf), t); |
| 10977 | 1997 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1998 | mwConference_setClientData(conf, g_conf, NULL); |
| 10977 | 1999 | |
| 2000 | for(; members; members = members->next) { | |
| 2001 | struct mwLoginInfo *peer = members->data; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2002 | purple_chat_conversation_add_user(g_conf, peer->user_id, |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
2003 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
| 10977 | 2004 | } |
| 2005 | } | |
| 2006 | ||
| 2007 | ||
| 2008 | static void mw_conf_closed(struct mwConference *conf, guint32 reason) { | |
| 2009 | struct mwServiceConference *srvc; | |
| 2010 | struct mwSession *session; | |
| 15884 | 2011 | struct mwPurplePluginData *pd; |
| 2012 | PurpleConnection *gc; | |
| 10977 | 2013 | |
| 2014 | const char *n = mwConference_getName(conf); | |
| 2015 | char *msg = mwError(reason); | |
| 2016 | ||
| 2017 | DEBUG_INFO("conf %s closed, 0x%08x\n", NSTR(n), reason); | |
| 2018 | ||
| 2019 | srvc = mwConference_getService(conf); | |
| 2020 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2021 | pd = mwSession_getClientData(session); | |
| 2022 | gc = pd->gc; | |
| 2023 | ||
| 2024 | serv_got_chat_left(gc, CONF_TO_ID(conf)); | |
| 2025 | ||
| 15884 | 2026 | purple_notify_error(gc, _("Conference Closed"), NULL, msg); |
| 10977 | 2027 | g_free(msg); |
| 2028 | } | |
| 2029 | ||
| 2030 | ||
| 2031 | static void mw_conf_peer_joined(struct mwConference *conf, | |
| 2032 | struct mwLoginInfo *peer) { | |
| 2033 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2034 | PurpleChatConversation *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 | g_conf = mwConference_getClientData(conf); | |
| 2041 | g_return_if_fail(g_conf != NULL); | |
| 2042 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2043 | purple_chat_conversation_add_user(g_conf, peer->user_id, |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
2044 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
| 10977 | 2045 | } |
| 2046 | ||
| 2047 | ||
| 2048 | static void mw_conf_peer_parted(struct mwConference *conf, | |
| 2049 | struct mwLoginInfo *peer) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2050 | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2051 | PurpleChatConversation *g_conf; |
| 10977 | 2052 | |
| 2053 | const char *n = mwConference_getName(conf); | |
| 2054 | ||
| 2055 | DEBUG_INFO("%s left conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2056 | ||
| 2057 | g_conf = mwConference_getClientData(conf); | |
| 2058 | g_return_if_fail(g_conf != NULL); | |
| 2059 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2060 | purple_chat_conversation_remove_user(g_conf, peer->user_id, NULL); |
| 10977 | 2061 | } |
| 2062 | ||
| 2063 | ||
| 2064 | static void mw_conf_text(struct mwConference *conf, | |
| 2065 | struct mwLoginInfo *who, const char *text) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2066 | |
| 10977 | 2067 | struct mwServiceConference *srvc; |
| 2068 | struct mwSession *session; | |
| 15884 | 2069 | struct mwPurplePluginData *pd; |
| 2070 | PurpleConnection *gc; | |
| 10977 | 2071 | char *esc; |
| 2072 | ||
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2073 | if(! text) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2074 | |
| 10977 | 2075 | srvc = mwConference_getService(conf); |
| 2076 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2077 | pd = mwSession_getClientData(session); | |
| 2078 | gc = pd->gc; | |
| 2079 | ||
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2080 | esc = g_markup_escape_text(text, -1); |
| 10977 | 2081 | serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, 0, esc, time(NULL)); |
| 2082 | g_free(esc); | |
| 2083 | } | |
| 2084 | ||
| 2085 | ||
| 2086 | static void mw_conf_typing(struct mwConference *conf, | |
| 2087 | struct mwLoginInfo *who, gboolean typing) { | |
| 2088 | ||
| 15884 | 2089 | /* purple really has no good way to expose this to the user. */ |
| 10977 | 2090 | |
| 2091 | const char *n = mwConference_getName(conf); | |
| 2092 | const char *w = who->user_id; | |
| 2093 | ||
| 2094 | if(typing) { | |
| 2095 | DEBUG_INFO("%s in conf %s: <typing>\n", NSTR(w), NSTR(n)); | |
| 2096 | ||
| 2097 | } else { | |
| 2098 | DEBUG_INFO("%s in conf %s: <stopped typing>\n", NSTR(w), NSTR(n)); | |
| 2099 | } | |
| 2100 | } | |
| 2101 | ||
| 2102 | ||
| 2103 | static void mw_conf_clear(struct mwServiceConference *srvc) { | |
| 2104 | ; | |
| 2105 | } | |
| 2106 | ||
| 2107 | ||
| 2108 | static struct mwConferenceHandler mw_conference_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2109 | mw_conf_invited, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2110 | mw_conf_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2111 | mw_conf_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2112 | mw_conf_peer_joined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2113 | mw_conf_peer_parted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2114 | mw_conf_text, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2115 | mw_conf_typing, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2116 | mw_conf_clear, |
| 10977 | 2117 | }; |
| 2118 | ||
| 2119 | ||
| 2120 | static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) { | |
| 2121 | struct mwServiceConference *srvc; | |
| 2122 | srvc = mwServiceConference_new(s, &mw_conference_handler); | |
| 2123 | return srvc; | |
| 2124 | } | |
| 2125 | ||
| 2126 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2127 | /** size of an outgoing file transfer chunk */ |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2128 | #define MW_FT_LEN (BUF_LONG * 2) |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2129 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2130 | |
| 15884 | 2131 | static void ft_incoming_cancel(PurpleXfer *xfer) { |
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29304
diff
changeset
|
2132 | /* incoming transfer rejected or cancelled in-progress */ |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2133 | struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
| 10977 | 2134 | if(ft) mwFileTransfer_reject(ft); |
| 2135 | } | |
| 2136 | ||
| 2137 | ||
| 15884 | 2138 | static void ft_incoming_init(PurpleXfer *xfer) { |
| 10977 | 2139 | /* incoming transfer accepted */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2140 | |
| 10977 | 2141 | /* - accept the mwFileTransfer |
| 2142 | - open/create the local FILE "wb" | |
| 2143 | - stick the FILE's fp in xfer->dest_fp | |
| 2144 | */ | |
| 2145 | ||
| 2146 | struct mwFileTransfer *ft; | |
| 2147 | FILE *fp; | |
| 2148 | ||
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2149 | ft = purple_xfer_get_protocol_data(xfer); |
| 10977 | 2150 | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2151 | fp = g_fopen(purple_xfer_get_local_filename(xfer), "wb"); |
| 10977 | 2152 | if(! fp) { |
| 2153 | mwFileTransfer_cancel(ft); | |
| 2154 | return; | |
| 2155 | } | |
| 2156 | ||
| 2157 | xfer->dest_fp = fp; | |
| 2158 | mwFileTransfer_accept(ft); | |
| 2159 | } | |
| 2160 | ||
| 2161 | ||
| 2162 | static void mw_ft_offered(struct mwFileTransfer *ft) { | |
| 2163 | /* | |
| 15884 | 2164 | - create a purple ft object |
| 10977 | 2165 | - offer it |
| 2166 | */ | |
| 2167 | ||
| 2168 | struct mwServiceFileTransfer *srvc; | |
| 2169 | struct mwSession *session; | |
| 15884 | 2170 | struct mwPurplePluginData *pd; |
| 2171 | PurpleConnection *gc; | |
| 2172 | PurpleAccount *acct; | |
| 10977 | 2173 | const char *who; |
| 15884 | 2174 | PurpleXfer *xfer; |
| 10977 | 2175 | |
| 2176 | /* @todo add some safety checks */ | |
| 2177 | srvc = mwFileTransfer_getService(ft); | |
| 2178 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2179 | pd = mwSession_getClientData(session); | |
| 2180 | gc = pd->gc; | |
| 15884 | 2181 | acct = purple_connection_get_account(gc); |
| 10977 | 2182 | |
| 2183 | who = mwFileTransfer_getUser(ft)->user; | |
| 2184 | ||
| 2185 | DEBUG_INFO("file transfer %p offered\n", ft); | |
| 2186 | DEBUG_INFO(" from: %s\n", NSTR(who)); | |
| 2187 | DEBUG_INFO(" file: %s\n", NSTR(mwFileTransfer_getFileName(ft))); | |
| 2188 | DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft)); | |
| 2189 | DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft))); | |
| 2190 | ||
| 15884 | 2191 | xfer = purple_xfer_new(acct, PURPLE_XFER_RECEIVE, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2192 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2193 | { |
| 15884 | 2194 | purple_xfer_ref(xfer); |
| 2195 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2196 | purple_xfer_set_protocol_data(xfer, ft); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2197 | |
| 15884 | 2198 | purple_xfer_set_init_fnc(xfer, ft_incoming_init); |
| 2199 | purple_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); | |
| 2200 | purple_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); | |
| 2201 | ||
| 2202 | purple_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); | |
| 2203 | purple_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); | |
| 2204 | purple_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); | |
| 2205 | ||
| 2206 | purple_xfer_request(xfer); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2207 | } |
| 10977 | 2208 | } |
| 2209 | ||
| 2210 | ||
| 2211 | static void ft_send(struct mwFileTransfer *ft, FILE *fp) { | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2212 | 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
|
2213 | struct mwOpaque o = { MW_FT_LEN, buf }; |
| 10977 | 2214 | guint32 rem; |
| 15884 | 2215 | PurpleXfer *xfer; |
| 10977 | 2216 | |
| 2217 | xfer = mwFileTransfer_getClientData(ft); | |
| 2218 | ||
| 2219 | rem = mwFileTransfer_getRemaining(ft); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2220 | if(rem < MW_FT_LEN) o.len = rem; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2221 | |
| 10977 | 2222 | if(fread(buf, (size_t) o.len, 1, fp)) { |
| 2223 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2224 | /* calculate progress and display it */ |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2225 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + o.len); |
| 15884 | 2226 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2227 | |
| 10977 | 2228 | mwFileTransfer_send(ft, &o); |
| 2229 | ||
| 2230 | } else { | |
| 2231 | int err = errno; | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2232 | 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
|
2233 | NSTR(mwFileTransfer_getFileName(ft)), g_strerror(err)); |
| 10977 | 2234 | |
| 2235 | mwFileTransfer_cancel(ft); | |
| 2236 | } | |
| 2237 | } | |
| 2238 | ||
| 2239 | ||
| 2240 | static void mw_ft_opened(struct mwFileTransfer *ft) { | |
| 2241 | /* | |
| 15884 | 2242 | - get purple ft from client data in ft |
| 10977 | 2243 | - set the state to active |
| 2244 | */ | |
| 2245 | ||
| 15884 | 2246 | PurpleXfer *xfer; |
| 10977 | 2247 | |
| 2248 | xfer = mwFileTransfer_getClientData(ft); | |
| 2249 | ||
| 2250 | if(! xfer) { | |
| 2251 | mwFileTransfer_cancel(ft); | |
| 2252 | mwFileTransfer_free(ft); | |
| 2253 | g_return_if_reached(); | |
| 2254 | } | |
| 2255 | ||
| 15884 | 2256 | if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2257 | xfer->dest_fp = g_fopen(purple_xfer_get_local_filename(xfer), "rb"); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2258 | ft_send(ft, xfer->dest_fp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2259 | } |
| 10977 | 2260 | } |
| 2261 | ||
| 2262 | ||
| 2263 | static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
| 2264 | /* | |
| 15884 | 2265 | - get purple ft from client data in ft |
| 10977 | 2266 | - indicate rejection/cancelation/completion |
| 2267 | - free the file transfer itself | |
| 2268 | */ | |
| 2269 | ||
| 15884 | 2270 | PurpleXfer *xfer; |
| 10977 | 2271 | |
| 2272 | xfer = mwFileTransfer_getClientData(ft); | |
| 2273 | if(xfer) { | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2274 | purple_xfer_set_protocol_data(xfer, NULL); |
| 10977 | 2275 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2276 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2277 | purple_xfer_set_completed(xfer, TRUE); |
| 2278 | purple_xfer_end(xfer); | |
| 10977 | 2279 | |
| 2280 | } else if(mwFileTransfer_isCancelLocal(ft)) { | |
| 15884 | 2281 | /* calling purple_xfer_cancel_local is redundant, since that's |
| 10977 | 2282 | probably what triggered this function to be called */ |
| 2283 | ; | |
| 2284 | ||
| 2285 | } else if(mwFileTransfer_isCancelRemote(ft)) { | |
| 2286 | /* steal the reference for the xfer */ | |
| 2287 | mwFileTransfer_setClientData(ft, NULL, NULL); | |
| 15884 | 2288 | purple_xfer_cancel_remote(xfer); |
| 10977 | 2289 | |
| 2290 | /* drop the stolen reference */ | |
| 15884 | 2291 | purple_xfer_unref(xfer); |
| 10977 | 2292 | return; |
| 2293 | } | |
| 2294 | } | |
| 2295 | ||
| 2296 | mwFileTransfer_free(ft); | |
| 2297 | } | |
| 2298 | ||
| 2299 | ||
| 2300 | static void mw_ft_recv(struct mwFileTransfer *ft, | |
| 2301 | struct mwOpaque *data) { | |
| 2302 | /* | |
| 15884 | 2303 | - get purple ft from client data in ft |
| 10977 | 2304 | - update transfered percentage |
| 15884 | 2305 | - if done, destroy the ft, disassociate from purple ft |
| 10977 | 2306 | */ |
| 2307 | ||
| 15884 | 2308 | PurpleXfer *xfer; |
| 10977 | 2309 | 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
|
2310 | size_t wc; |
| 10977 | 2311 | |
| 2312 | xfer = mwFileTransfer_getClientData(ft); | |
| 2313 | g_return_if_fail(xfer != NULL); | |
| 2314 | ||
| 2315 | fp = xfer->dest_fp; | |
| 2316 | g_return_if_fail(fp != NULL); | |
| 2317 | ||
| 2318 | /* 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
|
2319 | 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
|
2320 | 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
|
2321 | 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
|
2322 | 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
|
2323 | return; |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2324 | } |
| 10977 | 2325 | |
| 2326 | /* update the progress */ | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2327 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + data->len); |
| 15884 | 2328 | purple_xfer_update_progress(xfer); |
| 10977 | 2329 | |
| 2330 | /* let the other side know we got it, and to send some more */ | |
| 2331 | mwFileTransfer_ack(ft); | |
| 2332 | } | |
| 2333 | ||
| 2334 | ||
| 2335 | static void mw_ft_ack(struct mwFileTransfer *ft) { | |
| 15884 | 2336 | PurpleXfer *xfer; |
| 10977 | 2337 | |
| 2338 | xfer = mwFileTransfer_getClientData(ft); | |
| 2339 | g_return_if_fail(xfer != NULL); | |
|
32705
9d97ac4c2c22
Sametime: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents:
32698
diff
changeset
|
2340 | g_return_if_fail(purple_xfer_get_watcher(xfer) == 0); |
| 10977 | 2341 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2342 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2343 | purple_xfer_set_completed(xfer, TRUE); |
| 2344 | purple_xfer_end(xfer); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2345 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2346 | } else if(mwFileTransfer_isOpen(ft)) { |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2347 | ft_send(ft, xfer->dest_fp); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2348 | } |
| 10977 | 2349 | } |
| 2350 | ||
| 2351 | ||
| 2352 | static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
| 2353 | ; | |
| 2354 | } | |
| 2355 | ||
| 2356 | ||
| 2357 | static struct mwFileTransferHandler mw_ft_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2358 | mw_ft_offered, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2359 | mw_ft_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2360 | mw_ft_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2361 | mw_ft_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2362 | mw_ft_ack, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2363 | mw_ft_clear, |
| 10977 | 2364 | }; |
| 2365 | ||
| 2366 | ||
| 2367 | static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
| 2368 | struct mwServiceFileTransfer *srvc; | |
| 2369 | GHashTable *ft_map; | |
| 2370 | ||
| 2371 | ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 2372 | ||
| 2373 | srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
| 2374 | mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
| 2375 | (GDestroyNotify) g_hash_table_destroy); | |
| 2376 | ||
| 2377 | return srvc; | |
| 2378 | } | |
| 2379 | ||
| 2380 | ||
| 2381 | static void convo_data_free(struct convo_data *cd) { | |
| 2382 | GList *l; | |
| 2383 | ||
| 2384 | /* clean the queue */ | |
| 2385 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2386 | struct convo_msg *m = l->data; | |
| 2387 | if(m->clear) m->clear(m->data); | |
| 2388 | g_free(m); | |
| 2389 | } | |
| 2390 | ||
| 2391 | g_free(cd); | |
| 2392 | } | |
| 2393 | ||
| 2394 | ||
| 2395 | /** allocates a convo_data structure and associates it with the | |
| 2396 | conversation in the client data slot */ | |
| 2397 | static void convo_data_new(struct mwConversation *conv) { | |
| 2398 | struct convo_data *cd; | |
| 2399 | ||
| 2400 | g_return_if_fail(conv != NULL); | |
| 2401 | ||
| 2402 | if(mwConversation_getClientData(conv)) | |
| 2403 | return; | |
| 2404 | ||
| 2405 | cd = g_new0(struct convo_data, 1); | |
| 2406 | cd->conv = conv; | |
| 2407 | ||
| 2408 | mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
| 2409 | } | |
| 2410 | ||
| 2411 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2412 | static PurpleIMConversation *convo_get_im(struct mwConversation *conv) { |
| 10977 | 2413 | struct mwServiceIm *srvc; |
| 2414 | struct mwSession *session; | |
| 15884 | 2415 | struct mwPurplePluginData *pd; |
| 2416 | PurpleConnection *gc; | |
| 2417 | PurpleAccount *acct; | |
| 10977 | 2418 | |
| 2419 | struct mwIdBlock *idb; | |
| 2420 | ||
| 2421 | srvc = mwConversation_getService(conv); | |
| 2422 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2423 | pd = mwSession_getClientData(session); | |
| 2424 | gc = pd->gc; | |
| 15884 | 2425 | acct = purple_connection_get_account(gc); |
| 10977 | 2426 | |
| 2427 | idb = mwConversation_getTarget(conv); | |
| 2428 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2429 | return purple_conversations_find_im_with_account(idb->user, acct); |
| 10977 | 2430 | } |
| 2431 | ||
| 2432 | ||
| 2433 | static void convo_queue(struct mwConversation *conv, | |
| 2434 | enum mwImSendType type, gconstpointer data) { | |
| 2435 | ||
| 2436 | struct convo_data *cd; | |
| 2437 | struct convo_msg *m; | |
| 2438 | ||
| 2439 | convo_data_new(conv); | |
| 2440 | cd = mwConversation_getClientData(conv); | |
| 2441 | ||
| 2442 | m = g_new0(struct convo_msg, 1); | |
| 2443 | m->type = type; | |
| 2444 | ||
| 2445 | switch(type) { | |
| 2446 | case mwImSend_PLAIN: | |
| 2447 | m->data = g_strdup(data); | |
| 2448 | m->clear = g_free; | |
| 2449 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2450 | |
| 10977 | 2451 | case mwImSend_TYPING: |
| 2452 | default: | |
| 2453 | m->data = (gpointer) data; | |
| 2454 | m->clear = NULL; | |
| 2455 | } | |
| 2456 | ||
| 2457 | cd->queue = g_list_append(cd->queue, m); | |
| 2458 | } | |
| 2459 | ||
| 2460 | ||
| 2461 | /* Does what it takes to get an error displayed for a conversation */ | |
| 2462 | static void convo_error(struct mwConversation *conv, guint32 err) { | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2463 | PurpleIMConversation *im; |
| 10977 | 2464 | char *tmp, *text; |
| 2465 | struct mwIdBlock *idb; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2466 | |
| 10977 | 2467 | idb = mwConversation_getTarget(conv); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2468 | |
| 10977 | 2469 | tmp = mwError(err); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2470 | text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2471 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2472 | im = convo_get_im(conv); |
|
34868
faa5b053f310
Replaced purple_conversation_helper_present_error() with simpler purple_conversation_present_error()
Ankit Vani <a@nevitus.org>
parents:
34865
diff
changeset
|
2473 | if(im && !purple_conversation_present_error(idb->user, |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2474 | purple_conversation_get_account(PURPLE_CONVERSATION(im)), text)) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2475 | |
| 10977 | 2476 | g_free(text); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2477 | text = g_strdup_printf(_("Unable to send message to %s:"), |
| 10977 | 2478 | (idb->user)? idb->user: "(unknown)"); |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2479 | purple_notify_error(purple_account_get_connection( |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2480 | purple_conversation_get_account(PURPLE_CONVERSATION(im))), |
| 10977 | 2481 | NULL, text, tmp); |
| 2482 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2483 | |
| 10977 | 2484 | g_free(tmp); |
| 2485 | g_free(text); | |
| 2486 | } | |
| 2487 | ||
| 2488 | ||
| 2489 | static void convo_queue_send(struct mwConversation *conv) { | |
| 2490 | struct convo_data *cd; | |
| 2491 | GList *l; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2492 | |
| 10977 | 2493 | cd = mwConversation_getClientData(conv); |
| 2494 | ||
| 2495 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2496 | struct convo_msg *m = l->data; | |
| 2497 | ||
| 2498 | mwConversation_send(conv, m->type, m->data); | |
| 2499 | ||
| 2500 | if(m->clear) m->clear(m->data); | |
| 2501 | g_free(m); | |
| 2502 | } | |
| 2503 | ||
| 2504 | cd->queue = NULL; | |
| 2505 | } | |
| 2506 | ||
| 2507 | ||
| 15884 | 2508 | /** called when a mw conversation leaves a purple conversation to |
| 2509 | inform the purple conversation that it's unsafe to offer any *cool* | |
| 10977 | 2510 | features. */ |
| 2511 | static void convo_nofeatures(struct mwConversation *conv) { | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2512 | PurpleIMConversation *im; |
| 15884 | 2513 | PurpleConnection *gc; |
| 10977 | 2514 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2515 | im = convo_get_im(conv); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2516 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2517 | |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2518 | gc = purple_conversation_get_connection(PURPLE_CONVERSATION(im)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2519 | if(! gc) return; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2520 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2521 | purple_conversation_set_features(PURPLE_CONVERSATION(im), |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2522 | purple_connection_get_flags(gc)); |
| 15884 | 2523 | } |
| 2524 | ||
| 2525 | ||
| 2526 | /** called when a mw conversation and purple conversation come together, | |
| 2527 | to inform the purple conversation of what features to offer the | |
| 10977 | 2528 | user */ |
| 2529 | static void convo_features(struct mwConversation *conv) { | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2530 | PurpleIMConversation *im; |
| 15884 | 2531 | PurpleConnectionFlags feat; |
| 10977 | 2532 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2533 | im = convo_get_im(conv); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2534 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2535 | |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2536 | feat = purple_conversation_get_features(PURPLE_CONVERSATION(im)); |
| 10977 | 2537 | |
| 2538 | if(mwConversation_isOpen(conv)) { | |
| 2539 | if(mwConversation_supports(conv, mwImSend_HTML)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2540 | feat |= PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2541 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2542 | feat &= ~PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2543 | } |
| 2544 | ||
| 2545 | if(mwConversation_supports(conv, mwImSend_MIME)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2546 | feat &= ~PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2547 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2548 | feat |= PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2549 | } |
| 2550 | ||
| 2551 | DEBUG_INFO("conversation features set to 0x%04x\n", feat); | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2552 | purple_conversation_set_features(PURPLE_CONVERSATION(im), feat); |
| 10977 | 2553 | |
| 2554 | } else { | |
| 2555 | convo_nofeatures(conv); | |
| 2556 | } | |
| 2557 | } | |
| 2558 | ||
| 2559 | ||
| 2560 | static void mw_conversation_opened(struct mwConversation *conv) { | |
| 2561 | struct mwServiceIm *srvc; | |
| 2562 | struct mwSession *session; | |
| 15884 | 2563 | struct mwPurplePluginData *pd; |
| 2564 | PurpleConnection *gc; | |
| 2565 | PurpleAccount *acct; | |
| 10977 | 2566 | |
| 2567 | struct convo_dat *cd; | |
| 2568 | ||
| 2569 | srvc = mwConversation_getService(conv); | |
| 2570 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2571 | pd = mwSession_getClientData(session); | |
| 2572 | gc = pd->gc; | |
| 15884 | 2573 | acct = purple_connection_get_account(gc); |
| 10977 | 2574 | |
| 2575 | /* set up the queue */ | |
| 2576 | cd = mwConversation_getClientData(conv); | |
| 2577 | if(cd) { | |
| 2578 | convo_queue_send(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2579 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2580 | if(! convo_get_im(conv)) { |
| 10977 | 2581 | mwConversation_free(conv); |
| 2582 | return; | |
| 2583 | } | |
| 2584 | ||
| 2585 | } else { | |
| 2586 | convo_data_new(conv); | |
| 2587 | } | |
| 2588 | ||
| 2589 | { /* record the client key for the buddy */ | |
| 15884 | 2590 | PurpleBuddy *buddy; |
| 10977 | 2591 | struct mwLoginInfo *info; |
| 2592 | info = mwConversation_getTargetInfo(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2593 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
2594 | buddy = purple_blist_find_buddy(acct, info->user_id); |
| 10977 | 2595 | if(buddy) { |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
2596 | purple_blist_node_set_int((PurpleBlistNode *) buddy, |
| 10977 | 2597 | BUDDY_KEY_CLIENT, info->type); |
| 2598 | } | |
| 2599 | } | |
| 2600 | ||
| 2601 | convo_features(conv); | |
| 2602 | } | |
| 2603 | ||
| 2604 | ||
| 2605 | static void mw_conversation_closed(struct mwConversation *conv, | |
| 2606 | guint32 reason) { | |
| 2607 | ||
| 2608 | struct convo_data *cd; | |
| 2609 | ||
| 2610 | g_return_if_fail(conv != NULL); | |
| 2611 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2612 | /* 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
|
2613 | print an error message to the conversation */ |
| 10977 | 2614 | cd = mwConversation_getClientData(conv); |
| 2615 | if(reason && cd && cd->queue) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2616 | GList *l; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2617 | for(l = cd->queue; l; l = l->next) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2618 | struct convo_msg *m = l->data; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2619 | if(m->type != mwImSend_TYPING) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2620 | convo_error(conv, reason); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2621 | break; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2622 | } |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2623 | } |
| 10977 | 2624 | } |
| 2625 | ||
| 2626 | #if 0 | |
| 2627 | /* don't do this, to prevent the occasional weird sending of | |
| 2628 | formatted messages as plaintext when the other end closes the | |
| 2629 | conversation after we've begun composing the message */ | |
| 2630 | convo_nofeatures(conv); | |
| 2631 | #endif | |
| 2632 | ||
| 2633 | mwConversation_removeClientData(conv); | |
| 2634 | } | |
| 2635 | ||
| 2636 | ||
| 2637 | static void im_recv_text(struct mwConversation *conv, | |
| 15884 | 2638 | struct mwPurplePluginData *pd, |
| 10977 | 2639 | const char *msg) { |
| 2640 | ||
| 2641 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2642 | char *txt, *esc; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2643 | const char *t; |
| 10977 | 2644 | |
| 2645 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2646 | |
| 15884 | 2647 | txt = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2648 | t = txt? txt: msg; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2649 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2650 | esc = g_markup_escape_text(t, -1); |
| 10977 | 2651 | 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
|
2652 | g_free(esc); |
| 10977 | 2653 | |
| 2654 | g_free(txt); | |
| 2655 | } | |
| 2656 | ||
| 2657 | ||
| 2658 | static void im_recv_typing(struct mwConversation *conv, | |
| 15884 | 2659 | struct mwPurplePluginData *pd, |
| 10977 | 2660 | gboolean typing) { |
| 2661 | ||
| 2662 | struct mwIdBlock *idb; | |
| 2663 | idb = mwConversation_getTarget(conv); | |
| 2664 | ||
| 2665 | serv_got_typing(pd->gc, idb->user, 0, | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
2666 | typing? PURPLE_IM_TYPING: PURPLE_IM_NOT_TYPING); |
| 10977 | 2667 | } |
| 2668 | ||
| 2669 | ||
| 2670 | static void im_recv_html(struct mwConversation *conv, | |
| 15884 | 2671 | struct mwPurplePluginData *pd, |
| 10977 | 2672 | const char *msg) { |
| 2673 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2674 | char *t1, *t2; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2675 | const char *t; |
| 10977 | 2676 | |
| 2677 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2678 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2679 | /* ensure we're receiving UTF8 */ |
| 15884 | 2680 | t1 = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2681 | t = t1? t1: msg; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2682 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2683 | /* convert entities to UTF8 so they'll log correctly */ |
| 15884 | 2684 | t2 = purple_utf8_ncr_decode(t); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2685 | t = t2? t2: t; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2686 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2687 | serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
| 10977 | 2688 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2689 | g_free(t1); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2690 | g_free(t2); |
| 10977 | 2691 | } |
| 2692 | ||
| 2693 | ||
| 2694 | static void im_recv_subj(struct mwConversation *conv, | |
| 15884 | 2695 | struct mwPurplePluginData *pd, |
| 10977 | 2696 | const char *subj) { |
| 2697 | ||
| 2698 | /** @todo somehow indicate receipt of a conversation subject. It | |
| 2699 | would also be nice if we added a /topic command for the | |
| 2700 | protocol */ | |
| 2701 | ; | |
| 2702 | } | |
| 2703 | ||
| 2704 | ||
| 2705 | /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */ | |
| 2706 | static char *make_cid(const char *cid) { | |
| 2707 | gsize n; | |
| 2708 | char *c, *d; | |
| 2709 | ||
| 2710 | g_return_val_if_fail(cid != NULL, NULL); | |
| 2711 | ||
| 2712 | n = strlen(cid); | |
| 2713 | g_return_val_if_fail(n > 2, NULL); | |
| 2714 | ||
| 2715 | c = g_strndup(cid+1, n-2); | |
| 2716 | d = g_strdup_printf("cid:%s", c); | |
| 2717 | ||
| 2718 | g_free(c); | |
| 2719 | return d; | |
| 2720 | } | |
| 2721 | ||
| 2722 | ||
| 2723 | static void im_recv_mime(struct mwConversation *conv, | |
| 15884 | 2724 | struct mwPurplePluginData *pd, |
| 10977 | 2725 | const char *data) { |
| 2726 | ||
| 2727 | GHashTable *img_by_cid; | |
| 2728 | GList *images; | |
| 2729 | ||
| 2730 | GString *str; | |
| 2731 | ||
| 15884 | 2732 | 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
|
2733 | GList *parts; |
| 10977 | 2734 | |
| 2735 | img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
| 2736 | images = NULL; | |
| 2737 | ||
| 2738 | /* don't want the contained string to ever be NULL */ | |
| 2739 | str = g_string_new(""); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2740 | |
| 15884 | 2741 | doc = purple_mime_document_parse(data); |
| 10977 | 2742 | |
| 2743 | /* handle all the MIME parts */ | |
| 15884 | 2744 | parts = purple_mime_document_get_parts(doc); |
| 10977 | 2745 | for(; parts; parts = parts->next) { |
| 15884 | 2746 | PurpleMimePart *part = parts->data; |
| 10977 | 2747 | const char *type; |
| 2748 | ||
| 15884 | 2749 | type = purple_mime_part_get_field(part, "content-type"); |
| 10977 | 2750 | DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type)); |
| 2751 | ||
| 2752 | if(! type) { | |
| 2753 | ; /* feh */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2754 | |
| 15884 | 2755 | } else if(purple_str_has_prefix(type, "image")) { |
| 10977 | 2756 | /* put images into the image store */ |
| 2757 | ||
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2758 | guchar *d_dat; |
| 10977 | 2759 | gsize d_len; |
| 2760 | char *cid; | |
| 2761 | int img; | |
| 2762 | ||
| 2763 | /* obtain and unencode the data */ | |
| 15884 | 2764 | 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
|
2765 | |
| 10977 | 2766 | /* look up the content id */ |
| 15884 | 2767 | cid = (char *) purple_mime_part_get_field(part, "Content-ID"); |
| 10977 | 2768 | cid = make_cid(cid); |
| 2769 | ||
| 15884 | 2770 | /* add image to the purple image store */ |
|
33762
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2771 | /* TODO: This PurpleStoredImage will be rendered within the IM window |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2772 | and right-clicking the image will allow the user to save the image |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2773 | to disk. The default filename used in this dialog is the filename |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2774 | that we pass to purple_imgstore_new_with_id(), so we should call |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2775 | g_path_get_basename() and purple_escape_filename() on it before |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2776 | passing it in. This is easy, but it's not clear if there might be |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2777 | other implications because this filename is used elsewhere within |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33760
diff
changeset
|
2778 | this PRPL. */ |
| 33661 | 2779 | img = purple_imgstore_new_with_id(d_dat, d_len, cid); |
| 10977 | 2780 | |
| 2781 | /* map the cid to the image store identifier */ | |
| 2782 | g_hash_table_insert(img_by_cid, cid, GINT_TO_POINTER(img)); | |
| 2783 | ||
| 2784 | /* recall the image for dereferencing later */ | |
| 2785 | images = g_list_append(images, GINT_TO_POINTER(img)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2786 | |
| 15884 | 2787 | } else if(purple_str_has_prefix(type, "text")) { |
| 10977 | 2788 | |
| 2789 | /* concatenate all the text parts together */ | |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2790 | guchar *data; |
| 10977 | 2791 | gsize len; |
| 2792 | ||
| 15884 | 2793 | purple_mime_part_get_data_decoded(part, &data, &len); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2794 | g_string_append(str, (const char *)data); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2795 | g_free(data); |
| 10977 | 2796 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2797 | } |
| 10977 | 2798 | |
| 15884 | 2799 | purple_mime_document_free(doc); |
| 10977 | 2800 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2801 | /* @todo should put this in its own function */ |
| 10977 | 2802 | { /* replace each IMG tag's SRC attribute with an ID attribute. This |
| 2803 | actually modifies the contents of str */ | |
| 2804 | GData *attribs; | |
| 2805 | char *start, *end; | |
| 2806 | char *tmp = str->str; | |
| 2807 | ||
| 15884 | 2808 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 2809 | (const char **) &end, &attribs)) { |
| 2810 | ||
| 2811 | char *alt, *align, *border, *src; | |
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2812 | int img = 0; |
| 10977 | 2813 | |
| 2814 | alt = g_datalist_get_data(&attribs, "alt"); | |
| 2815 | align = g_datalist_get_data(&attribs, "align"); | |
| 2816 | border = g_datalist_get_data(&attribs, "border"); | |
| 2817 | src = g_datalist_get_data(&attribs, "src"); | |
| 2818 | ||
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2819 | if(src) |
|
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2820 | 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
|
2821 | |
| 10977 | 2822 | if(img) { |
| 2823 | GString *atstr; | |
| 2824 | gsize len = (end - start); | |
| 2825 | gsize mov; | |
| 2826 | ||
| 2827 | atstr = g_string_new(""); | |
| 2828 | if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt); | |
| 2829 | if(align) g_string_append_printf(atstr, " align=\"%s\"", align); | |
| 2830 | if(border) g_string_append_printf(atstr, " border=\"%s\"", border); | |
| 2831 | ||
|
33052
df92c3d93904
From now on, prpls must specify images using SRC instead of ID.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32705
diff
changeset
|
2832 | mov = g_snprintf(start, len, "<img%s src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%i\"", atstr->str, img); |
| 10977 | 2833 | while(mov < len) start[mov++] = ' '; |
| 2834 | ||
| 2835 | g_string_free(atstr, TRUE); | |
| 2836 | } | |
| 2837 | ||
| 2838 | g_datalist_clear(&attribs); | |
| 2839 | tmp = end + 1; | |
| 2840 | } | |
| 2841 | } | |
| 2842 | ||
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2843 | im_recv_html(conv, pd, str->str); |
| 10977 | 2844 | |
| 2845 | g_string_free(str, TRUE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2846 | |
| 10977 | 2847 | /* clean up the cid table */ |
| 2848 | g_hash_table_destroy(img_by_cid); | |
| 2849 | ||
| 2850 | /* dereference all the imgages */ | |
| 2851 | 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
|
2852 | purple_imgstore_unref_by_id(GPOINTER_TO_INT(images->data)); |
| 10977 | 2853 | images = g_list_delete_link(images, images); |
| 2854 | } | |
| 2855 | } | |
| 2856 | ||
| 2857 | ||
| 2858 | static void mw_conversation_recv(struct mwConversation *conv, | |
| 2859 | enum mwImSendType type, | |
| 2860 | gconstpointer msg) { | |
| 2861 | struct mwServiceIm *srvc; | |
| 2862 | struct mwSession *session; | |
| 15884 | 2863 | struct mwPurplePluginData *pd; |
| 10977 | 2864 | |
| 2865 | srvc = mwConversation_getService(conv); | |
| 2866 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2867 | pd = mwSession_getClientData(session); | |
| 2868 | ||
| 2869 | switch(type) { | |
| 2870 | case mwImSend_PLAIN: | |
| 2871 | im_recv_text(conv, pd, msg); | |
| 2872 | break; | |
| 2873 | ||
| 2874 | case mwImSend_TYPING: | |
| 2875 | im_recv_typing(conv, pd, !! msg); | |
| 2876 | break; | |
| 2877 | ||
| 2878 | case mwImSend_HTML: | |
| 2879 | im_recv_html(conv, pd, msg); | |
| 2880 | break; | |
| 2881 | ||
| 2882 | case mwImSend_SUBJECT: | |
| 2883 | im_recv_subj(conv, pd, msg); | |
| 2884 | break; | |
| 2885 | ||
| 2886 | case mwImSend_MIME: | |
| 2887 | im_recv_mime(conv, pd, msg); | |
| 2888 | break; | |
| 2889 | ||
| 2890 | default: | |
| 2891 | DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
| 2892 | ; /* erm... */ | |
| 2893 | } | |
| 2894 | } | |
| 2895 | ||
| 2896 | ||
| 2897 | static void mw_place_invite(struct mwConversation *conv, | |
| 2898 | const char *message, | |
| 2899 | const char *title, const char *name) { | |
| 2900 | struct mwServiceIm *srvc; | |
| 2901 | struct mwSession *session; | |
| 15884 | 2902 | struct mwPurplePluginData *pd; |
| 10977 | 2903 | |
| 2904 | struct mwIdBlock *idb; | |
| 2905 | GHashTable *ht; | |
| 2906 | ||
| 2907 | srvc = mwConversation_getService(conv); | |
| 2908 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2909 | pd = mwSession_getClientData(session); | |
| 2910 | ||
| 2911 | idb = mwConversation_getTarget(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2912 | |
| 10977 | 2913 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 2914 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
| 2915 | g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
| 2916 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
| 2917 | 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
|
2918 | g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
| 10977 | 2919 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2920 | if(! title) title = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2921 | if(! message) message = "(no message)"; |
| 10977 | 2922 | 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
|
2923 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2924 | mwConversation_close(conv, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2925 | mwConversation_free(conv); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2926 | } |
| 10977 | 2927 | |
| 2928 | ||
| 2929 | static void mw_im_clear(struct mwServiceIm *srvc) { | |
| 2930 | ; | |
| 2931 | } | |
| 2932 | ||
| 2933 | ||
| 2934 | static struct mwImHandler mw_im_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2935 | mw_conversation_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2936 | mw_conversation_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2937 | mw_conversation_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2938 | mw_place_invite, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2939 | mw_im_clear, |
| 10977 | 2940 | }; |
| 2941 | ||
| 2942 | ||
| 2943 | static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
| 2944 | struct mwServiceIm *srvc; | |
| 2945 | srvc = mwServiceIm_new(s, &mw_im_handler); | |
| 2946 | mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
| 2947 | return srvc; | |
| 2948 | } | |
| 2949 | ||
| 2950 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2951 | /* The following helps us relate a mwPlace to a PurpleChatConversation in the |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2952 | 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
|
2953 | the similar macros from the conference service above */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2954 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2955 | #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2956 | #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
|
2957 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2958 | #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
|
2959 | #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
|
2960 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2961 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2962 | static struct mwPlace * |
| 15884 | 2963 | place_find_by_id(struct mwPurplePluginData *pd, int id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2964 | struct mwServicePlace *srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2965 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2966 | GList *l; |
|
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 | l = (GList *) mwServicePlace_getPlaces(srvc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2969 | for(; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2970 | struct mwPlace *p = l->data; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2971 | PurpleChatConversation *h = mwPlace_getClientData(p); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2972 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2973 | if(CHAT_TO_ID(h) == id) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2974 | place = p; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2975 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2976 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2977 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2978 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2979 | return place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2980 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2981 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2982 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2983 | static void mw_place_opened(struct mwPlace *place) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2984 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2985 | struct mwSession *session; |
| 15884 | 2986 | struct mwPurplePluginData *pd; |
| 2987 | PurpleConnection *gc; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2988 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2989 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2990 | GList *members, *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2991 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2992 | const char *n = mwPlace_getName(place); |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2993 | const char *t = mwPlace_getTitle(place); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2994 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2995 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2996 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2997 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2998 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2999 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3000 | members = mwPlace_getMembers(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3001 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3002 | DEBUG_INFO("place %s opened, %u initial members\n", |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3003 | NSTR(n), g_list_length(members)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3004 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
3005 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
3006 | 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
|
3007 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3008 | mwPlace_setClientData(place, gconf, NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3009 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3010 | for(l = members; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3011 | struct mwIdBlock *idb = l->data; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3012 | purple_chat_conversation_add_user(gconf, idb->user, |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
3013 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3014 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3015 | g_list_free(members); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3016 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3017 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3018 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3019 | static void mw_place_closed(struct mwPlace *place, guint32 code) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3020 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3021 | struct mwSession *session; |
| 15884 | 3022 | struct mwPurplePluginData *pd; |
| 3023 | PurpleConnection *gc; | |
|
11943
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 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3026 | char *msg = mwError(code); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3027 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3028 | 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
|
3029 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3030 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3031 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3032 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3033 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3034 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3035 | serv_got_chat_left(gc, PLACE_TO_ID(place)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3036 | |
| 15884 | 3037 | purple_notify_error(gc, _("Place Closed"), NULL, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3038 | g_free(msg); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3039 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3040 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3041 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3042 | static void mw_place_peerJoined(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3043 | const struct mwIdBlock *peer) { |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3044 | PurpleChatConversation *gconf; |
|
11943
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 | const char *n = mwPlace_getName(place); |
|
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 | 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
|
3049 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3050 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3051 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3052 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3053 | purple_chat_conversation_add_user(gconf, peer->user, |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
3054 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
|
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 | |
|
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 | static void mw_place_peerParted(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3059 | const struct mwIdBlock *peer) { |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3060 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3061 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3062 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3063 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3064 | 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
|
3065 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3066 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3067 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3068 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3069 | purple_chat_conversation_remove_user(gconf, peer->user, NULL); |
|
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_peerSetAttribute(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 | guint32 attr, struct mwOpaque *o) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3076 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3077 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3078 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3079 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3080 | static void mw_place_peerUnsetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3081 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3082 | guint32 attr) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3083 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3084 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3085 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3086 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3087 | static void mw_place_message(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3088 | const struct mwIdBlock *who, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3089 | const char *msg) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3090 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3091 | struct mwSession *session; |
| 15884 | 3092 | struct mwPurplePluginData *pd; |
| 3093 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3094 | char *esc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3095 | |
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3096 | if(! msg) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3097 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3098 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3099 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3100 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3101 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3102 | |
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
3103 | esc = g_markup_escape_text(msg, -1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3104 | 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
|
3105 | g_free(esc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3106 | } |
|
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 | static void mw_place_clear(struct mwServicePlace *srvc) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3110 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3111 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3112 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3113 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3114 | static struct mwPlaceHandler mw_place_handler = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3115 | mw_place_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3116 | mw_place_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3117 | mw_place_peerJoined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3118 | mw_place_peerParted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3119 | mw_place_peerSetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3120 | mw_place_peerUnsetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3121 | mw_place_message, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3122 | mw_place_clear, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3123 | }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3124 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3125 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3126 | static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3127 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3128 | srvc = mwServicePlace_new(s, &mw_place_handler); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3129 | return srvc; |
|
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 | |
| 10977 | 3133 | static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
| 3134 | struct mwServiceResolve *srvc; | |
| 3135 | srvc = mwServiceResolve_new(s); | |
| 3136 | return srvc; | |
| 3137 | } | |
| 3138 | ||
| 3139 | ||
| 3140 | static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
| 3141 | struct mwServiceStorage *srvc; | |
| 3142 | srvc = mwServiceStorage_new(s); | |
| 3143 | return srvc; | |
| 3144 | } | |
| 3145 | ||
| 3146 | ||
| 15884 | 3147 | /** allocate and associate a mwPurplePluginData with a PurpleConnection */ |
| 3148 | static struct mwPurplePluginData *mwPurplePluginData_new(PurpleConnection *gc) { | |
| 3149 | struct mwPurplePluginData *pd; | |
| 10977 | 3150 | |
| 3151 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3152 | ||
| 15884 | 3153 | pd = g_new0(struct mwPurplePluginData, 1); |
| 10977 | 3154 | pd->gc = gc; |
| 3155 | pd->session = mwSession_new(&mw_session_handler); | |
| 3156 | pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
| 3157 | pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
| 3158 | pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
| 3159 | pd->srvc_im = mw_srvc_im_new(pd->session); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3160 | pd->srvc_place = mw_srvc_place_new(pd->session); |
| 10977 | 3161 | pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
| 3162 | pd->srvc_store = mw_srvc_store_new(pd->session); | |
| 3163 | pd->group_list_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
3164 | pd->sock_buf = purple_circular_buffer_new(0); |
| 10977 | 3165 | |
| 3166 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
| 3167 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
| 3168 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
| 3169 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3170 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
| 10977 | 3171 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
| 3172 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
| 3173 | ||
| 3174 | 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
|
3175 | mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 10977 | 3176 | |
| 3177 | mwSession_setClientData(pd->session, pd, NULL); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3178 | purple_connection_set_protocol_data(gc, pd); |
| 10977 | 3179 | |
| 3180 | return pd; | |
| 3181 | } | |
| 3182 | ||
| 3183 | ||
| 15884 | 3184 | static void mwPurplePluginData_free(struct mwPurplePluginData *pd) { |
| 10977 | 3185 | g_return_if_fail(pd != NULL); |
| 3186 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3187 | purple_connection_set_protocol_data(pd->gc, NULL); |
| 10977 | 3188 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3189 | mwSession_removeService(pd->session, mwService_AWARE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3190 | mwSession_removeService(pd->session, mwService_CONFERENCE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3191 | mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3192 | mwSession_removeService(pd->session, mwService_IM); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3193 | mwSession_removeService(pd->session, mwService_PLACE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3194 | mwSession_removeService(pd->session, mwService_RESOLVE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3195 | mwSession_removeService(pd->session, mwService_STORAGE); |
| 10977 | 3196 | |
| 3197 | mwService_free(MW_SERVICE(pd->srvc_aware)); | |
| 3198 | mwService_free(MW_SERVICE(pd->srvc_conf)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3199 | mwService_free(MW_SERVICE(pd->srvc_ft)); |
| 10977 | 3200 | mwService_free(MW_SERVICE(pd->srvc_im)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3201 | mwService_free(MW_SERVICE(pd->srvc_place)); |
| 10977 | 3202 | mwService_free(MW_SERVICE(pd->srvc_resolve)); |
| 3203 | mwService_free(MW_SERVICE(pd->srvc_store)); | |
| 3204 | ||
| 3205 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3206 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
| 10977 | 3207 | |
| 3208 | mwSession_free(pd->session); | |
| 3209 | ||
| 3210 | g_hash_table_destroy(pd->group_list_map); | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
3211 | g_object_unref(G_OBJECT(pd->sock_buf)); |
| 10977 | 3212 | |
| 3213 | g_free(pd); | |
| 3214 | } | |
| 3215 | ||
| 3216 | ||
| 15884 | 3217 | static const char *mw_prpl_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
| 10977 | 3218 | /* my little green dude is a chopped up version of the aim running |
| 3219 | guy. First, cut off the head and store someplace safe. Then, | |
| 3220 | take the left-half side of the body and throw it away. Make a | |
| 3221 | copy of the remaining body, and flip it horizontally. Now attach | |
| 3222 | the two pieces into an X shape, and drop the head back on the | |
| 3223 | top, being careful to center it. Then, just change the color | |
| 3224 | saturation to bring the red down a bit, and voila! */ | |
| 3225 | ||
| 3226 | /* then, throw all of that away and use sodipodi to make a new | |
| 3227 | icon. You know, LIKE A REAL MAN. */ | |
| 3228 | ||
| 3229 | return "meanwhile"; | |
| 3230 | } | |
| 3231 | ||
| 3232 | ||
| 15884 | 3233 | static const char* mw_prpl_list_emblem(PurpleBuddy *b) |
| 15524 | 3234 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3235 | if(buddy_is_external(b)) |
| 15524 | 3236 | return "external"; |
| 3237 | ||
| 3238 | return NULL; | |
| 10977 | 3239 | } |
| 3240 | ||
| 3241 | ||
| 15884 | 3242 | static char *mw_prpl_status_text(PurpleBuddy *b) { |
| 3243 | PurpleConnection *gc; | |
| 3244 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3245 | 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
|
3246 | 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
|
3247 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3248 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3249 | && (pd = purple_connection_get_protocol_data(gc))) |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3250 | 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
|
3251 | |
|
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
|
3252 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3253 | } |
| 3254 | ||
| 3255 | ||
| 15884 | 3256 | static const char *status_text(PurpleBuddy *b) { |
| 3257 | PurplePresence *presence; | |
| 3258 | PurpleStatus *status; | |
| 3259 | ||
| 3260 | presence = purple_buddy_get_presence(b); | |
| 3261 | status = purple_presence_get_active_status(presence); | |
| 3262 | ||
| 3263 | return purple_status_get_name(status); | |
| 10977 | 3264 | } |
| 3265 | ||
| 3266 | ||
| 3267 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3268 | const char *who, guint32 feature) { | |
| 3269 | ||
| 3270 | const struct mwAwareAttribute *attr; | |
| 3271 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3272 | ||
| 3273 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3274 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3275 | } | |
| 3276 | ||
| 3277 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3278 | 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
|
3279 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3280 | const char **f = feat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3281 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3282 | if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3283 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3284 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3285 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3286 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3287 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3288 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3289 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3290 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3291 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3292 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3293 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3294 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3295 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3296 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3297 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3298 | /* jenni loves siege */ |
| 10977 | 3299 | } |
| 3300 | ||
| 3301 | ||
| 15884 | 3302 | static void mw_prpl_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { |
| 3303 | 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
|
3304 | struct mwPurplePluginData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3305 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3306 | |
|
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
|
3307 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3308 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3309 | char *tmp; |
| 10977 | 3310 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3311 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3312 | && (pd = purple_connection_get_protocol_data(gc))) |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3313 | 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
|
3314 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3315 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3316 | |
|
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
|
3317 | if(message != NULL && g_utf8_validate(message, -1, NULL) && purple_utf8_strcasecmp(status, message)) { |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
3318 | purple_notify_user_info_add_pair_plaintext(user_info, status, message); |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3319 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3320 | } else { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
3321 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status); |
| 10977 | 3322 | } |
| 3323 | ||
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3324 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3325 | 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
|
3326 | if(tmp) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
3327 | purple_notify_user_info_add_pair_plaintext(user_info, _("Supports"), tmp); |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3328 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3329 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3330 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3331 | if(buddy_is_external(b)) { |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
3332 | purple_notify_user_info_add_pair_plaintext(user_info, NULL, _("External User")); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3333 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3334 | } |
| 10977 | 3335 | } |
| 3336 | ||
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3337 | 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
|
3338 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3339 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3340 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3341 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3342 | 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
|
3343 | MW_STATE_ACTIVE, NULL, TRUE, TRUE, FALSE, |
|
34811
377d4d43e0e0
Refactored the remaining protocols to use GType and GValue instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34746
diff
changeset
|
3344 | MW_STATE_MESSAGE, _("Message"), purple_g_value_new(G_TYPE_STRING), |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3345 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3346 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3347 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3348 | 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
|
3349 | MW_STATE_AWAY, NULL, TRUE, TRUE, FALSE, |
|
34811
377d4d43e0e0
Refactored the remaining protocols to use GType and GValue instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34746
diff
changeset
|
3350 | MW_STATE_MESSAGE, _("Message"), purple_g_value_new(G_TYPE_STRING), |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3351 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3352 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3353 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3354 | 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
|
3355 | MW_STATE_BUSY, _("Do Not Disturb"), TRUE, TRUE, FALSE, |
|
34811
377d4d43e0e0
Refactored the remaining protocols to use GType and GValue instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34746
diff
changeset
|
3356 | MW_STATE_MESSAGE, _("Message"), purple_g_value_new(G_TYPE_STRING), |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3357 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3358 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3359 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3360 | 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
|
3361 | 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
|
3362 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3363 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3364 | return types; |
| 10977 | 3365 | } |
| 3366 | ||
| 3367 | ||
| 15884 | 3368 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3369 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3370 | ; /* nothing to do */ |
| 10977 | 3371 | } |
| 3372 | ||
| 3373 | ||
| 15884 | 3374 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3375 | PurpleRequestFields *fields) { | |
| 3376 | PurpleAccount *acct; | |
| 3377 | PurpleConnection *gc; | |
| 3378 | struct mwPurplePluginData *pd; | |
| 10977 | 3379 | struct mwServiceConference *srvc; |
| 3380 | ||
| 15884 | 3381 | PurpleRequestField *f; |
| 10977 | 3382 | |
| 3383 | const char *topic, *invite; | |
| 3384 | struct mwConference *conf; | |
| 3385 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3386 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3387 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3388 | gc = purple_account_get_connection(acct); |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3389 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3390 | srvc = pd->srvc_conf; |
| 3391 | ||
| 15884 | 3392 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3393 | topic = purple_request_field_string_get_value(f); | |
| 3394 | ||
| 3395 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3396 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3397 | |
| 3398 | conf = mwConference_new(srvc, topic); | |
| 3399 | mwConference_open(conf); | |
| 3400 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3401 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3402 | mwConference_invite(conf, &idb, invite); |
| 3403 | } | |
| 3404 | ||
| 3405 | ||
| 15884 | 3406 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3407 | ||
| 3408 | PurpleRequestFields *fields; | |
| 3409 | PurpleRequestFieldGroup *g; | |
| 3410 | PurpleRequestField *f; | |
| 3411 | ||
| 3412 | PurpleAccount *acct; | |
| 3413 | PurpleConnection *gc; | |
| 10977 | 3414 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3415 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3416 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3417 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3418 | |
| 10977 | 3419 | g_return_if_fail(buddy != NULL); |
| 3420 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3421 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3422 | g_return_if_fail(acct != NULL); |
| 3423 | ||
| 15884 | 3424 | gc = purple_account_get_connection(acct); |
| 10977 | 3425 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3426 | |
| 15884 | 3427 | fields = purple_request_fields_new(); |
| 3428 | ||
| 3429 | g = purple_request_field_group_new(NULL); | |
| 3430 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3431 | |
| 15884 | 3432 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3433 | purple_request_field_group_add_field(g, f); | |
| 3434 | ||
| 3435 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3436 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3437 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3438 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3439 | 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
|
3440 | " 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
|
3441 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3442 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3443 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3444 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3445 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3446 | _("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
|
3447 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3448 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3449 | g_free(msg1); |
| 10977 | 3450 | } |
| 3451 | ||
| 3452 | ||
| 15884 | 3453 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3454 | PurpleRequestFields *fields) { | |
| 10977 | 3455 | ; |
| 3456 | } | |
| 3457 | ||
| 3458 | ||
| 15884 | 3459 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3460 | PurpleRequestFields *fields) { | |
| 3461 | 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
|
3462 | GList *l; |
| 10977 | 3463 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3464 | |
| 15884 | 3465 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3466 | msg = purple_request_field_string_get_value(f); | |
| 3467 | ||
| 3468 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3469 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3470 | |
| 3471 | if(l) { | |
| 15884 | 3472 | 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
|
3473 | |
| 10977 | 3474 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3475 | blist_menu_conf_create(buddy, msg); | |
| 3476 | ||
| 3477 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3478 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3479 | mwConference_invite(d, &idb, msg); |
| 3480 | } | |
| 3481 | } | |
| 3482 | } | |
| 3483 | ||
| 3484 | ||
| 15884 | 3485 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3486 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3487 | |
| 15884 | 3488 | PurpleRequestFields *fields; |
| 3489 | PurpleRequestFieldGroup *g; | |
| 3490 | PurpleRequestField *f; | |
| 3491 | ||
| 3492 | PurpleAccount *acct; | |
| 3493 | PurpleConnection *gc; | |
| 10977 | 3494 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3495 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3496 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3497 | char *msg; |
| 10977 | 3498 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3499 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3500 | g_return_if_fail(acct != NULL); |
| 3501 | ||
| 15884 | 3502 | gc = purple_account_get_connection(acct); |
| 10977 | 3503 | g_return_if_fail(gc != NULL); |
| 3504 | ||
| 15884 | 3505 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3506 | |
| 15884 | 3507 | g = purple_request_field_group_new(NULL); |
| 3508 | purple_request_fields_add_group(fields, g); | |
| 3509 | ||
| 3510 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3511 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3512 | for(; confs; confs = confs->next) { |
| 3513 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3514 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3515 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3516 | 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
|
3517 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3518 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3519 | |
| 15884 | 3520 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3521 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3522 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3523 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3524 | 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
|
3525 | " 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
|
3526 | " 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
|
3527 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3528 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3529 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3530 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3531 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3532 | _("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
|
3533 | acct, purple_buddy_get_name(buddy), NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3534 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3535 | g_free(msg); |
| 10977 | 3536 | } |
| 3537 | ||
| 3538 | ||
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
3539 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 15884 | 3540 | PurpleBuddy *buddy = (PurpleBuddy *) node; |
| 3541 | PurpleAccount *acct; | |
| 3542 | PurpleConnection *gc; | |
| 3543 | struct mwPurplePluginData *pd; | |
| 10977 | 3544 | GList *l; |
| 3545 | ||
| 3546 | g_return_if_fail(node != NULL); | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3547 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 10977 | 3548 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3549 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3550 | g_return_if_fail(acct != NULL); |
| 3551 | ||
| 15884 | 3552 | gc = purple_account_get_connection(acct); |
| 10977 | 3553 | g_return_if_fail(gc != NULL); |
| 3554 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3555 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3556 | g_return_if_fail(pd != NULL); |
| 3557 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3558 | /* |
| 10977 | 3559 | - get a list of all conferences on this session |
| 3560 | - if none, prompt to create one, and invite buddy to it | |
| 3561 | - else, prompt to select a conference or create one | |
| 3562 | */ | |
| 3563 | ||
| 3564 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3565 | if(l) { | |
| 3566 | blist_menu_conf_list(buddy, l); | |
| 3567 | g_list_free(l); | |
| 3568 | ||
| 3569 | } else { | |
| 3570 | blist_menu_conf_create(buddy, NULL); | |
| 3571 | } | |
| 3572 | } | |
| 3573 | ||
| 3574 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3575 | #if 0 |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
3576 | static void blist_menu_announce(PurpleBlistNode *node, gpointer data) { |
| 15884 | 3577 | PurpleBuddy *buddy = (PurpleBuddy *) node; |
| 3578 | PurpleAccount *acct; | |
| 3579 | PurpleConnection *gc; | |
| 3580 | struct mwPurplePluginData *pd; | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3581 | struct mwSession *session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3582 | char *rcpt_name; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3583 | GList *rcpt; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3584 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3585 | g_return_if_fail(node != NULL); |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3586 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3587 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3588 | acct = buddy->account; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3589 | g_return_if_fail(acct != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3590 | |
| 15884 | 3591 | gc = purple_account_get_connection(acct); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3592 | g_return_if_fail(gc != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3593 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3594 | pd = purple_connection_get_protocol_data(gc); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3595 | g_return_if_fail(pd != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3596 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3597 | rcpt_name = g_strdup_printf("@U %s", buddy->name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3598 | rcpt = g_list_prepend(NULL, rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3599 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3600 | session = pd->session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3601 | mwSession_sendAnnounce(session, FALSE, |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3602 | "This is a TEST announcement. Please ignore.", |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3603 | rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3604 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3605 | g_list_free(rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3606 | g_free(rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3607 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3608 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3609 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3610 | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
3611 | static GList *mw_prpl_blist_node_menu(PurpleBlistNode *node) { |
| 10977 | 3612 | GList *l = NULL; |
| 15884 | 3613 | PurpleMenuAction *act; |
| 3614 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3615 | if(! PURPLE_IS_BUDDY(node)) |
| 10977 | 3616 | return l; |
| 3617 | ||
| 3618 | l = g_list_append(l, NULL); | |
| 3619 | ||
| 15884 | 3620 | act = purple_menu_action_new(_("Invite to Conference..."), |
| 3621 | PURPLE_CALLBACK(blist_menu_conf), NULL, NULL); | |
| 10977 | 3622 | l = g_list_append(l, act); |
| 3623 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3624 | #if 0 |
| 15884 | 3625 | act = purple_menu_action_new(_("Send TEST Announcement"), |
| 3626 | PURPLE_CALLBACK(blist_menu_announce), NULL, NULL); | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3627 | l = g_list_append(l, act); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3628 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3629 | |
| 15884 | 3630 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3631 | blist-node-extended-menu signal for that. The function |
| 3632 | blist_node_menu_cb is assigned to this signal in the function | |
| 3633 | services_starting */ | |
| 3634 | ||
| 3635 | return l; | |
| 3636 | } | |
| 3637 | ||
| 3638 | ||
| 15884 | 3639 | static GList *mw_prpl_chat_info(PurpleConnection *gc) { |
| 10977 | 3640 | GList *l = NULL; |
| 3641 | struct proto_chat_entry *pce; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3642 | |
| 10977 | 3643 | pce = g_new0(struct proto_chat_entry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3644 | pce->label = _("Topic:"); |
| 10977 | 3645 | pce->identifier = CHAT_KEY_TOPIC; |
| 3646 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3647 | |
| 10977 | 3648 | return l; |
| 3649 | } | |
| 3650 | ||
| 3651 | ||
| 15884 | 3652 | static GHashTable *mw_prpl_chat_info_defaults(PurpleConnection *gc, |
| 10977 | 3653 | const char *name) { |
| 3654 | GHashTable *table; | |
| 3655 | ||
| 3656 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3657 | ||
| 3658 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3659 | NULL, g_free); | |
| 3660 | ||
| 3661 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3662 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3663 | ||
| 3664 | return table; | |
| 3665 | } | |
| 3666 | ||
| 3667 | ||
| 15884 | 3668 | static void mw_prpl_login(PurpleAccount *acct); |
| 3669 | ||
| 3670 | ||
| 3671 | static void mw_prpl_login(PurpleAccount *account) { | |
| 3672 | PurpleConnection *gc; | |
| 3673 | struct mwPurplePluginData *pd; | |
| 10977 | 3674 | |
| 3675 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3676 | guint port; |
| 10977 | 3677 | |
| 15884 | 3678 | gc = purple_account_get_connection(account); |
| 3679 | pd = mwPurplePluginData_new(gc); | |
| 10977 | 3680 | |
| 3681 | /* while we do support images, the default is to not offer it */ | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
3682 | purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_IMAGES); |
| 15884 | 3683 | |
| 3684 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3685 | |
| 3686 | host = strrchr(user, ':'); | |
| 3687 | if(host) { | |
| 3688 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3689 | *host++ = '\0'; | |
| 15884 | 3690 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3691 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3692 | |
| 10977 | 3693 | } else { |
| 15884 | 3694 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3695 | MW_PLUGIN_DEFAULT_HOST); |
| 3696 | } | |
| 3697 | ||
| 3698 | if(! host || ! *host) { | |
| 3699 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3700 | 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
|
3701 | g_free(user); |
|
32636
b5255be84952
Fix a mistake I made while manually propagating from im.pidgin.pidgin.2.x.y
Mark Doliner <markdoliner@pidgin.im>
parents:
32635
diff
changeset
|
3702 | purple_connection_error(gc, |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
3703 | 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
|
3704 | _("A server is required to connect this account")); |
| 10977 | 3705 | return; |
| 3706 | } | |
| 3707 | ||
|
34022
c49f6e9ea27d
Make all the prpls build.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
3708 | pass = g_strdup(purple_connection_get_password(gc)); |
| 15884 | 3709 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3710 | |
| 3711 | DEBUG_INFO("user: '%s'\n", user); | |
| 3712 | DEBUG_INFO("host: '%s'\n", host); | |
| 3713 | DEBUG_INFO("port: %u\n", port); | |
| 3714 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3715 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3716 | (char *) no_secret, NULL); |
| 3717 | 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
|
3718 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3719 | |
| 15884 | 3720 | 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
|
3721 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3722 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3723 | /* 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
|
3724 | 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
|
3725 | |
| 15884 | 3726 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3727 | 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
|
3728 | 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
|
3729 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3730 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3731 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3732 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3733 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3734 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3735 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3736 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3737 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3738 | GUINT_TO_POINTER(major), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3739 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3740 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3741 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3742 | } |
| 10977 | 3743 | |
| 15884 | 3744 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3745 | ||
| 3746 | if (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL) { | |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
3747 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
3748 | _("Unable to connect")); |
| 10977 | 3749 | } |
| 3750 | } | |
| 3751 | ||
| 3752 | ||
| 15884 | 3753 | static void mw_prpl_close(PurpleConnection *gc) { |
| 3754 | struct mwPurplePluginData *pd; | |
| 10977 | 3755 | |
| 3756 | g_return_if_fail(gc != NULL); | |
| 3757 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3758 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3759 | g_return_if_fail(pd != NULL); |
| 3760 | ||
| 3761 | /* get rid of the blist save timeout */ | |
| 3762 | if(pd->save_event) { | |
| 15884 | 3763 | purple_timeout_remove(pd->save_event); |
| 10977 | 3764 | pd->save_event = 0; |
| 3765 | blist_store(pd); | |
| 3766 | } | |
| 3767 | ||
| 3768 | /* stop the session */ | |
| 3769 | mwSession_stop(pd->session, 0x00); | |
| 3770 | ||
| 3771 | /* no longer necessary */ | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3772 | purple_connection_set_protocol_data(gc, NULL); |
| 10977 | 3773 | |
| 3774 | /* stop watching the socket */ | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3775 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3776 | purple_input_remove(pd->inpa); |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3777 | pd->inpa = 0; |
| 10977 | 3778 | } |
| 3779 | ||
| 3780 | /* clean up the rest */ | |
| 15884 | 3781 | mwPurplePluginData_free(pd); |
| 10977 | 3782 | } |
| 3783 | ||
| 3784 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21947
diff
changeset
|
3785 | static int mw_rand(void) { |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3786 | static int seed = 0; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3787 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3788 | /* for diversity, not security. don't touch */ |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3789 | srand(time(NULL) ^ seed); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3790 | seed = rand(); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3791 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3792 | return seed; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3793 | } |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3794 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3795 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3796 | /** 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
|
3797 | static char *im_mime_content_id(void) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3798 | return g_strdup_printf("%03x@%05xmeanwhile", |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3799 | mw_rand() & 0xfff, mw_rand() & 0xfffff); |
| 10977 | 3800 | } |
| 3801 | ||
| 3802 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3803 | /** generates a multipart/related content type with a random-ish |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3804 | 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
|
3805 | static char *im_mime_content_type(void) { |
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3806 | 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
|
3807 | mw_rand() & 0xfff, mw_rand() & 0xffff); |
| 10977 | 3808 | } |
| 3809 | ||
| 3810 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3811 | /** determine content type from extension. Not so happy about this, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3812 | but I don't want to actually write image type detection */ |
| 15884 | 3813 | static char *im_mime_img_content_type(PurpleStoredImage *img) { |
| 3814 | const char *fn = purple_imgstore_get_filename(img); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3815 | const char *ct = NULL; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3816 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3817 | ct = strrchr(fn, '.'); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3818 | if(! ct) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3819 | ct = "image"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3820 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3821 | } else if(! strcmp(".png", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3822 | ct = "image/png"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3823 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3824 | } else if(! strcmp(".jpg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3825 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3826 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3827 | } else if(! strcmp(".jpeg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3828 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3829 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3830 | } else if(! strcmp(".gif", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3831 | ct = "image/gif"; |
| 10977 | 3832 | |
| 3833 | } else { | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3834 | ct = "image"; |
| 10977 | 3835 | } |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3836 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3837 | return g_strdup_printf("%s; name=\"%s\"", ct, fn); |
| 10977 | 3838 | } |
| 3839 | ||
| 3840 | ||
| 15884 | 3841 | static char *im_mime_img_content_disp(PurpleStoredImage *img) { |
| 3842 | const char *fn = purple_imgstore_get_filename(img); | |
| 10977 | 3843 | return g_strdup_printf("attachment; filename=\"%s\"", fn); |
| 3844 | } | |
| 3845 | ||
| 3846 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3847 | /** turn an IM with embedded images into a multi-part mime document */ |
| 15884 | 3848 | static char *im_mime_convert(PurpleConnection *gc, |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3849 | struct mwConversation *conv, |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3850 | const char *message) { |
| 10977 | 3851 | GString *str; |
| 15884 | 3852 | PurpleMimeDocument *doc; |
| 3853 | PurpleMimePart *part; | |
| 10977 | 3854 | |
| 3855 | GData *attr; | |
| 3856 | char *tmp, *start, *end; | |
| 3857 | ||
| 3858 | str = g_string_new(NULL); | |
| 3859 | ||
| 15884 | 3860 | doc = purple_mime_document_new(); |
| 3861 | ||
| 3862 | purple_mime_document_set_field(doc, "Mime-Version", "1.0"); | |
| 3863 | purple_mime_document_set_field(doc, "Content-Disposition", "inline"); | |
| 10977 | 3864 | |
| 3865 | tmp = im_mime_content_type(); | |
| 15884 | 3866 | purple_mime_document_set_field(doc, "Content-Type", tmp); |
| 10977 | 3867 | g_free(tmp); |
| 3868 | ||
| 3869 | tmp = (char *) message; | |
| 15884 | 3870 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 3871 | (const char **) &end, &attr)) { |
| 3872 | char *id; | |
| 15884 | 3873 | PurpleStoredImage *img = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3874 | |
| 10977 | 3875 | gsize len = (start - tmp); |
| 3876 | ||
| 3877 | /* append the in-between-tags text */ | |
| 3878 | if(len) g_string_append_len(str, tmp, len); | |
| 3879 | ||
| 3880 | /* find the imgstore data by the id tag */ | |
| 3881 | id = g_datalist_get_data(&attr, "id"); | |
| 3882 | 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
|
3883 | img = purple_imgstore_find_by_id(atoi(id)); |
| 10977 | 3884 | |
| 3885 | if(img) { | |
| 3886 | char *cid; | |
| 3887 | gpointer data; | |
| 3888 | size_t size; | |
| 3889 | ||
| 15884 | 3890 | part = purple_mime_part_new(doc); |
| 10977 | 3891 | |
| 3892 | data = im_mime_img_content_disp(img); | |
| 15884 | 3893 | purple_mime_part_set_field(part, "Content-Disposition", data); |
| 10977 | 3894 | g_free(data); |
| 3895 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3896 | data = im_mime_img_content_type(img); |
| 15884 | 3897 | purple_mime_part_set_field(part, "Content-Type", data); |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3898 | g_free(data); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3899 | |
| 10977 | 3900 | cid = im_mime_content_id(); |
| 3901 | data = g_strdup_printf("<%s>", cid); | |
| 15884 | 3902 | purple_mime_part_set_field(part, "Content-ID", data); |
| 10977 | 3903 | g_free(data); |
| 3904 | ||
| 15884 | 3905 | purple_mime_part_set_field(part, "Content-transfer-encoding", "base64"); |
| 10977 | 3906 | |
| 3907 | /* obtain and base64 encode the image data, and put it in the | |
| 3908 | mime part */ | |
| 15884 | 3909 | 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
|
3910 | data = purple_base64_encode(purple_imgstore_get_data(img), (gsize) size); |
| 15884 | 3911 | purple_mime_part_set_data(part, data); |
| 10977 | 3912 | g_free(data); |
| 3913 | ||
| 3914 | /* append the modified tag */ | |
| 3915 | g_string_append_printf(str, "<img src=\"cid:%s\">", cid); | |
| 3916 | g_free(cid); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3917 | |
| 10977 | 3918 | } else { |
| 3919 | /* append the literal image tag, since we couldn't find a | |
| 3920 | relative imgstore object */ | |
| 3921 | gsize len = (end - start) + 1; | |
| 3922 | g_string_append_len(str, start, len); | |
| 3923 | } | |
| 3924 | ||
| 3925 | g_datalist_clear(&attr); | |
| 3926 | tmp = end + 1; | |
| 3927 | } | |
| 3928 | ||
| 3929 | /* append left-overs */ | |
| 3930 | g_string_append(str, tmp); | |
| 3931 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3932 | /* add the text/html part */ |
| 15884 | 3933 | part = purple_mime_part_new(doc); |
| 3934 | purple_mime_part_set_field(part, "Content-Disposition", "inline"); | |
| 3935 | ||
| 3936 | tmp = purple_utf8_ncr_encode(str->str); | |
| 3937 | purple_mime_part_set_field(part, "Content-Type", "text/html"); | |
| 3938 | purple_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); | |
| 3939 | purple_mime_part_set_data(part, tmp); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3940 | g_free(tmp); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3941 | |
| 10977 | 3942 | g_string_free(str, TRUE); |
| 3943 | ||
| 3944 | str = g_string_new(NULL); | |
| 15884 | 3945 | purple_mime_document_write(doc, str); |
| 10977 | 3946 | tmp = str->str; |
| 3947 | g_string_free(str, FALSE); | |
| 3948 | ||
| 3949 | return tmp; | |
| 3950 | } | |
| 3951 | ||
| 3952 | ||
| 15884 | 3953 | static int mw_prpl_send_im(PurpleConnection *gc, |
| 10977 | 3954 | const char *name, |
| 3955 | const char *message, | |
| 15884 | 3956 | PurpleMessageFlags flags) { |
| 3957 | ||
| 3958 | struct mwPurplePluginData *pd; | |
| 10977 | 3959 | struct mwIdBlock who = { (char *) name, NULL }; |
| 3960 | struct mwConversation *conv; | |
| 3961 | ||
| 3962 | g_return_val_if_fail(gc != NULL, 0); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
3963 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3964 | |
| 3965 | g_return_val_if_fail(pd != NULL, 0); | |
| 3966 | ||
| 3967 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 3968 | ||
| 3969 | /* this detection of features to determine how to send the message | |
| 3970 | (plain, html, or mime) is flawed because the other end of the | |
| 3971 | conversation could close their channel at any time, rendering any | |
| 3972 | existing formatting in an outgoing message innapropriate. The end | |
| 3973 | result is that it may be possible that the other side of the | |
| 3974 | conversation will receive a plaintext message with html contents, | |
| 3975 | which is bad. I'm not sure how to fix this correctly. */ | |
| 3976 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3977 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 3978 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 3979 | |
| 3980 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3981 | char *tmp; |
| 10977 | 3982 | int ret; |
| 3983 | ||
| 15884 | 3984 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 3985 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3986 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3987 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3988 | tmp = im_mime_convert(gc, conv, message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3989 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3990 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3991 | |
| 10977 | 3992 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3993 | /* send an HTML message */ |
| 10977 | 3994 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3995 | char *ncr; |
| 15884 | 3996 | ncr = purple_utf8_ncr_encode(message); |
| 3997 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3998 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3999 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4000 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4001 | g_free(tmp); |
| 10977 | 4002 | |
| 4003 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4004 | /* default to text */ |
| 15884 | 4005 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4006 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4007 | g_free(tmp); |
| 10977 | 4008 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4009 | |
| 10977 | 4010 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4011 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4012 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4013 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4014 | /* queue up the message safely as plain text */ |
| 15884 | 4015 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4016 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4017 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4018 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4019 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4020 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4021 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4022 | return 1; |
| 10977 | 4023 | } |
| 4024 | } | |
| 4025 | ||
| 4026 | ||
| 15884 | 4027 | static unsigned int mw_prpl_send_typing(PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4028 | const char *name, |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
4029 | PurpleIMTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4030 | |
| 15884 | 4031 | struct mwPurplePluginData *pd; |
| 10977 | 4032 | struct mwIdBlock who = { (char *) name, NULL }; |
| 4033 | struct mwConversation *conv; | |
| 4034 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
4035 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 4036 | |
| 4037 | g_return_val_if_fail(gc != NULL, 0); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4038 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4039 | |
| 4040 | g_return_val_if_fail(pd != NULL, 0); | |
| 4041 | ||
| 4042 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 4043 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4044 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4045 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4046 | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34642
diff
changeset
|
4047 | } else if((state == PURPLE_IM_TYPING) || (state == PURPLE_IM_TYPED)) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4048 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4049 | 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
|
4050 | 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
|
4051 | |
| 10977 | 4052 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4053 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4054 | if(! mwConversation_isPending(conv)) { |
| 10977 | 4055 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4056 | } |
| 10977 | 4057 | } |
| 4058 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4059 | return 0; |
| 10977 | 4060 | } |
| 4061 | ||
| 4062 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4063 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4064 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4065 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4066 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4067 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4068 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4069 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4070 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4071 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4072 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4073 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4074 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4075 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4076 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4077 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4078 | return "Lotus Sametime Links"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4079 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4080 | case mwLogin_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4081 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4082 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4083 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4084 | return "Lotus Notes Client"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4085 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4086 | case mwLogin_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4087 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4088 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4089 | return "IBM Community Tools"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4090 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4091 | case mwLogin_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4092 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4093 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4094 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4095 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4096 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4097 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4098 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4099 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4100 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4101 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4102 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4103 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4104 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4105 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4106 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4107 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4108 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4109 | return "Trillian"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4110 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4111 | case mwLogin_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4112 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4113 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4114 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4115 | return NULL; |
|
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 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4118 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4119 | |
| 15884 | 4120 | static void mw_prpl_get_info(PurpleConnection *gc, const char *who) { |
| 10977 | 4121 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4122 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4123 | |
| 15884 | 4124 | struct mwPurplePluginData *pd; |
| 4125 | PurpleAccount *acct; | |
| 4126 | PurpleBuddy *b; | |
| 4127 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4128 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4129 | const char *tmp2; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4130 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4131 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4132 | g_return_if_fail(*who != '\0'); |
| 10977 | 4133 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4134 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4135 | |
| 15884 | 4136 | acct = purple_connection_get_account(gc); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4137 | b = purple_blist_find_buddy(acct, who); |
| 15884 | 4138 | user_info = purple_notify_user_info_new(); |
| 4139 | ||
| 4140 | if(purple_str_has_prefix(who, "@E ")) { | |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
4141 | purple_notify_user_info_add_pair_html(user_info, _("External User"), NULL); |
| 10977 | 4142 | } |
| 4143 | ||
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4144 | purple_notify_user_info_add_pair_plaintext(user_info, _("User ID"), who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4145 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4146 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4147 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4148 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4149 | if(purple_buddy_get_server_alias(b)) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4150 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4151 | or if we should be using add_pair_plaintext */ |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
4152 | purple_notify_user_info_add_pair_html(user_info, _("Full Name"), purple_buddy_get_server_alias(b)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4153 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4154 | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
4155 | 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
|
4156 | if(type) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4157 | tmp2 = mw_client_name(type); |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4158 | if (tmp2) { |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4159 | purple_notify_user_info_add_pair_plaintext(user_info, _("Last Known Client"), tmp2); |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4160 | } else { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4161 | tmp = g_strdup_printf(_("Unknown (0x%04x)<br>"), type); |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
4162 | purple_notify_user_info_add_pair_html(user_info, _("Last Known Client"), tmp); |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4163 | g_free(tmp); |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4164 | } |
| 10977 | 4165 | } |
| 4166 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4167 | |
| 10977 | 4168 | tmp = user_supports_text(pd->srvc_aware, who); |
| 4169 | if(tmp) { | |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4170 | purple_notify_user_info_add_pair_plaintext(user_info, _("Supports"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4171 | g_free(tmp); |
| 10977 | 4172 | } |
| 4173 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4174 | if(b) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4175 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status_text(b)); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4176 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4177 | /* 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
|
4178 | 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
|
4179 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
| 15884 | 4180 | purple_notify_user_info_add_section_break(user_info); |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
4181 | purple_notify_user_info_add_pair_plaintext(user_info, NULL, tmp2); |
|
12496
788b20ccec91
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4182 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4183 | } |
| 10977 | 4184 | |
| 4185 | /* @todo emit a signal to allow a plugin to override the display of | |
| 4186 | this notification, so that it can create its own */ | |
| 4187 | ||
| 15884 | 4188 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 4189 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 4190 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4191 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4192 | |
| 15884 | 4193 | static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status) { |
| 4194 | PurpleConnection *gc; | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4195 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
4196 | char *message = NULL; |
| 10977 | 4197 | struct mwSession *session; |
| 4198 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4199 | |
| 10977 | 4200 | g_return_if_fail(acct != NULL); |
| 15884 | 4201 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4202 | |
| 15884 | 4203 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4204 | |
| 15884 | 4205 | 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
|
4206 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4207 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4208 | |
| 10977 | 4209 | session = gc_to_session(gc); |
| 4210 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4211 | |
| 10977 | 4212 | /* get a working copy of the current status */ |
| 4213 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4214 | |
| 10977 | 4215 | /* determine the state */ |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4216 | if(! strcmp(state, MW_STATE_ACTIVE)) { |
| 10977 | 4217 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4218 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4219 | } else if(! strcmp(state, MW_STATE_AWAY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4220 | stat.status = mwStatus_AWAY; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4221 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4222 | } else if(! strcmp(state, MW_STATE_BUSY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4223 | stat.status = mwStatus_BUSY; |
| 10977 | 4224 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4225 | |
| 10977 | 4226 | /* determine the message */ |
| 15884 | 4227 | 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
|
4228 | |
| 10977 | 4229 | if(message) { |
| 4230 | /* all the possible non-NULL values of message up to this point | |
| 4231 | are const, so we don't need to free them */ | |
| 15884 | 4232 | message = purple_markup_strip_html(message); |
| 10977 | 4233 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4234 | |
| 10977 | 4235 | /* out with the old */ |
| 4236 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4237 | |
| 10977 | 4238 | /* in with the new */ |
| 4239 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4240 | |
| 10977 | 4241 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4242 | mwUserStatus_clear(&stat); |
| 10977 | 4243 | } |
| 4244 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4245 | |
| 15884 | 4246 | static void mw_prpl_set_idle(PurpleConnection *gc, int t) { |
| 10977 | 4247 | struct mwSession *session; |
| 4248 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4249 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4250 | |
| 10977 | 4251 | session = gc_to_session(gc); |
| 4252 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4253 | |
| 10977 | 4254 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4255 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4256 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4257 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4258 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4259 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4260 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4261 | stat.time = 0; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4262 | } |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4263 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4264 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4265 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4266 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4267 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4268 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4269 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4270 | stat.status = mwStatus_ACTIVE; |
| 4271 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4272 | |
| 10977 | 4273 | mwSession_setUserStatus(session, &stat); |
| 4274 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4275 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4276 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4277 | |
| 15884 | 4278 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4279 | PurpleAccount *acct; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4280 | PurpleIMConversation *im; |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4281 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4282 | |
| 15884 | 4283 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4284 | id = g_list_nth_data(row, 1); |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4285 | im = purple_conversations_find_im_with_account(id, acct); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4286 | if(! im) im = purple_im_conversation_new(acct, id); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4287 | purple_conversation_present(PURPLE_CONVERSATION(im)); |
| 15884 | 4288 | } |
| 4289 | ||
| 4290 | ||
| 4291 | 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
|
4292 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4293 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4294 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4295 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4296 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4297 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4298 | |
| 15884 | 4299 | 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
|
4300 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4301 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4302 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4303 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4304 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4305 | static void notify_close(gpointer data) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4306 | if (data) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4307 | g_free(data); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4308 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4309 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4310 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4311 | |
| 10977 | 4312 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4313 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4314 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4315 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4316 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4317 | char *msg; |
| 10977 | 4318 | |
| 15884 | 4319 | PurpleNotifySearchResults *sres; |
| 4320 | PurpleNotifySearchColumn *scol; | |
| 4321 | ||
| 4322 | sres = purple_notify_searchresults_new(); | |
| 4323 | ||
| 4324 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4325 | purple_notify_searchresults_column_add(sres, scol); | |
| 4326 | ||
| 4327 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4328 | purple_notify_searchresults_column_add(sres, scol); | |
| 4329 | ||
| 4330 | 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
|
4331 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4332 | |
| 15884 | 4333 | 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
|
4334 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4335 | |
| 10977 | 4336 | for(l = result->matches; l; l = l->next) { |
| 4337 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4338 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4339 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4340 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4341 | NSTR(match->id), NSTR(match->name)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4342 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4343 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4344 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4345 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4346 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4347 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4348 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4349 | } |
| 10977 | 4350 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4351 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4352 | 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
|
4353 | " 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
|
4354 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4355 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4356 | |
| 15884 | 4357 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4358 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4359 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4360 | g_free(msg); |
| 10977 | 4361 | } |
| 4362 | ||
| 4363 | ||
| 4364 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4365 | guint32 id, guint32 code, GList *results, | |
| 4366 | gpointer b) { | |
| 4367 | ||
| 4368 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4369 | BuddyAddData *data = b; |
| 15884 | 4370 | PurpleBuddy *buddy = NULL; |
| 4371 | PurpleConnection *gc; | |
| 4372 | struct mwPurplePluginData *pd; | |
| 10977 | 4373 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4374 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4375 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4376 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4377 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4378 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4379 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4380 | |
| 4381 | if(results) | |
| 4382 | res = results->data; | |
| 4383 | ||
| 4384 | 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
|
4385 | if(!res->matches->next) { |
| 10977 | 4386 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4387 | |
| 10977 | 4388 | /* only one? that might be the right one! */ |
| 4389 | if(strcmp(res->name, match->id)) { | |
| 4390 | /* uh oh, the single result isn't identical to the search | |
| 4391 | term, better safe then sorry, so let's make sure it's who | |
| 4392 | the user meant to add */ | |
| 15884 | 4393 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4394 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4395 | |
| 10977 | 4396 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4397 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4398 | /* same person, set the server alias */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4399 | purple_buddy_set_server_alias(buddy, match->name); |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
4400 | purple_blist_node_set_string((PurpleBlistNode *) buddy, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4401 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4402 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4403 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4404 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4405 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4406 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4407 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4408 | g_free(data); |
| 10977 | 4409 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4410 | |
| 10977 | 4411 | } else { |
| 4412 | /* prompt user if more than one match was returned */ | |
| 15884 | 4413 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4414 | multi_resolved_query(res, gc, data); |
| 10977 | 4415 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4416 | |
| 10977 | 4417 | return; |
| 4418 | } | |
| 4419 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4420 | #if 0 |
| 10977 | 4421 | /* fall-through indicates that we couldn't find a matching user in |
| 4422 | the resolve service (ether error or zero results), so we remove | |
| 4423 | this buddy */ | |
| 4424 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4425 | /* 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
|
4426 | 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
|
4427 | 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
|
4428 | 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
|
4429 | 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
|
4430 | |
| 10977 | 4431 | DEBUG_INFO("no such buddy in community\n"); |
| 15884 | 4432 | purple_blist_remove_buddy(buddy); |
| 10977 | 4433 | blist_schedule(pd); |
| 4434 | ||
| 4435 | if(res && res->name) { | |
| 4436 | /* compose and display an error message */ | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4437 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4438 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4439 | char *msg; |
| 10977 | 4440 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4441 | msgA = _("Unable to add user: user not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4442 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4443 | 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
|
4444 | " Sametime community. This entry has been removed from" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4445 | " your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4446 | msg = g_strdup_printf(msgB, NSTR(res->name)); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4447 | |
| 15884 | 4448 | purple_notify_error(gc, _("Unable to add user"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4449 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4450 | g_free(msg); |
| 10977 | 4451 | } |
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4452 | #endif |
| 10977 | 4453 | } |
| 4454 | ||
| 4455 | ||
| 15884 | 4456 | static void mw_prpl_add_buddy(PurpleConnection *gc, |
| 4457 | PurpleBuddy *buddy, | |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4458 | PurpleGroup *group, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4459 | const char *message) { |
| 15884 | 4460 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4461 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4462 | struct mwServiceResolve *srvc; |
| 4463 | GList *query; | |
| 4464 | enum mwResolveFlag flags; | |
| 4465 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4466 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4467 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4468 | /* 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
|
4469 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4470 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4471 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4472 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4473 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4474 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4475 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4476 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4477 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4478 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4479 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4480 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4481 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4482 | ||
| 4483 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4484 | data, NULL); |
| 10977 | 4485 | g_list_free(query); |
| 4486 | ||
| 4487 | if(req == SEARCH_ERROR) { | |
| 15884 | 4488 | purple_blist_remove_buddy(buddy); |
| 10977 | 4489 | blist_schedule(pd); |
| 4490 | } | |
| 4491 | } | |
| 4492 | ||
| 4493 | ||
| 15884 | 4494 | static void foreach_add_buddies(PurpleGroup *group, GList *buddies, |
| 4495 | struct mwPurplePluginData *pd) { | |
| 10977 | 4496 | struct mwAwareList *list; |
| 4497 | ||
| 4498 | list = list_ensure(pd, group); | |
| 4499 | mwAwareList_addAware(list, buddies); | |
| 4500 | g_list_free(buddies); | |
| 4501 | } | |
| 4502 | ||
| 4503 | ||
| 15884 | 4504 | static void mw_prpl_add_buddies(PurpleConnection *gc, |
| 10977 | 4505 | GList *buddies, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4506 | GList *groups, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4507 | const char *message) { |
| 10977 | 4508 | |
| 15884 | 4509 | struct mwPurplePluginData *pd; |
| 10977 | 4510 | GHashTable *group_sets; |
| 4511 | struct mwAwareIdBlock *idbs, *idb; | |
| 4512 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4513 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4514 | |
| 15884 | 4515 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4516 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4517 | ||
| 4518 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4519 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4520 | ||
| 4521 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4522 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4523 | PurpleBuddy *b = buddies->data; |
| 4524 | PurpleGroup *g; | |
| 10977 | 4525 | const char *fn; |
| 4526 | GList *l; | |
| 4527 | ||
| 4528 | /* nab the saved server alias and stick it on the buddy */ | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
4529 | fn = purple_blist_node_get_string((PurpleBlistNode *) b, BUDDY_KEY_NAME); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4530 | purple_buddy_set_server_alias(b, fn); |
| 15884 | 4531 | |
| 4532 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4533 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4534 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4535 | idb->community = NULL; |
| 4536 | ||
| 4537 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4538 | g = purple_buddy_get_group(b); |
| 10977 | 4539 | l = g_hash_table_lookup(group_sets, g); |
| 4540 | l = g_list_prepend(l, idb++); | |
| 4541 | g_hash_table_insert(group_sets, g, l); | |
| 4542 | } | |
| 4543 | ||
| 4544 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4545 | for saving */ | |
| 4546 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4547 | blist_schedule(pd); | |
| 4548 | ||
| 4549 | /* cleanup */ | |
| 4550 | g_hash_table_destroy(group_sets); | |
| 4551 | g_free(idbs); | |
| 4552 | } | |
| 4553 | ||
| 4554 | ||
| 15884 | 4555 | static void mw_prpl_remove_buddy(PurpleConnection *gc, |
| 4556 | PurpleBuddy *buddy, PurpleGroup *group) { | |
| 4557 | ||
| 4558 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4559 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4560 | struct mwAwareList *list; |
| 4561 | ||
| 4562 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4563 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4564 | pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4565 | group = purple_buddy_get_group(buddy); |
| 10977 | 4566 | list = list_ensure(pd, group); |
| 4567 | ||
| 4568 | mwAwareList_removeAware(list, rem); | |
| 4569 | blist_schedule(pd); | |
| 4570 | ||
| 4571 | g_list_free(rem); | |
| 4572 | } | |
| 4573 | ||
| 4574 | ||
| 4575 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4576 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4577 | |
| 10977 | 4578 | struct mwUserItem *u; |
| 4579 | guint count; | |
| 4580 | ||
| 4581 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4582 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4583 | |
| 4584 | priv->count = count; | |
| 4585 | priv->users = g_new0(struct mwUserItem, count); | |
| 4586 | ||
| 4587 | while(count--) { | |
| 4588 | u = priv->users + count; | |
| 4589 | u->id = members->data; | |
| 4590 | members = members->next; | |
| 4591 | } | |
| 4592 | } | |
| 4593 | ||
| 4594 | ||
| 15884 | 4595 | static void mw_prpl_set_permit_deny(PurpleConnection *gc) { |
| 4596 | PurpleAccount *acct; | |
| 4597 | struct mwPurplePluginData *pd; | |
| 10977 | 4598 | struct mwSession *session; |
| 4599 | ||
| 4600 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4601 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4602 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4603 | NULL, /* users */ |
| 10977 | 4604 | }; |
| 4605 | ||
| 4606 | g_return_if_fail(gc != NULL); | |
| 4607 | ||
| 15884 | 4608 | acct = purple_connection_get_account(gc); |
| 10977 | 4609 | g_return_if_fail(acct != NULL); |
| 4610 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4611 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4612 | g_return_if_fail(pd != NULL); |
| 4613 | ||
| 4614 | session = pd->session; | |
| 4615 | g_return_if_fail(session != NULL); | |
| 4616 | ||
|
32623
547eacef0b63
Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
32617
diff
changeset
|
4617 | switch(purple_account_get_privacy_type(acct)) { |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4618 | case PURPLE_ACCOUNT_PRIVACY_DENY_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4619 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_DENY_USERS\n"); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4620 | privacy_fill(&privacy, purple_account_privacy_get_denied(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4621 | privacy.deny = TRUE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4622 | break; |
| 10977 | 4623 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4624 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4625 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL\n"); |
| 10977 | 4626 | privacy.deny = TRUE; |
| 4627 | break; | |
| 4628 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4629 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4630 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS\n"); |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4631 | privacy_fill(&privacy, purple_account_privacy_get_permitted(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4632 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4633 | break; |
| 10977 | 4634 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4635 | case PURPLE_ACCOUNT_PRIVACY_DENY_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4636 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_DENY_ALL\n"); |
| 10977 | 4637 | privacy.deny = FALSE; |
| 4638 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4639 | |
| 10977 | 4640 | default: |
|
32623
547eacef0b63
Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
32617
diff
changeset
|
4641 | DEBUG_INFO("acct->perm_deny is 0x%x\n", purple_account_get_privacy_type(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4642 | return; |
| 10977 | 4643 | } |
| 4644 | ||
| 4645 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4646 | g_free(privacy.users); | |
| 4647 | } | |
| 4648 | ||
| 4649 | ||
| 15884 | 4650 | static void mw_prpl_add_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4651 | mw_prpl_set_permit_deny(gc); |
| 4652 | } | |
| 4653 | ||
| 4654 | ||
| 15884 | 4655 | static void mw_prpl_add_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4656 | mw_prpl_set_permit_deny(gc); |
| 4657 | } | |
| 4658 | ||
| 4659 | ||
| 15884 | 4660 | static void mw_prpl_rem_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4661 | mw_prpl_set_permit_deny(gc); |
| 4662 | } | |
| 4663 | ||
| 4664 | ||
| 15884 | 4665 | static void mw_prpl_rem_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4666 | mw_prpl_set_permit_deny(gc); |
| 4667 | } | |
| 4668 | ||
| 4669 | ||
| 4670 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4671 | const char *name) { | |
| 4672 | GList *l, *ll; | |
| 4673 | struct mwConference *conf = NULL; | |
| 4674 | ||
| 4675 | ll = mwServiceConference_getConferences(srvc); | |
| 4676 | for(l = ll; l; l = l->next) { | |
| 4677 | struct mwConference *c = l->data; | |
| 4678 | if(! strcmp(name, mwConference_getName(c))) { | |
| 4679 | conf = c; | |
| 4680 | break; | |
| 4681 | } | |
| 4682 | } | |
| 4683 | g_list_free(ll); | |
| 4684 | ||
| 4685 | return conf; | |
| 4686 | } | |
| 4687 | ||
| 4688 | ||
| 15884 | 4689 | static void mw_prpl_join_chat(PurpleConnection *gc, |
| 10977 | 4690 | GHashTable *components) { |
| 4691 | ||
| 15884 | 4692 | struct mwPurplePluginData *pd; |
| 10977 | 4693 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4694 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4695 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4696 | |
| 4697 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4698 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4699 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4700 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4701 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4702 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4703 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4704 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4705 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4706 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4707 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4708 | |
| 10977 | 4709 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4710 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4711 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4712 | struct mwConference *conf = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4713 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4714 | srvc = pd->srvc_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4715 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4716 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4717 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4718 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4719 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4720 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4721 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4722 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4723 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4724 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4725 | } |
| 10977 | 4726 | } |
| 4727 | } | |
| 4728 | ||
| 4729 | ||
| 15884 | 4730 | static void mw_prpl_reject_chat(PurpleConnection *gc, |
| 10977 | 4731 | GHashTable *components) { |
| 4732 | ||
| 15884 | 4733 | struct mwPurplePluginData *pd; |
| 10977 | 4734 | struct mwServiceConference *srvc; |
| 4735 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4736 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4737 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4738 | srvc = pd->srvc_conf; |
| 4739 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4740 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4741 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4742 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4743 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4744 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4745 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4746 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4747 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4748 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4749 | } |
| 10977 | 4750 | } |
| 4751 | } | |
| 4752 | ||
| 4753 | ||
| 4754 | static char *mw_prpl_get_chat_name(GHashTable *components) { | |
| 4755 | return g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4756 | } | |
| 4757 | ||
| 4758 | ||
| 15884 | 4759 | static void mw_prpl_chat_invite(PurpleConnection *gc, |
| 10977 | 4760 | int id, |
| 4761 | const char *invitation, | |
| 4762 | const char *who) { | |
| 4763 | ||
| 15884 | 4764 | struct mwPurplePluginData *pd; |
| 10977 | 4765 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4766 | struct mwPlace *place; |
| 10977 | 4767 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4768 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4769 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4770 | g_return_if_fail(pd != NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4771 | |
| 10977 | 4772 | conf = ID_TO_CONF(pd, id); |
| 4773 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4774 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4775 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4776 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4777 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4778 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4779 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4780 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4781 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4782 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4783 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4784 | } |
| 4785 | ||
| 4786 | ||
| 15884 | 4787 | static void mw_prpl_chat_leave(PurpleConnection *gc, |
| 10977 | 4788 | int id) { |
| 4789 | ||
| 15884 | 4790 | struct mwPurplePluginData *pd; |
| 10977 | 4791 | struct mwConference *conf; |
| 4792 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4793 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4794 | |
| 4795 | g_return_if_fail(pd != NULL); | |
| 4796 | conf = ID_TO_CONF(pd, id); | |
| 4797 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4798 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4799 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4800 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4801 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4802 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4803 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4804 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4805 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4806 | } |
| 10977 | 4807 | } |
| 4808 | ||
| 4809 | ||
| 15884 | 4810 | static void mw_prpl_chat_whisper(PurpleConnection *gc, |
| 10977 | 4811 | int id, |
| 4812 | const char *who, | |
| 4813 | const char *message) { | |
| 4814 | ||
| 4815 | mw_prpl_send_im(gc, who, message, 0); | |
| 4816 | } | |
| 4817 | ||
| 4818 | ||
| 15884 | 4819 | static int mw_prpl_chat_send(PurpleConnection *gc, |
| 10977 | 4820 | int id, |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4821 | const char *message, |
| 15884 | 4822 | PurpleMessageFlags flags) { |
| 4823 | ||
| 4824 | struct mwPurplePluginData *pd; | |
| 10977 | 4825 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4826 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4827 | int ret; |
| 10977 | 4828 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4829 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4830 | |
| 4831 | g_return_val_if_fail(pd != NULL, 0); | |
| 4832 | conf = ID_TO_CONF(pd, id); | |
| 4833 | ||
| 15884 | 4834 | msg = purple_markup_strip_html(message); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4835 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4836 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4837 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4838 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4839 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4840 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4841 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4842 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4843 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4844 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4845 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4846 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4847 | return ret; |
| 10977 | 4848 | } |
| 4849 | ||
| 4850 | ||
| 15884 | 4851 | static void mw_prpl_keepalive(PurpleConnection *gc) { |
| 10977 | 4852 | struct mwSession *session; |
| 4853 | ||
| 4854 | g_return_if_fail(gc != NULL); | |
| 4855 | ||
| 4856 | session = gc_to_session(gc); | |
| 4857 | g_return_if_fail(session != NULL); | |
| 4858 | ||
| 4859 | mwSession_sendKeepalive(session); | |
| 4860 | } | |
| 4861 | ||
| 4862 | ||
| 15884 | 4863 | static void mw_prpl_alias_buddy(PurpleConnection *gc, |
| 10977 | 4864 | const char *who, |
| 4865 | const char *alias) { | |
| 4866 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4867 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4868 | g_return_if_fail(pd != NULL); |
| 4869 | ||
| 4870 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4871 | the server copy */ | |
| 4872 | ||
| 4873 | blist_schedule(pd); | |
| 4874 | } | |
| 4875 | ||
| 4876 | ||
| 15884 | 4877 | static void mw_prpl_group_buddy(PurpleConnection *gc, |
| 10977 | 4878 | const char *who, |
| 4879 | const char *old_group, | |
| 4880 | const char *new_group) { | |
| 4881 | ||
| 4882 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 4883 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4884 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4885 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4886 | PurpleGroup *group; |
| 10977 | 4887 | struct mwAwareList *list; |
| 4888 | ||
| 4889 | /* add who to new_group's aware list */ | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4890 | group = purple_blist_find_group(new_group); |
| 10977 | 4891 | list = list_ensure(pd, group); |
| 4892 | mwAwareList_addAware(list, gl); | |
| 4893 | ||
| 4894 | /* remove who from old_group's aware list */ | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4895 | group = purple_blist_find_group(old_group); |
| 10977 | 4896 | list = list_ensure(pd, group); |
| 4897 | mwAwareList_removeAware(list, gl); | |
| 4898 | ||
| 4899 | g_list_free(gl); | |
| 4900 | ||
| 4901 | /* schedule the changes to be saved */ | |
| 4902 | blist_schedule(pd); | |
| 4903 | } | |
| 4904 | ||
| 4905 | ||
| 15884 | 4906 | static void mw_prpl_rename_group(PurpleConnection *gc, |
| 10977 | 4907 | const char *old, |
| 15884 | 4908 | PurpleGroup *group, |
| 10977 | 4909 | GList *buddies) { |
| 4910 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4911 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4912 | g_return_if_fail(pd != NULL); |
| 4913 | ||
| 4914 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4915 | the server copy. Also, having this function should prevent all | |
| 4916 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4917 | give a crap what the group is named in Purple other than to record |
| 10977 | 4918 | that as the group name/alias */ |
| 4919 | ||
| 4920 | blist_schedule(pd); | |
| 4921 | } | |
| 4922 | ||
| 4923 | ||
| 15884 | 4924 | static void mw_prpl_buddy_free(PurpleBuddy *buddy) { |
| 10977 | 4925 | /* I don't think we have any cleanup for buddies yet */ |
| 4926 | ; | |
| 4927 | } | |
| 4928 | ||
| 4929 | ||
| 15884 | 4930 | static void mw_prpl_convo_closed(PurpleConnection *gc, const char *who) { |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4931 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4932 | struct mwServiceIm *srvc; |
| 4933 | struct mwConversation *conv; | |
| 4934 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4935 | ||
| 4936 | g_return_if_fail(pd != NULL); | |
| 4937 | ||
| 4938 | srvc = pd->srvc_im; | |
| 4939 | g_return_if_fail(srvc != NULL); | |
| 4940 | ||
| 4941 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 4942 | if(! conv) return; | |
| 4943 | ||
| 4944 | if(mwConversation_isOpen(conv)) | |
| 4945 | mwConversation_free(conv); | |
| 4946 | } | |
| 4947 | ||
| 4948 | ||
| 15884 | 4949 | static const char *mw_prpl_normalize(const PurpleAccount *account, |
| 10977 | 4950 | const char *id) { |
| 4951 | ||
| 4952 | /* code elsewhere assumes that the return value points to different | |
| 4953 | memory than the passed value, but it won't free the normalized | |
| 4954 | data. wtf? */ | |
| 4955 | ||
| 4956 | static char buf[BUF_LEN]; | |
|
33745
c31cf8de31cd
Fix a crash in Sametime when a malicious server sends us an abnormally
Mark Doliner <mark@kingant.net>
parents:
32049
diff
changeset
|
4957 | g_strlcpy(buf, id, sizeof(buf)); |
| 10977 | 4958 | return buf; |
| 4959 | } | |
| 4960 | ||
| 4961 | ||
| 15884 | 4962 | static void mw_prpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { |
| 4963 | struct mwPurplePluginData *pd; | |
| 10977 | 4964 | struct mwAwareList *list; |
| 4965 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4966 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4967 | g_return_if_fail(pd != NULL); |
| 4968 | g_return_if_fail(pd->group_list_map != NULL); | |
| 4969 | ||
| 4970 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 4971 | ||
| 4972 | if(list) { | |
| 4973 | g_hash_table_remove(pd->group_list_map, list); | |
| 4974 | g_hash_table_remove(pd->group_list_map, group); | |
| 4975 | mwAwareList_free(list); | |
| 4976 | ||
| 4977 | blist_schedule(pd); | |
| 4978 | } | |
| 4979 | } | |
| 4980 | ||
| 4981 | ||
| 15884 | 4982 | static gboolean mw_prpl_can_receive_file(PurpleConnection *gc, |
| 10977 | 4983 | const char *who) { |
| 15884 | 4984 | struct mwPurplePluginData *pd; |
| 10977 | 4985 | struct mwServiceAware *srvc; |
| 15884 | 4986 | PurpleAccount *acct; |
| 10977 | 4987 | |
| 4988 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 4989 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4990 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4991 | g_return_val_if_fail(pd != NULL, FALSE); |
| 4992 | ||
| 4993 | srvc = pd->srvc_aware; | |
| 4994 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4995 | |
| 15884 | 4996 | acct = purple_connection_get_account(gc); |
| 10977 | 4997 | g_return_val_if_fail(acct != NULL, FALSE); |
| 4998 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4999 | return purple_blist_find_buddy(acct, who) && |
| 10977 | 5000 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 5001 | } | |
| 5002 | ||
| 5003 | ||
| 15884 | 5004 | static void ft_outgoing_init(PurpleXfer *xfer) { |
| 5005 | PurpleAccount *acct; | |
| 5006 | PurpleConnection *gc; | |
| 5007 | ||
| 5008 | struct mwPurplePluginData *pd; | |
| 10977 | 5009 | struct mwServiceFileTransfer *srvc; |
| 5010 | struct mwFileTransfer *ft; | |
| 5011 | ||
| 5012 | const char *filename; | |
| 5013 | gsize filesize; | |
| 5014 | FILE *fp; | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5015 | char *remote_user = NULL; |
| 10977 | 5016 | |
| 5017 | struct mwIdBlock idb = { NULL, NULL }; | |
| 5018 | ||
| 5019 | DEBUG_INFO("ft_outgoing_init\n"); | |
| 5020 | ||
| 15884 | 5021 | acct = purple_xfer_get_account(xfer); |
| 5022 | gc = purple_account_get_connection(acct); | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5023 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5024 | srvc = pd->srvc_ft; |
| 5025 | ||
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5026 | remote_user = g_strdup(purple_xfer_get_remote_user(xfer)); |
|
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5027 | |
| 15884 | 5028 | filename = purple_xfer_get_local_filename(xfer); |
| 5029 | filesize = purple_xfer_get_size(xfer); | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5030 | idb.user = remote_user; |
| 10977 | 5031 | |
| 15884 | 5032 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5033 | |
| 10977 | 5034 | /* test that we can actually send the file */ |
| 5035 | fp = g_fopen(filename, "rb"); | |
| 5036 | if(! fp) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5037 | 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
|
5038 | filename, g_strerror(errno)); |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
5039 | purple_xfer_error(purple_xfer_get_type(xfer), acct, purple_xfer_get_remote_user(xfer), msg); |
| 10977 | 5040 | g_free(msg); |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5041 | g_free(remote_user); |
| 10977 | 5042 | return; |
| 5043 | } | |
| 5044 | fclose(fp); | |
| 5045 | ||
| 5046 | { | |
| 5047 | char *tmp = strrchr(filename, G_DIR_SEPARATOR); | |
| 5048 | if(tmp++) filename = tmp; | |
| 5049 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5050 | |
| 10977 | 5051 | ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); |
| 5052 | ||
| 15884 | 5053 | purple_xfer_ref(xfer); |
| 5054 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
5055 | purple_xfer_set_protocol_data(xfer, ft); |
| 10977 | 5056 | |
| 5057 | mwFileTransfer_offer(ft); | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5058 | g_free(remote_user); |
| 10977 | 5059 | } |
| 5060 | ||
| 5061 | ||
| 15884 | 5062 | static void ft_outgoing_cancel(PurpleXfer *xfer) { |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
5063 | struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5064 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5065 | DEBUG_INFO("ft_outgoing_cancel called\n"); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5066 | |
| 10977 | 5067 | if(ft) mwFileTransfer_cancel(ft); |
| 5068 | } | |
| 5069 | ||
| 5070 | ||
| 15884 | 5071 | static PurpleXfer *mw_prpl_new_xfer(PurpleConnection *gc, const char *who) { |
| 5072 | PurpleAccount *acct; | |
| 5073 | PurpleXfer *xfer; | |
| 5074 | ||
| 5075 | acct = purple_connection_get_account(gc); | |
| 5076 | ||
| 5077 | xfer = purple_xfer_new(acct, PURPLE_XFER_SEND, who); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5078 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5079 | { |
| 15884 | 5080 | purple_xfer_set_init_fnc(xfer, ft_outgoing_init); |
| 5081 | purple_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5082 | } |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5083 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5084 | return xfer; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5085 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5086 | |
| 15884 | 5087 | static void mw_prpl_send_file(PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5088 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5089 | |
| 15884 | 5090 | PurpleXfer *xfer = mw_prpl_new_xfer(gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5091 | |
| 10977 | 5092 | if(file) { |
| 5093 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 5094 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 5095 | |
| 5096 | } else { | |
| 5097 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 5098 | purple_xfer_request(xfer); |
| 10977 | 5099 | } |
| 5100 | } | |
| 5101 | ||
| 5102 | ||
| 15884 | 5103 | static PurplePluginProtocolInfo mw_prpl_info = { |
|
32637
2b7528058b5d
Switch back to initializing the struct this way. I guess the other
Mark Doliner <markdoliner@pidgin.im>
parents:
32636
diff
changeset
|
5104 | sizeof(PurplePluginProtocolInfo), |
|
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
|
5105 | 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
|
5106 | 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
|
5107 | 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
|
5108 | 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
|
5109 | 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
|
5110 | 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
|
5111 | 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
|
5112 | 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
|
5113 | 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
|
5114 | 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
|
5115 | 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
|
5116 | 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
|
5117 | 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
|
5118 | 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
|
5119 | 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
|
5120 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5121 | 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
|
5122 | 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
|
5123 | 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
|
5124 | 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
|
5125 | 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
|
5126 | 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
|
5127 | 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
|
5128 | 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
|
5129 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5130 | mw_prpl_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
|
5131 | 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
|
5132 | 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
|
5133 | 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
|
5134 | 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
|
5135 | 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
|
5136 | 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
|
5137 | 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
|
5138 | 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
|
5139 | 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
|
5140 | 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
|
5141 | 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
|
5142 | 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
|
5143 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5144 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5145 | 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
|
5146 | 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
|
5147 | 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
|
5148 | 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
|
5149 | 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
|
5150 | 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
|
5151 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5152 | 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
|
5153 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5154 | NULL, |
|
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 | 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
|
5156 | 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
|
5157 | 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
|
5158 | 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
|
5159 | 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
|
5160 | 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
|
5161 | 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
|
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 | 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
|
5164 | 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
|
5165 | 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
|
5166 | 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
|
5167 | 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
|
5168 | 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
|
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 | 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
|
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 |
| 10977 | 5175 | }; |
| 5176 | ||
| 5177 | ||
| 15884 | 5178 | static PurplePluginPrefFrame * |
| 5179 | mw_plugin_get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 5180 | PurplePluginPrefFrame *frame; | |
| 5181 | PurplePluginPref *pref; | |
| 5182 | ||
| 5183 | frame = purple_plugin_pref_frame_new(); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5184 | |
| 15884 | 5185 | pref = purple_plugin_pref_new_with_label(_("Remotely Stored Buddy List")); |
| 5186 | purple_plugin_pref_frame_add(frame, pref); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5187 | |
| 10977 | 5188 | |
| 15884 | 5189 | pref = purple_plugin_pref_new_with_name(MW_PRPL_OPT_BLIST_ACTION); |
| 5190 | purple_plugin_pref_set_label(pref, _("Buddy List Storage Mode")); | |
| 5191 | ||
| 5192 | purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE); | |
| 5193 | 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
|
5194 | GINT_TO_POINTER(blist_choice_LOCAL)); |
| 15884 | 5195 | 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
|
5196 | GINT_TO_POINTER(blist_choice_MERGE)); |
| 15884 | 5197 | 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
|
5198 | GINT_TO_POINTER(blist_choice_STORE)); |
| 15884 | 5199 | 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
|
5200 | GINT_TO_POINTER(blist_choice_SYNCH)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5201 | |
| 15884 | 5202 | purple_plugin_pref_frame_add(frame, pref); |
| 10977 | 5203 | |
| 5204 | return frame; | |
| 5205 | } | |
| 5206 | ||
| 5207 | ||
| 15884 | 5208 | static PurplePluginUiInfo mw_plugin_ui_info = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5209 | mw_plugin_get_plugin_pref_frame, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5210 | 0, /* page_num */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5211 | NULL, /* frame */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5212 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5213 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5214 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5215 | NULL |
| 10977 | 5216 | }; |
| 5217 | ||
| 5218 | ||
| 15884 | 5219 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5220 | struct mwSametimeList *l; |
| 5221 | ||
| 5222 | FILE *file; | |
| 5223 | char buf[BUF_LEN]; | |
| 5224 | size_t len; | |
| 5225 | ||
| 5226 | GString *str; | |
| 5227 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5228 | file = g_fopen(filename, "r"); |
| 10977 | 5229 | g_return_if_fail(file != NULL); |
| 5230 | ||
| 5231 | str = g_string_new(NULL); | |
| 5232 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 5233 | g_string_append_len(str, buf, len); | |
| 5234 | } | |
| 5235 | ||
| 5236 | fclose(file); | |
| 5237 | ||
| 5238 | l = mwSametimeList_load(str->str); | |
| 5239 | g_string_free(str, TRUE); | |
| 5240 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5241 | blist_merge(gc, l); |
| 10977 | 5242 | mwSametimeList_free(l); |
| 5243 | } | |
| 5244 | ||
| 5245 | ||
| 5246 | /** prompts for a file to import blist from */ | |
| 15884 | 5247 | static void st_import_action(PurplePluginAction *act) { |
| 5248 | PurpleConnection *gc; | |
| 5249 | PurpleAccount *account; | |
| 10977 | 5250 | char *title; |
| 5251 | ||
| 5252 | gc = act->context; | |
| 15884 | 5253 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5254 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 5255 | purple_account_get_username(account)); |
| 5256 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5257 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 5258 | 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
|
5259 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5260 | gc); |
| 10977 | 5261 | |
| 5262 | g_free(title); | |
| 5263 | } | |
| 5264 | ||
| 5265 | ||
| 15884 | 5266 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5267 | struct mwSametimeList *l; |
| 5268 | char *str; | |
| 5269 | FILE *file; | |
| 5270 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5271 | file = g_fopen(filename, "w"); |
| 10977 | 5272 | g_return_if_fail(file != NULL); |
| 5273 | ||
| 5274 | l = mwSametimeList_new(); | |
| 5275 | blist_export(gc, l); | |
| 5276 | str = mwSametimeList_store(l); | |
| 5277 | mwSametimeList_free(l); | |
| 5278 | ||
| 5279 | fprintf(file, "%s", str); | |
| 5280 | fclose(file); | |
| 5281 | ||
| 5282 | g_free(str); | |
| 5283 | } | |
| 5284 | ||
| 5285 | ||
| 5286 | /** prompts for a file to export blist to */ | |
| 15884 | 5287 | static void st_export_action(PurplePluginAction *act) { |
| 5288 | PurpleConnection *gc; | |
| 5289 | PurpleAccount *account; | |
| 10977 | 5290 | char *title; |
| 5291 | ||
| 5292 | gc = act->context; | |
| 15884 | 5293 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5294 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 5295 | purple_account_get_username(account)); |
| 5296 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5297 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 5298 | 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
|
5299 | account, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5300 | gc); |
| 10977 | 5301 | |
| 5302 | g_free(title); | |
| 5303 | } | |
| 5304 | ||
| 5305 | ||
| 5306 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 5307 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5308 | |
| 15884 | 5309 | 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
|
5310 | GList *l; |
| 10977 | 5311 | |
| 15884 | 5312 | f = purple_request_fields_get_field(fields, "group"); |
| 5313 | l = purple_request_field_list_get_items(f); | |
| 10977 | 5314 | |
| 5315 | for(; l; l = l->next) { | |
| 5316 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5317 | struct named_id *res; |
| 10977 | 5318 | |
| 15884 | 5319 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5320 | |
| 5321 | g_free(res->id); | |
| 5322 | g_free(res->name); | |
| 5323 | g_free(res); | |
| 5324 | } | |
| 5325 | } | |
| 5326 | ||
| 5327 | ||
| 15884 | 5328 | static void remote_group_done(struct mwPurplePluginData *pd, |
| 10977 | 5329 | const char *id, const char *name) { |
| 15884 | 5330 | PurpleConnection *gc; |
| 5331 | PurpleAccount *acct; | |
| 5332 | PurpleGroup *group; | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
5333 | PurpleBlistNode *gn; |
| 10977 | 5334 | const char *owner; |
| 5335 | ||
| 5336 | g_return_if_fail(pd != NULL); | |
| 5337 | ||
| 5338 | gc = pd->gc; | |
| 15884 | 5339 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5340 | |
| 10977 | 5341 | /* collision checking */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
5342 | group = purple_blist_find_group(name); |
| 10977 | 5343 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5344 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5345 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5346 | char *msg; |
| 10977 | 5347 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5348 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5349 | 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
|
5350 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5351 | |
| 15884 | 5352 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5353 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5354 | g_free(msg); |
| 10977 | 5355 | return; |
| 5356 | } | |
| 5357 | ||
| 15884 | 5358 | group = purple_group_new(name); |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
5359 | gn = (PurpleBlistNode *) group; |
| 15884 | 5360 | |
| 5361 | owner = purple_account_get_username(acct); | |
| 5362 | ||
| 5363 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 5364 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 5365 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 5366 | purple_blist_add_group(group, NULL); | |
| 10977 | 5367 | |
| 5368 | group_add(pd, group); | |
| 5369 | blist_schedule(pd); | |
| 5370 | } | |
| 5371 | ||
| 5372 | ||
| 15884 | 5373 | static void remote_group_multi_cb(struct mwPurplePluginData *pd, |
| 5374 | PurpleRequestFields *fields) { | |
| 5375 | 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
|
5376 | GList *l; |
| 10977 | 5377 | |
| 15884 | 5378 | f = purple_request_fields_get_field(fields, "group"); |
| 5379 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 5380 | |
| 5381 | if(l) { | |
| 5382 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5383 | struct named_id *res; |
| 10977 | 5384 | |
| 15884 | 5385 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5386 | remote_group_done(pd, res->id, res->name); |
| 5387 | } | |
| 5388 | ||
| 5389 | remote_group_multi_cleanup(NULL, fields); | |
| 5390 | } | |
| 5391 | ||
| 5392 | ||
| 5393 | static void remote_group_multi(struct mwResolveResult *result, | |
| 15884 | 5394 | struct mwPurplePluginData *pd) { |
| 5395 | ||
| 5396 | PurpleRequestFields *fields; | |
| 5397 | PurpleRequestFieldGroup *g; | |
| 5398 | PurpleRequestField *f; | |
| 10977 | 5399 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5400 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5401 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5402 | char *msg; |
| 10977 | 5403 | |
| 15884 | 5404 | PurpleConnection *gc = pd->gc; |
| 5405 | ||
| 5406 | fields = purple_request_fields_new(); | |
| 5407 | ||
| 5408 | g = purple_request_field_group_new(NULL); | |
| 5409 | purple_request_fields_add_group(fields, g); | |
| 5410 | ||
| 5411 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 5412 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 5413 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 5414 | |
| 5415 | for(l = result->matches; l; l = l->next) { | |
| 5416 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5417 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 5418 | |
| 5419 | res->id = g_strdup(match->id); | |
| 5420 | res->name = g_strdup(match->name); | |
| 5421 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
5422 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 5423 | } |
| 5424 | ||
| 15884 | 5425 | purple_request_field_group_add_field(g, f); |
| 10977 | 5426 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5427 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5428 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 5429 | " Notes Address Book groups. Please select the correct group from" |
| 5430 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5431 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 5432 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5433 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5434 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5435 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5436 | _("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
|
5437 | purple_connection_get_account(gc), result->name, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5438 | pd); |
| 10977 | 5439 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5440 | g_free(msg); |
| 10977 | 5441 | } |
| 5442 | ||
| 5443 | ||
| 5444 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 5445 | guint32 id, guint32 code, GList *results, | |
| 5446 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5447 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5448 | struct mwResolveResult *res = NULL; |
| 10977 | 5449 | struct mwSession *session; |
| 15884 | 5450 | struct mwPurplePluginData *pd; |
| 5451 | PurpleConnection *gc; | |
| 10977 | 5452 | |
| 5453 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5454 | g_return_if_fail(session != NULL); | |
| 5455 | ||
| 5456 | pd = mwSession_getClientData(session); | |
| 5457 | g_return_if_fail(pd != NULL); | |
| 5458 | ||
| 5459 | gc = pd->gc; | |
| 5460 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5461 | |
| 10977 | 5462 | if(!code && results) { |
| 5463 | res = results->data; | |
| 5464 | ||
| 5465 | if(res->matches) { | |
| 5466 | remote_group_multi(res, pd); | |
| 5467 | return; | |
| 5468 | } | |
| 5469 | } | |
| 5470 | ||
| 5471 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5472 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5473 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5474 | char *msg; |
| 10977 | 5475 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5476 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5477 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5478 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5479 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5480 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5481 | |
| 15884 | 5482 | purple_notify_error(gc, _("Unable to add group"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5483 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5484 | g_free(msg); |
| 10977 | 5485 | } |
| 5486 | } | |
| 5487 | ||
| 5488 | ||
| 15884 | 5489 | static void remote_group_action_cb(PurpleConnection *gc, const char *name) { |
| 5490 | struct mwPurplePluginData *pd; | |
| 10977 | 5491 | struct mwServiceResolve *srvc; |
| 5492 | GList *query; | |
| 5493 | enum mwResolveFlag flags; | |
| 5494 | guint32 req; | |
| 5495 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5496 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5497 | srvc = pd->srvc_resolve; |
| 5498 | ||
| 5499 | query = g_list_prepend(NULL, (char *) name); | |
| 5500 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5501 | |
| 10977 | 5502 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5503 | NULL, NULL); | |
| 5504 | g_list_free(query); | |
| 5505 | ||
| 5506 | if(req == SEARCH_ERROR) { | |
| 5507 | /** @todo display error */ | |
| 5508 | } | |
| 5509 | } | |
| 5510 | ||
| 5511 | ||
| 15884 | 5512 | static void remote_group_action(PurplePluginAction *act) { |
| 5513 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5514 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5515 | const char *msgB; |
| 10977 | 5516 | |
| 5517 | gc = act->context; | |
| 5518 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5519 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5520 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5521 | " to add the group and its members to your buddy list."); |
| 5522 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5523 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5524 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5525 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5526 | _("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
|
5527 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5528 | gc); |
| 10977 | 5529 | } |
| 5530 | ||
| 5531 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5532 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5533 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5534 | GList *l; |
|
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; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5537 | char *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5538 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5539 | |
| 15884 | 5540 | PurpleNotifySearchResults *sres; |
| 5541 | PurpleNotifySearchColumn *scol; | |
| 5542 | ||
| 5543 | sres = purple_notify_searchresults_new(); | |
| 5544 | ||
| 5545 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5546 | purple_notify_searchresults_column_add(sres, scol); | |
| 5547 | ||
| 5548 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5549 | purple_notify_searchresults_column_add(sres, scol); | |
| 5550 | ||
| 5551 | 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
|
5552 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5553 | |
| 15884 | 5554 | 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
|
5555 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5556 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5557 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5558 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5559 | GList *row = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5560 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5561 | if(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5562 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5563 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5564 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5565 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5566 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5567 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5568 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5569 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5570 | 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
|
5571 | " 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
|
5572 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5573 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5574 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5575 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5576 | |
| 15884 | 5577 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5578 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5579 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5580 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5581 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5582 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5583 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5584 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5585 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5586 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5587 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5588 | |
| 15884 | 5589 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5590 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5591 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5592 | if(results) res = results->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5593 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5594 | if(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5595 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5596 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5597 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5598 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5599 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5600 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5601 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5602 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5603 | 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
|
5604 | " Sametime community."); |
|
20228
ce019944d765
applied changes from 9d35dde0c779cca73548172223ba557f27d61882
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
5605 | 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
|
5606 | |
| 15884 | 5607 | purple_notify_error(gc, _("No Matches"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5608 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5609 | g_free(msg); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5610 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5611 | } |
|
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 | |
| 15884 | 5614 | static void search_action_cb(PurpleConnection *gc, const char *name) { |
| 5615 | struct mwPurplePluginData *pd; | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5616 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5617 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5618 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5619 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5620 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
5621 | pd = purple_connection_get_protocol_data(gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5622 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5623 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5624 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5625 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5626 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5627 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5628 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5629 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5630 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5631 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5632 | /** @todo display error */ |
|
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 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5635 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5636 | |
| 15884 | 5637 | static void search_action(PurplePluginAction *act) { |
| 5638 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5639 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5640 | const char *msgB; |
|
12630
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 | gc = act->context; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5643 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5644 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5645 | 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
|
5646 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5647 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5648 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5649 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5650 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5651 | _("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
|
5652 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5653 | gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5654 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5655 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5656 | |
| 15884 | 5657 | static GList *mw_plugin_actions(PurplePlugin *plugin, gpointer context) { |
| 5658 | PurplePluginAction *act; | |
| 10977 | 5659 | GList *l = NULL; |
| 5660 | ||
| 15884 | 5661 | act = purple_plugin_action_new(_("Import Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5662 | st_import_action); |
| 10977 | 5663 | l = g_list_append(l, act); |
| 5664 | ||
| 15884 | 5665 | act = purple_plugin_action_new(_("Export Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5666 | st_export_action); |
| 10977 | 5667 | l = g_list_append(l, act); |
| 5668 | ||
| 15884 | 5669 | act = purple_plugin_action_new(_("Add Notes Address Book Group..."), |
| 10977 | 5670 | remote_group_action); |
| 5671 | l = g_list_append(l, act); | |
| 5672 | ||
| 15884 | 5673 | act = purple_plugin_action_new(_("User Search..."), |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5674 | search_action); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5675 | l = g_list_append(l, act); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5676 | |
| 10977 | 5677 | return l; |
| 5678 | } | |
| 5679 | ||
| 5680 | ||
| 15884 | 5681 | static gboolean mw_plugin_load(PurplePlugin *plugin) { |
| 10977 | 5682 | return TRUE; |
| 5683 | } | |
| 5684 | ||
| 5685 | ||
| 15884 | 5686 | static gboolean mw_plugin_unload(PurplePlugin *plugin) { |
| 10977 | 5687 | return TRUE; |
| 5688 | } | |
| 5689 | ||
| 5690 | ||
| 15884 | 5691 | static void mw_plugin_destroy(PurplePlugin *plugin) { |
| 10977 | 5692 | g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); |
| 5693 | g_log_remove_handler("meanwhile", log_handler[1]); | |
| 5694 | } | |
| 5695 | ||
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5696 | static PurplePluginInfo mw_plugin_info = |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5697 | { |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5698 | PURPLE_PLUGIN_MAGIC, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5699 | PURPLE_MAJOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5700 | PURPLE_MINOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5701 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5702 | NULL, /**< ui_requirement */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5703 | 0, /**< flags */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5704 | NULL, /**< dependencies */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5705 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5706 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5707 | PLUGIN_ID, /**< id */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5708 | PLUGIN_NAME, /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20228
diff
changeset
|
5709 | DISPLAY_VERSION, /**< version */ |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5710 | PLUGIN_SUMMARY, /**< summary */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5711 | PLUGIN_DESC, /**< description */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5712 | PLUGIN_AUTHOR, /**< author */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5713 | PLUGIN_HOMEPAGE, /**< homepage */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5714 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5715 | mw_plugin_load, /**< load */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5716 | mw_plugin_unload, /**< unload */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5717 | mw_plugin_destroy, /**< destroy */ |
|
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 | NULL, /**< ui_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5720 | &mw_prpl_info, /**< extra_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5721 | &mw_plugin_ui_info, /**< prefs_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5722 | mw_plugin_actions, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5723 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5724 | /* padding */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5725 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5726 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5727 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5728 | NULL |
| 10977 | 5729 | }; |
| 5730 | ||
| 5731 | ||
| 5732 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5733 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5734 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5735 | if(! (msg && *msg)) return; |
| 10977 | 5736 | |
| 15884 | 5737 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5738 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5739 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5740 | |
| 5741 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5742 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5743 | |
| 5744 | } else { | |
| 15884 | 5745 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5746 | } |
| 5747 | } | |
| 5748 | ||
| 5749 | ||
| 15884 | 5750 | 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
|
5751 | PurpleAccountUserSplit *split; |
| 15884 | 5752 | PurpleAccountOption *opt; |
| 10977 | 5753 | GList *l = NULL; |
| 5754 | ||
| 5755 | GLogLevelFlags logflags = | |
| 5756 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5757 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5758 | /* set up the preferences */ |
| 15884 | 5759 | purple_prefs_add_none(MW_PRPL_OPT_BASE); |
| 5760 | 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
|
5761 | |
|
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
|
5762 | /* 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
|
5763 | 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
|
5764 | 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
|
5765 | 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
|
5766 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5767 | /* remove dead preferences */ |
| 15884 | 5768 | purple_prefs_remove(MW_PRPL_OPT_PSYCHIC); |
| 5769 | purple_prefs_remove(MW_PRPL_OPT_SAVE_DYNAMIC); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5770 | |
| 10977 | 5771 | /* port to connect to */ |
| 15884 | 5772 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
| 10977 | 5773 | MW_PLUGIN_DEFAULT_PORT); |
| 5774 | l = g_list_append(l, opt); | |
| 5775 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5776 | { /* 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
|
5777 | 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
|
5778 | than one account that wants to check for it. */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5779 | gboolean b = FALSE; |
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12422
diff
changeset
|
5780 | const char *label = _("Force login (ignore server redirects)"); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5781 | |
| 15884 | 5782 | if(purple_prefs_exists(MW_PRPL_OPT_FORCE_LOGIN)) |
| 5783 | b = purple_prefs_get_bool(MW_PRPL_OPT_FORCE_LOGIN); | |
| 5784 | ||
| 5785 | 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
|
5786 | l = g_list_append(l, opt); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5787 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5788 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5789 | /* pretend to be Sametime Connect */ |
| 15884 | 5790 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5791 | MW_KEY_FAKE_IT, FALSE); |
|
12312
470a1452d009
[gaim-migrate @ 14616]
Christopher O'Brien <siege@pidgin.im>
parents:
12311
diff
changeset
|
5792 | l = g_list_append(l, opt); |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5793 | |
| 10977 | 5794 | mw_prpl_info.protocol_options = l; |
| 5795 | l = NULL; | |
| 5796 | ||
| 15884 | 5797 | /* forward all our g_log messages to purple. Generally all the logging |
| 5798 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5799 | get caught here */ |
| 5800 | log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags, | |
| 5801 | mw_log_handler, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5802 | |
| 15884 | 5803 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5804 | log_handler[1] = g_log_set_handler("meanwhile", logflags, |
| 5805 | mw_log_handler, NULL); | |
| 5806 | } | |
| 5807 | ||
| 5808 | ||
| 15884 | 5809 | PURPLE_INIT_PLUGIN(sametime, mw_plugin_init, mw_plugin_info); |
| 10977 | 5810 | /* The End. */ |
| 5811 |