Wed, 21 Apr 2021 18:45:53 -0500
Migrate gg, novel, null, sametime, silc, and zephyr to using G_DECLARE_FINAL_TYPE for their protocol objects
Testing Done:
Compile only.
Reviewed at https://reviews.imfreedom.org/r/620/
| 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 | ||
|
40441
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
24 | #include <glib/gi18n-lib.h> |
|
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
25 | |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
26 | #define BUF_LEN (2048) |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
27 | #define BUF_LONG (BUF_LEN * 2) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
28 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
29 | /* system includes */ |
| 10977 | 30 | #include <stdlib.h> |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
31 | #include <time.h> |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
32 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
33 | /* glib includes */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
34 | #include <glib.h> |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
35 | #include <glib/gstdio.h> |
|
39526
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
36 | #include <gmime/gmime.h> |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
37 | |
| 15884 | 38 | /* purple includes */ |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
40255
diff
changeset
|
39 | #include <purple.h> |
| 10977 | 40 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
41 | /* meanwhile includes */ |
| 10977 | 42 | #include <mw_cipher.h> |
| 43 | #include <mw_common.h> | |
| 44 | #include <mw_error.h> | |
| 45 | #include <mw_service.h> | |
| 46 | #include <mw_session.h> | |
| 47 | #include <mw_srvc_aware.h> | |
| 48 | #include <mw_srvc_conf.h> | |
| 49 | #include <mw_srvc_ft.h> | |
| 50 | #include <mw_srvc_im.h> | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
51 | #include <mw_srvc_place.h> |
| 10977 | 52 | #include <mw_srvc_resolve.h> |
| 53 | #include <mw_srvc_store.h> | |
| 54 | #include <mw_st_list.h> | |
| 55 | ||
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
56 | /* plugin includes */ |
| 10977 | 57 | #include "sametime.h" |
|
39523
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
58 | #include "im_mime.h" |
| 10977 | 59 | |
|
40865
82e45cd837fa
Migrate gg, novel, null, sametime, silc, and zephyr to using G_DECLARE_FINAL_TYPE for their protocol objects
Gary Kramlich <grim@reaperworld.com>
parents:
40813
diff
changeset
|
60 | struct _mwProtocol { |
|
82e45cd837fa
Migrate gg, novel, null, sametime, silc, and zephyr to using G_DECLARE_FINAL_TYPE for their protocol objects
Gary Kramlich <grim@reaperworld.com>
parents:
40813
diff
changeset
|
61 | PurpleProtocol parent; |
|
82e45cd837fa
Migrate gg, novel, null, sametime, silc, and zephyr to using G_DECLARE_FINAL_TYPE for their protocol objects
Gary Kramlich <grim@reaperworld.com>
parents:
40813
diff
changeset
|
62 | }; |
| 10977 | 63 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
64 | static PurpleProtocol *my_protocol = NULL; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
65 | |
| 37004 | 66 | #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
|
67 | #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
|
68 | |
|
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
69 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
70 | /* considering that there's no display of this information for protocols, |
| 10977 | 71 | I don't know why I even bother providing these. Oh valiant reader, |
| 72 | I do it all for you. */ | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
73 | /* 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
|
74 | #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
|
75 | #define PLUGIN_NAME "Sametime Protocol" |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
76 | #define PLUGIN_CATEGORY "Protocol" |
| 10977 | 77 | #define PLUGIN_SUMMARY "Sametime Protocol Plugin" |
| 78 | #define PLUGIN_DESC "Open implementation of a Lotus Sametime client" | |
| 79 | #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/" | |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
80 | #define PLUGIN_AUTHORS \ |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
81 | { "Christopher (siege) O'Brien <siege@preoccupied.net>", NULL } |
| 10977 | 82 | |
| 83 | ||
| 84 | /* plugin preference names */ | |
| 36984 | 85 | #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
|
86 | #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
|
87 | #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
|
88 | #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
|
89 | #define MW_PROTOCOL_OPT_SAVE_DYNAMIC MW_PROTOCOL_OPT_BASE "/save_dynamic" |
| 10977 | 90 | |
| 91 | ||
| 92 | /* stages of connecting-ness */ | |
|
13779
410869639392
[gaim-migrate @ 16189]
Christopher O'Brien <siege@pidgin.im>
parents:
13713
diff
changeset
|
93 | #define MW_CONNECT_STEPS 11 |
| 10977 | 94 | |
| 95 | ||
| 96 | /* stages of conciousness */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
97 | #define MW_STATE_OFFLINE "offline" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
98 | #define MW_STATE_ACTIVE "active" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
99 | #define MW_STATE_AWAY "away" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
100 | #define MW_STATE_BUSY "dnd" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
101 | #define MW_STATE_MESSAGE "message" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
102 | #define MW_STATE_ENLIGHTENED "buddha" |
| 10977 | 103 | |
| 104 | ||
| 105 | /* keys to get/set chat information */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
106 | #define CHAT_KEY_CREATOR "chat.creator" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
107 | #define CHAT_KEY_NAME "chat.name" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
108 | #define CHAT_KEY_TOPIC "chat.topic" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
109 | #define CHAT_KEY_INVITE "chat.invite" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
110 | #define CHAT_KEY_IS_PLACE "chat.is_place" |
| 10977 | 111 | |
| 112 | ||
| 113 | /* key for associating a mwLoginType with a buddy */ | |
| 114 | #define BUDDY_KEY_CLIENT "meanwhile.client" | |
| 115 | ||
| 116 | /* store the remote alias so that we can re-create it easily */ | |
| 117 | #define BUDDY_KEY_NAME "meanwhile.shortname" | |
| 118 | ||
| 119 | /* enum mwSametimeUserType */ | |
| 120 | #define BUDDY_KEY_TYPE "meanwhile.type" | |
| 121 | ||
| 122 | ||
| 123 | /* key for the real group name for a meanwhile group */ | |
| 124 | #define GROUP_KEY_NAME "meanwhile.group" | |
| 125 | ||
| 126 | /* enum mwSametimeGroupType */ | |
| 127 | #define GROUP_KEY_TYPE "meanwhile.type" | |
| 128 | ||
| 129 | /* NAB group owning account */ | |
| 130 | #define GROUP_KEY_OWNER "meanwhile.account" | |
| 131 | ||
| 132 | /* key gtk blist uses to indicate a collapsed group */ | |
| 133 | #define GROUP_KEY_COLLAPSED "collapsed" | |
| 134 | ||
| 135 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
136 | /* verification replacement */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
137 | #define mwSession_NO_SECRET "meanwhile.no_secret" |
| 10977 | 138 | |
| 139 | ||
| 15884 | 140 | /* keys to get/set purple plugin information */ |
| 10977 | 141 | #define MW_KEY_HOST "server" |
| 142 | #define MW_KEY_PORT "port" | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
143 | #define MW_KEY_FORCE "force_login" |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
144 | #define MW_KEY_FAKE_IT "fake_client_id" |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
145 | #define MW_KEY_CLIENT "client_id_val" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
146 | #define MW_KEY_MAJOR "client_major" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
147 | #define MW_KEY_MINOR "client_minor" |
| 10977 | 148 | |
| 149 | ||
| 150 | /** number of seconds from the first blist change before a save to the | |
| 151 | storage service occurs. */ | |
| 152 | #define BLIST_SAVE_SECONDS 15 | |
| 153 | ||
| 154 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
155 | /** the possible buddy list storage settings */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
156 | enum blist_choice { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
157 | blist_choice_LOCAL = 1, /**< local only */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
158 | blist_choice_MERGE = 2, /**< merge from server */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
159 | 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
|
160 | blist_choice_SYNCH = 4 /**< sync with server */ |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
161 | }; |
| 10977 | 162 | |
| 163 | ||
| 164 | /** the default blist storage option */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
165 | #define BLIST_CHOICE_DEFAULT blist_choice_SYNCH |
| 10977 | 166 | |
| 167 | ||
| 168 | /* testing for the above */ | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
169 | #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
|
170 | #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
|
171 | #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
|
172 | #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
|
173 | #define BLIST_PREF_IS_SYNCH() BLIST_PREF_IS(blist_choice_SYNCH) |
| 10977 | 174 | |
| 175 | ||
| 176 | /* 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
|
177 | #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
|
178 | #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
|
179 | #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
|
180 | #define DEBUG_WARN(...) purple_debug_warning(G_LOG_DOMAIN, __VA_ARGS__) |
| 10977 | 181 | |
| 182 | ||
| 183 | /** calibrates distinct secure channel nomenclature */ | |
| 184 | static const unsigned char no_secret[] = { | |
| 185 | 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65, | |
| 186 | 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a, | |
| 187 | 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64, | |
| 188 | 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00, | |
| 189 | }; | |
| 190 | ||
| 191 | ||
| 192 | /** handler IDs from g_log_set_handler in mw_plugin_init */ | |
| 193 | static guint log_handler[2] = { 0, 0 }; | |
| 194 | ||
| 195 | ||
| 15884 | 196 | /** 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
|
197 | 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
|
198 | struct mwPurpleProtocolData { |
| 10977 | 199 | struct mwSession *session; |
| 200 | ||
| 201 | struct mwServiceAware *srvc_aware; | |
| 202 | struct mwServiceConference *srvc_conf; | |
| 203 | struct mwServiceFileTransfer *srvc_ft; | |
| 204 | struct mwServiceIm *srvc_im; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
205 | struct mwServicePlace *srvc_place; |
| 10977 | 206 | struct mwServiceResolve *srvc_resolve; |
| 207 | struct mwServiceStorage *srvc_store; | |
| 208 | ||
| 15884 | 209 | /** map of PurpleGroup:mwAwareList and mwAwareList:PurpleGroup */ |
| 10977 | 210 | GHashTable *group_list_map; |
| 211 | ||
| 212 | /** event id for the buddy list save callback */ | |
| 213 | guint save_event; | |
| 214 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
215 | GCancellable *cancellable; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
216 | GSocketClient *client; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
217 | GIOStream *stream; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
218 | GInputStream *input; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
219 | PurpleQueuedOutputStream *output; |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
220 | guint inpa; /* input watcher */ |
| 15884 | 221 | |
| 222 | PurpleConnection *gc; | |
| 10977 | 223 | }; |
| 224 | ||
| 225 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
226 | typedef struct { |
| 15884 | 227 | PurpleBuddy *buddy; |
| 228 | PurpleGroup *group; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
229 | } BuddyAddData; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
230 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
231 | |
| 10977 | 232 | /* blist and aware functions */ |
| 233 | ||
| 15884 | 234 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist); |
| 235 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
236 | 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
|
237 | |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
238 | static void blist_schedule(struct mwPurpleProtocolData *pd); |
| 15884 | 239 | |
| 240 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 241 | ||
| 242 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 243 | ||
| 244 | static gboolean buddy_is_external(PurpleBuddy *b); | |
| 245 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
246 | static void buddy_add(struct mwPurpleProtocolData *pd, PurpleBuddy *buddy); |
| 15884 | 247 | |
| 248 | static PurpleBuddy * | |
| 249 | buddy_ensure(PurpleConnection *gc, PurpleGroup *group, | |
| 10977 | 250 | struct mwSametimeUser *stuser); |
| 251 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
252 | static void group_add(struct mwPurpleProtocolData *pd, PurpleGroup *group); |
| 15884 | 253 | |
| 254 | static PurpleGroup * | |
| 255 | group_ensure(PurpleConnection *gc, struct mwSametimeGroup *stgroup); | |
| 10977 | 256 | |
| 257 | static struct mwAwareList * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
258 | list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group); |
| 10977 | 259 | |
| 260 | ||
| 261 | /* session functions */ | |
| 262 | ||
| 263 | static struct mwSession * | |
| 15884 | 264 | gc_to_session(PurpleConnection *gc); |
| 265 | ||
| 266 | static PurpleConnection *session_to_gc(struct mwSession *session); | |
| 10977 | 267 | |
| 268 | ||
| 269 | /* conference functions */ | |
| 270 | ||
| 271 | static struct mwConference * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
272 | conf_find_by_id(struct mwPurpleProtocolData *pd, int id); |
| 10977 | 273 | |
| 274 | ||
| 275 | /* conversation functions */ | |
| 276 | ||
| 277 | struct convo_msg { | |
| 278 | enum mwImSendType type; | |
| 279 | gpointer data; | |
| 280 | GDestroyNotify clear; | |
| 281 | }; | |
| 282 | ||
| 283 | ||
| 284 | struct convo_data { | |
| 285 | struct mwConversation *conv; | |
| 286 | GList *queue; /**< outgoing message queue, list of convo_msg */ | |
| 287 | }; | |
| 288 | ||
| 289 | static void convo_data_new(struct mwConversation *conv); | |
| 290 | ||
| 291 | static void convo_data_free(struct convo_data *conv); | |
| 292 | ||
| 293 | static void convo_features(struct mwConversation *conv); | |
| 294 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
295 | static PurpleIMConversation *convo_get_im(struct mwConversation *conv); |
| 10977 | 296 | |
| 297 | ||
|
12629
14aae7d5da6b
[gaim-migrate @ 14965]
Richard Laager <rlaager@pidgin.im>
parents:
12624
diff
changeset
|
298 | /* name and id */ |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
299 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
300 | struct named_id { |
| 10977 | 301 | char *id; |
| 302 | char *name; | |
| 303 | }; | |
| 304 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
305 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
306 | /* connection functions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
307 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
308 | static void connect_cb(GObject *source_object, GAsyncResult *result, gpointer data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
309 | |
| 10977 | 310 | |
| 311 | /* ----- session ------ */ | |
| 312 | ||
| 313 | ||
| 15884 | 314 | /** resolves a mwSession from a PurpleConnection */ |
| 315 | 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
|
316 | struct mwPurpleProtocolData *pd; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
317 | |
| 10977 | 318 | g_return_val_if_fail(gc != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
319 | |
|
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
|
320 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 321 | g_return_val_if_fail(pd != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
322 | |
| 10977 | 323 | return pd->session; |
| 324 | } | |
| 325 | ||
| 326 | ||
| 15884 | 327 | /** resolves a PurpleConnection from a mwSession */ |
| 328 | 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
|
329 | struct mwPurpleProtocolData *pd; |
| 10977 | 330 | |
| 331 | g_return_val_if_fail(session != NULL, NULL); | |
| 332 | ||
| 333 | pd = mwSession_getClientData(session); | |
| 334 | g_return_val_if_fail(pd != NULL, NULL); | |
| 335 | ||
| 336 | return pd->gc; | |
| 337 | } | |
| 338 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
339 | static void |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
340 | write_cb(GObject *source_object, GAsyncResult *result, gpointer data) |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
341 | { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
342 | PurpleQueuedOutputStream *stream = PURPLE_QUEUED_OUTPUT_STREAM(source_object); |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
343 | struct mwPurpleProtocolData *pd = data; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
344 | GError *error = NULL; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
345 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
346 | DEBUG_INFO("write_cb\n"); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
347 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
348 | if (!purple_queued_output_stream_push_bytes_finish(stream, result, &error)) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
349 | purple_queued_output_stream_clear_queue(stream); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
350 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
351 | if (error->code != G_IO_ERROR_CANCELLED) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
352 | g_prefix_error(&error, "%s", _("Lost connection with server: ")); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
353 | purple_connection_take_error(pd->gc, error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
354 | } else { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
355 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
356 | } |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
357 | } |
|
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 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
360 | |
| 10977 | 361 | static int mw_session_io_write(struct mwSession *session, |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
362 | const guchar *buf, gsize len) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
363 | struct mwPurpleProtocolData *pd; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
364 | GBytes *output; |
| 10977 | 365 | |
| 366 | pd = mwSession_getClientData(session); | |
| 367 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
368 | /* the session was already closed. */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
369 | if (pd->stream == NULL) { |
| 10977 | 370 | return 1; |
| 371 | } | |
| 372 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
373 | output = g_bytes_new(buf, len); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
374 | purple_queued_output_stream_push_bytes_async( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
375 | pd->output, output, G_PRIORITY_DEFAULT, pd->cancellable, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
376 | write_cb, pd); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
377 | g_bytes_unref(output); |
| 10977 | 378 | |
| 379 | return 0; | |
| 380 | } | |
| 381 | ||
| 382 | ||
| 383 | 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
|
384 | struct mwPurpleProtocolData *pd; |
| 10977 | 385 | |
| 386 | pd = mwSession_getClientData(session); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
387 | g_return_if_fail(pd != NULL); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
388 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
389 | g_cancellable_cancel(pd->cancellable); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
390 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
391 | if (pd->stream) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
392 | if (pd->inpa) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
393 | purple_input_remove(pd->inpa); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
394 | pd->inpa = 0; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
395 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
396 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
397 | purple_gio_graceful_close(pd->stream, pd->input, G_OUTPUT_STREAM(pd->output)); |
|
13206
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 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
400 | pd->input = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
401 | g_clear_object(&pd->output); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
402 | g_clear_object(&pd->stream); |
| 10977 | 403 | } |
| 404 | ||
| 405 | ||
| 406 | static void mw_session_clear(struct mwSession *session) { | |
| 407 | ; /* nothing for now */ | |
| 408 | } | |
| 409 | ||
| 410 | ||
| 411 | /* ----- aware list ----- */ | |
| 412 | ||
| 413 | ||
| 414 | static void blist_resolve_alias_cb(struct mwServiceResolve *srvc, | |
| 415 | guint32 id, guint32 code, GList *results, | |
| 416 | gpointer data) { | |
| 417 | struct mwResolveResult *result; | |
| 418 | struct mwResolveMatch *match; | |
| 419 | ||
| 420 | g_return_if_fail(results != NULL); | |
| 421 | ||
| 422 | result = results->data; | |
| 423 | g_return_if_fail(result != NULL); | |
| 424 | g_return_if_fail(result->matches != NULL); | |
| 425 | ||
| 426 | match = result->matches->data; | |
| 427 | g_return_if_fail(match != NULL); | |
| 428 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
429 | purple_buddy_set_server_alias(data, match->name); |
| 15884 | 430 | purple_blist_node_set_string(data, BUDDY_KEY_NAME, match->name); |
| 10977 | 431 | } |
| 432 | ||
| 433 | ||
| 434 | static void mw_aware_list_on_aware(struct mwAwareList *list, | |
| 435 | struct mwAwareSnapshot *aware) { | |
| 436 | ||
| 15884 | 437 | PurpleConnection *gc; |
| 438 | PurpleAccount *acct; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
439 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
440 | struct mwPurpleProtocolData *pd; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
441 | guint32 idle; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
442 | guint stat; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
443 | const char *id; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
444 | const char *status = MW_STATE_ACTIVE; |
| 10977 | 445 | |
| 446 | gc = mwAwareList_getClientData(list); | |
| 15884 | 447 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
448 | |
|
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
|
449 | pd = purple_connection_get_protocol_data(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
450 | idle = aware->status.time; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
451 | stat = aware->status.status; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
452 | id = aware->id.user; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
453 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
454 | if(idle) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
455 | guint32 idle_len; /*< how long a client has been idle */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
456 | 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
|
457 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
458 | DEBUG_INFO("%s has idle value 0x%x\n", id, idle); |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
459 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
460 | idle_len = time(NULL) - idle; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
461 | ugly_idle_len = ((time(NULL) * 1000) - idle) / 1000; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
462 | |
|
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
|
463 | 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
|
464 | 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
|
465 | 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
|
466 | 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
|
467 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
468 | /* |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
469 | 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
|
470 | 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
|
471 | 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
|
472 | 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
|
473 | 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
|
474 | 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
|
475 | this. |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
476 | */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
477 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
478 | 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
|
479 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
480 | #if 1 |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
481 | if(idle_len <= ugly_idle_len) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
482 | ; /* DEBUG_INFO("sane idle value, let's use it\n"); */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
483 | } else { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
484 | idle = time(NULL) - ugly_idle_len; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
485 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
486 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
487 | #else |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
488 | if(idle < 0 || idle > time(NULL)) { |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
489 | DEBUG_INFO("hiding a messy idle value 0x%x\n", id, idle); |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
490 | idle = -1; |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
491 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
492 | #endif |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
493 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
494 | |
| 10977 | 495 | switch(stat) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
496 | case mwStatus_ACTIVE: |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
497 | status = MW_STATE_ACTIVE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
498 | idle = 0; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
499 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
500 | |
| 10977 | 501 | case mwStatus_IDLE: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
502 | if(! idle) idle = -1; |
| 10977 | 503 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
504 | |
| 10977 | 505 | case mwStatus_AWAY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
506 | status = MW_STATE_AWAY; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
507 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
508 | |
| 10977 | 509 | case mwStatus_BUSY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
510 | status = MW_STATE_BUSY; |
| 10977 | 511 | break; |
| 512 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
513 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
514 | /* NAB group members */ |
| 10977 | 515 | if(aware->group) { |
| 15884 | 516 | PurpleGroup *group; |
| 517 | PurpleBuddy *buddy; | |
| 518 | PurpleBlistNode *bnode; | |
| 10977 | 519 | |
| 520 | 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
|
521 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 15884 | 522 | bnode = (PurpleBlistNode *) buddy; |
| 10977 | 523 | |
| 524 | if(! buddy) { | |
| 525 | struct mwServiceResolve *srvc; | |
| 526 | GList *query; | |
| 527 | ||
| 15884 | 528 | buddy = purple_buddy_new(acct, id, NULL); |
| 529 | purple_blist_add_buddy(buddy, NULL, group, NULL); | |
| 530 | ||
| 531 | bnode = (PurpleBlistNode *) buddy; | |
| 10977 | 532 | |
| 533 | srvc = pd->srvc_resolve; | |
| 534 | query = g_list_append(NULL, (char *) id); | |
| 535 | ||
| 536 | mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS, | |
| 537 | blist_resolve_alias_cb, buddy, NULL); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
538 | g_list_free(query); |
| 10977 | 539 | } |
| 540 | ||
| 15884 | 541 | purple_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL); |
| 10977 | 542 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
543 | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
544 | if(aware->online) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
545 | 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
|
546 | 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
|
547 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
548 | } else { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
549 | 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
|
550 | } |
| 10977 | 551 | } |
| 552 | ||
| 553 | ||
| 554 | static void mw_aware_list_on_attrib(struct mwAwareList *list, | |
| 555 | struct mwAwareIdBlock *id, | |
| 556 | struct mwAwareAttribute *attrib) { | |
| 557 | ||
| 558 | ; /* nothing. We'll get attribute data as we need it */ | |
| 559 | } | |
| 560 | ||
| 561 | ||
| 562 | static void mw_aware_list_clear(struct mwAwareList *list) { | |
| 563 | ; /* nothing for now */ | |
| 564 | } | |
| 565 | ||
| 566 | ||
| 567 | static struct mwAwareListHandler mw_aware_list_handler = { | |
|
17157
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
568 | mw_aware_list_on_aware, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
569 | mw_aware_list_on_attrib, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
570 | mw_aware_list_clear, |
| 10977 | 571 | }; |
| 572 | ||
| 573 | ||
| 574 | /** Ensures that an Aware List is associated with the given group, and | |
| 575 | returns that list. */ | |
| 576 | static struct mwAwareList * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
577 | list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
578 | |
| 10977 | 579 | struct mwAwareList *list; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
580 | |
| 10977 | 581 | g_return_val_if_fail(pd != NULL, NULL); |
| 582 | g_return_val_if_fail(group != NULL, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
583 | |
| 10977 | 584 | list = g_hash_table_lookup(pd->group_list_map, group); |
| 585 | if(! list) { | |
| 586 | list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler); | |
| 587 | mwAwareList_setClientData(list, pd->gc, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
588 | |
| 10977 | 589 | mwAwareList_watchAttributes(list, |
| 590 | mwAttribute_AV_PREFS_SET, | |
| 591 | mwAttribute_MICROPHONE, | |
| 592 | mwAttribute_SPEAKERS, | |
| 593 | mwAttribute_VIDEO_CAMERA, | |
| 594 | mwAttribute_FILE_TRANSFER, | |
| 595 | NULL); | |
| 596 | ||
| 597 | g_hash_table_replace(pd->group_list_map, group, list); | |
| 598 | g_hash_table_insert(pd->group_list_map, list, group); | |
| 599 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
600 | |
| 10977 | 601 | return list; |
| 602 | } | |
| 603 | ||
| 604 | ||
| 15884 | 605 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 10977 | 606 | /* - find the account for this connection |
| 607 | - iterate through the buddy list | |
| 608 | - add each buddy matching this account to the stlist | |
| 609 | */ | |
| 610 | ||
| 15884 | 611 | PurpleAccount *acct; |
| 612 | PurpleBlistNode *gn, *cn, *bn; | |
| 613 | PurpleGroup *grp; | |
| 614 | PurpleBuddy *bdy; | |
| 10977 | 615 | |
| 616 | struct mwSametimeGroup *stg = NULL; | |
| 617 | struct mwIdBlock idb = { NULL, NULL }; | |
| 618 | ||
| 15884 | 619 | acct = purple_connection_get_account(gc); |
| 10977 | 620 | g_return_if_fail(acct != NULL); |
| 621 | ||
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
622 | for (gn = purple_blist_get_default_root(); gn; |
|
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
623 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 10977 | 624 | const char *owner; |
| 625 | const char *gname; | |
| 626 | enum mwSametimeGroupType gtype; | |
| 627 | gboolean gopen; | |
| 628 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
629 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 630 | grp = (PurpleGroup *) gn; |
| 10977 | 631 | |
| 632 | /* the group's type (normal or dynamic) */ | |
| 15884 | 633 | gtype = purple_blist_node_get_int(gn, GROUP_KEY_TYPE); |
| 10977 | 634 | if(! gtype) gtype = mwSametimeGroup_NORMAL; |
| 635 | ||
| 636 | /* if it's a normal group with none of our people in it, skip it */ | |
| 15884 | 637 | if(gtype == mwSametimeGroup_NORMAL && !purple_group_on_account(grp, acct)) |
| 10977 | 638 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
639 | |
| 10977 | 640 | /* if the group has an owner and we're not it, skip it */ |
| 15884 | 641 | 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
|
642 | if(owner && !purple_strequal(owner, purple_account_get_username(acct))) |
| 10977 | 643 | continue; |
| 644 | ||
| 15884 | 645 | /* the group's actual name may be different from the purple group's |
| 10977 | 646 | name. Find whichever is there */ |
| 15884 | 647 | 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
|
648 | if(! gname) gname = purple_group_get_name(grp); |
| 10977 | 649 | |
| 650 | /* we save this, but never actually honor it */ | |
| 15884 | 651 | gopen = ! purple_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); |
| 10977 | 652 | |
| 653 | 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
|
654 | mwSametimeGroup_setAlias(stg, purple_group_get_name(grp)); |
| 10977 | 655 | mwSametimeGroup_setOpen(stg, gopen); |
| 656 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
657 | /* 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
|
658 | other clients */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
659 | if(gtype == mwSametimeGroup_DYNAMIC) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
660 | continue; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
661 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
662 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
663 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
664 | 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
|
665 | if(! PURPLE_IS_CONTACT(cn)) continue; |
| 10977 | 666 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
667 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
668 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
669 | 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
|
670 | 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
|
671 | if(purple_blist_node_is_transient(bn)) continue; |
| 15884 | 672 | |
| 673 | bdy = (PurpleBuddy *) bn; | |
| 10977 | 674 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
675 | if(purple_buddy_get_account(bdy) == acct) { |
| 10977 | 676 | struct mwSametimeUser *stu; |
| 677 | enum mwSametimeUserType utype; | |
| 678 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
679 | idb.user = (char *)purple_buddy_get_name(bdy); |
| 10977 | 680 | |
| 15884 | 681 | utype = purple_blist_node_get_int(bn, BUDDY_KEY_TYPE); |
| 10977 | 682 | if(! utype) utype = mwSametimeUser_NORMAL; |
| 683 | ||
| 684 | 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
|
685 | 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
|
686 | mwSametimeUser_setAlias(stu, purple_buddy_get_local_alias(bdy)); |
| 10977 | 687 | } |
| 688 | } | |
| 689 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
690 | } |
| 10977 | 691 | } |
| 692 | ||
| 693 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
694 | static void blist_store(struct mwPurpleProtocolData *pd) { |
| 10977 | 695 | |
| 696 | struct mwSametimeList *stlist; | |
| 697 | struct mwServiceStorage *srvc; | |
| 698 | struct mwStorageUnit *unit; | |
| 699 | ||
| 15884 | 700 | PurpleConnection *gc; |
| 10977 | 701 | |
| 702 | struct mwPutBuffer *b; | |
| 703 | struct mwOpaque *o; | |
| 704 | ||
| 705 | g_return_if_fail(pd != NULL); | |
| 706 | ||
| 707 | srvc = pd->srvc_store; | |
| 708 | g_return_if_fail(srvc != NULL); | |
| 709 | ||
| 710 | gc = pd->gc; | |
| 711 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
712 | if(BLIST_PREF_IS_LOCAL() || BLIST_PREF_IS_MERGE()) { |
| 10977 | 713 | DEBUG_INFO("preferences indicate not to save remote blist\n"); |
| 714 | return; | |
| 715 | ||
| 716 | } else if(MW_SERVICE_IS_DEAD(srvc)) { | |
| 717 | DEBUG_INFO("aborting save of blist: storage service is not alive\n"); | |
| 718 | return; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
719 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
720 | } else if(BLIST_PREF_IS_STORE() || BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
721 | DEBUG_INFO("saving remote blist\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
722 | |
| 10977 | 723 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
724 | g_return_if_reached(); |
| 10977 | 725 | } |
| 726 | ||
| 727 | /* create and export to a list object */ | |
| 728 | stlist = mwSametimeList_new(); | |
| 729 | blist_export(gc, stlist); | |
| 730 | ||
| 731 | /* write it to a buffer */ | |
| 732 | b = mwPutBuffer_new(); | |
| 733 | mwSametimeList_put(b, stlist); | |
| 734 | mwSametimeList_free(stlist); | |
| 735 | ||
| 736 | /* put the buffer contents into a storage unit */ | |
| 737 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
| 738 | o = mwStorageUnit_asOpaque(unit); | |
| 739 | mwPutBuffer_finalize(o, b); | |
| 740 | ||
| 741 | /* save the storage unit to the service */ | |
| 742 | mwServiceStorage_save(srvc, unit, NULL, NULL, NULL); | |
| 743 | } | |
| 744 | ||
| 745 | ||
| 746 | 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
|
747 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 748 | |
| 749 | blist_store(pd); | |
| 750 | pd->save_event = 0; | |
| 751 | return FALSE; | |
| 752 | } | |
| 753 | ||
| 754 | ||
| 755 | /** 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
|
756 | static void blist_schedule(struct mwPurpleProtocolData *pd) { |
| 10977 | 757 | if(pd->save_event) return; |
| 758 | ||
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
759 | pd->save_event = g_timeout_add_seconds(BLIST_SAVE_SECONDS, |
| 10977 | 760 | blist_save_cb, pd); |
| 761 | } | |
| 762 | ||
| 763 | ||
| 15884 | 764 | static gboolean buddy_is_external(PurpleBuddy *b) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
765 | g_return_val_if_fail(b != NULL, FALSE); |
|
40125
a7acc7b00d79
Replace purple_str_has_{prefix,suffix} by g_str_has_{prefix,suffix}.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39970
diff
changeset
|
766 | return g_str_has_prefix(purple_buddy_get_name(b), "@E "); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
767 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
768 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
769 | |
| 10977 | 770 | /** Actually add a buddy to the aware service, and schedule the buddy |
| 771 | 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
|
772 | static void buddy_add(struct mwPurpleProtocolData *pd, |
| 15884 | 773 | PurpleBuddy *buddy) { |
| 10977 | 774 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
775 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) purple_buddy_get_name(buddy), NULL }; |
| 10977 | 776 | struct mwAwareList *list; |
| 777 | ||
| 15884 | 778 | PurpleGroup *group; |
| 10977 | 779 | GList *add; |
| 780 | ||
| 781 | add = g_list_prepend(NULL, &idb); | |
| 782 | ||
| 15884 | 783 | group = purple_buddy_get_group(buddy); |
| 10977 | 784 | list = list_ensure(pd, group); |
| 785 | ||
| 786 | if(mwAwareList_addAware(list, add)) { | |
| 15884 | 787 | purple_blist_remove_buddy(buddy); |
| 10977 | 788 | } |
| 789 | ||
| 790 | blist_schedule(pd); | |
| 791 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
792 | g_list_free(add); |
| 10977 | 793 | } |
| 794 | ||
| 795 | ||
| 15884 | 796 | /** ensure that a PurpleBuddy exists in the group with data |
| 10977 | 797 | appropriately matching the st user entry from the st list */ |
| 15884 | 798 | static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, |
| 10977 | 799 | struct mwSametimeUser *stuser) { |
| 800 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
801 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 802 | PurpleBuddy *buddy; |
| 803 | PurpleAccount *acct = purple_connection_get_account(gc); | |
| 10977 | 804 | |
| 805 | const char *id = mwSametimeUser_getUser(stuser); | |
| 806 | const char *name = mwSametimeUser_getShortName(stuser); | |
| 807 | const char *alias = mwSametimeUser_getAlias(stuser); | |
| 808 | enum mwSametimeUserType type = mwSametimeUser_getType(stuser); | |
| 809 | ||
| 810 | 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
|
811 | g_return_val_if_fail(*id, NULL); |
| 10977 | 812 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
813 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 10977 | 814 | if(! buddy) { |
| 15884 | 815 | buddy = purple_buddy_new(acct, id, alias); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
816 | |
| 15884 | 817 | purple_blist_add_buddy(buddy, NULL, group, NULL); |
| 10977 | 818 | buddy_add(pd, buddy); |
| 819 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
820 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
821 | 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
|
822 | purple_buddy_set_server_alias(buddy, name); |
| 15884 | 823 | purple_blist_node_set_string((PurpleBlistNode *) buddy, BUDDY_KEY_NAME, name); |
| 824 | purple_blist_node_set_int((PurpleBlistNode *) buddy, BUDDY_KEY_TYPE, type); | |
| 10977 | 825 | |
| 826 | return buddy; | |
| 827 | } | |
| 828 | ||
| 829 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
830 | /** 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
|
831 | static void group_add(struct mwPurpleProtocolData *pd, |
| 15884 | 832 | PurpleGroup *group) { |
| 10977 | 833 | |
| 834 | struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL }; | |
| 835 | struct mwAwareList *list; | |
| 836 | const char *n; | |
| 837 | GList *add; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
838 | |
| 15884 | 839 | 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
|
840 | if(! n) n = purple_group_get_name(group); |
| 10977 | 841 | |
| 842 | idb.user = (char *) n; | |
| 843 | add = g_list_prepend(NULL, &idb); | |
| 844 | ||
| 845 | list = list_ensure(pd, group); | |
| 846 | mwAwareList_addAware(list, add); | |
| 847 | g_list_free(add); | |
| 848 | } | |
| 849 | ||
| 850 | ||
| 15884 | 851 | /** ensure that a PurpleGroup exists in the blist with data |
| 10977 | 852 | appropriately matching the st group entry from the st list */ |
| 15884 | 853 | static PurpleGroup *group_ensure(PurpleConnection *gc, |
| 10977 | 854 | struct mwSametimeGroup *stgroup) { |
| 15884 | 855 | PurpleAccount *acct; |
| 856 | PurpleGroup *group = NULL; | |
| 857 | PurpleBuddyList *blist; | |
| 858 | PurpleBlistNode *gn; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
859 | const char *name, *alias, *owner; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
860 | enum mwSametimeGroupType type; |
| 10977 | 861 | |
| 15884 | 862 | acct = purple_connection_get_account(gc); |
| 863 | owner = purple_account_get_username(acct); | |
| 864 | ||
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
865 | blist = purple_blist_get_default(); |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
866 | g_return_val_if_fail(blist != NULL, NULL); |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
867 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
868 | name = mwSametimeGroup_getName(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
869 | alias = mwSametimeGroup_getAlias(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
870 | type = mwSametimeGroup_getType(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
871 | |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
872 | if (!name) { |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
873 | DEBUG_WARN("Can't ensure a null group\n"); |
|
31991
efe4fb3772ad
Fix this compile warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
31983
diff
changeset
|
874 | return NULL; |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
875 | } |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
876 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
877 | DEBUG_INFO("attempting to ensure group %s, called %s\n", name, alias); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
878 | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
879 | /* first attempt at finding the group, by the name key */ |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
880 | for (gn = purple_blist_get_default_root(); gn; |
|
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
881 | gn = purple_blist_node_get_sibling_next(gn)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
882 | const char *n, *o; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
883 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 884 | n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
| 885 | 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
|
886 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
887 | DEBUG_INFO("found group named %s, owned by %s\n", n, o); |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
888 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
889 | if(n && purple_strequal(n, name)) { |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
890 | if(!o || purple_strequal(o, owner)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
891 | DEBUG_INFO("that'll work\n"); |
| 15884 | 892 | group = (PurpleGroup *) gn; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
893 | break; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
894 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
895 | } |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
896 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
897 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
898 | /* try again, by alias */ |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
899 | if(! group) { |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
900 | DEBUG_INFO("searching for group by alias %s\n", alias); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
901 | group = purple_blist_find_group(alias); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
902 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
903 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
904 | /* oh well, no such group. Let's create it! */ |
| 10977 | 905 | if(! group) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
906 | DEBUG_INFO("creating group\n"); |
| 15884 | 907 | group = purple_group_new(alias); |
| 908 | purple_blist_add_group(group, NULL); | |
| 10977 | 909 | } |
| 910 | ||
| 15884 | 911 | gn = (PurpleBlistNode *) group; |
| 912 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); | |
| 913 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | |
| 10977 | 914 | |
| 915 | if(type == mwSametimeGroup_DYNAMIC) { | |
| 15884 | 916 | 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
|
917 | group_add(purple_connection_get_protocol_data(gc), group); |
| 10977 | 918 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
919 | |
| 10977 | 920 | return group; |
| 921 | } | |
| 922 | ||
| 923 | ||
| 15884 | 924 | /** merge the entries from a st list into the purple blist */ |
| 925 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist) { | |
| 10977 | 926 | struct mwSametimeGroup *stgroup; |
| 927 | struct mwSametimeUser *stuser; | |
| 928 | ||
| 15884 | 929 | PurpleGroup *group; |
| 10977 | 930 | |
| 931 | GList *gl, *gtl, *ul, *utl; | |
| 932 | ||
| 933 | gl = gtl = mwSametimeList_getGroups(stlist); | |
| 934 | for(; gl; gl = gl->next) { | |
| 935 | ||
| 936 | stgroup = (struct mwSametimeGroup *) gl->data; | |
| 937 | group = group_ensure(gc, stgroup); | |
| 938 | ||
| 939 | ul = utl = mwSametimeGroup_getUsers(stgroup); | |
| 940 | for(; ul; ul = ul->next) { | |
| 941 | ||
| 942 | stuser = (struct mwSametimeUser *) ul->data; | |
|
33782
1690e0b2c508
Fix a bunch of unused variables
Daniel Atallah <datallah@pidgin.im>
parents:
33745
diff
changeset
|
943 | buddy_ensure(gc, group, stuser); |
| 10977 | 944 | } |
| 945 | g_list_free(utl); | |
| 946 | } | |
| 947 | g_list_free(gtl); | |
| 948 | } | |
| 949 | ||
| 950 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
951 | /** 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
|
952 | is left empty, remove group as well */ |
| 15884 | 953 | static void group_clear(PurpleGroup *group, PurpleAccount *acct, gboolean del) { |
| 954 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
955 | GList *prune = NULL; |
| 15884 | 956 | PurpleBlistNode *gn, *cn, *bn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
957 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
958 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
959 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
960 | DEBUG_INFO("clearing members from pruned group %s\n", purple_group_get_name(group)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
961 | |
| 15884 | 962 | gc = purple_account_get_connection(acct); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
963 | g_return_if_fail(gc != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
964 | |
| 15884 | 965 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
966 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
967 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
968 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
969 | 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
|
970 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
971 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
972 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
973 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
974 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 975 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 976 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
977 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
978 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
979 | if(purple_buddy_get_account(gb) == acct) { |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
980 | DEBUG_INFO("clearing %s from group\n", purple_buddy_get_name(gb)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
981 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
982 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
983 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
984 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
985 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
986 | /* quickly unsubscribe from presence for the entire group */ |
| 15884 | 987 | purple_account_remove_group(acct, group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
988 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
989 | /* remove blist entries that need to go */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
990 | while(prune) { |
| 15884 | 991 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
992 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
993 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
994 | DEBUG_INFO("cleared buddies\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
995 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
996 | /* 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
|
997 | 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
|
998 | DEBUG_INFO("removing empty group\n"); |
| 15884 | 999 | purple_blist_remove_group(group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1000 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1001 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1002 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1003 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1004 | /** prune out group members that shouldn't be there */ |
| 15884 | 1005 | static void group_prune(PurpleConnection *gc, PurpleGroup *group, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1006 | struct mwSametimeGroup *stgroup) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1007 | |
| 15884 | 1008 | PurpleAccount *acct; |
| 1009 | PurpleBlistNode *gn, *cn, *bn; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1010 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1011 | GHashTable *stusers; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1012 | GList *prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1013 | GList *ul, *utl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1014 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1015 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1016 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1017 | DEBUG_INFO("pruning membership of group %s\n", purple_group_get_name(group)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1018 | |
| 15884 | 1019 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1020 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1021 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1022 | 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
|
1023 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1024 | /* 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
|
1025 | contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1026 | utl = mwSametimeGroup_getUsers(stgroup); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1027 | for(ul = utl; ul; ul = ul->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1028 | const char *id = mwSametimeUser_getUser(ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1029 | g_hash_table_insert(stusers, (char *) id, ul->data); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1030 | DEBUG_INFO("server copy has %s\n", id); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1031 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1032 | g_list_free(utl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1033 | |
| 15884 | 1034 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1035 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1036 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1037 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1038 | 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
|
1039 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1040 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1041 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1042 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1043 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1044 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1045 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1046 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
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 | /* 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
|
1049 | them for pruning */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1050 | if(purple_buddy_get_account(gb) == acct && !g_hash_table_lookup(stusers, purple_buddy_get_name(gb))) { |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1051 | DEBUG_INFO("marking %s for pruning\n", purple_buddy_get_name(gb)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1052 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1053 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1054 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1055 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1056 | DEBUG_INFO("done marking\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1057 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1058 | g_hash_table_destroy(stusers); |
|
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 | if(prune) { |
| 15884 | 1061 | purple_account_remove_buddies(acct, prune, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1062 | while(prune) { |
| 15884 | 1063 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1064 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1065 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1066 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1067 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1068 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1069 | |
| 15884 | 1070 | /** 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
|
1071 | existing buddies that aren't in the st list */ |
| 15884 | 1072 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 1073 | ||
| 1074 | PurpleAccount *acct; | |
| 1075 | PurpleBuddyList *blist; | |
| 1076 | PurpleBlistNode *gn; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1077 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1078 | GHashTable *stgroups; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1079 | GList *g_prune = 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 | GList *gl, *gtl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1082 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1083 | const char *acct_n; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1084 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1085 | DEBUG_INFO("synchronizing local buddy list from server list\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1086 | |
| 15884 | 1087 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1088 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1089 | |
| 15884 | 1090 | acct_n = purple_account_get_username(acct); |
| 1091 | ||
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1092 | blist = purple_blist_get_default(); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1093 | g_return_if_fail(blist != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1094 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1095 | /* 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
|
1096 | list, mapping group name to group structure */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1097 | 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
|
1098 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1099 | gtl = mwSametimeList_getGroups(stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1100 | for(gl = gtl; gl; gl = gl->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1101 | const char *name = mwSametimeGroup_getName(gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1102 | g_hash_table_insert(stgroups, (char *) name, gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1103 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1104 | g_list_free(gtl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1105 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1106 | /* find all groups which should be pruned from the local list */ |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1107 | for (gn = purple_blist_get_default_root(); gn; |
|
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1108 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 15884 | 1109 | PurpleGroup *grp = (PurpleGroup *) gn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1110 | const char *gname, *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1111 | struct mwSametimeGroup *stgrp; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1112 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1113 | if(! PURPLE_IS_GROUP(gn)) continue; |
|
11943
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 | /* group not belonging to this account */ |
| 15884 | 1116 | if(! purple_group_on_account(grp, acct)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1117 | continue; |
|
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 | /* dynamic group belonging to this account. don't prune contents */ |
| 15884 | 1120 | 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
|
1121 | if(owner && purple_strequal(owner, acct_n)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1122 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1123 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1124 | /* 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
|
1125 | title, which can be different things in the st list */ |
| 15884 | 1126 | 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
|
1127 | if(! gname) gname = purple_group_get_name(grp); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1128 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1129 | stgrp = g_hash_table_lookup(stgroups, gname); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1130 | if(! stgrp) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1131 | /* remove the whole group */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1132 | 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
|
1133 | g_prune = g_list_prepend(g_prune, grp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1134 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1135 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1136 | /* synch the group contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1137 | group_prune(gc, grp, stgrp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1138 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1139 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1140 | DEBUG_INFO("done marking groups\n"); |
|
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 | /* don't need this anymore */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1143 | g_hash_table_destroy(stgroups); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1144 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1145 | /* prune all marked groups */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1146 | while(g_prune) { |
| 15884 | 1147 | PurpleGroup *grp = g_prune->data; |
| 1148 | PurpleBlistNode *gn = (PurpleBlistNode *) grp; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1149 | const char *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1150 | gboolean del = TRUE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1151 | |
| 15884 | 1152 | 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
|
1153 | if(owner && !purple_strequal(owner, acct_n)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1154 | /* 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
|
1155 | 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
|
1156 | del = FALSE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1157 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1158 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1159 | group_clear(g_prune->data, acct, del); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1160 | g_prune = g_list_delete_link(g_prune, g_prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1161 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1162 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1163 | /* done with the pruning, let's merge in the additions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1164 | blist_merge(gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1165 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1166 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1167 | |
| 10977 | 1168 | /** callback passed to the storage service when it's told to load the |
| 1169 | st list */ | |
| 1170 | static void fetch_blist_cb(struct mwServiceStorage *srvc, | |
| 1171 | guint32 result, struct mwStorageUnit *item, | |
| 1172 | gpointer data) { | |
| 1173 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1174 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 1175 | struct mwSametimeList *stlist; |
| 1176 | ||
| 1177 | struct mwGetBuffer *b; | |
| 1178 | ||
| 1179 | g_return_if_fail(result == ERR_SUCCESS); | |
| 1180 | ||
| 1181 | /* check our preferences for loading */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1182 | if(BLIST_PREF_IS_LOCAL()) { |
| 10977 | 1183 | DEBUG_INFO("preferences indicate not to load remote buddy list\n"); |
| 1184 | return; | |
| 1185 | } | |
| 1186 | ||
| 1187 | b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); | |
| 1188 | ||
| 1189 | stlist = mwSametimeList_new(); | |
| 1190 | mwSametimeList_get(b, stlist); | |
| 1191 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1192 | /* merge or synch depending on preferences */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1193 | if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1194 | blist_merge(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1195 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1196 | } else if(BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1197 | blist_sync(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1198 | } |
| 10977 | 1199 | |
| 1200 | mwSametimeList_free(stlist); | |
| 22973 | 1201 | mwGetBuffer_free(b); |
| 10977 | 1202 | } |
| 1203 | ||
| 1204 | ||
| 15884 | 1205 | /** signal triggered when a conversation is opened in Purple */ |
| 1206 | 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
|
1207 | struct mwPurpleProtocolData *pd) { |
| 10977 | 1208 | |
| 1209 | /* we need to tell the IM service to negotiate features for the | |
| 1210 | conversation right away, otherwise it'll wait until the first | |
| 1211 | message is sent before offering NotesBuddy features. Therefore | |
| 15884 | 1212 | whenever Purple creates a conversation, we'll immediately open the |
| 10977 | 1213 | channel to the other side and figure out what the target can |
| 1214 | handle. Unfortunately, this makes us vulnerable to Psychic Mode, | |
| 1215 | 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
|
1216 | would not */ |
| 10977 | 1217 | |
| 15884 | 1218 | PurpleConnection *gc; |
| 10977 | 1219 | struct mwIdBlock who = { 0, 0 }; |
| 1220 | struct mwConversation *conv; | |
| 1221 | ||
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1222 | gc = purple_conversation_get_connection(g_conv); |
| 10977 | 1223 | if(pd->gc != gc) |
| 1224 | return; /* not ours */ | |
| 1225 | ||
|
35070
d7350d876fda
libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents:
35005
diff
changeset
|
1226 | if(!PURPLE_IS_IM_CONVERSATION(g_conv)) |
| 10977 | 1227 | return; /* wrong type */ |
| 1228 | ||
| 15884 | 1229 | who.user = (char *) purple_conversation_get_name(g_conv); |
| 10977 | 1230 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 1231 | ||
| 1232 | convo_features(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1233 | |
| 10977 | 1234 | if(mwConversation_isClosed(conv)) |
| 1235 | mwConversation_open(conv); | |
| 1236 | } | |
| 1237 | ||
| 1238 | ||
| 15884 | 1239 | 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
|
1240 | struct mwPurpleProtocolData *pd = data; |
| 15884 | 1241 | PurpleConnection *gc; |
| 1242 | ||
| 1243 | PurpleGroup *group = (PurpleGroup *) node; | |
| 10977 | 1244 | |
| 1245 | GString *str; | |
| 1246 | char *tmp; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1247 | const char *gname; |
| 10977 | 1248 | |
| 1249 | g_return_if_fail(pd != NULL); | |
| 1250 | ||
| 1251 | gc = pd->gc; | |
| 1252 | g_return_if_fail(gc != NULL); | |
| 1253 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1254 | g_return_if_fail(PURPLE_IS_GROUP(node)); |
| 10977 | 1255 | |
| 1256 | str = g_string_new(NULL); | |
| 1257 | ||
| 15884 | 1258 | 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
|
1259 | gname = purple_group_get_name(group); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1260 | |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1261 | 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
|
1262 | 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
|
1263 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1264 | tmp = g_strdup_printf(_("Info for Group %s"), gname); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1265 | |
| 15884 | 1266 | purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
| 10977 | 1267 | NULL, str->str, NULL, NULL); |
| 1268 | ||
| 1269 | g_free(tmp); | |
| 1270 | g_string_free(str, TRUE); | |
| 1271 | } | |
| 1272 | ||
| 1273 | ||
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
1274 | /** The normal blist menu protocol function doesn't get called for groups, |
| 10977 | 1275 | so we use the blist-node-extended-menu signal to trigger this |
| 1276 | handler */ | |
| 15884 | 1277 | 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
|
1278 | GList **menu, struct mwPurpleProtocolData *pd) { |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1279 | const char *owner; |
| 15884 | 1280 | PurpleAccount *acct; |
|
39481
4db28449567d
Rename PurpleMenuAction to PurpleActionMenu
Gary Kramlich <grim@reaperworld.com>
parents:
39479
diff
changeset
|
1281 | PurpleActionMenu *act; |
| 10977 | 1282 | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1283 | /* we only want groups */ |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1284 | if(! PURPLE_IS_GROUP(node)) return; |
| 15884 | 1285 | |
| 1286 | acct = purple_connection_get_account(pd->gc); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1287 | g_return_if_fail(acct != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1288 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1289 | /* better make sure we're connected */ |
| 15884 | 1290 | if(! purple_account_is_connected(acct)) return; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1291 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1292 | /* check if it's a NAB group for this account */ |
| 15884 | 1293 | 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
|
1294 | if(owner && purple_strequal(owner, purple_account_get_username(acct))) { |
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
1295 | act = purple_action_menu_new(_("Get Notes Address Book Info"), |
| 15884 | 1296 | PURPLE_CALLBACK(blist_menu_nab), pd, NULL); |
| 10977 | 1297 | *menu = g_list_append(*menu, act); |
| 1298 | } | |
| 1299 | } | |
| 1300 | ||
| 1301 | ||
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1302 | /* 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
|
1303 | anymore. */ |
| 15884 | 1304 | static void blist_init(PurpleAccount *acct) { |
| 1305 | PurpleBlistNode *gnode, *cnode, *bnode; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1306 | GList *add_buds = NULL; |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1307 | |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1308 | for (gnode = purple_blist_get_default_root(); gnode; |
|
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1309 | 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
|
1310 | if(! PURPLE_IS_GROUP(gnode)) continue; |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1311 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1312 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1313 | cnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1314 | 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
|
1315 | if(! PURPLE_IS_CONTACT(cnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1316 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1317 | for(bnode = purple_blist_node_get_first_child(cnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1318 | bnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1319 | bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 15884 | 1320 | PurpleBuddy *b; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1321 | if(!PURPLE_IS_BUDDY(bnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1322 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1323 | |
| 15884 | 1324 | b = (PurpleBuddy *)bnode; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1325 | if(purple_buddy_get_account(b) == acct) { |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1326 | add_buds = g_list_append(add_buds, b); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1327 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1328 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1329 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1330 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1331 | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1332 | if(add_buds) { |
|
32319
ab70b05e538b
sametime: fix build (add_buddies added param)
Paul Aurich <darkrain42@pidgin.im>
parents:
32316
diff
changeset
|
1333 | purple_account_add_buddies(acct, add_buds, NULL); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1334 | g_list_free(add_buds); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1335 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1336 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1337 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1338 | |
| 10977 | 1339 | /** 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
|
1340 | static void services_starting(struct mwPurpleProtocolData *pd) { |
| 15884 | 1341 | |
| 1342 | PurpleConnection *gc; | |
| 1343 | PurpleAccount *acct; | |
| 10977 | 1344 | struct mwStorageUnit *unit; |
| 15884 | 1345 | PurpleBlistNode *l; |
| 10977 | 1346 | |
| 1347 | gc = pd->gc; | |
| 15884 | 1348 | acct = purple_connection_get_account(gc); |
| 10977 | 1349 | |
| 1350 | /* grab the buddy list from the server */ | |
| 1351 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1352 | mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
| 10977 | 1353 | |
| 1354 | /* find all the NAB groups and subscribe to them */ | |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1355 | for (l = purple_blist_get_default_root(); l; |
|
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1356 | l = purple_blist_node_get_sibling_next(l)) { |
| 15884 | 1357 | PurpleGroup *group = (PurpleGroup *) l; |
| 10977 | 1358 | enum mwSametimeGroupType gt; |
| 1359 | const char *owner; | |
| 1360 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1361 | if(! PURPLE_IS_GROUP(l)) continue; |
| 10977 | 1362 | |
| 1363 | /* if the group is ownerless, or has an owner and we're not it, | |
| 1364 | skip it */ | |
| 15884 | 1365 | 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
|
1366 | if(!owner || !purple_strequal(owner, purple_account_get_username(acct))) |
| 10977 | 1367 | continue; |
| 1368 | ||
| 15884 | 1369 | gt = purple_blist_node_get_int(l, GROUP_KEY_TYPE); |
| 10977 | 1370 | if(gt == mwSametimeGroup_DYNAMIC) |
| 1371 | group_add(pd, group); | |
| 1372 | } | |
| 1373 | ||
| 1374 | /* set the aware attributes */ | |
| 1375 | /* indicate we understand what AV prefs are, but don't support any */ | |
| 1376 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1377 | mwAttribute_AV_PREFS_SET, TRUE); | |
| 1378 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE); | |
| 1379 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS); | |
| 1380 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA); | |
| 1381 | ||
| 1382 | /* ... but we can do file transfers! */ | |
| 1383 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1384 | mwAttribute_FILE_TRANSFER, TRUE); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1385 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1386 | blist_init(acct); |
| 10977 | 1387 | } |
| 1388 | ||
| 1389 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1390 | static void session_loginRedirect(struct mwSession *session, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1391 | const char *host) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1392 | struct mwPurpleProtocolData *pd; |
| 15884 | 1393 | PurpleConnection *gc; |
| 1394 | PurpleAccount *account; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1395 | guint port; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1396 | const char *current_host; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1397 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1398 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1399 | gc = pd->gc; |
| 15884 | 1400 | account = purple_connection_get_account(gc); |
| 1401 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); | |
| 1402 | 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
|
1403 | MW_PLUGIN_DEFAULT_HOST); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1404 | |
| 15884 | 1405 | if(purple_account_get_bool(account, MW_KEY_FORCE, FALSE) || |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1406 | !host || purple_strequal(current_host, host)) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1407 | /* if we're configured to force logins, or if we're being |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1408 | redirected to the already configured host, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1409 | we'll force the login instead */ |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1410 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1411 | mwSession_forceLogin(session); |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1412 | return; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1413 | } |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1414 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1415 | pd->client = purple_gio_socket_client_new(account, NULL); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1416 | if (pd->client == NULL) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1417 | /* if we couldn't connect to the new host, we'll force the login instead */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1418 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1419 | mwSession_forceLogin(session); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1420 | return; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1421 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1422 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1423 | g_socket_client_connect_to_host_async( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1424 | pd->client, host, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1425 | port, pd->cancellable, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1426 | connect_cb, pd); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1427 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1428 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1429 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
1430 | static void mw_protocol_set_status(PurpleProtocolServer *protocol_server, PurpleAccount *acct, PurpleStatus *status); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1431 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1432 | |
| 10977 | 1433 | /** called from mw_session_stateChange when the session's state is |
| 1434 | mwSession_STARTED. Any finalizing of start-up stuff should go | |
| 1435 | here */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1436 | static void session_started(struct mwPurpleProtocolData *pd) { |
| 15884 | 1437 | PurpleStatus *status; |
| 1438 | PurpleAccount *acct; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1439 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1440 | /* set out initial status */ |
| 15884 | 1441 | acct = purple_connection_get_account(pd->gc); |
| 1442 | status = purple_account_get_active_status(acct); | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
1443 | mw_protocol_set_status(NULL, acct, status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1444 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1445 | /* start watching for new conversations */ |
| 15884 | 1446 | purple_signal_connect(purple_conversations_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1447 | "conversation-created", pd, |
| 15884 | 1448 | PURPLE_CALLBACK(conversation_created_cb), pd); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1449 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1450 | /* watch for group extended menu items */ |
| 15884 | 1451 | purple_signal_connect(purple_blist_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1452 | "blist-node-extended-menu", pd, |
| 15884 | 1453 | PURPLE_CALLBACK(blist_node_menu_cb), pd); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1454 | |
| 10977 | 1455 | /* use our services to do neat things */ |
| 1456 | services_starting(pd); | |
| 1457 | } | |
| 1458 | ||
| 1459 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1460 | static void session_stopping(struct mwPurpleProtocolData *pd) { |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1461 | /* stop watching the signals from session_started */ |
| 15884 | 1462 | purple_signals_disconnect_by_handle(pd); |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1463 | } |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1464 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1465 | |
| 10977 | 1466 | static void mw_session_stateChange(struct mwSession *session, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1467 | enum mwSessionState state, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1468 | gpointer info) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1469 | struct mwPurpleProtocolData *pd; |
| 15884 | 1470 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1471 | const char *msg = NULL; |
| 10977 | 1472 | |
| 1473 | pd = mwSession_getClientData(session); | |
| 1474 | gc = pd->gc; | |
| 1475 | ||
| 1476 | switch(state) { | |
| 1477 | case mwSession_STARTING: | |
| 1478 | msg = _("Sending Handshake"); | |
| 15884 | 1479 | purple_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS); |
| 10977 | 1480 | break; |
| 1481 | ||
| 1482 | case mwSession_HANDSHAKE: | |
| 1483 | msg = _("Waiting for Handshake Acknowledgement"); | |
| 15884 | 1484 | purple_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS); |
| 10977 | 1485 | break; |
| 1486 | ||
| 1487 | case mwSession_HANDSHAKE_ACK: | |
| 1488 | msg = _("Handshake Acknowledged, Sending Login"); | |
| 15884 | 1489 | purple_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS); |
| 10977 | 1490 | break; |
| 1491 | ||
| 1492 | case mwSession_LOGIN: | |
| 1493 | msg = _("Waiting for Login Acknowledgement"); | |
| 15884 | 1494 | purple_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS); |
| 10977 | 1495 | break; |
| 1496 | ||
| 1497 | case mwSession_LOGIN_REDIR: | |
| 1498 | msg = _("Login Redirected"); | |
| 15884 | 1499 | 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
|
1500 | session_loginRedirect(session, info); |
| 10977 | 1501 | break; |
| 1502 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1503 | case mwSession_LOGIN_CONT: |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1504 | msg = _("Forcing Login"); |
| 15884 | 1505 | 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
|
1506 | break; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1507 | |
| 10977 | 1508 | case mwSession_LOGIN_ACK: |
| 1509 | msg = _("Login Acknowledged"); | |
| 15884 | 1510 | purple_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS); |
| 10977 | 1511 | break; |
| 1512 | ||
| 1513 | case mwSession_STARTED: | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1514 | msg = _("Starting Services"); |
| 15884 | 1515 | purple_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS); |
| 10977 | 1516 | |
| 1517 | session_started(pd); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1518 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1519 | msg = _("Connected"); |
| 15884 | 1520 | 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
|
1521 | purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED); |
| 10977 | 1522 | break; |
| 1523 | ||
| 1524 | case mwSession_STOPPING: | |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1525 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1526 | session_stopping(pd); |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1527 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1528 | if(GPOINTER_TO_UINT(info) & ERR_FAILURE) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1529 | char *err = mwError(GPOINTER_TO_UINT(info)); |
| 21279 | 1530 | PurpleConnectionError reason; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1531 | switch (GPOINTER_TO_UINT(info)) { |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1532 | case VERSION_MISMATCH: |
| 21279 | 1533 | reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1534 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1535 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1536 | case USER_RESTRICTED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1537 | case INCORRECT_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1538 | case USER_UNREGISTERED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1539 | case GUEST_IN_USE: |
| 21279 | 1540 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1541 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1542 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1543 | case ENCRYPT_MISMATCH: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1544 | case ERR_ENCRYPT_NO_SUPPORT: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1545 | case ERR_NO_COMMON_ENCRYPT: |
| 21279 | 1546 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1547 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1548 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1549 | case VERIFICATION_DOWN: |
| 21279 | 1550 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1551 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1552 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1553 | case MULTI_SERVER_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1554 | case MULTI_SERVER_LOGIN2: |
| 21279 | 1555 | reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1556 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1557 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1558 | default: |
| 21279 | 1559 | reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1560 | } |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1561 | purple_connection_error(gc, reason, err); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1562 | g_free(err); |
| 10977 | 1563 | } |
| 1564 | break; | |
| 1565 | ||
| 1566 | case mwSession_STOPPED: | |
| 1567 | break; | |
| 1568 | ||
| 1569 | case mwSession_UNKNOWN: | |
| 1570 | default: | |
| 1571 | DEBUG_WARN("session in unknown state\n"); | |
| 1572 | } | |
| 1573 | } | |
| 1574 | ||
| 1575 | ||
| 1576 | 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
|
1577 | struct mwPurpleProtocolData *pd; |
| 15884 | 1578 | PurpleConnection *gc; |
| 1579 | PurpleAccount *acct; | |
| 10977 | 1580 | struct mwPrivacyInfo *privacy; |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1581 | GSList *list; |
| 10977 | 1582 | guint count; |
| 1583 | ||
| 1584 | DEBUG_INFO("privacy information set from server\n"); | |
| 1585 | ||
| 1586 | g_return_if_fail(session != NULL); | |
| 1587 | ||
| 1588 | pd = mwSession_getClientData(session); | |
| 1589 | g_return_if_fail(pd != NULL); | |
| 1590 | ||
| 1591 | gc = pd->gc; | |
| 1592 | g_return_if_fail(gc != NULL); | |
| 1593 | ||
| 15884 | 1594 | acct = purple_connection_get_account(gc); |
| 10977 | 1595 | g_return_if_fail(acct != NULL); |
| 1596 | ||
| 1597 | privacy = mwSession_getPrivacyInfo(session); | |
| 1598 | count = privacy->count; | |
| 1599 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1600 | if (privacy->deny) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1601 | 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
|
1602 | 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
|
1603 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1604 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1605 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1606 | 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
|
1607 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1608 | } else { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1609 | 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
|
1610 | 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
|
1611 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1612 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1613 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1614 | 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
|
1615 | } |
| 10977 | 1616 | } |
| 1617 | } | |
| 1618 | ||
| 1619 | ||
| 1620 | 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
|
1621 | struct mwPurpleProtocolData *pd; |
| 15884 | 1622 | PurpleConnection *gc; |
| 10977 | 1623 | struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL }; |
| 1624 | struct mwUserStatus *stat; | |
| 1625 | ||
| 1626 | g_return_if_fail(session != NULL); | |
| 1627 | ||
| 1628 | pd = mwSession_getClientData(session); | |
| 1629 | g_return_if_fail(pd != NULL); | |
| 1630 | ||
| 1631 | gc = pd->gc; | |
| 1632 | g_return_if_fail(gc != NULL); | |
| 1633 | ||
| 1634 | idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); | |
| 1635 | stat = mwSession_getUserStatus(session); | |
| 1636 | ||
| 1637 | /* trigger an update of our own status if we're in the buddy list */ | |
| 1638 | mwServiceAware_setStatus(pd->srvc_aware, &idb, stat); | |
| 1639 | } | |
| 1640 | ||
| 1641 | ||
| 1642 | static void mw_session_admin(struct mwSession *session, | |
| 1643 | const char *text) { | |
| 15884 | 1644 | PurpleConnection *gc; |
| 1645 | PurpleAccount *acct; | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1646 | const char *host; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1647 | const char *msg; |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1648 | char *prim; |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1649 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1650 | gc = session_to_gc(session); |
| 10977 | 1651 | g_return_if_fail(gc != NULL); |
| 1652 | ||
| 15884 | 1653 | acct = purple_connection_get_account(gc); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1654 | g_return_if_fail(acct != NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1655 | |
| 15884 | 1656 | 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
|
1657 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1658 | msg = _("A Sametime administrator has issued the following announcement" |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1659 | " on server %s"); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1660 | prim = g_strdup_printf(msg, host); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1661 | |
| 15884 | 1662 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1663 | _("Sametime Administrator Announcement"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1664 | prim, text, NULL, NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1665 | purple_request_cpar_from_connection(gc)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1666 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1667 | g_free(prim); |
| 10977 | 1668 | } |
| 1669 | ||
| 1670 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1671 | /** callback triggered from GPollableInputStream, watches the stream for |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1672 | available data to be processed by the session */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1673 | static gboolean |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1674 | read_cb(GObject *stream, gpointer data) |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1675 | { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1676 | struct mwPurpleProtocolData *pd = data; |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1677 | guchar buf[BUF_LEN]; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1678 | gssize len; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1679 | GError *error = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1680 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1681 | g_return_val_if_fail(pd != NULL, G_SOURCE_REMOVE); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1682 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1683 | do { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1684 | len = g_pollable_input_stream_read_nonblocking( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1685 | G_POLLABLE_INPUT_STREAM(stream), buf, sizeof(buf) - 1, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1686 | pd->cancellable, &error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1687 | if (len == 0) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1688 | DEBUG_INFO("connection reset\n"); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1689 | purple_connection_error(pd->gc, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1690 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1691 | _("Server closed the connection")); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1692 | return G_SOURCE_REMOVE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1693 | } else if (len < 0) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1694 | /* read problem occurred if we're here, so we'll need to take care of |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1695 | it and clean up internal state */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1696 | if (error->code == G_IO_ERROR_WOULD_BLOCK) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1697 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1698 | return G_SOURCE_CONTINUE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1699 | } else if (error->code == G_IO_ERROR_CANCELLED) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1700 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1701 | } else { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1702 | g_prefix_error(&error, "%s", |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1703 | _("Lost connection with server: ")); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1704 | purple_connection_take_error(pd->gc, error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1705 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1706 | pd->inpa = 0; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1707 | pd->input = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1708 | g_clear_object(&pd->output); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1709 | g_clear_object(&pd->stream); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1710 | return G_SOURCE_REMOVE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1711 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1712 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1713 | mwSession_recv(pd->session, buf, len); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1714 | } while (len > 0); |
| 10977 | 1715 | |
| 1716 | /* normal operation ends here */ | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1717 | return G_SOURCE_CONTINUE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1718 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1719 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1720 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1721 | /* Callback passed to g_socket_client_connect_to_host_async when an account is |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1722 | * logged in, and if the session logging in receives a redirect message */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1723 | static void |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1724 | connect_cb(GObject *source_object, GAsyncResult *result, gpointer data) |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1725 | { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1726 | GSocketClient *client = G_SOCKET_CLIENT(source_object); |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1727 | struct mwPurpleProtocolData *pd = data; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1728 | GSocketConnection *sockconn = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1729 | GSource *source = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1730 | GError *error = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1731 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1732 | sockconn = g_socket_client_connect_to_host_finish(client, result, &error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1733 | if (sockconn == NULL) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1734 | if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1735 | /* connection was cancelled */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1736 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1737 | } else if (pd->stream) { |
| 10977 | 1738 | /* this is a redirect connect, force login on existing socket */ |
| 1739 | mwSession_forceLogin(pd->session); | |
| 1740 | ||
| 1741 | } else { | |
| 1742 | /* this is a regular connect, error out */ | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1743 | purple_connection_take_error(pd->gc, error); |
| 10977 | 1744 | } |
| 1745 | ||
| 1746 | return; | |
| 1747 | } | |
| 1748 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1749 | if (pd->stream) { |
| 10977 | 1750 | /* stop any existing login attempt */ |
| 1751 | mwSession_stop(pd->session, ERR_SUCCESS); | |
| 1752 | } | |
| 1753 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1754 | pd->stream = G_IO_STREAM(sockconn); |
|
40811
44c107f92a65
Always ref result of g_io_stream_get_{input,output}_stream.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40800
diff
changeset
|
1755 | pd->input = g_object_ref(g_io_stream_get_input_stream(pd->stream)); |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1756 | pd->output = purple_queued_output_stream_new( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1757 | g_io_stream_get_output_stream(pd->stream)); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1758 | source = g_pollable_input_stream_create_source( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1759 | G_POLLABLE_INPUT_STREAM(pd->input), pd->cancellable); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1760 | g_source_set_callback(source, (GSourceFunc)read_cb, pd, NULL); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1761 | pd->inpa = g_source_attach(source, NULL); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1762 | g_source_unref(source); |
| 10977 | 1763 | |
| 1764 | mwSession_start(pd->session); | |
| 1765 | } | |
| 1766 | ||
| 1767 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1768 | static void mw_session_announce(struct mwSession *s, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1769 | struct mwLoginInfo *from, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1770 | gboolean may_reply, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1771 | const char *text) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1772 | struct mwPurpleProtocolData *pd; |
| 15884 | 1773 | PurpleAccount *acct; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1774 | PurpleIMConversation *im; |
| 15884 | 1775 | PurpleBuddy *buddy; |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1776 | char *who = from->user_id; |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1777 | char *msg, *msg2; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1778 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1779 | pd = mwSession_getClientData(s); |
| 15884 | 1780 | 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
|
1781 | 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
|
1782 | if(! im) im = purple_im_conversation_new(acct, who); |
| 15884 | 1783 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
1784 | buddy = purple_blist_find_buddy(acct, who); |
| 15884 | 1785 | 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
|
1786 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1787 | who = g_strdup_printf(_("Announcement from %s"), who); |
| 15884 | 1788 | msg = purple_markup_linkify(text); |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1789 | if (msg && msg[0]) |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1790 | 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
|
1791 | else |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1792 | msg2 = g_strdup(who); |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1793 | |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1794 | 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
|
1795 | g_free(who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1796 | g_free(msg); |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1797 | g_free(msg2); |
| 10977 | 1798 | } |
| 1799 | ||
| 1800 | ||
| 1801 | static struct mwSessionHandler mw_session_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1802 | mw_session_io_write, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1803 | mw_session_io_close, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1804 | mw_session_clear, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1805 | mw_session_stateChange, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1806 | mw_session_setPrivacyInfo, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1807 | mw_session_setUserStatus, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1808 | mw_session_admin, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1809 | mw_session_announce, |
| 10977 | 1810 | }; |
| 1811 | ||
| 1812 | ||
| 1813 | static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
| 1814 | struct mwAwareAttribute *attrib) { | |
| 1815 | ||
| 1816 | ; /** @todo handle server attributes. There may be some stuff we | |
| 1817 | actually want to look for, but I'm not aware of anything right | |
| 1818 | now.*/ | |
| 1819 | } | |
| 1820 | ||
| 1821 | ||
| 1822 | static void mw_aware_clear(struct mwServiceAware *srvc) { | |
| 1823 | ; /* nothing for now */ | |
| 1824 | } | |
| 1825 | ||
| 1826 | ||
| 1827 | static struct mwAwareHandler mw_aware_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1828 | mw_aware_on_attrib, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1829 | mw_aware_clear, |
| 10977 | 1830 | }; |
| 1831 | ||
| 1832 | ||
| 1833 | static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
| 1834 | struct mwServiceAware *srvc; | |
| 1835 | srvc = mwServiceAware_new(s, &mw_aware_handler); | |
| 1836 | return srvc; | |
| 1837 | }; | |
| 1838 | ||
| 1839 | ||
| 1840 | static void mw_conf_invited(struct mwConference *conf, | |
| 1841 | struct mwLoginInfo *inviter, | |
| 1842 | const char *invitation) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1843 | |
| 10977 | 1844 | struct mwServiceConference *srvc; |
| 1845 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1846 | struct mwPurpleProtocolData *pd; |
| 15884 | 1847 | PurpleConnection *gc; |
| 10977 | 1848 | |
| 1849 | char *c_inviter, *c_name, *c_topic, *c_invitation; | |
| 1850 | GHashTable *ht; | |
| 1851 | ||
| 1852 | srvc = mwConference_getService(conf); | |
| 1853 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1854 | pd = mwSession_getClientData(session); | |
| 1855 | gc = pd->gc; | |
| 1856 | ||
| 1857 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1858 | ||
| 1859 | c_inviter = g_strdup(inviter->user_id); | |
| 1860 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
| 1861 | ||
| 1862 | c_name = g_strdup(mwConference_getName(conf)); | |
| 1863 | g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
| 1864 | ||
| 1865 | c_topic = g_strdup(mwConference_getTitle(conf)); | |
| 1866 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
| 1867 | ||
| 1868 | c_invitation = g_strdup(invitation); | |
| 1869 | g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
| 1870 | ||
| 1871 | DEBUG_INFO("received invitation from '%s' to join ('%s','%s'): '%s'\n", | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1872 | c_inviter, c_name, |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1873 | c_topic, c_invitation); |
| 10977 | 1874 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1875 | if(! c_topic) c_topic = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1876 | if(! c_invitation) c_invitation = "(no message)"; |
| 35501 | 1877 | purple_serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
| 10977 | 1878 | } |
| 1879 | ||
| 1880 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1881 | /* The following mess helps us relate a mwConference to a PurpleChatConversation |
| 10977 | 1882 | in the various forms by which either may be indicated */ |
| 1883 | ||
| 1884 | #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
| 1885 | #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
| 1886 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1887 | #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
|
1888 | #define ID_TO_CHAT(id) (purple_conversations_find_chat(id)) |
| 10977 | 1889 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1890 | #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
|
1891 | #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
| 10977 | 1892 | |
| 1893 | ||
| 1894 | static struct mwConference * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1895 | conf_find_by_id(struct mwPurpleProtocolData *pd, int id) { |
| 10977 | 1896 | |
| 1897 | struct mwServiceConference *srvc = pd->srvc_conf; | |
| 1898 | struct mwConference *conf = NULL; | |
| 1899 | GList *l, *ll; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1900 | |
| 10977 | 1901 | ll = mwServiceConference_getConferences(srvc); |
| 1902 | for(l = ll; l; l = l->next) { | |
| 1903 | 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
|
1904 | PurpleChatConversation *h = mwConference_getClientData(c); |
| 10977 | 1905 | |
| 1906 | if(CHAT_TO_ID(h) == id) { | |
| 1907 | conf = c; | |
| 1908 | break; | |
| 1909 | } | |
| 1910 | } | |
| 1911 | g_list_free(ll); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1912 | |
| 10977 | 1913 | return conf; |
| 1914 | } | |
| 1915 | ||
| 1916 | ||
| 1917 | static void mw_conf_opened(struct mwConference *conf, GList *members) { | |
| 1918 | struct mwServiceConference *srvc; | |
| 1919 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1920 | struct mwPurpleProtocolData *pd; |
| 15884 | 1921 | PurpleConnection *gc; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1922 | PurpleChatConversation *g_conf; |
| 10977 | 1923 | |
| 1924 | const char *n = mwConference_getName(conf); | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1925 | const char *t = mwConference_getTitle(conf); |
| 10977 | 1926 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1927 | DEBUG_INFO("conf %s opened, %u initial members\n", n, g_list_length(members)); |
| 10977 | 1928 | |
| 1929 | srvc = mwConference_getService(conf); | |
| 1930 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1931 | pd = mwSession_getClientData(session); | |
| 1932 | gc = pd->gc; | |
| 1933 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1934 | if(! t) t = "(no title)"; |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
1935 | g_conf = purple_serv_got_joined_chat(gc, CONF_TO_ID(conf), t); |
| 10977 | 1936 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1937 | mwConference_setClientData(conf, g_conf, NULL); |
| 10977 | 1938 | |
| 1939 | for(; members; members = members->next) { | |
| 1940 | 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
|
1941 | 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
|
1942 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
| 10977 | 1943 | } |
| 1944 | } | |
| 1945 | ||
| 1946 | ||
| 1947 | static void mw_conf_closed(struct mwConference *conf, guint32 reason) { | |
| 1948 | struct mwServiceConference *srvc; | |
| 1949 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1950 | struct mwPurpleProtocolData *pd; |
| 15884 | 1951 | PurpleConnection *gc; |
| 10977 | 1952 | |
| 1953 | const char *n = mwConference_getName(conf); | |
| 1954 | char *msg = mwError(reason); | |
| 1955 | ||
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1956 | DEBUG_INFO("conf %s closed, 0x%08x\n", n, reason); |
| 10977 | 1957 | |
| 1958 | srvc = mwConference_getService(conf); | |
| 1959 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1960 | pd = mwSession_getClientData(session); | |
| 1961 | gc = pd->gc; | |
| 1962 | ||
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
1963 | purple_serv_got_chat_left(gc, CONF_TO_ID(conf)); |
| 10977 | 1964 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1965 | 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
|
1966 | purple_request_cpar_from_connection(gc)); |
| 10977 | 1967 | g_free(msg); |
| 1968 | } | |
| 1969 | ||
| 1970 | ||
| 1971 | static void mw_conf_peer_joined(struct mwConference *conf, | |
| 1972 | struct mwLoginInfo *peer) { | |
| 1973 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1974 | PurpleChatConversation *g_conf; |
| 10977 | 1975 | |
| 1976 | const char *n = mwConference_getName(conf); | |
| 1977 | ||
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1978 | DEBUG_INFO("%s joined conf %s\n", peer->user_id, n); |
| 10977 | 1979 | |
| 1980 | g_conf = mwConference_getClientData(conf); | |
| 1981 | g_return_if_fail(g_conf != NULL); | |
| 1982 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1983 | 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
|
1984 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
| 10977 | 1985 | } |
| 1986 | ||
| 1987 | ||
| 1988 | static void mw_conf_peer_parted(struct mwConference *conf, | |
| 1989 | struct mwLoginInfo *peer) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1990 | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1991 | PurpleChatConversation *g_conf; |
| 10977 | 1992 | |
| 1993 | const char *n = mwConference_getName(conf); | |
| 1994 | ||
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1995 | DEBUG_INFO("%s left conf %s\n", peer->user_id, n); |
| 10977 | 1996 | |
| 1997 | g_conf = mwConference_getClientData(conf); | |
| 1998 | g_return_if_fail(g_conf != NULL); | |
| 1999 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2000 | purple_chat_conversation_remove_user(g_conf, peer->user_id, NULL); |
| 10977 | 2001 | } |
| 2002 | ||
| 2003 | ||
| 2004 | static void mw_conf_text(struct mwConference *conf, | |
| 2005 | struct mwLoginInfo *who, const char *text) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2006 | |
| 10977 | 2007 | struct mwServiceConference *srvc; |
| 2008 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2009 | struct mwPurpleProtocolData *pd; |
| 15884 | 2010 | PurpleConnection *gc; |
| 10977 | 2011 | char *esc; |
| 2012 | ||
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2013 | if(! text) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2014 | |
| 10977 | 2015 | srvc = mwConference_getService(conf); |
| 2016 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2017 | pd = mwSession_getClientData(session); | |
| 2018 | gc = pd->gc; | |
| 2019 | ||
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2020 | esc = g_markup_escape_text(text, -1); |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
2021 | purple_serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, PURPLE_MESSAGE_RECV, esc, time(NULL)); |
| 10977 | 2022 | g_free(esc); |
| 2023 | } | |
| 2024 | ||
| 2025 | ||
| 2026 | static void mw_conf_typing(struct mwConference *conf, | |
| 2027 | struct mwLoginInfo *who, gboolean typing) { | |
| 2028 | ||
| 15884 | 2029 | /* purple really has no good way to expose this to the user. */ |
| 10977 | 2030 | |
| 2031 | const char *n = mwConference_getName(conf); | |
| 2032 | const char *w = who->user_id; | |
| 2033 | ||
| 2034 | if(typing) { | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2035 | DEBUG_INFO("%s in conf %s: <typing>\n", w, n); |
| 10977 | 2036 | |
| 2037 | } else { | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2038 | DEBUG_INFO("%s in conf %s: <stopped typing>\n", w, n); |
| 10977 | 2039 | } |
| 2040 | } | |
| 2041 | ||
| 2042 | ||
| 2043 | static void mw_conf_clear(struct mwServiceConference *srvc) { | |
| 2044 | ; | |
| 2045 | } | |
| 2046 | ||
| 2047 | ||
| 2048 | static struct mwConferenceHandler mw_conference_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2049 | mw_conf_invited, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2050 | mw_conf_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2051 | mw_conf_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2052 | mw_conf_peer_joined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2053 | mw_conf_peer_parted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2054 | mw_conf_text, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2055 | mw_conf_typing, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2056 | mw_conf_clear, |
| 10977 | 2057 | }; |
| 2058 | ||
| 2059 | ||
| 2060 | static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) { | |
| 2061 | struct mwServiceConference *srvc; | |
| 2062 | srvc = mwServiceConference_new(s, &mw_conference_handler); | |
| 2063 | return srvc; | |
| 2064 | } | |
| 2065 | ||
| 2066 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2067 | /** size of an outgoing file transfer chunk */ |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2068 | #define MW_FT_LEN (BUF_LONG * 2) |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2069 | |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2070 | #define MW_TYPE_XFER (mw_xfer_get_type()) |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2071 | G_DECLARE_FINAL_TYPE(mwXfer, mw_xfer, MW, XFER, PurpleXfer) |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2072 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2073 | struct _mwXfer { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2074 | PurpleXfer parent; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2075 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2076 | struct mwFileTransfer *ft; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2077 | }; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2078 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2079 | G_DEFINE_DYNAMIC_TYPE(mwXfer, mw_xfer, PURPLE_TYPE_XFER); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2080 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2081 | |
| 15884 | 2082 | static void ft_incoming_cancel(PurpleXfer *xfer) { |
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29304
diff
changeset
|
2083 | /* incoming transfer rejected or cancelled in-progress */ |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2084 | mwXfer *mw_xfer = MW_XFER(xfer); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2085 | if(mw_xfer->ft) mwFileTransfer_reject(mw_xfer->ft); |
| 10977 | 2086 | } |
| 2087 | ||
| 2088 | ||
| 15884 | 2089 | static void ft_incoming_init(PurpleXfer *xfer) { |
| 10977 | 2090 | /* incoming transfer accepted */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2091 | |
| 10977 | 2092 | /* - accept the mwFileTransfer |
| 2093 | - open/create the local FILE "wb" | |
| 2094 | - stick the FILE's fp in xfer->dest_fp | |
| 2095 | */ | |
| 2096 | ||
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2097 | mwXfer *mw_xfer = MW_XFER(xfer); |
| 10977 | 2098 | |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2099 | purple_xfer_start(xfer, -1, NULL, 0); |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2100 | mwFileTransfer_accept(mw_xfer->ft); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2101 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2102 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2103 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2104 | static void ft_outgoing_init(PurpleXfer *xfer) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2105 | PurpleAccount *acct; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2106 | PurpleConnection *gc; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2107 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2108 | struct mwPurpleProtocolData *pd; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2109 | struct mwServiceFileTransfer *srvc; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2110 | struct mwFileTransfer *ft; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2111 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2112 | const char *filename; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2113 | gsize filesize; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2114 | FILE *fp; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2115 | char *remote_user = NULL; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2116 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2117 | struct mwIdBlock idb = { NULL, NULL }; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2118 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2119 | DEBUG_INFO("ft_outgoing_init\n"); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2120 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2121 | acct = purple_xfer_get_account(xfer); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2122 | gc = purple_account_get_connection(acct); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2123 | pd = purple_connection_get_protocol_data(gc); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2124 | srvc = pd->srvc_ft; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2125 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2126 | remote_user = g_strdup(purple_xfer_get_remote_user(xfer)); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2127 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2128 | filename = purple_xfer_get_local_filename(xfer); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2129 | filesize = purple_xfer_get_size(xfer); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2130 | idb.user = remote_user; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2131 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2132 | /* test that we can actually send the file */ |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2133 | fp = g_fopen(filename, "rb"); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2134 | if(! fp) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2135 | char *msg = g_strdup_printf(_("Error reading file %s: \n%s\n"), |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2136 | filename, g_strerror(errno)); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2137 | purple_xfer_error(purple_xfer_get_xfer_type(xfer), acct, purple_xfer_get_remote_user(xfer), msg); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2138 | g_free(msg); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2139 | g_free(remote_user); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2140 | return; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2141 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2142 | fclose(fp); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2143 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2144 | { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2145 | char *tmp = strrchr(filename, G_DIR_SEPARATOR); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2146 | if(tmp++) filename = tmp; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2147 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2148 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2149 | ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2150 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2151 | g_object_ref(xfer); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2152 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) g_object_unref); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2153 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2154 | mwFileTransfer_offer(ft); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2155 | g_free(remote_user); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2156 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2157 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2158 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2159 | static void ft_init(PurpleXfer *xfer) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2160 | switch(purple_xfer_get_xfer_type(xfer)) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2161 | case PURPLE_XFER_TYPE_SEND: |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2162 | ft_outgoing_init(xfer); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2163 | break; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2164 | case PURPLE_XFER_TYPE_RECEIVE: |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2165 | ft_incoming_init(xfer); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2166 | break; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2167 | case PURPLE_XFER_TYPE_UNKNOWN: |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2168 | default: |
|
39670
8d95b195ce69
Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents:
39669
diff
changeset
|
2169 | g_return_if_reached(); |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2170 | break; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2171 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2172 | } |
| 10977 | 2173 | |
| 2174 | static void mw_ft_offered(struct mwFileTransfer *ft) { | |
| 2175 | /* | |
| 15884 | 2176 | - create a purple ft object |
| 10977 | 2177 | - offer it |
| 2178 | */ | |
| 2179 | ||
| 2180 | struct mwServiceFileTransfer *srvc; | |
| 2181 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2182 | struct mwPurpleProtocolData *pd; |
| 15884 | 2183 | PurpleConnection *gc; |
| 2184 | PurpleAccount *acct; | |
| 10977 | 2185 | const char *who; |
| 15884 | 2186 | PurpleXfer *xfer; |
| 10977 | 2187 | |
| 2188 | /* @todo add some safety checks */ | |
| 2189 | srvc = mwFileTransfer_getService(ft); | |
| 2190 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2191 | pd = mwSession_getClientData(session); | |
| 2192 | gc = pd->gc; | |
| 15884 | 2193 | acct = purple_connection_get_account(gc); |
| 10977 | 2194 | |
| 2195 | who = mwFileTransfer_getUser(ft)->user; | |
| 2196 | ||
| 2197 | DEBUG_INFO("file transfer %p offered\n", ft); | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2198 | DEBUG_INFO(" from: %s\n", who); |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2199 | DEBUG_INFO(" file: %s\n", mwFileTransfer_getFileName(ft)); |
| 10977 | 2200 | DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft)); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2201 | DEBUG_INFO(" text: %s\n", mwFileTransfer_getMessage(ft)); |
| 10977 | 2202 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34920
diff
changeset
|
2203 | xfer = purple_xfer_new(acct, PURPLE_XFER_TYPE_RECEIVE, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2204 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2205 | { |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
2206 | g_object_ref(xfer); |
|
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
2207 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) g_object_unref); |
| 15884 | 2208 | |
| 2209 | purple_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); | |
| 2210 | purple_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); | |
| 2211 | purple_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); | |
| 2212 | ||
| 2213 | purple_xfer_request(xfer); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2214 | } |
| 10977 | 2215 | } |
| 2216 | ||
| 2217 | ||
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2218 | static void ft_send(struct mwFileTransfer *ft) { |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2219 | 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
|
2220 | struct mwOpaque o = { MW_FT_LEN, buf }; |
| 10977 | 2221 | guint32 rem; |
| 15884 | 2222 | PurpleXfer *xfer; |
| 10977 | 2223 | |
| 2224 | xfer = mwFileTransfer_getClientData(ft); | |
| 2225 | ||
| 2226 | rem = mwFileTransfer_getRemaining(ft); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2227 | if(rem < MW_FT_LEN) o.len = rem; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2228 | |
| 36043 | 2229 | if(purple_xfer_read_file(xfer, buf, (size_t) o.len) == (gssize)o.len) { |
| 10977 | 2230 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2231 | /* calculate progress and display it */ |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2232 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + o.len); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2233 | |
| 10977 | 2234 | mwFileTransfer_send(ft, &o); |
| 2235 | ||
| 2236 | } else { | |
| 2237 | int err = errno; | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2238 | DEBUG_WARN("problem reading from file %s: %s\n", |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2239 | mwFileTransfer_getFileName(ft), g_strerror(err)); |
| 10977 | 2240 | |
| 2241 | mwFileTransfer_cancel(ft); | |
| 2242 | } | |
| 2243 | } | |
| 2244 | ||
| 2245 | ||
| 2246 | static void mw_ft_opened(struct mwFileTransfer *ft) { | |
| 2247 | /* | |
| 15884 | 2248 | - get purple ft from client data in ft |
| 10977 | 2249 | - set the state to active |
| 2250 | */ | |
| 2251 | ||
| 15884 | 2252 | PurpleXfer *xfer; |
| 10977 | 2253 | |
| 2254 | xfer = mwFileTransfer_getClientData(ft); | |
| 2255 | ||
| 2256 | if(! xfer) { | |
| 2257 | mwFileTransfer_cancel(ft); | |
| 2258 | mwFileTransfer_free(ft); | |
| 2259 | g_return_if_reached(); | |
| 2260 | } | |
| 2261 | ||
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34920
diff
changeset
|
2262 | 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
|
2263 | 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
|
2264 | ft_send(ft); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2265 | } |
| 10977 | 2266 | } |
| 2267 | ||
| 2268 | ||
| 2269 | static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
| 2270 | /* | |
| 15884 | 2271 | - get purple ft from client data in ft |
| 10977 | 2272 | - indicate rejection/cancelation/completion |
| 2273 | - free the file transfer itself | |
| 2274 | */ | |
| 2275 | ||
| 15884 | 2276 | PurpleXfer *xfer; |
| 10977 | 2277 | |
| 2278 | xfer = mwFileTransfer_getClientData(ft); | |
| 2279 | if(xfer) { | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2280 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2281 | purple_xfer_set_completed(xfer, TRUE); |
| 2282 | purple_xfer_end(xfer); | |
| 10977 | 2283 | |
| 2284 | } else if(mwFileTransfer_isCancelLocal(ft)) { | |
| 15884 | 2285 | /* calling purple_xfer_cancel_local is redundant, since that's |
| 10977 | 2286 | probably what triggered this function to be called */ |
| 2287 | ; | |
| 2288 | ||
| 2289 | } else if(mwFileTransfer_isCancelRemote(ft)) { | |
| 2290 | /* steal the reference for the xfer */ | |
| 2291 | mwFileTransfer_setClientData(ft, NULL, NULL); | |
| 15884 | 2292 | purple_xfer_cancel_remote(xfer); |
| 10977 | 2293 | |
| 2294 | /* 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
|
2295 | g_object_unref(xfer); |
| 10977 | 2296 | return; |
| 2297 | } | |
| 2298 | } | |
| 2299 | ||
| 2300 | mwFileTransfer_free(ft); | |
| 2301 | } | |
| 2302 | ||
| 2303 | ||
| 2304 | static void mw_ft_recv(struct mwFileTransfer *ft, | |
| 2305 | struct mwOpaque *data) { | |
| 2306 | /* | |
| 15884 | 2307 | - get purple ft from client data in ft |
| 10977 | 2308 | - update transfered percentage |
| 15884 | 2309 | - if done, destroy the ft, disassociate from purple ft |
| 10977 | 2310 | */ |
| 2311 | ||
| 15884 | 2312 | PurpleXfer *xfer; |
| 10977 | 2313 | |
| 2314 | xfer = mwFileTransfer_getClientData(ft); | |
| 2315 | g_return_if_fail(xfer != NULL); | |
| 2316 | ||
| 2317 | /* 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
|
2318 | 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
|
2319 | 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
|
2320 | 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
|
2321 | return; |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2322 | } |
| 10977 | 2323 | |
| 2324 | /* update the progress */ | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2325 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + data->len); |
| 10977 | 2326 | |
| 2327 | /* let the other side know we got it, and to send some more */ | |
| 2328 | mwFileTransfer_ack(ft); | |
| 2329 | } | |
| 2330 | ||
| 2331 | ||
| 2332 | static void mw_ft_ack(struct mwFileTransfer *ft) { | |
| 15884 | 2333 | PurpleXfer *xfer; |
| 10977 | 2334 | |
| 2335 | xfer = mwFileTransfer_getClientData(ft); | |
| 2336 | g_return_if_fail(xfer != NULL); | |
|
32705
9d97ac4c2c22
Sametime: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents:
32698
diff
changeset
|
2337 | g_return_if_fail(purple_xfer_get_watcher(xfer) == 0); |
| 10977 | 2338 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2339 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2340 | purple_xfer_set_completed(xfer, TRUE); |
| 2341 | purple_xfer_end(xfer); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2342 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2343 | } else if(mwFileTransfer_isOpen(ft)) { |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2344 | ft_send(ft); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2345 | } |
| 10977 | 2346 | } |
| 2347 | ||
| 2348 | ||
| 2349 | static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
| 2350 | ; | |
| 2351 | } | |
| 2352 | ||
| 2353 | ||
| 2354 | static struct mwFileTransferHandler mw_ft_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2355 | mw_ft_offered, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2356 | mw_ft_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2357 | mw_ft_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2358 | mw_ft_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2359 | mw_ft_ack, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2360 | mw_ft_clear, |
| 10977 | 2361 | }; |
| 2362 | ||
| 2363 | ||
| 2364 | static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
| 2365 | struct mwServiceFileTransfer *srvc; | |
| 2366 | GHashTable *ft_map; | |
| 2367 | ||
| 2368 | ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 2369 | ||
| 2370 | srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
| 2371 | mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
| 2372 | (GDestroyNotify) g_hash_table_destroy); | |
| 2373 | ||
| 2374 | return srvc; | |
| 2375 | } | |
| 2376 | ||
| 2377 | ||
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2378 | static void ft_outgoing_cancel(PurpleXfer *xfer) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2379 | mwXfer *mw_xfer = MW_XFER(xfer); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2380 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2381 | DEBUG_INFO("ft_outgoing_cancel called\n"); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2382 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2383 | if(mw_xfer->ft) mwFileTransfer_cancel(mw_xfer->ft); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2384 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2385 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2386 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2387 | static void |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2388 | mw_xfer_init(mwXfer *xfer) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2389 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2390 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2391 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2392 | static void |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2393 | mw_xfer_class_finalize(mwXferClass *klass) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2394 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2395 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2396 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2397 | static void |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2398 | mw_xfer_class_init(mwXferClass *klass) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2399 | PurpleXferClass *xfer_class = PURPLE_XFER_CLASS(klass); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2400 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2401 | xfer_class->init = ft_init; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2402 | xfer_class->cancel_send = ft_outgoing_cancel; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2403 | xfer_class->cancel_recv = ft_incoming_cancel; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2404 | xfer_class->request_denied = ft_incoming_cancel; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2405 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2406 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2407 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2408 | static PurpleXfer *mw_protocol_new_xfer(PurpleProtocolXfer *prplxfer, PurpleConnection *gc, const char *who) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2409 | PurpleAccount *acct; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2410 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2411 | acct = purple_connection_get_account(gc); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2412 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2413 | return g_object_new( |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2414 | MW_TYPE_XFER, |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2415 | "account", acct, |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2416 | "type", PURPLE_XFER_TYPE_SEND, |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2417 | "remote-user", who, |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2418 | NULL |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2419 | ); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2420 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2421 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2422 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2423 | |
| 10977 | 2424 | static void convo_data_free(struct convo_data *cd) { |
| 2425 | GList *l; | |
| 2426 | ||
| 2427 | /* clean the queue */ | |
| 2428 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2429 | struct convo_msg *m = l->data; | |
| 2430 | if(m->clear) m->clear(m->data); | |
| 2431 | g_free(m); | |
| 2432 | } | |
| 2433 | ||
| 2434 | g_free(cd); | |
| 2435 | } | |
| 2436 | ||
| 2437 | ||
| 2438 | /** allocates a convo_data structure and associates it with the | |
| 2439 | conversation in the client data slot */ | |
| 2440 | static void convo_data_new(struct mwConversation *conv) { | |
| 2441 | struct convo_data *cd; | |
| 2442 | ||
| 2443 | g_return_if_fail(conv != NULL); | |
| 2444 | ||
| 2445 | if(mwConversation_getClientData(conv)) | |
| 2446 | return; | |
| 2447 | ||
| 2448 | cd = g_new0(struct convo_data, 1); | |
| 2449 | cd->conv = conv; | |
| 2450 | ||
| 2451 | mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
| 2452 | } | |
| 2453 | ||
| 2454 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2455 | static PurpleIMConversation *convo_get_im(struct mwConversation *conv) { |
| 10977 | 2456 | struct mwServiceIm *srvc; |
| 2457 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2458 | struct mwPurpleProtocolData *pd; |
| 15884 | 2459 | PurpleConnection *gc; |
| 2460 | PurpleAccount *acct; | |
| 10977 | 2461 | |
| 2462 | struct mwIdBlock *idb; | |
| 2463 | ||
| 2464 | srvc = mwConversation_getService(conv); | |
| 2465 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2466 | pd = mwSession_getClientData(session); | |
| 2467 | gc = pd->gc; | |
| 15884 | 2468 | acct = purple_connection_get_account(gc); |
| 10977 | 2469 | |
| 2470 | idb = mwConversation_getTarget(conv); | |
| 2471 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2472 | return purple_conversations_find_im_with_account(idb->user, acct); |
| 10977 | 2473 | } |
| 2474 | ||
| 2475 | ||
| 2476 | static void convo_queue(struct mwConversation *conv, | |
| 2477 | enum mwImSendType type, gconstpointer data) { | |
| 2478 | ||
| 2479 | struct convo_data *cd; | |
| 2480 | struct convo_msg *m; | |
| 2481 | ||
| 2482 | convo_data_new(conv); | |
| 2483 | cd = mwConversation_getClientData(conv); | |
| 2484 | ||
| 2485 | m = g_new0(struct convo_msg, 1); | |
| 2486 | m->type = type; | |
| 2487 | ||
| 2488 | switch(type) { | |
| 2489 | case mwImSend_PLAIN: | |
| 2490 | m->data = g_strdup(data); | |
| 2491 | m->clear = g_free; | |
| 2492 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2493 | |
| 10977 | 2494 | case mwImSend_TYPING: |
| 2495 | default: | |
| 2496 | m->data = (gpointer) data; | |
| 2497 | m->clear = NULL; | |
| 2498 | } | |
| 2499 | ||
| 2500 | cd->queue = g_list_append(cd->queue, m); | |
| 2501 | } | |
| 2502 | ||
| 2503 | ||
| 2504 | /* Does what it takes to get an error displayed for a conversation */ | |
| 2505 | 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
|
2506 | PurpleIMConversation *im; |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2507 | PurpleConnection *pc; |
| 10977 | 2508 | char *tmp, *text; |
| 2509 | struct mwIdBlock *idb; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2510 | |
| 10977 | 2511 | idb = mwConversation_getTarget(conv); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2512 | |
| 10977 | 2513 | tmp = mwError(err); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2514 | text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2515 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2516 | 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
|
2517 | 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
|
2518 | purple_conversation_get_account(PURPLE_CONVERSATION(im)), text)) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2519 | |
| 10977 | 2520 | g_free(text); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2521 | text = g_strdup_printf(_("Unable to send message to %s:"), |
| 10977 | 2522 | (idb->user)? idb->user: "(unknown)"); |
| 34955 | 2523 | pc = purple_account_get_connection(purple_conversation_get_account( |
| 2524 | PURPLE_CONVERSATION(im))); | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2525 | purple_notify_error(pc, NULL, text, tmp, purple_request_cpar_from_connection(pc)); |
| 10977 | 2526 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2527 | |
| 10977 | 2528 | g_free(tmp); |
| 2529 | g_free(text); | |
| 2530 | } | |
| 2531 | ||
| 2532 | ||
| 2533 | static void convo_queue_send(struct mwConversation *conv) { | |
| 2534 | struct convo_data *cd; | |
| 2535 | GList *l; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2536 | |
| 10977 | 2537 | cd = mwConversation_getClientData(conv); |
| 2538 | ||
| 2539 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2540 | struct convo_msg *m = l->data; | |
| 2541 | ||
| 2542 | mwConversation_send(conv, m->type, m->data); | |
| 2543 | ||
| 2544 | if(m->clear) m->clear(m->data); | |
| 2545 | g_free(m); | |
| 2546 | } | |
| 2547 | ||
| 2548 | cd->queue = NULL; | |
| 2549 | } | |
| 2550 | ||
| 2551 | ||
| 15884 | 2552 | /** called when a mw conversation leaves a purple conversation to |
| 2553 | inform the purple conversation that it's unsafe to offer any *cool* | |
| 10977 | 2554 | features. */ |
| 2555 | 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
|
2556 | PurpleIMConversation *im; |
| 15884 | 2557 | PurpleConnection *gc; |
| 10977 | 2558 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2559 | 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
|
2560 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2561 | |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2562 | gc = purple_conversation_get_connection(PURPLE_CONVERSATION(im)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2563 | if(! gc) return; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2564 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2565 | 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
|
2566 | purple_connection_get_flags(gc)); |
| 15884 | 2567 | } |
| 2568 | ||
| 2569 | ||
| 2570 | /** called when a mw conversation and purple conversation come together, | |
| 2571 | to inform the purple conversation of what features to offer the | |
| 10977 | 2572 | user */ |
| 2573 | 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
|
2574 | PurpleIMConversation *im; |
| 15884 | 2575 | PurpleConnectionFlags feat; |
| 10977 | 2576 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2577 | 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
|
2578 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2579 | |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2580 | feat = purple_conversation_get_features(PURPLE_CONVERSATION(im)); |
| 10977 | 2581 | |
| 2582 | if(mwConversation_isOpen(conv)) { | |
| 2583 | if(mwConversation_supports(conv, mwImSend_HTML)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2584 | feat |= PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2585 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2586 | feat &= ~PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2587 | } |
| 2588 | ||
| 2589 | if(mwConversation_supports(conv, mwImSend_MIME)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2590 | feat &= ~PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2591 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2592 | feat |= PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2593 | } |
| 2594 | ||
| 2595 | 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
|
2596 | purple_conversation_set_features(PURPLE_CONVERSATION(im), feat); |
| 10977 | 2597 | |
| 2598 | } else { | |
| 2599 | convo_nofeatures(conv); | |
| 2600 | } | |
| 2601 | } | |
| 2602 | ||
| 2603 | ||
| 2604 | static void mw_conversation_opened(struct mwConversation *conv) { | |
| 2605 | struct mwServiceIm *srvc; | |
| 2606 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2607 | struct mwPurpleProtocolData *pd; |
| 15884 | 2608 | PurpleConnection *gc; |
| 2609 | PurpleAccount *acct; | |
| 10977 | 2610 | |
| 2611 | struct convo_dat *cd; | |
| 2612 | ||
| 2613 | srvc = mwConversation_getService(conv); | |
| 2614 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2615 | pd = mwSession_getClientData(session); | |
| 2616 | gc = pd->gc; | |
| 15884 | 2617 | acct = purple_connection_get_account(gc); |
| 10977 | 2618 | |
| 2619 | /* set up the queue */ | |
| 2620 | cd = mwConversation_getClientData(conv); | |
| 2621 | if(cd) { | |
| 2622 | convo_queue_send(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2623 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2624 | if(! convo_get_im(conv)) { |
| 10977 | 2625 | mwConversation_free(conv); |
| 2626 | return; | |
| 2627 | } | |
| 2628 | ||
| 2629 | } else { | |
| 2630 | convo_data_new(conv); | |
| 2631 | } | |
| 2632 | ||
| 2633 | { /* record the client key for the buddy */ | |
| 15884 | 2634 | PurpleBuddy *buddy; |
| 10977 | 2635 | struct mwLoginInfo *info; |
| 2636 | info = mwConversation_getTargetInfo(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2637 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
2638 | buddy = purple_blist_find_buddy(acct, info->user_id); |
| 10977 | 2639 | if(buddy) { |
| 15884 | 2640 | purple_blist_node_set_int((PurpleBlistNode *) buddy, |
| 10977 | 2641 | BUDDY_KEY_CLIENT, info->type); |
| 2642 | } | |
| 2643 | } | |
| 2644 | ||
| 2645 | convo_features(conv); | |
| 2646 | } | |
| 2647 | ||
| 2648 | ||
| 2649 | static void mw_conversation_closed(struct mwConversation *conv, | |
| 2650 | guint32 reason) { | |
| 2651 | ||
| 2652 | struct convo_data *cd; | |
| 2653 | ||
| 2654 | g_return_if_fail(conv != NULL); | |
| 2655 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2656 | /* 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
|
2657 | print an error message to the conversation */ |
| 10977 | 2658 | cd = mwConversation_getClientData(conv); |
| 2659 | if(reason && cd && cd->queue) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2660 | GList *l; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2661 | for(l = cd->queue; l; l = l->next) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2662 | struct convo_msg *m = l->data; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2663 | if(m->type != mwImSend_TYPING) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2664 | convo_error(conv, reason); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2665 | break; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2666 | } |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2667 | } |
| 10977 | 2668 | } |
| 2669 | ||
| 2670 | mwConversation_removeClientData(conv); | |
| 2671 | } | |
| 2672 | ||
| 2673 | ||
| 2674 | 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
|
2675 | struct mwPurpleProtocolData *pd, |
| 10977 | 2676 | const char *msg) { |
| 2677 | ||
| 2678 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2679 | char *txt, *esc; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2680 | const char *t; |
| 10977 | 2681 | |
| 2682 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2683 | |
| 15884 | 2684 | txt = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2685 | t = txt? txt: msg; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2686 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2687 | esc = g_markup_escape_text(t, -1); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2688 | 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
|
2689 | g_free(esc); |
| 10977 | 2690 | |
| 2691 | g_free(txt); | |
| 2692 | } | |
| 2693 | ||
| 2694 | ||
| 2695 | 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
|
2696 | struct mwPurpleProtocolData *pd, |
| 10977 | 2697 | gboolean typing) { |
| 2698 | ||
| 2699 | struct mwIdBlock *idb; | |
| 2700 | idb = mwConversation_getTarget(conv); | |
| 2701 | ||
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2702 | 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
|
2703 | typing? PURPLE_IM_TYPING: PURPLE_IM_NOT_TYPING); |
| 10977 | 2704 | } |
| 2705 | ||
| 2706 | ||
| 2707 | 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
|
2708 | struct mwPurpleProtocolData *pd, |
| 10977 | 2709 | const char *msg) { |
| 2710 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2711 | char *t1, *t2; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2712 | const char *t; |
| 10977 | 2713 | |
| 2714 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2715 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2716 | /* ensure we're receiving UTF8 */ |
| 15884 | 2717 | t1 = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2718 | t = t1? t1: msg; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2719 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2720 | /* convert entities to UTF8 so they'll log correctly */ |
| 15884 | 2721 | t2 = purple_utf8_ncr_decode(t); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2722 | t = t2? t2: t; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2723 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2724 | purple_serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
| 10977 | 2725 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2726 | g_free(t1); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2727 | g_free(t2); |
| 10977 | 2728 | } |
| 2729 | ||
| 2730 | ||
| 2731 | 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
|
2732 | struct mwPurpleProtocolData *pd, |
| 10977 | 2733 | const char *subj) { |
| 2734 | ||
| 2735 | /** @todo somehow indicate receipt of a conversation subject. It | |
| 2736 | would also be nice if we added a /topic command for the | |
| 2737 | protocol */ | |
| 2738 | ; | |
| 2739 | } | |
| 2740 | ||
| 2741 | ||
| 2742 | static void mw_conversation_recv(struct mwConversation *conv, | |
| 2743 | enum mwImSendType type, | |
| 2744 | gconstpointer msg) { | |
| 2745 | struct mwServiceIm *srvc; | |
| 2746 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2747 | struct mwPurpleProtocolData *pd; |
| 10977 | 2748 | |
| 2749 | srvc = mwConversation_getService(conv); | |
| 2750 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2751 | pd = mwSession_getClientData(session); | |
| 2752 | ||
| 2753 | switch(type) { | |
| 2754 | case mwImSend_PLAIN: | |
| 2755 | im_recv_text(conv, pd, msg); | |
| 2756 | break; | |
| 2757 | ||
| 2758 | case mwImSend_TYPING: | |
| 2759 | im_recv_typing(conv, pd, !! msg); | |
| 2760 | break; | |
| 2761 | ||
| 2762 | case mwImSend_HTML: | |
| 2763 | im_recv_html(conv, pd, msg); | |
| 2764 | break; | |
| 2765 | ||
| 2766 | case mwImSend_SUBJECT: | |
| 2767 | im_recv_subj(conv, pd, msg); | |
| 2768 | break; | |
| 2769 | ||
|
39523
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
2770 | case mwImSend_MIME: { |
|
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
2771 | gchar *parsed_message = im_mime_parse(msg); |
|
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
2772 | im_recv_html(conv, pd, parsed_message); |
|
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
2773 | g_free(parsed_message); |
| 10977 | 2774 | break; |
|
39523
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
2775 | } |
| 10977 | 2776 | |
| 2777 | default: | |
| 2778 | DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
| 2779 | ; /* erm... */ | |
| 2780 | } | |
| 2781 | } | |
| 2782 | ||
| 2783 | ||
| 2784 | static void mw_place_invite(struct mwConversation *conv, | |
| 2785 | const char *message, | |
| 2786 | const char *title, const char *name) { | |
| 2787 | struct mwServiceIm *srvc; | |
| 2788 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2789 | struct mwPurpleProtocolData *pd; |
| 10977 | 2790 | |
| 2791 | struct mwIdBlock *idb; | |
| 2792 | GHashTable *ht; | |
| 2793 | ||
| 2794 | srvc = mwConversation_getService(conv); | |
| 2795 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2796 | pd = mwSession_getClientData(session); | |
| 2797 | ||
| 2798 | idb = mwConversation_getTarget(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2799 | |
| 10977 | 2800 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 2801 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
| 2802 | g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
| 2803 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
| 2804 | 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
|
2805 | g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
| 10977 | 2806 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2807 | if(! title) title = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2808 | if(! message) message = "(no message)"; |
| 35501 | 2809 | 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
|
2810 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2811 | mwConversation_close(conv, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2812 | mwConversation_free(conv); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2813 | } |
| 10977 | 2814 | |
| 2815 | ||
| 2816 | static void mw_im_clear(struct mwServiceIm *srvc) { | |
| 2817 | ; | |
| 2818 | } | |
| 2819 | ||
| 2820 | ||
| 2821 | static struct mwImHandler mw_im_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2822 | mw_conversation_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2823 | mw_conversation_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2824 | mw_conversation_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2825 | mw_place_invite, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2826 | mw_im_clear, |
| 10977 | 2827 | }; |
| 2828 | ||
| 2829 | ||
| 2830 | static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
| 2831 | struct mwServiceIm *srvc; | |
| 2832 | srvc = mwServiceIm_new(s, &mw_im_handler); | |
| 2833 | mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
| 2834 | return srvc; | |
| 2835 | } | |
| 2836 | ||
| 2837 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2838 | /* 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
|
2839 | 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
|
2840 | the similar macros from the conference service above */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2841 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2842 | #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2843 | #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
|
2844 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2845 | #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
|
2846 | #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
|
2847 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2848 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2849 | static struct mwPlace * |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2850 | place_find_by_id(struct mwPurpleProtocolData *pd, int id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2851 | struct mwServicePlace *srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2852 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2853 | GList *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2854 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2855 | l = (GList *) mwServicePlace_getPlaces(srvc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2856 | for(; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2857 | 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
|
2858 | PurpleChatConversation *h = mwPlace_getClientData(p); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2859 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2860 | if(CHAT_TO_ID(h) == id) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2861 | place = p; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2862 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2863 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2864 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2865 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2866 | return place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2867 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2868 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2869 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2870 | static void mw_place_opened(struct mwPlace *place) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2871 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2872 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2873 | struct mwPurpleProtocolData *pd; |
| 15884 | 2874 | PurpleConnection *gc; |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2875 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2876 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2877 | GList *members, *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2878 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2879 | const char *n = mwPlace_getName(place); |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2880 | const char *t = mwPlace_getTitle(place); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2881 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2882 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2883 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2884 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2885 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2886 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2887 | members = mwPlace_getMembers(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2888 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2889 | DEBUG_INFO("place %s opened, %u initial members\n", |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2890 | n, g_list_length(members)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2891 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2892 | if(! t) t = "(no title)"; |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2893 | 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
|
2894 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2895 | mwPlace_setClientData(place, gconf, NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2896 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2897 | for(l = members; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2898 | 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
|
2899 | 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
|
2900 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2901 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2902 | g_list_free(members); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2903 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2904 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2905 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2906 | static void mw_place_closed(struct mwPlace *place, guint32 code) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2907 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2908 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2909 | struct mwPurpleProtocolData *pd; |
| 15884 | 2910 | PurpleConnection *gc; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2911 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2912 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2913 | char *msg = mwError(code); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2914 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2915 | DEBUG_INFO("place %s closed, 0x%08x\n", n, code); |
|
11943
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 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2918 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2919 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2920 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2921 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2922 | 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
|
2923 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2924 | 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
|
2925 | purple_request_cpar_from_connection(gc)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2926 | g_free(msg); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2927 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2928 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2929 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2930 | static void mw_place_peerJoined(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2931 | 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
|
2932 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2933 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2934 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2935 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2936 | DEBUG_INFO("%s joined place %s\n", peer->user, n); |
|
11943
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 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2939 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2940 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2941 | 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
|
2942 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2943 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2944 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2945 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2946 | static void mw_place_peerParted(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2947 | 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
|
2948 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2949 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2950 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2951 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2952 | DEBUG_INFO("%s left place %s\n", peer->user, n); |
|
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 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2955 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2956 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2957 | purple_chat_conversation_remove_user(gconf, peer->user, NULL); |
|
11943
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2960 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2961 | static void mw_place_peerSetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2962 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2963 | guint32 attr, struct mwOpaque *o) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2964 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2965 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2966 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2967 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2968 | static void mw_place_peerUnsetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2969 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2970 | guint32 attr) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2971 | ; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2972 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2973 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2974 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2975 | static void mw_place_message(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2976 | const struct mwIdBlock *who, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2977 | const char *msg) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2978 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2979 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2980 | struct mwPurpleProtocolData *pd; |
| 15884 | 2981 | PurpleConnection *gc; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2982 | char *esc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2983 | |
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2984 | if(! msg) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2985 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2986 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2987 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2988 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2989 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2990 | |
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2991 | esc = g_markup_escape_text(msg, -1); |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
2992 | 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
|
2993 | PURPLE_MESSAGE_RECV, esc, time(NULL)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2994 | g_free(esc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2995 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2996 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2997 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2998 | static void mw_place_clear(struct mwServicePlace *srvc) { |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3003 | static struct mwPlaceHandler mw_place_handler = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3004 | mw_place_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3005 | mw_place_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3006 | mw_place_peerJoined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3007 | mw_place_peerParted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3008 | mw_place_peerSetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3009 | mw_place_peerUnsetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3010 | mw_place_message, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3011 | mw_place_clear, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3012 | }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3013 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3014 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3015 | static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3016 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3017 | srvc = mwServicePlace_new(s, &mw_place_handler); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3018 | return srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3019 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3020 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3021 | |
| 10977 | 3022 | static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
| 3023 | struct mwServiceResolve *srvc; | |
| 3024 | srvc = mwServiceResolve_new(s); | |
| 3025 | return srvc; | |
| 3026 | } | |
| 3027 | ||
| 3028 | ||
| 3029 | static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
| 3030 | struct mwServiceStorage *srvc; | |
| 3031 | srvc = mwServiceStorage_new(s); | |
| 3032 | return srvc; | |
| 3033 | } | |
| 3034 | ||
| 3035 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3036 | /** 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
|
3037 | 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
|
3038 | struct mwPurpleProtocolData *pd; |
| 10977 | 3039 | |
| 3040 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3041 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3042 | pd = g_new0(struct mwPurpleProtocolData, 1); |
| 10977 | 3043 | pd->gc = gc; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3044 | pd->cancellable = g_cancellable_new(); |
| 10977 | 3045 | pd->session = mwSession_new(&mw_session_handler); |
| 3046 | pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
| 3047 | pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
| 3048 | pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
| 3049 | pd->srvc_im = mw_srvc_im_new(pd->session); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3050 | pd->srvc_place = mw_srvc_place_new(pd->session); |
| 10977 | 3051 | pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
| 3052 | pd->srvc_store = mw_srvc_store_new(pd->session); | |
| 3053 | pd->group_list_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 3054 | ||
| 3055 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
| 3056 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
| 3057 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
| 3058 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3059 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
| 10977 | 3060 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
| 3061 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
| 3062 | ||
| 3063 | 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
|
3064 | mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 10977 | 3065 | |
| 3066 | 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
|
3067 | purple_connection_set_protocol_data(gc, pd); |
| 10977 | 3068 | |
| 3069 | return pd; | |
| 3070 | } | |
| 3071 | ||
| 3072 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3073 | static void mwPurpleProtocolData_free(struct mwPurpleProtocolData *pd) { |
| 10977 | 3074 | g_return_if_fail(pd != NULL); |
| 3075 | ||
|
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
|
3076 | purple_connection_set_protocol_data(pd->gc, NULL); |
| 10977 | 3077 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3078 | mwSession_removeService(pd->session, mwService_AWARE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3079 | mwSession_removeService(pd->session, mwService_CONFERENCE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3080 | mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3081 | mwSession_removeService(pd->session, mwService_IM); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3082 | mwSession_removeService(pd->session, mwService_PLACE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3083 | mwSession_removeService(pd->session, mwService_RESOLVE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3084 | mwSession_removeService(pd->session, mwService_STORAGE); |
| 10977 | 3085 | |
| 3086 | mwService_free(MW_SERVICE(pd->srvc_aware)); | |
| 3087 | mwService_free(MW_SERVICE(pd->srvc_conf)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3088 | mwService_free(MW_SERVICE(pd->srvc_ft)); |
| 10977 | 3089 | mwService_free(MW_SERVICE(pd->srvc_im)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3090 | mwService_free(MW_SERVICE(pd->srvc_place)); |
| 10977 | 3091 | mwService_free(MW_SERVICE(pd->srvc_resolve)); |
| 3092 | mwService_free(MW_SERVICE(pd->srvc_store)); | |
| 3093 | ||
| 3094 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3095 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
| 10977 | 3096 | |
| 3097 | mwSession_free(pd->session); | |
| 3098 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3099 | g_clear_object(&pd->cancellable); |
| 10977 | 3100 | g_hash_table_destroy(pd->group_list_map); |
|
40811
44c107f92a65
Always ref result of g_io_stream_get_{input,output}_stream.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40800
diff
changeset
|
3101 | g_clear_object(&pd->input); |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3102 | g_clear_object(&pd->output); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3103 | g_clear_object(&pd->stream); |
| 10977 | 3104 | |
| 3105 | g_free(pd); | |
| 3106 | } | |
| 3107 | ||
| 3108 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3109 | static const char *mw_protocol_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
| 10977 | 3110 | /* my little green dude is a chopped up version of the aim running |
| 3111 | guy. First, cut off the head and store someplace safe. Then, | |
| 3112 | take the left-half side of the body and throw it away. Make a | |
| 3113 | copy of the remaining body, and flip it horizontally. Now attach | |
| 3114 | the two pieces into an X shape, and drop the head back on the | |
| 3115 | top, being careful to center it. Then, just change the color | |
| 3116 | saturation to bring the red down a bit, and voila! */ | |
| 3117 | ||
| 3118 | /* then, throw all of that away and use sodipodi to make a new | |
| 3119 | icon. You know, LIKE A REAL MAN. */ | |
| 3120 | ||
| 3121 | return "meanwhile"; | |
| 3122 | } | |
| 3123 | ||
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3124 | static GList * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3125 | mw_protocol_get_account_options(PurpleProtocol *protocol) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3126 | PurpleAccountOption *opt; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3127 | GList *opts = NULL; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3128 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3129 | /* port to connect to */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3130 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3131 | MW_PLUGIN_DEFAULT_PORT); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3132 | opts = g_list_append(opts, opt); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3133 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3134 | { /* copy the old force login setting from prefs if it's |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3135 | there. Don't delete the preference, since there may be more |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3136 | than one account that wants to check for it. */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3137 | gboolean b = FALSE; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3138 | const gchar *label = _("Force login (ignore server redirects)"); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3139 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3140 | if (purple_prefs_exists(MW_PROTOCOL_OPT_FORCE_LOGIN)) |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3141 | b = purple_prefs_get_bool(MW_PROTOCOL_OPT_FORCE_LOGIN); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3142 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3143 | opt = purple_account_option_bool_new(label, MW_KEY_FORCE, b); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3144 | opts = g_list_append(opts, opt); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3145 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3146 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3147 | /* pretend to be Sametime Connect */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3148 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3149 | MW_KEY_FAKE_IT, FALSE); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3150 | opts = g_list_append(opts, opt); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3151 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3152 | return opts; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3153 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3154 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3155 | static GList * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3156 | mw_protocol_get_user_splits(PurpleProtocol *protocol) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3157 | PurpleAccountUserSplit *split; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3158 | GList *splits = NULL; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3159 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3160 | /* set up account ID as user:server */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3161 | split = purple_account_user_split_new(_("Server"), |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3162 | MW_PLUGIN_DEFAULT_HOST, ':'); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3163 | splits = g_list_append(splits, split); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3164 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3165 | return splits; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3166 | } |
| 10977 | 3167 | |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3168 | static const char * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3169 | mw_protocol_list_emblem(PurpleProtocolClient *client, PurpleBuddy *b) { |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3170 | if(buddy_is_external(b)) { |
| 15524 | 3171 | return "external"; |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3172 | } |
| 15524 | 3173 | |
| 3174 | return NULL; | |
| 10977 | 3175 | } |
| 3176 | ||
| 3177 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3178 | static char * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3179 | mw_protocol_status_text(PurpleProtocolClient * client, PurpleBuddy *b) { |
| 15884 | 3180 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3181 | struct mwPurpleProtocolData *pd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3182 | 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
|
3183 | 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
|
3184 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3185 | 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
|
3186 | && (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
|
3187 | 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
|
3188 | |
|
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
|
3189 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3190 | } |
| 3191 | ||
| 3192 | ||
| 15884 | 3193 | static const char *status_text(PurpleBuddy *b) { |
| 3194 | PurplePresence *presence; | |
| 3195 | PurpleStatus *status; | |
| 3196 | ||
| 3197 | presence = purple_buddy_get_presence(b); | |
| 3198 | status = purple_presence_get_active_status(presence); | |
| 3199 | ||
| 3200 | return purple_status_get_name(status); | |
| 10977 | 3201 | } |
| 3202 | ||
| 3203 | ||
| 3204 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3205 | const char *who, guint32 feature) { | |
| 3206 | ||
| 3207 | const struct mwAwareAttribute *attr; | |
| 3208 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3209 | ||
| 3210 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3211 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3212 | } | |
| 3213 | ||
| 3214 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3215 | 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
|
3216 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3217 | const char **f = feat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3218 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3219 | if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3220 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3221 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3222 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3223 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3224 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3225 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3226 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3227 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3228 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3229 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3230 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3231 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3232 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3233 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3234 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3235 | /* jenni loves siege */ |
| 10977 | 3236 | } |
| 3237 | ||
| 3238 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3239 | static void |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3240 | mw_protocol_tooltip_text(PurpleProtocolClient *client, PurpleBuddy *b, |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3241 | PurpleNotifyUserInfo *user_info, gboolean full) |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3242 | { |
| 15884 | 3243 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3244 | struct mwPurpleProtocolData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3245 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3246 | |
|
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
|
3247 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3248 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3249 | char *tmp; |
| 10977 | 3250 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3251 | 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
|
3252 | && (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
|
3253 | 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
|
3254 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3255 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3256 | |
|
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
|
3257 | 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
|
3258 | 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
|
3259 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3260 | } 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
|
3261 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status); |
| 10977 | 3262 | } |
| 3263 | ||
|
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
|
3264 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3265 | 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
|
3266 | 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
|
3267 | 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
|
3268 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3269 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3270 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3271 | 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
|
3272 | 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
|
3273 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3274 | } |
| 10977 | 3275 | } |
| 3276 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3277 | 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
|
3278 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3279 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3280 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3281 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3282 | 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
|
3283 | 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
|
3284 | 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
|
3285 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3286 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3287 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3288 | 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
|
3289 | 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
|
3290 | 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
|
3291 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3292 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3293 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3294 | 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
|
3295 | 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
|
3296 | 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
|
3297 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3298 | types = g_list_append(types, type); |
|
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 | 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
|
3301 | 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
|
3302 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3303 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3304 | return types; |
| 10977 | 3305 | } |
| 3306 | ||
| 3307 | ||
| 15884 | 3308 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3309 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3310 | ; /* nothing to do */ |
| 10977 | 3311 | } |
| 3312 | ||
| 3313 | ||
| 15884 | 3314 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3315 | PurpleRequestFields *fields) { | |
| 3316 | PurpleAccount *acct; | |
| 3317 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3318 | struct mwPurpleProtocolData *pd; |
| 10977 | 3319 | struct mwServiceConference *srvc; |
| 3320 | ||
| 15884 | 3321 | PurpleRequestField *f; |
| 10977 | 3322 | |
| 3323 | const char *topic, *invite; | |
| 3324 | struct mwConference *conf; | |
| 3325 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3326 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3327 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3328 | 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
|
3329 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3330 | srvc = pd->srvc_conf; |
| 3331 | ||
| 15884 | 3332 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3333 | topic = purple_request_field_string_get_value(f); | |
| 3334 | ||
| 3335 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3336 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3337 | |
| 3338 | conf = mwConference_new(srvc, topic); | |
| 3339 | mwConference_open(conf); | |
| 3340 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3341 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3342 | mwConference_invite(conf, &idb, invite); |
| 3343 | } | |
| 3344 | ||
| 3345 | ||
| 15884 | 3346 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3347 | ||
| 3348 | PurpleRequestFields *fields; | |
| 3349 | PurpleRequestFieldGroup *g; | |
| 3350 | PurpleRequestField *f; | |
| 3351 | ||
| 3352 | PurpleAccount *acct; | |
| 3353 | PurpleConnection *gc; | |
| 10977 | 3354 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3355 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3356 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3357 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3358 | |
| 10977 | 3359 | g_return_if_fail(buddy != NULL); |
| 3360 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3361 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3362 | g_return_if_fail(acct != NULL); |
| 3363 | ||
| 15884 | 3364 | gc = purple_account_get_connection(acct); |
| 10977 | 3365 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3366 | |
| 15884 | 3367 | fields = purple_request_fields_new(); |
| 3368 | ||
| 3369 | g = purple_request_field_group_new(NULL); | |
| 3370 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3371 | |
| 15884 | 3372 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3373 | purple_request_field_group_add_field(g, f); | |
| 3374 | ||
| 3375 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3376 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3377 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3378 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3379 | 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
|
3380 | " 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
|
3381 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3382 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3383 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3384 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3385 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3386 | _("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
|
3387 | purple_request_cpar_from_account(acct), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3388 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3389 | g_free(msg1); |
| 10977 | 3390 | } |
| 3391 | ||
| 3392 | ||
| 15884 | 3393 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3394 | PurpleRequestFields *fields) { | |
| 10977 | 3395 | ; |
| 3396 | } | |
| 3397 | ||
| 3398 | ||
| 15884 | 3399 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3400 | PurpleRequestFields *fields) { | |
| 3401 | 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
|
3402 | GList *l; |
| 10977 | 3403 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3404 | |
| 15884 | 3405 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3406 | msg = purple_request_field_string_get_value(f); | |
| 3407 | ||
| 3408 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3409 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3410 | |
| 3411 | if(l) { | |
| 15884 | 3412 | 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
|
3413 | |
| 10977 | 3414 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3415 | blist_menu_conf_create(buddy, msg); | |
| 3416 | ||
| 3417 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3418 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3419 | mwConference_invite(d, &idb, msg); |
| 3420 | } | |
| 3421 | } | |
| 3422 | } | |
| 3423 | ||
| 3424 | ||
| 15884 | 3425 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3426 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3427 | |
| 15884 | 3428 | PurpleRequestFields *fields; |
| 3429 | PurpleRequestFieldGroup *g; | |
| 3430 | PurpleRequestField *f; | |
| 3431 | ||
| 3432 | PurpleAccount *acct; | |
| 3433 | PurpleConnection *gc; | |
| 10977 | 3434 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3435 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3436 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3437 | char *msg; |
| 10977 | 3438 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3439 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3440 | g_return_if_fail(acct != NULL); |
| 3441 | ||
| 15884 | 3442 | gc = purple_account_get_connection(acct); |
| 10977 | 3443 | g_return_if_fail(gc != NULL); |
| 3444 | ||
| 15884 | 3445 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3446 | |
| 15884 | 3447 | g = purple_request_field_group_new(NULL); |
| 3448 | purple_request_fields_add_group(fields, g); | |
| 3449 | ||
| 3450 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3451 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3452 | for(; confs; confs = confs->next) { |
| 3453 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3454 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3455 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3456 | 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
|
3457 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3458 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3459 | |
| 15884 | 3460 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3461 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3462 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3463 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3464 | 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
|
3465 | " 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
|
3466 | " 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
|
3467 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3468 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3469 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3470 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3471 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3472 | _("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
|
3473 | purple_request_cpar_from_account(acct), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3474 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3475 | g_free(msg); |
| 10977 | 3476 | } |
| 3477 | ||
| 3478 | ||
| 15884 | 3479 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 3480 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3481 | PurpleAccount *acct; | |
| 3482 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3483 | struct mwPurpleProtocolData *pd; |
| 10977 | 3484 | GList *l; |
| 3485 | ||
| 3486 | 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
|
3487 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 10977 | 3488 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3489 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3490 | g_return_if_fail(acct != NULL); |
| 3491 | ||
| 15884 | 3492 | gc = purple_account_get_connection(acct); |
| 10977 | 3493 | g_return_if_fail(gc != NULL); |
| 3494 | ||
|
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
|
3495 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3496 | g_return_if_fail(pd != NULL); |
| 3497 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3498 | /* |
| 10977 | 3499 | - get a list of all conferences on this session |
| 3500 | - if none, prompt to create one, and invite buddy to it | |
| 3501 | - else, prompt to select a conference or create one | |
| 3502 | */ | |
| 3503 | ||
| 3504 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3505 | if(l) { | |
| 3506 | blist_menu_conf_list(buddy, l); | |
| 3507 | g_list_free(l); | |
| 3508 | ||
| 3509 | } else { | |
| 3510 | blist_menu_conf_create(buddy, NULL); | |
| 3511 | } | |
| 3512 | } | |
| 3513 | ||
| 3514 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3515 | static GList * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3516 | mw_protocol_blist_node_menu(PurpleProtocolClient *client, |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3517 | PurpleBlistNode *node) |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3518 | { |
| 10977 | 3519 | GList *l = NULL; |
|
39481
4db28449567d
Rename PurpleMenuAction to PurpleActionMenu
Gary Kramlich <grim@reaperworld.com>
parents:
39479
diff
changeset
|
3520 | PurpleActionMenu *act; |
| 15884 | 3521 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3522 | if(! PURPLE_IS_BUDDY(node)) |
| 10977 | 3523 | return l; |
| 3524 | ||
| 3525 | l = g_list_append(l, NULL); | |
| 3526 | ||
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
3527 | act = purple_action_menu_new(_("Invite to Conference..."), |
| 15884 | 3528 | PURPLE_CALLBACK(blist_menu_conf), NULL, NULL); |
| 10977 | 3529 | l = g_list_append(l, act); |
| 3530 | ||
| 15884 | 3531 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3532 | blist-node-extended-menu signal for that. The function |
| 3533 | blist_node_menu_cb is assigned to this signal in the function | |
| 3534 | services_starting */ | |
| 3535 | ||
| 3536 | return l; | |
| 3537 | } | |
| 3538 | ||
| 3539 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3540 | static GList * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3541 | mw_protocol_chat_info(PurpleProtocolChat *protocol_chat, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3542 | PurpleConnection *gc) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3543 | { |
| 10977 | 3544 | GList *l = NULL; |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3545 | PurpleProtocolChatEntry *pce; |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3546 | |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3547 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3548 | pce->label = _("Topic:"); |
| 10977 | 3549 | pce->identifier = CHAT_KEY_TOPIC; |
| 3550 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3551 | |
| 10977 | 3552 | return l; |
| 3553 | } | |
| 3554 | ||
| 3555 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3556 | static GHashTable * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3557 | mw_protocol_chat_info_defaults(PurpleProtocolChat *protocol_chat, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3558 | PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3559 | const char *name) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3560 | { |
| 10977 | 3561 | GHashTable *table; |
| 3562 | ||
| 3563 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3564 | ||
| 3565 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3566 | NULL, g_free); | |
| 3567 | ||
| 3568 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3569 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3570 | ||
| 3571 | return table; | |
| 3572 | } | |
| 3573 | ||
| 3574 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3575 | static void mw_protocol_login(PurpleAccount *acct); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3576 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3577 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3578 | static void mw_protocol_login(PurpleAccount *account) { |
| 15884 | 3579 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3580 | struct mwPurpleProtocolData *pd; |
| 10977 | 3581 | |
| 3582 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3583 | guint port; |
| 10977 | 3584 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3585 | GError *error = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3586 | |
| 15884 | 3587 | 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
|
3588 | pd = mwPurpleProtocolData_new(gc); |
| 10977 | 3589 | |
| 3590 | /* 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
|
3591 | purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_IMAGES); |
| 15884 | 3592 | |
| 3593 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3594 | |
| 3595 | host = strrchr(user, ':'); | |
| 3596 | if(host) { | |
| 3597 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3598 | *host++ = '\0'; | |
| 15884 | 3599 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3600 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3601 | |
| 10977 | 3602 | } else { |
| 15884 | 3603 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3604 | MW_PLUGIN_DEFAULT_HOST); |
| 3605 | } | |
| 3606 | ||
| 3607 | if(! host || ! *host) { | |
| 3608 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3609 | 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
|
3610 | 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
|
3611 | 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
|
3612 | 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
|
3613 | _("A server is required to connect this account")); |
| 10977 | 3614 | return; |
| 3615 | } | |
| 3616 | ||
|
34022
c49f6e9ea27d
Make all the prpls build.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
3617 | pass = g_strdup(purple_connection_get_password(gc)); |
| 15884 | 3618 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3619 | |
| 3620 | DEBUG_INFO("user: '%s'\n", user); | |
| 3621 | DEBUG_INFO("host: '%s'\n", host); | |
| 3622 | DEBUG_INFO("port: %u\n", port); | |
| 3623 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3624 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3625 | (char *) no_secret, NULL); |
| 3626 | 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
|
3627 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3628 | |
| 15884 | 3629 | 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
|
3630 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3631 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3632 | /* 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
|
3633 | 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
|
3634 | |
| 15884 | 3635 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3636 | 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
|
3637 | 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
|
3638 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3639 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3640 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3641 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3642 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3643 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3644 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3645 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3646 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3647 | GUINT_TO_POINTER(major), NULL); |
|
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 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3650 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3651 | } |
| 10977 | 3652 | |
| 15884 | 3653 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3654 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3655 | pd->client = purple_gio_socket_client_new(account, &error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3656 | if (pd->client == NULL) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3657 | purple_connection_take_error(gc, error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3658 | return; |
| 10977 | 3659 | } |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3660 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3661 | g_socket_client_connect_to_host_async( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3662 | pd->client, host, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3663 | port, pd->cancellable, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3664 | connect_cb, pd); |
| 10977 | 3665 | } |
| 3666 | ||
| 3667 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3668 | 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
|
3669 | struct mwPurpleProtocolData *pd; |
| 10977 | 3670 | |
| 3671 | g_return_if_fail(gc != NULL); | |
| 3672 | ||
|
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
|
3673 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3674 | g_return_if_fail(pd != NULL); |
| 3675 | ||
| 3676 | /* get rid of the blist save timeout */ | |
| 3677 | if(pd->save_event) { | |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
3678 | g_source_remove(pd->save_event); |
| 10977 | 3679 | pd->save_event = 0; |
| 3680 | blist_store(pd); | |
| 3681 | } | |
| 3682 | ||
| 3683 | /* stop the session */ | |
| 3684 | mwSession_stop(pd->session, 0x00); | |
| 3685 | ||
| 3686 | /* 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
|
3687 | purple_connection_set_protocol_data(gc, NULL); |
| 10977 | 3688 | |
| 3689 | /* 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
|
3690 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3691 | 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
|
3692 | pd->inpa = 0; |
| 10977 | 3693 | } |
| 3694 | ||
| 3695 | /* clean up the rest */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3696 | mwPurpleProtocolData_free(pd); |
| 10977 | 3697 | } |
| 3698 | ||
| 3699 | ||
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3700 | static int mw_protocol_send_im(PurpleProtocolIM *im, PurpleConnection *gc, |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3701 | PurpleMessage *msg) |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3702 | { |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3703 | gchar name[1000]; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3704 | struct mwPurpleProtocolData *pd; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3705 | struct mwIdBlock who = { name, NULL }; |
| 10977 | 3706 | struct mwConversation *conv; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3707 | const gchar *message; |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3708 | PurpleMessageFlags flags; |
| 10977 | 3709 | |
| 3710 | 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
|
3711 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3712 | |
| 3713 | g_return_val_if_fail(pd != NULL, 0); | |
| 3714 | ||
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
3715 | 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
|
3716 | message = purple_message_get_contents(msg); |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3717 | flags = purple_message_get_flags(msg); |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3718 | |
| 10977 | 3719 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 3720 | ||
| 3721 | /* this detection of features to determine how to send the message | |
| 3722 | (plain, html, or mime) is flawed because the other end of the | |
| 3723 | conversation could close their channel at any time, rendering any | |
| 3724 | existing formatting in an outgoing message innapropriate. The end | |
| 3725 | result is that it may be possible that the other side of the | |
| 3726 | conversation will receive a plaintext message with html contents, | |
| 3727 | which is bad. I'm not sure how to fix this correctly. */ | |
| 3728 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3729 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 3730 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 3731 | |
| 3732 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3733 | char *tmp; |
| 10977 | 3734 | int ret; |
| 3735 | ||
| 15884 | 3736 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 3737 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3738 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3739 | |
|
39523
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
3740 | tmp = im_mime_generate(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3741 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3742 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3743 | |
| 10977 | 3744 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3745 | /* send an HTML message */ |
| 10977 | 3746 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3747 | char *ncr; |
| 15884 | 3748 | ncr = purple_utf8_ncr_encode(message); |
| 3749 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3750 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3751 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3752 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3753 | g_free(tmp); |
| 10977 | 3754 | |
| 3755 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3756 | /* default to text */ |
| 15884 | 3757 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
3758 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3759 | g_free(tmp); |
| 10977 | 3760 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3761 | |
| 10977 | 3762 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3763 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3764 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3765 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3766 | /* queue up the message safely as plain text */ |
| 15884 | 3767 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3768 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3769 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3770 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3771 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3772 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3773 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3774 | return 1; |
| 10977 | 3775 | } |
| 3776 | } | |
| 3777 | ||
| 3778 | ||
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3779 | static unsigned int mw_protocol_send_typing(PurpleProtocolIM *im, |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3780 | PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3781 | 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
|
3782 | PurpleIMTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3783 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3784 | struct mwPurpleProtocolData *pd; |
| 10977 | 3785 | struct mwIdBlock who = { (char *) name, NULL }; |
| 3786 | struct mwConversation *conv; | |
| 3787 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
3788 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 3789 | |
| 3790 | 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
|
3791 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3792 | |
| 3793 | g_return_val_if_fail(pd != NULL, 0); | |
| 3794 | ||
| 3795 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 3796 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3797 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3798 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3799 | |
|
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
|
3800 | } 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
|
3801 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3802 | 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
|
3803 | 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
|
3804 | |
| 10977 | 3805 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3806 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3807 | if(! mwConversation_isPending(conv)) { |
| 10977 | 3808 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3809 | } |
| 10977 | 3810 | } |
| 3811 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3812 | return 0; |
| 10977 | 3813 | } |
| 3814 | ||
| 3815 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3816 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3817 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3818 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3819 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3820 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3821 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3822 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3823 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3824 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3825 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3826 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3827 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3828 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3829 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3830 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3831 | return "Lotus Sametime Links"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3832 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3833 | case mwLogin_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3834 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3835 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3836 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3837 | return "Lotus Notes Client"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3838 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3839 | case mwLogin_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3840 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3841 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3842 | return "IBM Community Tools"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3843 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3844 | case mwLogin_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3845 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3846 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3847 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3848 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3849 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3850 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3851 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3852 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3853 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3854 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3855 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3856 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3857 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3858 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3859 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3860 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3861 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3862 | return "Trillian"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3863 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3864 | case mwLogin_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3865 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3866 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3867 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3868 | return NULL; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3869 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3870 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3871 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3872 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3873 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3874 | mw_protocol_get_info(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3875 | PurpleConnection *gc, const gchar *who) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3876 | { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3877 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3878 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3879 | struct mwPurpleProtocolData *pd; |
| 15884 | 3880 | PurpleAccount *acct; |
| 3881 | PurpleBuddy *b; | |
| 3882 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3883 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3884 | const char *tmp2; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3885 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3886 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3887 | g_return_if_fail(*who != '\0'); |
| 10977 | 3888 | |
|
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
|
3889 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3890 | |
| 15884 | 3891 | 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
|
3892 | b = purple_blist_find_buddy(acct, who); |
| 15884 | 3893 | user_info = purple_notify_user_info_new(); |
| 3894 | ||
|
40125
a7acc7b00d79
Replace purple_str_has_{prefix,suffix} by g_str_has_{prefix,suffix}.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39970
diff
changeset
|
3895 | if (g_str_has_prefix(who, "@E ")) { |
|
a7acc7b00d79
Replace purple_str_has_{prefix,suffix} by g_str_has_{prefix,suffix}.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39970
diff
changeset
|
3896 | purple_notify_user_info_add_pair_html(user_info, _("External User"), |
|
a7acc7b00d79
Replace purple_str_has_{prefix,suffix} by g_str_has_{prefix,suffix}.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39970
diff
changeset
|
3897 | NULL); |
|
a7acc7b00d79
Replace purple_str_has_{prefix,suffix} by g_str_has_{prefix,suffix}.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39970
diff
changeset
|
3898 | } |
| 10977 | 3899 | |
|
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
|
3900 | 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
|
3901 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3902 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3903 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3904 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3905 | 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
|
3906 | /* 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
|
3907 | 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
|
3908 | 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
|
3909 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3910 | |
| 15884 | 3911 | 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
|
3912 | 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
|
3913 | 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
|
3914 | 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
|
3915 | 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
|
3916 | } else { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3917 | 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
|
3918 | 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
|
3919 | 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
|
3920 | } |
| 10977 | 3921 | } |
| 3922 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3923 | |
| 10977 | 3924 | tmp = user_supports_text(pd->srvc_aware, who); |
| 3925 | 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
|
3926 | 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
|
3927 | g_free(tmp); |
| 10977 | 3928 | } |
| 3929 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3930 | 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
|
3931 | 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
|
3932 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3933 | /* 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
|
3934 | 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
|
3935 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
| 15884 | 3936 | 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
|
3937 | 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
|
3938 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3939 | } |
| 10977 | 3940 | |
| 3941 | /* @todo emit a signal to allow a plugin to override the display of | |
| 3942 | this notification, so that it can create its own */ | |
| 3943 | ||
| 15884 | 3944 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 3945 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 3946 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3947 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3948 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3949 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3950 | mw_protocol_set_status(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3951 | PurpleAccount *acct, PurpleStatus *status) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3952 | { |
| 15884 | 3953 | PurpleConnection *gc; |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3954 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
3955 | char *message = NULL; |
| 10977 | 3956 | struct mwSession *session; |
| 3957 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3958 | |
| 10977 | 3959 | g_return_if_fail(acct != NULL); |
| 15884 | 3960 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3961 | |
| 15884 | 3962 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3963 | |
| 15884 | 3964 | 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
|
3965 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3966 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3967 | |
| 10977 | 3968 | session = gc_to_session(gc); |
| 3969 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3970 | |
| 10977 | 3971 | /* get a working copy of the current status */ |
| 3972 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3973 | |
| 10977 | 3974 | /* determine the state */ |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3975 | if(purple_strequal(state, MW_STATE_ACTIVE)) { |
| 10977 | 3976 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3977 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3978 | } else if(purple_strequal(state, MW_STATE_AWAY)) { |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3979 | stat.status = mwStatus_AWAY; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3980 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3981 | } else if(purple_strequal(state, MW_STATE_BUSY)) { |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3982 | stat.status = mwStatus_BUSY; |
| 10977 | 3983 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3984 | |
| 10977 | 3985 | /* determine the message */ |
| 15884 | 3986 | 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
|
3987 | |
| 10977 | 3988 | if(message) { |
| 3989 | /* all the possible non-NULL values of message up to this point | |
| 3990 | are const, so we don't need to free them */ | |
| 15884 | 3991 | message = purple_markup_strip_html(message); |
| 10977 | 3992 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3993 | |
| 10977 | 3994 | /* out with the old */ |
| 3995 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3996 | |
| 10977 | 3997 | /* in with the new */ |
| 3998 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3999 | |
| 10977 | 4000 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4001 | mwUserStatus_clear(&stat); |
| 10977 | 4002 | } |
| 4003 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4004 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4005 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4006 | mw_protocol_set_idle(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4007 | PurpleConnection *gc, gint t) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4008 | { |
| 10977 | 4009 | struct mwSession *session; |
| 4010 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4011 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4012 | |
| 10977 | 4013 | session = gc_to_session(gc); |
| 4014 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4015 | |
| 10977 | 4016 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4017 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4018 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4019 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4020 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4021 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4022 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4023 | stat.time = 0; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4024 | } |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4025 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4026 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4027 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4028 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4029 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4030 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4031 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4032 | stat.status = mwStatus_ACTIVE; |
| 4033 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4034 | |
| 10977 | 4035 | mwSession_setUserStatus(session, &stat); |
| 4036 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4037 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4038 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4039 | |
| 15884 | 4040 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4041 | PurpleAccount *acct; | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4042 | PurpleIMConversation *im; |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4043 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4044 | |
| 15884 | 4045 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4046 | 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
|
4047 | 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
|
4048 | 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
|
4049 | purple_conversation_present(PURPLE_CONVERSATION(im)); |
| 15884 | 4050 | } |
| 4051 | ||
| 4052 | ||
| 4053 | 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
|
4054 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4055 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4056 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4057 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4058 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4059 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4060 | |
| 15884 | 4061 | 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
|
4062 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4063 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4064 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4065 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4066 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4067 | 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
|
4068 | g_free(data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4069 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4070 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4071 | |
| 10977 | 4072 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4073 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4074 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4075 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4076 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4077 | char *msg; |
| 10977 | 4078 | |
| 15884 | 4079 | PurpleNotifySearchResults *sres; |
| 4080 | PurpleNotifySearchColumn *scol; | |
| 4081 | ||
| 4082 | sres = purple_notify_searchresults_new(); | |
| 4083 | ||
| 4084 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4085 | purple_notify_searchresults_column_add(sres, scol); | |
| 4086 | ||
| 4087 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4088 | purple_notify_searchresults_column_add(sres, scol); | |
| 4089 | ||
| 4090 | 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
|
4091 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4092 | |
| 15884 | 4093 | 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
|
4094 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4095 | |
| 10977 | 4096 | for(l = result->matches; l; l = l->next) { |
| 4097 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4098 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4099 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4100 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
4101 | match->id, match->name); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4102 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4103 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4104 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4105 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4106 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4107 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4108 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4109 | } |
| 10977 | 4110 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4111 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4112 | 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
|
4113 | " 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
|
4114 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4115 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4116 | |
| 15884 | 4117 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4118 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4119 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4120 | g_free(msg); |
| 10977 | 4121 | } |
| 4122 | ||
| 4123 | ||
| 4124 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4125 | guint32 id, guint32 code, GList *results, | |
| 4126 | gpointer b) { | |
| 4127 | ||
| 4128 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4129 | BuddyAddData *data = b; |
| 15884 | 4130 | PurpleBuddy *buddy = NULL; |
| 4131 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4132 | struct mwPurpleProtocolData *pd; |
| 10977 | 4133 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4134 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4135 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4136 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4137 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4138 | 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
|
4139 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4140 | |
| 4141 | if(results) | |
| 4142 | res = results->data; | |
| 4143 | ||
| 4144 | 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
|
4145 | if(!res->matches->next) { |
| 10977 | 4146 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4147 | |
| 10977 | 4148 | /* only one? that might be the right one! */ |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4149 | if(!purple_strequal(res->name, match->id)) { |
| 10977 | 4150 | /* uh oh, the single result isn't identical to the search |
| 4151 | term, better safe then sorry, so let's make sure it's who | |
| 4152 | the user meant to add */ | |
| 15884 | 4153 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4154 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4155 | |
| 10977 | 4156 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4157 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4158 | /* 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
|
4159 | purple_buddy_set_server_alias(buddy, match->name); |
| 15884 | 4160 | purple_blist_node_set_string((PurpleBlistNode *) buddy, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4161 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4162 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4163 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4164 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4165 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4166 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4167 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4168 | g_free(data); |
| 10977 | 4169 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4170 | |
| 10977 | 4171 | } else { |
| 4172 | /* prompt user if more than one match was returned */ | |
| 15884 | 4173 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4174 | multi_resolved_query(res, gc, data); |
| 10977 | 4175 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4176 | |
| 10977 | 4177 | return; |
| 4178 | } | |
| 4179 | } | |
| 4180 | ||
| 4181 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4182 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4183 | mw_protocol_add_buddy(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4184 | PurpleConnection *gc, PurpleBuddy *buddy, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4185 | PurpleGroup *group, const gchar *message) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4186 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4187 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4188 | struct mwServiceResolve *srvc; |
| 4189 | GList *query; | |
| 4190 | enum mwResolveFlag flags; | |
| 4191 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4192 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4193 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4194 | /* 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
|
4195 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4196 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4197 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4198 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4199 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4200 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4201 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4202 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4203 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4204 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4205 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4206 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4207 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4208 | ||
| 4209 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4210 | data, NULL); |
| 10977 | 4211 | g_list_free(query); |
| 4212 | ||
| 4213 | if(req == SEARCH_ERROR) { | |
| 15884 | 4214 | purple_blist_remove_buddy(buddy); |
| 10977 | 4215 | blist_schedule(pd); |
| 4216 | } | |
| 4217 | } | |
| 4218 | ||
| 4219 | ||
| 15884 | 4220 | 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
|
4221 | struct mwPurpleProtocolData *pd) { |
| 10977 | 4222 | struct mwAwareList *list; |
| 4223 | ||
| 4224 | list = list_ensure(pd, group); | |
| 4225 | mwAwareList_addAware(list, buddies); | |
| 4226 | g_list_free(buddies); | |
| 4227 | } | |
| 4228 | ||
| 4229 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4230 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4231 | mw_protocol_add_buddies(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4232 | PurpleConnection *gc, |
| 10977 | 4233 | GList *buddies, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4234 | GList *groups, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4235 | const char *message) { |
| 10977 | 4236 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4237 | struct mwPurpleProtocolData *pd; |
| 10977 | 4238 | GHashTable *group_sets; |
| 4239 | struct mwAwareIdBlock *idbs, *idb; | |
| 4240 | ||
|
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
|
4241 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4242 | |
| 15884 | 4243 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4244 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4245 | ||
| 4246 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4247 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4248 | ||
| 4249 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4250 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4251 | PurpleBuddy *b = buddies->data; |
| 4252 | PurpleGroup *g; | |
| 10977 | 4253 | const char *fn; |
| 4254 | GList *l; | |
| 4255 | ||
| 4256 | /* nab the saved server alias and stick it on the buddy */ | |
| 15884 | 4257 | 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
|
4258 | purple_buddy_set_server_alias(b, fn); |
| 15884 | 4259 | |
| 4260 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4261 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4262 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4263 | idb->community = NULL; |
| 4264 | ||
| 4265 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4266 | g = purple_buddy_get_group(b); |
| 10977 | 4267 | l = g_hash_table_lookup(group_sets, g); |
| 4268 | l = g_list_prepend(l, idb++); | |
| 4269 | g_hash_table_insert(group_sets, g, l); | |
| 4270 | } | |
| 4271 | ||
| 4272 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4273 | for saving */ | |
| 4274 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4275 | blist_schedule(pd); | |
| 4276 | ||
| 4277 | /* cleanup */ | |
| 4278 | g_hash_table_destroy(group_sets); | |
| 4279 | g_free(idbs); | |
| 4280 | } | |
| 4281 | ||
| 4282 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4283 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4284 | mw_protocol_remove_buddy(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4285 | PurpleConnection *gc, PurpleBuddy *buddy, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4286 | PurpleGroup *group) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4287 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4288 | struct mwPurpleProtocolData *pd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4289 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4290 | struct mwAwareList *list; |
| 4291 | ||
| 4292 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4293 | ||
|
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
|
4294 | pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4295 | group = purple_buddy_get_group(buddy); |
| 10977 | 4296 | list = list_ensure(pd, group); |
| 4297 | ||
| 4298 | mwAwareList_removeAware(list, rem); | |
| 4299 | blist_schedule(pd); | |
| 4300 | ||
| 4301 | g_list_free(rem); | |
| 4302 | } | |
| 4303 | ||
| 4304 | ||
| 4305 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4306 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4307 | |
| 10977 | 4308 | struct mwUserItem *u; |
| 4309 | guint count; | |
| 4310 | ||
| 4311 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4312 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4313 | |
| 4314 | priv->count = count; | |
| 4315 | priv->users = g_new0(struct mwUserItem, count); | |
| 4316 | ||
| 4317 | while(count--) { | |
| 4318 | u = priv->users + count; | |
| 4319 | u->id = members->data; | |
| 4320 | members = members->next; | |
| 4321 | } | |
| 4322 | } | |
| 4323 | ||
| 4324 | ||
|
40521
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4325 | static void mw_protocol_set_permit_deny(PurpleProtocolPrivacy *priv, |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4326 | PurpleConnection *gc) |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4327 | { |
| 15884 | 4328 | PurpleAccount *acct; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4329 | struct mwPurpleProtocolData *pd; |
| 10977 | 4330 | struct mwSession *session; |
| 4331 | ||
| 4332 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4333 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4334 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4335 | NULL, /* users */ |
| 10977 | 4336 | }; |
| 4337 | ||
| 4338 | g_return_if_fail(gc != NULL); | |
| 4339 | ||
| 15884 | 4340 | acct = purple_connection_get_account(gc); |
| 10977 | 4341 | g_return_if_fail(acct != NULL); |
| 4342 | ||
|
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
|
4343 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4344 | g_return_if_fail(pd != NULL); |
| 4345 | ||
| 4346 | session = pd->session; | |
| 4347 | g_return_if_fail(session != NULL); | |
| 4348 | ||
|
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
|
4349 | 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
|
4350 | case PURPLE_ACCOUNT_PRIVACY_DENY_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4351 | 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
|
4352 | privacy_fill(&privacy, purple_account_privacy_get_denied(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4353 | privacy.deny = TRUE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4354 | break; |
| 10977 | 4355 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4356 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4357 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL\n"); |
| 10977 | 4358 | privacy.deny = TRUE; |
| 4359 | break; | |
| 4360 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4361 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4362 | 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
|
4363 | privacy_fill(&privacy, purple_account_privacy_get_permitted(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4364 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4365 | break; |
| 10977 | 4366 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4367 | case PURPLE_ACCOUNT_PRIVACY_DENY_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4368 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_DENY_ALL\n"); |
| 10977 | 4369 | privacy.deny = FALSE; |
| 4370 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4371 | |
| 10977 | 4372 | 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
|
4373 | 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
|
4374 | return; |
| 10977 | 4375 | } |
| 4376 | ||
| 4377 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4378 | g_free(privacy.users); | |
| 4379 | } | |
| 4380 | ||
| 4381 | ||
|
40521
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4382 | static void mw_protocol_add_permit(PurpleProtocolPrivacy *privacy, |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4383 | PurpleConnection *gc, const char *name) |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4384 | { |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4385 | mw_protocol_set_permit_deny(privacy, gc); |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4386 | } |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4387 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4388 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4389 | static void mw_protocol_add_deny(PurpleProtocolPrivacy *privacy, |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4390 | PurpleConnection *gc, const char *name) |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4391 | { |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4392 | mw_protocol_set_permit_deny(privacy, gc); |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4393 | } |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4394 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4395 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4396 | static void mw_protocol_remove_permit(PurpleProtocolPrivacy *privacy, |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4397 | PurpleConnection *gc, const char *name) |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4398 | { |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4399 | mw_protocol_set_permit_deny(privacy, gc); |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4400 | } |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4401 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4402 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4403 | static void mw_protocol_remove_deny(PurpleProtocolPrivacy *privacy, |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4404 | PurpleConnection *gc, const char *name) |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4405 | { |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4406 | mw_protocol_set_permit_deny(privacy, gc); |
| 10977 | 4407 | } |
| 4408 | ||
| 4409 | ||
| 4410 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4411 | const char *name) { | |
| 4412 | GList *l, *ll; | |
| 4413 | struct mwConference *conf = NULL; | |
| 4414 | ||
| 4415 | ll = mwServiceConference_getConferences(srvc); | |
| 4416 | for(l = ll; l; l = l->next) { | |
| 4417 | struct mwConference *c = l->data; | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4418 | if(purple_strequal(name, mwConference_getName(c))) { |
| 10977 | 4419 | conf = c; |
| 4420 | break; | |
| 4421 | } | |
| 4422 | } | |
| 4423 | g_list_free(ll); | |
| 4424 | ||
| 4425 | return conf; | |
| 4426 | } | |
| 4427 | ||
| 4428 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4429 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4430 | mw_protocol_join_chat(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4431 | GHashTable *components) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4432 | { |
| 10977 | 4433 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4434 | struct mwPurpleProtocolData *pd; |
| 10977 | 4435 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4436 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4437 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4438 | |
| 4439 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4440 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4441 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4442 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4443 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4444 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4445 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4446 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4447 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4448 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4449 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4450 | |
| 10977 | 4451 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4452 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4453 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4454 | struct mwConference *conf = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4455 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4456 | srvc = pd->srvc_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4457 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4458 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4459 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4460 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4461 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4462 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4463 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4464 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4465 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4466 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4467 | } |
| 10977 | 4468 | } |
| 4469 | } | |
| 4470 | ||
| 4471 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4472 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4473 | mw_protocol_reject_chat(PurpleProtocolChat *protocol_chat, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4474 | PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4475 | GHashTable *components) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4476 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4477 | struct mwPurpleProtocolData *pd; |
| 10977 | 4478 | struct mwServiceConference *srvc; |
| 4479 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4480 | |
|
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
|
4481 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4482 | srvc = pd->srvc_conf; |
| 4483 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4484 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4485 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4486 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4487 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4488 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4489 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4490 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4491 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4492 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4493 | } |
| 10977 | 4494 | } |
| 4495 | } | |
| 4496 | ||
| 4497 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4498 | static char * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4499 | mw_protocol_get_chat_name(PurpleProtocolChat *protocol_chat, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4500 | GHashTable *components) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4501 | { |
| 10977 | 4502 | return g_hash_table_lookup(components, CHAT_KEY_NAME); |
| 4503 | } | |
| 4504 | ||
| 4505 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4506 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4507 | mw_protocol_chat_invite(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4508 | int id, const char *invitation, const char *who) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4509 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4510 | struct mwPurpleProtocolData *pd; |
| 10977 | 4511 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4512 | struct mwPlace *place; |
| 10977 | 4513 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4514 | ||
|
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
|
4515 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4516 | g_return_if_fail(pd != NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4517 | |
| 10977 | 4518 | conf = ID_TO_CONF(pd, id); |
| 4519 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4520 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4521 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4522 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4523 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4524 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4525 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4526 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4527 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4528 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4529 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4530 | } |
| 4531 | ||
| 4532 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4533 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4534 | mw_protocol_chat_leave(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4535 | int id) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4536 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4537 | struct mwPurpleProtocolData *pd; |
| 10977 | 4538 | struct mwConference *conf; |
| 4539 | ||
|
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
|
4540 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4541 | |
| 4542 | g_return_if_fail(pd != NULL); | |
| 4543 | conf = ID_TO_CONF(pd, id); | |
| 4544 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4545 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4546 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4547 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4548 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4549 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4550 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4551 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4552 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4553 | } |
| 10977 | 4554 | } |
| 4555 | ||
| 4556 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4557 | static int |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4558 | mw_protocol_chat_send(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4559 | int id, PurpleMessage *pmsg) |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
4560 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4561 | struct mwPurpleProtocolData *pd; |
| 10977 | 4562 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4563 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4564 | int ret; |
| 10977 | 4565 | |
|
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
|
4566 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4567 | |
| 4568 | g_return_val_if_fail(pd != NULL, 0); | |
| 4569 | conf = ID_TO_CONF(pd, id); | |
| 4570 | ||
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
4571 | 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
|
4572 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4573 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4574 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4575 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4576 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4577 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4578 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4579 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4580 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4581 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4582 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4583 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4584 | return ret; |
| 10977 | 4585 | } |
| 4586 | ||
| 4587 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4588 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4589 | mw_protocol_keepalive(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4590 | PurpleConnection *gc) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4591 | { |
| 10977 | 4592 | struct mwSession *session; |
| 4593 | ||
| 4594 | g_return_if_fail(gc != NULL); | |
| 4595 | ||
| 4596 | session = gc_to_session(gc); | |
| 4597 | g_return_if_fail(session != NULL); | |
| 4598 | ||
| 4599 | mwSession_sendKeepalive(session); | |
| 4600 | } | |
| 4601 | ||
| 4602 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4603 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4604 | mw_protocol_alias_buddy(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4605 | PurpleConnection *gc, const gchar *who, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4606 | const gchar *alias) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4607 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4608 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4609 | g_return_if_fail(pd != NULL); |
| 4610 | ||
| 4611 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4612 | the server copy */ | |
| 4613 | ||
| 4614 | blist_schedule(pd); | |
| 4615 | } | |
| 4616 | ||
| 4617 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4618 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4619 | mw_protocol_group_buddy(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4620 | PurpleConnection *gc, const gchar *who, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4621 | const gchar *old_group, const gchar *new_group) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4622 | { |
| 10977 | 4623 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
| 4624 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4625 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4626 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4627 | PurpleGroup *group; |
| 10977 | 4628 | struct mwAwareList *list; |
| 4629 | ||
| 4630 | /* 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
|
4631 | group = purple_blist_find_group(new_group); |
| 10977 | 4632 | list = list_ensure(pd, group); |
| 4633 | mwAwareList_addAware(list, gl); | |
| 4634 | ||
| 4635 | /* 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
|
4636 | group = purple_blist_find_group(old_group); |
| 10977 | 4637 | list = list_ensure(pd, group); |
| 4638 | mwAwareList_removeAware(list, gl); | |
| 4639 | ||
| 4640 | g_list_free(gl); | |
| 4641 | ||
| 4642 | /* schedule the changes to be saved */ | |
| 4643 | blist_schedule(pd); | |
| 4644 | } | |
| 4645 | ||
| 4646 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4647 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4648 | mw_protocol_rename_group(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4649 | PurpleConnection *gc, const gchar *old, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4650 | PurpleGroup *group, GList *buddies) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4651 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4652 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4653 | g_return_if_fail(pd != NULL); |
| 4654 | ||
| 4655 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4656 | the server copy. Also, having this function should prevent all | |
| 4657 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4658 | give a crap what the group is named in Purple other than to record |
| 10977 | 4659 | that as the group name/alias */ |
| 4660 | ||
| 4661 | blist_schedule(pd); | |
| 4662 | } | |
| 4663 | ||
| 4664 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4665 | static void |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4666 | mw_protocol_buddy_free(PurpleProtocolClient *client, PurpleBuddy *buddy) { |
| 10977 | 4667 | /* I don't think we have any cleanup for buddies yet */ |
| 4668 | ; | |
| 4669 | } | |
| 4670 | ||
| 4671 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4672 | static void |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4673 | mw_protocol_convo_closed(PurpleProtocolClient *client, PurpleConnection *gc, |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4674 | const char *who) |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4675 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4676 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4677 | struct mwServiceIm *srvc; |
| 4678 | struct mwConversation *conv; | |
| 4679 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4680 | ||
| 4681 | g_return_if_fail(pd != NULL); | |
| 4682 | ||
| 4683 | srvc = pd->srvc_im; | |
| 4684 | g_return_if_fail(srvc != NULL); | |
| 4685 | ||
| 4686 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 4687 | if(! conv) return; | |
| 4688 | ||
| 4689 | if(mwConversation_isOpen(conv)) | |
| 4690 | mwConversation_free(conv); | |
| 4691 | } | |
| 4692 | ||
| 4693 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4694 | static const gchar * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4695 | mw_protocol_normalize(PurpleProtocolClient *client, PurpleAccount *account, |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4696 | const gchar *id) |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4697 | { |
| 10977 | 4698 | |
| 4699 | /* code elsewhere assumes that the return value points to different | |
| 4700 | memory than the passed value, but it won't free the normalized | |
| 4701 | data. wtf? */ | |
| 4702 | ||
| 4703 | 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
|
4704 | g_strlcpy(buf, id, sizeof(buf)); |
| 10977 | 4705 | return buf; |
| 4706 | } | |
| 4707 | ||
| 4708 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4709 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4710 | mw_protocol_remove_group(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4711 | PurpleConnection *gc, PurpleGroup *group) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4712 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4713 | struct mwPurpleProtocolData *pd; |
| 10977 | 4714 | struct mwAwareList *list; |
| 4715 | ||
|
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
|
4716 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4717 | g_return_if_fail(pd != NULL); |
| 4718 | g_return_if_fail(pd->group_list_map != NULL); | |
| 4719 | ||
| 4720 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 4721 | ||
| 4722 | if(list) { | |
| 4723 | g_hash_table_remove(pd->group_list_map, list); | |
| 4724 | g_hash_table_remove(pd->group_list_map, group); | |
| 4725 | mwAwareList_free(list); | |
| 4726 | ||
| 4727 | blist_schedule(pd); | |
| 4728 | } | |
| 4729 | } | |
| 4730 | ||
| 4731 | ||
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4732 | 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
|
4733 | PurpleConnection *gc, |
| 10977 | 4734 | const char *who) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4735 | struct mwPurpleProtocolData *pd; |
| 10977 | 4736 | struct mwServiceAware *srvc; |
| 15884 | 4737 | PurpleAccount *acct; |
| 10977 | 4738 | |
| 4739 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 4740 | ||
|
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
|
4741 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4742 | g_return_val_if_fail(pd != NULL, FALSE); |
| 4743 | ||
| 4744 | srvc = pd->srvc_aware; | |
| 4745 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4746 | |
| 15884 | 4747 | acct = purple_connection_get_account(gc); |
| 10977 | 4748 | g_return_val_if_fail(acct != NULL, FALSE); |
| 4749 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4750 | return purple_blist_find_buddy(acct, who) && |
| 10977 | 4751 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 4752 | } | |
| 4753 | ||
| 4754 | ||
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4755 | 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
|
4756 | PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4757 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4758 | |
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4759 | PurpleXfer *xfer = mw_protocol_new_xfer(prplxfer, gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4760 | |
| 10977 | 4761 | if(file) { |
| 4762 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 4763 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 4764 | |
| 4765 | } else { | |
| 4766 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 4767 | purple_xfer_request(xfer); |
| 10977 | 4768 | } |
| 4769 | } | |
| 4770 | ||
| 4771 | ||
| 15884 | 4772 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 4773 | struct mwSametimeList *l; |
| 4774 | ||
| 4775 | FILE *file; | |
| 4776 | char buf[BUF_LEN]; | |
| 4777 | size_t len; | |
| 4778 | ||
| 4779 | GString *str; | |
| 4780 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
4781 | file = g_fopen(filename, "r"); |
| 10977 | 4782 | g_return_if_fail(file != NULL); |
| 4783 | ||
| 4784 | str = g_string_new(NULL); | |
| 4785 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 4786 | g_string_append_len(str, buf, len); | |
| 4787 | } | |
| 4788 | ||
| 4789 | fclose(file); | |
| 4790 | ||
| 4791 | l = mwSametimeList_load(str->str); | |
| 4792 | g_string_free(str, TRUE); | |
| 4793 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4794 | blist_merge(gc, l); |
| 10977 | 4795 | mwSametimeList_free(l); |
| 4796 | } | |
| 4797 | ||
| 4798 | ||
| 4799 | /** 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
|
4800 | static void st_import_action(PurpleProtocolAction *act) { |
| 15884 | 4801 | PurpleConnection *gc; |
| 4802 | PurpleAccount *account; | |
| 10977 | 4803 | char *title; |
| 4804 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4805 | gc = act->connection; |
| 15884 | 4806 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4807 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 4808 | purple_account_get_username(account)); |
| 4809 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4810 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 4811 | 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
|
4812 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4813 | gc); |
| 10977 | 4814 | |
| 4815 | g_free(title); | |
| 4816 | } | |
| 4817 | ||
| 4818 | ||
| 15884 | 4819 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 4820 | struct mwSametimeList *l; |
| 4821 | char *str; | |
| 4822 | FILE *file; | |
| 4823 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
4824 | file = g_fopen(filename, "w"); |
| 10977 | 4825 | g_return_if_fail(file != NULL); |
| 4826 | ||
| 4827 | l = mwSametimeList_new(); | |
| 4828 | blist_export(gc, l); | |
| 4829 | str = mwSametimeList_store(l); | |
| 4830 | mwSametimeList_free(l); | |
| 4831 | ||
| 4832 | fprintf(file, "%s", str); | |
| 4833 | fclose(file); | |
| 4834 | ||
| 4835 | g_free(str); | |
| 4836 | } | |
| 4837 | ||
| 4838 | ||
| 4839 | /** 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
|
4840 | static void st_export_action(PurpleProtocolAction *act) { |
| 15884 | 4841 | PurpleConnection *gc; |
| 4842 | PurpleAccount *account; | |
| 10977 | 4843 | char *title; |
| 4844 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4845 | gc = act->connection; |
| 15884 | 4846 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4847 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 4848 | purple_account_get_username(account)); |
| 4849 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4850 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 4851 | 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
|
4852 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4853 | gc); |
| 10977 | 4854 | |
| 4855 | g_free(title); | |
| 4856 | } | |
| 4857 | ||
| 4858 | ||
| 4859 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 4860 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4861 | |
| 15884 | 4862 | 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
|
4863 | GList *l; |
| 10977 | 4864 | |
| 15884 | 4865 | f = purple_request_fields_get_field(fields, "group"); |
| 4866 | l = purple_request_field_list_get_items(f); | |
| 10977 | 4867 | |
| 4868 | for(; l; l = l->next) { | |
| 4869 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4870 | struct named_id *res; |
| 10977 | 4871 | |
| 15884 | 4872 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 4873 | |
| 4874 | g_free(res->id); | |
| 4875 | g_free(res->name); | |
| 4876 | g_free(res); | |
| 4877 | } | |
| 4878 | } | |
| 4879 | ||
| 4880 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4881 | static void remote_group_done(struct mwPurpleProtocolData *pd, |
| 10977 | 4882 | const char *id, const char *name) { |
| 15884 | 4883 | PurpleConnection *gc; |
| 4884 | PurpleAccount *acct; | |
| 4885 | PurpleGroup *group; | |
| 4886 | PurpleBlistNode *gn; | |
| 10977 | 4887 | const char *owner; |
| 4888 | ||
| 4889 | g_return_if_fail(pd != NULL); | |
| 4890 | ||
| 4891 | gc = pd->gc; | |
| 15884 | 4892 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4893 | |
| 10977 | 4894 | /* collision checking */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4895 | group = purple_blist_find_group(name); |
| 10977 | 4896 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4897 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4898 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4899 | char *msg; |
| 10977 | 4900 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4901 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4902 | 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
|
4903 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4904 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
4905 | 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
|
4906 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4907 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4908 | g_free(msg); |
| 10977 | 4909 | return; |
| 4910 | } | |
| 4911 | ||
| 15884 | 4912 | group = purple_group_new(name); |
| 4913 | gn = (PurpleBlistNode *) group; | |
| 4914 | ||
| 4915 | owner = purple_account_get_username(acct); | |
| 4916 | ||
| 4917 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 4918 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 4919 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 4920 | purple_blist_add_group(group, NULL); | |
| 10977 | 4921 | |
| 4922 | group_add(pd, group); | |
| 4923 | blist_schedule(pd); | |
| 4924 | } | |
| 4925 | ||
| 4926 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4927 | static void remote_group_multi_cb(struct mwPurpleProtocolData *pd, |
| 15884 | 4928 | PurpleRequestFields *fields) { |
| 4929 | 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
|
4930 | GList *l; |
| 10977 | 4931 | |
| 15884 | 4932 | f = purple_request_fields_get_field(fields, "group"); |
| 4933 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 4934 | |
| 4935 | if(l) { | |
| 4936 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4937 | struct named_id *res; |
| 10977 | 4938 | |
| 15884 | 4939 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 4940 | remote_group_done(pd, res->id, res->name); |
| 4941 | } | |
| 4942 | ||
| 4943 | remote_group_multi_cleanup(NULL, fields); | |
| 4944 | } | |
| 4945 | ||
| 4946 | ||
| 4947 | 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
|
4948 | struct mwPurpleProtocolData *pd) { |
| 15884 | 4949 | |
| 4950 | PurpleRequestFields *fields; | |
| 4951 | PurpleRequestFieldGroup *g; | |
| 4952 | PurpleRequestField *f; | |
| 10977 | 4953 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4954 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4955 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4956 | char *msg; |
| 10977 | 4957 | |
| 15884 | 4958 | PurpleConnection *gc = pd->gc; |
| 4959 | ||
| 4960 | fields = purple_request_fields_new(); | |
| 4961 | ||
| 4962 | g = purple_request_field_group_new(NULL); | |
| 4963 | purple_request_fields_add_group(fields, g); | |
| 4964 | ||
| 4965 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 4966 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 4967 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 4968 | |
| 4969 | for(l = result->matches; l; l = l->next) { | |
| 4970 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4971 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 4972 | |
| 4973 | res->id = g_strdup(match->id); | |
| 4974 | res->name = g_strdup(match->name); | |
| 4975 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
4976 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 4977 | } |
| 4978 | ||
| 15884 | 4979 | purple_request_field_group_add_field(g, f); |
| 10977 | 4980 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4981 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4982 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 4983 | " Notes Address Book groups. Please select the correct group from" |
| 4984 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4985 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4986 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4987 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4988 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4989 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4990 | _("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
|
4991 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4992 | pd); |
| 10977 | 4993 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4994 | g_free(msg); |
| 10977 | 4995 | } |
| 4996 | ||
| 4997 | ||
| 4998 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 4999 | guint32 id, guint32 code, GList *results, | |
| 5000 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5001 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5002 | struct mwResolveResult *res = NULL; |
| 10977 | 5003 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5004 | struct mwPurpleProtocolData *pd; |
| 15884 | 5005 | PurpleConnection *gc; |
| 10977 | 5006 | |
| 5007 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5008 | g_return_if_fail(session != NULL); | |
| 5009 | ||
| 5010 | pd = mwSession_getClientData(session); | |
| 5011 | g_return_if_fail(pd != NULL); | |
| 5012 | ||
| 5013 | gc = pd->gc; | |
| 5014 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5015 | |
| 10977 | 5016 | if(!code && results) { |
| 5017 | res = results->data; | |
| 5018 | ||
| 5019 | if(res->matches) { | |
| 5020 | remote_group_multi(res, pd); | |
| 5021 | return; | |
| 5022 | } | |
| 5023 | } | |
| 5024 | ||
| 5025 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5026 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5027 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5028 | char *msg; |
| 10977 | 5029 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5030 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5031 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5032 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5033 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5034 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5035 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5036 | 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
|
5037 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5038 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5039 | g_free(msg); |
| 10977 | 5040 | } |
| 5041 | } | |
| 5042 | ||
| 5043 | ||
| 15884 | 5044 | 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
|
5045 | struct mwPurpleProtocolData *pd; |
| 10977 | 5046 | struct mwServiceResolve *srvc; |
| 5047 | GList *query; | |
| 5048 | enum mwResolveFlag flags; | |
| 5049 | guint32 req; | |
| 5050 | ||
|
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
|
5051 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5052 | srvc = pd->srvc_resolve; |
| 5053 | ||
| 5054 | query = g_list_prepend(NULL, (char *) name); | |
| 5055 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5056 | |
| 10977 | 5057 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5058 | NULL, NULL); | |
| 5059 | g_list_free(query); | |
| 5060 | ||
| 5061 | if(req == SEARCH_ERROR) { | |
| 5062 | /** @todo display error */ | |
| 5063 | } | |
| 5064 | } | |
| 5065 | ||
| 5066 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5067 | static void remote_group_action(PurpleProtocolAction *act) { |
| 15884 | 5068 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5069 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5070 | const char *msgB; |
| 10977 | 5071 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5072 | gc = act->connection; |
| 10977 | 5073 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5074 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5075 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5076 | " to add the group and its members to your buddy list."); |
| 5077 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5078 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5079 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5080 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5081 | _("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
|
5082 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5083 | gc); |
| 10977 | 5084 | } |
| 5085 | ||
| 5086 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5087 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5088 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5089 | GList *l; |
|
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 *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5093 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5094 | |
| 15884 | 5095 | PurpleNotifySearchResults *sres; |
| 5096 | PurpleNotifySearchColumn *scol; | |
| 5097 | ||
| 5098 | sres = purple_notify_searchresults_new(); | |
| 5099 | ||
| 5100 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5101 | purple_notify_searchresults_column_add(sres, scol); | |
| 5102 | ||
| 5103 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5104 | purple_notify_searchresults_column_add(sres, scol); | |
| 5105 | ||
| 5106 | 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
|
5107 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5108 | |
| 15884 | 5109 | 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
|
5110 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5111 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5112 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5113 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5114 | GList *row = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5115 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5116 | if(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5117 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5118 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5119 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5120 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5121 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5122 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5123 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5124 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5125 | 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
|
5126 | " 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
|
5127 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5128 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5129 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5130 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5131 | |
| 15884 | 5132 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5133 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5134 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5135 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5136 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5137 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5138 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5139 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5140 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5141 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5142 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5143 | |
| 15884 | 5144 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5145 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5146 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5147 | if(results) res = results->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5148 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5149 | if(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5150 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5151 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5152 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5153 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5154 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5155 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5156 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5157 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5158 | 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
|
5159 | " Sametime community."); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
5160 | msg = g_strdup_printf(msgB, (res && res->name) ? res->name : ""); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5161 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5162 | 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
|
5163 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5164 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5165 | g_free(msg); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5166 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5167 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5168 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5169 | |
| 15884 | 5170 | 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
|
5171 | struct mwPurpleProtocolData *pd; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5172 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5173 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5174 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5175 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5176 | |
|
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
|
5177 | pd = purple_connection_get_protocol_data(gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5178 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5179 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5180 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5181 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5182 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5183 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5184 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5185 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5186 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5187 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5188 | /** @todo display error */ |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5189 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5190 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5191 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5192 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5193 | static void search_action(PurpleProtocolAction *act) { |
| 15884 | 5194 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5195 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5196 | const char *msgB; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5197 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5198 | gc = act->connection; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5199 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5200 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5201 | 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
|
5202 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5203 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5204 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5205 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5206 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5207 | _("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
|
5208 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5209 | gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5210 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5211 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5212 | |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
5213 | static GList * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
5214 | mw_protocol_get_actions(PurpleProtocolClient *client, PurpleConnection *gc) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5215 | PurpleProtocolAction *act; |
| 10977 | 5216 | GList *l = NULL; |
| 5217 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5218 | act = purple_protocol_action_new(_("Import Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5219 | st_import_action); |
| 10977 | 5220 | l = g_list_append(l, act); |
| 5221 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5222 | act = purple_protocol_action_new(_("Export Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5223 | st_export_action); |
| 10977 | 5224 | l = g_list_append(l, act); |
| 5225 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5226 | act = purple_protocol_action_new(_("Add Notes Address Book Group..."), |
| 10977 | 5227 | remote_group_action); |
| 5228 | l = g_list_append(l, act); | |
| 5229 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5230 | act = purple_protocol_action_new(_("User Search..."), |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5231 | search_action); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5232 | l = g_list_append(l, act); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5233 | |
| 10977 | 5234 | return l; |
| 5235 | } | |
| 5236 | ||
| 5237 | ||
| 5238 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5239 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5240 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5241 | if(! (msg && *msg)) return; |
| 10977 | 5242 | |
| 15884 | 5243 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5244 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5245 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5246 | |
| 5247 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5248 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5249 | |
| 5250 | } else { | |
| 15884 | 5251 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5252 | } |
| 5253 | } | |
| 5254 | ||
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5255 | static void |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5256 | mw_protocol_init(mwProtocol *self) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5257 | { |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5258 | /* set up the preferences */ |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5259 | purple_prefs_add_none(MW_PROTOCOL_OPT_BASE); |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5260 | purple_prefs_add_int(MW_PROTOCOL_OPT_BLIST_ACTION, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5261 | BLIST_CHOICE_DEFAULT); |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5262 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5263 | /* remove dead preferences */ |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5264 | purple_prefs_remove(MW_PROTOCOL_OPT_PSYCHIC); |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5265 | purple_prefs_remove(MW_PROTOCOL_OPT_SAVE_DYNAMIC); |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5266 | } |
| 10977 | 5267 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5268 | static void |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5269 | mw_protocol_class_init(mwProtocolClass *klass) |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5270 | { |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5271 | PurpleProtocolClass *protocol_class = PURPLE_PROTOCOL_CLASS(klass); |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5272 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5273 | protocol_class->login = mw_protocol_login; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5274 | protocol_class->close = mw_protocol_close; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5275 | protocol_class->status_types = mw_protocol_status_types; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5276 | protocol_class->list_icon = mw_protocol_list_icon; |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5277 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5278 | protocol_class->get_account_options = mw_protocol_get_account_options; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5279 | protocol_class->get_user_splits = mw_protocol_get_user_splits; |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5280 | } |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5281 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5282 | static void |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5283 | mw_protocol_class_finalize(G_GNUC_UNUSED mwProtocolClass *klass) |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5284 | { |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5285 | } |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5286 | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5287 | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5288 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5289 | mw_protocol_client_iface_init(PurpleProtocolClientInterface *client_iface) |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5290 | { |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5291 | 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
|
5292 | 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
|
5293 | 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
|
5294 | 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
|
5295 | 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
|
5296 | 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
|
5297 | 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
|
5298 | 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
|
5299 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5300 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5301 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5302 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5303 | mw_protocol_server_iface_init(PurpleProtocolServerInterface *server_iface) |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5304 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5305 | 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
|
5306 | 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
|
5307 | 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
|
5308 | 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
|
5309 | 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
|
5310 | 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
|
5311 | 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
|
5312 | 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
|
5313 | 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
|
5314 | 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
|
5315 | 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
|
5316 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5317 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5318 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5319 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5320 | mw_protocol_im_iface_init(PurpleProtocolIMInterface *im_iface) |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5321 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5322 | 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
|
5323 | 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
|
5324 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5325 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5326 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5327 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5328 | mw_protocol_chat_iface_init(PurpleProtocolChatInterface *chat_iface) |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5329 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5330 | 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
|
5331 | 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
|
5332 | 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
|
5333 | 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
|
5334 | 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
|
5335 | 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
|
5336 | 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
|
5337 | 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
|
5338 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5339 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5340 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5341 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5342 | mw_protocol_privacy_iface_init(PurpleProtocolPrivacyInterface *privacy_iface) |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5343 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5344 | 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
|
5345 | privacy_iface->add_deny = mw_protocol_add_deny; |
|
40521
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
5346 | privacy_iface->remove_permit = mw_protocol_remove_permit; |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
5347 | privacy_iface->remove_deny = mw_protocol_remove_deny; |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5348 | 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
|
5349 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5350 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5351 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5352 | static void |
|
38827
3573c82d32d8
Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
38433
diff
changeset
|
5353 | 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
|
5354 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5355 | 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
|
5356 | 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
|
5357 | 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
|
5358 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5359 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5360 | G_DEFINE_DYNAMIC_TYPE_EXTENDED( |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5361 | mwProtocol, mw_protocol, PURPLE_TYPE_PROTOCOL, 0, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5362 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5363 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CLIENT, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5364 | mw_protocol_client_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5365 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5366 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_SERVER, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5367 | mw_protocol_server_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5368 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5369 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_IM, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5370 | mw_protocol_im_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5371 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5372 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CHAT, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5373 | mw_protocol_chat_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5374 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5375 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_PRIVACY, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5376 | mw_protocol_privacy_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5377 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5378 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_XFER, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5379 | 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
|
5380 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5381 | static PurpleProtocol * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5382 | mw_protocol_new(void) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5383 | return PURPLE_PROTOCOL(g_object_new( |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5384 | MW_TYPE_PROTOCOL, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5385 | "id", PROTOCOL_ID, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5386 | "name", PROTOCOL_NAME, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5387 | NULL)); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5388 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5389 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5390 | static PurplePluginInfo * |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5391 | plugin_query(GError **error) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5392 | { |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5393 | const gchar * const authors[] = PLUGIN_AUTHORS; |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5394 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5395 | 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
|
5396 | "id", PLUGIN_ID, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5397 | "name", PLUGIN_NAME, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5398 | "version", DISPLAY_VERSION, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5399 | "category", PLUGIN_CATEGORY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5400 | "summary", PLUGIN_SUMMARY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5401 | "description", PLUGIN_DESC, |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5402 | "authors", authors, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5403 | "website", PLUGIN_HOMEPAGE, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5404 | "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
|
5405 | "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
|
5406 | 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
|
5407 | NULL |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5408 | ); |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5409 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5410 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5411 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5412 | static gboolean |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5413 | plugin_load(PurplePlugin *plugin, GError **error) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5414 | { |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5415 | PurpleProtocolManager *manager = purple_protocol_manager_get_default(); |
| 36679 | 5416 | GLogLevelFlags logflags = |
| 5417 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5418 | ||
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5419 | mw_protocol_register_type(G_TYPE_MODULE(plugin)); |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5420 | |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
5421 | mw_xfer_register_type(G_TYPE_MODULE(plugin)); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
5422 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5423 | my_protocol = mw_protocol_new(); |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5424 | if(!purple_protocol_manager_register(manager, my_protocol, error)) { |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5425 | g_clear_object(&my_protocol); |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5426 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5427 | return FALSE; |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5428 | } |
| 10977 | 5429 | |
| 15884 | 5430 | /* forward all our g_log messages to purple. Generally all the logging |
| 5431 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5432 | get caught here */ |
| 5433 | 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
|
5434 | mw_log_handler, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5435 | |
| 15884 | 5436 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5437 | 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
|
5438 | 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
|
5439 | |
|
39526
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5440 | g_mime_init(); |
|
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5441 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5442 | return TRUE; |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5443 | } |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5444 | |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5445 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5446 | static gboolean |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5447 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5448 | { |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5449 | PurpleProtocolManager *manager = purple_protocol_manager_get_default(); |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5450 | |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5451 | if(!purple_protocol_manager_unregister(manager, my_protocol, error)) { |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5452 | return FALSE; |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5453 | } |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5454 | |
|
39526
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5455 | g_mime_shutdown(); |
|
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5456 | |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36660
diff
changeset
|
5457 | 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
|
5458 | 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
|
5459 | |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5460 | g_clear_object(&my_protocol); |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5461 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5462 | return TRUE; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5463 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5464 | |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5465 | |
|
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5466 | PURPLE_PLUGIN_INIT(sametime, plugin_query, plugin_load, plugin_unload); |
| 10977 | 5467 | /* The End. */ |
| 5468 |