Sat, 21 Sep 2013 16:41:50 +0530
Merged default 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" |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
39 | #include "xfer.h" |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
40 | #include "imgstore.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
41 | #include "mime.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
42 | #include "notify.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
43 | #include "plugin.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
44 | #include "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; | |
| 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); |
| 15884 | 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 | ||
| 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; |
| 662 | PurpleBlistNode *gn, *cn, *bn; | |
| 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); |
| 15884 | 873 | purple_blist_node_set_string((PurpleBlistNode *) buddy, BUDDY_KEY_NAME, name); |
| 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 | |
| 15884 | 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; | |
| 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 | ||
| 15884 | 967 | gn = (PurpleBlistNode *) group; |
| 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; |
| 15884 | 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 | |
| 15884 | 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; |
| 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 | |
| 15884 | 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; | |
| 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; |
| 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 | ||
| 15884 | 1295 | static void blist_menu_nab(PurpleBlistNode *node, gpointer data) { |
| 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 */ | |
| 15884 | 1333 | static void blist_node_menu_cb(PurpleBlistNode *node, |
| 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) { |
| 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; |
| 15884 | 1413 | PurpleBlistNode *l; |
| 10977 | 1414 | |
| 1415 | gc = pd->gc; | |
| 15884 | 1416 | acct = purple_connection_get_account(gc); |
| 10977 | 1417 | |
| 1418 | /* grab the buddy list from the server */ | |
| 1419 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1420 | mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
| 10977 | 1421 | |
| 1422 | /* find all the NAB groups and subscribe to them */ | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1423 | for(l = purple_blist_get_root(); l; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1424 | l = purple_blist_node_get_sibling_next(l)) { |
| 15884 | 1425 | PurpleGroup *group = (PurpleGroup *) l; |
| 10977 | 1426 | enum mwSametimeGroupType gt; |
| 1427 | const char *owner; | |
| 1428 | ||
|
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"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1721 | prim, text, NULL, NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1722 | purple_request_cpar_from_connection(gc)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1723 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1724 | g_free(prim); |
| 10977 | 1725 | } |
| 1726 | ||
| 1727 | ||
| 1728 | /** called from read_cb, attempts to read available data from sock and | |
| 1729 | pass it to the session, passing back the return code from the read | |
| 1730 | call for handling in read_cb */ | |
| 1731 | static int read_recv(struct mwSession *session, int sock) { | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1732 | guchar buf[BUF_LEN]; |
| 10977 | 1733 | int len; |
| 1734 | ||
| 1735 | 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
|
1736 | 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
|
1737 | 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
|
1738 | } |
| 10977 | 1739 | |
| 1740 | return len; | |
| 1741 | } | |
| 1742 | ||
| 1743 | ||
| 15884 | 1744 | /** callback triggered from purple_input_add, watches the socked for |
| 10977 | 1745 | available data to be processed by the session */ |
| 15884 | 1746 | static void read_cb(gpointer data, gint source, PurpleInputCondition cond) { |
| 1747 | struct mwPurplePluginData *pd = data; | |
| 10977 | 1748 | int ret = 0, err = 0; |
| 1749 | ||
| 1750 | g_return_if_fail(pd != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1751 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1752 | ret = read_recv(pd->session, pd->socket); |
| 10977 | 1753 | |
| 1754 | /* normal operation ends here */ | |
| 1755 | if(ret > 0) return; | |
| 1756 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1757 | /* fetch the global error value */ |
| 10977 | 1758 | err = errno; |
| 1759 | ||
| 14754 | 1760 | /* read problem occurred if we're here, so we'll need to take care of |
| 10977 | 1761 | it and clean up internal state */ |
| 1762 | ||
| 1763 | if(pd->socket) { | |
| 1764 | close(pd->socket); | |
| 1765 | pd->socket = 0; | |
| 1766 | } | |
| 1767 | ||
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1768 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1769 | 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
|
1770 | pd->inpa = 0; |
| 10977 | 1771 | } |
| 1772 | ||
| 1773 | if(! ret) { | |
| 1774 | 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
|
1775 | purple_connection_error(pd->gc, |
| 21279 | 1776 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1777 | _("Server closed the connection")); |
| 10977 | 1778 | |
| 1779 | } 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
|
1780 | 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
|
1781 | 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
|
1782 | |
|
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 | 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
|
1784 | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1785 | 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
|
1786 | purple_connection_error(pd->gc, |
| 21279 | 1787 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 1788 | msg); | |
| 10977 | 1789 | g_free(msg); |
| 1790 | } | |
| 1791 | } | |
| 1792 | ||
| 1793 | ||
| 15884 | 1794 | /** Callback passed to purple_proxy_connect when an account is logged |
| 10977 | 1795 | 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
|
1796 | static void connect_cb(gpointer data, gint source, const gchar *error_message) { |
| 10977 | 1797 | |
| 15884 | 1798 | struct mwPurplePluginData *pd = data; |
| 10977 | 1799 | |
| 1800 | if(source < 0) { | |
| 1801 | /* connection failed */ | |
| 1802 | ||
| 1803 | if(pd->socket) { | |
| 1804 | /* this is a redirect connect, force login on existing socket */ | |
| 1805 | mwSession_forceLogin(pd->session); | |
| 1806 | ||
| 1807 | } else { | |
| 1808 | /* this is a regular connect, error out */ | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1809 | 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
|
1810 | error_message); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1811 | purple_connection_error(pd->gc, |
| 21279 | 1812 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1813 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1814 | g_free(tmp); |
| 10977 | 1815 | } |
| 1816 | ||
| 1817 | return; | |
| 1818 | } | |
| 1819 | ||
| 1820 | if(pd->socket) { | |
| 1821 | /* stop any existing login attempt */ | |
| 1822 | mwSession_stop(pd->session, ERR_SUCCESS); | |
| 1823 | } | |
| 1824 | ||
| 1825 | pd->socket = source; | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1826 | pd->inpa = purple_input_add(source, PURPLE_INPUT_READ, |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
1827 | read_cb, pd); |
| 10977 | 1828 | |
| 1829 | mwSession_start(pd->session); | |
| 1830 | } | |
| 1831 | ||
| 1832 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1833 | static void mw_session_announce(struct mwSession *s, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1834 | struct mwLoginInfo *from, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1835 | gboolean may_reply, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1836 | const char *text) { |
| 15884 | 1837 | struct mwPurplePluginData *pd; |
| 1838 | PurpleAccount *acct; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1839 | PurpleIMConversation *im; |
| 15884 | 1840 | PurpleBuddy *buddy; |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1841 | char *who = from->user_id; |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1842 | char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1843 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1844 | pd = mwSession_getClientData(s); |
| 15884 | 1845 | 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
|
1846 | 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
|
1847 | if(! im) im = purple_im_conversation_new(acct, who); |
| 15884 | 1848 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
1849 | buddy = purple_blist_find_buddy(acct, who); |
| 15884 | 1850 | 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
|
1851 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1852 | who = g_strdup_printf(_("Announcement from %s"), who); |
| 15884 | 1853 | msg = purple_markup_linkify(text); |
| 1854 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1855 | 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
|
1856 | PURPLE_MESSAGE_RECV, time(NULL)); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1857 | g_free(who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1858 | g_free(msg); |
| 10977 | 1859 | } |
| 1860 | ||
| 1861 | ||
| 1862 | static struct mwSessionHandler mw_session_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1863 | mw_session_io_write, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1864 | mw_session_io_close, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1865 | mw_session_clear, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1866 | mw_session_stateChange, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1867 | mw_session_setPrivacyInfo, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1868 | mw_session_setUserStatus, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1869 | mw_session_admin, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1870 | mw_session_announce, |
| 10977 | 1871 | }; |
| 1872 | ||
| 1873 | ||
| 1874 | static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
| 1875 | struct mwAwareAttribute *attrib) { | |
| 1876 | ||
| 1877 | ; /** @todo handle server attributes. There may be some stuff we | |
| 1878 | actually want to look for, but I'm not aware of anything right | |
| 1879 | now.*/ | |
| 1880 | } | |
| 1881 | ||
| 1882 | ||
| 1883 | static void mw_aware_clear(struct mwServiceAware *srvc) { | |
| 1884 | ; /* nothing for now */ | |
| 1885 | } | |
| 1886 | ||
| 1887 | ||
| 1888 | static struct mwAwareHandler mw_aware_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1889 | mw_aware_on_attrib, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1890 | mw_aware_clear, |
| 10977 | 1891 | }; |
| 1892 | ||
| 1893 | ||
| 1894 | static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
| 1895 | struct mwServiceAware *srvc; | |
| 1896 | srvc = mwServiceAware_new(s, &mw_aware_handler); | |
| 1897 | return srvc; | |
| 1898 | }; | |
| 1899 | ||
| 1900 | ||
| 1901 | static void mw_conf_invited(struct mwConference *conf, | |
| 1902 | struct mwLoginInfo *inviter, | |
| 1903 | const char *invitation) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1904 | |
| 10977 | 1905 | struct mwServiceConference *srvc; |
| 1906 | struct mwSession *session; | |
| 15884 | 1907 | struct mwPurplePluginData *pd; |
| 1908 | PurpleConnection *gc; | |
| 10977 | 1909 | |
| 1910 | char *c_inviter, *c_name, *c_topic, *c_invitation; | |
| 1911 | GHashTable *ht; | |
| 1912 | ||
| 1913 | srvc = mwConference_getService(conf); | |
| 1914 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1915 | pd = mwSession_getClientData(session); | |
| 1916 | gc = pd->gc; | |
| 1917 | ||
| 1918 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1919 | ||
| 1920 | c_inviter = g_strdup(inviter->user_id); | |
| 1921 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
| 1922 | ||
| 1923 | c_name = g_strdup(mwConference_getName(conf)); | |
| 1924 | g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
| 1925 | ||
| 1926 | c_topic = g_strdup(mwConference_getTitle(conf)); | |
| 1927 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
| 1928 | ||
| 1929 | c_invitation = g_strdup(invitation); | |
| 1930 | g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
| 1931 | ||
| 1932 | DEBUG_INFO("received invitation from '%s' to join ('%s','%s'): '%s'\n", | |
| 1933 | NSTR(c_inviter), NSTR(c_name), | |
| 1934 | NSTR(c_topic), NSTR(c_invitation)); | |
| 1935 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1936 | if(! c_topic) c_topic = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1937 | if(! c_invitation) c_invitation = "(no message)"; |
| 10977 | 1938 | serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
| 1939 | } | |
| 1940 | ||
| 1941 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1942 | /* The following mess helps us relate a mwConference to a PurpleChatConversation |
| 10977 | 1943 | in the various forms by which either may be indicated */ |
| 1944 | ||
| 1945 | #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
| 1946 | #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
| 1947 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1948 | #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
|
1949 | #define ID_TO_CHAT(id) (purple_conversations_find_chat(id)) |
| 10977 | 1950 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1951 | #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
|
1952 | #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
| 10977 | 1953 | |
| 1954 | ||
| 1955 | static struct mwConference * | |
| 15884 | 1956 | conf_find_by_id(struct mwPurplePluginData *pd, int id) { |
| 10977 | 1957 | |
| 1958 | struct mwServiceConference *srvc = pd->srvc_conf; | |
| 1959 | struct mwConference *conf = NULL; | |
| 1960 | GList *l, *ll; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1961 | |
| 10977 | 1962 | ll = mwServiceConference_getConferences(srvc); |
| 1963 | for(l = ll; l; l = l->next) { | |
| 1964 | 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
|
1965 | PurpleChatConversation *h = mwConference_getClientData(c); |
| 10977 | 1966 | |
| 1967 | if(CHAT_TO_ID(h) == id) { | |
| 1968 | conf = c; | |
| 1969 | break; | |
| 1970 | } | |
| 1971 | } | |
| 1972 | g_list_free(ll); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1973 | |
| 10977 | 1974 | return conf; |
| 1975 | } | |
| 1976 | ||
| 1977 | ||
| 1978 | static void mw_conf_opened(struct mwConference *conf, GList *members) { | |
| 1979 | struct mwServiceConference *srvc; | |
| 1980 | struct mwSession *session; | |
| 15884 | 1981 | struct mwPurplePluginData *pd; |
| 1982 | PurpleConnection *gc; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1983 | PurpleChatConversation *g_conf; |
| 10977 | 1984 | |
| 1985 | const char *n = mwConference_getName(conf); | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1986 | const char *t = mwConference_getTitle(conf); |
| 10977 | 1987 | |
| 1988 | DEBUG_INFO("conf %s opened, %u initial members\n", | |
| 1989 | NSTR(n), g_list_length(members)); | |
| 1990 | ||
| 1991 | srvc = mwConference_getService(conf); | |
| 1992 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1993 | pd = mwSession_getClientData(session); | |
| 1994 | gc = pd->gc; | |
| 1995 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1996 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1997 | g_conf = serv_got_joined_chat(gc, CONF_TO_ID(conf), t); |
| 10977 | 1998 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1999 | mwConference_setClientData(conf, g_conf, NULL); |
| 10977 | 2000 | |
| 2001 | for(; members; members = members->next) { | |
| 2002 | 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
|
2003 | 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
|
2004 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
| 10977 | 2005 | } |
| 2006 | } | |
| 2007 | ||
| 2008 | ||
| 2009 | static void mw_conf_closed(struct mwConference *conf, guint32 reason) { | |
| 2010 | struct mwServiceConference *srvc; | |
| 2011 | struct mwSession *session; | |
| 15884 | 2012 | struct mwPurplePluginData *pd; |
| 2013 | PurpleConnection *gc; | |
| 10977 | 2014 | |
| 2015 | const char *n = mwConference_getName(conf); | |
| 2016 | char *msg = mwError(reason); | |
| 2017 | ||
| 2018 | DEBUG_INFO("conf %s closed, 0x%08x\n", NSTR(n), reason); | |
| 2019 | ||
| 2020 | srvc = mwConference_getService(conf); | |
| 2021 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2022 | pd = mwSession_getClientData(session); | |
| 2023 | gc = pd->gc; | |
| 2024 | ||
| 2025 | serv_got_chat_left(gc, CONF_TO_ID(conf)); | |
| 2026 | ||
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2027 | purple_notify_error(gc, _("Conference Closed"), NULL, msg, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2028 | purple_request_cpar_from_connection(gc)); |
| 10977 | 2029 | g_free(msg); |
| 2030 | } | |
| 2031 | ||
| 2032 | ||
| 2033 | static void mw_conf_peer_joined(struct mwConference *conf, | |
| 2034 | struct mwLoginInfo *peer) { | |
| 2035 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2036 | PurpleChatConversation *g_conf; |
| 10977 | 2037 | |
| 2038 | const char *n = mwConference_getName(conf); | |
| 2039 | ||
| 2040 | DEBUG_INFO("%s joined conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2041 | ||
| 2042 | g_conf = mwConference_getClientData(conf); | |
| 2043 | g_return_if_fail(g_conf != NULL); | |
| 2044 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2045 | 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
|
2046 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
| 10977 | 2047 | } |
| 2048 | ||
| 2049 | ||
| 2050 | static void mw_conf_peer_parted(struct mwConference *conf, | |
| 2051 | struct mwLoginInfo *peer) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2052 | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2053 | PurpleChatConversation *g_conf; |
| 10977 | 2054 | |
| 2055 | const char *n = mwConference_getName(conf); | |
| 2056 | ||
| 2057 | DEBUG_INFO("%s left conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2058 | ||
| 2059 | g_conf = mwConference_getClientData(conf); | |
| 2060 | g_return_if_fail(g_conf != NULL); | |
| 2061 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2062 | purple_chat_conversation_remove_user(g_conf, peer->user_id, NULL); |
| 10977 | 2063 | } |
| 2064 | ||
| 2065 | ||
| 2066 | static void mw_conf_text(struct mwConference *conf, | |
| 2067 | struct mwLoginInfo *who, const char *text) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2068 | |
| 10977 | 2069 | struct mwServiceConference *srvc; |
| 2070 | struct mwSession *session; | |
| 15884 | 2071 | struct mwPurplePluginData *pd; |
| 2072 | PurpleConnection *gc; | |
| 10977 | 2073 | char *esc; |
| 2074 | ||
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2075 | if(! text) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2076 | |
| 10977 | 2077 | srvc = mwConference_getService(conf); |
| 2078 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2079 | pd = mwSession_getClientData(session); | |
| 2080 | gc = pd->gc; | |
| 2081 | ||
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2082 | esc = g_markup_escape_text(text, -1); |
| 10977 | 2083 | serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, 0, esc, time(NULL)); |
| 2084 | g_free(esc); | |
| 2085 | } | |
| 2086 | ||
| 2087 | ||
| 2088 | static void mw_conf_typing(struct mwConference *conf, | |
| 2089 | struct mwLoginInfo *who, gboolean typing) { | |
| 2090 | ||
| 15884 | 2091 | /* purple really has no good way to expose this to the user. */ |
| 10977 | 2092 | |
| 2093 | const char *n = mwConference_getName(conf); | |
| 2094 | const char *w = who->user_id; | |
| 2095 | ||
| 2096 | if(typing) { | |
| 2097 | DEBUG_INFO("%s in conf %s: <typing>\n", NSTR(w), NSTR(n)); | |
| 2098 | ||
| 2099 | } else { | |
| 2100 | DEBUG_INFO("%s in conf %s: <stopped typing>\n", NSTR(w), NSTR(n)); | |
| 2101 | } | |
| 2102 | } | |
| 2103 | ||
| 2104 | ||
| 2105 | static void mw_conf_clear(struct mwServiceConference *srvc) { | |
| 2106 | ; | |
| 2107 | } | |
| 2108 | ||
| 2109 | ||
| 2110 | static struct mwConferenceHandler mw_conference_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2111 | mw_conf_invited, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2112 | mw_conf_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2113 | mw_conf_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2114 | mw_conf_peer_joined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2115 | mw_conf_peer_parted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2116 | mw_conf_text, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2117 | mw_conf_typing, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2118 | mw_conf_clear, |
| 10977 | 2119 | }; |
| 2120 | ||
| 2121 | ||
| 2122 | static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) { | |
| 2123 | struct mwServiceConference *srvc; | |
| 2124 | srvc = mwServiceConference_new(s, &mw_conference_handler); | |
| 2125 | return srvc; | |
| 2126 | } | |
| 2127 | ||
| 2128 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2129 | /** size of an outgoing file transfer chunk */ |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2130 | #define MW_FT_LEN (BUF_LONG * 2) |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2131 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2132 | |
| 15884 | 2133 | static void ft_incoming_cancel(PurpleXfer *xfer) { |
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29304
diff
changeset
|
2134 | /* 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
|
2135 | struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
| 10977 | 2136 | if(ft) mwFileTransfer_reject(ft); |
| 2137 | } | |
| 2138 | ||
| 2139 | ||
| 15884 | 2140 | static void ft_incoming_init(PurpleXfer *xfer) { |
| 10977 | 2141 | /* incoming transfer accepted */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2142 | |
| 10977 | 2143 | /* - accept the mwFileTransfer |
| 2144 | - open/create the local FILE "wb" | |
| 2145 | - stick the FILE's fp in xfer->dest_fp | |
| 2146 | */ | |
| 2147 | ||
| 2148 | struct mwFileTransfer *ft; | |
| 2149 | ||
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2150 | ft = purple_xfer_get_protocol_data(xfer); |
| 10977 | 2151 | |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2152 | purple_xfer_start(xfer, -1, NULL, 0); |
| 10977 | 2153 | mwFileTransfer_accept(ft); |
| 2154 | } | |
| 2155 | ||
| 2156 | ||
| 2157 | static void mw_ft_offered(struct mwFileTransfer *ft) { | |
| 2158 | /* | |
| 15884 | 2159 | - create a purple ft object |
| 10977 | 2160 | - offer it |
| 2161 | */ | |
| 2162 | ||
| 2163 | struct mwServiceFileTransfer *srvc; | |
| 2164 | struct mwSession *session; | |
| 15884 | 2165 | struct mwPurplePluginData *pd; |
| 2166 | PurpleConnection *gc; | |
| 2167 | PurpleAccount *acct; | |
| 10977 | 2168 | const char *who; |
| 15884 | 2169 | PurpleXfer *xfer; |
| 10977 | 2170 | |
| 2171 | /* @todo add some safety checks */ | |
| 2172 | srvc = mwFileTransfer_getService(ft); | |
| 2173 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2174 | pd = mwSession_getClientData(session); | |
| 2175 | gc = pd->gc; | |
| 15884 | 2176 | acct = purple_connection_get_account(gc); |
| 10977 | 2177 | |
| 2178 | who = mwFileTransfer_getUser(ft)->user; | |
| 2179 | ||
| 2180 | DEBUG_INFO("file transfer %p offered\n", ft); | |
| 2181 | DEBUG_INFO(" from: %s\n", NSTR(who)); | |
| 2182 | DEBUG_INFO(" file: %s\n", NSTR(mwFileTransfer_getFileName(ft))); | |
| 2183 | DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft)); | |
| 2184 | DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft))); | |
| 2185 | ||
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34920
diff
changeset
|
2186 | xfer = purple_xfer_new(acct, PURPLE_XFER_TYPE_RECEIVE, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2187 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2188 | { |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
2189 | g_object_ref(xfer); |
|
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
2190 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) g_object_unref); |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2191 | purple_xfer_set_protocol_data(xfer, ft); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2192 | |
| 15884 | 2193 | purple_xfer_set_init_fnc(xfer, ft_incoming_init); |
| 2194 | purple_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); | |
| 2195 | purple_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); | |
| 2196 | ||
| 2197 | purple_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); | |
| 2198 | purple_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); | |
| 2199 | purple_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); | |
| 2200 | ||
| 2201 | purple_xfer_request(xfer); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2202 | } |
| 10977 | 2203 | } |
| 2204 | ||
| 2205 | ||
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2206 | static void ft_send(struct mwFileTransfer *ft) { |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2207 | 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
|
2208 | struct mwOpaque o = { MW_FT_LEN, buf }; |
| 10977 | 2209 | guint32 rem; |
| 15884 | 2210 | PurpleXfer *xfer; |
| 10977 | 2211 | |
| 2212 | xfer = mwFileTransfer_getClientData(ft); | |
| 2213 | ||
| 2214 | rem = mwFileTransfer_getRemaining(ft); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2215 | if(rem < MW_FT_LEN) o.len = rem; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2216 | |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2217 | if(purple_xfer_read_file(xfer, buf, (size_t) o.len) > 0) { |
| 10977 | 2218 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2219 | /* calculate progress and display it */ |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2220 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + o.len); |
| 15884 | 2221 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2222 | |
| 10977 | 2223 | mwFileTransfer_send(ft, &o); |
| 2224 | ||
| 2225 | } else { | |
| 2226 | int err = errno; | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2227 | DEBUG_WARN("problem reading from file %s: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20288
diff
changeset
|
2228 | NSTR(mwFileTransfer_getFileName(ft)), g_strerror(err)); |
| 10977 | 2229 | |
| 2230 | mwFileTransfer_cancel(ft); | |
| 2231 | } | |
| 2232 | } | |
| 2233 | ||
| 2234 | ||
| 2235 | static void mw_ft_opened(struct mwFileTransfer *ft) { | |
| 2236 | /* | |
| 15884 | 2237 | - get purple ft from client data in ft |
| 10977 | 2238 | - set the state to active |
| 2239 | */ | |
| 2240 | ||
| 15884 | 2241 | PurpleXfer *xfer; |
| 10977 | 2242 | |
| 2243 | xfer = mwFileTransfer_getClientData(ft); | |
| 2244 | ||
| 2245 | if(! xfer) { | |
| 2246 | mwFileTransfer_cancel(ft); | |
| 2247 | mwFileTransfer_free(ft); | |
| 2248 | g_return_if_reached(); | |
| 2249 | } | |
| 2250 | ||
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34920
diff
changeset
|
2251 | if(purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND) { |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2252 | purple_xfer_start(xfer, -1, NULL, 0); |
|
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2253 | ft_send(ft); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2254 | } |
| 10977 | 2255 | } |
| 2256 | ||
| 2257 | ||
| 2258 | static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
| 2259 | /* | |
| 15884 | 2260 | - get purple ft from client data in ft |
| 10977 | 2261 | - indicate rejection/cancelation/completion |
| 2262 | - free the file transfer itself | |
| 2263 | */ | |
| 2264 | ||
| 15884 | 2265 | PurpleXfer *xfer; |
| 10977 | 2266 | |
| 2267 | xfer = mwFileTransfer_getClientData(ft); | |
| 2268 | if(xfer) { | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2269 | purple_xfer_set_protocol_data(xfer, NULL); |
| 10977 | 2270 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2271 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2272 | purple_xfer_set_completed(xfer, TRUE); |
| 2273 | purple_xfer_end(xfer); | |
| 10977 | 2274 | |
| 2275 | } else if(mwFileTransfer_isCancelLocal(ft)) { | |
| 15884 | 2276 | /* calling purple_xfer_cancel_local is redundant, since that's |
| 10977 | 2277 | probably what triggered this function to be called */ |
| 2278 | ; | |
| 2279 | ||
| 2280 | } else if(mwFileTransfer_isCancelRemote(ft)) { | |
| 2281 | /* steal the reference for the xfer */ | |
| 2282 | mwFileTransfer_setClientData(ft, NULL, NULL); | |
| 15884 | 2283 | purple_xfer_cancel_remote(xfer); |
| 10977 | 2284 | |
| 2285 | /* drop the stolen reference */ | |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
2286 | g_object_unref(xfer); |
| 10977 | 2287 | return; |
| 2288 | } | |
| 2289 | } | |
| 2290 | ||
| 2291 | mwFileTransfer_free(ft); | |
| 2292 | } | |
| 2293 | ||
| 2294 | ||
| 2295 | static void mw_ft_recv(struct mwFileTransfer *ft, | |
| 2296 | struct mwOpaque *data) { | |
| 2297 | /* | |
| 15884 | 2298 | - get purple ft from client data in ft |
| 10977 | 2299 | - update transfered percentage |
| 15884 | 2300 | - if done, destroy the ft, disassociate from purple ft |
| 10977 | 2301 | */ |
| 2302 | ||
| 15884 | 2303 | PurpleXfer *xfer; |
| 10977 | 2304 | |
| 2305 | xfer = mwFileTransfer_getClientData(ft); | |
| 2306 | g_return_if_fail(xfer != NULL); | |
| 2307 | ||
| 2308 | /* we must collect and save our precious data */ | |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2309 | if (!purple_xfer_write_file(xfer, data->data, data->len)) { |
|
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 | 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
|
2311 | 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
|
2312 | return; |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2313 | } |
| 10977 | 2314 | |
| 2315 | /* update the progress */ | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2316 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + data->len); |
| 15884 | 2317 | purple_xfer_update_progress(xfer); |
| 10977 | 2318 | |
| 2319 | /* let the other side know we got it, and to send some more */ | |
| 2320 | mwFileTransfer_ack(ft); | |
| 2321 | } | |
| 2322 | ||
| 2323 | ||
| 2324 | static void mw_ft_ack(struct mwFileTransfer *ft) { | |
| 15884 | 2325 | PurpleXfer *xfer; |
| 10977 | 2326 | |
| 2327 | xfer = mwFileTransfer_getClientData(ft); | |
| 2328 | g_return_if_fail(xfer != NULL); | |
|
32705
9d97ac4c2c22
Sametime: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents:
32698
diff
changeset
|
2329 | g_return_if_fail(purple_xfer_get_watcher(xfer) == 0); |
| 10977 | 2330 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2331 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2332 | purple_xfer_set_completed(xfer, TRUE); |
| 2333 | purple_xfer_end(xfer); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2334 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2335 | } else if(mwFileTransfer_isOpen(ft)) { |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2336 | ft_send(ft); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2337 | } |
| 10977 | 2338 | } |
| 2339 | ||
| 2340 | ||
| 2341 | static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
| 2342 | ; | |
| 2343 | } | |
| 2344 | ||
| 2345 | ||
| 2346 | static struct mwFileTransferHandler mw_ft_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2347 | mw_ft_offered, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2348 | mw_ft_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2349 | mw_ft_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2350 | mw_ft_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2351 | mw_ft_ack, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2352 | mw_ft_clear, |
| 10977 | 2353 | }; |
| 2354 | ||
| 2355 | ||
| 2356 | static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
| 2357 | struct mwServiceFileTransfer *srvc; | |
| 2358 | GHashTable *ft_map; | |
| 2359 | ||
| 2360 | ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 2361 | ||
| 2362 | srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
| 2363 | mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
| 2364 | (GDestroyNotify) g_hash_table_destroy); | |
| 2365 | ||
| 2366 | return srvc; | |
| 2367 | } | |
| 2368 | ||
| 2369 | ||
| 2370 | static void convo_data_free(struct convo_data *cd) { | |
| 2371 | GList *l; | |
| 2372 | ||
| 2373 | /* clean the queue */ | |
| 2374 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2375 | struct convo_msg *m = l->data; | |
| 2376 | if(m->clear) m->clear(m->data); | |
| 2377 | g_free(m); | |
| 2378 | } | |
| 2379 | ||
| 2380 | g_free(cd); | |
| 2381 | } | |
| 2382 | ||
| 2383 | ||
| 2384 | /** allocates a convo_data structure and associates it with the | |
| 2385 | conversation in the client data slot */ | |
| 2386 | static void convo_data_new(struct mwConversation *conv) { | |
| 2387 | struct convo_data *cd; | |
| 2388 | ||
| 2389 | g_return_if_fail(conv != NULL); | |
| 2390 | ||
| 2391 | if(mwConversation_getClientData(conv)) | |
| 2392 | return; | |
| 2393 | ||
| 2394 | cd = g_new0(struct convo_data, 1); | |
| 2395 | cd->conv = conv; | |
| 2396 | ||
| 2397 | mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
| 2398 | } | |
| 2399 | ||
| 2400 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2401 | static PurpleIMConversation *convo_get_im(struct mwConversation *conv) { |
| 10977 | 2402 | struct mwServiceIm *srvc; |
| 2403 | struct mwSession *session; | |
| 15884 | 2404 | struct mwPurplePluginData *pd; |
| 2405 | PurpleConnection *gc; | |
| 2406 | PurpleAccount *acct; | |
| 10977 | 2407 | |
| 2408 | struct mwIdBlock *idb; | |
| 2409 | ||
| 2410 | srvc = mwConversation_getService(conv); | |
| 2411 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2412 | pd = mwSession_getClientData(session); | |
| 2413 | gc = pd->gc; | |
| 15884 | 2414 | acct = purple_connection_get_account(gc); |
| 10977 | 2415 | |
| 2416 | idb = mwConversation_getTarget(conv); | |
| 2417 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2418 | return purple_conversations_find_im_with_account(idb->user, acct); |
| 10977 | 2419 | } |
| 2420 | ||
| 2421 | ||
| 2422 | static void convo_queue(struct mwConversation *conv, | |
| 2423 | enum mwImSendType type, gconstpointer data) { | |
| 2424 | ||
| 2425 | struct convo_data *cd; | |
| 2426 | struct convo_msg *m; | |
| 2427 | ||
| 2428 | convo_data_new(conv); | |
| 2429 | cd = mwConversation_getClientData(conv); | |
| 2430 | ||
| 2431 | m = g_new0(struct convo_msg, 1); | |
| 2432 | m->type = type; | |
| 2433 | ||
| 2434 | switch(type) { | |
| 2435 | case mwImSend_PLAIN: | |
| 2436 | m->data = g_strdup(data); | |
| 2437 | m->clear = g_free; | |
| 2438 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2439 | |
| 10977 | 2440 | case mwImSend_TYPING: |
| 2441 | default: | |
| 2442 | m->data = (gpointer) data; | |
| 2443 | m->clear = NULL; | |
| 2444 | } | |
| 2445 | ||
| 2446 | cd->queue = g_list_append(cd->queue, m); | |
| 2447 | } | |
| 2448 | ||
| 2449 | ||
| 2450 | /* Does what it takes to get an error displayed for a conversation */ | |
| 2451 | 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
|
2452 | PurpleIMConversation *im; |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2453 | PurpleConnection *pc; |
| 10977 | 2454 | char *tmp, *text; |
| 2455 | struct mwIdBlock *idb; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2456 | |
| 10977 | 2457 | idb = mwConversation_getTarget(conv); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2458 | |
| 10977 | 2459 | tmp = mwError(err); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2460 | text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2461 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2462 | 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
|
2463 | 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
|
2464 | purple_conversation_get_account(PURPLE_CONVERSATION(im)), text)) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2465 | |
| 10977 | 2466 | g_free(text); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2467 | text = g_strdup_printf(_("Unable to send message to %s:"), |
| 10977 | 2468 | (idb->user)? idb->user: "(unknown)"); |
| 34955 | 2469 | pc = purple_account_get_connection(purple_conversation_get_account( |
| 2470 | PURPLE_CONVERSATION(im))); | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2471 | purple_notify_error(pc, NULL, text, tmp, purple_request_cpar_from_connection(pc)); |
| 10977 | 2472 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2473 | |
| 10977 | 2474 | g_free(tmp); |
| 2475 | g_free(text); | |
| 2476 | } | |
| 2477 | ||
| 2478 | ||
| 2479 | static void convo_queue_send(struct mwConversation *conv) { | |
| 2480 | struct convo_data *cd; | |
| 2481 | GList *l; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2482 | |
| 10977 | 2483 | cd = mwConversation_getClientData(conv); |
| 2484 | ||
| 2485 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2486 | struct convo_msg *m = l->data; | |
| 2487 | ||
| 2488 | mwConversation_send(conv, m->type, m->data); | |
| 2489 | ||
| 2490 | if(m->clear) m->clear(m->data); | |
| 2491 | g_free(m); | |
| 2492 | } | |
| 2493 | ||
| 2494 | cd->queue = NULL; | |
| 2495 | } | |
| 2496 | ||
| 2497 | ||
| 15884 | 2498 | /** called when a mw conversation leaves a purple conversation to |
| 2499 | inform the purple conversation that it's unsafe to offer any *cool* | |
| 10977 | 2500 | features. */ |
| 2501 | 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
|
2502 | PurpleIMConversation *im; |
| 15884 | 2503 | PurpleConnection *gc; |
| 10977 | 2504 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2505 | 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
|
2506 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2507 | |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2508 | gc = purple_conversation_get_connection(PURPLE_CONVERSATION(im)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2509 | if(! gc) return; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2510 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2511 | 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
|
2512 | purple_connection_get_flags(gc)); |
| 15884 | 2513 | } |
| 2514 | ||
| 2515 | ||
| 2516 | /** called when a mw conversation and purple conversation come together, | |
| 2517 | to inform the purple conversation of what features to offer the | |
| 10977 | 2518 | user */ |
| 2519 | 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
|
2520 | PurpleIMConversation *im; |
| 15884 | 2521 | PurpleConnectionFlags feat; |
| 10977 | 2522 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2523 | 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
|
2524 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2525 | |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2526 | feat = purple_conversation_get_features(PURPLE_CONVERSATION(im)); |
| 10977 | 2527 | |
| 2528 | if(mwConversation_isOpen(conv)) { | |
| 2529 | if(mwConversation_supports(conv, mwImSend_HTML)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2530 | feat |= PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2531 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2532 | feat &= ~PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2533 | } |
| 2534 | ||
| 2535 | if(mwConversation_supports(conv, mwImSend_MIME)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2536 | feat &= ~PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2537 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2538 | feat |= PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2539 | } |
| 2540 | ||
| 2541 | 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
|
2542 | purple_conversation_set_features(PURPLE_CONVERSATION(im), feat); |
| 10977 | 2543 | |
| 2544 | } else { | |
| 2545 | convo_nofeatures(conv); | |
| 2546 | } | |
| 2547 | } | |
| 2548 | ||
| 2549 | ||
| 2550 | static void mw_conversation_opened(struct mwConversation *conv) { | |
| 2551 | struct mwServiceIm *srvc; | |
| 2552 | struct mwSession *session; | |
| 15884 | 2553 | struct mwPurplePluginData *pd; |
| 2554 | PurpleConnection *gc; | |
| 2555 | PurpleAccount *acct; | |
| 10977 | 2556 | |
| 2557 | struct convo_dat *cd; | |
| 2558 | ||
| 2559 | srvc = mwConversation_getService(conv); | |
| 2560 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2561 | pd = mwSession_getClientData(session); | |
| 2562 | gc = pd->gc; | |
| 15884 | 2563 | acct = purple_connection_get_account(gc); |
| 10977 | 2564 | |
| 2565 | /* set up the queue */ | |
| 2566 | cd = mwConversation_getClientData(conv); | |
| 2567 | if(cd) { | |
| 2568 | convo_queue_send(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2569 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2570 | if(! convo_get_im(conv)) { |
| 10977 | 2571 | mwConversation_free(conv); |
| 2572 | return; | |
| 2573 | } | |
| 2574 | ||
| 2575 | } else { | |
| 2576 | convo_data_new(conv); | |
| 2577 | } | |
| 2578 | ||
| 2579 | { /* record the client key for the buddy */ | |
| 15884 | 2580 | PurpleBuddy *buddy; |
| 10977 | 2581 | struct mwLoginInfo *info; |
| 2582 | info = mwConversation_getTargetInfo(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2583 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
2584 | buddy = purple_blist_find_buddy(acct, info->user_id); |
| 10977 | 2585 | if(buddy) { |
| 15884 | 2586 | purple_blist_node_set_int((PurpleBlistNode *) buddy, |
| 10977 | 2587 | BUDDY_KEY_CLIENT, info->type); |
| 2588 | } | |
| 2589 | } | |
| 2590 | ||
| 2591 | convo_features(conv); | |
| 2592 | } | |
| 2593 | ||
| 2594 | ||
| 2595 | static void mw_conversation_closed(struct mwConversation *conv, | |
| 2596 | guint32 reason) { | |
| 2597 | ||
| 2598 | struct convo_data *cd; | |
| 2599 | ||
| 2600 | g_return_if_fail(conv != NULL); | |
| 2601 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2602 | /* 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
|
2603 | print an error message to the conversation */ |
| 10977 | 2604 | cd = mwConversation_getClientData(conv); |
| 2605 | if(reason && cd && cd->queue) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2606 | GList *l; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2607 | for(l = cd->queue; l; l = l->next) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2608 | struct convo_msg *m = l->data; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2609 | if(m->type != mwImSend_TYPING) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2610 | convo_error(conv, reason); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2611 | break; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2612 | } |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2613 | } |
| 10977 | 2614 | } |
| 2615 | ||
| 2616 | #if 0 | |
| 2617 | /* don't do this, to prevent the occasional weird sending of | |
| 2618 | formatted messages as plaintext when the other end closes the | |
| 2619 | conversation after we've begun composing the message */ | |
| 2620 | convo_nofeatures(conv); | |
| 2621 | #endif | |
| 2622 | ||
| 2623 | mwConversation_removeClientData(conv); | |
| 2624 | } | |
| 2625 | ||
| 2626 | ||
| 2627 | static void im_recv_text(struct mwConversation *conv, | |
| 15884 | 2628 | struct mwPurplePluginData *pd, |
| 10977 | 2629 | const char *msg) { |
| 2630 | ||
| 2631 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2632 | char *txt, *esc; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2633 | const char *t; |
| 10977 | 2634 | |
| 2635 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2636 | |
| 15884 | 2637 | txt = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2638 | t = txt? txt: msg; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2639 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2640 | esc = g_markup_escape_text(t, -1); |
| 10977 | 2641 | 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
|
2642 | g_free(esc); |
| 10977 | 2643 | |
| 2644 | g_free(txt); | |
| 2645 | } | |
| 2646 | ||
| 2647 | ||
| 2648 | static void im_recv_typing(struct mwConversation *conv, | |
| 15884 | 2649 | struct mwPurplePluginData *pd, |
| 10977 | 2650 | gboolean typing) { |
| 2651 | ||
| 2652 | struct mwIdBlock *idb; | |
| 2653 | idb = mwConversation_getTarget(conv); | |
| 2654 | ||
| 2655 | 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
|
2656 | typing? PURPLE_IM_TYPING: PURPLE_IM_NOT_TYPING); |
| 10977 | 2657 | } |
| 2658 | ||
| 2659 | ||
| 2660 | static void im_recv_html(struct mwConversation *conv, | |
| 15884 | 2661 | struct mwPurplePluginData *pd, |
| 10977 | 2662 | const char *msg) { |
| 2663 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2664 | char *t1, *t2; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2665 | const char *t; |
| 10977 | 2666 | |
| 2667 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2668 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2669 | /* ensure we're receiving UTF8 */ |
| 15884 | 2670 | t1 = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2671 | t = t1? t1: msg; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2672 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2673 | /* convert entities to UTF8 so they'll log correctly */ |
| 15884 | 2674 | t2 = purple_utf8_ncr_decode(t); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2675 | t = t2? t2: t; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2676 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2677 | serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
| 10977 | 2678 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2679 | g_free(t1); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2680 | g_free(t2); |
| 10977 | 2681 | } |
| 2682 | ||
| 2683 | ||
| 2684 | static void im_recv_subj(struct mwConversation *conv, | |
| 15884 | 2685 | struct mwPurplePluginData *pd, |
| 10977 | 2686 | const char *subj) { |
| 2687 | ||
| 2688 | /** @todo somehow indicate receipt of a conversation subject. It | |
| 2689 | would also be nice if we added a /topic command for the | |
| 2690 | protocol */ | |
| 2691 | ; | |
| 2692 | } | |
| 2693 | ||
| 2694 | ||
| 2695 | /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */ | |
| 2696 | static char *make_cid(const char *cid) { | |
| 2697 | gsize n; | |
| 2698 | char *c, *d; | |
| 2699 | ||
| 2700 | g_return_val_if_fail(cid != NULL, NULL); | |
| 2701 | ||
| 2702 | n = strlen(cid); | |
| 2703 | g_return_val_if_fail(n > 2, NULL); | |
| 2704 | ||
| 2705 | c = g_strndup(cid+1, n-2); | |
| 2706 | d = g_strdup_printf("cid:%s", c); | |
| 2707 | ||
| 2708 | g_free(c); | |
| 2709 | return d; | |
| 2710 | } | |
| 2711 | ||
| 2712 | ||
| 2713 | static void im_recv_mime(struct mwConversation *conv, | |
| 15884 | 2714 | struct mwPurplePluginData *pd, |
| 10977 | 2715 | const char *data) { |
| 2716 | ||
| 2717 | GHashTable *img_by_cid; | |
| 2718 | GList *images; | |
| 2719 | ||
| 2720 | GString *str; | |
| 2721 | ||
| 15884 | 2722 | 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
|
2723 | GList *parts; |
| 10977 | 2724 | |
| 2725 | img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
| 2726 | images = NULL; | |
| 2727 | ||
| 2728 | /* don't want the contained string to ever be NULL */ | |
| 2729 | str = g_string_new(""); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2730 | |
| 15884 | 2731 | doc = purple_mime_document_parse(data); |
| 10977 | 2732 | |
| 2733 | /* handle all the MIME parts */ | |
| 15884 | 2734 | parts = purple_mime_document_get_parts(doc); |
| 10977 | 2735 | for(; parts; parts = parts->next) { |
| 15884 | 2736 | PurpleMimePart *part = parts->data; |
| 10977 | 2737 | const char *type; |
| 2738 | ||
| 15884 | 2739 | type = purple_mime_part_get_field(part, "content-type"); |
| 10977 | 2740 | DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type)); |
| 2741 | ||
| 2742 | if(! type) { | |
| 2743 | ; /* feh */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2744 | |
| 15884 | 2745 | } else if(purple_str_has_prefix(type, "image")) { |
| 10977 | 2746 | /* put images into the image store */ |
| 2747 | ||
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2748 | guchar *d_dat; |
| 10977 | 2749 | gsize d_len; |
| 2750 | char *cid; | |
| 2751 | int img; | |
| 2752 | ||
| 2753 | /* obtain and unencode the data */ | |
| 15884 | 2754 | 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
|
2755 | |
| 10977 | 2756 | /* look up the content id */ |
| 15884 | 2757 | cid = (char *) purple_mime_part_get_field(part, "Content-ID"); |
| 10977 | 2758 | cid = make_cid(cid); |
| 2759 | ||
| 15884 | 2760 | /* 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
|
2761 | /* 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
|
2762 | 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
|
2763 | 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
|
2764 | 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
|
2765 | 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
|
2766 | 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
|
2767 | 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
|
2768 | this PRPL. */ |
| 33661 | 2769 | img = purple_imgstore_new_with_id(d_dat, d_len, cid); |
| 10977 | 2770 | |
| 2771 | /* map the cid to the image store identifier */ | |
| 2772 | g_hash_table_insert(img_by_cid, cid, GINT_TO_POINTER(img)); | |
| 2773 | ||
| 2774 | /* recall the image for dereferencing later */ | |
| 2775 | images = g_list_append(images, GINT_TO_POINTER(img)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2776 | |
| 15884 | 2777 | } else if(purple_str_has_prefix(type, "text")) { |
| 10977 | 2778 | |
| 2779 | /* concatenate all the text parts together */ | |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2780 | guchar *data; |
| 10977 | 2781 | gsize len; |
| 2782 | ||
| 15884 | 2783 | purple_mime_part_get_data_decoded(part, &data, &len); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2784 | g_string_append(str, (const char *)data); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2785 | g_free(data); |
| 10977 | 2786 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2787 | } |
| 10977 | 2788 | |
| 15884 | 2789 | purple_mime_document_free(doc); |
| 10977 | 2790 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2791 | /* @todo should put this in its own function */ |
| 10977 | 2792 | { /* replace each IMG tag's SRC attribute with an ID attribute. This |
| 2793 | actually modifies the contents of str */ | |
| 2794 | GData *attribs; | |
| 2795 | char *start, *end; | |
| 2796 | char *tmp = str->str; | |
| 2797 | ||
| 15884 | 2798 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 2799 | (const char **) &end, &attribs)) { |
| 2800 | ||
| 2801 | char *alt, *align, *border, *src; | |
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2802 | int img = 0; |
| 10977 | 2803 | |
| 2804 | alt = g_datalist_get_data(&attribs, "alt"); | |
| 2805 | align = g_datalist_get_data(&attribs, "align"); | |
| 2806 | border = g_datalist_get_data(&attribs, "border"); | |
| 2807 | src = g_datalist_get_data(&attribs, "src"); | |
| 2808 | ||
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2809 | if(src) |
|
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2810 | 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
|
2811 | |
| 10977 | 2812 | if(img) { |
| 2813 | GString *atstr; | |
| 2814 | gsize len = (end - start); | |
| 2815 | gsize mov; | |
| 2816 | ||
| 2817 | atstr = g_string_new(""); | |
| 2818 | if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt); | |
| 2819 | if(align) g_string_append_printf(atstr, " align=\"%s\"", align); | |
| 2820 | if(border) g_string_append_printf(atstr, " border=\"%s\"", border); | |
| 2821 | ||
|
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
|
2822 | mov = g_snprintf(start, len, "<img%s src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%i\"", atstr->str, img); |
| 10977 | 2823 | while(mov < len) start[mov++] = ' '; |
| 2824 | ||
| 2825 | g_string_free(atstr, TRUE); | |
| 2826 | } | |
| 2827 | ||
| 2828 | g_datalist_clear(&attribs); | |
| 2829 | tmp = end + 1; | |
| 2830 | } | |
| 2831 | } | |
| 2832 | ||
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2833 | im_recv_html(conv, pd, str->str); |
| 10977 | 2834 | |
| 2835 | g_string_free(str, TRUE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2836 | |
| 10977 | 2837 | /* clean up the cid table */ |
| 2838 | g_hash_table_destroy(img_by_cid); | |
| 2839 | ||
| 2840 | /* dereference all the imgages */ | |
| 2841 | 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
|
2842 | purple_imgstore_unref_by_id(GPOINTER_TO_INT(images->data)); |
| 10977 | 2843 | images = g_list_delete_link(images, images); |
| 2844 | } | |
| 2845 | } | |
| 2846 | ||
| 2847 | ||
| 2848 | static void mw_conversation_recv(struct mwConversation *conv, | |
| 2849 | enum mwImSendType type, | |
| 2850 | gconstpointer msg) { | |
| 2851 | struct mwServiceIm *srvc; | |
| 2852 | struct mwSession *session; | |
| 15884 | 2853 | struct mwPurplePluginData *pd; |
| 10977 | 2854 | |
| 2855 | srvc = mwConversation_getService(conv); | |
| 2856 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2857 | pd = mwSession_getClientData(session); | |
| 2858 | ||
| 2859 | switch(type) { | |
| 2860 | case mwImSend_PLAIN: | |
| 2861 | im_recv_text(conv, pd, msg); | |
| 2862 | break; | |
| 2863 | ||
| 2864 | case mwImSend_TYPING: | |
| 2865 | im_recv_typing(conv, pd, !! msg); | |
| 2866 | break; | |
| 2867 | ||
| 2868 | case mwImSend_HTML: | |
| 2869 | im_recv_html(conv, pd, msg); | |
| 2870 | break; | |
| 2871 | ||
| 2872 | case mwImSend_SUBJECT: | |
| 2873 | im_recv_subj(conv, pd, msg); | |
| 2874 | break; | |
| 2875 | ||
| 2876 | case mwImSend_MIME: | |
| 2877 | im_recv_mime(conv, pd, msg); | |
| 2878 | break; | |
| 2879 | ||
| 2880 | default: | |
| 2881 | DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
| 2882 | ; /* erm... */ | |
| 2883 | } | |
| 2884 | } | |
| 2885 | ||
| 2886 | ||
| 2887 | static void mw_place_invite(struct mwConversation *conv, | |
| 2888 | const char *message, | |
| 2889 | const char *title, const char *name) { | |
| 2890 | struct mwServiceIm *srvc; | |
| 2891 | struct mwSession *session; | |
| 15884 | 2892 | struct mwPurplePluginData *pd; |
| 10977 | 2893 | |
| 2894 | struct mwIdBlock *idb; | |
| 2895 | GHashTable *ht; | |
| 2896 | ||
| 2897 | srvc = mwConversation_getService(conv); | |
| 2898 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2899 | pd = mwSession_getClientData(session); | |
| 2900 | ||
| 2901 | idb = mwConversation_getTarget(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2902 | |
| 10977 | 2903 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 2904 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
| 2905 | g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
| 2906 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
| 2907 | 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
|
2908 | g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
| 10977 | 2909 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2910 | if(! title) title = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2911 | if(! message) message = "(no message)"; |
| 10977 | 2912 | 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
|
2913 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2914 | mwConversation_close(conv, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2915 | mwConversation_free(conv); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2916 | } |
| 10977 | 2917 | |
| 2918 | ||
| 2919 | static void mw_im_clear(struct mwServiceIm *srvc) { | |
| 2920 | ; | |
| 2921 | } | |
| 2922 | ||
| 2923 | ||
| 2924 | static struct mwImHandler mw_im_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2925 | mw_conversation_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2926 | mw_conversation_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2927 | mw_conversation_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2928 | mw_place_invite, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2929 | mw_im_clear, |
| 10977 | 2930 | }; |
| 2931 | ||
| 2932 | ||
| 2933 | static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
| 2934 | struct mwServiceIm *srvc; | |
| 2935 | srvc = mwServiceIm_new(s, &mw_im_handler); | |
| 2936 | mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
| 2937 | return srvc; | |
| 2938 | } | |
| 2939 | ||
| 2940 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2941 | /* 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
|
2942 | 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
|
2943 | the similar macros from the conference service above */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2944 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2945 | #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2946 | #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
|
2947 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2948 | #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
|
2949 | #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
|
2950 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2951 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2952 | static struct mwPlace * |
| 15884 | 2953 | place_find_by_id(struct mwPurplePluginData *pd, int id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2954 | struct mwServicePlace *srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2955 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2956 | GList *l; |
|
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 | l = (GList *) mwServicePlace_getPlaces(srvc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2959 | for(; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2960 | 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
|
2961 | PurpleChatConversation *h = mwPlace_getClientData(p); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2962 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2963 | if(CHAT_TO_ID(h) == id) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2964 | place = p; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2965 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2966 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2967 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2968 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2969 | return place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2970 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2971 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2972 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2973 | static void mw_place_opened(struct mwPlace *place) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2974 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2975 | struct mwSession *session; |
| 15884 | 2976 | struct mwPurplePluginData *pd; |
| 2977 | PurpleConnection *gc; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2978 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2979 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2980 | GList *members, *l; |
|
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 | const char *n = mwPlace_getName(place); |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2983 | const char *t = mwPlace_getTitle(place); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2984 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2985 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2986 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2987 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2988 | gc = pd->gc; |
|
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 | members = mwPlace_getMembers(place); |
|
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 | DEBUG_INFO("place %s opened, %u initial members\n", |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2993 | NSTR(n), g_list_length(members)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2994 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2995 | if(! t) t = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2996 | 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
|
2997 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2998 | mwPlace_setClientData(place, gconf, NULL); |
|
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 | for(l = members; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3001 | 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
|
3002 | 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
|
3003 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3004 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3005 | g_list_free(members); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3006 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3007 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3008 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3009 | static void mw_place_closed(struct mwPlace *place, guint32 code) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3010 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3011 | struct mwSession *session; |
| 15884 | 3012 | struct mwPurplePluginData *pd; |
| 3013 | PurpleConnection *gc; | |
|
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 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3016 | char *msg = mwError(code); |
|
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 | 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
|
3019 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3020 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3021 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3022 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3023 | gc = pd->gc; |
|
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 | serv_got_chat_left(gc, PLACE_TO_ID(place)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3026 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
3027 | purple_notify_error(gc, _("Place Closed"), NULL, msg, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
3028 | purple_request_cpar_from_connection(gc)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3029 | g_free(msg); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3030 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3031 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3032 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3033 | static void mw_place_peerJoined(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3034 | 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
|
3035 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3036 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3037 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3038 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3039 | 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
|
3040 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3041 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3042 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3043 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3044 | 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
|
3045 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3046 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3047 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3048 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3049 | static void mw_place_peerParted(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3050 | 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
|
3051 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3052 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3053 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3054 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3055 | 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
|
3056 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3057 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3058 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3059 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3060 | purple_chat_conversation_remove_user(gconf, peer->user, NULL); |
|
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 | |
|
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 | static void mw_place_peerSetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3065 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3066 | guint32 attr, struct mwOpaque *o) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3067 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3068 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3069 | |
|
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 | static void mw_place_peerUnsetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3072 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3073 | guint32 attr) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3074 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3075 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3076 | |
|
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 | static void mw_place_message(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3079 | const struct mwIdBlock *who, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3080 | const char *msg) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3081 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3082 | struct mwSession *session; |
| 15884 | 3083 | struct mwPurplePluginData *pd; |
| 3084 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3085 | char *esc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3086 | |
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3087 | if(! msg) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3088 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3089 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3090 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3091 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3092 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3093 | |
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
3094 | esc = g_markup_escape_text(msg, -1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3095 | 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
|
3096 | g_free(esc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3097 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3098 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3099 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3100 | static void mw_place_clear(struct mwServicePlace *srvc) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3101 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3102 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3103 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3104 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3105 | static struct mwPlaceHandler mw_place_handler = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3106 | mw_place_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3107 | mw_place_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3108 | mw_place_peerJoined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3109 | mw_place_peerParted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3110 | mw_place_peerSetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3111 | mw_place_peerUnsetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3112 | mw_place_message, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3113 | mw_place_clear, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3114 | }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3115 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3116 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3117 | static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3118 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3119 | srvc = mwServicePlace_new(s, &mw_place_handler); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3120 | return srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3121 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3122 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3123 | |
| 10977 | 3124 | static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
| 3125 | struct mwServiceResolve *srvc; | |
| 3126 | srvc = mwServiceResolve_new(s); | |
| 3127 | return srvc; | |
| 3128 | } | |
| 3129 | ||
| 3130 | ||
| 3131 | static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
| 3132 | struct mwServiceStorage *srvc; | |
| 3133 | srvc = mwServiceStorage_new(s); | |
| 3134 | return srvc; | |
| 3135 | } | |
| 3136 | ||
| 3137 | ||
| 15884 | 3138 | /** allocate and associate a mwPurplePluginData with a PurpleConnection */ |
| 3139 | static struct mwPurplePluginData *mwPurplePluginData_new(PurpleConnection *gc) { | |
| 3140 | struct mwPurplePluginData *pd; | |
| 10977 | 3141 | |
| 3142 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3143 | ||
| 15884 | 3144 | pd = g_new0(struct mwPurplePluginData, 1); |
| 10977 | 3145 | pd->gc = gc; |
| 3146 | pd->session = mwSession_new(&mw_session_handler); | |
| 3147 | pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
| 3148 | pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
| 3149 | pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
| 3150 | pd->srvc_im = mw_srvc_im_new(pd->session); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3151 | pd->srvc_place = mw_srvc_place_new(pd->session); |
| 10977 | 3152 | pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
| 3153 | pd->srvc_store = mw_srvc_store_new(pd->session); | |
| 3154 | 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
|
3155 | pd->sock_buf = purple_circular_buffer_new(0); |
| 10977 | 3156 | |
| 3157 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
| 3158 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
| 3159 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
| 3160 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3161 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
| 10977 | 3162 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
| 3163 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
| 3164 | ||
| 3165 | 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
|
3166 | mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 10977 | 3167 | |
| 3168 | 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
|
3169 | purple_connection_set_protocol_data(gc, pd); |
| 10977 | 3170 | |
| 3171 | return pd; | |
| 3172 | } | |
| 3173 | ||
| 3174 | ||
| 15884 | 3175 | static void mwPurplePluginData_free(struct mwPurplePluginData *pd) { |
| 10977 | 3176 | g_return_if_fail(pd != NULL); |
| 3177 | ||
|
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(pd->gc, NULL); |
| 10977 | 3179 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3180 | mwSession_removeService(pd->session, mwService_AWARE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3181 | mwSession_removeService(pd->session, mwService_CONFERENCE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3182 | mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3183 | mwSession_removeService(pd->session, mwService_IM); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3184 | mwSession_removeService(pd->session, mwService_PLACE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3185 | mwSession_removeService(pd->session, mwService_RESOLVE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3186 | mwSession_removeService(pd->session, mwService_STORAGE); |
| 10977 | 3187 | |
| 3188 | mwService_free(MW_SERVICE(pd->srvc_aware)); | |
| 3189 | mwService_free(MW_SERVICE(pd->srvc_conf)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3190 | mwService_free(MW_SERVICE(pd->srvc_ft)); |
| 10977 | 3191 | mwService_free(MW_SERVICE(pd->srvc_im)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3192 | mwService_free(MW_SERVICE(pd->srvc_place)); |
| 10977 | 3193 | mwService_free(MW_SERVICE(pd->srvc_resolve)); |
| 3194 | mwService_free(MW_SERVICE(pd->srvc_store)); | |
| 3195 | ||
| 3196 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3197 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
| 10977 | 3198 | |
| 3199 | mwSession_free(pd->session); | |
| 3200 | ||
| 3201 | 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
|
3202 | g_object_unref(G_OBJECT(pd->sock_buf)); |
| 10977 | 3203 | |
| 3204 | g_free(pd); | |
| 3205 | } | |
| 3206 | ||
| 3207 | ||
| 15884 | 3208 | static const char *mw_prpl_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
| 10977 | 3209 | /* my little green dude is a chopped up version of the aim running |
| 3210 | guy. First, cut off the head and store someplace safe. Then, | |
| 3211 | take the left-half side of the body and throw it away. Make a | |
| 3212 | copy of the remaining body, and flip it horizontally. Now attach | |
| 3213 | the two pieces into an X shape, and drop the head back on the | |
| 3214 | top, being careful to center it. Then, just change the color | |
| 3215 | saturation to bring the red down a bit, and voila! */ | |
| 3216 | ||
| 3217 | /* then, throw all of that away and use sodipodi to make a new | |
| 3218 | icon. You know, LIKE A REAL MAN. */ | |
| 3219 | ||
| 3220 | return "meanwhile"; | |
| 3221 | } | |
| 3222 | ||
| 3223 | ||
| 15884 | 3224 | static const char* mw_prpl_list_emblem(PurpleBuddy *b) |
| 15524 | 3225 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3226 | if(buddy_is_external(b)) |
| 15524 | 3227 | return "external"; |
| 3228 | ||
| 3229 | return NULL; | |
| 10977 | 3230 | } |
| 3231 | ||
| 3232 | ||
| 15884 | 3233 | static char *mw_prpl_status_text(PurpleBuddy *b) { |
| 3234 | PurpleConnection *gc; | |
| 3235 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3236 | 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
|
3237 | 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
|
3238 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3239 | 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
|
3240 | && (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
|
3241 | 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
|
3242 | |
|
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
|
3243 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3244 | } |
| 3245 | ||
| 3246 | ||
| 15884 | 3247 | static const char *status_text(PurpleBuddy *b) { |
| 3248 | PurplePresence *presence; | |
| 3249 | PurpleStatus *status; | |
| 3250 | ||
| 3251 | presence = purple_buddy_get_presence(b); | |
| 3252 | status = purple_presence_get_active_status(presence); | |
| 3253 | ||
| 3254 | return purple_status_get_name(status); | |
| 10977 | 3255 | } |
| 3256 | ||
| 3257 | ||
| 3258 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3259 | const char *who, guint32 feature) { | |
| 3260 | ||
| 3261 | const struct mwAwareAttribute *attr; | |
| 3262 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3263 | ||
| 3264 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3265 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3266 | } | |
| 3267 | ||
| 3268 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3269 | 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
|
3270 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3271 | const char **f = feat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3272 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3273 | if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3274 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3275 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3276 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3277 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3278 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3279 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3280 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3281 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3282 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3283 | } |
|
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 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3286 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3287 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3288 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3289 | /* jenni loves siege */ |
| 10977 | 3290 | } |
| 3291 | ||
| 3292 | ||
| 15884 | 3293 | static void mw_prpl_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { |
| 3294 | 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
|
3295 | struct mwPurplePluginData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3296 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3297 | |
|
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
|
3298 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3299 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3300 | char *tmp; |
| 10977 | 3301 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3302 | 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
|
3303 | && (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
|
3304 | 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
|
3305 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3306 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3307 | |
|
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
|
3308 | 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
|
3309 | 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
|
3310 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3311 | } 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
|
3312 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status); |
| 10977 | 3313 | } |
| 3314 | ||
|
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
|
3315 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3316 | 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
|
3317 | 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
|
3318 | 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
|
3319 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3320 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3321 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3322 | 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
|
3323 | 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
|
3324 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3325 | } |
| 10977 | 3326 | } |
| 3327 | ||
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3328 | 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
|
3329 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3330 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3331 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3332 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3333 | 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
|
3334 | 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
|
3335 | 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
|
3336 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3337 | types = g_list_append(types, type); |
|
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 | 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
|
3340 | 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
|
3341 | 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
|
3342 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3343 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3344 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3345 | 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
|
3346 | 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
|
3347 | 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
|
3348 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3349 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3350 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3351 | 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
|
3352 | 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
|
3353 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3354 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3355 | return types; |
| 10977 | 3356 | } |
| 3357 | ||
| 3358 | ||
| 15884 | 3359 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3360 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3361 | ; /* nothing to do */ |
| 10977 | 3362 | } |
| 3363 | ||
| 3364 | ||
| 15884 | 3365 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3366 | PurpleRequestFields *fields) { | |
| 3367 | PurpleAccount *acct; | |
| 3368 | PurpleConnection *gc; | |
| 3369 | struct mwPurplePluginData *pd; | |
| 10977 | 3370 | struct mwServiceConference *srvc; |
| 3371 | ||
| 15884 | 3372 | PurpleRequestField *f; |
| 10977 | 3373 | |
| 3374 | const char *topic, *invite; | |
| 3375 | struct mwConference *conf; | |
| 3376 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3377 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3378 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3379 | 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
|
3380 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3381 | srvc = pd->srvc_conf; |
| 3382 | ||
| 15884 | 3383 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3384 | topic = purple_request_field_string_get_value(f); | |
| 3385 | ||
| 3386 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3387 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3388 | |
| 3389 | conf = mwConference_new(srvc, topic); | |
| 3390 | mwConference_open(conf); | |
| 3391 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3392 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3393 | mwConference_invite(conf, &idb, invite); |
| 3394 | } | |
| 3395 | ||
| 3396 | ||
| 15884 | 3397 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3398 | ||
| 3399 | PurpleRequestFields *fields; | |
| 3400 | PurpleRequestFieldGroup *g; | |
| 3401 | PurpleRequestField *f; | |
| 3402 | ||
| 3403 | PurpleAccount *acct; | |
| 3404 | PurpleConnection *gc; | |
| 10977 | 3405 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3406 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3407 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3408 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3409 | |
| 10977 | 3410 | g_return_if_fail(buddy != NULL); |
| 3411 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3412 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3413 | g_return_if_fail(acct != NULL); |
| 3414 | ||
| 15884 | 3415 | gc = purple_account_get_connection(acct); |
| 10977 | 3416 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3417 | |
| 15884 | 3418 | fields = purple_request_fields_new(); |
| 3419 | ||
| 3420 | g = purple_request_field_group_new(NULL); | |
| 3421 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3422 | |
| 15884 | 3423 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3424 | purple_request_field_group_add_field(g, f); | |
| 3425 | ||
| 3426 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3427 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3428 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3429 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3430 | 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
|
3431 | " 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
|
3432 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3433 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3434 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3435 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3436 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3437 | _("Cancel"), G_CALLBACK(conf_create_prompt_cancel), |
|
34332
876483829700
Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
3438 | purple_request_cpar_from_account(acct), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3439 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3440 | g_free(msg1); |
| 10977 | 3441 | } |
| 3442 | ||
| 3443 | ||
| 15884 | 3444 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3445 | PurpleRequestFields *fields) { | |
| 10977 | 3446 | ; |
| 3447 | } | |
| 3448 | ||
| 3449 | ||
| 15884 | 3450 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3451 | PurpleRequestFields *fields) { | |
| 3452 | 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
|
3453 | GList *l; |
| 10977 | 3454 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3455 | |
| 15884 | 3456 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3457 | msg = purple_request_field_string_get_value(f); | |
| 3458 | ||
| 3459 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3460 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3461 | |
| 3462 | if(l) { | |
| 15884 | 3463 | 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
|
3464 | |
| 10977 | 3465 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3466 | blist_menu_conf_create(buddy, msg); | |
| 3467 | ||
| 3468 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3469 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3470 | mwConference_invite(d, &idb, msg); |
| 3471 | } | |
| 3472 | } | |
| 3473 | } | |
| 3474 | ||
| 3475 | ||
| 15884 | 3476 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3477 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3478 | |
| 15884 | 3479 | PurpleRequestFields *fields; |
| 3480 | PurpleRequestFieldGroup *g; | |
| 3481 | PurpleRequestField *f; | |
| 3482 | ||
| 3483 | PurpleAccount *acct; | |
| 3484 | PurpleConnection *gc; | |
| 10977 | 3485 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3486 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3487 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3488 | char *msg; |
| 10977 | 3489 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3490 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3491 | g_return_if_fail(acct != NULL); |
| 3492 | ||
| 15884 | 3493 | gc = purple_account_get_connection(acct); |
| 10977 | 3494 | g_return_if_fail(gc != NULL); |
| 3495 | ||
| 15884 | 3496 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3497 | |
| 15884 | 3498 | g = purple_request_field_group_new(NULL); |
| 3499 | purple_request_fields_add_group(fields, g); | |
| 3500 | ||
| 3501 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3502 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3503 | for(; confs; confs = confs->next) { |
| 3504 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3505 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3506 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3507 | 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
|
3508 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3509 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3510 | |
| 15884 | 3511 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3512 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3513 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3514 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3515 | 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
|
3516 | " 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
|
3517 | " 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
|
3518 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3519 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3520 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3521 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3522 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3523 | _("Cancel"), G_CALLBACK(conf_select_prompt_cancel), |
|
34332
876483829700
Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
3524 | purple_request_cpar_from_account(acct), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3525 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3526 | g_free(msg); |
| 10977 | 3527 | } |
| 3528 | ||
| 3529 | ||
| 15884 | 3530 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 3531 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3532 | PurpleAccount *acct; | |
| 3533 | PurpleConnection *gc; | |
| 3534 | struct mwPurplePluginData *pd; | |
| 10977 | 3535 | GList *l; |
| 3536 | ||
| 3537 | 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
|
3538 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 10977 | 3539 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3540 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3541 | g_return_if_fail(acct != NULL); |
| 3542 | ||
| 15884 | 3543 | gc = purple_account_get_connection(acct); |
| 10977 | 3544 | g_return_if_fail(gc != NULL); |
| 3545 | ||
|
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
|
3546 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3547 | g_return_if_fail(pd != NULL); |
| 3548 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3549 | /* |
| 10977 | 3550 | - get a list of all conferences on this session |
| 3551 | - if none, prompt to create one, and invite buddy to it | |
| 3552 | - else, prompt to select a conference or create one | |
| 3553 | */ | |
| 3554 | ||
| 3555 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3556 | if(l) { | |
| 3557 | blist_menu_conf_list(buddy, l); | |
| 3558 | g_list_free(l); | |
| 3559 | ||
| 3560 | } else { | |
| 3561 | blist_menu_conf_create(buddy, NULL); | |
| 3562 | } | |
| 3563 | } | |
| 3564 | ||
| 3565 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3566 | #if 0 |
| 15884 | 3567 | static void blist_menu_announce(PurpleBlistNode *node, gpointer data) { |
| 3568 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3569 | PurpleAccount *acct; | |
| 3570 | PurpleConnection *gc; | |
| 3571 | struct mwPurplePluginData *pd; | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3572 | struct mwSession *session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3573 | char *rcpt_name; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3574 | GList *rcpt; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3575 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3576 | 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
|
3577 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3578 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3579 | acct = buddy->account; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3580 | g_return_if_fail(acct != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3581 | |
| 15884 | 3582 | gc = purple_account_get_connection(acct); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3583 | g_return_if_fail(gc != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3584 | |
|
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
|
3585 | pd = purple_connection_get_protocol_data(gc); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3586 | g_return_if_fail(pd != NULL); |
|
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 | rcpt_name = g_strdup_printf("@U %s", buddy->name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3589 | rcpt = g_list_prepend(NULL, rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3590 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3591 | session = pd->session; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3592 | mwSession_sendAnnounce(session, FALSE, |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3593 | "This is a TEST announcement. Please ignore.", |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3594 | rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3595 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3596 | g_list_free(rcpt); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3597 | g_free(rcpt_name); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3598 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3599 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3600 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3601 | |
| 15884 | 3602 | static GList *mw_prpl_blist_node_menu(PurpleBlistNode *node) { |
| 10977 | 3603 | GList *l = NULL; |
| 15884 | 3604 | PurpleMenuAction *act; |
| 3605 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3606 | if(! PURPLE_IS_BUDDY(node)) |
| 10977 | 3607 | return l; |
| 3608 | ||
| 3609 | l = g_list_append(l, NULL); | |
| 3610 | ||
| 15884 | 3611 | act = purple_menu_action_new(_("Invite to Conference..."), |
| 3612 | PURPLE_CALLBACK(blist_menu_conf), NULL, NULL); | |
| 10977 | 3613 | l = g_list_append(l, act); |
| 3614 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3615 | #if 0 |
| 15884 | 3616 | act = purple_menu_action_new(_("Send TEST Announcement"), |
| 3617 | PURPLE_CALLBACK(blist_menu_announce), NULL, NULL); | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3618 | l = g_list_append(l, act); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3619 | #endif |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
3620 | |
| 15884 | 3621 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3622 | blist-node-extended-menu signal for that. The function |
| 3623 | blist_node_menu_cb is assigned to this signal in the function | |
| 3624 | services_starting */ | |
| 3625 | ||
| 3626 | return l; | |
| 3627 | } | |
| 3628 | ||
| 3629 | ||
| 15884 | 3630 | static GList *mw_prpl_chat_info(PurpleConnection *gc) { |
| 10977 | 3631 | GList *l = NULL; |
| 3632 | struct proto_chat_entry *pce; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3633 | |
| 10977 | 3634 | pce = g_new0(struct proto_chat_entry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3635 | pce->label = _("Topic:"); |
| 10977 | 3636 | pce->identifier = CHAT_KEY_TOPIC; |
| 3637 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3638 | |
| 10977 | 3639 | return l; |
| 3640 | } | |
| 3641 | ||
| 3642 | ||
| 15884 | 3643 | static GHashTable *mw_prpl_chat_info_defaults(PurpleConnection *gc, |
| 10977 | 3644 | const char *name) { |
| 3645 | GHashTable *table; | |
| 3646 | ||
| 3647 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3648 | ||
| 3649 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3650 | NULL, g_free); | |
| 3651 | ||
| 3652 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3653 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3654 | ||
| 3655 | return table; | |
| 3656 | } | |
| 3657 | ||
| 3658 | ||
| 15884 | 3659 | static void mw_prpl_login(PurpleAccount *acct); |
| 3660 | ||
| 3661 | ||
| 3662 | static void mw_prpl_login(PurpleAccount *account) { | |
| 3663 | PurpleConnection *gc; | |
| 3664 | struct mwPurplePluginData *pd; | |
| 10977 | 3665 | |
| 3666 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3667 | guint port; |
| 10977 | 3668 | |
| 15884 | 3669 | gc = purple_account_get_connection(account); |
| 3670 | pd = mwPurplePluginData_new(gc); | |
| 10977 | 3671 | |
| 3672 | /* 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
|
3673 | purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_IMAGES); |
| 15884 | 3674 | |
| 3675 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3676 | |
| 3677 | host = strrchr(user, ':'); | |
| 3678 | if(host) { | |
| 3679 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3680 | *host++ = '\0'; | |
| 15884 | 3681 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3682 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3683 | |
| 10977 | 3684 | } else { |
| 15884 | 3685 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3686 | MW_PLUGIN_DEFAULT_HOST); |
| 3687 | } | |
| 3688 | ||
| 3689 | if(! host || ! *host) { | |
| 3690 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3691 | 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
|
3692 | 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
|
3693 | 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
|
3694 | 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
|
3695 | _("A server is required to connect this account")); |
| 10977 | 3696 | return; |
| 3697 | } | |
| 3698 | ||
|
34022
c49f6e9ea27d
Make all the prpls build.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
3699 | pass = g_strdup(purple_connection_get_password(gc)); |
| 15884 | 3700 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3701 | |
| 3702 | DEBUG_INFO("user: '%s'\n", user); | |
| 3703 | DEBUG_INFO("host: '%s'\n", host); | |
| 3704 | DEBUG_INFO("port: %u\n", port); | |
| 3705 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3706 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3707 | (char *) no_secret, NULL); |
| 3708 | 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
|
3709 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3710 | |
| 15884 | 3711 | 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
|
3712 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3713 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3714 | /* 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
|
3715 | 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
|
3716 | |
| 15884 | 3717 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3718 | 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
|
3719 | 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
|
3720 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3721 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3722 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3723 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3724 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3725 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3726 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3727 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3728 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3729 | GUINT_TO_POINTER(major), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3730 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3731 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3732 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3733 | } |
| 10977 | 3734 | |
| 15884 | 3735 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3736 | ||
| 3737 | 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
|
3738 | 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
|
3739 | _("Unable to connect")); |
| 10977 | 3740 | } |
| 3741 | } | |
| 3742 | ||
| 3743 | ||
| 15884 | 3744 | static void mw_prpl_close(PurpleConnection *gc) { |
| 3745 | struct mwPurplePluginData *pd; | |
| 10977 | 3746 | |
| 3747 | g_return_if_fail(gc != NULL); | |
| 3748 | ||
|
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
|
3749 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3750 | g_return_if_fail(pd != NULL); |
| 3751 | ||
| 3752 | /* get rid of the blist save timeout */ | |
| 3753 | if(pd->save_event) { | |
| 15884 | 3754 | purple_timeout_remove(pd->save_event); |
| 10977 | 3755 | pd->save_event = 0; |
| 3756 | blist_store(pd); | |
| 3757 | } | |
| 3758 | ||
| 3759 | /* stop the session */ | |
| 3760 | mwSession_stop(pd->session, 0x00); | |
| 3761 | ||
| 3762 | /* 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
|
3763 | purple_connection_set_protocol_data(gc, NULL); |
| 10977 | 3764 | |
| 3765 | /* 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
|
3766 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3767 | 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
|
3768 | pd->inpa = 0; |
| 10977 | 3769 | } |
| 3770 | ||
| 3771 | /* clean up the rest */ | |
| 15884 | 3772 | mwPurplePluginData_free(pd); |
| 10977 | 3773 | } |
| 3774 | ||
| 3775 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21947
diff
changeset
|
3776 | static int mw_rand(void) { |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3777 | static int seed = 0; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3778 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3779 | /* for diversity, not security. don't touch */ |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3780 | srand(time(NULL) ^ seed); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3781 | seed = rand(); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3782 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3783 | return seed; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3784 | } |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3785 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3786 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3787 | /** 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
|
3788 | static char *im_mime_content_id(void) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3789 | return g_strdup_printf("%03x@%05xmeanwhile", |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3790 | mw_rand() & 0xfff, mw_rand() & 0xfffff); |
| 10977 | 3791 | } |
| 3792 | ||
| 3793 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3794 | /** generates a multipart/related content type with a random-ish |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3795 | 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
|
3796 | static char *im_mime_content_type(void) { |
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3797 | 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
|
3798 | mw_rand() & 0xfff, mw_rand() & 0xffff); |
| 10977 | 3799 | } |
| 3800 | ||
| 3801 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3802 | /** determine content type from extension. Not so happy about this, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3803 | but I don't want to actually write image type detection */ |
| 15884 | 3804 | static char *im_mime_img_content_type(PurpleStoredImage *img) { |
| 3805 | const char *fn = purple_imgstore_get_filename(img); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3806 | const char *ct = NULL; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3807 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3808 | ct = strrchr(fn, '.'); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3809 | if(! ct) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3810 | ct = "image"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3811 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3812 | } else if(! strcmp(".png", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3813 | ct = "image/png"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3814 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3815 | } else if(! strcmp(".jpg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3816 | ct = "image/jpeg"; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3817 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3818 | } else if(! strcmp(".jpeg", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3819 | ct = "image/jpeg"; |
|
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(".gif", ct)) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3822 | ct = "image/gif"; |
| 10977 | 3823 | |
| 3824 | } else { | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3825 | ct = "image"; |
| 10977 | 3826 | } |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3827 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3828 | return g_strdup_printf("%s; name=\"%s\"", ct, fn); |
| 10977 | 3829 | } |
| 3830 | ||
| 3831 | ||
| 15884 | 3832 | static char *im_mime_img_content_disp(PurpleStoredImage *img) { |
| 3833 | const char *fn = purple_imgstore_get_filename(img); | |
| 10977 | 3834 | return g_strdup_printf("attachment; filename=\"%s\"", fn); |
| 3835 | } | |
| 3836 | ||
| 3837 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3838 | /** turn an IM with embedded images into a multi-part mime document */ |
| 15884 | 3839 | static char *im_mime_convert(PurpleConnection *gc, |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3840 | struct mwConversation *conv, |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3841 | const char *message) { |
| 10977 | 3842 | GString *str; |
| 15884 | 3843 | PurpleMimeDocument *doc; |
| 3844 | PurpleMimePart *part; | |
| 10977 | 3845 | |
| 3846 | GData *attr; | |
| 3847 | char *tmp, *start, *end; | |
| 3848 | ||
| 3849 | str = g_string_new(NULL); | |
| 3850 | ||
| 15884 | 3851 | doc = purple_mime_document_new(); |
| 3852 | ||
| 3853 | purple_mime_document_set_field(doc, "Mime-Version", "1.0"); | |
| 3854 | purple_mime_document_set_field(doc, "Content-Disposition", "inline"); | |
| 10977 | 3855 | |
| 3856 | tmp = im_mime_content_type(); | |
| 15884 | 3857 | purple_mime_document_set_field(doc, "Content-Type", tmp); |
| 10977 | 3858 | g_free(tmp); |
| 3859 | ||
| 3860 | tmp = (char *) message; | |
| 15884 | 3861 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 3862 | (const char **) &end, &attr)) { |
| 3863 | char *id; | |
| 15884 | 3864 | PurpleStoredImage *img = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3865 | |
| 10977 | 3866 | gsize len = (start - tmp); |
| 3867 | ||
| 3868 | /* append the in-between-tags text */ | |
| 3869 | if(len) g_string_append_len(str, tmp, len); | |
| 3870 | ||
| 3871 | /* find the imgstore data by the id tag */ | |
| 3872 | id = g_datalist_get_data(&attr, "id"); | |
| 3873 | 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
|
3874 | img = purple_imgstore_find_by_id(atoi(id)); |
| 10977 | 3875 | |
| 3876 | if(img) { | |
| 3877 | char *cid; | |
| 3878 | gpointer data; | |
| 3879 | size_t size; | |
| 3880 | ||
| 15884 | 3881 | part = purple_mime_part_new(doc); |
| 10977 | 3882 | |
| 3883 | data = im_mime_img_content_disp(img); | |
| 15884 | 3884 | purple_mime_part_set_field(part, "Content-Disposition", data); |
| 10977 | 3885 | g_free(data); |
| 3886 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3887 | data = im_mime_img_content_type(img); |
| 15884 | 3888 | purple_mime_part_set_field(part, "Content-Type", data); |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3889 | g_free(data); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3890 | |
| 10977 | 3891 | cid = im_mime_content_id(); |
| 3892 | data = g_strdup_printf("<%s>", cid); | |
| 15884 | 3893 | purple_mime_part_set_field(part, "Content-ID", data); |
| 10977 | 3894 | g_free(data); |
| 3895 | ||
| 15884 | 3896 | purple_mime_part_set_field(part, "Content-transfer-encoding", "base64"); |
| 10977 | 3897 | |
| 3898 | /* obtain and base64 encode the image data, and put it in the | |
| 3899 | mime part */ | |
| 15884 | 3900 | 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
|
3901 | data = purple_base64_encode(purple_imgstore_get_data(img), (gsize) size); |
| 15884 | 3902 | purple_mime_part_set_data(part, data); |
| 10977 | 3903 | g_free(data); |
| 3904 | ||
| 3905 | /* append the modified tag */ | |
| 3906 | g_string_append_printf(str, "<img src=\"cid:%s\">", cid); | |
| 3907 | g_free(cid); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3908 | |
| 10977 | 3909 | } else { |
| 3910 | /* append the literal image tag, since we couldn't find a | |
| 3911 | relative imgstore object */ | |
| 3912 | gsize len = (end - start) + 1; | |
| 3913 | g_string_append_len(str, start, len); | |
| 3914 | } | |
| 3915 | ||
| 3916 | g_datalist_clear(&attr); | |
| 3917 | tmp = end + 1; | |
| 3918 | } | |
| 3919 | ||
| 3920 | /* append left-overs */ | |
| 3921 | g_string_append(str, tmp); | |
| 3922 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3923 | /* add the text/html part */ |
| 15884 | 3924 | part = purple_mime_part_new(doc); |
| 3925 | purple_mime_part_set_field(part, "Content-Disposition", "inline"); | |
| 3926 | ||
| 3927 | tmp = purple_utf8_ncr_encode(str->str); | |
| 3928 | purple_mime_part_set_field(part, "Content-Type", "text/html"); | |
| 3929 | purple_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); | |
| 3930 | purple_mime_part_set_data(part, tmp); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3931 | g_free(tmp); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3932 | |
| 10977 | 3933 | g_string_free(str, TRUE); |
| 3934 | ||
| 3935 | str = g_string_new(NULL); | |
| 15884 | 3936 | purple_mime_document_write(doc, str); |
| 10977 | 3937 | tmp = str->str; |
| 3938 | g_string_free(str, FALSE); | |
| 3939 | ||
| 3940 | return tmp; | |
| 3941 | } | |
| 3942 | ||
| 3943 | ||
| 15884 | 3944 | static int mw_prpl_send_im(PurpleConnection *gc, |
| 10977 | 3945 | const char *name, |
| 3946 | const char *message, | |
| 15884 | 3947 | PurpleMessageFlags flags) { |
| 3948 | ||
| 3949 | struct mwPurplePluginData *pd; | |
| 10977 | 3950 | struct mwIdBlock who = { (char *) name, NULL }; |
| 3951 | struct mwConversation *conv; | |
| 3952 | ||
| 3953 | 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
|
3954 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3955 | |
| 3956 | g_return_val_if_fail(pd != NULL, 0); | |
| 3957 | ||
| 3958 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 3959 | ||
| 3960 | /* this detection of features to determine how to send the message | |
| 3961 | (plain, html, or mime) is flawed because the other end of the | |
| 3962 | conversation could close their channel at any time, rendering any | |
| 3963 | existing formatting in an outgoing message innapropriate. The end | |
| 3964 | result is that it may be possible that the other side of the | |
| 3965 | conversation will receive a plaintext message with html contents, | |
| 3966 | which is bad. I'm not sure how to fix this correctly. */ | |
| 3967 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3968 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 3969 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 3970 | |
| 3971 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3972 | char *tmp; |
| 10977 | 3973 | int ret; |
| 3974 | ||
| 15884 | 3975 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 3976 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3977 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3978 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3979 | tmp = im_mime_convert(gc, conv, message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3980 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3981 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3982 | |
| 10977 | 3983 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3984 | /* send an HTML message */ |
| 10977 | 3985 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3986 | char *ncr; |
| 15884 | 3987 | ncr = purple_utf8_ncr_encode(message); |
| 3988 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3989 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3990 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3991 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3992 | g_free(tmp); |
| 10977 | 3993 | |
| 3994 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3995 | /* default to text */ |
| 15884 | 3996 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
3997 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3998 | g_free(tmp); |
| 10977 | 3999 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4000 | |
| 10977 | 4001 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4002 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4003 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4004 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4005 | /* queue up the message safely as plain text */ |
| 15884 | 4006 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4007 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4008 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4009 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4010 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4011 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4012 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4013 | return 1; |
| 10977 | 4014 | } |
| 4015 | } | |
| 4016 | ||
| 4017 | ||
| 15884 | 4018 | static unsigned int mw_prpl_send_typing(PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4019 | 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
|
4020 | PurpleIMTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4021 | |
| 15884 | 4022 | struct mwPurplePluginData *pd; |
| 10977 | 4023 | struct mwIdBlock who = { (char *) name, NULL }; |
| 4024 | struct mwConversation *conv; | |
| 4025 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
4026 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 4027 | |
| 4028 | 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
|
4029 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4030 | |
| 4031 | g_return_val_if_fail(pd != NULL, 0); | |
| 4032 | ||
| 4033 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 4034 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4035 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4036 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4037 | |
|
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
|
4038 | } 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
|
4039 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4040 | 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
|
4041 | 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
|
4042 | |
| 10977 | 4043 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4044 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4045 | if(! mwConversation_isPending(conv)) { |
| 10977 | 4046 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4047 | } |
| 10977 | 4048 | } |
| 4049 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4050 | return 0; |
| 10977 | 4051 | } |
| 4052 | ||
| 4053 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4054 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4055 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4056 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4057 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4058 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4059 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4060 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4061 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4062 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4063 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4064 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4065 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4066 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4067 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4068 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4069 | return "Lotus Sametime Links"; |
|
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_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4072 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4073 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4074 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4075 | return "Lotus Notes Client"; |
|
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_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4078 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4079 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4080 | return "IBM Community Tools"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4081 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4082 | case mwLogin_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4083 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4084 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4085 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4086 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4087 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4088 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4089 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4090 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4091 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4092 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4093 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4094 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4095 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4096 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4097 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4098 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4099 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4100 | return "Trillian"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4101 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4102 | case mwLogin_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4103 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4104 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4105 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4106 | return NULL; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4107 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4108 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4109 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4110 | |
| 15884 | 4111 | static void mw_prpl_get_info(PurpleConnection *gc, const char *who) { |
| 10977 | 4112 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4113 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4114 | |
| 15884 | 4115 | struct mwPurplePluginData *pd; |
| 4116 | PurpleAccount *acct; | |
| 4117 | PurpleBuddy *b; | |
| 4118 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4119 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4120 | const char *tmp2; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4121 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4122 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4123 | g_return_if_fail(*who != '\0'); |
| 10977 | 4124 | |
|
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
|
4125 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4126 | |
| 15884 | 4127 | 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
|
4128 | b = purple_blist_find_buddy(acct, who); |
| 15884 | 4129 | user_info = purple_notify_user_info_new(); |
| 4130 | ||
| 4131 | 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
|
4132 | purple_notify_user_info_add_pair_html(user_info, _("External User"), NULL); |
| 10977 | 4133 | } |
| 4134 | ||
|
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
|
4135 | 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
|
4136 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4137 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4138 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4139 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4140 | 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
|
4141 | /* 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
|
4142 | 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
|
4143 | 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
|
4144 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4145 | |
| 15884 | 4146 | 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
|
4147 | 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
|
4148 | 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
|
4149 | 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
|
4150 | 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
|
4151 | } else { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4152 | 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
|
4153 | 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
|
4154 | 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
|
4155 | } |
| 10977 | 4156 | } |
| 4157 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4158 | |
| 10977 | 4159 | tmp = user_supports_text(pd->srvc_aware, who); |
| 4160 | 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
|
4161 | 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
|
4162 | g_free(tmp); |
| 10977 | 4163 | } |
| 4164 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4165 | 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
|
4166 | 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
|
4167 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4168 | /* 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
|
4169 | 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
|
4170 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
| 15884 | 4171 | 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
|
4172 | 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
|
4173 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4174 | } |
| 10977 | 4175 | |
| 4176 | /* @todo emit a signal to allow a plugin to override the display of | |
| 4177 | this notification, so that it can create its own */ | |
| 4178 | ||
| 15884 | 4179 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 4180 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 4181 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4182 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4183 | |
| 15884 | 4184 | static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status) { |
| 4185 | PurpleConnection *gc; | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4186 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
4187 | char *message = NULL; |
| 10977 | 4188 | struct mwSession *session; |
| 4189 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4190 | |
| 10977 | 4191 | g_return_if_fail(acct != NULL); |
| 15884 | 4192 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4193 | |
| 15884 | 4194 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4195 | |
| 15884 | 4196 | 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
|
4197 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4198 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4199 | |
| 10977 | 4200 | session = gc_to_session(gc); |
| 4201 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4202 | |
| 10977 | 4203 | /* get a working copy of the current status */ |
| 4204 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4205 | |
| 10977 | 4206 | /* determine the state */ |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4207 | if(! strcmp(state, MW_STATE_ACTIVE)) { |
| 10977 | 4208 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4209 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4210 | } else if(! strcmp(state, MW_STATE_AWAY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4211 | stat.status = mwStatus_AWAY; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4212 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4213 | } else if(! strcmp(state, MW_STATE_BUSY)) { |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4214 | stat.status = mwStatus_BUSY; |
| 10977 | 4215 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4216 | |
| 10977 | 4217 | /* determine the message */ |
| 15884 | 4218 | 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
|
4219 | |
| 10977 | 4220 | if(message) { |
| 4221 | /* all the possible non-NULL values of message up to this point | |
| 4222 | are const, so we don't need to free them */ | |
| 15884 | 4223 | message = purple_markup_strip_html(message); |
| 10977 | 4224 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4225 | |
| 10977 | 4226 | /* out with the old */ |
| 4227 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4228 | |
| 10977 | 4229 | /* in with the new */ |
| 4230 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4231 | |
| 10977 | 4232 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4233 | mwUserStatus_clear(&stat); |
| 10977 | 4234 | } |
| 4235 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4236 | |
| 15884 | 4237 | static void mw_prpl_set_idle(PurpleConnection *gc, int t) { |
| 10977 | 4238 | struct mwSession *session; |
| 4239 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4240 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4241 | |
| 10977 | 4242 | session = gc_to_session(gc); |
| 4243 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4244 | |
| 10977 | 4245 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4246 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4247 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4248 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4249 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4250 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4251 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4252 | stat.time = 0; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4253 | } |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4254 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4255 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4256 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4257 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4258 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4259 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4260 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4261 | stat.status = mwStatus_ACTIVE; |
| 4262 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4263 | |
| 10977 | 4264 | mwSession_setUserStatus(session, &stat); |
| 4265 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4266 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4267 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4268 | |
| 15884 | 4269 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4270 | PurpleAccount *acct; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4271 | PurpleIMConversation *im; |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4272 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4273 | |
| 15884 | 4274 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4275 | 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
|
4276 | 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
|
4277 | 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
|
4278 | purple_conversation_present(PURPLE_CONVERSATION(im)); |
| 15884 | 4279 | } |
| 4280 | ||
| 4281 | ||
| 4282 | 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
|
4283 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4284 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4285 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4286 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4287 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4288 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4289 | |
| 15884 | 4290 | 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
|
4291 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4292 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4293 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4294 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4295 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4296 | static void notify_close(gpointer data) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4297 | if (data) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4298 | g_free(data); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4299 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4300 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4301 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4302 | |
| 10977 | 4303 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4304 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4305 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4306 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4307 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4308 | char *msg; |
| 10977 | 4309 | |
| 15884 | 4310 | PurpleNotifySearchResults *sres; |
| 4311 | PurpleNotifySearchColumn *scol; | |
| 4312 | ||
| 4313 | sres = purple_notify_searchresults_new(); | |
| 4314 | ||
| 4315 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4316 | purple_notify_searchresults_column_add(sres, scol); | |
| 4317 | ||
| 4318 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4319 | purple_notify_searchresults_column_add(sres, scol); | |
| 4320 | ||
| 4321 | 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
|
4322 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4323 | |
| 15884 | 4324 | 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
|
4325 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4326 | |
| 10977 | 4327 | for(l = result->matches; l; l = l->next) { |
| 4328 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4329 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4330 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4331 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4332 | NSTR(match->id), NSTR(match->name)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4333 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4334 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4335 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4336 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4337 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4338 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4339 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4340 | } |
| 10977 | 4341 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4342 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4343 | 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
|
4344 | " 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
|
4345 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4346 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4347 | |
| 15884 | 4348 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4349 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4350 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4351 | g_free(msg); |
| 10977 | 4352 | } |
| 4353 | ||
| 4354 | ||
| 4355 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4356 | guint32 id, guint32 code, GList *results, | |
| 4357 | gpointer b) { | |
| 4358 | ||
| 4359 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4360 | BuddyAddData *data = b; |
| 15884 | 4361 | PurpleBuddy *buddy = NULL; |
| 4362 | PurpleConnection *gc; | |
| 4363 | struct mwPurplePluginData *pd; | |
| 10977 | 4364 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4365 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4366 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4367 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4368 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4369 | 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
|
4370 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4371 | |
| 4372 | if(results) | |
| 4373 | res = results->data; | |
| 4374 | ||
| 4375 | 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
|
4376 | if(!res->matches->next) { |
| 10977 | 4377 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4378 | |
| 10977 | 4379 | /* only one? that might be the right one! */ |
| 4380 | if(strcmp(res->name, match->id)) { | |
| 4381 | /* uh oh, the single result isn't identical to the search | |
| 4382 | term, better safe then sorry, so let's make sure it's who | |
| 4383 | the user meant to add */ | |
| 15884 | 4384 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4385 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4386 | |
| 10977 | 4387 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4388 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4389 | /* 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
|
4390 | purple_buddy_set_server_alias(buddy, match->name); |
| 15884 | 4391 | purple_blist_node_set_string((PurpleBlistNode *) buddy, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4392 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4393 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4394 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4395 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4396 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4397 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4398 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4399 | g_free(data); |
| 10977 | 4400 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4401 | |
| 10977 | 4402 | } else { |
| 4403 | /* prompt user if more than one match was returned */ | |
| 15884 | 4404 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4405 | multi_resolved_query(res, gc, data); |
| 10977 | 4406 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4407 | |
| 10977 | 4408 | return; |
| 4409 | } | |
| 4410 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4411 | #if 0 |
| 10977 | 4412 | /* fall-through indicates that we couldn't find a matching user in |
| 4413 | the resolve service (ether error or zero results), so we remove | |
| 4414 | this buddy */ | |
| 4415 | ||
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4416 | /* 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
|
4417 | 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
|
4418 | 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
|
4419 | 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
|
4420 | 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
|
4421 | |
| 10977 | 4422 | DEBUG_INFO("no such buddy in community\n"); |
| 15884 | 4423 | purple_blist_remove_buddy(buddy); |
| 10977 | 4424 | blist_schedule(pd); |
| 4425 | ||
| 4426 | if(res && res->name) { | |
| 4427 | /* compose and display an error message */ | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4428 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4429 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4430 | char *msg; |
| 10977 | 4431 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4432 | msgA = _("Unable to add user: user not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4433 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4434 | 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
|
4435 | " Sametime community. This entry has been removed from" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4436 | " your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4437 | msg = g_strdup_printf(msgB, NSTR(res->name)); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4438 | |
| 15884 | 4439 | purple_notify_error(gc, _("Unable to add user"), msgA, msg); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4440 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4441 | g_free(msg); |
| 10977 | 4442 | } |
|
14976
3f4e883a2766
[gaim-migrate @ 17686]
Christopher O'Brien <siege@pidgin.im>
parents:
14975
diff
changeset
|
4443 | #endif |
| 10977 | 4444 | } |
| 4445 | ||
| 4446 | ||
| 15884 | 4447 | static void mw_prpl_add_buddy(PurpleConnection *gc, |
| 4448 | PurpleBuddy *buddy, | |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4449 | PurpleGroup *group, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4450 | const char *message) { |
| 15884 | 4451 | |
|
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
|
4452 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4453 | struct mwServiceResolve *srvc; |
| 4454 | GList *query; | |
| 4455 | enum mwResolveFlag flags; | |
| 4456 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4457 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4458 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4459 | /* 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
|
4460 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4461 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4462 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4463 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4464 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4465 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4466 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4467 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4468 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4469 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4470 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4471 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4472 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4473 | ||
| 4474 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4475 | data, NULL); |
| 10977 | 4476 | g_list_free(query); |
| 4477 | ||
| 4478 | if(req == SEARCH_ERROR) { | |
| 15884 | 4479 | purple_blist_remove_buddy(buddy); |
| 10977 | 4480 | blist_schedule(pd); |
| 4481 | } | |
| 4482 | } | |
| 4483 | ||
| 4484 | ||
| 15884 | 4485 | static void foreach_add_buddies(PurpleGroup *group, GList *buddies, |
| 4486 | struct mwPurplePluginData *pd) { | |
| 10977 | 4487 | struct mwAwareList *list; |
| 4488 | ||
| 4489 | list = list_ensure(pd, group); | |
| 4490 | mwAwareList_addAware(list, buddies); | |
| 4491 | g_list_free(buddies); | |
| 4492 | } | |
| 4493 | ||
| 4494 | ||
| 15884 | 4495 | static void mw_prpl_add_buddies(PurpleConnection *gc, |
| 10977 | 4496 | GList *buddies, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4497 | GList *groups, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4498 | const char *message) { |
| 10977 | 4499 | |
| 15884 | 4500 | struct mwPurplePluginData *pd; |
| 10977 | 4501 | GHashTable *group_sets; |
| 4502 | struct mwAwareIdBlock *idbs, *idb; | |
| 4503 | ||
|
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
|
4504 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4505 | |
| 15884 | 4506 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4507 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4508 | ||
| 4509 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4510 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4511 | ||
| 4512 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4513 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4514 | PurpleBuddy *b = buddies->data; |
| 4515 | PurpleGroup *g; | |
| 10977 | 4516 | const char *fn; |
| 4517 | GList *l; | |
| 4518 | ||
| 4519 | /* nab the saved server alias and stick it on the buddy */ | |
| 15884 | 4520 | 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
|
4521 | purple_buddy_set_server_alias(b, fn); |
| 15884 | 4522 | |
| 4523 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4524 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4525 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4526 | idb->community = NULL; |
| 4527 | ||
| 4528 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4529 | g = purple_buddy_get_group(b); |
| 10977 | 4530 | l = g_hash_table_lookup(group_sets, g); |
| 4531 | l = g_list_prepend(l, idb++); | |
| 4532 | g_hash_table_insert(group_sets, g, l); | |
| 4533 | } | |
| 4534 | ||
| 4535 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4536 | for saving */ | |
| 4537 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4538 | blist_schedule(pd); | |
| 4539 | ||
| 4540 | /* cleanup */ | |
| 4541 | g_hash_table_destroy(group_sets); | |
| 4542 | g_free(idbs); | |
| 4543 | } | |
| 4544 | ||
| 4545 | ||
| 15884 | 4546 | static void mw_prpl_remove_buddy(PurpleConnection *gc, |
| 4547 | PurpleBuddy *buddy, PurpleGroup *group) { | |
| 4548 | ||
| 4549 | struct mwPurplePluginData *pd; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4550 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4551 | struct mwAwareList *list; |
| 4552 | ||
| 4553 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4554 | ||
|
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
|
4555 | pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4556 | group = purple_buddy_get_group(buddy); |
| 10977 | 4557 | list = list_ensure(pd, group); |
| 4558 | ||
| 4559 | mwAwareList_removeAware(list, rem); | |
| 4560 | blist_schedule(pd); | |
| 4561 | ||
| 4562 | g_list_free(rem); | |
| 4563 | } | |
| 4564 | ||
| 4565 | ||
| 4566 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4567 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4568 | |
| 10977 | 4569 | struct mwUserItem *u; |
| 4570 | guint count; | |
| 4571 | ||
| 4572 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4573 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4574 | |
| 4575 | priv->count = count; | |
| 4576 | priv->users = g_new0(struct mwUserItem, count); | |
| 4577 | ||
| 4578 | while(count--) { | |
| 4579 | u = priv->users + count; | |
| 4580 | u->id = members->data; | |
| 4581 | members = members->next; | |
| 4582 | } | |
| 4583 | } | |
| 4584 | ||
| 4585 | ||
| 15884 | 4586 | static void mw_prpl_set_permit_deny(PurpleConnection *gc) { |
| 4587 | PurpleAccount *acct; | |
| 4588 | struct mwPurplePluginData *pd; | |
| 10977 | 4589 | struct mwSession *session; |
| 4590 | ||
| 4591 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4592 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4593 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4594 | NULL, /* users */ |
| 10977 | 4595 | }; |
| 4596 | ||
| 4597 | g_return_if_fail(gc != NULL); | |
| 4598 | ||
| 15884 | 4599 | acct = purple_connection_get_account(gc); |
| 10977 | 4600 | g_return_if_fail(acct != NULL); |
| 4601 | ||
|
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
|
4602 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4603 | g_return_if_fail(pd != NULL); |
| 4604 | ||
| 4605 | session = pd->session; | |
| 4606 | g_return_if_fail(session != NULL); | |
| 4607 | ||
|
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
|
4608 | 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
|
4609 | case PURPLE_ACCOUNT_PRIVACY_DENY_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4610 | 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
|
4611 | privacy_fill(&privacy, purple_account_privacy_get_denied(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4612 | privacy.deny = TRUE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4613 | break; |
| 10977 | 4614 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4615 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4616 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL\n"); |
| 10977 | 4617 | privacy.deny = TRUE; |
| 4618 | break; | |
| 4619 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4620 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4621 | 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
|
4622 | privacy_fill(&privacy, purple_account_privacy_get_permitted(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4623 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4624 | break; |
| 10977 | 4625 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4626 | case PURPLE_ACCOUNT_PRIVACY_DENY_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4627 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_DENY_ALL\n"); |
| 10977 | 4628 | privacy.deny = FALSE; |
| 4629 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4630 | |
| 10977 | 4631 | 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
|
4632 | 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
|
4633 | return; |
| 10977 | 4634 | } |
| 4635 | ||
| 4636 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4637 | g_free(privacy.users); | |
| 4638 | } | |
| 4639 | ||
| 4640 | ||
| 15884 | 4641 | static void mw_prpl_add_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4642 | mw_prpl_set_permit_deny(gc); |
| 4643 | } | |
| 4644 | ||
| 4645 | ||
| 15884 | 4646 | static void mw_prpl_add_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4647 | mw_prpl_set_permit_deny(gc); |
| 4648 | } | |
| 4649 | ||
| 4650 | ||
| 15884 | 4651 | static void mw_prpl_rem_permit(PurpleConnection *gc, const char *name) { |
| 10977 | 4652 | mw_prpl_set_permit_deny(gc); |
| 4653 | } | |
| 4654 | ||
| 4655 | ||
| 15884 | 4656 | static void mw_prpl_rem_deny(PurpleConnection *gc, const char *name) { |
| 10977 | 4657 | mw_prpl_set_permit_deny(gc); |
| 4658 | } | |
| 4659 | ||
| 4660 | ||
| 4661 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4662 | const char *name) { | |
| 4663 | GList *l, *ll; | |
| 4664 | struct mwConference *conf = NULL; | |
| 4665 | ||
| 4666 | ll = mwServiceConference_getConferences(srvc); | |
| 4667 | for(l = ll; l; l = l->next) { | |
| 4668 | struct mwConference *c = l->data; | |
| 4669 | if(! strcmp(name, mwConference_getName(c))) { | |
| 4670 | conf = c; | |
| 4671 | break; | |
| 4672 | } | |
| 4673 | } | |
| 4674 | g_list_free(ll); | |
| 4675 | ||
| 4676 | return conf; | |
| 4677 | } | |
| 4678 | ||
| 4679 | ||
| 15884 | 4680 | static void mw_prpl_join_chat(PurpleConnection *gc, |
| 10977 | 4681 | GHashTable *components) { |
| 4682 | ||
| 15884 | 4683 | struct mwPurplePluginData *pd; |
| 10977 | 4684 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4685 | |
|
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
|
4686 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4687 | |
| 4688 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4689 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4690 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4691 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4692 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4693 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4694 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4695 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4696 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4697 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4698 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4699 | |
| 10977 | 4700 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4701 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4702 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4703 | struct mwConference *conf = 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_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4706 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4707 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4708 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4709 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4710 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4711 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4712 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4713 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4714 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4715 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4716 | } |
| 10977 | 4717 | } |
| 4718 | } | |
| 4719 | ||
| 4720 | ||
| 15884 | 4721 | static void mw_prpl_reject_chat(PurpleConnection *gc, |
| 10977 | 4722 | GHashTable *components) { |
| 4723 | ||
| 15884 | 4724 | struct mwPurplePluginData *pd; |
| 10977 | 4725 | struct mwServiceConference *srvc; |
| 4726 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4727 | |
|
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
|
4728 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4729 | srvc = pd->srvc_conf; |
| 4730 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4731 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4732 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4733 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4734 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4735 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4736 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4737 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4738 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4739 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4740 | } |
| 10977 | 4741 | } |
| 4742 | } | |
| 4743 | ||
| 4744 | ||
| 4745 | static char *mw_prpl_get_chat_name(GHashTable *components) { | |
| 4746 | return g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4747 | } | |
| 4748 | ||
| 4749 | ||
| 15884 | 4750 | static void mw_prpl_chat_invite(PurpleConnection *gc, |
| 10977 | 4751 | int id, |
| 4752 | const char *invitation, | |
| 4753 | const char *who) { | |
| 4754 | ||
| 15884 | 4755 | struct mwPurplePluginData *pd; |
| 10977 | 4756 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4757 | struct mwPlace *place; |
| 10977 | 4758 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4759 | ||
|
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
|
4760 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4761 | g_return_if_fail(pd != NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4762 | |
| 10977 | 4763 | conf = ID_TO_CONF(pd, id); |
| 4764 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4765 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4766 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4767 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4768 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4769 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4770 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4771 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4772 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4773 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4774 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4775 | } |
| 4776 | ||
| 4777 | ||
| 15884 | 4778 | static void mw_prpl_chat_leave(PurpleConnection *gc, |
| 10977 | 4779 | int id) { |
| 4780 | ||
| 15884 | 4781 | struct mwPurplePluginData *pd; |
| 10977 | 4782 | struct mwConference *conf; |
| 4783 | ||
|
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
|
4784 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4785 | |
| 4786 | g_return_if_fail(pd != NULL); | |
| 4787 | conf = ID_TO_CONF(pd, id); | |
| 4788 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4789 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4790 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4791 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4792 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4793 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4794 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4795 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4796 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4797 | } |
| 10977 | 4798 | } |
| 4799 | ||
| 4800 | ||
| 15884 | 4801 | static void mw_prpl_chat_whisper(PurpleConnection *gc, |
| 10977 | 4802 | int id, |
| 4803 | const char *who, | |
| 4804 | const char *message) { | |
| 4805 | ||
| 4806 | mw_prpl_send_im(gc, who, message, 0); | |
| 4807 | } | |
| 4808 | ||
| 4809 | ||
| 15884 | 4810 | static int mw_prpl_chat_send(PurpleConnection *gc, |
| 10977 | 4811 | int id, |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
4812 | const char *message, |
| 15884 | 4813 | PurpleMessageFlags flags) { |
| 4814 | ||
| 4815 | struct mwPurplePluginData *pd; | |
| 10977 | 4816 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4817 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4818 | int ret; |
| 10977 | 4819 | |
|
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
|
4820 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4821 | |
| 4822 | g_return_val_if_fail(pd != NULL, 0); | |
| 4823 | conf = ID_TO_CONF(pd, id); | |
| 4824 | ||
| 15884 | 4825 | msg = purple_markup_strip_html(message); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4826 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4827 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4828 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4829 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4830 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4831 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4832 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4833 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4834 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4835 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4836 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4837 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4838 | return ret; |
| 10977 | 4839 | } |
| 4840 | ||
| 4841 | ||
| 15884 | 4842 | static void mw_prpl_keepalive(PurpleConnection *gc) { |
| 10977 | 4843 | struct mwSession *session; |
| 4844 | ||
| 4845 | g_return_if_fail(gc != NULL); | |
| 4846 | ||
| 4847 | session = gc_to_session(gc); | |
| 4848 | g_return_if_fail(session != NULL); | |
| 4849 | ||
| 4850 | mwSession_sendKeepalive(session); | |
| 4851 | } | |
| 4852 | ||
| 4853 | ||
| 15884 | 4854 | static void mw_prpl_alias_buddy(PurpleConnection *gc, |
| 10977 | 4855 | const char *who, |
| 4856 | const char *alias) { | |
| 4857 | ||
|
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
|
4858 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4859 | g_return_if_fail(pd != NULL); |
| 4860 | ||
| 4861 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4862 | the server copy */ | |
| 4863 | ||
| 4864 | blist_schedule(pd); | |
| 4865 | } | |
| 4866 | ||
| 4867 | ||
| 15884 | 4868 | static void mw_prpl_group_buddy(PurpleConnection *gc, |
| 10977 | 4869 | const char *who, |
| 4870 | const char *old_group, | |
| 4871 | const char *new_group) { | |
| 4872 | ||
| 4873 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 4874 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4875 | ||
|
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
|
4876 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4877 | PurpleGroup *group; |
| 10977 | 4878 | struct mwAwareList *list; |
| 4879 | ||
| 4880 | /* 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
|
4881 | group = purple_blist_find_group(new_group); |
| 10977 | 4882 | list = list_ensure(pd, group); |
| 4883 | mwAwareList_addAware(list, gl); | |
| 4884 | ||
| 4885 | /* 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
|
4886 | group = purple_blist_find_group(old_group); |
| 10977 | 4887 | list = list_ensure(pd, group); |
| 4888 | mwAwareList_removeAware(list, gl); | |
| 4889 | ||
| 4890 | g_list_free(gl); | |
| 4891 | ||
| 4892 | /* schedule the changes to be saved */ | |
| 4893 | blist_schedule(pd); | |
| 4894 | } | |
| 4895 | ||
| 4896 | ||
| 15884 | 4897 | static void mw_prpl_rename_group(PurpleConnection *gc, |
| 10977 | 4898 | const char *old, |
| 15884 | 4899 | PurpleGroup *group, |
| 10977 | 4900 | GList *buddies) { |
| 4901 | ||
|
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
|
4902 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4903 | g_return_if_fail(pd != NULL); |
| 4904 | ||
| 4905 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4906 | the server copy. Also, having this function should prevent all | |
| 4907 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4908 | give a crap what the group is named in Purple other than to record |
| 10977 | 4909 | that as the group name/alias */ |
| 4910 | ||
| 4911 | blist_schedule(pd); | |
| 4912 | } | |
| 4913 | ||
| 4914 | ||
| 15884 | 4915 | static void mw_prpl_buddy_free(PurpleBuddy *buddy) { |
| 10977 | 4916 | /* I don't think we have any cleanup for buddies yet */ |
| 4917 | ; | |
| 4918 | } | |
| 4919 | ||
| 4920 | ||
| 15884 | 4921 | 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
|
4922 | struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4923 | struct mwServiceIm *srvc; |
| 4924 | struct mwConversation *conv; | |
| 4925 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4926 | ||
| 4927 | g_return_if_fail(pd != NULL); | |
| 4928 | ||
| 4929 | srvc = pd->srvc_im; | |
| 4930 | g_return_if_fail(srvc != NULL); | |
| 4931 | ||
| 4932 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 4933 | if(! conv) return; | |
| 4934 | ||
| 4935 | if(mwConversation_isOpen(conv)) | |
| 4936 | mwConversation_free(conv); | |
| 4937 | } | |
| 4938 | ||
| 4939 | ||
| 15884 | 4940 | static const char *mw_prpl_normalize(const PurpleAccount *account, |
| 10977 | 4941 | const char *id) { |
| 4942 | ||
| 4943 | /* code elsewhere assumes that the return value points to different | |
| 4944 | memory than the passed value, but it won't free the normalized | |
| 4945 | data. wtf? */ | |
| 4946 | ||
| 4947 | 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
|
4948 | g_strlcpy(buf, id, sizeof(buf)); |
| 10977 | 4949 | return buf; |
| 4950 | } | |
| 4951 | ||
| 4952 | ||
| 15884 | 4953 | static void mw_prpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { |
| 4954 | struct mwPurplePluginData *pd; | |
| 10977 | 4955 | struct mwAwareList *list; |
| 4956 | ||
|
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
|
4957 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4958 | g_return_if_fail(pd != NULL); |
| 4959 | g_return_if_fail(pd->group_list_map != NULL); | |
| 4960 | ||
| 4961 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 4962 | ||
| 4963 | if(list) { | |
| 4964 | g_hash_table_remove(pd->group_list_map, list); | |
| 4965 | g_hash_table_remove(pd->group_list_map, group); | |
| 4966 | mwAwareList_free(list); | |
| 4967 | ||
| 4968 | blist_schedule(pd); | |
| 4969 | } | |
| 4970 | } | |
| 4971 | ||
| 4972 | ||
| 15884 | 4973 | static gboolean mw_prpl_can_receive_file(PurpleConnection *gc, |
| 10977 | 4974 | const char *who) { |
| 15884 | 4975 | struct mwPurplePluginData *pd; |
| 10977 | 4976 | struct mwServiceAware *srvc; |
| 15884 | 4977 | PurpleAccount *acct; |
| 10977 | 4978 | |
| 4979 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 4980 | ||
|
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
|
4981 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4982 | g_return_val_if_fail(pd != NULL, FALSE); |
| 4983 | ||
| 4984 | srvc = pd->srvc_aware; | |
| 4985 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4986 | |
| 15884 | 4987 | acct = purple_connection_get_account(gc); |
| 10977 | 4988 | g_return_val_if_fail(acct != NULL, FALSE); |
| 4989 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4990 | return purple_blist_find_buddy(acct, who) && |
| 10977 | 4991 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 4992 | } | |
| 4993 | ||
| 4994 | ||
| 15884 | 4995 | static void ft_outgoing_init(PurpleXfer *xfer) { |
| 4996 | PurpleAccount *acct; | |
| 4997 | PurpleConnection *gc; | |
| 4998 | ||
| 4999 | struct mwPurplePluginData *pd; | |
| 10977 | 5000 | struct mwServiceFileTransfer *srvc; |
| 5001 | struct mwFileTransfer *ft; | |
| 5002 | ||
| 5003 | const char *filename; | |
| 5004 | gsize filesize; | |
| 5005 | FILE *fp; | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5006 | char *remote_user = NULL; |
| 10977 | 5007 | |
| 5008 | struct mwIdBlock idb = { NULL, NULL }; | |
| 5009 | ||
| 5010 | DEBUG_INFO("ft_outgoing_init\n"); | |
| 5011 | ||
| 15884 | 5012 | acct = purple_xfer_get_account(xfer); |
| 5013 | 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
|
5014 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5015 | srvc = pd->srvc_ft; |
| 5016 | ||
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5017 | 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
|
5018 | |
| 15884 | 5019 | filename = purple_xfer_get_local_filename(xfer); |
| 5020 | 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
|
5021 | idb.user = remote_user; |
| 10977 | 5022 | |
| 15884 | 5023 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5024 | |
| 10977 | 5025 | /* test that we can actually send the file */ |
| 5026 | fp = g_fopen(filename, "rb"); | |
| 5027 | if(! fp) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5028 | 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
|
5029 | filename, g_strerror(errno)); |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
5030 | purple_xfer_error(purple_xfer_get_xfer_type(xfer), acct, purple_xfer_get_remote_user(xfer), msg); |
| 10977 | 5031 | g_free(msg); |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5032 | g_free(remote_user); |
| 10977 | 5033 | return; |
| 5034 | } | |
| 5035 | fclose(fp); | |
| 5036 | ||
| 5037 | { | |
| 5038 | char *tmp = strrchr(filename, G_DIR_SEPARATOR); | |
| 5039 | if(tmp++) filename = tmp; | |
| 5040 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5041 | |
| 10977 | 5042 | ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); |
| 5043 | ||
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
5044 | g_object_ref(xfer); |
|
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
5045 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) g_object_unref); |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
5046 | purple_xfer_set_protocol_data(xfer, ft); |
| 10977 | 5047 | |
| 5048 | mwFileTransfer_offer(ft); | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
5049 | g_free(remote_user); |
| 10977 | 5050 | } |
| 5051 | ||
| 5052 | ||
| 15884 | 5053 | 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
|
5054 | struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5055 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5056 | DEBUG_INFO("ft_outgoing_cancel called\n"); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
5057 | |
| 10977 | 5058 | if(ft) mwFileTransfer_cancel(ft); |
| 5059 | } | |
| 5060 | ||
| 5061 | ||
| 15884 | 5062 | static PurpleXfer *mw_prpl_new_xfer(PurpleConnection *gc, const char *who) { |
| 5063 | PurpleAccount *acct; | |
| 5064 | PurpleXfer *xfer; | |
| 5065 | ||
| 5066 | acct = purple_connection_get_account(gc); | |
| 5067 | ||
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34920
diff
changeset
|
5068 | xfer = purple_xfer_new(acct, PURPLE_XFER_TYPE_SEND, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5069 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5070 | { |
| 15884 | 5071 | purple_xfer_set_init_fnc(xfer, ft_outgoing_init); |
| 5072 | purple_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5073 | } |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
5074 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5075 | return xfer; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5076 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5077 | |
| 15884 | 5078 | static void mw_prpl_send_file(PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5079 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5080 | |
| 15884 | 5081 | PurpleXfer *xfer = mw_prpl_new_xfer(gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
5082 | |
| 10977 | 5083 | if(file) { |
| 5084 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 5085 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 5086 | |
| 5087 | } else { | |
| 5088 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 5089 | purple_xfer_request(xfer); |
| 10977 | 5090 | } |
| 5091 | } | |
| 5092 | ||
| 5093 | ||
| 15884 | 5094 | 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
|
5095 | 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
|
5096 | 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
|
5097 | 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
|
5098 | 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
|
5099 | 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
|
5100 | 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
|
5101 | 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
|
5102 | 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
|
5103 | 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
|
5104 | 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
|
5105 | 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
|
5106 | 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
|
5107 | 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
|
5108 | 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
|
5109 | 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
|
5110 | 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
|
5111 | 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
|
5112 | 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
|
5113 | 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
|
5114 | 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
|
5115 | 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
|
5116 | 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
|
5117 | 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
|
5118 | 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
|
5119 | 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
|
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_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
|
5122 | 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
|
5123 | 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
|
5124 | 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
|
5125 | 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
|
5126 | 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
|
5127 | 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
|
5128 | 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
|
5129 | 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
|
5130 | 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
|
5131 | 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
|
5132 | 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
|
5133 | 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
|
5134 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5135 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5136 | 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
|
5137 | 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
|
5138 | 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
|
5139 | 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
|
5140 | 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
|
5141 | 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
|
5142 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5143 | mw_prpl_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
|
5144 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5145 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5146 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5147 | 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
|
5148 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5149 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5150 | 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
|
5151 | 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
|
5152 | 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
|
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 | 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
|
5160 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5161 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5162 | NULL, |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5163 | 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, |
|
34312
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34297
diff
changeset
|
5165 | NULL, |
|
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
|
5166 | NULL |
| 10977 | 5167 | }; |
| 5168 | ||
|
34297
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
5169 | #if 0 |
| 15884 | 5170 | static PurplePluginPrefFrame * |
| 5171 | mw_plugin_get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 5172 | PurplePluginPrefFrame *frame; | |
| 5173 | PurplePluginPref *pref; | |
| 5174 | ||
| 5175 | frame = purple_plugin_pref_frame_new(); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5176 | |
| 15884 | 5177 | pref = purple_plugin_pref_new_with_label(_("Remotely Stored Buddy List")); |
| 5178 | purple_plugin_pref_frame_add(frame, pref); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5179 | |
| 10977 | 5180 | |
| 15884 | 5181 | pref = purple_plugin_pref_new_with_name(MW_PRPL_OPT_BLIST_ACTION); |
| 5182 | purple_plugin_pref_set_label(pref, _("Buddy List Storage Mode")); | |
| 5183 | ||
| 5184 | purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE); | |
| 5185 | 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
|
5186 | GINT_TO_POINTER(blist_choice_LOCAL)); |
| 15884 | 5187 | 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
|
5188 | GINT_TO_POINTER(blist_choice_MERGE)); |
| 15884 | 5189 | 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
|
5190 | GINT_TO_POINTER(blist_choice_STORE)); |
| 15884 | 5191 | 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
|
5192 | GINT_TO_POINTER(blist_choice_SYNCH)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5193 | |
| 15884 | 5194 | purple_plugin_pref_frame_add(frame, pref); |
| 10977 | 5195 | |
| 5196 | return frame; | |
| 5197 | } | |
|
34297
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
5198 | #endif |
| 10977 | 5199 | |
| 15884 | 5200 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5201 | struct mwSametimeList *l; |
| 5202 | ||
| 5203 | FILE *file; | |
| 5204 | char buf[BUF_LEN]; | |
| 5205 | size_t len; | |
| 5206 | ||
| 5207 | GString *str; | |
| 5208 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5209 | file = g_fopen(filename, "r"); |
| 10977 | 5210 | g_return_if_fail(file != NULL); |
| 5211 | ||
| 5212 | str = g_string_new(NULL); | |
| 5213 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 5214 | g_string_append_len(str, buf, len); | |
| 5215 | } | |
| 5216 | ||
| 5217 | fclose(file); | |
| 5218 | ||
| 5219 | l = mwSametimeList_load(str->str); | |
| 5220 | g_string_free(str, TRUE); | |
| 5221 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5222 | blist_merge(gc, l); |
| 10977 | 5223 | mwSametimeList_free(l); |
| 5224 | } | |
| 5225 | ||
| 5226 | ||
| 5227 | /** prompts for a file to import blist from */ | |
| 15884 | 5228 | static void st_import_action(PurplePluginAction *act) { |
| 5229 | PurpleConnection *gc; | |
| 5230 | PurpleAccount *account; | |
| 10977 | 5231 | char *title; |
| 5232 | ||
| 5233 | gc = act->context; | |
| 15884 | 5234 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5235 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 5236 | purple_account_get_username(account)); |
| 5237 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5238 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 5239 | G_CALLBACK(st_import_action_cb), NULL, |
|
34333
b92698241603
Request API refactoring: switch purple_request_file to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
5240 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5241 | gc); |
| 10977 | 5242 | |
| 5243 | g_free(title); | |
| 5244 | } | |
| 5245 | ||
| 5246 | ||
| 15884 | 5247 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5248 | struct mwSametimeList *l; |
| 5249 | char *str; | |
| 5250 | FILE *file; | |
| 5251 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5252 | file = g_fopen(filename, "w"); |
| 10977 | 5253 | g_return_if_fail(file != NULL); |
| 5254 | ||
| 5255 | l = mwSametimeList_new(); | |
| 5256 | blist_export(gc, l); | |
| 5257 | str = mwSametimeList_store(l); | |
| 5258 | mwSametimeList_free(l); | |
| 5259 | ||
| 5260 | fprintf(file, "%s", str); | |
| 5261 | fclose(file); | |
| 5262 | ||
| 5263 | g_free(str); | |
| 5264 | } | |
| 5265 | ||
| 5266 | ||
| 5267 | /** prompts for a file to export blist to */ | |
| 15884 | 5268 | static void st_export_action(PurplePluginAction *act) { |
| 5269 | PurpleConnection *gc; | |
| 5270 | PurpleAccount *account; | |
| 10977 | 5271 | char *title; |
| 5272 | ||
| 5273 | gc = act->context; | |
| 15884 | 5274 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5275 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 5276 | purple_account_get_username(account)); |
| 5277 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5278 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 5279 | G_CALLBACK(st_export_action_cb), NULL, |
|
34333
b92698241603
Request API refactoring: switch purple_request_file to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
5280 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5281 | gc); |
| 10977 | 5282 | |
| 5283 | g_free(title); | |
| 5284 | } | |
| 5285 | ||
| 5286 | ||
| 5287 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 5288 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5289 | |
| 15884 | 5290 | 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
|
5291 | GList *l; |
| 10977 | 5292 | |
| 15884 | 5293 | f = purple_request_fields_get_field(fields, "group"); |
| 5294 | l = purple_request_field_list_get_items(f); | |
| 10977 | 5295 | |
| 5296 | for(; l; l = l->next) { | |
| 5297 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5298 | struct named_id *res; |
| 10977 | 5299 | |
| 15884 | 5300 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5301 | |
| 5302 | g_free(res->id); | |
| 5303 | g_free(res->name); | |
| 5304 | g_free(res); | |
| 5305 | } | |
| 5306 | } | |
| 5307 | ||
| 5308 | ||
| 15884 | 5309 | static void remote_group_done(struct mwPurplePluginData *pd, |
| 10977 | 5310 | const char *id, const char *name) { |
| 15884 | 5311 | PurpleConnection *gc; |
| 5312 | PurpleAccount *acct; | |
| 5313 | PurpleGroup *group; | |
| 5314 | PurpleBlistNode *gn; | |
| 10977 | 5315 | const char *owner; |
| 5316 | ||
| 5317 | g_return_if_fail(pd != NULL); | |
| 5318 | ||
| 5319 | gc = pd->gc; | |
| 15884 | 5320 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5321 | |
| 10977 | 5322 | /* collision checking */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
5323 | group = purple_blist_find_group(name); |
| 10977 | 5324 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5325 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5326 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5327 | char *msg; |
| 10977 | 5328 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5329 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5330 | 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
|
5331 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5332 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5333 | purple_notify_error(gc, _("Unable to add group"), msgA, msg, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5334 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5335 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5336 | g_free(msg); |
| 10977 | 5337 | return; |
| 5338 | } | |
| 5339 | ||
| 15884 | 5340 | group = purple_group_new(name); |
| 5341 | gn = (PurpleBlistNode *) group; | |
| 5342 | ||
| 5343 | owner = purple_account_get_username(acct); | |
| 5344 | ||
| 5345 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 5346 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 5347 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 5348 | purple_blist_add_group(group, NULL); | |
| 10977 | 5349 | |
| 5350 | group_add(pd, group); | |
| 5351 | blist_schedule(pd); | |
| 5352 | } | |
| 5353 | ||
| 5354 | ||
| 15884 | 5355 | static void remote_group_multi_cb(struct mwPurplePluginData *pd, |
| 5356 | PurpleRequestFields *fields) { | |
| 5357 | 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
|
5358 | GList *l; |
| 10977 | 5359 | |
| 15884 | 5360 | f = purple_request_fields_get_field(fields, "group"); |
| 5361 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 5362 | |
| 5363 | if(l) { | |
| 5364 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5365 | struct named_id *res; |
| 10977 | 5366 | |
| 15884 | 5367 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5368 | remote_group_done(pd, res->id, res->name); |
| 5369 | } | |
| 5370 | ||
| 5371 | remote_group_multi_cleanup(NULL, fields); | |
| 5372 | } | |
| 5373 | ||
| 5374 | ||
| 5375 | static void remote_group_multi(struct mwResolveResult *result, | |
| 15884 | 5376 | struct mwPurplePluginData *pd) { |
| 5377 | ||
| 5378 | PurpleRequestFields *fields; | |
| 5379 | PurpleRequestFieldGroup *g; | |
| 5380 | PurpleRequestField *f; | |
| 10977 | 5381 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5382 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5383 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5384 | char *msg; |
| 10977 | 5385 | |
| 15884 | 5386 | PurpleConnection *gc = pd->gc; |
| 5387 | ||
| 5388 | fields = purple_request_fields_new(); | |
| 5389 | ||
| 5390 | g = purple_request_field_group_new(NULL); | |
| 5391 | purple_request_fields_add_group(fields, g); | |
| 5392 | ||
| 5393 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 5394 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 5395 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 5396 | |
| 5397 | for(l = result->matches; l; l = l->next) { | |
| 5398 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5399 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 5400 | |
| 5401 | res->id = g_strdup(match->id); | |
| 5402 | res->name = g_strdup(match->name); | |
| 5403 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
5404 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 5405 | } |
| 5406 | ||
| 15884 | 5407 | purple_request_field_group_add_field(g, f); |
| 10977 | 5408 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5409 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5410 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 5411 | " Notes Address Book groups. Please select the correct group from" |
| 5412 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5413 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 5414 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5415 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5416 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5417 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5418 | _("Cancel"), G_CALLBACK(remote_group_multi_cleanup), |
|
34332
876483829700
Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
5419 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5420 | pd); |
| 10977 | 5421 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5422 | g_free(msg); |
| 10977 | 5423 | } |
| 5424 | ||
| 5425 | ||
| 5426 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 5427 | guint32 id, guint32 code, GList *results, | |
| 5428 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5429 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5430 | struct mwResolveResult *res = NULL; |
| 10977 | 5431 | struct mwSession *session; |
| 15884 | 5432 | struct mwPurplePluginData *pd; |
| 5433 | PurpleConnection *gc; | |
| 10977 | 5434 | |
| 5435 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5436 | g_return_if_fail(session != NULL); | |
| 5437 | ||
| 5438 | pd = mwSession_getClientData(session); | |
| 5439 | g_return_if_fail(pd != NULL); | |
| 5440 | ||
| 5441 | gc = pd->gc; | |
| 5442 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5443 | |
| 10977 | 5444 | if(!code && results) { |
| 5445 | res = results->data; | |
| 5446 | ||
| 5447 | if(res->matches) { | |
| 5448 | remote_group_multi(res, pd); | |
| 5449 | return; | |
| 5450 | } | |
| 5451 | } | |
| 5452 | ||
| 5453 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5454 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5455 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5456 | char *msg; |
| 10977 | 5457 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5458 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5459 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5460 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5461 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5462 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5463 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5464 | purple_notify_error(gc, _("Unable to add group"), msgA, msg, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5465 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5466 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5467 | g_free(msg); |
| 10977 | 5468 | } |
| 5469 | } | |
| 5470 | ||
| 5471 | ||
| 15884 | 5472 | static void remote_group_action_cb(PurpleConnection *gc, const char *name) { |
| 5473 | struct mwPurplePluginData *pd; | |
| 10977 | 5474 | struct mwServiceResolve *srvc; |
| 5475 | GList *query; | |
| 5476 | enum mwResolveFlag flags; | |
| 5477 | guint32 req; | |
| 5478 | ||
|
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
|
5479 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5480 | srvc = pd->srvc_resolve; |
| 5481 | ||
| 5482 | query = g_list_prepend(NULL, (char *) name); | |
| 5483 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5484 | |
| 10977 | 5485 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5486 | NULL, NULL); | |
| 5487 | g_list_free(query); | |
| 5488 | ||
| 5489 | if(req == SEARCH_ERROR) { | |
| 5490 | /** @todo display error */ | |
| 5491 | } | |
| 5492 | } | |
| 5493 | ||
| 5494 | ||
| 15884 | 5495 | static void remote_group_action(PurplePluginAction *act) { |
| 5496 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5497 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5498 | const char *msgB; |
| 10977 | 5499 | |
| 5500 | gc = act->context; | |
| 5501 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5502 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5503 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5504 | " to add the group and its members to your buddy list."); |
| 5505 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5506 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5507 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5508 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5509 | _("Cancel"), NULL, |
|
34329
ddbc1337332c
Request API refactoring: introduce PurpleRequestCommonParameters and switch purple_request_input to it
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
5510 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5511 | gc); |
| 10977 | 5512 | } |
| 5513 | ||
| 5514 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5515 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5516 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5517 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5518 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5519 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5520 | char *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5521 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5522 | |
| 15884 | 5523 | PurpleNotifySearchResults *sres; |
| 5524 | PurpleNotifySearchColumn *scol; | |
| 5525 | ||
| 5526 | sres = purple_notify_searchresults_new(); | |
| 5527 | ||
| 5528 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5529 | purple_notify_searchresults_column_add(sres, scol); | |
| 5530 | ||
| 5531 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5532 | purple_notify_searchresults_column_add(sres, scol); | |
| 5533 | ||
| 5534 | 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
|
5535 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5536 | |
| 15884 | 5537 | 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
|
5538 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5539 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5540 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5541 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5542 | GList *row = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5543 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5544 | if(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5545 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5546 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5547 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5548 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5549 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5550 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5551 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5552 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5553 | 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
|
5554 | " 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
|
5555 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5556 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5557 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5558 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5559 | |
| 15884 | 5560 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5561 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5562 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5563 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5564 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5565 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5566 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5567 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5568 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5569 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5570 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5571 | |
| 15884 | 5572 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5573 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5574 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5575 | if(results) res = results->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5576 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5577 | if(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5578 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5579 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5580 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5581 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5582 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5583 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5584 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5585 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5586 | 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
|
5587 | " Sametime community."); |
|
20228
ce019944d765
applied changes from 9d35dde0c779cca73548172223ba557f27d61882
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
5588 | 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
|
5589 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5590 | purple_notify_error(gc, _("No Matches"), msgA, msg, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5591 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5592 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5593 | g_free(msg); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5594 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5595 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5596 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5597 | |
| 15884 | 5598 | static void search_action_cb(PurpleConnection *gc, const char *name) { |
| 5599 | struct mwPurplePluginData *pd; | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5600 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5601 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5602 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5603 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5604 | |
|
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
|
5605 | pd = purple_connection_get_protocol_data(gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5606 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5607 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5608 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5609 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5610 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5611 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5612 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5613 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5614 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5615 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5616 | /** @todo display error */ |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5617 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5618 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5619 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5620 | |
| 15884 | 5621 | static void search_action(PurplePluginAction *act) { |
| 5622 | PurpleConnection *gc; | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5623 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5624 | const char *msgB; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5625 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5626 | gc = act->context; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5627 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5628 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5629 | msgB = _("Enter a name or partial ID in the field below to search" |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5630 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5631 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5632 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5633 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5634 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5635 | _("Cancel"), NULL, |
|
34329
ddbc1337332c
Request API refactoring: introduce PurpleRequestCommonParameters and switch purple_request_input to it
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
5636 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5637 | gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5638 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5639 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5640 | |
| 15884 | 5641 | static GList *mw_plugin_actions(PurplePlugin *plugin, gpointer context) { |
| 5642 | PurplePluginAction *act; | |
| 10977 | 5643 | GList *l = NULL; |
| 5644 | ||
| 15884 | 5645 | act = purple_plugin_action_new(_("Import Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5646 | st_import_action); |
| 10977 | 5647 | l = g_list_append(l, act); |
| 5648 | ||
| 15884 | 5649 | act = purple_plugin_action_new(_("Export Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5650 | st_export_action); |
| 10977 | 5651 | l = g_list_append(l, act); |
| 5652 | ||
| 15884 | 5653 | act = purple_plugin_action_new(_("Add Notes Address Book Group..."), |
| 10977 | 5654 | remote_group_action); |
| 5655 | l = g_list_append(l, act); | |
| 5656 | ||
| 15884 | 5657 | act = purple_plugin_action_new(_("User Search..."), |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5658 | search_action); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5659 | l = g_list_append(l, act); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5660 | |
| 10977 | 5661 | return l; |
| 5662 | } | |
| 5663 | ||
| 5664 | ||
| 15884 | 5665 | static gboolean mw_plugin_load(PurplePlugin *plugin) { |
| 10977 | 5666 | return TRUE; |
| 5667 | } | |
| 5668 | ||
| 5669 | ||
| 15884 | 5670 | static gboolean mw_plugin_unload(PurplePlugin *plugin) { |
| 10977 | 5671 | return TRUE; |
| 5672 | } | |
| 5673 | ||
| 5674 | ||
| 15884 | 5675 | static void mw_plugin_destroy(PurplePlugin *plugin) { |
| 10977 | 5676 | g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); |
| 5677 | g_log_remove_handler("meanwhile", log_handler[1]); | |
| 5678 | } | |
| 5679 | ||
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5680 | static PurplePluginInfo mw_plugin_info = |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5681 | { |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5682 | PURPLE_PLUGIN_MAGIC, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5683 | PURPLE_MAJOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5684 | PURPLE_MINOR_VERSION, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5685 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5686 | NULL, /**< ui_requirement */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5687 | 0, /**< flags */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5688 | NULL, /**< dependencies */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5689 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5690 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5691 | PLUGIN_ID, /**< id */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5692 | PLUGIN_NAME, /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20228
diff
changeset
|
5693 | DISPLAY_VERSION, /**< version */ |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5694 | PLUGIN_SUMMARY, /**< summary */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5695 | PLUGIN_DESC, /**< description */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5696 | PLUGIN_AUTHOR, /**< author */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5697 | PLUGIN_HOMEPAGE, /**< homepage */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5698 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5699 | mw_plugin_load, /**< load */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5700 | mw_plugin_unload, /**< unload */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5701 | mw_plugin_destroy, /**< destroy */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5702 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5703 | NULL, /**< ui_info */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5704 | &mw_prpl_info, /**< extra_info */ |
|
34297
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
5705 | NULL, /**< prefs_info */ |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5706 | mw_plugin_actions, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5707 | |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5708 | /* padding */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5709 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5710 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5711 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
5712 | NULL |
| 10977 | 5713 | }; |
| 5714 | ||
| 5715 | ||
| 5716 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5717 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5718 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5719 | if(! (msg && *msg)) return; |
| 10977 | 5720 | |
| 15884 | 5721 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5722 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5723 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5724 | |
| 5725 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5726 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5727 | |
| 5728 | } else { | |
| 15884 | 5729 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5730 | } |
| 5731 | } | |
| 5732 | ||
| 5733 | ||
| 15884 | 5734 | static void mw_plugin_init(PurplePlugin *plugin) { |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5735 | PurpleAccountUserSplit *split; |
| 15884 | 5736 | PurpleAccountOption *opt; |
| 10977 | 5737 | GList *l = NULL; |
| 5738 | ||
| 5739 | GLogLevelFlags logflags = | |
| 5740 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5741 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5742 | /* set up the preferences */ |
| 15884 | 5743 | purple_prefs_add_none(MW_PRPL_OPT_BASE); |
| 5744 | purple_prefs_add_int(MW_PRPL_OPT_BLIST_ACTION, BLIST_CHOICE_DEFAULT); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5745 | |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5746 | /* set up account ID as user:server */ |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5747 | split = purple_account_user_split_new(_("Server"), |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5748 | MW_PLUGIN_DEFAULT_HOST, ':'); |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5749 | mw_prpl_info.user_splits = g_list_append(mw_prpl_info.user_splits, split); |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
5750 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5751 | /* remove dead preferences */ |
| 15884 | 5752 | purple_prefs_remove(MW_PRPL_OPT_PSYCHIC); |
| 5753 | purple_prefs_remove(MW_PRPL_OPT_SAVE_DYNAMIC); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5754 | |
| 10977 | 5755 | /* port to connect to */ |
| 15884 | 5756 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
| 10977 | 5757 | MW_PLUGIN_DEFAULT_PORT); |
| 5758 | l = g_list_append(l, opt); | |
| 5759 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5760 | { /* copy the old force login setting from prefs if it's |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5761 | there. Don't delete the preference, since there may be more |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5762 | than one account that wants to check for it. */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5763 | gboolean b = FALSE; |
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12422
diff
changeset
|
5764 | const char *label = _("Force login (ignore server redirects)"); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5765 | |
| 15884 | 5766 | if(purple_prefs_exists(MW_PRPL_OPT_FORCE_LOGIN)) |
| 5767 | b = purple_prefs_get_bool(MW_PRPL_OPT_FORCE_LOGIN); | |
| 5768 | ||
| 5769 | opt = purple_account_option_bool_new(label, MW_KEY_FORCE, b); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5770 | l = g_list_append(l, opt); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5771 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5772 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5773 | /* pretend to be Sametime Connect */ |
| 15884 | 5774 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5775 | MW_KEY_FAKE_IT, FALSE); |
|
12312
470a1452d009
[gaim-migrate @ 14616]
Christopher O'Brien <siege@pidgin.im>
parents:
12311
diff
changeset
|
5776 | l = g_list_append(l, opt); |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5777 | |
| 10977 | 5778 | mw_prpl_info.protocol_options = l; |
| 5779 | l = NULL; | |
| 5780 | ||
| 15884 | 5781 | /* forward all our g_log messages to purple. Generally all the logging |
| 5782 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5783 | get caught here */ |
| 5784 | log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags, | |
| 5785 | mw_log_handler, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5786 | |
| 15884 | 5787 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5788 | log_handler[1] = g_log_set_handler("meanwhile", logflags, |
| 5789 | mw_log_handler, NULL); | |
| 5790 | } | |
| 5791 | ||
| 5792 | ||
| 15884 | 5793 | PURPLE_INIT_PLUGIN(sametime, mw_plugin_init, mw_plugin_info); |
| 10977 | 5794 | /* The End. */ |
| 5795 |