Thu, 01 Feb 2018 22:33:16 -0600
Move the MenuAction stuff to the new action.[ch] files
| 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" |
|
39479
4da996236e9b
Move the MenuAction stuff to the new action.[ch] files
Gary Kramlich <grim@reaperworld.com>
parents:
39467
diff
changeset
|
36 | #include "action.h" |
|
34570
ac513e5901eb
Rename circbuffer files to circularbuffer files to match the object name
Ankit Vani <a@nevitus.org>
parents:
34529
diff
changeset
|
37 | #include "circularbuffer.h" |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
38 | #include "conversation.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
39 | #include "debug.h" |
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
40 | #include "image-store.h" |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
41 | #include "xfer.h" |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
42 | #include "mime.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
43 | #include "notify.h" |
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
34865
diff
changeset
|
44 | #include "plugins.h" |
|
36543
a8c3fecee2d3
Renamed prpl.[ch] to protocol.[ch]
Ankit Vani <a@nevitus.org>
parents:
36541
diff
changeset
|
45 | #include "protocol.h" |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
46 | #include "request.h" |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
47 | #include "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 | ||
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
68 | static PurpleProtocol *my_protocol = NULL; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
69 | |
| 37004 | 70 | #define PROTOCOL_ID "prpl-meanwhile" |
|
36638
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
71 | #define PROTOCOL_NAME "Sametime" |
|
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
72 | |
|
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
73 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
74 | /* considering that there's no display of this information for protocols, |
| 10977 | 75 | I don't know why I even bother providing these. Oh valiant reader, |
| 76 | I do it all for you. */ | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
77 | /* scratch that, I just added it to the protocol options panel */ |
|
36985
9faafe43603e
Rename protocol plugin IDs to prpl-*
Ankit Vani <a@nevitus.org>
parents:
36984
diff
changeset
|
78 | #define PLUGIN_ID "prpl-sametime" |
|
36638
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
79 | #define PLUGIN_NAME "Sametime Protocol" |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
80 | #define PLUGIN_CATEGORY "Protocol" |
| 10977 | 81 | #define PLUGIN_SUMMARY "Sametime Protocol Plugin" |
| 82 | #define PLUGIN_DESC "Open implementation of a Lotus Sametime client" | |
| 83 | #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/" | |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
84 | #define PLUGIN_AUTHORS \ |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
85 | { "Christopher (siege) O'Brien <siege@preoccupied.net>", NULL } |
| 10977 | 86 | |
| 87 | ||
| 88 | /* plugin preference names */ | |
| 36984 | 89 | #define MW_PROTOCOL_OPT_BASE "/plugins/prpl/meanwhile" |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
90 | #define MW_PROTOCOL_OPT_BLIST_ACTION MW_PROTOCOL_OPT_BASE "/blist_action" |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
91 | #define MW_PROTOCOL_OPT_PSYCHIC MW_PROTOCOL_OPT_BASE "/psychic" |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
92 | #define MW_PROTOCOL_OPT_FORCE_LOGIN MW_PROTOCOL_OPT_BASE "/force_login" |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
93 | #define MW_PROTOCOL_OPT_SAVE_DYNAMIC MW_PROTOCOL_OPT_BASE "/save_dynamic" |
| 10977 | 94 | |
| 95 | ||
| 96 | /* stages of connecting-ness */ | |
|
13779
410869639392
[gaim-migrate @ 16189]
Christopher O'Brien <siege@pidgin.im>
parents:
13713
diff
changeset
|
97 | #define MW_CONNECT_STEPS 11 |
| 10977 | 98 | |
| 99 | ||
| 100 | /* stages of conciousness */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
101 | #define MW_STATE_OFFLINE "offline" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
102 | #define MW_STATE_ACTIVE "active" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
103 | #define MW_STATE_AWAY "away" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
104 | #define MW_STATE_BUSY "dnd" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
105 | #define MW_STATE_MESSAGE "message" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
106 | #define MW_STATE_ENLIGHTENED "buddha" |
| 10977 | 107 | |
| 108 | ||
| 109 | /* keys to get/set chat information */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
110 | #define CHAT_KEY_CREATOR "chat.creator" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
111 | #define CHAT_KEY_NAME "chat.name" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
112 | #define CHAT_KEY_TOPIC "chat.topic" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
113 | #define CHAT_KEY_INVITE "chat.invite" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
114 | #define CHAT_KEY_IS_PLACE "chat.is_place" |
| 10977 | 115 | |
| 116 | ||
| 117 | /* key for associating a mwLoginType with a buddy */ | |
| 118 | #define BUDDY_KEY_CLIENT "meanwhile.client" | |
| 119 | ||
| 120 | /* store the remote alias so that we can re-create it easily */ | |
| 121 | #define BUDDY_KEY_NAME "meanwhile.shortname" | |
| 122 | ||
| 123 | /* enum mwSametimeUserType */ | |
| 124 | #define BUDDY_KEY_TYPE "meanwhile.type" | |
| 125 | ||
| 126 | ||
| 127 | /* key for the real group name for a meanwhile group */ | |
| 128 | #define GROUP_KEY_NAME "meanwhile.group" | |
| 129 | ||
| 130 | /* enum mwSametimeGroupType */ | |
| 131 | #define GROUP_KEY_TYPE "meanwhile.type" | |
| 132 | ||
| 133 | /* NAB group owning account */ | |
| 134 | #define GROUP_KEY_OWNER "meanwhile.account" | |
| 135 | ||
| 136 | /* key gtk blist uses to indicate a collapsed group */ | |
| 137 | #define GROUP_KEY_COLLAPSED "collapsed" | |
| 138 | ||
| 139 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
140 | /* verification replacement */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
141 | #define mwSession_NO_SECRET "meanwhile.no_secret" |
| 10977 | 142 | |
| 143 | ||
| 15884 | 144 | /* keys to get/set purple plugin information */ |
| 10977 | 145 | #define MW_KEY_HOST "server" |
| 146 | #define MW_KEY_PORT "port" | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
147 | #define MW_KEY_FORCE "force_login" |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
148 | #define MW_KEY_FAKE_IT "fake_client_id" |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
149 | #define MW_KEY_CLIENT "client_id_val" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
150 | #define MW_KEY_MAJOR "client_major" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
151 | #define MW_KEY_MINOR "client_minor" |
| 10977 | 152 | |
| 153 | ||
| 154 | /** number of seconds from the first blist change before a save to the | |
| 155 | storage service occurs. */ | |
| 156 | #define BLIST_SAVE_SECONDS 15 | |
| 157 | ||
| 158 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
159 | /** the possible buddy list storage settings */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
160 | enum blist_choice { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
161 | blist_choice_LOCAL = 1, /**< local only */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
162 | blist_choice_MERGE = 2, /**< merge from server */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
163 | 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
|
164 | blist_choice_SYNCH = 4 /**< sync with server */ |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
165 | }; |
| 10977 | 166 | |
| 167 | ||
| 168 | /** the default blist storage option */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
169 | #define BLIST_CHOICE_DEFAULT blist_choice_SYNCH |
| 10977 | 170 | |
| 171 | ||
| 172 | /* testing for the above */ | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
173 | #define BLIST_PREF_IS(n) (purple_prefs_get_int(MW_PROTOCOL_OPT_BLIST_ACTION)==(n)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
174 | #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
|
175 | #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
|
176 | #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
|
177 | #define BLIST_PREF_IS_SYNCH() BLIST_PREF_IS(blist_choice_SYNCH) |
| 10977 | 178 | |
| 179 | ||
| 180 | /* 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
|
181 | #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
|
182 | #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
|
183 | #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
|
184 | #define DEBUG_WARN(...) purple_debug_warning(G_LOG_DOMAIN, __VA_ARGS__) |
| 10977 | 185 | |
| 186 | ||
| 187 | /** ensure non-null strings */ | |
| 188 | #ifndef NSTR | |
| 189 | # define NSTR(str) ((str)? (str): "(null)") | |
| 190 | #endif | |
| 191 | ||
| 192 | ||
| 193 | /** calibrates distinct secure channel nomenclature */ | |
| 194 | static const unsigned char no_secret[] = { | |
| 195 | 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65, | |
| 196 | 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a, | |
| 197 | 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64, | |
| 198 | 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00, | |
| 199 | }; | |
| 200 | ||
| 201 | ||
| 202 | /** handler IDs from g_log_set_handler in mw_plugin_init */ | |
| 203 | static guint log_handler[2] = { 0, 0 }; | |
| 204 | ||
| 205 | ||
| 15884 | 206 | /** 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
|
207 | available as purple_connection_get_protocol_data(gc) and mwSession_getClientData */ |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
208 | struct mwPurpleProtocolData { |
| 10977 | 209 | struct mwSession *session; |
| 210 | ||
| 211 | struct mwServiceAware *srvc_aware; | |
| 212 | struct mwServiceConference *srvc_conf; | |
| 213 | struct mwServiceFileTransfer *srvc_ft; | |
| 214 | struct mwServiceIm *srvc_im; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
215 | struct mwServicePlace *srvc_place; |
| 10977 | 216 | struct mwServiceResolve *srvc_resolve; |
| 217 | struct mwServiceStorage *srvc_store; | |
| 218 | ||
| 15884 | 219 | /** map of PurpleGroup:mwAwareList and mwAwareList:PurpleGroup */ |
| 10977 | 220 | GHashTable *group_list_map; |
| 221 | ||
| 222 | /** event id for the buddy list save callback */ | |
| 223 | guint save_event; | |
| 224 | ||
| 225 | /** socket fd */ | |
| 226 | int socket; | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
227 | guint inpa; /* input watcher */ |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
228 | gint outpa; /* like inpa, but the other way */ |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
229 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
230 | /** circular buffer for outgoing data */ |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
231 | PurpleCircularBuffer *sock_buf; |
| 15884 | 232 | |
| 233 | PurpleConnection *gc; | |
| 10977 | 234 | }; |
| 235 | ||
| 236 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
237 | typedef struct { |
| 15884 | 238 | PurpleBuddy *buddy; |
| 239 | PurpleGroup *group; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
240 | } BuddyAddData; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
241 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
242 | |
| 10977 | 243 | /* blist and aware functions */ |
| 244 | ||
| 15884 | 245 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist); |
| 246 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
247 | static void blist_store(struct mwPurpleProtocolData *pd); |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
248 | |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
249 | static void blist_schedule(struct mwPurpleProtocolData *pd); |
| 15884 | 250 | |
| 251 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 252 | ||
| 253 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 254 | ||
| 255 | static gboolean buddy_is_external(PurpleBuddy *b); | |
| 256 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
257 | static void buddy_add(struct mwPurpleProtocolData *pd, PurpleBuddy *buddy); |
| 15884 | 258 | |
| 259 | static PurpleBuddy * | |
| 260 | buddy_ensure(PurpleConnection *gc, PurpleGroup *group, | |
| 10977 | 261 | struct mwSametimeUser *stuser); |
| 262 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
263 | static void group_add(struct mwPurpleProtocolData *pd, PurpleGroup *group); |
| 15884 | 264 | |
| 265 | static PurpleGroup * | |
| 266 | group_ensure(PurpleConnection *gc, struct mwSametimeGroup *stgroup); | |
| 10977 | 267 | |
| 268 | static struct mwAwareList * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
269 | list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group); |
| 10977 | 270 | |
| 271 | ||
| 272 | /* session functions */ | |
| 273 | ||
| 274 | static struct mwSession * | |
| 15884 | 275 | gc_to_session(PurpleConnection *gc); |
| 276 | ||
| 277 | static PurpleConnection *session_to_gc(struct mwSession *session); | |
| 10977 | 278 | |
| 279 | ||
| 280 | /* conference functions */ | |
| 281 | ||
| 282 | static struct mwConference * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
283 | conf_find_by_id(struct mwPurpleProtocolData *pd, int id); |
| 10977 | 284 | |
| 285 | ||
| 286 | /* conversation functions */ | |
| 287 | ||
| 288 | struct convo_msg { | |
| 289 | enum mwImSendType type; | |
| 290 | gpointer data; | |
| 291 | GDestroyNotify clear; | |
| 292 | }; | |
| 293 | ||
| 294 | ||
| 295 | struct convo_data { | |
| 296 | struct mwConversation *conv; | |
| 297 | GList *queue; /**< outgoing message queue, list of convo_msg */ | |
| 298 | }; | |
| 299 | ||
| 300 | static void convo_data_new(struct mwConversation *conv); | |
| 301 | ||
| 302 | static void convo_data_free(struct convo_data *conv); | |
| 303 | ||
| 304 | static void convo_features(struct mwConversation *conv); | |
| 305 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
306 | static PurpleIMConversation *convo_get_im(struct mwConversation *conv); |
| 10977 | 307 | |
| 308 | ||
|
12629
14aae7d5da6b
[gaim-migrate @ 14965]
Richard Laager <rlaager@pidgin.im>
parents:
12624
diff
changeset
|
309 | /* name and id */ |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
310 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
311 | struct named_id { |
| 10977 | 312 | char *id; |
| 313 | char *name; | |
| 314 | }; | |
| 315 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
316 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
317 | /* connection functions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
318 | |
|
14178
d12b287697c9
[gaim-migrate @ 16750]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
319 | 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
|
320 | |
| 10977 | 321 | |
| 322 | /* ----- session ------ */ | |
| 323 | ||
| 324 | ||
| 15884 | 325 | /** resolves a mwSession from a PurpleConnection */ |
| 326 | static struct mwSession *gc_to_session(PurpleConnection *gc) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
327 | struct mwPurpleProtocolData *pd; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
328 | |
| 10977 | 329 | g_return_val_if_fail(gc != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
330 | |
|
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
|
331 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 332 | g_return_val_if_fail(pd != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
333 | |
| 10977 | 334 | return pd->session; |
| 335 | } | |
| 336 | ||
| 337 | ||
| 15884 | 338 | /** resolves a PurpleConnection from a mwSession */ |
| 339 | static PurpleConnection *session_to_gc(struct mwSession *session) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
340 | struct mwPurpleProtocolData *pd; |
| 10977 | 341 | |
| 342 | g_return_val_if_fail(session != NULL, NULL); | |
| 343 | ||
| 344 | pd = mwSession_getClientData(session); | |
| 345 | g_return_val_if_fail(pd != NULL, NULL); | |
| 346 | ||
| 347 | return pd->gc; | |
| 348 | } | |
| 349 | ||
| 350 | ||
| 15884 | 351 | static void write_cb(gpointer data, gint source, PurpleInputCondition cond) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
352 | struct mwPurpleProtocolData *pd = data; |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
353 | PurpleCircularBuffer *circ = pd->sock_buf; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
354 | gsize avail; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
355 | int ret; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
356 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
357 | DEBUG_INFO("write_cb\n"); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
358 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
359 | g_return_if_fail(circ != NULL); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
360 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
361 | avail = purple_circular_buffer_get_max_read(circ); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
362 | if(BUF_LONG < avail) avail = BUF_LONG; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
363 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
364 | while(avail) { |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
365 | 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
|
366 | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
367 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
368 | break; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
369 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
370 | purple_circular_buffer_mark_read(circ, ret); |
|
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
371 | avail = purple_circular_buffer_get_max_read(circ); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
372 | if(BUF_LONG < avail) avail = BUF_LONG; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
373 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
374 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
375 | if(! avail) { |
| 15884 | 376 | purple_input_remove(pd->outpa); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
377 | pd->outpa = 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
378 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
379 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
380 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
381 | |
| 10977 | 382 | static int mw_session_io_write(struct mwSession *session, |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
383 | const guchar *buf, gsize len) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
384 | struct mwPurpleProtocolData *pd; |
|
22709
6bd336964410
Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
385 | gssize ret = 0; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
386 | int err = 0; |
| 10977 | 387 | |
| 388 | pd = mwSession_getClientData(session); | |
| 389 | ||
| 390 | /* socket was already closed. */ | |
| 391 | if(pd->socket == 0) | |
| 392 | return 1; | |
| 393 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
394 | if(pd->outpa) { |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
395 | 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
|
396 | purple_circular_buffer_append(pd->sock_buf, buf, len); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
397 | return 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
398 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
399 | |
| 10977 | 400 | while(len) { |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
401 | 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
|
402 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
403 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
404 | break; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
405 | |
| 10977 | 406 | len -= ret; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
407 | buf += ret; |
| 10977 | 408 | } |
| 409 | ||
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
410 | if(ret <= 0) |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
411 | err = errno; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
412 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
413 | if(err == EAGAIN) { |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
414 | /* append remainder to circular buffer */ |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
415 | DEBUG_INFO("EAGAIN\n"); |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
34148
diff
changeset
|
416 | purple_circular_buffer_append(pd->sock_buf, buf, len); |
| 15884 | 417 | 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
|
418 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
419 | } else if(len > 0) { |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
420 | 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
|
421 | g_strerror(errno)); |
|
22709
6bd336964410
Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
422 | 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
|
423 | " 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
|
424 | purple_connection_error(pd->gc, |
| 21279 | 425 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
426 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
427 | g_free(tmp); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
428 | |
| 10977 | 429 | return -1; |
| 430 | } | |
| 431 | ||
| 432 | return 0; | |
| 433 | } | |
| 434 | ||
| 435 | ||
| 436 | static void mw_session_io_close(struct mwSession *session) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
437 | struct mwPurpleProtocolData *pd; |
| 10977 | 438 | |
| 439 | pd = mwSession_getClientData(session); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
440 | g_return_if_fail(pd != NULL); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
441 | |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
442 | if(pd->outpa) { |
| 15884 | 443 | purple_input_remove(pd->outpa); |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
444 | pd->outpa = 0; |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
445 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
446 | |
| 10977 | 447 | if(pd->socket) { |
| 448 | close(pd->socket); | |
| 449 | pd->socket = 0; | |
| 450 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
451 | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
452 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
453 | 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
|
454 | pd->inpa = 0; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
455 | } |
| 10977 | 456 | } |
| 457 | ||
| 458 | ||
| 459 | static void mw_session_clear(struct mwSession *session) { | |
| 460 | ; /* nothing for now */ | |
| 461 | } | |
| 462 | ||
| 463 | ||
| 464 | /* ----- aware list ----- */ | |
| 465 | ||
| 466 | ||
| 467 | static void blist_resolve_alias_cb(struct mwServiceResolve *srvc, | |
| 468 | guint32 id, guint32 code, GList *results, | |
| 469 | gpointer data) { | |
| 470 | struct mwResolveResult *result; | |
| 471 | struct mwResolveMatch *match; | |
| 472 | ||
| 473 | g_return_if_fail(results != NULL); | |
| 474 | ||
| 475 | result = results->data; | |
| 476 | g_return_if_fail(result != NULL); | |
| 477 | g_return_if_fail(result->matches != NULL); | |
| 478 | ||
| 479 | match = result->matches->data; | |
| 480 | g_return_if_fail(match != NULL); | |
| 481 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
482 | purple_buddy_set_server_alias(data, match->name); |
| 15884 | 483 | purple_blist_node_set_string(data, BUDDY_KEY_NAME, match->name); |
| 10977 | 484 | } |
| 485 | ||
| 486 | ||
| 487 | static void mw_aware_list_on_aware(struct mwAwareList *list, | |
| 488 | struct mwAwareSnapshot *aware) { | |
| 489 | ||
| 15884 | 490 | PurpleConnection *gc; |
| 491 | PurpleAccount *acct; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
492 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
493 | struct mwPurpleProtocolData *pd; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
494 | guint32 idle; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
495 | guint stat; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
496 | const char *id; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
497 | const char *status = MW_STATE_ACTIVE; |
| 10977 | 498 | |
| 499 | gc = mwAwareList_getClientData(list); | |
| 15884 | 500 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
501 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
502 | pd = purple_connection_get_protocol_data(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
503 | idle = aware->status.time; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
504 | stat = aware->status.status; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
505 | id = aware->id.user; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
506 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
507 | if(idle) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
508 | guint32 idle_len; /*< how long a client has been idle */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
509 | guint32 ugly_idle_len; /*< how long a broken client has been idle */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
510 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
511 | DEBUG_INFO("%s has idle value 0x%x\n", NSTR(id), idle); |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
512 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
513 | idle_len = time(NULL) - idle; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
514 | ugly_idle_len = ((time(NULL) * 1000) - idle) / 1000; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
515 | |
|
25181
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
516 | if(idle > ugly_idle_len) |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
517 | ugly_idle_len = 0; |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
518 | else |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
519 | ugly_idle_len = (ugly_idle_len - idle) / 1000; |
|
a104228b1fce
Fix ludicrously long idle times for Sametime 7.5 buddies by assuming idle time
Laurent Montaron <lpm+pidgin.im@pobox.com>
parents:
25105
diff
changeset
|
520 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
521 | /* |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
522 | what's the deal here? Well, good clients are smart enough to |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
523 | publish their idle time by using an attribute to indicate that |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
524 | they went idle at some time UTC, in seconds since epoch. Bad |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
525 | clients use milliseconds since epoch. So we're going to compute |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
526 | the idle time for either method, then figure out the lower of |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
527 | the two and use that. Blame the ST 7.5 development team for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
528 | this. |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
529 | */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
530 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
531 | DEBUG_INFO("idle time: %u, ugly idle time: %u\n", idle_len, ugly_idle_len); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
532 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
533 | #if 1 |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
534 | if(idle_len <= ugly_idle_len) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
535 | ; /* DEBUG_INFO("sane idle value, let's use it\n"); */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
536 | } else { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
537 | idle = time(NULL) - ugly_idle_len; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
538 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
539 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
540 | #else |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
541 | if(idle < 0 || idle > time(NULL)) { |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
542 | DEBUG_INFO("hiding a messy idle value 0x%x\n", NSTR(id), idle); |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
543 | idle = -1; |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
544 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
545 | #endif |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
546 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
547 | |
| 10977 | 548 | switch(stat) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
549 | case mwStatus_ACTIVE: |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
550 | status = MW_STATE_ACTIVE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
551 | idle = 0; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
552 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
553 | |
| 10977 | 554 | case mwStatus_IDLE: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
555 | if(! idle) idle = -1; |
| 10977 | 556 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
557 | |
| 10977 | 558 | case mwStatus_AWAY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
559 | status = MW_STATE_AWAY; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
560 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
561 | |
| 10977 | 562 | case mwStatus_BUSY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
563 | status = MW_STATE_BUSY; |
| 10977 | 564 | break; |
| 565 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
566 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
567 | /* NAB group members */ |
| 10977 | 568 | if(aware->group) { |
| 15884 | 569 | PurpleGroup *group; |
| 570 | PurpleBuddy *buddy; | |
| 571 | PurpleBlistNode *bnode; | |
| 10977 | 572 | |
| 573 | group = g_hash_table_lookup(pd->group_list_map, list); | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
574 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 15884 | 575 | bnode = (PurpleBlistNode *) buddy; |
| 10977 | 576 | |
| 577 | if(! buddy) { | |
| 578 | struct mwServiceResolve *srvc; | |
| 579 | GList *query; | |
| 580 | ||
| 15884 | 581 | buddy = purple_buddy_new(acct, id, NULL); |
| 582 | purple_blist_add_buddy(buddy, NULL, group, NULL); | |
| 583 | ||
| 584 | bnode = (PurpleBlistNode *) buddy; | |
| 10977 | 585 | |
| 586 | srvc = pd->srvc_resolve; | |
| 587 | query = g_list_append(NULL, (char *) id); | |
| 588 | ||
| 589 | mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS, | |
| 590 | blist_resolve_alias_cb, buddy, NULL); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
591 | g_list_free(query); |
| 10977 | 592 | } |
| 593 | ||
| 15884 | 594 | purple_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL); |
| 10977 | 595 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
596 | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
597 | if(aware->online) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
598 | purple_protocol_got_user_status(acct, id, status, NULL); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
599 | purple_protocol_got_user_idle(acct, id, !!idle, (time_t) idle); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
600 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
601 | } else { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
602 | purple_protocol_got_user_status(acct, id, MW_STATE_OFFLINE, NULL); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
603 | } |
| 10977 | 604 | } |
| 605 | ||
| 606 | ||
| 607 | static void mw_aware_list_on_attrib(struct mwAwareList *list, | |
| 608 | struct mwAwareIdBlock *id, | |
| 609 | struct mwAwareAttribute *attrib) { | |
| 610 | ||
| 611 | ; /* nothing. We'll get attribute data as we need it */ | |
| 612 | } | |
| 613 | ||
| 614 | ||
| 615 | static void mw_aware_list_clear(struct mwAwareList *list) { | |
| 616 | ; /* nothing for now */ | |
| 617 | } | |
| 618 | ||
| 619 | ||
| 620 | static struct mwAwareListHandler mw_aware_list_handler = { | |
|
17157
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
621 | mw_aware_list_on_aware, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
622 | mw_aware_list_on_attrib, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
623 | mw_aware_list_clear, |
| 10977 | 624 | }; |
| 625 | ||
| 626 | ||
| 627 | /** Ensures that an Aware List is associated with the given group, and | |
| 628 | returns that list. */ | |
| 629 | static struct mwAwareList * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
630 | list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
631 | |
| 10977 | 632 | struct mwAwareList *list; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
633 | |
| 10977 | 634 | g_return_val_if_fail(pd != NULL, NULL); |
| 635 | g_return_val_if_fail(group != NULL, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
636 | |
| 10977 | 637 | list = g_hash_table_lookup(pd->group_list_map, group); |
| 638 | if(! list) { | |
| 639 | list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler); | |
| 640 | mwAwareList_setClientData(list, pd->gc, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
641 | |
| 10977 | 642 | mwAwareList_watchAttributes(list, |
| 643 | mwAttribute_AV_PREFS_SET, | |
| 644 | mwAttribute_MICROPHONE, | |
| 645 | mwAttribute_SPEAKERS, | |
| 646 | mwAttribute_VIDEO_CAMERA, | |
| 647 | mwAttribute_FILE_TRANSFER, | |
| 648 | NULL); | |
| 649 | ||
| 650 | g_hash_table_replace(pd->group_list_map, group, list); | |
| 651 | g_hash_table_insert(pd->group_list_map, list, group); | |
| 652 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
653 | |
| 10977 | 654 | return list; |
| 655 | } | |
| 656 | ||
| 657 | ||
| 15884 | 658 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 10977 | 659 | /* - find the account for this connection |
| 660 | - iterate through the buddy list | |
| 661 | - add each buddy matching this account to the stlist | |
| 662 | */ | |
| 663 | ||
| 15884 | 664 | PurpleAccount *acct; |
| 665 | PurpleBlistNode *gn, *cn, *bn; | |
| 666 | PurpleGroup *grp; | |
| 667 | PurpleBuddy *bdy; | |
| 10977 | 668 | |
| 669 | struct mwSametimeGroup *stg = NULL; | |
| 670 | struct mwIdBlock idb = { NULL, NULL }; | |
| 671 | ||
| 15884 | 672 | acct = purple_connection_get_account(gc); |
| 10977 | 673 | g_return_if_fail(acct != NULL); |
| 674 | ||
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
675 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
676 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 10977 | 677 | const char *owner; |
| 678 | const char *gname; | |
| 679 | enum mwSametimeGroupType gtype; | |
| 680 | gboolean gopen; | |
| 681 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
682 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 683 | grp = (PurpleGroup *) gn; |
| 10977 | 684 | |
| 685 | /* the group's type (normal or dynamic) */ | |
| 15884 | 686 | gtype = purple_blist_node_get_int(gn, GROUP_KEY_TYPE); |
| 10977 | 687 | if(! gtype) gtype = mwSametimeGroup_NORMAL; |
| 688 | ||
| 689 | /* if it's a normal group with none of our people in it, skip it */ | |
| 15884 | 690 | if(gtype == mwSametimeGroup_NORMAL && !purple_group_on_account(grp, acct)) |
| 10977 | 691 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
692 | |
| 10977 | 693 | /* if the group has an owner and we're not it, skip it */ |
| 15884 | 694 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
695 | if(owner && !purple_strequal(owner, purple_account_get_username(acct))) |
| 10977 | 696 | continue; |
| 697 | ||
| 15884 | 698 | /* the group's actual name may be different from the purple group's |
| 10977 | 699 | name. Find whichever is there */ |
| 15884 | 700 | gname = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
701 | if(! gname) gname = purple_group_get_name(grp); |
| 10977 | 702 | |
| 703 | /* we save this, but never actually honor it */ | |
| 15884 | 704 | gopen = ! purple_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); |
| 10977 | 705 | |
| 706 | stg = mwSametimeGroup_new(stlist, gtype, gname); | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
707 | mwSametimeGroup_setAlias(stg, purple_group_get_name(grp)); |
| 10977 | 708 | mwSametimeGroup_setOpen(stg, gopen); |
| 709 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
710 | /* don't attempt to put buddies in a dynamic group, it breaks |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
711 | other clients */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
712 | if(gtype == mwSametimeGroup_DYNAMIC) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
713 | continue; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
714 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
715 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
716 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
717 | cn = purple_blist_node_get_sibling_next(cn)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
718 | if(! PURPLE_IS_CONTACT(cn)) continue; |
| 10977 | 719 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
720 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
721 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
722 | bn = purple_blist_node_get_sibling_next(bn)) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
723 | 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
|
724 | if(purple_blist_node_is_transient(bn)) continue; |
| 15884 | 725 | |
| 726 | bdy = (PurpleBuddy *) bn; | |
| 10977 | 727 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
728 | if(purple_buddy_get_account(bdy) == acct) { |
| 10977 | 729 | struct mwSametimeUser *stu; |
| 730 | enum mwSametimeUserType utype; | |
| 731 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
732 | idb.user = (char *)purple_buddy_get_name(bdy); |
| 10977 | 733 | |
| 15884 | 734 | utype = purple_blist_node_get_int(bn, BUDDY_KEY_TYPE); |
| 10977 | 735 | if(! utype) utype = mwSametimeUser_NORMAL; |
| 736 | ||
| 737 | stu = mwSametimeUser_new(stg, utype, &idb); | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
738 | mwSametimeUser_setShortName(stu, purple_buddy_get_server_alias(bdy)); |
|
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
|
739 | mwSametimeUser_setAlias(stu, purple_buddy_get_local_alias(bdy)); |
| 10977 | 740 | } |
| 741 | } | |
| 742 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
743 | } |
| 10977 | 744 | } |
| 745 | ||
| 746 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
747 | static void blist_store(struct mwPurpleProtocolData *pd) { |
| 10977 | 748 | |
| 749 | struct mwSametimeList *stlist; | |
| 750 | struct mwServiceStorage *srvc; | |
| 751 | struct mwStorageUnit *unit; | |
| 752 | ||
| 15884 | 753 | PurpleConnection *gc; |
| 10977 | 754 | |
| 755 | struct mwPutBuffer *b; | |
| 756 | struct mwOpaque *o; | |
| 757 | ||
| 758 | g_return_if_fail(pd != NULL); | |
| 759 | ||
| 760 | srvc = pd->srvc_store; | |
| 761 | g_return_if_fail(srvc != NULL); | |
| 762 | ||
| 763 | gc = pd->gc; | |
| 764 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
765 | if(BLIST_PREF_IS_LOCAL() || BLIST_PREF_IS_MERGE()) { |
| 10977 | 766 | DEBUG_INFO("preferences indicate not to save remote blist\n"); |
| 767 | return; | |
| 768 | ||
| 769 | } else if(MW_SERVICE_IS_DEAD(srvc)) { | |
| 770 | DEBUG_INFO("aborting save of blist: storage service is not alive\n"); | |
| 771 | return; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
772 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
773 | } else if(BLIST_PREF_IS_STORE() || BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
774 | DEBUG_INFO("saving remote blist\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
775 | |
| 10977 | 776 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
777 | g_return_if_reached(); |
| 10977 | 778 | } |
| 779 | ||
| 780 | /* create and export to a list object */ | |
| 781 | stlist = mwSametimeList_new(); | |
| 782 | blist_export(gc, stlist); | |
| 783 | ||
| 784 | /* write it to a buffer */ | |
| 785 | b = mwPutBuffer_new(); | |
| 786 | mwSametimeList_put(b, stlist); | |
| 787 | mwSametimeList_free(stlist); | |
| 788 | ||
| 789 | /* put the buffer contents into a storage unit */ | |
| 790 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
| 791 | o = mwStorageUnit_asOpaque(unit); | |
| 792 | mwPutBuffer_finalize(o, b); | |
| 793 | ||
| 794 | /* save the storage unit to the service */ | |
| 795 | mwServiceStorage_save(srvc, unit, NULL, NULL, NULL); | |
| 796 | } | |
| 797 | ||
| 798 | ||
| 799 | static gboolean blist_save_cb(gpointer data) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
800 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 801 | |
| 802 | blist_store(pd); | |
| 803 | pd->save_event = 0; | |
| 804 | return FALSE; | |
| 805 | } | |
| 806 | ||
| 807 | ||
| 808 | /** schedules the buddy list to be saved to the server */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
809 | static void blist_schedule(struct mwPurpleProtocolData *pd) { |
| 10977 | 810 | if(pd->save_event) return; |
| 811 | ||
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
812 | pd->save_event = g_timeout_add_seconds(BLIST_SAVE_SECONDS, |
| 10977 | 813 | blist_save_cb, pd); |
| 814 | } | |
| 815 | ||
| 816 | ||
| 15884 | 817 | static gboolean buddy_is_external(PurpleBuddy *b) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
818 | g_return_val_if_fail(b != NULL, FALSE); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
819 | return purple_str_has_prefix(purple_buddy_get_name(b), "@E "); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
820 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
821 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
822 | |
| 10977 | 823 | /** Actually add a buddy to the aware service, and schedule the buddy |
| 824 | list to be saved to the server */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
825 | static void buddy_add(struct mwPurpleProtocolData *pd, |
| 15884 | 826 | PurpleBuddy *buddy) { |
| 10977 | 827 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
828 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) purple_buddy_get_name(buddy), NULL }; |
| 10977 | 829 | struct mwAwareList *list; |
| 830 | ||
| 15884 | 831 | PurpleGroup *group; |
| 10977 | 832 | GList *add; |
| 833 | ||
| 834 | add = g_list_prepend(NULL, &idb); | |
| 835 | ||
| 15884 | 836 | group = purple_buddy_get_group(buddy); |
| 10977 | 837 | list = list_ensure(pd, group); |
| 838 | ||
| 839 | if(mwAwareList_addAware(list, add)) { | |
| 15884 | 840 | purple_blist_remove_buddy(buddy); |
| 10977 | 841 | } |
| 842 | ||
| 843 | blist_schedule(pd); | |
| 844 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
845 | g_list_free(add); |
| 10977 | 846 | } |
| 847 | ||
| 848 | ||
| 15884 | 849 | /** ensure that a PurpleBuddy exists in the group with data |
| 10977 | 850 | appropriately matching the st user entry from the st list */ |
| 15884 | 851 | static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, |
| 10977 | 852 | struct mwSametimeUser *stuser) { |
| 853 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
854 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 855 | PurpleBuddy *buddy; |
| 856 | PurpleAccount *acct = purple_connection_get_account(gc); | |
| 10977 | 857 | |
| 858 | const char *id = mwSametimeUser_getUser(stuser); | |
| 859 | const char *name = mwSametimeUser_getShortName(stuser); | |
| 860 | const char *alias = mwSametimeUser_getAlias(stuser); | |
| 861 | enum mwSametimeUserType type = mwSametimeUser_getType(stuser); | |
| 862 | ||
| 863 | g_return_val_if_fail(id != NULL, NULL); | |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
864 | g_return_val_if_fail(*id, NULL); |
| 10977 | 865 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
866 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 10977 | 867 | if(! buddy) { |
| 15884 | 868 | buddy = purple_buddy_new(acct, id, alias); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
869 | |
| 15884 | 870 | purple_blist_add_buddy(buddy, NULL, group, NULL); |
| 10977 | 871 | buddy_add(pd, buddy); |
| 872 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
873 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
874 | 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
|
875 | purple_buddy_set_server_alias(buddy, name); |
| 15884 | 876 | purple_blist_node_set_string((PurpleBlistNode *) buddy, BUDDY_KEY_NAME, name); |
| 877 | purple_blist_node_set_int((PurpleBlistNode *) buddy, BUDDY_KEY_TYPE, type); | |
| 10977 | 878 | |
| 879 | return buddy; | |
| 880 | } | |
| 881 | ||
| 882 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
883 | /** add aware watch for a dynamic group */ |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
884 | static void group_add(struct mwPurpleProtocolData *pd, |
| 15884 | 885 | PurpleGroup *group) { |
| 10977 | 886 | |
| 887 | struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL }; | |
| 888 | struct mwAwareList *list; | |
| 889 | const char *n; | |
| 890 | GList *add; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
891 | |
| 15884 | 892 | n = purple_blist_node_get_string((PurpleBlistNode *) group, GROUP_KEY_NAME); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
893 | if(! n) n = purple_group_get_name(group); |
| 10977 | 894 | |
| 895 | idb.user = (char *) n; | |
| 896 | add = g_list_prepend(NULL, &idb); | |
| 897 | ||
| 898 | list = list_ensure(pd, group); | |
| 899 | mwAwareList_addAware(list, add); | |
| 900 | g_list_free(add); | |
| 901 | } | |
| 902 | ||
| 903 | ||
| 15884 | 904 | /** ensure that a PurpleGroup exists in the blist with data |
| 10977 | 905 | appropriately matching the st group entry from the st list */ |
| 15884 | 906 | static PurpleGroup *group_ensure(PurpleConnection *gc, |
| 10977 | 907 | struct mwSametimeGroup *stgroup) { |
| 15884 | 908 | PurpleAccount *acct; |
| 909 | PurpleGroup *group = NULL; | |
| 910 | PurpleBuddyList *blist; | |
| 911 | PurpleBlistNode *gn; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
912 | const char *name, *alias, *owner; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
913 | enum mwSametimeGroupType type; |
| 10977 | 914 | |
| 15884 | 915 | acct = purple_connection_get_account(gc); |
| 916 | owner = purple_account_get_username(acct); | |
| 917 | ||
|
34726
af52ff6660c0
Replaced purple_get_blist() with purple_blist_get_buddy_list()
Ankit Vani <a@nevitus.org>
parents:
34723
diff
changeset
|
918 | blist = purple_blist_get_buddy_list(); |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
919 | g_return_val_if_fail(blist != NULL, NULL); |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
920 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
921 | name = mwSametimeGroup_getName(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
922 | alias = mwSametimeGroup_getAlias(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
923 | type = mwSametimeGroup_getType(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
924 | |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
925 | if (!name) { |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
926 | DEBUG_WARN("Can't ensure a null group\n"); |
|
31991
efe4fb3772ad
Fix this compile warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
31983
diff
changeset
|
927 | return NULL; |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
928 | } |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
929 | |
|
32049
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
930 | if (!name) { |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
931 | DEBUG_WARN("Can't ensure a null group\n"); |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
932 | return NULL; |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
933 | } |
|
c51421b3224e
Fix up the Sametime prpl to play nice with Visual C++. This patch also puts
Patrick Cloke <clokep@gmail.com>
parents:
31991
diff
changeset
|
934 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
935 | DEBUG_INFO("attempting to ensure group %s, called %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
936 | NSTR(name), NSTR(alias)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
937 | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
938 | /* first attempt at finding the group, by the name key */ |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
939 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
940 | gn = purple_blist_node_get_sibling_next(gn)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
941 | const char *n, *o; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
942 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 943 | n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
| 944 | o = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
945 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
946 | DEBUG_INFO("found group named %s, owned by %s\n", NSTR(n), NSTR(o)); |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
947 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
948 | if(n && purple_strequal(n, name)) { |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
949 | if(!o || purple_strequal(o, owner)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
950 | DEBUG_INFO("that'll work\n"); |
| 15884 | 951 | group = (PurpleGroup *) gn; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
952 | break; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
953 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
954 | } |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
955 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
956 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
957 | /* try again, by alias */ |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
958 | if(! group) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
959 | DEBUG_INFO("searching for group by alias %s\n", NSTR(alias)); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
960 | group = purple_blist_find_group(alias); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
961 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
962 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
963 | /* oh well, no such group. Let's create it! */ |
| 10977 | 964 | if(! group) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
965 | DEBUG_INFO("creating group\n"); |
| 15884 | 966 | group = purple_group_new(alias); |
| 967 | purple_blist_add_group(group, NULL); | |
| 10977 | 968 | } |
| 969 | ||
| 15884 | 970 | gn = (PurpleBlistNode *) group; |
| 971 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); | |
| 972 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | |
| 10977 | 973 | |
| 974 | if(type == mwSametimeGroup_DYNAMIC) { | |
| 15884 | 975 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); |
|
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
|
976 | group_add(purple_connection_get_protocol_data(gc), group); |
| 10977 | 977 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
978 | |
| 10977 | 979 | return group; |
| 980 | } | |
| 981 | ||
| 982 | ||
| 15884 | 983 | /** merge the entries from a st list into the purple blist */ |
| 984 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist) { | |
| 10977 | 985 | struct mwSametimeGroup *stgroup; |
| 986 | struct mwSametimeUser *stuser; | |
| 987 | ||
| 15884 | 988 | PurpleGroup *group; |
| 10977 | 989 | |
| 990 | GList *gl, *gtl, *ul, *utl; | |
| 991 | ||
| 992 | gl = gtl = mwSametimeList_getGroups(stlist); | |
| 993 | for(; gl; gl = gl->next) { | |
| 994 | ||
| 995 | stgroup = (struct mwSametimeGroup *) gl->data; | |
| 996 | group = group_ensure(gc, stgroup); | |
| 997 | ||
| 998 | ul = utl = mwSametimeGroup_getUsers(stgroup); | |
| 999 | for(; ul; ul = ul->next) { | |
| 1000 | ||
| 1001 | stuser = (struct mwSametimeUser *) ul->data; | |
|
33782
1690e0b2c508
Fix a bunch of unused variables
Daniel Atallah <datallah@pidgin.im>
parents:
33745
diff
changeset
|
1002 | buddy_ensure(gc, group, stuser); |
| 10977 | 1003 | } |
| 1004 | g_list_free(utl); | |
| 1005 | } | |
| 1006 | g_list_free(gtl); | |
| 1007 | } | |
| 1008 | ||
| 1009 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1010 | /** 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
|
1011 | is left empty, remove group as well */ |
| 15884 | 1012 | static void group_clear(PurpleGroup *group, PurpleAccount *acct, gboolean del) { |
| 1013 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1014 | GList *prune = NULL; |
| 15884 | 1015 | PurpleBlistNode *gn, *cn, *bn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1016 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1017 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1018 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1019 | 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
|
1020 | |
| 15884 | 1021 | gc = purple_account_get_connection(acct); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1022 | g_return_if_fail(gc != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1023 | |
| 15884 | 1024 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1025 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1026 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1027 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1028 | 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
|
1029 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1030 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1031 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1032 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1033 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1034 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1035 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1036 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1037 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1038 | 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
|
1039 | 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
|
1040 | prune = g_list_prepend(prune, gb); |
|
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 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1043 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1044 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1045 | /* quickly unsubscribe from presence for the entire group */ |
| 15884 | 1046 | purple_account_remove_group(acct, group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1047 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1048 | /* remove blist entries that need to go */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1049 | while(prune) { |
| 15884 | 1050 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1051 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1052 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1053 | DEBUG_INFO("cleared buddies\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1054 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1055 | /* 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
|
1056 | 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
|
1057 | DEBUG_INFO("removing empty group\n"); |
| 15884 | 1058 | purple_blist_remove_group(group); |
|
11943
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 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1061 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1062 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1063 | /** prune out group members that shouldn't be there */ |
| 15884 | 1064 | static void group_prune(PurpleConnection *gc, PurpleGroup *group, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1065 | struct mwSametimeGroup *stgroup) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1066 | |
| 15884 | 1067 | PurpleAccount *acct; |
| 1068 | PurpleBlistNode *gn, *cn, *bn; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1069 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1070 | GHashTable *stusers; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1071 | GList *prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1072 | GList *ul, *utl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1073 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1074 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1075 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1076 | 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
|
1077 | |
| 15884 | 1078 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1079 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1080 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1081 | 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
|
1082 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1083 | /* 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
|
1084 | contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1085 | utl = mwSametimeGroup_getUsers(stgroup); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1086 | for(ul = utl; ul; ul = ul->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1087 | const char *id = mwSametimeUser_getUser(ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1088 | g_hash_table_insert(stusers, (char *) id, ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1089 | DEBUG_INFO("server copy has %s\n", NSTR(id)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1090 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1091 | g_list_free(utl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1092 | |
| 15884 | 1093 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1094 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1095 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1096 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1097 | 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
|
1098 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1099 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1100 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1101 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1102 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1103 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1104 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1105 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1106 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1107 | /* 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
|
1108 | them for pruning */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1109 | 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
|
1110 | 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
|
1111 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1112 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1113 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1114 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1115 | DEBUG_INFO("done marking\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1116 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1117 | g_hash_table_destroy(stusers); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1118 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1119 | if(prune) { |
| 15884 | 1120 | purple_account_remove_buddies(acct, prune, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1121 | while(prune) { |
| 15884 | 1122 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1123 | prune = g_list_delete_link(prune, prune); |
|
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 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1126 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1127 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1128 | |
| 15884 | 1129 | /** 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
|
1130 | existing buddies that aren't in the st list */ |
| 15884 | 1131 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 1132 | ||
| 1133 | PurpleAccount *acct; | |
| 1134 | PurpleBuddyList *blist; | |
| 1135 | PurpleBlistNode *gn; | |
|
11943
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 | GHashTable *stgroups; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1138 | GList *g_prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1139 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1140 | GList *gl, *gtl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1141 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1142 | const char *acct_n; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1143 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1144 | DEBUG_INFO("synchronizing local buddy list from server list\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1145 | |
| 15884 | 1146 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1147 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1148 | |
| 15884 | 1149 | acct_n = purple_account_get_username(acct); |
| 1150 | ||
|
34726
af52ff6660c0
Replaced purple_get_blist() with purple_blist_get_buddy_list()
Ankit Vani <a@nevitus.org>
parents:
34723
diff
changeset
|
1151 | blist = purple_blist_get_buddy_list(); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1152 | g_return_if_fail(blist != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1153 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1154 | /* 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
|
1155 | list, mapping group name to group structure */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1156 | 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
|
1157 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1158 | gtl = mwSametimeList_getGroups(stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1159 | for(gl = gtl; gl; gl = gl->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1160 | const char *name = mwSametimeGroup_getName(gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1161 | g_hash_table_insert(stgroups, (char *) name, gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1162 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1163 | g_list_free(gtl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1164 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1165 | /* 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
|
1166 | for(gn = purple_blist_get_root(); gn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1167 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 15884 | 1168 | PurpleGroup *grp = (PurpleGroup *) gn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1169 | const char *gname, *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1170 | struct mwSametimeGroup *stgrp; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1171 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1172 | if(! PURPLE_IS_GROUP(gn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1173 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1174 | /* group not belonging to this account */ |
| 15884 | 1175 | if(! purple_group_on_account(grp, acct)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1176 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1177 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1178 | /* dynamic group belonging to this account. don't prune contents */ |
| 15884 | 1179 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
1180 | if(owner && purple_strequal(owner, acct_n)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1181 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1182 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1183 | /* 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
|
1184 | title, which can be different things in the st list */ |
| 15884 | 1185 | 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
|
1186 | if(! gname) gname = purple_group_get_name(grp); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1187 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1188 | stgrp = g_hash_table_lookup(stgroups, gname); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1189 | if(! stgrp) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1190 | /* remove the whole group */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1191 | 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
|
1192 | g_prune = g_list_prepend(g_prune, grp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1193 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1194 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1195 | /* synch the group contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1196 | group_prune(gc, grp, stgrp); |
|
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 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1199 | DEBUG_INFO("done marking groups\n"); |
|
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 | /* don't need this anymore */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1202 | g_hash_table_destroy(stgroups); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1203 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1204 | /* prune all marked groups */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1205 | while(g_prune) { |
| 15884 | 1206 | PurpleGroup *grp = g_prune->data; |
| 1207 | PurpleBlistNode *gn = (PurpleBlistNode *) grp; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1208 | const char *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1209 | gboolean del = TRUE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1210 | |
| 15884 | 1211 | owner = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
1212 | if(owner && !purple_strequal(owner, acct_n)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1213 | /* 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
|
1214 | 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
|
1215 | del = FALSE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1216 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1217 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1218 | group_clear(g_prune->data, acct, del); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1219 | g_prune = g_list_delete_link(g_prune, g_prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1220 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1221 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1222 | /* done with the pruning, let's merge in the additions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1223 | blist_merge(gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1224 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1225 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1226 | |
| 10977 | 1227 | /** callback passed to the storage service when it's told to load the |
| 1228 | st list */ | |
| 1229 | static void fetch_blist_cb(struct mwServiceStorage *srvc, | |
| 1230 | guint32 result, struct mwStorageUnit *item, | |
| 1231 | gpointer data) { | |
| 1232 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1233 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 1234 | struct mwSametimeList *stlist; |
| 1235 | ||
| 1236 | struct mwGetBuffer *b; | |
| 1237 | ||
| 1238 | g_return_if_fail(result == ERR_SUCCESS); | |
| 1239 | ||
| 1240 | /* check our preferences for loading */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1241 | if(BLIST_PREF_IS_LOCAL()) { |
| 10977 | 1242 | DEBUG_INFO("preferences indicate not to load remote buddy list\n"); |
| 1243 | return; | |
| 1244 | } | |
| 1245 | ||
| 1246 | b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); | |
| 1247 | ||
| 1248 | stlist = mwSametimeList_new(); | |
| 1249 | mwSametimeList_get(b, stlist); | |
| 1250 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1251 | /* merge or synch depending on preferences */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1252 | if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1253 | blist_merge(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1254 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1255 | } else if(BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1256 | blist_sync(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1257 | } |
| 10977 | 1258 | |
| 1259 | mwSametimeList_free(stlist); | |
| 22973 | 1260 | mwGetBuffer_free(b); |
| 10977 | 1261 | } |
| 1262 | ||
| 1263 | ||
| 15884 | 1264 | /** signal triggered when a conversation is opened in Purple */ |
| 1265 | static void conversation_created_cb(PurpleConversation *g_conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1266 | struct mwPurpleProtocolData *pd) { |
| 10977 | 1267 | |
| 1268 | /* we need to tell the IM service to negotiate features for the | |
| 1269 | conversation right away, otherwise it'll wait until the first | |
| 1270 | message is sent before offering NotesBuddy features. Therefore | |
| 15884 | 1271 | whenever Purple creates a conversation, we'll immediately open the |
| 10977 | 1272 | channel to the other side and figure out what the target can |
| 1273 | handle. Unfortunately, this makes us vulnerable to Psychic Mode, | |
| 1274 | 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
|
1275 | would not */ |
| 10977 | 1276 | |
| 15884 | 1277 | PurpleConnection *gc; |
| 10977 | 1278 | struct mwIdBlock who = { 0, 0 }; |
| 1279 | struct mwConversation *conv; | |
| 1280 | ||
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1281 | gc = purple_conversation_get_connection(g_conv); |
| 10977 | 1282 | if(pd->gc != gc) |
| 1283 | return; /* not ours */ | |
| 1284 | ||
|
35070
d7350d876fda
libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents:
35005
diff
changeset
|
1285 | if(!PURPLE_IS_IM_CONVERSATION(g_conv)) |
| 10977 | 1286 | return; /* wrong type */ |
| 1287 | ||
| 15884 | 1288 | who.user = (char *) purple_conversation_get_name(g_conv); |
| 10977 | 1289 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 1290 | ||
| 1291 | convo_features(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1292 | |
| 10977 | 1293 | if(mwConversation_isClosed(conv)) |
| 1294 | mwConversation_open(conv); | |
| 1295 | } | |
| 1296 | ||
| 1297 | ||
| 15884 | 1298 | static void blist_menu_nab(PurpleBlistNode *node, gpointer data) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1299 | struct mwPurpleProtocolData *pd = data; |
| 15884 | 1300 | PurpleConnection *gc; |
| 1301 | ||
| 1302 | PurpleGroup *group = (PurpleGroup *) node; | |
| 10977 | 1303 | |
| 1304 | GString *str; | |
| 1305 | char *tmp; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1306 | const char *gname; |
| 10977 | 1307 | |
| 1308 | g_return_if_fail(pd != NULL); | |
| 1309 | ||
| 1310 | gc = pd->gc; | |
| 1311 | g_return_if_fail(gc != NULL); | |
| 1312 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1313 | g_return_if_fail(PURPLE_IS_GROUP(node)); |
| 10977 | 1314 | |
| 1315 | str = g_string_new(NULL); | |
| 1316 | ||
| 15884 | 1317 | 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
|
1318 | gname = purple_group_get_name(group); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1319 | |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1320 | 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
|
1321 | 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
|
1322 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1323 | tmp = g_strdup_printf(_("Info for Group %s"), gname); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1324 | |
| 15884 | 1325 | purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
| 10977 | 1326 | NULL, str->str, NULL, NULL); |
| 1327 | ||
| 1328 | g_free(tmp); | |
| 1329 | g_string_free(str, TRUE); | |
| 1330 | } | |
| 1331 | ||
| 1332 | ||
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
1333 | /** The normal blist menu protocol function doesn't get called for groups, |
| 10977 | 1334 | so we use the blist-node-extended-menu signal to trigger this |
| 1335 | handler */ | |
| 15884 | 1336 | static void blist_node_menu_cb(PurpleBlistNode *node, |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1337 | GList **menu, struct mwPurpleProtocolData *pd) { |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1338 | const char *owner; |
| 15884 | 1339 | PurpleAccount *acct; |
| 1340 | PurpleMenuAction *act; | |
| 10977 | 1341 | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1342 | /* we only want groups */ |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1343 | if(! PURPLE_IS_GROUP(node)) return; |
| 15884 | 1344 | |
| 1345 | acct = purple_connection_get_account(pd->gc); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1346 | g_return_if_fail(acct != NULL); |
|
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 | /* better make sure we're connected */ |
| 15884 | 1349 | if(! purple_account_is_connected(acct)) return; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1350 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1351 | /* check if it's a NAB group for this account */ |
| 15884 | 1352 | owner = purple_blist_node_get_string(node, GROUP_KEY_OWNER); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
1353 | if(owner && purple_strequal(owner, purple_account_get_username(acct))) { |
| 15884 | 1354 | act = purple_menu_action_new(_("Get Notes Address Book Info"), |
| 1355 | PURPLE_CALLBACK(blist_menu_nab), pd, NULL); | |
| 10977 | 1356 | *menu = g_list_append(*menu, act); |
| 1357 | } | |
| 1358 | } | |
| 1359 | ||
| 1360 | ||
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1361 | /* 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
|
1362 | anymore. */ |
| 15884 | 1363 | static void blist_init(PurpleAccount *acct) { |
| 1364 | PurpleBlistNode *gnode, *cnode, *bnode; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1365 | GList *add_buds = NULL; |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1366 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1367 | for(gnode = purple_blist_get_root(); gnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1368 | 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
|
1369 | if(! PURPLE_IS_GROUP(gnode)) continue; |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1370 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1371 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1372 | cnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1373 | 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
|
1374 | if(! PURPLE_IS_CONTACT(cnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1375 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1376 | for(bnode = purple_blist_node_get_first_child(cnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1377 | bnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1378 | bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 15884 | 1379 | PurpleBuddy *b; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1380 | if(!PURPLE_IS_BUDDY(bnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1381 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1382 | |
| 15884 | 1383 | b = (PurpleBuddy *)bnode; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1384 | if(purple_buddy_get_account(b) == acct) { |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1385 | add_buds = g_list_append(add_buds, b); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1386 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1387 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1388 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1389 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1390 | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1391 | if(add_buds) { |
|
32319
ab70b05e538b
sametime: fix build (add_buddies added param)
Paul Aurich <darkrain42@pidgin.im>
parents:
32316
diff
changeset
|
1392 | purple_account_add_buddies(acct, add_buds, NULL); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1393 | g_list_free(add_buds); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1394 | } |
|
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 | |
| 10977 | 1398 | /** Last thing to happen from a started session */ |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1399 | static void services_starting(struct mwPurpleProtocolData *pd) { |
| 15884 | 1400 | |
| 1401 | PurpleConnection *gc; | |
| 1402 | PurpleAccount *acct; | |
| 10977 | 1403 | struct mwStorageUnit *unit; |
| 15884 | 1404 | PurpleBlistNode *l; |
| 10977 | 1405 | |
| 1406 | gc = pd->gc; | |
| 15884 | 1407 | acct = purple_connection_get_account(gc); |
| 10977 | 1408 | |
| 1409 | /* grab the buddy list from the server */ | |
| 1410 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1411 | mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
| 10977 | 1412 | |
| 1413 | /* 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
|
1414 | for(l = purple_blist_get_root(); l; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1415 | l = purple_blist_node_get_sibling_next(l)) { |
| 15884 | 1416 | PurpleGroup *group = (PurpleGroup *) l; |
| 10977 | 1417 | enum mwSametimeGroupType gt; |
| 1418 | const char *owner; | |
| 1419 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1420 | if(! PURPLE_IS_GROUP(l)) continue; |
| 10977 | 1421 | |
| 1422 | /* if the group is ownerless, or has an owner and we're not it, | |
| 1423 | skip it */ | |
| 15884 | 1424 | owner = purple_blist_node_get_string(l, GROUP_KEY_OWNER); |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
1425 | if(!owner || !purple_strequal(owner, purple_account_get_username(acct))) |
| 10977 | 1426 | continue; |
| 1427 | ||
| 15884 | 1428 | gt = purple_blist_node_get_int(l, GROUP_KEY_TYPE); |
| 10977 | 1429 | if(gt == mwSametimeGroup_DYNAMIC) |
| 1430 | group_add(pd, group); | |
| 1431 | } | |
| 1432 | ||
| 1433 | /* set the aware attributes */ | |
| 1434 | /* indicate we understand what AV prefs are, but don't support any */ | |
| 1435 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1436 | mwAttribute_AV_PREFS_SET, TRUE); | |
| 1437 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE); | |
| 1438 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS); | |
| 1439 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA); | |
| 1440 | ||
| 1441 | /* ... but we can do file transfers! */ | |
| 1442 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1443 | mwAttribute_FILE_TRANSFER, TRUE); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1444 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1445 | blist_init(acct); |
| 10977 | 1446 | } |
| 1447 | ||
| 1448 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1449 | static void session_loginRedirect(struct mwSession *session, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1450 | const char *host) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1451 | struct mwPurpleProtocolData *pd; |
| 15884 | 1452 | PurpleConnection *gc; |
| 1453 | PurpleAccount *account; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1454 | guint port; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1455 | const char *current_host; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1456 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1457 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1458 | gc = pd->gc; |
| 15884 | 1459 | account = purple_connection_get_account(gc); |
| 1460 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); | |
| 1461 | 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
|
1462 | MW_PLUGIN_DEFAULT_HOST); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1463 | |
| 15884 | 1464 | if(purple_account_get_bool(account, MW_KEY_FORCE, FALSE) || |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
1465 | !host || purple_strequal(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
|
1466 | (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
|
1467 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1468 | /* 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
|
1469 | 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
|
1470 | 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
|
1471 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1472 | mwSession_forceLogin(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1473 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1474 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1475 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1476 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1477 | static void mw_protocol_set_status(PurpleAccount *acct, PurpleStatus *status); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1478 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1479 | |
| 10977 | 1480 | /** called from mw_session_stateChange when the session's state is |
| 1481 | mwSession_STARTED. Any finalizing of start-up stuff should go | |
| 1482 | here */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1483 | static void session_started(struct mwPurpleProtocolData *pd) { |
| 15884 | 1484 | PurpleStatus *status; |
| 1485 | PurpleAccount *acct; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1486 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1487 | /* set out initial status */ |
| 15884 | 1488 | acct = purple_connection_get_account(pd->gc); |
| 1489 | status = purple_account_get_active_status(acct); | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1490 | mw_protocol_set_status(acct, status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1491 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1492 | /* start watching for new conversations */ |
| 15884 | 1493 | purple_signal_connect(purple_conversations_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1494 | "conversation-created", pd, |
| 15884 | 1495 | PURPLE_CALLBACK(conversation_created_cb), pd); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1496 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1497 | /* watch for group extended menu items */ |
| 15884 | 1498 | purple_signal_connect(purple_blist_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1499 | "blist-node-extended-menu", pd, |
| 15884 | 1500 | PURPLE_CALLBACK(blist_node_menu_cb), pd); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1501 | |
| 10977 | 1502 | /* use our services to do neat things */ |
| 1503 | services_starting(pd); | |
| 1504 | } | |
| 1505 | ||
| 1506 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1507 | static void session_stopping(struct mwPurpleProtocolData *pd) { |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1508 | /* stop watching the signals from session_started */ |
| 15884 | 1509 | purple_signals_disconnect_by_handle(pd); |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1510 | } |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1511 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1512 | |
| 10977 | 1513 | static void mw_session_stateChange(struct mwSession *session, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1514 | enum mwSessionState state, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1515 | gpointer info) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1516 | struct mwPurpleProtocolData *pd; |
| 15884 | 1517 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1518 | const char *msg = NULL; |
| 10977 | 1519 | |
| 1520 | pd = mwSession_getClientData(session); | |
| 1521 | gc = pd->gc; | |
| 1522 | ||
| 1523 | switch(state) { | |
| 1524 | case mwSession_STARTING: | |
| 1525 | msg = _("Sending Handshake"); | |
| 15884 | 1526 | purple_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS); |
| 10977 | 1527 | break; |
| 1528 | ||
| 1529 | case mwSession_HANDSHAKE: | |
| 1530 | msg = _("Waiting for Handshake Acknowledgement"); | |
| 15884 | 1531 | purple_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS); |
| 10977 | 1532 | break; |
| 1533 | ||
| 1534 | case mwSession_HANDSHAKE_ACK: | |
| 1535 | msg = _("Handshake Acknowledged, Sending Login"); | |
| 15884 | 1536 | purple_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS); |
| 10977 | 1537 | break; |
| 1538 | ||
| 1539 | case mwSession_LOGIN: | |
| 1540 | msg = _("Waiting for Login Acknowledgement"); | |
| 15884 | 1541 | purple_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS); |
| 10977 | 1542 | break; |
| 1543 | ||
| 1544 | case mwSession_LOGIN_REDIR: | |
| 1545 | msg = _("Login Redirected"); | |
| 15884 | 1546 | 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
|
1547 | session_loginRedirect(session, info); |
| 10977 | 1548 | break; |
| 1549 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1550 | case mwSession_LOGIN_CONT: |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1551 | msg = _("Forcing Login"); |
| 15884 | 1552 | purple_connection_update_progress(gc, msg, 7, MW_CONNECT_STEPS); |
|
35966
d603bfb42fd9
Fix some coverity CWE-484 issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33782
diff
changeset
|
1553 | break; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1554 | |
| 10977 | 1555 | case mwSession_LOGIN_ACK: |
| 1556 | msg = _("Login Acknowledged"); | |
| 15884 | 1557 | purple_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS); |
| 10977 | 1558 | break; |
| 1559 | ||
| 1560 | case mwSession_STARTED: | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1561 | msg = _("Starting Services"); |
| 15884 | 1562 | purple_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS); |
| 10977 | 1563 | |
| 1564 | session_started(pd); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1565 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1566 | msg = _("Connected"); |
| 15884 | 1567 | 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
|
1568 | purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED); |
| 10977 | 1569 | break; |
| 1570 | ||
| 1571 | case mwSession_STOPPING: | |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1572 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1573 | session_stopping(pd); |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1574 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1575 | if(GPOINTER_TO_UINT(info) & ERR_FAILURE) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1576 | char *err = mwError(GPOINTER_TO_UINT(info)); |
| 21279 | 1577 | PurpleConnectionError reason; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1578 | switch (GPOINTER_TO_UINT(info)) { |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1579 | case VERSION_MISMATCH: |
| 21279 | 1580 | reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1581 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1582 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1583 | case USER_RESTRICTED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1584 | case INCORRECT_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1585 | case USER_UNREGISTERED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1586 | case GUEST_IN_USE: |
| 21279 | 1587 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1588 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1589 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1590 | case ENCRYPT_MISMATCH: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1591 | case ERR_ENCRYPT_NO_SUPPORT: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1592 | case ERR_NO_COMMON_ENCRYPT: |
| 21279 | 1593 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1594 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1595 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1596 | case VERIFICATION_DOWN: |
| 21279 | 1597 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1598 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1599 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1600 | case MULTI_SERVER_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1601 | case MULTI_SERVER_LOGIN2: |
| 21279 | 1602 | reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1603 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1604 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1605 | default: |
| 21279 | 1606 | reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1607 | } |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1608 | purple_connection_error(gc, reason, err); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1609 | g_free(err); |
| 10977 | 1610 | } |
| 1611 | break; | |
| 1612 | ||
| 1613 | case mwSession_STOPPED: | |
| 1614 | break; | |
| 1615 | ||
| 1616 | case mwSession_UNKNOWN: | |
| 1617 | default: | |
| 1618 | DEBUG_WARN("session in unknown state\n"); | |
| 1619 | } | |
| 1620 | } | |
| 1621 | ||
| 1622 | ||
| 1623 | static void mw_session_setPrivacyInfo(struct mwSession *session) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1624 | struct mwPurpleProtocolData *pd; |
| 15884 | 1625 | PurpleConnection *gc; |
| 1626 | PurpleAccount *acct; | |
| 10977 | 1627 | struct mwPrivacyInfo *privacy; |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1628 | GSList *list; |
| 10977 | 1629 | guint count; |
| 1630 | ||
| 1631 | DEBUG_INFO("privacy information set from server\n"); | |
| 1632 | ||
| 1633 | g_return_if_fail(session != NULL); | |
| 1634 | ||
| 1635 | pd = mwSession_getClientData(session); | |
| 1636 | g_return_if_fail(pd != NULL); | |
| 1637 | ||
| 1638 | gc = pd->gc; | |
| 1639 | g_return_if_fail(gc != NULL); | |
| 1640 | ||
| 15884 | 1641 | acct = purple_connection_get_account(gc); |
| 10977 | 1642 | g_return_if_fail(acct != NULL); |
| 1643 | ||
| 1644 | privacy = mwSession_getPrivacyInfo(session); | |
| 1645 | count = privacy->count; | |
| 1646 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1647 | if (privacy->deny) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1648 | 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
|
1649 | 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
|
1650 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1651 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1652 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1653 | 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
|
1654 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1655 | } else { |
|
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_permitted(acct))) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1657 | 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
|
1658 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1659 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1660 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1661 | 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
|
1662 | } |
| 10977 | 1663 | } |
| 1664 | } | |
| 1665 | ||
| 1666 | ||
| 1667 | static void mw_session_setUserStatus(struct mwSession *session) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1668 | struct mwPurpleProtocolData *pd; |
| 15884 | 1669 | PurpleConnection *gc; |
| 10977 | 1670 | struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL }; |
| 1671 | struct mwUserStatus *stat; | |
| 1672 | ||
| 1673 | g_return_if_fail(session != NULL); | |
| 1674 | ||
| 1675 | pd = mwSession_getClientData(session); | |
| 1676 | g_return_if_fail(pd != NULL); | |
| 1677 | ||
| 1678 | gc = pd->gc; | |
| 1679 | g_return_if_fail(gc != NULL); | |
| 1680 | ||
| 1681 | idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); | |
| 1682 | stat = mwSession_getUserStatus(session); | |
| 1683 | ||
| 1684 | /* trigger an update of our own status if we're in the buddy list */ | |
| 1685 | mwServiceAware_setStatus(pd->srvc_aware, &idb, stat); | |
| 1686 | } | |
| 1687 | ||
| 1688 | ||
| 1689 | static void mw_session_admin(struct mwSession *session, | |
| 1690 | const char *text) { | |
| 15884 | 1691 | PurpleConnection *gc; |
| 1692 | PurpleAccount *acct; | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1693 | const char *host; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1694 | const char *msg; |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1695 | char *prim; |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1696 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1697 | gc = session_to_gc(session); |
| 10977 | 1698 | g_return_if_fail(gc != NULL); |
| 1699 | ||
| 15884 | 1700 | acct = purple_connection_get_account(gc); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1701 | g_return_if_fail(acct != NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1702 | |
| 15884 | 1703 | 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
|
1704 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1705 | msg = _("A Sametime administrator has issued the following announcement" |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1706 | " on server %s"); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1707 | prim = g_strdup_printf(msg, NSTR(host)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1708 | |
| 15884 | 1709 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1710 | _("Sametime Administrator Announcement"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1711 | prim, text, NULL, NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1712 | purple_request_cpar_from_connection(gc)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1713 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1714 | g_free(prim); |
| 10977 | 1715 | } |
| 1716 | ||
| 1717 | ||
| 1718 | /** called from read_cb, attempts to read available data from sock and | |
| 1719 | pass it to the session, passing back the return code from the read | |
| 1720 | call for handling in read_cb */ | |
| 1721 | static int read_recv(struct mwSession *session, int sock) { | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1722 | guchar buf[BUF_LEN]; |
| 10977 | 1723 | int len; |
| 1724 | ||
| 1725 | len = read(sock, buf, BUF_LEN); | |
|
22277
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22195
diff
changeset
|
1726 | if(len > 0) { |
|
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22195
diff
changeset
|
1727 | mwSession_recv(session, buf, len); |
|
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22195
diff
changeset
|
1728 | } |
| 10977 | 1729 | |
| 1730 | return len; | |
| 1731 | } | |
| 1732 | ||
| 1733 | ||
| 15884 | 1734 | /** callback triggered from purple_input_add, watches the socked for |
| 10977 | 1735 | available data to be processed by the session */ |
| 15884 | 1736 | static void read_cb(gpointer data, gint source, PurpleInputCondition cond) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1737 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 1738 | int ret = 0, err = 0; |
| 1739 | ||
| 1740 | g_return_if_fail(pd != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1741 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1742 | ret = read_recv(pd->session, pd->socket); |
| 10977 | 1743 | |
| 1744 | /* normal operation ends here */ | |
| 1745 | if(ret > 0) return; | |
| 1746 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1747 | /* fetch the global error value */ |
| 10977 | 1748 | err = errno; |
| 1749 | ||
| 14754 | 1750 | /* read problem occurred if we're here, so we'll need to take care of |
| 10977 | 1751 | it and clean up internal state */ |
| 1752 | ||
| 1753 | if(pd->socket) { | |
| 1754 | close(pd->socket); | |
| 1755 | pd->socket = 0; | |
| 1756 | } | |
| 1757 | ||
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1758 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1759 | 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
|
1760 | pd->inpa = 0; |
| 10977 | 1761 | } |
| 1762 | ||
| 1763 | if(! ret) { | |
| 1764 | DEBUG_INFO("connection reset\n"); | |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1765 | purple_connection_error(pd->gc, |
| 21279 | 1766 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1767 | _("Server closed the connection")); |
| 10977 | 1768 | |
| 1769 | } else if(ret < 0) { | |
|
21486
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1770 | const gchar *err_str = g_strerror(err); |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1771 | char *msg = NULL; |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1772 | |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1773 | DEBUG_INFO("error in read callback: %s\n", err_str); |
|
773326dcdc30
Use distinct variables for the result of g_strerror (which is const) and a
Will Thompson <resiak@pidgin.im>
parents:
21453
diff
changeset
|
1774 | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1775 | msg = g_strdup_printf(_("Lost connection with server: %s"), err_str); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1776 | purple_connection_error(pd->gc, |
| 21279 | 1777 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 1778 | msg); | |
| 10977 | 1779 | g_free(msg); |
| 1780 | } | |
| 1781 | } | |
| 1782 | ||
| 1783 | ||
| 15884 | 1784 | /** Callback passed to purple_proxy_connect when an account is logged |
| 10977 | 1785 | in, and if the session logging in receives a redirect message */ |
|
14178
d12b287697c9
[gaim-migrate @ 16750]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
1786 | static void connect_cb(gpointer data, gint source, const gchar *error_message) { |
| 10977 | 1787 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1788 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 1789 | |
| 1790 | if(source < 0) { | |
| 1791 | /* connection failed */ | |
| 1792 | ||
| 1793 | if(pd->socket) { | |
| 1794 | /* this is a redirect connect, force login on existing socket */ | |
| 1795 | mwSession_forceLogin(pd->session); | |
| 1796 | ||
| 1797 | } else { | |
| 1798 | /* this is a regular connect, error out */ | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1799 | 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
|
1800 | error_message); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1801 | purple_connection_error(pd->gc, |
| 21279 | 1802 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1803 | tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27361
diff
changeset
|
1804 | g_free(tmp); |
| 10977 | 1805 | } |
| 1806 | ||
| 1807 | return; | |
| 1808 | } | |
| 1809 | ||
| 1810 | if(pd->socket) { | |
| 1811 | /* stop any existing login attempt */ | |
| 1812 | mwSession_stop(pd->session, ERR_SUCCESS); | |
| 1813 | } | |
| 1814 | ||
| 1815 | pd->socket = source; | |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1816 | pd->inpa = purple_input_add(source, PURPLE_INPUT_READ, |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
1817 | read_cb, pd); |
| 10977 | 1818 | |
| 1819 | mwSession_start(pd->session); | |
| 1820 | } | |
| 1821 | ||
| 1822 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1823 | static void mw_session_announce(struct mwSession *s, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1824 | struct mwLoginInfo *from, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1825 | gboolean may_reply, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1826 | const char *text) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1827 | struct mwPurpleProtocolData *pd; |
| 15884 | 1828 | PurpleAccount *acct; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1829 | PurpleIMConversation *im; |
| 15884 | 1830 | PurpleBuddy *buddy; |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1831 | char *who = from->user_id; |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1832 | char *msg, *msg2; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1833 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1834 | pd = mwSession_getClientData(s); |
| 15884 | 1835 | 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
|
1836 | 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
|
1837 | if(! im) im = purple_im_conversation_new(acct, who); |
| 15884 | 1838 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
1839 | buddy = purple_blist_find_buddy(acct, who); |
| 15884 | 1840 | 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
|
1841 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1842 | who = g_strdup_printf(_("Announcement from %s"), who); |
| 15884 | 1843 | msg = purple_markup_linkify(text); |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1844 | if (msg && msg[0]) |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1845 | msg2 = g_strdup_printf("%s: %s", who, msg); |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1846 | else |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1847 | msg2 = g_strdup(who); |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1848 | |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1849 | purple_conversation_write_system_message(PURPLE_CONVERSATION(im), msg2, 0); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1850 | g_free(who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1851 | g_free(msg); |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1852 | g_free(msg2); |
| 10977 | 1853 | } |
| 1854 | ||
| 1855 | ||
| 1856 | static struct mwSessionHandler mw_session_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1857 | mw_session_io_write, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1858 | mw_session_io_close, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1859 | mw_session_clear, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1860 | mw_session_stateChange, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1861 | mw_session_setPrivacyInfo, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1862 | mw_session_setUserStatus, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1863 | mw_session_admin, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1864 | mw_session_announce, |
| 10977 | 1865 | }; |
| 1866 | ||
| 1867 | ||
| 1868 | static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
| 1869 | struct mwAwareAttribute *attrib) { | |
| 1870 | ||
| 1871 | ; /** @todo handle server attributes. There may be some stuff we | |
| 1872 | actually want to look for, but I'm not aware of anything right | |
| 1873 | now.*/ | |
| 1874 | } | |
| 1875 | ||
| 1876 | ||
| 1877 | static void mw_aware_clear(struct mwServiceAware *srvc) { | |
| 1878 | ; /* nothing for now */ | |
| 1879 | } | |
| 1880 | ||
| 1881 | ||
| 1882 | static struct mwAwareHandler mw_aware_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1883 | mw_aware_on_attrib, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1884 | mw_aware_clear, |
| 10977 | 1885 | }; |
| 1886 | ||
| 1887 | ||
| 1888 | static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
| 1889 | struct mwServiceAware *srvc; | |
| 1890 | srvc = mwServiceAware_new(s, &mw_aware_handler); | |
| 1891 | return srvc; | |
| 1892 | }; | |
| 1893 | ||
| 1894 | ||
| 1895 | static void mw_conf_invited(struct mwConference *conf, | |
| 1896 | struct mwLoginInfo *inviter, | |
| 1897 | const char *invitation) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1898 | |
| 10977 | 1899 | struct mwServiceConference *srvc; |
| 1900 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1901 | struct mwPurpleProtocolData *pd; |
| 15884 | 1902 | PurpleConnection *gc; |
| 10977 | 1903 | |
| 1904 | char *c_inviter, *c_name, *c_topic, *c_invitation; | |
| 1905 | GHashTable *ht; | |
| 1906 | ||
| 1907 | srvc = mwConference_getService(conf); | |
| 1908 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1909 | pd = mwSession_getClientData(session); | |
| 1910 | gc = pd->gc; | |
| 1911 | ||
| 1912 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1913 | ||
| 1914 | c_inviter = g_strdup(inviter->user_id); | |
| 1915 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
| 1916 | ||
| 1917 | c_name = g_strdup(mwConference_getName(conf)); | |
| 1918 | g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
| 1919 | ||
| 1920 | c_topic = g_strdup(mwConference_getTitle(conf)); | |
| 1921 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
| 1922 | ||
| 1923 | c_invitation = g_strdup(invitation); | |
| 1924 | g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
| 1925 | ||
| 1926 | DEBUG_INFO("received invitation from '%s' to join ('%s','%s'): '%s'\n", | |
| 1927 | NSTR(c_inviter), NSTR(c_name), | |
| 1928 | NSTR(c_topic), NSTR(c_invitation)); | |
| 1929 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1930 | if(! c_topic) c_topic = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1931 | if(! c_invitation) c_invitation = "(no message)"; |
| 35501 | 1932 | purple_serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
| 10977 | 1933 | } |
| 1934 | ||
| 1935 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1936 | /* The following mess helps us relate a mwConference to a PurpleChatConversation |
| 10977 | 1937 | in the various forms by which either may be indicated */ |
| 1938 | ||
| 1939 | #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
| 1940 | #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
| 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 | #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
|
1943 | #define ID_TO_CHAT(id) (purple_conversations_find_chat(id)) |
| 10977 | 1944 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1945 | #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
|
1946 | #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
| 10977 | 1947 | |
| 1948 | ||
| 1949 | static struct mwConference * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1950 | conf_find_by_id(struct mwPurpleProtocolData *pd, int id) { |
| 10977 | 1951 | |
| 1952 | struct mwServiceConference *srvc = pd->srvc_conf; | |
| 1953 | struct mwConference *conf = NULL; | |
| 1954 | GList *l, *ll; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1955 | |
| 10977 | 1956 | ll = mwServiceConference_getConferences(srvc); |
| 1957 | for(l = ll; l; l = l->next) { | |
| 1958 | 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
|
1959 | PurpleChatConversation *h = mwConference_getClientData(c); |
| 10977 | 1960 | |
| 1961 | if(CHAT_TO_ID(h) == id) { | |
| 1962 | conf = c; | |
| 1963 | break; | |
| 1964 | } | |
| 1965 | } | |
| 1966 | g_list_free(ll); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1967 | |
| 10977 | 1968 | return conf; |
| 1969 | } | |
| 1970 | ||
| 1971 | ||
| 1972 | static void mw_conf_opened(struct mwConference *conf, GList *members) { | |
| 1973 | struct mwServiceConference *srvc; | |
| 1974 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1975 | struct mwPurpleProtocolData *pd; |
| 15884 | 1976 | PurpleConnection *gc; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1977 | PurpleChatConversation *g_conf; |
| 10977 | 1978 | |
| 1979 | const char *n = mwConference_getName(conf); | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1980 | const char *t = mwConference_getTitle(conf); |
| 10977 | 1981 | |
| 1982 | DEBUG_INFO("conf %s opened, %u initial members\n", | |
| 1983 | NSTR(n), g_list_length(members)); | |
| 1984 | ||
| 1985 | srvc = mwConference_getService(conf); | |
| 1986 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1987 | pd = mwSession_getClientData(session); | |
| 1988 | gc = pd->gc; | |
| 1989 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1990 | if(! t) t = "(no title)"; |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
1991 | g_conf = purple_serv_got_joined_chat(gc, CONF_TO_ID(conf), t); |
| 10977 | 1992 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1993 | mwConference_setClientData(conf, g_conf, NULL); |
| 10977 | 1994 | |
| 1995 | for(; members; members = members->next) { | |
| 1996 | 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
|
1997 | 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
|
1998 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
| 10977 | 1999 | } |
| 2000 | } | |
| 2001 | ||
| 2002 | ||
| 2003 | static void mw_conf_closed(struct mwConference *conf, guint32 reason) { | |
| 2004 | struct mwServiceConference *srvc; | |
| 2005 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2006 | struct mwPurpleProtocolData *pd; |
| 15884 | 2007 | PurpleConnection *gc; |
| 10977 | 2008 | |
| 2009 | const char *n = mwConference_getName(conf); | |
| 2010 | char *msg = mwError(reason); | |
| 2011 | ||
| 2012 | DEBUG_INFO("conf %s closed, 0x%08x\n", NSTR(n), reason); | |
| 2013 | ||
| 2014 | srvc = mwConference_getService(conf); | |
| 2015 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2016 | pd = mwSession_getClientData(session); | |
| 2017 | gc = pd->gc; | |
| 2018 | ||
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2019 | purple_serv_got_chat_left(gc, CONF_TO_ID(conf)); |
| 10977 | 2020 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2021 | 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
|
2022 | purple_request_cpar_from_connection(gc)); |
| 10977 | 2023 | g_free(msg); |
| 2024 | } | |
| 2025 | ||
| 2026 | ||
| 2027 | static void mw_conf_peer_joined(struct mwConference *conf, | |
| 2028 | struct mwLoginInfo *peer) { | |
| 2029 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2030 | PurpleChatConversation *g_conf; |
| 10977 | 2031 | |
| 2032 | const char *n = mwConference_getName(conf); | |
| 2033 | ||
| 2034 | DEBUG_INFO("%s joined conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2035 | ||
| 2036 | g_conf = mwConference_getClientData(conf); | |
| 2037 | g_return_if_fail(g_conf != NULL); | |
| 2038 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2039 | 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
|
2040 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
| 10977 | 2041 | } |
| 2042 | ||
| 2043 | ||
| 2044 | static void mw_conf_peer_parted(struct mwConference *conf, | |
| 2045 | struct mwLoginInfo *peer) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2046 | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2047 | PurpleChatConversation *g_conf; |
| 10977 | 2048 | |
| 2049 | const char *n = mwConference_getName(conf); | |
| 2050 | ||
| 2051 | DEBUG_INFO("%s left conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
| 2052 | ||
| 2053 | g_conf = mwConference_getClientData(conf); | |
| 2054 | g_return_if_fail(g_conf != NULL); | |
| 2055 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2056 | purple_chat_conversation_remove_user(g_conf, peer->user_id, NULL); |
| 10977 | 2057 | } |
| 2058 | ||
| 2059 | ||
| 2060 | static void mw_conf_text(struct mwConference *conf, | |
| 2061 | struct mwLoginInfo *who, const char *text) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2062 | |
| 10977 | 2063 | struct mwServiceConference *srvc; |
| 2064 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2065 | struct mwPurpleProtocolData *pd; |
| 15884 | 2066 | PurpleConnection *gc; |
| 10977 | 2067 | char *esc; |
| 2068 | ||
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2069 | if(! text) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2070 | |
| 10977 | 2071 | srvc = mwConference_getService(conf); |
| 2072 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2073 | pd = mwSession_getClientData(session); | |
| 2074 | gc = pd->gc; | |
| 2075 | ||
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2076 | esc = g_markup_escape_text(text, -1); |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
2077 | purple_serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, PURPLE_MESSAGE_RECV, esc, time(NULL)); |
| 10977 | 2078 | g_free(esc); |
| 2079 | } | |
| 2080 | ||
| 2081 | ||
| 2082 | static void mw_conf_typing(struct mwConference *conf, | |
| 2083 | struct mwLoginInfo *who, gboolean typing) { | |
| 2084 | ||
| 15884 | 2085 | /* purple really has no good way to expose this to the user. */ |
| 10977 | 2086 | |
| 2087 | const char *n = mwConference_getName(conf); | |
| 2088 | const char *w = who->user_id; | |
| 2089 | ||
| 2090 | if(typing) { | |
| 2091 | DEBUG_INFO("%s in conf %s: <typing>\n", NSTR(w), NSTR(n)); | |
| 2092 | ||
| 2093 | } else { | |
| 2094 | DEBUG_INFO("%s in conf %s: <stopped typing>\n", NSTR(w), NSTR(n)); | |
| 2095 | } | |
| 2096 | } | |
| 2097 | ||
| 2098 | ||
| 2099 | static void mw_conf_clear(struct mwServiceConference *srvc) { | |
| 2100 | ; | |
| 2101 | } | |
| 2102 | ||
| 2103 | ||
| 2104 | static struct mwConferenceHandler mw_conference_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2105 | mw_conf_invited, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2106 | mw_conf_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2107 | mw_conf_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2108 | mw_conf_peer_joined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2109 | mw_conf_peer_parted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2110 | mw_conf_text, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2111 | mw_conf_typing, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2112 | mw_conf_clear, |
| 10977 | 2113 | }; |
| 2114 | ||
| 2115 | ||
| 2116 | static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) { | |
| 2117 | struct mwServiceConference *srvc; | |
| 2118 | srvc = mwServiceConference_new(s, &mw_conference_handler); | |
| 2119 | return srvc; | |
| 2120 | } | |
| 2121 | ||
| 2122 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2123 | /** size of an outgoing file transfer chunk */ |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2124 | #define MW_FT_LEN (BUF_LONG * 2) |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2125 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2126 | |
| 15884 | 2127 | static void ft_incoming_cancel(PurpleXfer *xfer) { |
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29304
diff
changeset
|
2128 | /* 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
|
2129 | struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
| 10977 | 2130 | if(ft) mwFileTransfer_reject(ft); |
| 2131 | } | |
| 2132 | ||
| 2133 | ||
| 15884 | 2134 | static void ft_incoming_init(PurpleXfer *xfer) { |
| 10977 | 2135 | /* incoming transfer accepted */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2136 | |
| 10977 | 2137 | /* - accept the mwFileTransfer |
| 2138 | - open/create the local FILE "wb" | |
| 2139 | - stick the FILE's fp in xfer->dest_fp | |
| 2140 | */ | |
| 2141 | ||
| 2142 | struct mwFileTransfer *ft; | |
| 2143 | ||
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2144 | ft = purple_xfer_get_protocol_data(xfer); |
| 10977 | 2145 | |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2146 | purple_xfer_start(xfer, -1, NULL, 0); |
| 10977 | 2147 | mwFileTransfer_accept(ft); |
| 2148 | } | |
| 2149 | ||
| 2150 | ||
| 2151 | static void mw_ft_offered(struct mwFileTransfer *ft) { | |
| 2152 | /* | |
| 15884 | 2153 | - create a purple ft object |
| 10977 | 2154 | - offer it |
| 2155 | */ | |
| 2156 | ||
| 2157 | struct mwServiceFileTransfer *srvc; | |
| 2158 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2159 | struct mwPurpleProtocolData *pd; |
| 15884 | 2160 | PurpleConnection *gc; |
| 2161 | PurpleAccount *acct; | |
| 10977 | 2162 | const char *who; |
| 15884 | 2163 | PurpleXfer *xfer; |
| 10977 | 2164 | |
| 2165 | /* @todo add some safety checks */ | |
| 2166 | srvc = mwFileTransfer_getService(ft); | |
| 2167 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2168 | pd = mwSession_getClientData(session); | |
| 2169 | gc = pd->gc; | |
| 15884 | 2170 | acct = purple_connection_get_account(gc); |
| 10977 | 2171 | |
| 2172 | who = mwFileTransfer_getUser(ft)->user; | |
| 2173 | ||
| 2174 | DEBUG_INFO("file transfer %p offered\n", ft); | |
| 2175 | DEBUG_INFO(" from: %s\n", NSTR(who)); | |
| 2176 | DEBUG_INFO(" file: %s\n", NSTR(mwFileTransfer_getFileName(ft))); | |
| 2177 | DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft)); | |
| 2178 | DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft))); | |
| 2179 | ||
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34920
diff
changeset
|
2180 | xfer = purple_xfer_new(acct, PURPLE_XFER_TYPE_RECEIVE, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2181 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2182 | { |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
2183 | g_object_ref(xfer); |
|
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
2184 | 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
|
2185 | purple_xfer_set_protocol_data(xfer, ft); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2186 | |
| 15884 | 2187 | purple_xfer_set_init_fnc(xfer, ft_incoming_init); |
| 2188 | purple_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); | |
| 2189 | purple_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); | |
| 2190 | ||
| 2191 | purple_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); | |
| 2192 | purple_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); | |
| 2193 | purple_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); | |
| 2194 | ||
| 2195 | purple_xfer_request(xfer); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2196 | } |
| 10977 | 2197 | } |
| 2198 | ||
| 2199 | ||
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2200 | static void ft_send(struct mwFileTransfer *ft) { |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2201 | 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
|
2202 | struct mwOpaque o = { MW_FT_LEN, buf }; |
| 10977 | 2203 | guint32 rem; |
| 15884 | 2204 | PurpleXfer *xfer; |
| 10977 | 2205 | |
| 2206 | xfer = mwFileTransfer_getClientData(ft); | |
| 2207 | ||
| 2208 | rem = mwFileTransfer_getRemaining(ft); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2209 | if(rem < MW_FT_LEN) o.len = rem; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2210 | |
| 36043 | 2211 | if(purple_xfer_read_file(xfer, buf, (size_t) o.len) == (gssize)o.len) { |
| 10977 | 2212 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2213 | /* calculate progress and display it */ |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2214 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + o.len); |
| 15884 | 2215 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2216 | |
| 10977 | 2217 | mwFileTransfer_send(ft, &o); |
| 2218 | ||
| 2219 | } else { | |
| 2220 | int err = errno; | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2221 | 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
|
2222 | NSTR(mwFileTransfer_getFileName(ft)), g_strerror(err)); |
| 10977 | 2223 | |
| 2224 | mwFileTransfer_cancel(ft); | |
| 2225 | } | |
| 2226 | } | |
| 2227 | ||
| 2228 | ||
| 2229 | static void mw_ft_opened(struct mwFileTransfer *ft) { | |
| 2230 | /* | |
| 15884 | 2231 | - get purple ft from client data in ft |
| 10977 | 2232 | - set the state to active |
| 2233 | */ | |
| 2234 | ||
| 15884 | 2235 | PurpleXfer *xfer; |
| 10977 | 2236 | |
| 2237 | xfer = mwFileTransfer_getClientData(ft); | |
| 2238 | ||
| 2239 | if(! xfer) { | |
| 2240 | mwFileTransfer_cancel(ft); | |
| 2241 | mwFileTransfer_free(ft); | |
| 2242 | g_return_if_reached(); | |
| 2243 | } | |
| 2244 | ||
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34920
diff
changeset
|
2245 | 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
|
2246 | 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
|
2247 | ft_send(ft); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2248 | } |
| 10977 | 2249 | } |
| 2250 | ||
| 2251 | ||
| 2252 | static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
| 2253 | /* | |
| 15884 | 2254 | - get purple ft from client data in ft |
| 10977 | 2255 | - indicate rejection/cancelation/completion |
| 2256 | - free the file transfer itself | |
| 2257 | */ | |
| 2258 | ||
| 15884 | 2259 | PurpleXfer *xfer; |
| 10977 | 2260 | |
| 2261 | xfer = mwFileTransfer_getClientData(ft); | |
| 2262 | if(xfer) { | |
|
32243
709c68f85f51
Convert the sametime prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
2263 | purple_xfer_set_protocol_data(xfer, NULL); |
| 10977 | 2264 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2265 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2266 | purple_xfer_set_completed(xfer, TRUE); |
| 2267 | purple_xfer_end(xfer); | |
| 10977 | 2268 | |
| 2269 | } else if(mwFileTransfer_isCancelLocal(ft)) { | |
| 15884 | 2270 | /* calling purple_xfer_cancel_local is redundant, since that's |
| 10977 | 2271 | probably what triggered this function to be called */ |
| 2272 | ; | |
| 2273 | ||
| 2274 | } else if(mwFileTransfer_isCancelRemote(ft)) { | |
| 2275 | /* steal the reference for the xfer */ | |
| 2276 | mwFileTransfer_setClientData(ft, NULL, NULL); | |
| 15884 | 2277 | purple_xfer_cancel_remote(xfer); |
| 10977 | 2278 | |
| 2279 | /* 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
|
2280 | g_object_unref(xfer); |
| 10977 | 2281 | return; |
| 2282 | } | |
| 2283 | } | |
| 2284 | ||
| 2285 | mwFileTransfer_free(ft); | |
| 2286 | } | |
| 2287 | ||
| 2288 | ||
| 2289 | static void mw_ft_recv(struct mwFileTransfer *ft, | |
| 2290 | struct mwOpaque *data) { | |
| 2291 | /* | |
| 15884 | 2292 | - get purple ft from client data in ft |
| 10977 | 2293 | - update transfered percentage |
| 15884 | 2294 | - if done, destroy the ft, disassociate from purple ft |
| 10977 | 2295 | */ |
| 2296 | ||
| 15884 | 2297 | PurpleXfer *xfer; |
| 10977 | 2298 | |
| 2299 | xfer = mwFileTransfer_getClientData(ft); | |
| 2300 | g_return_if_fail(xfer != NULL); | |
| 2301 | ||
| 2302 | /* 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
|
2303 | 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
|
2304 | 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
|
2305 | 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
|
2306 | return; |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2307 | } |
| 10977 | 2308 | |
| 2309 | /* update the progress */ | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2310 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + data->len); |
| 15884 | 2311 | purple_xfer_update_progress(xfer); |
| 10977 | 2312 | |
| 2313 | /* let the other side know we got it, and to send some more */ | |
| 2314 | mwFileTransfer_ack(ft); | |
| 2315 | } | |
| 2316 | ||
| 2317 | ||
| 2318 | static void mw_ft_ack(struct mwFileTransfer *ft) { | |
| 15884 | 2319 | PurpleXfer *xfer; |
| 10977 | 2320 | |
| 2321 | xfer = mwFileTransfer_getClientData(ft); | |
| 2322 | g_return_if_fail(xfer != NULL); | |
|
32705
9d97ac4c2c22
Sametime: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents:
32698
diff
changeset
|
2323 | g_return_if_fail(purple_xfer_get_watcher(xfer) == 0); |
| 10977 | 2324 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2325 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2326 | purple_xfer_set_completed(xfer, TRUE); |
| 2327 | purple_xfer_end(xfer); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2328 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2329 | } else if(mwFileTransfer_isOpen(ft)) { |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2330 | ft_send(ft); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2331 | } |
| 10977 | 2332 | } |
| 2333 | ||
| 2334 | ||
| 2335 | static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
| 2336 | ; | |
| 2337 | } | |
| 2338 | ||
| 2339 | ||
| 2340 | static struct mwFileTransferHandler mw_ft_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2341 | mw_ft_offered, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2342 | mw_ft_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2343 | mw_ft_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2344 | mw_ft_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2345 | mw_ft_ack, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2346 | mw_ft_clear, |
| 10977 | 2347 | }; |
| 2348 | ||
| 2349 | ||
| 2350 | static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
| 2351 | struct mwServiceFileTransfer *srvc; | |
| 2352 | GHashTable *ft_map; | |
| 2353 | ||
| 2354 | ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 2355 | ||
| 2356 | srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
| 2357 | mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
| 2358 | (GDestroyNotify) g_hash_table_destroy); | |
| 2359 | ||
| 2360 | return srvc; | |
| 2361 | } | |
| 2362 | ||
| 2363 | ||
| 2364 | static void convo_data_free(struct convo_data *cd) { | |
| 2365 | GList *l; | |
| 2366 | ||
| 2367 | /* clean the queue */ | |
| 2368 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2369 | struct convo_msg *m = l->data; | |
| 2370 | if(m->clear) m->clear(m->data); | |
| 2371 | g_free(m); | |
| 2372 | } | |
| 2373 | ||
| 2374 | g_free(cd); | |
| 2375 | } | |
| 2376 | ||
| 2377 | ||
| 2378 | /** allocates a convo_data structure and associates it with the | |
| 2379 | conversation in the client data slot */ | |
| 2380 | static void convo_data_new(struct mwConversation *conv) { | |
| 2381 | struct convo_data *cd; | |
| 2382 | ||
| 2383 | g_return_if_fail(conv != NULL); | |
| 2384 | ||
| 2385 | if(mwConversation_getClientData(conv)) | |
| 2386 | return; | |
| 2387 | ||
| 2388 | cd = g_new0(struct convo_data, 1); | |
| 2389 | cd->conv = conv; | |
| 2390 | ||
| 2391 | mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
| 2392 | } | |
| 2393 | ||
| 2394 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2395 | static PurpleIMConversation *convo_get_im(struct mwConversation *conv) { |
| 10977 | 2396 | struct mwServiceIm *srvc; |
| 2397 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2398 | struct mwPurpleProtocolData *pd; |
| 15884 | 2399 | PurpleConnection *gc; |
| 2400 | PurpleAccount *acct; | |
| 10977 | 2401 | |
| 2402 | struct mwIdBlock *idb; | |
| 2403 | ||
| 2404 | srvc = mwConversation_getService(conv); | |
| 2405 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2406 | pd = mwSession_getClientData(session); | |
| 2407 | gc = pd->gc; | |
| 15884 | 2408 | acct = purple_connection_get_account(gc); |
| 10977 | 2409 | |
| 2410 | idb = mwConversation_getTarget(conv); | |
| 2411 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2412 | return purple_conversations_find_im_with_account(idb->user, acct); |
| 10977 | 2413 | } |
| 2414 | ||
| 2415 | ||
| 2416 | static void convo_queue(struct mwConversation *conv, | |
| 2417 | enum mwImSendType type, gconstpointer data) { | |
| 2418 | ||
| 2419 | struct convo_data *cd; | |
| 2420 | struct convo_msg *m; | |
| 2421 | ||
| 2422 | convo_data_new(conv); | |
| 2423 | cd = mwConversation_getClientData(conv); | |
| 2424 | ||
| 2425 | m = g_new0(struct convo_msg, 1); | |
| 2426 | m->type = type; | |
| 2427 | ||
| 2428 | switch(type) { | |
| 2429 | case mwImSend_PLAIN: | |
| 2430 | m->data = g_strdup(data); | |
| 2431 | m->clear = g_free; | |
| 2432 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2433 | |
| 10977 | 2434 | case mwImSend_TYPING: |
| 2435 | default: | |
| 2436 | m->data = (gpointer) data; | |
| 2437 | m->clear = NULL; | |
| 2438 | } | |
| 2439 | ||
| 2440 | cd->queue = g_list_append(cd->queue, m); | |
| 2441 | } | |
| 2442 | ||
| 2443 | ||
| 2444 | /* Does what it takes to get an error displayed for a conversation */ | |
| 2445 | 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
|
2446 | PurpleIMConversation *im; |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2447 | PurpleConnection *pc; |
| 10977 | 2448 | char *tmp, *text; |
| 2449 | struct mwIdBlock *idb; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2450 | |
| 10977 | 2451 | idb = mwConversation_getTarget(conv); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2452 | |
| 10977 | 2453 | tmp = mwError(err); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2454 | text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2455 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2456 | 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
|
2457 | 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
|
2458 | purple_conversation_get_account(PURPLE_CONVERSATION(im)), text)) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2459 | |
| 10977 | 2460 | g_free(text); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2461 | text = g_strdup_printf(_("Unable to send message to %s:"), |
| 10977 | 2462 | (idb->user)? idb->user: "(unknown)"); |
| 34955 | 2463 | pc = purple_account_get_connection(purple_conversation_get_account( |
| 2464 | PURPLE_CONVERSATION(im))); | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2465 | purple_notify_error(pc, NULL, text, tmp, purple_request_cpar_from_connection(pc)); |
| 10977 | 2466 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2467 | |
| 10977 | 2468 | g_free(tmp); |
| 2469 | g_free(text); | |
| 2470 | } | |
| 2471 | ||
| 2472 | ||
| 2473 | static void convo_queue_send(struct mwConversation *conv) { | |
| 2474 | struct convo_data *cd; | |
| 2475 | GList *l; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2476 | |
| 10977 | 2477 | cd = mwConversation_getClientData(conv); |
| 2478 | ||
| 2479 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2480 | struct convo_msg *m = l->data; | |
| 2481 | ||
| 2482 | mwConversation_send(conv, m->type, m->data); | |
| 2483 | ||
| 2484 | if(m->clear) m->clear(m->data); | |
| 2485 | g_free(m); | |
| 2486 | } | |
| 2487 | ||
| 2488 | cd->queue = NULL; | |
| 2489 | } | |
| 2490 | ||
| 2491 | ||
| 15884 | 2492 | /** called when a mw conversation leaves a purple conversation to |
| 2493 | inform the purple conversation that it's unsafe to offer any *cool* | |
| 10977 | 2494 | features. */ |
| 2495 | 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
|
2496 | PurpleIMConversation *im; |
| 15884 | 2497 | PurpleConnection *gc; |
| 10977 | 2498 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2499 | 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
|
2500 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2501 | |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2502 | gc = purple_conversation_get_connection(PURPLE_CONVERSATION(im)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2503 | if(! gc) return; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2504 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2505 | 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
|
2506 | purple_connection_get_flags(gc)); |
| 15884 | 2507 | } |
| 2508 | ||
| 2509 | ||
| 2510 | /** called when a mw conversation and purple conversation come together, | |
| 2511 | to inform the purple conversation of what features to offer the | |
| 10977 | 2512 | user */ |
| 2513 | 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
|
2514 | PurpleIMConversation *im; |
| 15884 | 2515 | PurpleConnectionFlags feat; |
| 10977 | 2516 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2517 | 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
|
2518 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2519 | |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2520 | feat = purple_conversation_get_features(PURPLE_CONVERSATION(im)); |
| 10977 | 2521 | |
| 2522 | if(mwConversation_isOpen(conv)) { | |
| 2523 | if(mwConversation_supports(conv, mwImSend_HTML)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2524 | feat |= PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2525 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2526 | feat &= ~PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2527 | } |
| 2528 | ||
| 2529 | if(mwConversation_supports(conv, mwImSend_MIME)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2530 | feat &= ~PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2531 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2532 | feat |= PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2533 | } |
| 2534 | ||
| 2535 | 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
|
2536 | purple_conversation_set_features(PURPLE_CONVERSATION(im), feat); |
| 10977 | 2537 | |
| 2538 | } else { | |
| 2539 | convo_nofeatures(conv); | |
| 2540 | } | |
| 2541 | } | |
| 2542 | ||
| 2543 | ||
| 2544 | static void mw_conversation_opened(struct mwConversation *conv) { | |
| 2545 | struct mwServiceIm *srvc; | |
| 2546 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2547 | struct mwPurpleProtocolData *pd; |
| 15884 | 2548 | PurpleConnection *gc; |
| 2549 | PurpleAccount *acct; | |
| 10977 | 2550 | |
| 2551 | struct convo_dat *cd; | |
| 2552 | ||
| 2553 | srvc = mwConversation_getService(conv); | |
| 2554 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2555 | pd = mwSession_getClientData(session); | |
| 2556 | gc = pd->gc; | |
| 15884 | 2557 | acct = purple_connection_get_account(gc); |
| 10977 | 2558 | |
| 2559 | /* set up the queue */ | |
| 2560 | cd = mwConversation_getClientData(conv); | |
| 2561 | if(cd) { | |
| 2562 | convo_queue_send(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2563 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2564 | if(! convo_get_im(conv)) { |
| 10977 | 2565 | mwConversation_free(conv); |
| 2566 | return; | |
| 2567 | } | |
| 2568 | ||
| 2569 | } else { | |
| 2570 | convo_data_new(conv); | |
| 2571 | } | |
| 2572 | ||
| 2573 | { /* record the client key for the buddy */ | |
| 15884 | 2574 | PurpleBuddy *buddy; |
| 10977 | 2575 | struct mwLoginInfo *info; |
| 2576 | info = mwConversation_getTargetInfo(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2577 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
2578 | buddy = purple_blist_find_buddy(acct, info->user_id); |
| 10977 | 2579 | if(buddy) { |
| 15884 | 2580 | purple_blist_node_set_int((PurpleBlistNode *) buddy, |
| 10977 | 2581 | BUDDY_KEY_CLIENT, info->type); |
| 2582 | } | |
| 2583 | } | |
| 2584 | ||
| 2585 | convo_features(conv); | |
| 2586 | } | |
| 2587 | ||
| 2588 | ||
| 2589 | static void mw_conversation_closed(struct mwConversation *conv, | |
| 2590 | guint32 reason) { | |
| 2591 | ||
| 2592 | struct convo_data *cd; | |
| 2593 | ||
| 2594 | g_return_if_fail(conv != NULL); | |
| 2595 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2596 | /* 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
|
2597 | print an error message to the conversation */ |
| 10977 | 2598 | cd = mwConversation_getClientData(conv); |
| 2599 | if(reason && cd && cd->queue) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2600 | GList *l; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2601 | for(l = cd->queue; l; l = l->next) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2602 | struct convo_msg *m = l->data; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2603 | if(m->type != mwImSend_TYPING) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2604 | convo_error(conv, reason); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2605 | break; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2606 | } |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2607 | } |
| 10977 | 2608 | } |
| 2609 | ||
| 2610 | mwConversation_removeClientData(conv); | |
| 2611 | } | |
| 2612 | ||
| 2613 | ||
| 2614 | static void im_recv_text(struct mwConversation *conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2615 | struct mwPurpleProtocolData *pd, |
| 10977 | 2616 | const char *msg) { |
| 2617 | ||
| 2618 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2619 | char *txt, *esc; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2620 | const char *t; |
| 10977 | 2621 | |
| 2622 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2623 | |
| 15884 | 2624 | txt = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2625 | t = txt? txt: msg; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2626 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2627 | esc = g_markup_escape_text(t, -1); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2628 | purple_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
|
2629 | g_free(esc); |
| 10977 | 2630 | |
| 2631 | g_free(txt); | |
| 2632 | } | |
| 2633 | ||
| 2634 | ||
| 2635 | static void im_recv_typing(struct mwConversation *conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2636 | struct mwPurpleProtocolData *pd, |
| 10977 | 2637 | gboolean typing) { |
| 2638 | ||
| 2639 | struct mwIdBlock *idb; | |
| 2640 | idb = mwConversation_getTarget(conv); | |
| 2641 | ||
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2642 | purple_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
|
2643 | typing? PURPLE_IM_TYPING: PURPLE_IM_NOT_TYPING); |
| 10977 | 2644 | } |
| 2645 | ||
| 2646 | ||
| 2647 | static void im_recv_html(struct mwConversation *conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2648 | struct mwPurpleProtocolData *pd, |
| 10977 | 2649 | const char *msg) { |
| 2650 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2651 | char *t1, *t2; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2652 | const char *t; |
| 10977 | 2653 | |
| 2654 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2655 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2656 | /* ensure we're receiving UTF8 */ |
| 15884 | 2657 | t1 = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2658 | t = t1? t1: msg; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2659 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2660 | /* convert entities to UTF8 so they'll log correctly */ |
| 15884 | 2661 | t2 = purple_utf8_ncr_decode(t); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2662 | t = t2? t2: t; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2663 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2664 | purple_serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
| 10977 | 2665 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2666 | g_free(t1); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2667 | g_free(t2); |
| 10977 | 2668 | } |
| 2669 | ||
| 2670 | ||
| 2671 | static void im_recv_subj(struct mwConversation *conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2672 | struct mwPurpleProtocolData *pd, |
| 10977 | 2673 | const char *subj) { |
| 2674 | ||
| 2675 | /** @todo somehow indicate receipt of a conversation subject. It | |
| 2676 | would also be nice if we added a /topic command for the | |
| 2677 | protocol */ | |
| 2678 | ; | |
| 2679 | } | |
| 2680 | ||
| 2681 | ||
| 2682 | /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */ | |
| 2683 | static char *make_cid(const char *cid) { | |
| 2684 | gsize n; | |
| 2685 | char *c, *d; | |
| 2686 | ||
| 2687 | g_return_val_if_fail(cid != NULL, NULL); | |
| 2688 | ||
| 2689 | n = strlen(cid); | |
| 2690 | g_return_val_if_fail(n > 2, NULL); | |
| 2691 | ||
| 2692 | c = g_strndup(cid+1, n-2); | |
| 2693 | d = g_strdup_printf("cid:%s", c); | |
| 2694 | ||
| 2695 | g_free(c); | |
| 2696 | return d; | |
| 2697 | } | |
| 2698 | ||
| 2699 | ||
| 2700 | static void im_recv_mime(struct mwConversation *conv, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2701 | struct mwPurpleProtocolData *pd, |
| 10977 | 2702 | const char *data) { |
| 2703 | ||
| 2704 | GHashTable *img_by_cid; | |
| 2705 | ||
| 2706 | GString *str; | |
| 2707 | ||
| 15884 | 2708 | 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
|
2709 | GList *parts; |
| 10977 | 2710 | |
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
2711 | img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref); |
| 10977 | 2712 | |
| 2713 | /* don't want the contained string to ever be NULL */ | |
| 2714 | str = g_string_new(""); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2715 | |
| 15884 | 2716 | doc = purple_mime_document_parse(data); |
| 10977 | 2717 | |
| 2718 | /* handle all the MIME parts */ | |
| 15884 | 2719 | parts = purple_mime_document_get_parts(doc); |
| 10977 | 2720 | for(; parts; parts = parts->next) { |
| 15884 | 2721 | PurpleMimePart *part = parts->data; |
| 10977 | 2722 | const char *type; |
| 2723 | ||
| 15884 | 2724 | type = purple_mime_part_get_field(part, "content-type"); |
| 10977 | 2725 | DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type)); |
| 2726 | ||
| 2727 | if(! type) { | |
| 2728 | ; /* feh */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2729 | |
| 15884 | 2730 | } else if(purple_str_has_prefix(type, "image")) { |
| 10977 | 2731 | /* put images into the image store */ |
| 2732 | ||
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2733 | guchar *d_dat; |
| 10977 | 2734 | gsize d_len; |
| 2735 | char *cid; | |
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
2736 | PurpleImage *image; |
| 10977 | 2737 | |
| 2738 | /* obtain and unencode the data */ | |
| 15884 | 2739 | 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
|
2740 | |
| 10977 | 2741 | /* look up the content id */ |
| 15884 | 2742 | cid = (char *) purple_mime_part_get_field(part, "Content-ID"); |
| 10977 | 2743 | cid = make_cid(cid); |
| 2744 | ||
| 15884 | 2745 | /* add image to the purple image store */ |
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
2746 | image = purple_image_new_from_data(d_dat, d_len); |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
2747 | purple_image_set_friendly_filename(image, cid); |
| 10977 | 2748 | |
| 2749 | /* map the cid to the image store identifier */ | |
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
2750 | g_hash_table_insert(img_by_cid, cid, image); |
| 15884 | 2751 | } else if(purple_str_has_prefix(type, "text")) { |
| 10977 | 2752 | |
| 2753 | /* concatenate all the text parts together */ | |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11133
diff
changeset
|
2754 | guchar *data; |
| 10977 | 2755 | gsize len; |
| 2756 | ||
| 15884 | 2757 | purple_mime_part_get_data_decoded(part, &data, &len); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2758 | g_string_append(str, (const char *)data); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2759 | g_free(data); |
| 10977 | 2760 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2761 | } |
| 10977 | 2762 | |
| 15884 | 2763 | purple_mime_document_free(doc); |
| 10977 | 2764 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2765 | /* @todo should put this in its own function */ |
| 10977 | 2766 | { /* replace each IMG tag's SRC attribute with an ID attribute. This |
| 2767 | actually modifies the contents of str */ | |
| 2768 | GData *attribs; | |
| 2769 | char *start, *end; | |
| 2770 | char *tmp = str->str; | |
| 2771 | ||
| 15884 | 2772 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 2773 | (const char **) &end, &attribs)) { |
| 2774 | ||
| 2775 | char *alt, *align, *border, *src; | |
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2776 | int img = 0; |
| 10977 | 2777 | |
| 2778 | alt = g_datalist_get_data(&attribs, "alt"); | |
| 2779 | align = g_datalist_get_data(&attribs, "align"); | |
| 2780 | border = g_datalist_get_data(&attribs, "border"); | |
| 2781 | src = g_datalist_get_data(&attribs, "src"); | |
| 2782 | ||
|
13580
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2783 | if(src) |
|
5cf462f3bae1
[gaim-migrate @ 15961]
Christopher O'Brien <siege@pidgin.im>
parents:
13296
diff
changeset
|
2784 | 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
|
2785 | |
| 10977 | 2786 | if(img) { |
| 2787 | GString *atstr; | |
| 2788 | gsize len = (end - start); | |
| 2789 | gsize mov; | |
| 2790 | ||
| 2791 | atstr = g_string_new(""); | |
| 2792 | if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt); | |
| 2793 | if(align) g_string_append_printf(atstr, " align=\"%s\"", align); | |
| 2794 | if(border) g_string_append_printf(atstr, " border=\"%s\"", border); | |
| 2795 | ||
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
2796 | mov = g_snprintf(start, len, "<img src=\"" PURPLE_IMAGE_STORE_PROTOCOL |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
2797 | "%u\"%s", img, atstr->str); |
| 10977 | 2798 | while(mov < len) start[mov++] = ' '; |
| 2799 | ||
| 2800 | g_string_free(atstr, TRUE); | |
| 2801 | } | |
| 2802 | ||
| 2803 | g_datalist_clear(&attribs); | |
| 2804 | tmp = end + 1; | |
| 2805 | } | |
| 2806 | } | |
| 2807 | ||
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2808 | im_recv_html(conv, pd, str->str); |
| 10977 | 2809 | |
| 2810 | g_string_free(str, TRUE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2811 | |
| 10977 | 2812 | /* clean up the cid table */ |
| 2813 | g_hash_table_destroy(img_by_cid); | |
| 2814 | } | |
| 2815 | ||
| 2816 | ||
| 2817 | static void mw_conversation_recv(struct mwConversation *conv, | |
| 2818 | enum mwImSendType type, | |
| 2819 | gconstpointer msg) { | |
| 2820 | struct mwServiceIm *srvc; | |
| 2821 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2822 | struct mwPurpleProtocolData *pd; |
| 10977 | 2823 | |
| 2824 | srvc = mwConversation_getService(conv); | |
| 2825 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2826 | pd = mwSession_getClientData(session); | |
| 2827 | ||
| 2828 | switch(type) { | |
| 2829 | case mwImSend_PLAIN: | |
| 2830 | im_recv_text(conv, pd, msg); | |
| 2831 | break; | |
| 2832 | ||
| 2833 | case mwImSend_TYPING: | |
| 2834 | im_recv_typing(conv, pd, !! msg); | |
| 2835 | break; | |
| 2836 | ||
| 2837 | case mwImSend_HTML: | |
| 2838 | im_recv_html(conv, pd, msg); | |
| 2839 | break; | |
| 2840 | ||
| 2841 | case mwImSend_SUBJECT: | |
| 2842 | im_recv_subj(conv, pd, msg); | |
| 2843 | break; | |
| 2844 | ||
| 2845 | case mwImSend_MIME: | |
| 2846 | im_recv_mime(conv, pd, msg); | |
| 2847 | break; | |
| 2848 | ||
| 2849 | default: | |
| 2850 | DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
| 2851 | ; /* erm... */ | |
| 2852 | } | |
| 2853 | } | |
| 2854 | ||
| 2855 | ||
| 2856 | static void mw_place_invite(struct mwConversation *conv, | |
| 2857 | const char *message, | |
| 2858 | const char *title, const char *name) { | |
| 2859 | struct mwServiceIm *srvc; | |
| 2860 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2861 | struct mwPurpleProtocolData *pd; |
| 10977 | 2862 | |
| 2863 | struct mwIdBlock *idb; | |
| 2864 | GHashTable *ht; | |
| 2865 | ||
| 2866 | srvc = mwConversation_getService(conv); | |
| 2867 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2868 | pd = mwSession_getClientData(session); | |
| 2869 | ||
| 2870 | idb = mwConversation_getTarget(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2871 | |
| 10977 | 2872 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 2873 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
| 2874 | g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
| 2875 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
| 2876 | 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
|
2877 | g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
| 10977 | 2878 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2879 | if(! title) title = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2880 | if(! message) message = "(no message)"; |
| 35501 | 2881 | purple_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
|
2882 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2883 | mwConversation_close(conv, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2884 | mwConversation_free(conv); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2885 | } |
| 10977 | 2886 | |
| 2887 | ||
| 2888 | static void mw_im_clear(struct mwServiceIm *srvc) { | |
| 2889 | ; | |
| 2890 | } | |
| 2891 | ||
| 2892 | ||
| 2893 | static struct mwImHandler mw_im_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2894 | mw_conversation_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2895 | mw_conversation_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2896 | mw_conversation_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2897 | mw_place_invite, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2898 | mw_im_clear, |
| 10977 | 2899 | }; |
| 2900 | ||
| 2901 | ||
| 2902 | static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
| 2903 | struct mwServiceIm *srvc; | |
| 2904 | srvc = mwServiceIm_new(s, &mw_im_handler); | |
| 2905 | mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
| 2906 | return srvc; | |
| 2907 | } | |
| 2908 | ||
| 2909 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2910 | /* 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
|
2911 | 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
|
2912 | the similar macros from the conference service above */ |
|
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 | #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2915 | #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
|
2916 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2917 | #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
|
2918 | #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
|
2919 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2920 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2921 | static struct mwPlace * |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2922 | place_find_by_id(struct mwPurpleProtocolData *pd, int id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2923 | struct mwServicePlace *srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2924 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2925 | GList *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2926 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2927 | l = (GList *) mwServicePlace_getPlaces(srvc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2928 | for(; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2929 | 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
|
2930 | PurpleChatConversation *h = mwPlace_getClientData(p); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2931 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2932 | if(CHAT_TO_ID(h) == id) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2933 | place = p; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2934 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2935 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2936 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2937 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2938 | return place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2939 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2940 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2941 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2942 | static void mw_place_opened(struct mwPlace *place) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2943 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2944 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2945 | struct mwPurpleProtocolData *pd; |
| 15884 | 2946 | PurpleConnection *gc; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2947 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2948 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2949 | GList *members, *l; |
|
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 | const char *n = mwPlace_getName(place); |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2952 | const char *t = mwPlace_getTitle(place); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2953 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2954 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2955 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2956 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2957 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2958 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2959 | members = mwPlace_getMembers(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2960 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2961 | DEBUG_INFO("place %s opened, %u initial members\n", |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2962 | NSTR(n), g_list_length(members)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2963 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2964 | if(! t) t = "(no title)"; |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2965 | gconf = purple_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
|
2966 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2967 | mwPlace_setClientData(place, gconf, NULL); |
|
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 | for(l = members; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2970 | 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
|
2971 | 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
|
2972 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2973 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2974 | g_list_free(members); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2975 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2976 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2977 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2978 | static void mw_place_closed(struct mwPlace *place, guint32 code) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2979 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2980 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2981 | struct mwPurpleProtocolData *pd; |
| 15884 | 2982 | PurpleConnection *gc; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2983 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2984 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2985 | char *msg = mwError(code); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2986 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2987 | 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
|
2988 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2989 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2990 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2991 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2992 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2993 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2994 | purple_serv_got_chat_left(gc, PLACE_TO_ID(place)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2995 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2996 | 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
|
2997 | purple_request_cpar_from_connection(gc)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2998 | g_free(msg); |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3001 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3002 | static void mw_place_peerJoined(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3003 | 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
|
3004 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3005 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3006 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3007 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3008 | DEBUG_INFO("%s joined place %s\n", NSTR(peer->user), NSTR(n)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3009 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3010 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3011 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3012 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3013 | 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
|
3014 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3015 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3016 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3017 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3018 | static void mw_place_peerParted(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3019 | 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
|
3020 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3021 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3022 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3023 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3024 | 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
|
3025 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3026 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3027 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3028 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
3029 | purple_chat_conversation_remove_user(gconf, peer->user, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3030 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3031 | |
|
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_peerSetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3034 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3035 | guint32 attr, struct mwOpaque *o) { |
|
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 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3038 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3039 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3040 | static void mw_place_peerUnsetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3041 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3042 | guint32 attr) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3043 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3044 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3045 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3046 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3047 | static void mw_place_message(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3048 | const struct mwIdBlock *who, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3049 | const char *msg) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3050 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3051 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3052 | struct mwPurpleProtocolData *pd; |
| 15884 | 3053 | PurpleConnection *gc; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3054 | char *esc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3055 | |
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3056 | if(! msg) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
3057 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3058 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3059 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3060 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3061 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3062 | |
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
3063 | esc = g_markup_escape_text(msg, -1); |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
3064 | purple_serv_got_chat_in(gc, PLACE_TO_ID(place), who->user, |
|
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
3065 | PURPLE_MESSAGE_RECV, esc, time(NULL)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3066 | g_free(esc); |
|
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 | static void mw_place_clear(struct mwServicePlace *srvc) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3071 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3072 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3073 | |
|
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 | static struct mwPlaceHandler mw_place_handler = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3076 | mw_place_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3077 | mw_place_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3078 | mw_place_peerJoined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3079 | mw_place_peerParted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3080 | mw_place_peerSetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3081 | mw_place_peerUnsetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3082 | mw_place_message, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3083 | mw_place_clear, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3084 | }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3085 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3086 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3087 | static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3088 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3089 | srvc = mwServicePlace_new(s, &mw_place_handler); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3090 | return srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3091 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3092 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3093 | |
| 10977 | 3094 | static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
| 3095 | struct mwServiceResolve *srvc; | |
| 3096 | srvc = mwServiceResolve_new(s); | |
| 3097 | return srvc; | |
| 3098 | } | |
| 3099 | ||
| 3100 | ||
| 3101 | static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
| 3102 | struct mwServiceStorage *srvc; | |
| 3103 | srvc = mwServiceStorage_new(s); | |
| 3104 | return srvc; | |
| 3105 | } | |
| 3106 | ||
| 3107 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3108 | /** allocate and associate a mwPurpleProtocolData with a PurpleConnection */ |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3109 | static struct mwPurpleProtocolData *mwPurpleProtocolData_new(PurpleConnection *gc) { |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3110 | struct mwPurpleProtocolData *pd; |
| 10977 | 3111 | |
| 3112 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3113 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3114 | pd = g_new0(struct mwPurpleProtocolData, 1); |
| 10977 | 3115 | pd->gc = gc; |
| 3116 | pd->session = mwSession_new(&mw_session_handler); | |
| 3117 | pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
| 3118 | pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
| 3119 | pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
| 3120 | pd->srvc_im = mw_srvc_im_new(pd->session); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3121 | pd->srvc_place = mw_srvc_place_new(pd->session); |
| 10977 | 3122 | pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
| 3123 | pd->srvc_store = mw_srvc_store_new(pd->session); | |
| 3124 | 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
|
3125 | pd->sock_buf = purple_circular_buffer_new(0); |
| 10977 | 3126 | |
| 3127 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
| 3128 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
| 3129 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
| 3130 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3131 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
| 10977 | 3132 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
| 3133 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
| 3134 | ||
| 3135 | 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
|
3136 | mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 10977 | 3137 | |
| 3138 | 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
|
3139 | purple_connection_set_protocol_data(gc, pd); |
| 10977 | 3140 | |
| 3141 | return pd; | |
| 3142 | } | |
| 3143 | ||
| 3144 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3145 | static void mwPurpleProtocolData_free(struct mwPurpleProtocolData *pd) { |
| 10977 | 3146 | g_return_if_fail(pd != NULL); |
| 3147 | ||
|
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
|
3148 | purple_connection_set_protocol_data(pd->gc, NULL); |
| 10977 | 3149 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3150 | mwSession_removeService(pd->session, mwService_AWARE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3151 | mwSession_removeService(pd->session, mwService_CONFERENCE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3152 | mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3153 | mwSession_removeService(pd->session, mwService_IM); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3154 | mwSession_removeService(pd->session, mwService_PLACE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3155 | mwSession_removeService(pd->session, mwService_RESOLVE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3156 | mwSession_removeService(pd->session, mwService_STORAGE); |
| 10977 | 3157 | |
| 3158 | mwService_free(MW_SERVICE(pd->srvc_aware)); | |
| 3159 | mwService_free(MW_SERVICE(pd->srvc_conf)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3160 | mwService_free(MW_SERVICE(pd->srvc_ft)); |
| 10977 | 3161 | mwService_free(MW_SERVICE(pd->srvc_im)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3162 | mwService_free(MW_SERVICE(pd->srvc_place)); |
| 10977 | 3163 | mwService_free(MW_SERVICE(pd->srvc_resolve)); |
| 3164 | mwService_free(MW_SERVICE(pd->srvc_store)); | |
| 3165 | ||
| 3166 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3167 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
| 10977 | 3168 | |
| 3169 | mwSession_free(pd->session); | |
| 3170 | ||
| 3171 | 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
|
3172 | g_object_unref(G_OBJECT(pd->sock_buf)); |
| 10977 | 3173 | |
| 3174 | g_free(pd); | |
| 3175 | } | |
| 3176 | ||
| 3177 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3178 | static const char *mw_protocol_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
| 10977 | 3179 | /* my little green dude is a chopped up version of the aim running |
| 3180 | guy. First, cut off the head and store someplace safe. Then, | |
| 3181 | take the left-half side of the body and throw it away. Make a | |
| 3182 | copy of the remaining body, and flip it horizontally. Now attach | |
| 3183 | the two pieces into an X shape, and drop the head back on the | |
| 3184 | top, being careful to center it. Then, just change the color | |
| 3185 | saturation to bring the red down a bit, and voila! */ | |
| 3186 | ||
| 3187 | /* then, throw all of that away and use sodipodi to make a new | |
| 3188 | icon. You know, LIKE A REAL MAN. */ | |
| 3189 | ||
| 3190 | return "meanwhile"; | |
| 3191 | } | |
| 3192 | ||
| 3193 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3194 | static const char* mw_protocol_list_emblem(PurpleBuddy *b) |
| 15524 | 3195 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3196 | if(buddy_is_external(b)) |
| 15524 | 3197 | return "external"; |
| 3198 | ||
| 3199 | return NULL; | |
| 10977 | 3200 | } |
| 3201 | ||
| 3202 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3203 | static char *mw_protocol_status_text(PurpleBuddy *b) { |
| 15884 | 3204 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3205 | struct mwPurpleProtocolData *pd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3206 | 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
|
3207 | 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
|
3208 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3209 | 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
|
3210 | && (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
|
3211 | 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
|
3212 | |
|
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
|
3213 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3214 | } |
| 3215 | ||
| 3216 | ||
| 15884 | 3217 | static const char *status_text(PurpleBuddy *b) { |
| 3218 | PurplePresence *presence; | |
| 3219 | PurpleStatus *status; | |
| 3220 | ||
| 3221 | presence = purple_buddy_get_presence(b); | |
| 3222 | status = purple_presence_get_active_status(presence); | |
| 3223 | ||
| 3224 | return purple_status_get_name(status); | |
| 10977 | 3225 | } |
| 3226 | ||
| 3227 | ||
| 3228 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3229 | const char *who, guint32 feature) { | |
| 3230 | ||
| 3231 | const struct mwAwareAttribute *attr; | |
| 3232 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3233 | ||
| 3234 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3235 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3236 | } | |
| 3237 | ||
| 3238 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3239 | 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
|
3240 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3241 | const char **f = feat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3242 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3243 | if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3244 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3245 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3246 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3247 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3248 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3249 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3250 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3251 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3252 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3253 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3254 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3255 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3256 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3257 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3258 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3259 | /* jenni loves siege */ |
| 10977 | 3260 | } |
| 3261 | ||
| 3262 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3263 | static void mw_protocol_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { |
| 15884 | 3264 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3265 | struct mwPurpleProtocolData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3266 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3267 | |
|
19586
21a91bf371dd
Fix crashing when the sametime account disconnects and we update the conv. window infopanel. Fixes #2762.
Daniel Atallah <datallah@pidgin.im>
parents:
18861
diff
changeset
|
3268 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3269 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3270 | char *tmp; |
| 10977 | 3271 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3272 | if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
|
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
|
3273 | && (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
|
3274 | 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
|
3275 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3276 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3277 | |
|
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
|
3278 | 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
|
3279 | 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
|
3280 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3281 | } 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
|
3282 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status); |
| 10977 | 3283 | } |
| 3284 | ||
|
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
|
3285 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3286 | 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
|
3287 | 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
|
3288 | 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
|
3289 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3290 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3291 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3292 | 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
|
3293 | 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
|
3294 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3295 | } |
| 10977 | 3296 | } |
| 3297 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3298 | static GList *mw_protocol_status_types(PurpleAccount *acct) |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3299 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3300 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3301 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3302 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3303 | 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
|
3304 | MW_STATE_ACTIVE, NULL, TRUE, TRUE, FALSE, |
|
35005
bff56dfca65d
Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
3305 | MW_STATE_MESSAGE, _("Message"), purple_value_new(G_TYPE_STRING), |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3306 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3307 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3308 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3309 | 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
|
3310 | MW_STATE_AWAY, NULL, TRUE, TRUE, FALSE, |
|
35005
bff56dfca65d
Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
3311 | MW_STATE_MESSAGE, _("Message"), purple_value_new(G_TYPE_STRING), |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3312 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3313 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3314 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3315 | 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
|
3316 | MW_STATE_BUSY, _("Do Not Disturb"), TRUE, TRUE, FALSE, |
|
35005
bff56dfca65d
Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
3317 | MW_STATE_MESSAGE, _("Message"), purple_value_new(G_TYPE_STRING), |
|
25890
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3318 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3319 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3320 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3321 | 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
|
3322 | 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
|
3323 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3324 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3325 | return types; |
| 10977 | 3326 | } |
| 3327 | ||
| 3328 | ||
| 15884 | 3329 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3330 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3331 | ; /* nothing to do */ |
| 10977 | 3332 | } |
| 3333 | ||
| 3334 | ||
| 15884 | 3335 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3336 | PurpleRequestFields *fields) { | |
| 3337 | PurpleAccount *acct; | |
| 3338 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3339 | struct mwPurpleProtocolData *pd; |
| 10977 | 3340 | struct mwServiceConference *srvc; |
| 3341 | ||
| 15884 | 3342 | PurpleRequestField *f; |
| 10977 | 3343 | |
| 3344 | const char *topic, *invite; | |
| 3345 | struct mwConference *conf; | |
| 3346 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3347 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3348 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3349 | 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
|
3350 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3351 | srvc = pd->srvc_conf; |
| 3352 | ||
| 15884 | 3353 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3354 | topic = purple_request_field_string_get_value(f); | |
| 3355 | ||
| 3356 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3357 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3358 | |
| 3359 | conf = mwConference_new(srvc, topic); | |
| 3360 | mwConference_open(conf); | |
| 3361 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3362 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3363 | mwConference_invite(conf, &idb, invite); |
| 3364 | } | |
| 3365 | ||
| 3366 | ||
| 15884 | 3367 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3368 | ||
| 3369 | PurpleRequestFields *fields; | |
| 3370 | PurpleRequestFieldGroup *g; | |
| 3371 | PurpleRequestField *f; | |
| 3372 | ||
| 3373 | PurpleAccount *acct; | |
| 3374 | PurpleConnection *gc; | |
| 10977 | 3375 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3376 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3377 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3378 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3379 | |
| 10977 | 3380 | g_return_if_fail(buddy != NULL); |
| 3381 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3382 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3383 | g_return_if_fail(acct != NULL); |
| 3384 | ||
| 15884 | 3385 | gc = purple_account_get_connection(acct); |
| 10977 | 3386 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3387 | |
| 15884 | 3388 | fields = purple_request_fields_new(); |
| 3389 | ||
| 3390 | g = purple_request_field_group_new(NULL); | |
| 3391 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3392 | |
| 15884 | 3393 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3394 | purple_request_field_group_add_field(g, f); | |
| 3395 | ||
| 3396 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3397 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3398 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3399 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3400 | 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
|
3401 | " 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
|
3402 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3403 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3404 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3405 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3406 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3407 | _("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
|
3408 | purple_request_cpar_from_account(acct), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3409 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3410 | g_free(msg1); |
| 10977 | 3411 | } |
| 3412 | ||
| 3413 | ||
| 15884 | 3414 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3415 | PurpleRequestFields *fields) { | |
| 10977 | 3416 | ; |
| 3417 | } | |
| 3418 | ||
| 3419 | ||
| 15884 | 3420 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3421 | PurpleRequestFields *fields) { | |
| 3422 | 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
|
3423 | GList *l; |
| 10977 | 3424 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3425 | |
| 15884 | 3426 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3427 | msg = purple_request_field_string_get_value(f); | |
| 3428 | ||
| 3429 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3430 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3431 | |
| 3432 | if(l) { | |
| 15884 | 3433 | 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
|
3434 | |
| 10977 | 3435 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3436 | blist_menu_conf_create(buddy, msg); | |
| 3437 | ||
| 3438 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3439 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3440 | mwConference_invite(d, &idb, msg); |
| 3441 | } | |
| 3442 | } | |
| 3443 | } | |
| 3444 | ||
| 3445 | ||
| 15884 | 3446 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3447 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3448 | |
| 15884 | 3449 | PurpleRequestFields *fields; |
| 3450 | PurpleRequestFieldGroup *g; | |
| 3451 | PurpleRequestField *f; | |
| 3452 | ||
| 3453 | PurpleAccount *acct; | |
| 3454 | PurpleConnection *gc; | |
| 10977 | 3455 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3456 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3457 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3458 | char *msg; |
| 10977 | 3459 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3460 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3461 | g_return_if_fail(acct != NULL); |
| 3462 | ||
| 15884 | 3463 | gc = purple_account_get_connection(acct); |
| 10977 | 3464 | g_return_if_fail(gc != NULL); |
| 3465 | ||
| 15884 | 3466 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3467 | |
| 15884 | 3468 | g = purple_request_field_group_new(NULL); |
| 3469 | purple_request_fields_add_group(fields, g); | |
| 3470 | ||
| 3471 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3472 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3473 | for(; confs; confs = confs->next) { |
| 3474 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3475 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3476 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3477 | 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
|
3478 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3479 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3480 | |
| 15884 | 3481 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3482 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3483 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3484 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3485 | 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
|
3486 | " 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
|
3487 | " 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
|
3488 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3489 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3490 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3491 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3492 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3493 | _("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
|
3494 | purple_request_cpar_from_account(acct), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3495 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3496 | g_free(msg); |
| 10977 | 3497 | } |
| 3498 | ||
| 3499 | ||
| 15884 | 3500 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 3501 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3502 | PurpleAccount *acct; | |
| 3503 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3504 | struct mwPurpleProtocolData *pd; |
| 10977 | 3505 | GList *l; |
| 3506 | ||
| 3507 | 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
|
3508 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 10977 | 3509 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3510 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3511 | g_return_if_fail(acct != NULL); |
| 3512 | ||
| 15884 | 3513 | gc = purple_account_get_connection(acct); |
| 10977 | 3514 | g_return_if_fail(gc != NULL); |
| 3515 | ||
|
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
|
3516 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3517 | g_return_if_fail(pd != NULL); |
| 3518 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3519 | /* |
| 10977 | 3520 | - get a list of all conferences on this session |
| 3521 | - if none, prompt to create one, and invite buddy to it | |
| 3522 | - else, prompt to select a conference or create one | |
| 3523 | */ | |
| 3524 | ||
| 3525 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3526 | if(l) { | |
| 3527 | blist_menu_conf_list(buddy, l); | |
| 3528 | g_list_free(l); | |
| 3529 | ||
| 3530 | } else { | |
| 3531 | blist_menu_conf_create(buddy, NULL); | |
| 3532 | } | |
| 3533 | } | |
| 3534 | ||
| 3535 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3536 | static GList *mw_protocol_blist_node_menu(PurpleBlistNode *node) { |
| 10977 | 3537 | GList *l = NULL; |
| 15884 | 3538 | PurpleMenuAction *act; |
| 3539 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3540 | if(! PURPLE_IS_BUDDY(node)) |
| 10977 | 3541 | return l; |
| 3542 | ||
| 3543 | l = g_list_append(l, NULL); | |
| 3544 | ||
| 15884 | 3545 | act = purple_menu_action_new(_("Invite to Conference..."), |
| 3546 | PURPLE_CALLBACK(blist_menu_conf), NULL, NULL); | |
| 10977 | 3547 | l = g_list_append(l, act); |
| 3548 | ||
| 15884 | 3549 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3550 | blist-node-extended-menu signal for that. The function |
| 3551 | blist_node_menu_cb is assigned to this signal in the function | |
| 3552 | services_starting */ | |
| 3553 | ||
| 3554 | return l; | |
| 3555 | } | |
| 3556 | ||
| 3557 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3558 | static GList *mw_protocol_chat_info(PurpleConnection *gc) { |
| 10977 | 3559 | GList *l = NULL; |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3560 | PurpleProtocolChatEntry *pce; |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3561 | |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3562 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3563 | pce->label = _("Topic:"); |
| 10977 | 3564 | pce->identifier = CHAT_KEY_TOPIC; |
| 3565 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3566 | |
| 10977 | 3567 | return l; |
| 3568 | } | |
| 3569 | ||
| 3570 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3571 | static GHashTable *mw_protocol_chat_info_defaults(PurpleConnection *gc, |
| 10977 | 3572 | const char *name) { |
| 3573 | GHashTable *table; | |
| 3574 | ||
| 3575 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3576 | ||
| 3577 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3578 | NULL, g_free); | |
| 3579 | ||
| 3580 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3581 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3582 | ||
| 3583 | return table; | |
| 3584 | } | |
| 3585 | ||
| 3586 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3587 | static void mw_protocol_login(PurpleAccount *acct); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3588 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3589 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3590 | static void mw_protocol_login(PurpleAccount *account) { |
| 15884 | 3591 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3592 | struct mwPurpleProtocolData *pd; |
| 10977 | 3593 | |
| 3594 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3595 | guint port; |
| 10977 | 3596 | |
| 15884 | 3597 | gc = purple_account_get_connection(account); |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3598 | pd = mwPurpleProtocolData_new(gc); |
| 10977 | 3599 | |
| 3600 | /* 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
|
3601 | purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_IMAGES); |
| 15884 | 3602 | |
| 3603 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3604 | |
| 3605 | host = strrchr(user, ':'); | |
| 3606 | if(host) { | |
| 3607 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3608 | *host++ = '\0'; | |
| 15884 | 3609 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3610 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3611 | |
| 10977 | 3612 | } else { |
| 15884 | 3613 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3614 | MW_PLUGIN_DEFAULT_HOST); |
| 3615 | } | |
| 3616 | ||
| 3617 | if(! host || ! *host) { | |
| 3618 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3619 | 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
|
3620 | 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
|
3621 | 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
|
3622 | 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
|
3623 | _("A server is required to connect this account")); |
| 10977 | 3624 | return; |
| 3625 | } | |
| 3626 | ||
|
34022
c49f6e9ea27d
Make all the prpls build.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
3627 | pass = g_strdup(purple_connection_get_password(gc)); |
| 15884 | 3628 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3629 | |
| 3630 | DEBUG_INFO("user: '%s'\n", user); | |
| 3631 | DEBUG_INFO("host: '%s'\n", host); | |
| 3632 | DEBUG_INFO("port: %u\n", port); | |
| 3633 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3634 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3635 | (char *) no_secret, NULL); |
| 3636 | 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
|
3637 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3638 | |
| 15884 | 3639 | 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
|
3640 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3641 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3642 | /* 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
|
3643 | 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
|
3644 | |
| 15884 | 3645 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3646 | 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
|
3647 | 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
|
3648 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3649 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3650 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3651 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3652 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3653 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3654 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3655 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3656 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3657 | GUINT_TO_POINTER(major), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3658 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3659 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3660 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3661 | } |
| 10977 | 3662 | |
| 15884 | 3663 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3664 | ||
| 3665 | 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
|
3666 | 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
|
3667 | _("Unable to connect")); |
| 10977 | 3668 | } |
| 3669 | } | |
| 3670 | ||
| 3671 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3672 | static void mw_protocol_close(PurpleConnection *gc) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3673 | struct mwPurpleProtocolData *pd; |
| 10977 | 3674 | |
| 3675 | g_return_if_fail(gc != NULL); | |
| 3676 | ||
|
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
|
3677 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3678 | g_return_if_fail(pd != NULL); |
| 3679 | ||
| 3680 | /* get rid of the blist save timeout */ | |
| 3681 | if(pd->save_event) { | |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
3682 | g_source_remove(pd->save_event); |
| 10977 | 3683 | pd->save_event = 0; |
| 3684 | blist_store(pd); | |
| 3685 | } | |
| 3686 | ||
| 3687 | /* stop the session */ | |
| 3688 | mwSession_stop(pd->session, 0x00); | |
| 3689 | ||
| 3690 | /* 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
|
3691 | purple_connection_set_protocol_data(gc, NULL); |
| 10977 | 3692 | |
| 3693 | /* 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
|
3694 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3695 | 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
|
3696 | pd->inpa = 0; |
| 10977 | 3697 | } |
| 3698 | ||
| 3699 | /* clean up the rest */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3700 | mwPurpleProtocolData_free(pd); |
| 10977 | 3701 | } |
| 3702 | ||
| 3703 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21947
diff
changeset
|
3704 | static int mw_rand(void) { |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3705 | static int seed = 0; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3706 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3707 | /* for diversity, not security. don't touch */ |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3708 | srand(time(NULL) ^ seed); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3709 | seed = rand(); |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3710 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3711 | return seed; |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3712 | } |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3713 | |
|
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3714 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3715 | /** 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
|
3716 | static char *im_mime_content_id(void) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3717 | return g_strdup_printf("%03x@%05xmeanwhile", |
|
12735
daa5dfe5e65a
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3718 | mw_rand() & 0xfff, mw_rand() & 0xfffff); |
| 10977 | 3719 | } |
| 3720 | ||
| 3721 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3722 | /** generates a multipart/related content type with a random-ish |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3723 | 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
|
3724 | static char *im_mime_content_type(void) { |
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3725 | 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
|
3726 | mw_rand() & 0xfff, mw_rand() & 0xffff); |
| 10977 | 3727 | } |
| 3728 | ||
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3729 | /** determine content type from contents */ |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3730 | static gchar * |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3731 | im_mime_img_content_type(PurpleImage *img) |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3732 | { |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3733 | const gchar *mimetype; |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3734 | |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3735 | mimetype = purple_image_get_mimetype(img); |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3736 | |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3737 | if (!mimetype) |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3738 | mimetype = "image"; |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3739 | |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3740 | return g_strdup_printf("%s; name=\"%s\"", mimetype, |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3741 | purple_image_get_friendly_filename(img)); |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3742 | } |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3743 | |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3744 | |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3745 | static char * |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3746 | im_mime_img_content_disp(PurpleImage *img) { |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3747 | return g_strdup_printf("attachment; filename=\"%s\"", |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3748 | purple_image_get_friendly_filename(img)); |
| 10977 | 3749 | } |
| 3750 | ||
| 3751 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3752 | /** turn an IM with embedded images into a multi-part mime document */ |
| 15884 | 3753 | static char *im_mime_convert(PurpleConnection *gc, |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3754 | struct mwConversation *conv, |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3755 | const char *message) { |
| 10977 | 3756 | GString *str; |
| 15884 | 3757 | PurpleMimeDocument *doc; |
| 3758 | PurpleMimePart *part; | |
| 10977 | 3759 | |
| 3760 | GData *attr; | |
| 3761 | char *tmp, *start, *end; | |
| 3762 | ||
| 3763 | str = g_string_new(NULL); | |
| 3764 | ||
| 15884 | 3765 | doc = purple_mime_document_new(); |
| 3766 | ||
| 3767 | purple_mime_document_set_field(doc, "Mime-Version", "1.0"); | |
| 3768 | purple_mime_document_set_field(doc, "Content-Disposition", "inline"); | |
| 10977 | 3769 | |
| 3770 | tmp = im_mime_content_type(); | |
| 15884 | 3771 | purple_mime_document_set_field(doc, "Content-Type", tmp); |
| 10977 | 3772 | g_free(tmp); |
| 3773 | ||
| 3774 | tmp = (char *) message; | |
| 15884 | 3775 | while(*tmp && purple_markup_find_tag("img", tmp, (const char **) &start, |
| 10977 | 3776 | (const char **) &end, &attr)) { |
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3777 | gchar *uri; |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3778 | PurpleImage *img = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3779 | |
| 10977 | 3780 | gsize len = (start - tmp); |
| 3781 | ||
| 3782 | /* append the in-between-tags text */ | |
| 3783 | if(len) g_string_append_len(str, tmp, len); | |
| 3784 | ||
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3785 | uri = g_datalist_get_data(&attr, "src"); |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3786 | if (uri) |
|
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3787 | img = purple_image_store_get_from_uri(uri); |
| 10977 | 3788 | |
| 3789 | if(img) { | |
| 3790 | char *cid; | |
| 3791 | gpointer data; | |
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3792 | gsize size; |
| 10977 | 3793 | |
| 15884 | 3794 | part = purple_mime_part_new(doc); |
| 10977 | 3795 | |
| 3796 | data = im_mime_img_content_disp(img); | |
| 15884 | 3797 | purple_mime_part_set_field(part, "Content-Disposition", data); |
| 10977 | 3798 | g_free(data); |
| 3799 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3800 | data = im_mime_img_content_type(img); |
| 15884 | 3801 | purple_mime_part_set_field(part, "Content-Type", data); |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3802 | g_free(data); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3803 | |
| 10977 | 3804 | cid = im_mime_content_id(); |
| 3805 | data = g_strdup_printf("<%s>", cid); | |
| 15884 | 3806 | purple_mime_part_set_field(part, "Content-ID", data); |
| 10977 | 3807 | g_free(data); |
| 3808 | ||
| 15884 | 3809 | purple_mime_part_set_field(part, "Content-transfer-encoding", "base64"); |
| 10977 | 3810 | |
| 3811 | /* obtain and base64 encode the image data, and put it in the | |
| 3812 | mime part */ | |
|
38298
f0a8f63f9312
rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents:
37389
diff
changeset
|
3813 | size = purple_image_get_data_size(img); |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38298
diff
changeset
|
3814 | data = g_base64_encode(purple_image_get_data(img), size); |
| 15884 | 3815 | purple_mime_part_set_data(part, data); |
| 10977 | 3816 | g_free(data); |
| 3817 | ||
| 3818 | /* append the modified tag */ | |
| 3819 | g_string_append_printf(str, "<img src=\"cid:%s\">", cid); | |
| 3820 | g_free(cid); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3821 | |
| 10977 | 3822 | } else { |
| 3823 | /* append the literal image tag, since we couldn't find a | |
|
35832
3ade2f38ec3a
imgstore: unref sametime
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35501
diff
changeset
|
3824 | relative PurpleImage object */ |
| 10977 | 3825 | gsize len = (end - start) + 1; |
| 3826 | g_string_append_len(str, start, len); | |
| 3827 | } | |
| 3828 | ||
| 3829 | g_datalist_clear(&attr); | |
| 3830 | tmp = end + 1; | |
| 3831 | } | |
| 3832 | ||
| 3833 | /* append left-overs */ | |
| 3834 | g_string_append(str, tmp); | |
| 3835 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3836 | /* add the text/html part */ |
| 15884 | 3837 | part = purple_mime_part_new(doc); |
| 3838 | purple_mime_part_set_field(part, "Content-Disposition", "inline"); | |
| 3839 | ||
| 3840 | tmp = purple_utf8_ncr_encode(str->str); | |
| 3841 | purple_mime_part_set_field(part, "Content-Type", "text/html"); | |
| 3842 | purple_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); | |
| 3843 | purple_mime_part_set_data(part, tmp); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3844 | g_free(tmp); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3845 | |
| 10977 | 3846 | g_string_free(str, TRUE); |
| 3847 | ||
| 3848 | str = g_string_new(NULL); | |
| 15884 | 3849 | purple_mime_document_write(doc, str); |
| 10977 | 3850 | tmp = str->str; |
| 3851 | g_string_free(str, FALSE); | |
| 3852 | ||
| 3853 | return tmp; | |
| 3854 | } | |
| 3855 | ||
| 3856 | ||
| 37148 | 3857 | static int mw_protocol_send_im(PurpleConnection *gc, PurpleMessage *msg) { |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3858 | |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3859 | gchar name[1000]; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3860 | struct mwPurpleProtocolData *pd; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3861 | struct mwIdBlock who = { name, NULL }; |
| 10977 | 3862 | struct mwConversation *conv; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3863 | const gchar *message; |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3864 | PurpleMessageFlags flags; |
| 10977 | 3865 | |
| 3866 | 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
|
3867 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3868 | |
| 3869 | g_return_val_if_fail(pd != NULL, 0); | |
| 3870 | ||
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
3871 | g_strlcpy(name, purple_message_get_recipient(msg), sizeof(name)); |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3872 | message = purple_message_get_contents(msg); |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3873 | flags = purple_message_get_flags(msg); |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3874 | |
| 10977 | 3875 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 3876 | ||
| 3877 | /* this detection of features to determine how to send the message | |
| 3878 | (plain, html, or mime) is flawed because the other end of the | |
| 3879 | conversation could close their channel at any time, rendering any | |
| 3880 | existing formatting in an outgoing message innapropriate. The end | |
| 3881 | result is that it may be possible that the other side of the | |
| 3882 | conversation will receive a plaintext message with html contents, | |
| 3883 | which is bad. I'm not sure how to fix this correctly. */ | |
| 3884 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3885 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 3886 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 3887 | |
| 3888 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3889 | char *tmp; |
| 10977 | 3890 | int ret; |
| 3891 | ||
| 15884 | 3892 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 3893 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3894 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3895 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3896 | tmp = im_mime_convert(gc, conv, message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3897 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3898 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3899 | |
| 10977 | 3900 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3901 | /* send an HTML message */ |
| 10977 | 3902 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3903 | char *ncr; |
| 15884 | 3904 | ncr = purple_utf8_ncr_encode(message); |
| 3905 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3906 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3907 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3908 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3909 | g_free(tmp); |
| 10977 | 3910 | |
| 3911 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3912 | /* default to text */ |
| 15884 | 3913 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
3914 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3915 | g_free(tmp); |
| 10977 | 3916 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3917 | |
| 10977 | 3918 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3919 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3920 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3921 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3922 | /* queue up the message safely as plain text */ |
| 15884 | 3923 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3924 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3925 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3926 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3927 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3928 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3929 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3930 | return 1; |
| 10977 | 3931 | } |
| 3932 | } | |
| 3933 | ||
| 3934 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3935 | static unsigned int mw_protocol_send_typing(PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3936 | 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
|
3937 | PurpleIMTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3938 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3939 | struct mwPurpleProtocolData *pd; |
| 10977 | 3940 | struct mwIdBlock who = { (char *) name, NULL }; |
| 3941 | struct mwConversation *conv; | |
| 3942 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
3943 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 3944 | |
| 3945 | 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
|
3946 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3947 | |
| 3948 | g_return_val_if_fail(pd != NULL, 0); | |
| 3949 | ||
| 3950 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 3951 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3952 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3953 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3954 | |
|
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
|
3955 | } 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
|
3956 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3957 | 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
|
3958 | 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
|
3959 | |
| 10977 | 3960 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3961 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3962 | if(! mwConversation_isPending(conv)) { |
| 10977 | 3963 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3964 | } |
| 10977 | 3965 | } |
| 3966 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3967 | return 0; |
| 10977 | 3968 | } |
| 3969 | ||
| 3970 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3971 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3972 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3973 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3974 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3975 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3976 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3977 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3978 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3979 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3980 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3981 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3982 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3983 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3984 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3985 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3986 | return "Lotus Sametime Links"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3987 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3988 | case mwLogin_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3989 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3990 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3991 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3992 | return "Lotus Notes Client"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3993 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3994 | case mwLogin_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3995 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3996 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3997 | return "IBM Community Tools"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3998 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3999 | case mwLogin_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4000 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4001 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4002 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4003 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4004 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4005 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4006 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4007 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4008 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4009 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4010 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4011 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4012 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4013 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4014 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4015 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4016 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4017 | return "Trillian"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4018 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4019 | case mwLogin_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4020 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4021 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4022 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4023 | return NULL; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4024 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4025 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4026 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4027 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4028 | static void mw_protocol_get_info(PurpleConnection *gc, const char *who) { |
| 10977 | 4029 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4030 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4031 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4032 | struct mwPurpleProtocolData *pd; |
| 15884 | 4033 | PurpleAccount *acct; |
| 4034 | PurpleBuddy *b; | |
| 4035 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4036 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4037 | const char *tmp2; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4038 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4039 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4040 | g_return_if_fail(*who != '\0'); |
| 10977 | 4041 | |
|
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
|
4042 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4043 | |
| 15884 | 4044 | 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
|
4045 | b = purple_blist_find_buddy(acct, who); |
| 15884 | 4046 | user_info = purple_notify_user_info_new(); |
| 4047 | ||
| 4048 | 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
|
4049 | purple_notify_user_info_add_pair_html(user_info, _("External User"), NULL); |
| 10977 | 4050 | } |
| 4051 | ||
|
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
|
4052 | 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
|
4053 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4054 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4055 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4056 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4057 | 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
|
4058 | /* 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
|
4059 | 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
|
4060 | 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
|
4061 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4062 | |
| 15884 | 4063 | 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
|
4064 | 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
|
4065 | 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
|
4066 | 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
|
4067 | 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
|
4068 | } else { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4069 | 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
|
4070 | 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
|
4071 | 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
|
4072 | } |
| 10977 | 4073 | } |
| 4074 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4075 | |
| 10977 | 4076 | tmp = user_supports_text(pd->srvc_aware, who); |
| 4077 | 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
|
4078 | 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
|
4079 | g_free(tmp); |
| 10977 | 4080 | } |
| 4081 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4082 | 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
|
4083 | 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
|
4084 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
4085 | /* 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
|
4086 | 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
|
4087 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
| 15884 | 4088 | 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
|
4089 | 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
|
4090 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4091 | } |
| 10977 | 4092 | |
| 4093 | /* @todo emit a signal to allow a plugin to override the display of | |
| 4094 | this notification, so that it can create its own */ | |
| 4095 | ||
| 15884 | 4096 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 4097 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 4098 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4099 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4100 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4101 | static void mw_protocol_set_status(PurpleAccount *acct, PurpleStatus *status) { |
| 15884 | 4102 | PurpleConnection *gc; |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4103 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
4104 | char *message = NULL; |
| 10977 | 4105 | struct mwSession *session; |
| 4106 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4107 | |
| 10977 | 4108 | g_return_if_fail(acct != NULL); |
| 15884 | 4109 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4110 | |
| 15884 | 4111 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4112 | |
| 15884 | 4113 | 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
|
4114 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4115 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4116 | |
| 10977 | 4117 | session = gc_to_session(gc); |
| 4118 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4119 | |
| 10977 | 4120 | /* get a working copy of the current status */ |
| 4121 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4122 | |
| 10977 | 4123 | /* determine the state */ |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4124 | if(purple_strequal(state, MW_STATE_ACTIVE)) { |
| 10977 | 4125 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4126 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4127 | } else if(purple_strequal(state, MW_STATE_AWAY)) { |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4128 | stat.status = mwStatus_AWAY; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4129 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4130 | } else if(purple_strequal(state, MW_STATE_BUSY)) { |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4131 | stat.status = mwStatus_BUSY; |
| 10977 | 4132 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4133 | |
| 10977 | 4134 | /* determine the message */ |
| 15884 | 4135 | 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
|
4136 | |
| 10977 | 4137 | if(message) { |
| 4138 | /* all the possible non-NULL values of message up to this point | |
| 4139 | are const, so we don't need to free them */ | |
| 15884 | 4140 | message = purple_markup_strip_html(message); |
| 10977 | 4141 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4142 | |
| 10977 | 4143 | /* out with the old */ |
| 4144 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4145 | |
| 10977 | 4146 | /* in with the new */ |
| 4147 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4148 | |
| 10977 | 4149 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4150 | mwUserStatus_clear(&stat); |
| 10977 | 4151 | } |
| 4152 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4153 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4154 | static void mw_protocol_set_idle(PurpleConnection *gc, int t) { |
| 10977 | 4155 | struct mwSession *session; |
| 4156 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4157 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4158 | |
| 10977 | 4159 | session = gc_to_session(gc); |
| 4160 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4161 | |
| 10977 | 4162 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4163 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4164 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4165 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4166 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4167 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4168 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4169 | stat.time = 0; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4170 | } |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4171 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4172 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4173 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4174 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4175 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4176 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4177 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4178 | stat.status = mwStatus_ACTIVE; |
| 4179 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4180 | |
| 10977 | 4181 | mwSession_setUserStatus(session, &stat); |
| 4182 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4183 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4184 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4185 | |
| 15884 | 4186 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4187 | PurpleAccount *acct; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4188 | PurpleIMConversation *im; |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4189 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4190 | |
| 15884 | 4191 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4192 | 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
|
4193 | 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
|
4194 | 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
|
4195 | purple_conversation_present(PURPLE_CONVERSATION(im)); |
| 15884 | 4196 | } |
| 4197 | ||
| 4198 | ||
| 4199 | 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
|
4200 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4201 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4202 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4203 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4204 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4205 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4206 | |
| 15884 | 4207 | 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
|
4208 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4209 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4210 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4211 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4212 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4213 | static void notify_close(gpointer data) { |
|
37389
7240fd8e3462
free() and g_free() are specified to be NULL-safe. Remove NULL checks.
Michael McConville <mmcconville@mykolab.com>
parents:
37163
diff
changeset
|
4214 | g_free(data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4215 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4216 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4217 | |
| 10977 | 4218 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4219 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4220 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4221 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4222 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4223 | char *msg; |
| 10977 | 4224 | |
| 15884 | 4225 | PurpleNotifySearchResults *sres; |
| 4226 | PurpleNotifySearchColumn *scol; | |
| 4227 | ||
| 4228 | sres = purple_notify_searchresults_new(); | |
| 4229 | ||
| 4230 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4231 | purple_notify_searchresults_column_add(sres, scol); | |
| 4232 | ||
| 4233 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4234 | purple_notify_searchresults_column_add(sres, scol); | |
| 4235 | ||
| 4236 | 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
|
4237 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4238 | |
| 15884 | 4239 | 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
|
4240 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4241 | |
| 10977 | 4242 | for(l = result->matches; l; l = l->next) { |
| 4243 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4244 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4245 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4246 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4247 | NSTR(match->id), NSTR(match->name)); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4248 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4249 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4250 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4251 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4252 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4253 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4254 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4255 | } |
| 10977 | 4256 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4257 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4258 | 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
|
4259 | " 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
|
4260 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4261 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4262 | |
| 15884 | 4263 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4264 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4265 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4266 | g_free(msg); |
| 10977 | 4267 | } |
| 4268 | ||
| 4269 | ||
| 4270 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4271 | guint32 id, guint32 code, GList *results, | |
| 4272 | gpointer b) { | |
| 4273 | ||
| 4274 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4275 | BuddyAddData *data = b; |
| 15884 | 4276 | PurpleBuddy *buddy = NULL; |
| 4277 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4278 | struct mwPurpleProtocolData *pd; |
| 10977 | 4279 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4280 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4281 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4282 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4283 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4284 | 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
|
4285 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4286 | |
| 4287 | if(results) | |
| 4288 | res = results->data; | |
| 4289 | ||
| 4290 | 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
|
4291 | if(!res->matches->next) { |
| 10977 | 4292 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4293 | |
| 10977 | 4294 | /* only one? that might be the right one! */ |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4295 | if(!purple_strequal(res->name, match->id)) { |
| 10977 | 4296 | /* uh oh, the single result isn't identical to the search |
| 4297 | term, better safe then sorry, so let's make sure it's who | |
| 4298 | the user meant to add */ | |
| 15884 | 4299 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4300 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4301 | |
| 10977 | 4302 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4303 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4304 | /* 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
|
4305 | purple_buddy_set_server_alias(buddy, match->name); |
| 15884 | 4306 | purple_blist_node_set_string((PurpleBlistNode *) buddy, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4307 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4308 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4309 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4310 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4311 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4312 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4313 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4314 | g_free(data); |
| 10977 | 4315 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4316 | |
| 10977 | 4317 | } else { |
| 4318 | /* prompt user if more than one match was returned */ | |
| 15884 | 4319 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4320 | multi_resolved_query(res, gc, data); |
| 10977 | 4321 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4322 | |
| 10977 | 4323 | return; |
| 4324 | } | |
| 4325 | } | |
| 4326 | ||
| 4327 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4328 | static void mw_protocol_add_buddy(PurpleConnection *gc, |
| 15884 | 4329 | PurpleBuddy *buddy, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4330 | PurpleGroup *group, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4331 | const char *message) { |
| 15884 | 4332 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4333 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4334 | struct mwServiceResolve *srvc; |
| 4335 | GList *query; | |
| 4336 | enum mwResolveFlag flags; | |
| 4337 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4338 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4339 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4340 | /* 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
|
4341 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4342 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4343 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4344 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4345 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4346 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4347 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4348 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4349 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4350 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4351 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4352 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4353 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4354 | ||
| 4355 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4356 | data, NULL); |
| 10977 | 4357 | g_list_free(query); |
| 4358 | ||
| 4359 | if(req == SEARCH_ERROR) { | |
| 15884 | 4360 | purple_blist_remove_buddy(buddy); |
| 10977 | 4361 | blist_schedule(pd); |
| 4362 | } | |
| 4363 | } | |
| 4364 | ||
| 4365 | ||
| 15884 | 4366 | static void foreach_add_buddies(PurpleGroup *group, GList *buddies, |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4367 | struct mwPurpleProtocolData *pd) { |
| 10977 | 4368 | struct mwAwareList *list; |
| 4369 | ||
| 4370 | list = list_ensure(pd, group); | |
| 4371 | mwAwareList_addAware(list, buddies); | |
| 4372 | g_list_free(buddies); | |
| 4373 | } | |
| 4374 | ||
| 4375 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4376 | static void mw_protocol_add_buddies(PurpleConnection *gc, |
| 10977 | 4377 | GList *buddies, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4378 | GList *groups, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4379 | const char *message) { |
| 10977 | 4380 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4381 | struct mwPurpleProtocolData *pd; |
| 10977 | 4382 | GHashTable *group_sets; |
| 4383 | struct mwAwareIdBlock *idbs, *idb; | |
| 4384 | ||
|
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
|
4385 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4386 | |
| 15884 | 4387 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4388 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4389 | ||
| 4390 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4391 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4392 | ||
| 4393 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4394 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4395 | PurpleBuddy *b = buddies->data; |
| 4396 | PurpleGroup *g; | |
| 10977 | 4397 | const char *fn; |
| 4398 | GList *l; | |
| 4399 | ||
| 4400 | /* nab the saved server alias and stick it on the buddy */ | |
| 15884 | 4401 | 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
|
4402 | purple_buddy_set_server_alias(b, fn); |
| 15884 | 4403 | |
| 4404 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4405 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4406 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4407 | idb->community = NULL; |
| 4408 | ||
| 4409 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4410 | g = purple_buddy_get_group(b); |
| 10977 | 4411 | l = g_hash_table_lookup(group_sets, g); |
| 4412 | l = g_list_prepend(l, idb++); | |
| 4413 | g_hash_table_insert(group_sets, g, l); | |
| 4414 | } | |
| 4415 | ||
| 4416 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4417 | for saving */ | |
| 4418 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4419 | blist_schedule(pd); | |
| 4420 | ||
| 4421 | /* cleanup */ | |
| 4422 | g_hash_table_destroy(group_sets); | |
| 4423 | g_free(idbs); | |
| 4424 | } | |
| 4425 | ||
| 4426 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4427 | static void mw_protocol_remove_buddy(PurpleConnection *gc, |
| 15884 | 4428 | PurpleBuddy *buddy, PurpleGroup *group) { |
| 4429 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4430 | struct mwPurpleProtocolData *pd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4431 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4432 | struct mwAwareList *list; |
| 4433 | ||
| 4434 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4435 | ||
|
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
|
4436 | pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4437 | group = purple_buddy_get_group(buddy); |
| 10977 | 4438 | list = list_ensure(pd, group); |
| 4439 | ||
| 4440 | mwAwareList_removeAware(list, rem); | |
| 4441 | blist_schedule(pd); | |
| 4442 | ||
| 4443 | g_list_free(rem); | |
| 4444 | } | |
| 4445 | ||
| 4446 | ||
| 4447 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4448 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4449 | |
| 10977 | 4450 | struct mwUserItem *u; |
| 4451 | guint count; | |
| 4452 | ||
| 4453 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4454 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4455 | |
| 4456 | priv->count = count; | |
| 4457 | priv->users = g_new0(struct mwUserItem, count); | |
| 4458 | ||
| 4459 | while(count--) { | |
| 4460 | u = priv->users + count; | |
| 4461 | u->id = members->data; | |
| 4462 | members = members->next; | |
| 4463 | } | |
| 4464 | } | |
| 4465 | ||
| 4466 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4467 | static void mw_protocol_set_permit_deny(PurpleConnection *gc) { |
| 15884 | 4468 | PurpleAccount *acct; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4469 | struct mwPurpleProtocolData *pd; |
| 10977 | 4470 | struct mwSession *session; |
| 4471 | ||
| 4472 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4473 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4474 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4475 | NULL, /* users */ |
| 10977 | 4476 | }; |
| 4477 | ||
| 4478 | g_return_if_fail(gc != NULL); | |
| 4479 | ||
| 15884 | 4480 | acct = purple_connection_get_account(gc); |
| 10977 | 4481 | g_return_if_fail(acct != NULL); |
| 4482 | ||
|
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
|
4483 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4484 | g_return_if_fail(pd != NULL); |
| 4485 | ||
| 4486 | session = pd->session; | |
| 4487 | g_return_if_fail(session != NULL); | |
| 4488 | ||
|
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
|
4489 | 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
|
4490 | case PURPLE_ACCOUNT_PRIVACY_DENY_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4491 | 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
|
4492 | privacy_fill(&privacy, purple_account_privacy_get_denied(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4493 | privacy.deny = TRUE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4494 | break; |
| 10977 | 4495 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4496 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4497 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL\n"); |
| 10977 | 4498 | privacy.deny = TRUE; |
| 4499 | break; | |
| 4500 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4501 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4502 | 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
|
4503 | privacy_fill(&privacy, purple_account_privacy_get_permitted(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4504 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4505 | break; |
| 10977 | 4506 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4507 | case PURPLE_ACCOUNT_PRIVACY_DENY_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4508 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_DENY_ALL\n"); |
| 10977 | 4509 | privacy.deny = FALSE; |
| 4510 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4511 | |
| 10977 | 4512 | 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
|
4513 | 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
|
4514 | return; |
| 10977 | 4515 | } |
| 4516 | ||
| 4517 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4518 | g_free(privacy.users); | |
| 4519 | } | |
| 4520 | ||
| 4521 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4522 | static void mw_protocol_add_permit(PurpleConnection *gc, const char *name) { |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4523 | mw_protocol_set_permit_deny(gc); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4524 | } |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4525 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4526 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4527 | static void mw_protocol_add_deny(PurpleConnection *gc, const char *name) { |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4528 | mw_protocol_set_permit_deny(gc); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4529 | } |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4530 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4531 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4532 | static void mw_protocol_rem_permit(PurpleConnection *gc, const char *name) { |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4533 | mw_protocol_set_permit_deny(gc); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4534 | } |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4535 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4536 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4537 | static void mw_protocol_rem_deny(PurpleConnection *gc, const char *name) { |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4538 | mw_protocol_set_permit_deny(gc); |
| 10977 | 4539 | } |
| 4540 | ||
| 4541 | ||
| 4542 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4543 | const char *name) { | |
| 4544 | GList *l, *ll; | |
| 4545 | struct mwConference *conf = NULL; | |
| 4546 | ||
| 4547 | ll = mwServiceConference_getConferences(srvc); | |
| 4548 | for(l = ll; l; l = l->next) { | |
| 4549 | struct mwConference *c = l->data; | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4550 | if(purple_strequal(name, mwConference_getName(c))) { |
| 10977 | 4551 | conf = c; |
| 4552 | break; | |
| 4553 | } | |
| 4554 | } | |
| 4555 | g_list_free(ll); | |
| 4556 | ||
| 4557 | return conf; | |
| 4558 | } | |
| 4559 | ||
| 4560 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4561 | static void mw_protocol_join_chat(PurpleConnection *gc, |
| 10977 | 4562 | GHashTable *components) { |
| 4563 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4564 | struct mwPurpleProtocolData *pd; |
| 10977 | 4565 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4566 | |
|
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
|
4567 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4568 | |
| 4569 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4570 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4571 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4572 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4573 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4574 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4575 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4576 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4577 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4578 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4579 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4580 | |
| 10977 | 4581 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4582 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4583 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4584 | struct mwConference *conf = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4585 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4586 | srvc = pd->srvc_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4587 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4588 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4589 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4590 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4591 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4592 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4593 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4594 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4595 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4596 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4597 | } |
| 10977 | 4598 | } |
| 4599 | } | |
| 4600 | ||
| 4601 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4602 | static void mw_protocol_reject_chat(PurpleConnection *gc, |
| 10977 | 4603 | GHashTable *components) { |
| 4604 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4605 | struct mwPurpleProtocolData *pd; |
| 10977 | 4606 | struct mwServiceConference *srvc; |
| 4607 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4608 | |
|
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
|
4609 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4610 | srvc = pd->srvc_conf; |
| 4611 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4612 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4613 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4614 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4615 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4616 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4617 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4618 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4619 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4620 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4621 | } |
| 10977 | 4622 | } |
| 4623 | } | |
| 4624 | ||
| 4625 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4626 | static char *mw_protocol_get_chat_name(GHashTable *components) { |
| 10977 | 4627 | return g_hash_table_lookup(components, CHAT_KEY_NAME); |
| 4628 | } | |
| 4629 | ||
| 4630 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4631 | static void mw_protocol_chat_invite(PurpleConnection *gc, |
| 10977 | 4632 | int id, |
| 4633 | const char *invitation, | |
| 4634 | const char *who) { | |
| 4635 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4636 | struct mwPurpleProtocolData *pd; |
| 10977 | 4637 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4638 | struct mwPlace *place; |
| 10977 | 4639 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4640 | ||
|
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
|
4641 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4642 | g_return_if_fail(pd != NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4643 | |
| 10977 | 4644 | conf = ID_TO_CONF(pd, id); |
| 4645 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4646 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4647 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4648 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4649 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4650 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4651 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4652 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4653 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4654 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4655 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4656 | } |
| 4657 | ||
| 4658 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4659 | static void mw_protocol_chat_leave(PurpleConnection *gc, |
| 10977 | 4660 | int id) { |
| 4661 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4662 | struct mwPurpleProtocolData *pd; |
| 10977 | 4663 | struct mwConference *conf; |
| 4664 | ||
|
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
|
4665 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4666 | |
| 4667 | g_return_if_fail(pd != NULL); | |
| 4668 | conf = ID_TO_CONF(pd, id); | |
| 4669 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4670 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4671 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4672 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4673 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4674 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4675 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4676 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4677 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4678 | } |
| 10977 | 4679 | } |
| 4680 | ||
| 4681 | ||
| 37148 | 4682 | static int mw_protocol_chat_send(PurpleConnection *gc, int id, PurpleMessage *pmsg) |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
4683 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4684 | struct mwPurpleProtocolData *pd; |
| 10977 | 4685 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4686 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4687 | int ret; |
| 10977 | 4688 | |
|
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
|
4689 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4690 | |
| 4691 | g_return_val_if_fail(pd != NULL, 0); | |
| 4692 | conf = ID_TO_CONF(pd, id); | |
| 4693 | ||
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
4694 | msg = purple_markup_strip_html(purple_message_get_contents(pmsg)); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4695 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4696 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4697 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4698 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4699 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4700 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4701 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4702 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4703 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4704 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4705 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4706 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4707 | return ret; |
| 10977 | 4708 | } |
| 4709 | ||
| 4710 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4711 | static void mw_protocol_keepalive(PurpleConnection *gc) { |
| 10977 | 4712 | struct mwSession *session; |
| 4713 | ||
| 4714 | g_return_if_fail(gc != NULL); | |
| 4715 | ||
| 4716 | session = gc_to_session(gc); | |
| 4717 | g_return_if_fail(session != NULL); | |
| 4718 | ||
| 4719 | mwSession_sendKeepalive(session); | |
| 4720 | } | |
| 4721 | ||
| 4722 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4723 | static void mw_protocol_alias_buddy(PurpleConnection *gc, |
| 10977 | 4724 | const char *who, |
| 4725 | const char *alias) { | |
| 4726 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4727 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4728 | g_return_if_fail(pd != NULL); |
| 4729 | ||
| 4730 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4731 | the server copy */ | |
| 4732 | ||
| 4733 | blist_schedule(pd); | |
| 4734 | } | |
| 4735 | ||
| 4736 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4737 | static void mw_protocol_group_buddy(PurpleConnection *gc, |
| 10977 | 4738 | const char *who, |
| 4739 | const char *old_group, | |
| 4740 | const char *new_group) { | |
| 4741 | ||
| 4742 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 4743 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4744 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4745 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4746 | PurpleGroup *group; |
| 10977 | 4747 | struct mwAwareList *list; |
| 4748 | ||
| 4749 | /* 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
|
4750 | group = purple_blist_find_group(new_group); |
| 10977 | 4751 | list = list_ensure(pd, group); |
| 4752 | mwAwareList_addAware(list, gl); | |
| 4753 | ||
| 4754 | /* 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
|
4755 | group = purple_blist_find_group(old_group); |
| 10977 | 4756 | list = list_ensure(pd, group); |
| 4757 | mwAwareList_removeAware(list, gl); | |
| 4758 | ||
| 4759 | g_list_free(gl); | |
| 4760 | ||
| 4761 | /* schedule the changes to be saved */ | |
| 4762 | blist_schedule(pd); | |
| 4763 | } | |
| 4764 | ||
| 4765 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4766 | static void mw_protocol_rename_group(PurpleConnection *gc, |
| 10977 | 4767 | const char *old, |
| 15884 | 4768 | PurpleGroup *group, |
| 10977 | 4769 | GList *buddies) { |
| 4770 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4771 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4772 | g_return_if_fail(pd != NULL); |
| 4773 | ||
| 4774 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4775 | the server copy. Also, having this function should prevent all | |
| 4776 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4777 | give a crap what the group is named in Purple other than to record |
| 10977 | 4778 | that as the group name/alias */ |
| 4779 | ||
| 4780 | blist_schedule(pd); | |
| 4781 | } | |
| 4782 | ||
| 4783 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4784 | static void mw_protocol_buddy_free(PurpleBuddy *buddy) { |
| 10977 | 4785 | /* I don't think we have any cleanup for buddies yet */ |
| 4786 | ; | |
| 4787 | } | |
| 4788 | ||
| 4789 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4790 | static void mw_protocol_convo_closed(PurpleConnection *gc, const char *who) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4791 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4792 | struct mwServiceIm *srvc; |
| 4793 | struct mwConversation *conv; | |
| 4794 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4795 | ||
| 4796 | g_return_if_fail(pd != NULL); | |
| 4797 | ||
| 4798 | srvc = pd->srvc_im; | |
| 4799 | g_return_if_fail(srvc != NULL); | |
| 4800 | ||
| 4801 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 4802 | if(! conv) return; | |
| 4803 | ||
| 4804 | if(mwConversation_isOpen(conv)) | |
| 4805 | mwConversation_free(conv); | |
| 4806 | } | |
| 4807 | ||
| 4808 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4809 | static const char *mw_protocol_normalize(const PurpleAccount *account, |
| 10977 | 4810 | const char *id) { |
| 4811 | ||
| 4812 | /* code elsewhere assumes that the return value points to different | |
| 4813 | memory than the passed value, but it won't free the normalized | |
| 4814 | data. wtf? */ | |
| 4815 | ||
| 4816 | 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
|
4817 | g_strlcpy(buf, id, sizeof(buf)); |
| 10977 | 4818 | return buf; |
| 4819 | } | |
| 4820 | ||
| 4821 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
4822 | static void mw_protocol_remove_group(PurpleConnection *gc, PurpleGroup *group) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4823 | struct mwPurpleProtocolData *pd; |
| 10977 | 4824 | struct mwAwareList *list; |
| 4825 | ||
|
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
|
4826 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4827 | g_return_if_fail(pd != NULL); |
| 4828 | g_return_if_fail(pd->group_list_map != NULL); | |
| 4829 | ||
| 4830 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 4831 | ||
| 4832 | if(list) { | |
| 4833 | g_hash_table_remove(pd->group_list_map, list); | |
| 4834 | g_hash_table_remove(pd->group_list_map, group); | |
| 4835 | mwAwareList_free(list); | |
| 4836 | ||
| 4837 | blist_schedule(pd); | |
| 4838 | } | |
| 4839 | } | |
| 4840 | ||
| 4841 | ||
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4842 | static gboolean mw_protocol_can_receive_file(PurpleProtocolXfer *prplxfer, |
|
38828
a7190db83539
Update the PurpleProtocolXferInterface to pass around the interfance instance as well
Gary Kramlich <grim@reaperworld.com>
parents:
38827
diff
changeset
|
4843 | PurpleConnection *gc, |
| 10977 | 4844 | const char *who) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4845 | struct mwPurpleProtocolData *pd; |
| 10977 | 4846 | struct mwServiceAware *srvc; |
| 15884 | 4847 | PurpleAccount *acct; |
| 10977 | 4848 | |
| 4849 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 4850 | ||
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4851 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4852 | g_return_val_if_fail(pd != NULL, FALSE); |
| 4853 | ||
| 4854 | srvc = pd->srvc_aware; | |
| 4855 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4856 | |
| 15884 | 4857 | acct = purple_connection_get_account(gc); |
| 10977 | 4858 | g_return_val_if_fail(acct != NULL, FALSE); |
| 4859 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4860 | return purple_blist_find_buddy(acct, who) && |
| 10977 | 4861 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 4862 | } | |
| 4863 | ||
| 4864 | ||
| 15884 | 4865 | static void ft_outgoing_init(PurpleXfer *xfer) { |
| 4866 | PurpleAccount *acct; | |
| 4867 | PurpleConnection *gc; | |
| 4868 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4869 | struct mwPurpleProtocolData *pd; |
| 10977 | 4870 | struct mwServiceFileTransfer *srvc; |
| 4871 | struct mwFileTransfer *ft; | |
| 4872 | ||
| 4873 | const char *filename; | |
| 4874 | gsize filesize; | |
| 4875 | FILE *fp; | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
4876 | char *remote_user = NULL; |
| 10977 | 4877 | |
| 4878 | struct mwIdBlock idb = { NULL, NULL }; | |
| 4879 | ||
| 4880 | DEBUG_INFO("ft_outgoing_init\n"); | |
| 4881 | ||
| 15884 | 4882 | acct = purple_xfer_get_account(xfer); |
| 4883 | 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
|
4884 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4885 | srvc = pd->srvc_ft; |
| 4886 | ||
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
4887 | 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
|
4888 | |
| 15884 | 4889 | filename = purple_xfer_get_local_filename(xfer); |
| 4890 | 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
|
4891 | idb.user = remote_user; |
| 10977 | 4892 | |
| 15884 | 4893 | purple_xfer_update_progress(xfer); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
4894 | |
| 10977 | 4895 | /* test that we can actually send the file */ |
| 4896 | fp = g_fopen(filename, "rb"); | |
| 4897 | if(! fp) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4898 | 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
|
4899 | filename, g_strerror(errno)); |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
4900 | purple_xfer_error(purple_xfer_get_xfer_type(xfer), acct, purple_xfer_get_remote_user(xfer), msg); |
| 10977 | 4901 | g_free(msg); |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
4902 | g_free(remote_user); |
| 10977 | 4903 | return; |
| 4904 | } | |
| 4905 | fclose(fp); | |
| 4906 | ||
| 4907 | { | |
| 4908 | char *tmp = strrchr(filename, G_DIR_SEPARATOR); | |
| 4909 | if(tmp++) filename = tmp; | |
| 4910 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4911 | |
| 10977 | 4912 | ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); |
| 4913 | ||
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
4914 | g_object_ref(xfer); |
|
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
4915 | 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
|
4916 | purple_xfer_set_protocol_data(xfer, ft); |
| 10977 | 4917 | |
| 4918 | mwFileTransfer_offer(ft); | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33796
diff
changeset
|
4919 | g_free(remote_user); |
| 10977 | 4920 | } |
| 4921 | ||
| 4922 | ||
| 15884 | 4923 | 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
|
4924 | struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4925 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
4926 | DEBUG_INFO("ft_outgoing_cancel called\n"); |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
4927 | |
| 10977 | 4928 | if(ft) mwFileTransfer_cancel(ft); |
| 4929 | } | |
| 4930 | ||
| 4931 | ||
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4932 | static PurpleXfer *mw_protocol_new_xfer(PurpleProtocolXfer *prplxfer, PurpleConnection *gc, const char *who) { |
| 15884 | 4933 | PurpleAccount *acct; |
| 4934 | PurpleXfer *xfer; | |
| 4935 | ||
| 4936 | acct = purple_connection_get_account(gc); | |
| 4937 | ||
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34920
diff
changeset
|
4938 | xfer = purple_xfer_new(acct, PURPLE_XFER_TYPE_SEND, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
4939 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
4940 | { |
| 15884 | 4941 | purple_xfer_set_init_fnc(xfer, ft_outgoing_init); |
| 4942 | purple_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
4943 | } |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
4944 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4945 | return xfer; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4946 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4947 | |
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4948 | static void mw_protocol_send_file(PurpleProtocolXfer *prplxfer, |
|
38828
a7190db83539
Update the PurpleProtocolXferInterface to pass around the interfance instance as well
Gary Kramlich <grim@reaperworld.com>
parents:
38827
diff
changeset
|
4949 | PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4950 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4951 | |
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4952 | PurpleXfer *xfer = mw_protocol_new_xfer(prplxfer, gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4953 | |
| 10977 | 4954 | if(file) { |
| 4955 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 4956 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 4957 | |
| 4958 | } else { | |
| 4959 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 4960 | purple_xfer_request(xfer); |
| 10977 | 4961 | } |
| 4962 | } | |
| 4963 | ||
| 4964 | ||
| 15884 | 4965 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 4966 | struct mwSametimeList *l; |
| 4967 | ||
| 4968 | FILE *file; | |
| 4969 | char buf[BUF_LEN]; | |
| 4970 | size_t len; | |
| 4971 | ||
| 4972 | GString *str; | |
| 4973 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
4974 | file = g_fopen(filename, "r"); |
| 10977 | 4975 | g_return_if_fail(file != NULL); |
| 4976 | ||
| 4977 | str = g_string_new(NULL); | |
| 4978 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 4979 | g_string_append_len(str, buf, len); | |
| 4980 | } | |
| 4981 | ||
| 4982 | fclose(file); | |
| 4983 | ||
| 4984 | l = mwSametimeList_load(str->str); | |
| 4985 | g_string_free(str, TRUE); | |
| 4986 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4987 | blist_merge(gc, l); |
| 10977 | 4988 | mwSametimeList_free(l); |
| 4989 | } | |
| 4990 | ||
| 4991 | ||
| 4992 | /** prompts for a file to import blist from */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4993 | static void st_import_action(PurpleProtocolAction *act) { |
| 15884 | 4994 | PurpleConnection *gc; |
| 4995 | PurpleAccount *account; | |
| 10977 | 4996 | char *title; |
| 4997 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4998 | gc = act->connection; |
| 15884 | 4999 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5000 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 5001 | purple_account_get_username(account)); |
| 5002 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5003 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 5004 | 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
|
5005 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5006 | gc); |
| 10977 | 5007 | |
| 5008 | g_free(title); | |
| 5009 | } | |
| 5010 | ||
| 5011 | ||
| 15884 | 5012 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 5013 | struct mwSametimeList *l; |
| 5014 | char *str; | |
| 5015 | FILE *file; | |
| 5016 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
5017 | file = g_fopen(filename, "w"); |
| 10977 | 5018 | g_return_if_fail(file != NULL); |
| 5019 | ||
| 5020 | l = mwSametimeList_new(); | |
| 5021 | blist_export(gc, l); | |
| 5022 | str = mwSametimeList_store(l); | |
| 5023 | mwSametimeList_free(l); | |
| 5024 | ||
| 5025 | fprintf(file, "%s", str); | |
| 5026 | fclose(file); | |
| 5027 | ||
| 5028 | g_free(str); | |
| 5029 | } | |
| 5030 | ||
| 5031 | ||
| 5032 | /** prompts for a file to export blist to */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5033 | static void st_export_action(PurpleProtocolAction *act) { |
| 15884 | 5034 | PurpleConnection *gc; |
| 5035 | PurpleAccount *account; | |
| 10977 | 5036 | char *title; |
| 5037 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5038 | gc = act->connection; |
| 15884 | 5039 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5040 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 5041 | purple_account_get_username(account)); |
| 5042 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5043 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 5044 | 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
|
5045 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5046 | gc); |
| 10977 | 5047 | |
| 5048 | g_free(title); | |
| 5049 | } | |
| 5050 | ||
| 5051 | ||
| 5052 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 5053 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5054 | |
| 15884 | 5055 | 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
|
5056 | GList *l; |
| 10977 | 5057 | |
| 15884 | 5058 | f = purple_request_fields_get_field(fields, "group"); |
| 5059 | l = purple_request_field_list_get_items(f); | |
| 10977 | 5060 | |
| 5061 | for(; l; l = l->next) { | |
| 5062 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5063 | struct named_id *res; |
| 10977 | 5064 | |
| 15884 | 5065 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5066 | |
| 5067 | g_free(res->id); | |
| 5068 | g_free(res->name); | |
| 5069 | g_free(res); | |
| 5070 | } | |
| 5071 | } | |
| 5072 | ||
| 5073 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5074 | static void remote_group_done(struct mwPurpleProtocolData *pd, |
| 10977 | 5075 | const char *id, const char *name) { |
| 15884 | 5076 | PurpleConnection *gc; |
| 5077 | PurpleAccount *acct; | |
| 5078 | PurpleGroup *group; | |
| 5079 | PurpleBlistNode *gn; | |
| 10977 | 5080 | const char *owner; |
| 5081 | ||
| 5082 | g_return_if_fail(pd != NULL); | |
| 5083 | ||
| 5084 | gc = pd->gc; | |
| 15884 | 5085 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5086 | |
| 10977 | 5087 | /* collision checking */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
5088 | group = purple_blist_find_group(name); |
| 10977 | 5089 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5090 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5091 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5092 | char *msg; |
| 10977 | 5093 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5094 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5095 | 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
|
5096 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5097 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5098 | 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
|
5099 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5100 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5101 | g_free(msg); |
| 10977 | 5102 | return; |
| 5103 | } | |
| 5104 | ||
| 15884 | 5105 | group = purple_group_new(name); |
| 5106 | gn = (PurpleBlistNode *) group; | |
| 5107 | ||
| 5108 | owner = purple_account_get_username(acct); | |
| 5109 | ||
| 5110 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 5111 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 5112 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 5113 | purple_blist_add_group(group, NULL); | |
| 10977 | 5114 | |
| 5115 | group_add(pd, group); | |
| 5116 | blist_schedule(pd); | |
| 5117 | } | |
| 5118 | ||
| 5119 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5120 | static void remote_group_multi_cb(struct mwPurpleProtocolData *pd, |
| 15884 | 5121 | PurpleRequestFields *fields) { |
| 5122 | 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
|
5123 | GList *l; |
| 10977 | 5124 | |
| 15884 | 5125 | f = purple_request_fields_get_field(fields, "group"); |
| 5126 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 5127 | |
| 5128 | if(l) { | |
| 5129 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5130 | struct named_id *res; |
| 10977 | 5131 | |
| 15884 | 5132 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 5133 | remote_group_done(pd, res->id, res->name); |
| 5134 | } | |
| 5135 | ||
| 5136 | remote_group_multi_cleanup(NULL, fields); | |
| 5137 | } | |
| 5138 | ||
| 5139 | ||
| 5140 | static void remote_group_multi(struct mwResolveResult *result, | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5141 | struct mwPurpleProtocolData *pd) { |
| 15884 | 5142 | |
| 5143 | PurpleRequestFields *fields; | |
| 5144 | PurpleRequestFieldGroup *g; | |
| 5145 | PurpleRequestField *f; | |
| 10977 | 5146 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5147 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5148 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5149 | char *msg; |
| 10977 | 5150 | |
| 15884 | 5151 | PurpleConnection *gc = pd->gc; |
| 5152 | ||
| 5153 | fields = purple_request_fields_new(); | |
| 5154 | ||
| 5155 | g = purple_request_field_group_new(NULL); | |
| 5156 | purple_request_fields_add_group(fields, g); | |
| 5157 | ||
| 5158 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 5159 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 5160 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 5161 | |
| 5162 | for(l = result->matches; l; l = l->next) { | |
| 5163 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5164 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 5165 | |
| 5166 | res->id = g_strdup(match->id); | |
| 5167 | res->name = g_strdup(match->name); | |
| 5168 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
5169 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 5170 | } |
| 5171 | ||
| 15884 | 5172 | purple_request_field_group_add_field(g, f); |
| 10977 | 5173 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5174 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5175 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 5176 | " Notes Address Book groups. Please select the correct group from" |
| 5177 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5178 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 5179 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5180 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5181 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5182 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5183 | _("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
|
5184 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5185 | pd); |
| 10977 | 5186 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5187 | g_free(msg); |
| 10977 | 5188 | } |
| 5189 | ||
| 5190 | ||
| 5191 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 5192 | guint32 id, guint32 code, GList *results, | |
| 5193 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5194 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5195 | struct mwResolveResult *res = NULL; |
| 10977 | 5196 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5197 | struct mwPurpleProtocolData *pd; |
| 15884 | 5198 | PurpleConnection *gc; |
| 10977 | 5199 | |
| 5200 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5201 | g_return_if_fail(session != NULL); | |
| 5202 | ||
| 5203 | pd = mwSession_getClientData(session); | |
| 5204 | g_return_if_fail(pd != NULL); | |
| 5205 | ||
| 5206 | gc = pd->gc; | |
| 5207 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5208 | |
| 10977 | 5209 | if(!code && results) { |
| 5210 | res = results->data; | |
| 5211 | ||
| 5212 | if(res->matches) { | |
| 5213 | remote_group_multi(res, pd); | |
| 5214 | return; | |
| 5215 | } | |
| 5216 | } | |
| 5217 | ||
| 5218 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5219 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5220 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5221 | char *msg; |
| 10977 | 5222 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5223 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5224 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5225 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5226 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5227 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5228 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5229 | 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
|
5230 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5231 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5232 | g_free(msg); |
| 10977 | 5233 | } |
| 5234 | } | |
| 5235 | ||
| 5236 | ||
| 15884 | 5237 | static void remote_group_action_cb(PurpleConnection *gc, const char *name) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5238 | struct mwPurpleProtocolData *pd; |
| 10977 | 5239 | struct mwServiceResolve *srvc; |
| 5240 | GList *query; | |
| 5241 | enum mwResolveFlag flags; | |
| 5242 | guint32 req; | |
| 5243 | ||
|
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
|
5244 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5245 | srvc = pd->srvc_resolve; |
| 5246 | ||
| 5247 | query = g_list_prepend(NULL, (char *) name); | |
| 5248 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5249 | |
| 10977 | 5250 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5251 | NULL, NULL); | |
| 5252 | g_list_free(query); | |
| 5253 | ||
| 5254 | if(req == SEARCH_ERROR) { | |
| 5255 | /** @todo display error */ | |
| 5256 | } | |
| 5257 | } | |
| 5258 | ||
| 5259 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5260 | static void remote_group_action(PurpleProtocolAction *act) { |
| 15884 | 5261 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5262 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5263 | const char *msgB; |
| 10977 | 5264 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5265 | gc = act->connection; |
| 10977 | 5266 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5267 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5268 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5269 | " to add the group and its members to your buddy list."); |
| 5270 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5271 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5272 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5273 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5274 | _("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
|
5275 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5276 | gc); |
| 10977 | 5277 | } |
| 5278 | ||
| 5279 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5280 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5281 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5282 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5283 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5284 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5285 | char *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5286 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5287 | |
| 15884 | 5288 | PurpleNotifySearchResults *sres; |
| 5289 | PurpleNotifySearchColumn *scol; | |
| 5290 | ||
| 5291 | sres = purple_notify_searchresults_new(); | |
| 5292 | ||
| 5293 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5294 | purple_notify_searchresults_column_add(sres, scol); | |
| 5295 | ||
| 5296 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5297 | purple_notify_searchresults_column_add(sres, scol); | |
| 5298 | ||
| 5299 | 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
|
5300 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5301 | |
| 15884 | 5302 | 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
|
5303 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5304 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5305 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5306 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5307 | GList *row = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5308 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5309 | if(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5310 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5311 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5312 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5313 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5314 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5315 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5316 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5317 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5318 | 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
|
5319 | " 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
|
5320 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5321 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5322 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5323 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5324 | |
| 15884 | 5325 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5326 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5327 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5328 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5329 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5330 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5331 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5332 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5333 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5334 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5335 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5336 | |
| 15884 | 5337 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5338 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5339 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5340 | if(results) res = results->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5341 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5342 | if(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5343 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5344 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5345 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5346 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5347 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5348 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5349 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5350 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5351 | 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
|
5352 | " Sametime community."); |
|
20228
ce019944d765
applied changes from 9d35dde0c779cca73548172223ba557f27d61882
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
5353 | 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
|
5354 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5355 | 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
|
5356 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5357 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5358 | g_free(msg); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5359 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5360 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5361 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5362 | |
| 15884 | 5363 | static void search_action_cb(PurpleConnection *gc, const char *name) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5364 | struct mwPurpleProtocolData *pd; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5365 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5366 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5367 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5368 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5369 | |
|
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
|
5370 | pd = purple_connection_get_protocol_data(gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5371 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5372 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5373 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5374 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5375 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5376 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5377 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5378 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5379 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5380 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5381 | /** @todo display error */ |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5382 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5383 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5384 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5385 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5386 | static void search_action(PurpleProtocolAction *act) { |
| 15884 | 5387 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5388 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5389 | const char *msgB; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5390 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5391 | gc = act->connection; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5392 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5393 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5394 | 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
|
5395 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5396 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5397 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5398 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5399 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5400 | _("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
|
5401 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5402 | gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5403 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5404 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5405 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5406 | static GList *mw_protocol_get_actions(PurpleConnection *gc) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5407 | PurpleProtocolAction *act; |
| 10977 | 5408 | GList *l = NULL; |
| 5409 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5410 | act = purple_protocol_action_new(_("Import Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5411 | st_import_action); |
| 10977 | 5412 | l = g_list_append(l, act); |
| 5413 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5414 | act = purple_protocol_action_new(_("Export Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5415 | st_export_action); |
| 10977 | 5416 | l = g_list_append(l, act); |
| 5417 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5418 | act = purple_protocol_action_new(_("Add Notes Address Book Group..."), |
| 10977 | 5419 | remote_group_action); |
| 5420 | l = g_list_append(l, act); | |
| 5421 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5422 | act = purple_protocol_action_new(_("User Search..."), |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5423 | search_action); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5424 | l = g_list_append(l, act); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5425 | |
| 10977 | 5426 | return l; |
| 5427 | } | |
| 5428 | ||
| 5429 | ||
| 5430 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5431 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5432 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5433 | if(! (msg && *msg)) return; |
| 10977 | 5434 | |
| 15884 | 5435 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5436 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5437 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5438 | |
| 5439 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5440 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5441 | |
| 5442 | } else { | |
| 15884 | 5443 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5444 | } |
| 5445 | } | |
| 5446 | ||
| 5447 | ||
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5448 | static void |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5449 | mw_protocol_init(PurpleProtocol *protocol) |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5450 | { |
|
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
|
5451 | PurpleAccountUserSplit *split; |
| 15884 | 5452 | PurpleAccountOption *opt; |
| 10977 | 5453 | GList *l = NULL; |
| 5454 | ||
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5455 | protocol->id = PROTOCOL_ID; |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5456 | protocol->name = PROTOCOL_NAME; |
| 10977 | 5457 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5458 | /* set up the preferences */ |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5459 | purple_prefs_add_none(MW_PROTOCOL_OPT_BASE); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5460 | purple_prefs_add_int(MW_PROTOCOL_OPT_BLIST_ACTION, BLIST_CHOICE_DEFAULT); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5461 | |
|
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
|
5462 | /* 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
|
5463 | 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
|
5464 | MW_PLUGIN_DEFAULT_HOST, ':'); |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5465 | protocol->user_splits = g_list_append(protocol->user_splits, split); |
|
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
|
5466 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5467 | /* remove dead preferences */ |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5468 | purple_prefs_remove(MW_PROTOCOL_OPT_PSYCHIC); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5469 | purple_prefs_remove(MW_PROTOCOL_OPT_SAVE_DYNAMIC); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5470 | |
| 10977 | 5471 | /* port to connect to */ |
| 15884 | 5472 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5473 | MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 5474 | l = g_list_append(l, opt); |
| 5475 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5476 | { /* 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
|
5477 | 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
|
5478 | than one account that wants to check for it. */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5479 | gboolean b = FALSE; |
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12422
diff
changeset
|
5480 | const char *label = _("Force login (ignore server redirects)"); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5481 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5482 | if(purple_prefs_exists(MW_PROTOCOL_OPT_FORCE_LOGIN)) |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
5483 | b = purple_prefs_get_bool(MW_PROTOCOL_OPT_FORCE_LOGIN); |
| 15884 | 5484 | |
| 5485 | 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
|
5486 | l = g_list_append(l, opt); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5487 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5488 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5489 | /* pretend to be Sametime Connect */ |
| 15884 | 5490 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5491 | MW_KEY_FAKE_IT, FALSE); |
|
12312
470a1452d009
[gaim-migrate @ 14616]
Christopher O'Brien <siege@pidgin.im>
parents:
12311
diff
changeset
|
5492 | l = g_list_append(l, opt); |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5493 | |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37004
diff
changeset
|
5494 | protocol->account_options = l; |
| 10977 | 5495 | l = NULL; |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5496 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5497 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5498 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5499 | static void |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5500 | mw_protocol_class_init(PurpleProtocolClass *klass) |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5501 | { |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5502 | klass->login = mw_protocol_login; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5503 | klass->close = mw_protocol_close; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5504 | klass->status_types = mw_protocol_status_types; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5505 | klass->list_icon = mw_protocol_list_icon; |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5506 | } |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5507 | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5508 | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5509 | static void |
|
36729
7f9fac14ed60
Temporarily replaced PurpleProtocolInterface with PurpleProtocolClientIface in protocols
Ankit Vani <a@nevitus.org>
parents:
36714
diff
changeset
|
5510 | mw_protocol_client_iface_init(PurpleProtocolClientIface *client_iface) |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5511 | { |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5512 | client_iface->get_actions = mw_protocol_get_actions; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5513 | client_iface->list_emblem = mw_protocol_list_emblem; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5514 | client_iface->status_text = mw_protocol_status_text; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5515 | client_iface->tooltip_text = mw_protocol_tooltip_text; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5516 | client_iface->blist_node_menu = mw_protocol_blist_node_menu; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5517 | client_iface->buddy_free = mw_protocol_buddy_free; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5518 | client_iface->convo_closed = mw_protocol_convo_closed; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5519 | client_iface->normalize = mw_protocol_normalize; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5520 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5521 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5522 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5523 | static void |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5524 | mw_protocol_server_iface_init(PurpleProtocolServerIface *server_iface) |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5525 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5526 | server_iface->get_info = mw_protocol_get_info; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5527 | server_iface->set_status = mw_protocol_set_status; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5528 | server_iface->set_idle = mw_protocol_set_idle; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5529 | server_iface->add_buddy = mw_protocol_add_buddy; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5530 | server_iface->add_buddies = mw_protocol_add_buddies; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5531 | server_iface->remove_buddy = mw_protocol_remove_buddy; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5532 | server_iface->keepalive = mw_protocol_keepalive; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5533 | server_iface->alias_buddy = mw_protocol_alias_buddy; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5534 | server_iface->group_buddy = mw_protocol_group_buddy; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5535 | server_iface->rename_group = mw_protocol_rename_group; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5536 | server_iface->remove_group = mw_protocol_remove_group; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5537 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5538 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5539 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5540 | static void |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5541 | mw_protocol_im_iface_init(PurpleProtocolIMIface *im_iface) |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5542 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5543 | im_iface->send = mw_protocol_send_im; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5544 | im_iface->send_typing = mw_protocol_send_typing; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5545 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5546 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5547 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5548 | static void |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5549 | mw_protocol_chat_iface_init(PurpleProtocolChatIface *chat_iface) |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5550 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5551 | chat_iface->info = mw_protocol_chat_info; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5552 | chat_iface->info_defaults = mw_protocol_chat_info_defaults; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5553 | chat_iface->join = mw_protocol_join_chat; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5554 | chat_iface->reject = mw_protocol_reject_chat; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5555 | chat_iface->get_name = mw_protocol_get_chat_name; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5556 | chat_iface->invite = mw_protocol_chat_invite; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5557 | chat_iface->leave = mw_protocol_chat_leave; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5558 | chat_iface->send = mw_protocol_chat_send; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5559 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5560 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5561 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5562 | static void |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5563 | mw_protocol_privacy_iface_init(PurpleProtocolPrivacyIface *privacy_iface) |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5564 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5565 | privacy_iface->add_permit = mw_protocol_add_permit; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5566 | privacy_iface->add_deny = mw_protocol_add_deny; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5567 | privacy_iface->rem_permit = mw_protocol_rem_permit; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5568 | privacy_iface->rem_deny = mw_protocol_rem_deny; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5569 | privacy_iface->set_permit_deny = mw_protocol_set_permit_deny; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5570 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5571 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5572 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5573 | static void |
|
38827
3573c82d32d8
Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
38433
diff
changeset
|
5574 | mw_protocol_xfer_iface_init(PurpleProtocolXferInterface *xfer_iface) |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5575 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5576 | xfer_iface->can_receive = mw_protocol_can_receive_file; |
|
39005
6a56e1366809
xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38854
diff
changeset
|
5577 | xfer_iface->send_file = mw_protocol_send_file; |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5578 | xfer_iface->new_xfer = mw_protocol_new_xfer; |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5579 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5580 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5581 | |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5582 | PURPLE_DEFINE_TYPE_EXTENDED( |
|
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5583 | mwProtocol, mw_protocol, PURPLE_TYPE_PROTOCOL, 0, |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5584 | |
|
36729
7f9fac14ed60
Temporarily replaced PurpleProtocolInterface with PurpleProtocolClientIface in protocols
Ankit Vani <a@nevitus.org>
parents:
36714
diff
changeset
|
5585 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE, |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5586 | mw_protocol_client_iface_init) |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5587 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5588 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE, |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5589 | mw_protocol_server_iface_init) |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5590 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5591 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE, |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5592 | mw_protocol_im_iface_init) |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5593 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5594 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE, |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5595 | mw_protocol_chat_iface_init) |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5596 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5597 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE, |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5598 | mw_protocol_privacy_iface_init) |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5599 | |
|
38827
3573c82d32d8
Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
38433
diff
changeset
|
5600 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER, |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5601 | mw_protocol_xfer_iface_init) |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5602 | ); |
|
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5603 | |
|
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5604 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5605 | static PurplePluginInfo * |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5606 | plugin_query(GError **error) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5607 | { |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5608 | const gchar * const authors[] = PLUGIN_AUTHORS; |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5609 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5610 | return purple_plugin_info_new( |
|
36638
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
5611 | "id", PLUGIN_ID, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5612 | "name", PLUGIN_NAME, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5613 | "version", DISPLAY_VERSION, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5614 | "category", PLUGIN_CATEGORY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5615 | "summary", PLUGIN_SUMMARY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5616 | "description", PLUGIN_DESC, |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5617 | "authors", authors, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5618 | "website", PLUGIN_HOMEPAGE, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5619 | "abi-version", PURPLE_ABI_VERSION, |
|
36653
4084c34c051d
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents:
36642
diff
changeset
|
5620 | "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL | |
|
4084c34c051d
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents:
36642
diff
changeset
|
5621 | PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5622 | NULL |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5623 | ); |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5624 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5625 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5626 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5627 | static gboolean |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5628 | plugin_load(PurplePlugin *plugin, GError **error) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5629 | { |
| 36679 | 5630 | GLogLevelFlags logflags = |
| 5631 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5632 | ||
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5633 | mw_protocol_register_type(plugin); |
|
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5634 | |
|
36628
3d43ca8d69ee
Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents:
36613
diff
changeset
|
5635 | my_protocol = purple_protocols_add(MW_TYPE_PROTOCOL, error); |
|
3d43ca8d69ee
Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents:
36613
diff
changeset
|
5636 | if (!my_protocol) |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5637 | return FALSE; |
| 10977 | 5638 | |
| 15884 | 5639 | /* forward all our g_log messages to purple. Generally all the logging |
| 5640 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5641 | get caught here */ |
| 5642 | log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags, | |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36660
diff
changeset
|
5643 | mw_log_handler, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5644 | |
| 15884 | 5645 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5646 | log_handler[1] = g_log_set_handler("meanwhile", logflags, |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36660
diff
changeset
|
5647 | mw_log_handler, NULL); |
|
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36660
diff
changeset
|
5648 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5649 | return TRUE; |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5650 | } |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5651 | |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5652 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5653 | static gboolean |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5654 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5655 | { |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36660
diff
changeset
|
5656 | g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); |
|
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36660
diff
changeset
|
5657 | g_log_remove_handler("meanwhile", log_handler[1]); |
|
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36660
diff
changeset
|
5658 | |
|
36628
3d43ca8d69ee
Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents:
36613
diff
changeset
|
5659 | if (!purple_protocols_remove(my_protocol, error)) |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5660 | return FALSE; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5661 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5662 | return TRUE; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5663 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5664 | |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5665 | |
|
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5666 | PURPLE_PLUGIN_INIT(sametime, plugin_query, plugin_load, plugin_unload); |
| 10977 | 5667 | /* The End. */ |
| 5668 |