Mon, 12 Sep 2022 22:08:59 -0500
Remove the list_icon vfunc from PurpleProtocol.
This was replaced by the icon-name, icon-resource-path, and icon-search-path
properties.
Testing Done:
Compiled
Reviewed at https://reviews.imfreedom.org/r/1749/
| 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 | |
|
40945
bbeb2e98ea5b
Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
38 | #include <gplugin.h> |
|
bbeb2e98ea5b
Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
39 | #include <gplugin-native.h> |
|
bbeb2e98ea5b
Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
40 | |
| 15884 | 41 | /* 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
|
42 | #include <purple.h> |
| 10977 | 43 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
44 | /* meanwhile includes */ |
| 10977 | 45 | #include <mw_cipher.h> |
| 46 | #include <mw_common.h> | |
| 47 | #include <mw_error.h> | |
| 48 | #include <mw_service.h> | |
| 49 | #include <mw_session.h> | |
| 50 | #include <mw_srvc_aware.h> | |
| 51 | #include <mw_srvc_conf.h> | |
| 52 | #include <mw_srvc_ft.h> | |
| 53 | #include <mw_srvc_im.h> | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
54 | #include <mw_srvc_place.h> |
| 10977 | 55 | #include <mw_srvc_resolve.h> |
| 56 | #include <mw_srvc_store.h> | |
| 57 | #include <mw_st_list.h> | |
| 58 | ||
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
59 | /* plugin includes */ |
| 10977 | 60 | #include "sametime.h" |
|
39523
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
61 | #include "im_mime.h" |
| 10977 | 62 | |
|
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
|
63 | 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
|
64 | 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
|
65 | }; |
| 10977 | 66 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
67 | static PurpleProtocol *my_protocol = NULL; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
68 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
69 | /* considering that there's no display of this information for protocols, |
| 10977 | 70 | I don't know why I even bother providing these. Oh valiant reader, |
| 71 | I do it all for you. */ | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
72 | /* 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
|
73 | #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
|
74 | #define PLUGIN_NAME "Sametime Protocol" |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
75 | #define PLUGIN_CATEGORY "Protocol" |
| 10977 | 76 | #define PLUGIN_SUMMARY "Sametime Protocol Plugin" |
| 77 | #define PLUGIN_DESC "Open implementation of a Lotus Sametime client" | |
| 78 | #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/" | |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
79 | #define PLUGIN_AUTHORS \ |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
80 | { "Christopher (siege) O'Brien <siege@preoccupied.net>", NULL } |
| 10977 | 81 | |
| 82 | ||
| 83 | /* plugin preference names */ | |
| 36984 | 84 | #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
|
85 | #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
|
86 | #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
|
87 | #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
|
88 | #define MW_PROTOCOL_OPT_SAVE_DYNAMIC MW_PROTOCOL_OPT_BASE "/save_dynamic" |
| 10977 | 89 | |
| 90 | ||
| 91 | /* stages of connecting-ness */ | |
|
13779
410869639392
[gaim-migrate @ 16189]
Christopher O'Brien <siege@pidgin.im>
parents:
13713
diff
changeset
|
92 | #define MW_CONNECT_STEPS 11 |
| 10977 | 93 | |
| 94 | ||
|
41084
72d6941bfa2e
Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41078
diff
changeset
|
95 | /* stages of consciousness */ |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
96 | #define MW_STATE_OFFLINE "offline" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
97 | #define MW_STATE_ACTIVE "active" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
98 | #define MW_STATE_AWAY "away" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
99 | #define MW_STATE_BUSY "dnd" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
100 | #define MW_STATE_MESSAGE "message" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
101 | #define MW_STATE_ENLIGHTENED "buddha" |
| 10977 | 102 | |
| 103 | ||
| 104 | /* keys to get/set chat information */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
105 | #define CHAT_KEY_CREATOR "chat.creator" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
106 | #define CHAT_KEY_NAME "chat.name" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
107 | #define CHAT_KEY_TOPIC "chat.topic" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
108 | #define CHAT_KEY_INVITE "chat.invite" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
109 | #define CHAT_KEY_IS_PLACE "chat.is_place" |
| 10977 | 110 | |
| 111 | ||
| 112 | /* key for associating a mwLoginType with a buddy */ | |
| 113 | #define BUDDY_KEY_CLIENT "meanwhile.client" | |
| 114 | ||
| 115 | /* store the remote alias so that we can re-create it easily */ | |
| 116 | #define BUDDY_KEY_NAME "meanwhile.shortname" | |
| 117 | ||
| 118 | /* enum mwSametimeUserType */ | |
| 119 | #define BUDDY_KEY_TYPE "meanwhile.type" | |
| 120 | ||
| 121 | ||
| 122 | /* key for the real group name for a meanwhile group */ | |
| 123 | #define GROUP_KEY_NAME "meanwhile.group" | |
| 124 | ||
| 125 | /* enum mwSametimeGroupType */ | |
| 126 | #define GROUP_KEY_TYPE "meanwhile.type" | |
| 127 | ||
| 128 | /* NAB group owning account */ | |
| 129 | #define GROUP_KEY_OWNER "meanwhile.account" | |
| 130 | ||
| 131 | /* key gtk blist uses to indicate a collapsed group */ | |
| 132 | #define GROUP_KEY_COLLAPSED "collapsed" | |
| 133 | ||
| 134 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
135 | /* verification replacement */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
136 | #define mwSession_NO_SECRET "meanwhile.no_secret" |
| 10977 | 137 | |
| 138 | ||
| 15884 | 139 | /* keys to get/set purple plugin information */ |
| 10977 | 140 | #define MW_KEY_HOST "server" |
| 141 | #define MW_KEY_PORT "port" | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
142 | #define MW_KEY_FORCE "force_login" |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
143 | #define MW_KEY_FAKE_IT "fake_client_id" |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
144 | #define MW_KEY_CLIENT "client_id_val" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
145 | #define MW_KEY_MAJOR "client_major" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
146 | #define MW_KEY_MINOR "client_minor" |
| 10977 | 147 | |
| 148 | ||
| 149 | /** number of seconds from the first blist change before a save to the | |
| 150 | storage service occurs. */ | |
| 151 | #define BLIST_SAVE_SECONDS 15 | |
| 152 | ||
| 153 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
154 | /** the possible buddy list storage settings */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
155 | enum blist_choice { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
156 | blist_choice_LOCAL = 1, /**< local only */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
157 | blist_choice_MERGE = 2, /**< merge from server */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
158 | 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
|
159 | blist_choice_SYNCH = 4 /**< sync with server */ |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
160 | }; |
| 10977 | 161 | |
| 162 | ||
| 163 | /** the default blist storage option */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
164 | #define BLIST_CHOICE_DEFAULT blist_choice_SYNCH |
| 10977 | 165 | |
| 166 | ||
| 167 | /* testing for the above */ | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
168 | #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
|
169 | #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
|
170 | #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
|
171 | #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
|
172 | #define BLIST_PREF_IS_SYNCH() BLIST_PREF_IS(blist_choice_SYNCH) |
| 10977 | 173 | |
| 174 | ||
| 175 | /* 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
|
176 | #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
|
177 | #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
|
178 | #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
|
179 | #define DEBUG_WARN(...) purple_debug_warning(G_LOG_DOMAIN, __VA_ARGS__) |
| 10977 | 180 | |
| 181 | ||
| 182 | /** calibrates distinct secure channel nomenclature */ | |
| 183 | static const unsigned char no_secret[] = { | |
| 184 | 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65, | |
| 185 | 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a, | |
| 186 | 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64, | |
| 187 | 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00, | |
| 188 | }; | |
| 189 | ||
| 190 | ||
| 191 | /** handler IDs from g_log_set_handler in mw_plugin_init */ | |
| 192 | static guint log_handler[2] = { 0, 0 }; | |
| 193 | ||
| 194 | ||
| 15884 | 195 | /** 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
|
196 | 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
|
197 | struct mwPurpleProtocolData { |
| 10977 | 198 | struct mwSession *session; |
| 199 | ||
| 200 | struct mwServiceAware *srvc_aware; | |
| 201 | struct mwServiceConference *srvc_conf; | |
| 202 | struct mwServiceFileTransfer *srvc_ft; | |
| 203 | struct mwServiceIm *srvc_im; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
204 | struct mwServicePlace *srvc_place; |
| 10977 | 205 | struct mwServiceResolve *srvc_resolve; |
| 206 | struct mwServiceStorage *srvc_store; | |
| 207 | ||
| 15884 | 208 | /** map of PurpleGroup:mwAwareList and mwAwareList:PurpleGroup */ |
| 10977 | 209 | GHashTable *group_list_map; |
| 210 | ||
| 211 | /** event id for the buddy list save callback */ | |
| 212 | guint save_event; | |
| 213 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
214 | GCancellable *cancellable; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
215 | GSocketClient *client; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
216 | GIOStream *stream; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
217 | GInputStream *input; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
218 | PurpleQueuedOutputStream *output; |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
219 | guint inpa; /* input watcher */ |
| 15884 | 220 | |
| 221 | PurpleConnection *gc; | |
| 10977 | 222 | }; |
| 223 | ||
| 224 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
225 | typedef struct { |
| 15884 | 226 | PurpleBuddy *buddy; |
| 227 | PurpleGroup *group; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
228 | } BuddyAddData; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
229 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
230 | |
| 10977 | 231 | /* blist and aware functions */ |
| 232 | ||
| 15884 | 233 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist); |
| 234 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
235 | 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
|
236 | |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
237 | static void blist_schedule(struct mwPurpleProtocolData *pd); |
| 15884 | 238 | |
| 239 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 240 | ||
| 241 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 242 | ||
| 243 | static gboolean buddy_is_external(PurpleBuddy *b); | |
| 244 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
245 | static void buddy_add(struct mwPurpleProtocolData *pd, PurpleBuddy *buddy); |
| 15884 | 246 | |
| 247 | static PurpleBuddy * | |
| 248 | buddy_ensure(PurpleConnection *gc, PurpleGroup *group, | |
| 10977 | 249 | struct mwSametimeUser *stuser); |
| 250 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
251 | static void group_add(struct mwPurpleProtocolData *pd, PurpleGroup *group); |
| 15884 | 252 | |
| 253 | static PurpleGroup * | |
| 254 | group_ensure(PurpleConnection *gc, struct mwSametimeGroup *stgroup); | |
| 10977 | 255 | |
| 256 | static struct mwAwareList * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
257 | list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group); |
| 10977 | 258 | |
| 259 | ||
| 260 | /* session functions */ | |
| 261 | ||
| 262 | static struct mwSession * | |
| 15884 | 263 | gc_to_session(PurpleConnection *gc); |
| 264 | ||
| 265 | static PurpleConnection *session_to_gc(struct mwSession *session); | |
| 10977 | 266 | |
| 267 | ||
| 268 | /* conference functions */ | |
| 269 | ||
| 270 | static struct mwConference * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
271 | conf_find_by_id(struct mwPurpleProtocolData *pd, int id); |
| 10977 | 272 | |
| 273 | ||
| 274 | /* conversation functions */ | |
| 275 | ||
| 276 | struct convo_msg { | |
| 277 | enum mwImSendType type; | |
| 278 | gpointer data; | |
| 279 | GDestroyNotify clear; | |
| 280 | }; | |
| 281 | ||
| 282 | ||
| 283 | struct convo_data { | |
| 284 | struct mwConversation *conv; | |
| 285 | GList *queue; /**< outgoing message queue, list of convo_msg */ | |
| 286 | }; | |
| 287 | ||
| 288 | static void convo_data_new(struct mwConversation *conv); | |
| 289 | ||
| 290 | static void convo_data_free(struct convo_data *conv); | |
| 291 | ||
| 292 | static void convo_features(struct mwConversation *conv); | |
| 293 | ||
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
294 | static PurpleConversation *convo_get_im(struct mwConversation *conv); |
| 10977 | 295 | |
| 296 | ||
|
12629
14aae7d5da6b
[gaim-migrate @ 14965]
Richard Laager <rlaager@pidgin.im>
parents:
12624
diff
changeset
|
297 | /* name and id */ |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
298 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
299 | struct named_id { |
| 10977 | 300 | char *id; |
| 301 | char *name; | |
| 302 | }; | |
| 303 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
304 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
305 | /* connection functions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
306 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
307 | 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
|
308 | |
| 10977 | 309 | |
| 310 | /* ----- session ------ */ | |
| 311 | ||
| 312 | ||
| 15884 | 313 | /** resolves a mwSession from a PurpleConnection */ |
| 314 | 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
|
315 | struct mwPurpleProtocolData *pd; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
316 | |
| 10977 | 317 | g_return_val_if_fail(gc != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
318 | |
|
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
|
319 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 320 | g_return_val_if_fail(pd != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
321 | |
| 10977 | 322 | return pd->session; |
| 323 | } | |
| 324 | ||
| 325 | ||
| 15884 | 326 | /** resolves a PurpleConnection from a mwSession */ |
| 327 | 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
|
328 | struct mwPurpleProtocolData *pd; |
| 10977 | 329 | |
| 330 | g_return_val_if_fail(session != NULL, NULL); | |
| 331 | ||
| 332 | pd = mwSession_getClientData(session); | |
| 333 | g_return_val_if_fail(pd != NULL, NULL); | |
| 334 | ||
| 335 | return pd->gc; | |
| 336 | } | |
| 337 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
338 | static void |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
339 | 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
|
340 | { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
341 | 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
|
342 | struct mwPurpleProtocolData *pd = data; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
343 | GError *error = NULL; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
344 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
345 | DEBUG_INFO("write_cb\n"); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
346 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
347 | 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
|
348 | purple_queued_output_stream_clear_queue(stream); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
349 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
350 | if (error->code != G_IO_ERROR_CANCELLED) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
351 | 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
|
352 | purple_connection_take_error(pd->gc, error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
353 | } else { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
354 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
355 | } |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
356 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
357 | } |
|
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 | |
| 10977 | 360 | static int mw_session_io_write(struct mwSession *session, |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
361 | const guchar *buf, gsize len) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
362 | struct mwPurpleProtocolData *pd; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
363 | GBytes *output; |
| 10977 | 364 | |
| 365 | pd = mwSession_getClientData(session); | |
| 366 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
367 | /* the session was already closed. */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
368 | if (pd->stream == NULL) { |
| 10977 | 369 | return 1; |
| 370 | } | |
| 371 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
372 | output = g_bytes_new(buf, len); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
373 | purple_queued_output_stream_push_bytes_async( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
374 | 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
|
375 | write_cb, pd); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
376 | g_bytes_unref(output); |
| 10977 | 377 | |
| 378 | return 0; | |
| 379 | } | |
| 380 | ||
| 381 | ||
| 382 | 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
|
383 | struct mwPurpleProtocolData *pd; |
| 10977 | 384 | |
| 385 | pd = mwSession_getClientData(session); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
386 | g_return_if_fail(pd != NULL); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
387 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
388 | g_cancellable_cancel(pd->cancellable); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
389 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
390 | if (pd->stream) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
391 | if (pd->inpa) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
392 | purple_input_remove(pd->inpa); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
393 | pd->inpa = 0; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
394 | } |
|
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 | 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
|
397 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
398 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
399 | pd->input = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
400 | g_clear_object(&pd->output); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
401 | g_clear_object(&pd->stream); |
| 10977 | 402 | } |
| 403 | ||
| 404 | ||
| 405 | static void mw_session_clear(struct mwSession *session) { | |
| 406 | ; /* nothing for now */ | |
| 407 | } | |
| 408 | ||
| 409 | ||
| 410 | /* ----- aware list ----- */ | |
| 411 | ||
| 412 | ||
| 413 | static void blist_resolve_alias_cb(struct mwServiceResolve *srvc, | |
| 414 | guint32 id, guint32 code, GList *results, | |
| 415 | gpointer data) { | |
| 416 | struct mwResolveResult *result; | |
| 417 | struct mwResolveMatch *match; | |
| 418 | ||
| 419 | g_return_if_fail(results != NULL); | |
| 420 | ||
| 421 | result = results->data; | |
| 422 | g_return_if_fail(result != NULL); | |
| 423 | g_return_if_fail(result->matches != NULL); | |
| 424 | ||
| 425 | match = result->matches->data; | |
| 426 | g_return_if_fail(match != NULL); | |
| 427 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
428 | purple_buddy_set_server_alias(data, match->name); |
| 15884 | 429 | purple_blist_node_set_string(data, BUDDY_KEY_NAME, match->name); |
| 10977 | 430 | } |
| 431 | ||
| 432 | ||
| 433 | static void mw_aware_list_on_aware(struct mwAwareList *list, | |
| 434 | struct mwAwareSnapshot *aware) { | |
| 435 | ||
| 15884 | 436 | PurpleConnection *gc; |
| 437 | PurpleAccount *acct; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
438 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
439 | struct mwPurpleProtocolData *pd; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
440 | guint32 idle; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
441 | guint stat; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
442 | const char *id; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
443 | const char *status = MW_STATE_ACTIVE; |
| 10977 | 444 | |
| 445 | gc = mwAwareList_getClientData(list); | |
| 15884 | 446 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
447 | |
|
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
|
448 | pd = purple_connection_get_protocol_data(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
449 | idle = aware->status.time; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
450 | stat = aware->status.status; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
451 | id = aware->id.user; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
452 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
453 | if(idle) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
454 | guint32 idle_len; /*< how long a client has been idle */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
455 | 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
|
456 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
457 | 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
|
458 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
459 | idle_len = time(NULL) - idle; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
460 | ugly_idle_len = ((time(NULL) * 1000) - idle) / 1000; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
461 | |
|
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
|
462 | 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
|
463 | 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
|
464 | 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
|
465 | 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
|
466 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
467 | /* |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
468 | 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
|
469 | 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
|
470 | 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
|
471 | 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
|
472 | 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
|
473 | 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
|
474 | this. |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
475 | */ |
|
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 | 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
|
478 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
479 | #if 1 |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
480 | if(idle_len <= ugly_idle_len) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
481 | ; /* DEBUG_INFO("sane idle value, let's use it\n"); */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
482 | } else { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
483 | idle = time(NULL) - ugly_idle_len; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
484 | } |
|
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 | #else |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
487 | if(idle < 0 || idle > time(NULL)) { |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
488 | 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
|
489 | idle = -1; |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
490 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
491 | #endif |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
492 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
493 | |
| 10977 | 494 | switch(stat) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
495 | case mwStatus_ACTIVE: |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
496 | status = MW_STATE_ACTIVE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
497 | idle = 0; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
498 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
499 | |
| 10977 | 500 | case mwStatus_IDLE: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
501 | if(! idle) idle = -1; |
| 10977 | 502 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
503 | |
| 10977 | 504 | case mwStatus_AWAY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
505 | status = MW_STATE_AWAY; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
506 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
507 | |
| 10977 | 508 | case mwStatus_BUSY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
509 | status = MW_STATE_BUSY; |
| 10977 | 510 | break; |
| 511 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
512 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
513 | /* NAB group members */ |
| 10977 | 514 | if(aware->group) { |
| 15884 | 515 | PurpleGroup *group; |
| 516 | PurpleBuddy *buddy; | |
| 517 | PurpleBlistNode *bnode; | |
| 10977 | 518 | |
| 519 | 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
|
520 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 15884 | 521 | bnode = (PurpleBlistNode *) buddy; |
| 10977 | 522 | |
| 523 | if(! buddy) { | |
| 524 | struct mwServiceResolve *srvc; | |
| 525 | GList *query; | |
| 526 | ||
| 15884 | 527 | buddy = purple_buddy_new(acct, id, NULL); |
| 528 | purple_blist_add_buddy(buddy, NULL, group, NULL); | |
| 529 | ||
| 530 | bnode = (PurpleBlistNode *) buddy; | |
| 10977 | 531 | |
| 532 | srvc = pd->srvc_resolve; | |
| 533 | query = g_list_append(NULL, (char *) id); | |
| 534 | ||
| 535 | mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS, | |
| 536 | blist_resolve_alias_cb, buddy, NULL); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
537 | g_list_free(query); |
| 10977 | 538 | } |
| 539 | ||
| 15884 | 540 | purple_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL); |
| 10977 | 541 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
542 | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
543 | if(aware->online) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
544 | 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
|
545 | 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
|
546 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
547 | } else { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
548 | 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
|
549 | } |
| 10977 | 550 | } |
| 551 | ||
| 552 | ||
| 553 | static void mw_aware_list_on_attrib(struct mwAwareList *list, | |
| 554 | struct mwAwareIdBlock *id, | |
| 555 | struct mwAwareAttribute *attrib) { | |
| 556 | ||
| 557 | ; /* nothing. We'll get attribute data as we need it */ | |
| 558 | } | |
| 559 | ||
| 560 | ||
| 561 | static void mw_aware_list_clear(struct mwAwareList *list) { | |
| 562 | ; /* nothing for now */ | |
| 563 | } | |
| 564 | ||
| 565 | ||
| 566 | static struct mwAwareListHandler mw_aware_list_handler = { | |
|
17157
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
567 | mw_aware_list_on_aware, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
568 | mw_aware_list_on_attrib, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
569 | mw_aware_list_clear, |
| 10977 | 570 | }; |
| 571 | ||
| 572 | ||
| 573 | /** Ensures that an Aware List is associated with the given group, and | |
| 574 | returns that list. */ | |
| 575 | static struct mwAwareList * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
576 | list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
577 | |
| 10977 | 578 | struct mwAwareList *list; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
579 | |
| 10977 | 580 | g_return_val_if_fail(pd != NULL, NULL); |
| 581 | g_return_val_if_fail(group != NULL, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
582 | |
| 10977 | 583 | list = g_hash_table_lookup(pd->group_list_map, group); |
| 584 | if(! list) { | |
| 585 | list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler); | |
| 586 | mwAwareList_setClientData(list, pd->gc, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
587 | |
| 10977 | 588 | mwAwareList_watchAttributes(list, |
| 589 | mwAttribute_AV_PREFS_SET, | |
| 590 | mwAttribute_MICROPHONE, | |
| 591 | mwAttribute_SPEAKERS, | |
| 592 | mwAttribute_VIDEO_CAMERA, | |
| 593 | mwAttribute_FILE_TRANSFER, | |
| 594 | NULL); | |
| 595 | ||
| 596 | g_hash_table_replace(pd->group_list_map, group, list); | |
| 597 | g_hash_table_insert(pd->group_list_map, list, group); | |
| 598 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
599 | |
| 10977 | 600 | return list; |
| 601 | } | |
| 602 | ||
| 603 | ||
| 15884 | 604 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 10977 | 605 | /* - find the account for this connection |
| 606 | - iterate through the buddy list | |
| 607 | - add each buddy matching this account to the stlist | |
| 608 | */ | |
| 609 | ||
| 15884 | 610 | PurpleAccount *acct; |
| 611 | PurpleBlistNode *gn, *cn, *bn; | |
| 612 | PurpleGroup *grp; | |
| 613 | PurpleBuddy *bdy; | |
| 10977 | 614 | |
| 615 | struct mwSametimeGroup *stg = NULL; | |
| 616 | struct mwIdBlock idb = { NULL, NULL }; | |
| 617 | ||
| 15884 | 618 | acct = purple_connection_get_account(gc); |
| 10977 | 619 | g_return_if_fail(acct != NULL); |
| 620 | ||
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
621 | 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
|
622 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 10977 | 623 | const char *owner; |
| 624 | const char *gname; | |
| 625 | enum mwSametimeGroupType gtype; | |
| 626 | gboolean gopen; | |
| 627 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
628 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 629 | grp = (PurpleGroup *) gn; |
| 10977 | 630 | |
| 631 | /* the group's type (normal or dynamic) */ | |
| 15884 | 632 | gtype = purple_blist_node_get_int(gn, GROUP_KEY_TYPE); |
| 10977 | 633 | if(! gtype) gtype = mwSametimeGroup_NORMAL; |
| 634 | ||
| 635 | /* if it's a normal group with none of our people in it, skip it */ | |
| 15884 | 636 | if(gtype == mwSametimeGroup_NORMAL && !purple_group_on_account(grp, acct)) |
| 10977 | 637 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
638 | |
| 10977 | 639 | /* if the group has an owner and we're not it, skip it */ |
| 15884 | 640 | 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
|
641 | if(owner && !purple_strequal(owner, purple_account_get_username(acct))) |
| 10977 | 642 | continue; |
| 643 | ||
| 15884 | 644 | /* the group's actual name may be different from the purple group's |
| 10977 | 645 | name. Find whichever is there */ |
| 15884 | 646 | 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
|
647 | if(! gname) gname = purple_group_get_name(grp); |
| 10977 | 648 | |
| 649 | /* we save this, but never actually honor it */ | |
| 15884 | 650 | gopen = ! purple_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); |
| 10977 | 651 | |
| 652 | 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
|
653 | mwSametimeGroup_setAlias(stg, purple_group_get_name(grp)); |
| 10977 | 654 | mwSametimeGroup_setOpen(stg, gopen); |
| 655 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
656 | /* 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
|
657 | other clients */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
658 | if(gtype == mwSametimeGroup_DYNAMIC) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
659 | continue; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
660 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
661 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
662 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
663 | 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
|
664 | if(! PURPLE_IS_CONTACT(cn)) continue; |
| 10977 | 665 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
666 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
667 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
668 | 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
|
669 | 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
|
670 | if(purple_blist_node_is_transient(bn)) continue; |
| 15884 | 671 | |
| 672 | bdy = (PurpleBuddy *) bn; | |
| 10977 | 673 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
674 | if(purple_buddy_get_account(bdy) == acct) { |
| 10977 | 675 | struct mwSametimeUser *stu; |
| 676 | enum mwSametimeUserType utype; | |
| 677 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
678 | idb.user = (char *)purple_buddy_get_name(bdy); |
| 10977 | 679 | |
| 15884 | 680 | utype = purple_blist_node_get_int(bn, BUDDY_KEY_TYPE); |
| 10977 | 681 | if(! utype) utype = mwSametimeUser_NORMAL; |
| 682 | ||
| 683 | 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
|
684 | 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
|
685 | mwSametimeUser_setAlias(stu, purple_buddy_get_local_alias(bdy)); |
| 10977 | 686 | } |
| 687 | } | |
| 688 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
689 | } |
| 10977 | 690 | } |
| 691 | ||
| 692 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
693 | static void blist_store(struct mwPurpleProtocolData *pd) { |
| 10977 | 694 | |
| 695 | struct mwSametimeList *stlist; | |
| 696 | struct mwServiceStorage *srvc; | |
| 697 | struct mwStorageUnit *unit; | |
| 698 | ||
| 15884 | 699 | PurpleConnection *gc; |
| 10977 | 700 | |
| 701 | struct mwPutBuffer *b; | |
| 702 | struct mwOpaque *o; | |
| 703 | ||
| 704 | g_return_if_fail(pd != NULL); | |
| 705 | ||
| 706 | srvc = pd->srvc_store; | |
| 707 | g_return_if_fail(srvc != NULL); | |
| 708 | ||
| 709 | gc = pd->gc; | |
| 710 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
711 | if(BLIST_PREF_IS_LOCAL() || BLIST_PREF_IS_MERGE()) { |
| 10977 | 712 | DEBUG_INFO("preferences indicate not to save remote blist\n"); |
| 713 | return; | |
| 714 | ||
| 715 | } else if(MW_SERVICE_IS_DEAD(srvc)) { | |
| 716 | DEBUG_INFO("aborting save of blist: storage service is not alive\n"); | |
| 717 | return; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
718 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
719 | } else if(BLIST_PREF_IS_STORE() || BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
720 | DEBUG_INFO("saving remote blist\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
721 | |
| 10977 | 722 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
723 | g_return_if_reached(); |
| 10977 | 724 | } |
| 725 | ||
| 726 | /* create and export to a list object */ | |
| 727 | stlist = mwSametimeList_new(); | |
| 728 | blist_export(gc, stlist); | |
| 729 | ||
| 730 | /* write it to a buffer */ | |
| 731 | b = mwPutBuffer_new(); | |
| 732 | mwSametimeList_put(b, stlist); | |
| 733 | mwSametimeList_free(stlist); | |
| 734 | ||
| 735 | /* put the buffer contents into a storage unit */ | |
| 736 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
| 737 | o = mwStorageUnit_asOpaque(unit); | |
| 738 | mwPutBuffer_finalize(o, b); | |
| 739 | ||
| 740 | /* save the storage unit to the service */ | |
| 741 | mwServiceStorage_save(srvc, unit, NULL, NULL, NULL); | |
| 742 | } | |
| 743 | ||
| 744 | ||
| 745 | 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
|
746 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 747 | |
| 748 | blist_store(pd); | |
| 749 | pd->save_event = 0; | |
| 750 | return FALSE; | |
| 751 | } | |
| 752 | ||
| 753 | ||
| 754 | /** 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
|
755 | static void blist_schedule(struct mwPurpleProtocolData *pd) { |
| 10977 | 756 | if(pd->save_event) return; |
| 757 | ||
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
758 | pd->save_event = g_timeout_add_seconds(BLIST_SAVE_SECONDS, |
| 10977 | 759 | blist_save_cb, pd); |
| 760 | } | |
| 761 | ||
| 762 | ||
| 15884 | 763 | static gboolean buddy_is_external(PurpleBuddy *b) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
764 | 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
|
765 | 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
|
766 | } |
|
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 | |
| 10977 | 769 | /** Actually add a buddy to the aware service, and schedule the buddy |
| 770 | 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
|
771 | static void buddy_add(struct mwPurpleProtocolData *pd, |
| 15884 | 772 | PurpleBuddy *buddy) { |
| 10977 | 773 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
774 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) purple_buddy_get_name(buddy), NULL }; |
| 10977 | 775 | struct mwAwareList *list; |
| 776 | ||
| 15884 | 777 | PurpleGroup *group; |
| 10977 | 778 | GList *add; |
| 779 | ||
| 780 | add = g_list_prepend(NULL, &idb); | |
| 781 | ||
| 15884 | 782 | group = purple_buddy_get_group(buddy); |
| 10977 | 783 | list = list_ensure(pd, group); |
| 784 | ||
| 785 | if(mwAwareList_addAware(list, add)) { | |
| 15884 | 786 | purple_blist_remove_buddy(buddy); |
| 10977 | 787 | } |
| 788 | ||
| 789 | blist_schedule(pd); | |
| 790 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
791 | g_list_free(add); |
| 10977 | 792 | } |
| 793 | ||
| 794 | ||
| 15884 | 795 | /** ensure that a PurpleBuddy exists in the group with data |
| 10977 | 796 | appropriately matching the st user entry from the st list */ |
| 15884 | 797 | static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, |
| 10977 | 798 | struct mwSametimeUser *stuser) { |
| 799 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
800 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 801 | PurpleBuddy *buddy; |
| 802 | PurpleAccount *acct = purple_connection_get_account(gc); | |
| 10977 | 803 | |
| 804 | const char *id = mwSametimeUser_getUser(stuser); | |
| 805 | const char *name = mwSametimeUser_getShortName(stuser); | |
| 806 | const char *alias = mwSametimeUser_getAlias(stuser); | |
| 807 | enum mwSametimeUserType type = mwSametimeUser_getType(stuser); | |
| 808 | ||
| 809 | 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
|
810 | g_return_val_if_fail(*id, NULL); |
| 10977 | 811 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
812 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 10977 | 813 | if(! buddy) { |
| 15884 | 814 | buddy = purple_buddy_new(acct, id, alias); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
815 | |
| 15884 | 816 | purple_blist_add_buddy(buddy, NULL, group, NULL); |
| 10977 | 817 | buddy_add(pd, buddy); |
| 818 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
819 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
820 | 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
|
821 | purple_buddy_set_server_alias(buddy, name); |
| 15884 | 822 | purple_blist_node_set_string((PurpleBlistNode *) buddy, BUDDY_KEY_NAME, name); |
| 823 | purple_blist_node_set_int((PurpleBlistNode *) buddy, BUDDY_KEY_TYPE, type); | |
| 10977 | 824 | |
| 825 | return buddy; | |
| 826 | } | |
| 827 | ||
| 828 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
829 | /** 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
|
830 | static void group_add(struct mwPurpleProtocolData *pd, |
| 15884 | 831 | PurpleGroup *group) { |
| 10977 | 832 | |
| 833 | struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL }; | |
| 834 | struct mwAwareList *list; | |
| 835 | const char *n; | |
| 836 | GList *add; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
837 | |
| 15884 | 838 | 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
|
839 | if(! n) n = purple_group_get_name(group); |
| 10977 | 840 | |
| 841 | idb.user = (char *) n; | |
| 842 | add = g_list_prepend(NULL, &idb); | |
| 843 | ||
| 844 | list = list_ensure(pd, group); | |
| 845 | mwAwareList_addAware(list, add); | |
| 846 | g_list_free(add); | |
| 847 | } | |
| 848 | ||
| 849 | ||
| 15884 | 850 | /** ensure that a PurpleGroup exists in the blist with data |
| 10977 | 851 | appropriately matching the st group entry from the st list */ |
| 15884 | 852 | static PurpleGroup *group_ensure(PurpleConnection *gc, |
| 10977 | 853 | struct mwSametimeGroup *stgroup) { |
| 15884 | 854 | PurpleAccount *acct; |
| 855 | PurpleGroup *group = NULL; | |
| 856 | PurpleBuddyList *blist; | |
| 857 | PurpleBlistNode *gn; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
858 | const char *name, *alias, *owner; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
859 | enum mwSametimeGroupType type; |
| 10977 | 860 | |
| 15884 | 861 | acct = purple_connection_get_account(gc); |
| 862 | owner = purple_account_get_username(acct); | |
| 863 | ||
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
864 | blist = purple_blist_get_default(); |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
865 | g_return_val_if_fail(blist != NULL, NULL); |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
866 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
867 | name = mwSametimeGroup_getName(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
868 | alias = mwSametimeGroup_getAlias(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
869 | type = mwSametimeGroup_getType(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
870 | |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
871 | if (!name) { |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
872 | DEBUG_WARN("Can't ensure a null group\n"); |
|
31991
efe4fb3772ad
Fix this compile warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
31983
diff
changeset
|
873 | return NULL; |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
874 | } |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
875 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
876 | 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
|
877 | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
878 | /* 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
|
879 | 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
|
880 | gn = purple_blist_node_get_sibling_next(gn)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
881 | const char *n, *o; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
882 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 883 | n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
| 884 | 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
|
885 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
886 | 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
|
887 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
888 | if(n && purple_strequal(n, name)) { |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
889 | if(!o || purple_strequal(o, owner)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
890 | DEBUG_INFO("that'll work\n"); |
| 15884 | 891 | group = (PurpleGroup *) gn; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
892 | break; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
893 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
894 | } |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
895 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
896 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
897 | /* try again, by alias */ |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
898 | if(! group) { |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
899 | 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
|
900 | group = purple_blist_find_group(alias); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
901 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
902 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
903 | /* oh well, no such group. Let's create it! */ |
| 10977 | 904 | if(! group) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
905 | DEBUG_INFO("creating group\n"); |
| 15884 | 906 | group = purple_group_new(alias); |
| 907 | purple_blist_add_group(group, NULL); | |
| 10977 | 908 | } |
| 909 | ||
| 15884 | 910 | gn = (PurpleBlistNode *) group; |
| 911 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); | |
| 912 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | |
| 10977 | 913 | |
| 914 | if(type == mwSametimeGroup_DYNAMIC) { | |
| 15884 | 915 | 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
|
916 | group_add(purple_connection_get_protocol_data(gc), group); |
| 10977 | 917 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
918 | |
| 10977 | 919 | return group; |
| 920 | } | |
| 921 | ||
| 922 | ||
| 15884 | 923 | /** merge the entries from a st list into the purple blist */ |
| 924 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist) { | |
| 10977 | 925 | struct mwSametimeGroup *stgroup; |
| 926 | struct mwSametimeUser *stuser; | |
| 927 | ||
| 15884 | 928 | PurpleGroup *group; |
| 10977 | 929 | |
| 930 | GList *gl, *gtl, *ul, *utl; | |
| 931 | ||
| 932 | gl = gtl = mwSametimeList_getGroups(stlist); | |
| 933 | for(; gl; gl = gl->next) { | |
| 934 | ||
| 935 | stgroup = (struct mwSametimeGroup *) gl->data; | |
| 936 | group = group_ensure(gc, stgroup); | |
| 937 | ||
| 938 | ul = utl = mwSametimeGroup_getUsers(stgroup); | |
| 939 | for(; ul; ul = ul->next) { | |
| 940 | ||
| 941 | stuser = (struct mwSametimeUser *) ul->data; | |
|
33782
1690e0b2c508
Fix a bunch of unused variables
Daniel Atallah <datallah@pidgin.im>
parents:
33745
diff
changeset
|
942 | buddy_ensure(gc, group, stuser); |
| 10977 | 943 | } |
| 944 | g_list_free(utl); | |
| 945 | } | |
| 946 | g_list_free(gtl); | |
| 947 | } | |
| 948 | ||
| 949 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
950 | /** 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
|
951 | is left empty, remove group as well */ |
| 15884 | 952 | static void group_clear(PurpleGroup *group, PurpleAccount *acct, gboolean del) { |
| 953 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
954 | GList *prune = NULL; |
| 15884 | 955 | PurpleBlistNode *gn, *cn, *bn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
956 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
957 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
958 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
959 | 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
|
960 | |
| 15884 | 961 | gc = purple_account_get_connection(acct); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
962 | g_return_if_fail(gc != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
963 | |
| 15884 | 964 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
965 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
966 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
967 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
968 | 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
|
969 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
970 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
971 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
972 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
973 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 974 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 975 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
976 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
977 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
978 | if(purple_buddy_get_account(gb) == acct) { |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
979 | 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
|
980 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
981 | } |
|
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 | /* quickly unsubscribe from presence for the entire group */ |
| 15884 | 986 | purple_account_remove_group(acct, group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
987 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
988 | /* remove blist entries that need to go */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
989 | while(prune) { |
| 15884 | 990 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
991 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
992 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
993 | DEBUG_INFO("cleared buddies\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
994 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
995 | /* 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
|
996 | 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
|
997 | DEBUG_INFO("removing empty group\n"); |
| 15884 | 998 | purple_blist_remove_group(group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
999 | } |
|
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 | /** prune out group members that shouldn't be there */ |
| 15884 | 1004 | static void group_prune(PurpleConnection *gc, PurpleGroup *group, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1005 | struct mwSametimeGroup *stgroup) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1006 | |
| 15884 | 1007 | PurpleAccount *acct; |
| 1008 | PurpleBlistNode *gn, *cn, *bn; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1009 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1010 | GHashTable *stusers; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1011 | GList *prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1012 | GList *ul, *utl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1013 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1014 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1015 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1016 | 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
|
1017 | |
| 15884 | 1018 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1019 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1020 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1021 | 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
|
1022 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1023 | /* 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
|
1024 | contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1025 | utl = mwSametimeGroup_getUsers(stgroup); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1026 | for(ul = utl; ul; ul = ul->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1027 | const char *id = mwSametimeUser_getUser(ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1028 | 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
|
1029 | DEBUG_INFO("server copy has %s\n", id); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1030 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1031 | g_list_free(utl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1032 | |
| 15884 | 1033 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1034 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1035 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1036 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1037 | 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
|
1038 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1039 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1040 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1041 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1042 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1043 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1044 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1045 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1046 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1047 | /* 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
|
1048 | them for pruning */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1049 | 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
|
1050 | 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
|
1051 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1052 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1053 | } |
|
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 | DEBUG_INFO("done marking\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1056 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1057 | g_hash_table_destroy(stusers); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1058 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1059 | if(prune) { |
| 15884 | 1060 | purple_account_remove_buddies(acct, prune, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1061 | while(prune) { |
| 15884 | 1062 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1063 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1064 | } |
|
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 | |
| 15884 | 1069 | /** 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
|
1070 | existing buddies that aren't in the st list */ |
| 15884 | 1071 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 1072 | ||
| 1073 | PurpleAccount *acct; | |
| 1074 | PurpleBuddyList *blist; | |
| 1075 | PurpleBlistNode *gn; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1076 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1077 | GHashTable *stgroups; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1078 | GList *g_prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1079 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1080 | GList *gl, *gtl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1081 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1082 | const char *acct_n; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1083 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1084 | DEBUG_INFO("synchronizing local buddy list from server list\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1085 | |
| 15884 | 1086 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1087 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1088 | |
| 15884 | 1089 | acct_n = purple_account_get_username(acct); |
| 1090 | ||
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1091 | blist = purple_blist_get_default(); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1092 | g_return_if_fail(blist != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1093 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1094 | /* 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
|
1095 | list, mapping group name to group structure */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1096 | 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
|
1097 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1098 | gtl = mwSametimeList_getGroups(stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1099 | for(gl = gtl; gl; gl = gl->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1100 | const char *name = mwSametimeGroup_getName(gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1101 | g_hash_table_insert(stgroups, (char *) name, gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1102 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1103 | g_list_free(gtl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1104 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1105 | /* 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
|
1106 | 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
|
1107 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 15884 | 1108 | PurpleGroup *grp = (PurpleGroup *) gn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1109 | const char *gname, *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1110 | struct mwSametimeGroup *stgrp; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1111 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1112 | if(! PURPLE_IS_GROUP(gn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1113 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1114 | /* group not belonging to this account */ |
| 15884 | 1115 | if(! purple_group_on_account(grp, acct)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1116 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1117 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1118 | /* dynamic group belonging to this account. don't prune contents */ |
| 15884 | 1119 | 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
|
1120 | if(owner && purple_strequal(owner, acct_n)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1121 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1122 | |
|
41084
72d6941bfa2e
Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41078
diff
changeset
|
1123 | /* we actually are syncing by this key as opposed to the group |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1124 | title, which can be different things in the st list */ |
| 15884 | 1125 | 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
|
1126 | if(! gname) gname = purple_group_get_name(grp); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1127 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1128 | stgrp = g_hash_table_lookup(stgroups, gname); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1129 | if(! stgrp) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1130 | /* remove the whole group */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1131 | 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
|
1132 | g_prune = g_list_prepend(g_prune, grp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1133 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1134 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1135 | /* synch the group contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1136 | group_prune(gc, grp, stgrp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1137 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1138 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1139 | DEBUG_INFO("done marking groups\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1140 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1141 | /* don't need this anymore */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1142 | g_hash_table_destroy(stgroups); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1143 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1144 | /* prune all marked groups */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1145 | while(g_prune) { |
| 15884 | 1146 | PurpleGroup *grp = g_prune->data; |
| 1147 | PurpleBlistNode *gn = (PurpleBlistNode *) grp; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1148 | const char *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1149 | gboolean del = TRUE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1150 | |
| 15884 | 1151 | 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
|
1152 | if(owner && !purple_strequal(owner, acct_n)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1153 | /* 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
|
1154 | 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
|
1155 | del = FALSE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1156 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1157 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1158 | group_clear(g_prune->data, acct, del); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1159 | g_prune = g_list_delete_link(g_prune, g_prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1160 | } |
|
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 | /* done with the pruning, let's merge in the additions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1163 | blist_merge(gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1164 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1165 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1166 | |
| 10977 | 1167 | /** callback passed to the storage service when it's told to load the |
| 1168 | st list */ | |
| 1169 | static void fetch_blist_cb(struct mwServiceStorage *srvc, | |
| 1170 | guint32 result, struct mwStorageUnit *item, | |
| 1171 | gpointer data) { | |
| 1172 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1173 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 1174 | struct mwSametimeList *stlist; |
| 1175 | ||
| 1176 | struct mwGetBuffer *b; | |
| 1177 | ||
| 1178 | g_return_if_fail(result == ERR_SUCCESS); | |
| 1179 | ||
| 1180 | /* check our preferences for loading */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1181 | if(BLIST_PREF_IS_LOCAL()) { |
| 10977 | 1182 | DEBUG_INFO("preferences indicate not to load remote buddy list\n"); |
| 1183 | return; | |
| 1184 | } | |
| 1185 | ||
| 1186 | b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); | |
| 1187 | ||
| 1188 | stlist = mwSametimeList_new(); | |
| 1189 | mwSametimeList_get(b, stlist); | |
| 1190 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1191 | /* merge or synch depending on preferences */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1192 | if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1193 | blist_merge(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1194 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1195 | } else if(BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1196 | blist_sync(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1197 | } |
| 10977 | 1198 | |
| 1199 | mwSametimeList_free(stlist); | |
| 22973 | 1200 | mwGetBuffer_free(b); |
| 10977 | 1201 | } |
| 1202 | ||
| 1203 | ||
| 15884 | 1204 | /** signal triggered when a conversation is opened in Purple */ |
| 1205 | 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
|
1206 | struct mwPurpleProtocolData *pd) { |
| 10977 | 1207 | |
| 1208 | /* we need to tell the IM service to negotiate features for the | |
| 1209 | conversation right away, otherwise it'll wait until the first | |
| 1210 | message is sent before offering NotesBuddy features. Therefore | |
| 15884 | 1211 | whenever Purple creates a conversation, we'll immediately open the |
| 10977 | 1212 | channel to the other side and figure out what the target can |
| 1213 | handle. Unfortunately, this makes us vulnerable to Psychic Mode, | |
| 1214 | 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
|
1215 | would not */ |
| 10977 | 1216 | |
| 15884 | 1217 | PurpleConnection *gc; |
| 10977 | 1218 | struct mwIdBlock who = { 0, 0 }; |
| 1219 | struct mwConversation *conv; | |
| 1220 | ||
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1221 | gc = purple_conversation_get_connection(g_conv); |
| 10977 | 1222 | if(pd->gc != gc) |
| 1223 | return; /* not ours */ | |
| 1224 | ||
|
35070
d7350d876fda
libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents:
35005
diff
changeset
|
1225 | if(!PURPLE_IS_IM_CONVERSATION(g_conv)) |
| 10977 | 1226 | return; /* wrong type */ |
| 1227 | ||
| 15884 | 1228 | who.user = (char *) purple_conversation_get_name(g_conv); |
| 10977 | 1229 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 1230 | ||
| 1231 | convo_features(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1232 | |
| 10977 | 1233 | if(mwConversation_isClosed(conv)) |
| 1234 | mwConversation_open(conv); | |
| 1235 | } | |
| 1236 | ||
| 1237 | ||
| 15884 | 1238 | 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
|
1239 | struct mwPurpleProtocolData *pd = data; |
| 15884 | 1240 | PurpleConnection *gc; |
| 1241 | ||
| 1242 | PurpleGroup *group = (PurpleGroup *) node; | |
| 10977 | 1243 | |
| 1244 | GString *str; | |
| 1245 | char *tmp; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1246 | const char *gname; |
| 10977 | 1247 | |
| 1248 | g_return_if_fail(pd != NULL); | |
| 1249 | ||
| 1250 | gc = pd->gc; | |
| 1251 | g_return_if_fail(gc != NULL); | |
| 1252 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1253 | g_return_if_fail(PURPLE_IS_GROUP(node)); |
| 10977 | 1254 | |
| 1255 | str = g_string_new(NULL); | |
| 1256 | ||
| 15884 | 1257 | 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
|
1258 | gname = purple_group_get_name(group); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1259 | |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1260 | 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
|
1261 | 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
|
1262 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1263 | tmp = g_strdup_printf(_("Info for Group %s"), gname); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1264 | |
| 15884 | 1265 | purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
| 10977 | 1266 | NULL, str->str, NULL, NULL); |
| 1267 | ||
| 1268 | g_free(tmp); | |
| 1269 | g_string_free(str, TRUE); | |
| 1270 | } | |
| 1271 | ||
| 1272 | ||
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
1273 | /** The normal blist menu protocol function doesn't get called for groups, |
| 10977 | 1274 | so we use the blist-node-extended-menu signal to trigger this |
| 1275 | handler */ | |
| 15884 | 1276 | 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
|
1277 | GList **menu, struct mwPurpleProtocolData *pd) { |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1278 | const char *owner; |
| 15884 | 1279 | PurpleAccount *acct; |
|
39481
4db28449567d
Rename PurpleMenuAction to PurpleActionMenu
Gary Kramlich <grim@reaperworld.com>
parents:
39479
diff
changeset
|
1280 | PurpleActionMenu *act; |
| 10977 | 1281 | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1282 | /* we only want groups */ |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1283 | if(! PURPLE_IS_GROUP(node)) return; |
| 15884 | 1284 | |
| 1285 | acct = purple_connection_get_account(pd->gc); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1286 | g_return_if_fail(acct != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1287 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1288 | /* better make sure we're connected */ |
| 15884 | 1289 | if(! purple_account_is_connected(acct)) return; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1290 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1291 | /* check if it's a NAB group for this account */ |
| 15884 | 1292 | 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
|
1293 | 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
|
1294 | act = purple_action_menu_new(_("Get Notes Address Book Info"), |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41084
diff
changeset
|
1295 | G_CALLBACK(blist_menu_nab), pd, NULL); |
| 10977 | 1296 | *menu = g_list_append(*menu, act); |
| 1297 | } | |
| 1298 | } | |
| 1299 | ||
| 1300 | ||
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1301 | /* 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
|
1302 | anymore. */ |
| 15884 | 1303 | static void blist_init(PurpleAccount *acct) { |
| 1304 | PurpleBlistNode *gnode, *cnode, *bnode; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1305 | GList *add_buds = NULL; |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1306 | |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1307 | 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
|
1308 | 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
|
1309 | if(! PURPLE_IS_GROUP(gnode)) continue; |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1310 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1311 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1312 | cnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1313 | 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
|
1314 | if(! PURPLE_IS_CONTACT(cnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1315 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1316 | for(bnode = purple_blist_node_get_first_child(cnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1317 | bnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1318 | bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 15884 | 1319 | PurpleBuddy *b; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1320 | if(!PURPLE_IS_BUDDY(bnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1321 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1322 | |
| 15884 | 1323 | b = (PurpleBuddy *)bnode; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1324 | if(purple_buddy_get_account(b) == acct) { |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1325 | add_buds = g_list_append(add_buds, b); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1326 | } |
|
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 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1330 | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1331 | if(add_buds) { |
|
32319
ab70b05e538b
sametime: fix build (add_buddies added param)
Paul Aurich <darkrain42@pidgin.im>
parents:
32316
diff
changeset
|
1332 | purple_account_add_buddies(acct, add_buds, NULL); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1333 | g_list_free(add_buds); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1334 | } |
|
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 | |
| 10977 | 1338 | /** 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
|
1339 | static void services_starting(struct mwPurpleProtocolData *pd) { |
| 15884 | 1340 | |
| 1341 | PurpleConnection *gc; | |
| 1342 | PurpleAccount *acct; | |
| 10977 | 1343 | struct mwStorageUnit *unit; |
| 15884 | 1344 | PurpleBlistNode *l; |
| 10977 | 1345 | |
| 1346 | gc = pd->gc; | |
| 15884 | 1347 | acct = purple_connection_get_account(gc); |
| 10977 | 1348 | |
| 1349 | /* grab the buddy list from the server */ | |
| 1350 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1351 | mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
| 10977 | 1352 | |
| 1353 | /* 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
|
1354 | 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
|
1355 | l = purple_blist_node_get_sibling_next(l)) { |
| 15884 | 1356 | PurpleGroup *group = (PurpleGroup *) l; |
| 10977 | 1357 | enum mwSametimeGroupType gt; |
| 1358 | const char *owner; | |
| 1359 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1360 | if(! PURPLE_IS_GROUP(l)) continue; |
| 10977 | 1361 | |
| 1362 | /* if the group is ownerless, or has an owner and we're not it, | |
| 1363 | skip it */ | |
| 15884 | 1364 | 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
|
1365 | if(!owner || !purple_strequal(owner, purple_account_get_username(acct))) |
| 10977 | 1366 | continue; |
| 1367 | ||
| 15884 | 1368 | gt = purple_blist_node_get_int(l, GROUP_KEY_TYPE); |
| 10977 | 1369 | if(gt == mwSametimeGroup_DYNAMIC) |
| 1370 | group_add(pd, group); | |
| 1371 | } | |
| 1372 | ||
| 1373 | /* set the aware attributes */ | |
| 1374 | /* indicate we understand what AV prefs are, but don't support any */ | |
| 1375 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1376 | mwAttribute_AV_PREFS_SET, TRUE); | |
| 1377 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE); | |
| 1378 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS); | |
| 1379 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA); | |
| 1380 | ||
| 1381 | /* ... but we can do file transfers! */ | |
| 1382 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1383 | mwAttribute_FILE_TRANSFER, TRUE); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1384 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1385 | blist_init(acct); |
| 10977 | 1386 | } |
| 1387 | ||
| 1388 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1389 | static void session_loginRedirect(struct mwSession *session, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1390 | const char *host) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1391 | struct mwPurpleProtocolData *pd; |
| 15884 | 1392 | PurpleConnection *gc; |
| 1393 | PurpleAccount *account; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1394 | guint port; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1395 | const char *current_host; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1396 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1397 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1398 | gc = pd->gc; |
| 15884 | 1399 | account = purple_connection_get_account(gc); |
| 1400 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); | |
| 1401 | 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
|
1402 | MW_PLUGIN_DEFAULT_HOST); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1403 | |
| 15884 | 1404 | 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
|
1405 | !host || purple_strequal(current_host, host)) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1406 | /* 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
|
1407 | redirected to the already configured host, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1408 | we'll force the login instead */ |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1409 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1410 | mwSession_forceLogin(session); |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1411 | return; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1412 | } |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1413 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1414 | 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
|
1415 | if (pd->client == NULL) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1416 | /* 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
|
1417 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1418 | mwSession_forceLogin(session); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1419 | return; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1420 | } |
|
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 | g_socket_client_connect_to_host_async( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1423 | pd->client, host, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1424 | port, pd->cancellable, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1425 | connect_cb, pd); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1426 | } |
|
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 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
1429 | 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
|
1430 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1431 | |
| 10977 | 1432 | /** called from mw_session_stateChange when the session's state is |
| 1433 | mwSession_STARTED. Any finalizing of start-up stuff should go | |
| 1434 | here */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1435 | static void session_started(struct mwPurpleProtocolData *pd) { |
| 15884 | 1436 | PurpleStatus *status; |
| 1437 | PurpleAccount *acct; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1438 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1439 | /* set out initial status */ |
| 15884 | 1440 | acct = purple_connection_get_account(pd->gc); |
| 1441 | 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
|
1442 | mw_protocol_set_status(NULL, acct, status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1443 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1444 | /* start watching for new conversations */ |
| 15884 | 1445 | purple_signal_connect(purple_conversations_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1446 | "conversation-created", pd, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41084
diff
changeset
|
1447 | G_CALLBACK(conversation_created_cb), pd); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1448 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1449 | /* watch for group extended menu items */ |
| 15884 | 1450 | purple_signal_connect(purple_blist_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1451 | "blist-node-extended-menu", pd, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41084
diff
changeset
|
1452 | G_CALLBACK(blist_node_menu_cb), pd); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1453 | |
| 10977 | 1454 | /* use our services to do neat things */ |
| 1455 | services_starting(pd); | |
| 1456 | } | |
| 1457 | ||
| 1458 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1459 | static void session_stopping(struct mwPurpleProtocolData *pd) { |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1460 | /* stop watching the signals from session_started */ |
| 15884 | 1461 | purple_signals_disconnect_by_handle(pd); |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1462 | } |
|
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 | |
| 10977 | 1465 | static void mw_session_stateChange(struct mwSession *session, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1466 | enum mwSessionState state, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1467 | gpointer info) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1468 | struct mwPurpleProtocolData *pd; |
| 15884 | 1469 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1470 | const char *msg = NULL; |
| 10977 | 1471 | |
| 1472 | pd = mwSession_getClientData(session); | |
| 1473 | gc = pd->gc; | |
| 1474 | ||
| 1475 | switch(state) { | |
| 1476 | case mwSession_STARTING: | |
| 1477 | msg = _("Sending Handshake"); | |
| 15884 | 1478 | purple_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS); |
| 10977 | 1479 | break; |
| 1480 | ||
| 1481 | case mwSession_HANDSHAKE: | |
| 1482 | msg = _("Waiting for Handshake Acknowledgement"); | |
| 15884 | 1483 | purple_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS); |
| 10977 | 1484 | break; |
| 1485 | ||
| 1486 | case mwSession_HANDSHAKE_ACK: | |
| 1487 | msg = _("Handshake Acknowledged, Sending Login"); | |
| 15884 | 1488 | purple_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS); |
| 10977 | 1489 | break; |
| 1490 | ||
| 1491 | case mwSession_LOGIN: | |
| 1492 | msg = _("Waiting for Login Acknowledgement"); | |
| 15884 | 1493 | purple_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS); |
| 10977 | 1494 | break; |
| 1495 | ||
| 1496 | case mwSession_LOGIN_REDIR: | |
| 1497 | msg = _("Login Redirected"); | |
| 15884 | 1498 | 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
|
1499 | session_loginRedirect(session, info); |
| 10977 | 1500 | break; |
| 1501 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1502 | case mwSession_LOGIN_CONT: |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1503 | msg = _("Forcing Login"); |
| 15884 | 1504 | 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
|
1505 | break; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1506 | |
| 10977 | 1507 | case mwSession_LOGIN_ACK: |
| 1508 | msg = _("Login Acknowledged"); | |
| 15884 | 1509 | purple_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS); |
| 10977 | 1510 | break; |
| 1511 | ||
| 1512 | case mwSession_STARTED: | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1513 | msg = _("Starting Services"); |
| 15884 | 1514 | purple_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS); |
| 10977 | 1515 | |
| 1516 | session_started(pd); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1517 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1518 | msg = _("Connected"); |
| 15884 | 1519 | 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
|
1520 | purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED); |
| 10977 | 1521 | break; |
| 1522 | ||
| 1523 | case mwSession_STOPPING: | |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1524 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1525 | session_stopping(pd); |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1526 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1527 | if(GPOINTER_TO_UINT(info) & ERR_FAILURE) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1528 | char *err = mwError(GPOINTER_TO_UINT(info)); |
| 21279 | 1529 | PurpleConnectionError reason; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1530 | switch (GPOINTER_TO_UINT(info)) { |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1531 | case VERSION_MISMATCH: |
| 21279 | 1532 | reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1533 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1534 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1535 | case USER_RESTRICTED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1536 | case INCORRECT_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1537 | case USER_UNREGISTERED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1538 | case GUEST_IN_USE: |
| 21279 | 1539 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1540 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1541 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1542 | case ENCRYPT_MISMATCH: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1543 | case ERR_ENCRYPT_NO_SUPPORT: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1544 | case ERR_NO_COMMON_ENCRYPT: |
| 21279 | 1545 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1546 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1547 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1548 | case VERIFICATION_DOWN: |
| 21279 | 1549 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1550 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1551 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1552 | case MULTI_SERVER_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1553 | case MULTI_SERVER_LOGIN2: |
| 21279 | 1554 | reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1555 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1556 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1557 | default: |
| 21279 | 1558 | reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1559 | } |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1560 | purple_connection_error(gc, reason, err); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1561 | g_free(err); |
| 10977 | 1562 | } |
| 1563 | break; | |
| 1564 | ||
| 1565 | case mwSession_STOPPED: | |
| 1566 | break; | |
| 1567 | ||
| 1568 | case mwSession_UNKNOWN: | |
| 1569 | default: | |
| 1570 | DEBUG_WARN("session in unknown state\n"); | |
| 1571 | } | |
| 1572 | } | |
| 1573 | ||
| 1574 | ||
| 1575 | 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
|
1576 | struct mwPurpleProtocolData *pd; |
| 15884 | 1577 | PurpleConnection *gc; |
| 1578 | PurpleAccount *acct; | |
| 10977 | 1579 | struct mwPrivacyInfo *privacy; |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1580 | GSList *list; |
| 10977 | 1581 | guint count; |
| 1582 | ||
| 1583 | DEBUG_INFO("privacy information set from server\n"); | |
| 1584 | ||
| 1585 | g_return_if_fail(session != NULL); | |
| 1586 | ||
| 1587 | pd = mwSession_getClientData(session); | |
| 1588 | g_return_if_fail(pd != NULL); | |
| 1589 | ||
| 1590 | gc = pd->gc; | |
| 1591 | g_return_if_fail(gc != NULL); | |
| 1592 | ||
| 15884 | 1593 | acct = purple_connection_get_account(gc); |
| 10977 | 1594 | g_return_if_fail(acct != NULL); |
| 1595 | ||
| 1596 | privacy = mwSession_getPrivacyInfo(session); | |
| 1597 | count = privacy->count; | |
| 1598 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1599 | if (privacy->deny) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1600 | 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
|
1601 | 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
|
1602 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1603 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1604 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1605 | 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
|
1606 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1607 | } else { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1608 | 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
|
1609 | 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
|
1610 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1611 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1612 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1613 | 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
|
1614 | } |
| 10977 | 1615 | } |
| 1616 | } | |
| 1617 | ||
| 1618 | ||
| 1619 | 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
|
1620 | struct mwPurpleProtocolData *pd; |
| 15884 | 1621 | PurpleConnection *gc; |
| 10977 | 1622 | struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL }; |
| 1623 | struct mwUserStatus *stat; | |
| 1624 | ||
| 1625 | g_return_if_fail(session != NULL); | |
| 1626 | ||
| 1627 | pd = mwSession_getClientData(session); | |
| 1628 | g_return_if_fail(pd != NULL); | |
| 1629 | ||
| 1630 | gc = pd->gc; | |
| 1631 | g_return_if_fail(gc != NULL); | |
| 1632 | ||
| 1633 | idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); | |
| 1634 | stat = mwSession_getUserStatus(session); | |
| 1635 | ||
| 1636 | /* trigger an update of our own status if we're in the buddy list */ | |
| 1637 | mwServiceAware_setStatus(pd->srvc_aware, &idb, stat); | |
| 1638 | } | |
| 1639 | ||
| 1640 | ||
| 1641 | static void mw_session_admin(struct mwSession *session, | |
| 1642 | const char *text) { | |
| 15884 | 1643 | PurpleConnection *gc; |
| 1644 | PurpleAccount *acct; | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1645 | const char *host; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1646 | const char *msg; |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1647 | char *prim; |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1648 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1649 | gc = session_to_gc(session); |
| 10977 | 1650 | g_return_if_fail(gc != NULL); |
| 1651 | ||
| 15884 | 1652 | acct = purple_connection_get_account(gc); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1653 | g_return_if_fail(acct != NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1654 | |
| 15884 | 1655 | 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
|
1656 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1657 | msg = _("A Sametime administrator has issued the following announcement" |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1658 | " on server %s"); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1659 | prim = g_strdup_printf(msg, host); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1660 | |
| 15884 | 1661 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1662 | _("Sametime Administrator Announcement"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1663 | prim, text, NULL, NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1664 | purple_request_cpar_from_connection(gc)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1665 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1666 | g_free(prim); |
| 10977 | 1667 | } |
| 1668 | ||
| 1669 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1670 | /** 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
|
1671 | 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
|
1672 | static gboolean |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1673 | read_cb(GObject *stream, gpointer data) |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1674 | { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1675 | struct mwPurpleProtocolData *pd = data; |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1676 | guchar buf[BUF_LEN]; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1677 | gssize len; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1678 | GError *error = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1679 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1680 | 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
|
1681 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1682 | do { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1683 | len = g_pollable_input_stream_read_nonblocking( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1684 | 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
|
1685 | pd->cancellable, &error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1686 | if (len == 0) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1687 | DEBUG_INFO("connection reset\n"); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1688 | purple_connection_error(pd->gc, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1689 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1690 | _("Server closed the connection")); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1691 | return G_SOURCE_REMOVE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1692 | } else if (len < 0) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1693 | /* 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
|
1694 | it and clean up internal state */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1695 | 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
|
1696 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1697 | return G_SOURCE_CONTINUE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1698 | } 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
|
1699 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1700 | } else { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1701 | g_prefix_error(&error, "%s", |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1702 | _("Lost connection with server: ")); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1703 | purple_connection_take_error(pd->gc, error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1704 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1705 | pd->inpa = 0; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1706 | pd->input = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1707 | g_clear_object(&pd->output); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1708 | g_clear_object(&pd->stream); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1709 | return G_SOURCE_REMOVE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1710 | } |
|
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 | mwSession_recv(pd->session, buf, len); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1713 | } while (len > 0); |
| 10977 | 1714 | |
| 1715 | /* normal operation ends here */ | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1716 | return G_SOURCE_CONTINUE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1717 | } |
|
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 | /* 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
|
1721 | * 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
|
1722 | static void |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1723 | 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
|
1724 | { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1725 | 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
|
1726 | struct mwPurpleProtocolData *pd = data; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1727 | GSocketConnection *sockconn = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1728 | GSource *source = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1729 | GError *error = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1730 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1731 | 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
|
1732 | if (sockconn == NULL) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1733 | 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
|
1734 | /* connection was cancelled */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1735 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1736 | } else if (pd->stream) { |
| 10977 | 1737 | /* this is a redirect connect, force login on existing socket */ |
| 1738 | mwSession_forceLogin(pd->session); | |
| 1739 | ||
| 1740 | } else { | |
| 1741 | /* 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
|
1742 | purple_connection_take_error(pd->gc, error); |
| 10977 | 1743 | } |
| 1744 | ||
| 1745 | return; | |
| 1746 | } | |
| 1747 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1748 | if (pd->stream) { |
| 10977 | 1749 | /* stop any existing login attempt */ |
| 1750 | mwSession_stop(pd->session, ERR_SUCCESS); | |
| 1751 | } | |
| 1752 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1753 | 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
|
1754 | 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
|
1755 | pd->output = purple_queued_output_stream_new( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1756 | 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
|
1757 | source = g_pollable_input_stream_create_source( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1758 | 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
|
1759 | 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
|
1760 | pd->inpa = g_source_attach(source, NULL); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1761 | g_source_unref(source); |
| 10977 | 1762 | |
| 1763 | mwSession_start(pd->session); | |
| 1764 | } | |
| 1765 | ||
| 1766 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1767 | static void mw_session_announce(struct mwSession *s, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1768 | struct mwLoginInfo *from, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1769 | gboolean may_reply, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1770 | const char *text) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1771 | struct mwPurpleProtocolData *pd; |
| 15884 | 1772 | PurpleAccount *acct; |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
1773 | PurpleConversation *im; |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
1774 | PurpleConversationManager *manager; |
| 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); |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
1781 | |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
1782 | manager = purple_conversation_manager_get_default(); |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
1783 | im = purple_conversation_manager_find_im(manager, acct, who); |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
1784 | if(!PURPLE_IS_IM_CONVERSATION(im)) { |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
1785 | im = purple_im_conversation_new(acct, who); |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
1786 | } |
| 15884 | 1787 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
1788 | buddy = purple_blist_find_buddy(acct, who); |
| 15884 | 1789 | 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
|
1790 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1791 | who = g_strdup_printf(_("Announcement from %s"), who); |
| 15884 | 1792 | msg = purple_markup_linkify(text); |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1793 | if (msg && msg[0]) |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1794 | 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
|
1795 | else |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1796 | msg2 = g_strdup(who); |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1797 | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
1798 | purple_conversation_write_system_message(im, msg2, 0); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1799 | g_free(who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1800 | g_free(msg); |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1801 | g_free(msg2); |
| 10977 | 1802 | } |
| 1803 | ||
| 1804 | ||
| 1805 | static struct mwSessionHandler mw_session_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1806 | mw_session_io_write, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1807 | mw_session_io_close, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1808 | mw_session_clear, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1809 | mw_session_stateChange, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1810 | mw_session_setPrivacyInfo, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1811 | mw_session_setUserStatus, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1812 | mw_session_admin, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1813 | mw_session_announce, |
| 10977 | 1814 | }; |
| 1815 | ||
| 1816 | ||
| 1817 | static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
| 1818 | struct mwAwareAttribute *attrib) { | |
| 1819 | ||
| 1820 | ; /** @todo handle server attributes. There may be some stuff we | |
| 1821 | actually want to look for, but I'm not aware of anything right | |
| 1822 | now.*/ | |
| 1823 | } | |
| 1824 | ||
| 1825 | ||
| 1826 | static void mw_aware_clear(struct mwServiceAware *srvc) { | |
| 1827 | ; /* nothing for now */ | |
| 1828 | } | |
| 1829 | ||
| 1830 | ||
| 1831 | static struct mwAwareHandler mw_aware_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1832 | mw_aware_on_attrib, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1833 | mw_aware_clear, |
| 10977 | 1834 | }; |
| 1835 | ||
| 1836 | ||
| 1837 | static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
| 1838 | struct mwServiceAware *srvc; | |
| 1839 | srvc = mwServiceAware_new(s, &mw_aware_handler); | |
| 1840 | return srvc; | |
| 1841 | }; | |
| 1842 | ||
| 1843 | ||
| 1844 | static void mw_conf_invited(struct mwConference *conf, | |
| 1845 | struct mwLoginInfo *inviter, | |
| 1846 | const char *invitation) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1847 | |
| 10977 | 1848 | struct mwServiceConference *srvc; |
| 1849 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1850 | struct mwPurpleProtocolData *pd; |
| 15884 | 1851 | PurpleConnection *gc; |
| 10977 | 1852 | |
| 1853 | char *c_inviter, *c_name, *c_topic, *c_invitation; | |
| 1854 | GHashTable *ht; | |
| 1855 | ||
| 1856 | srvc = mwConference_getService(conf); | |
| 1857 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1858 | pd = mwSession_getClientData(session); | |
| 1859 | gc = pd->gc; | |
| 1860 | ||
| 1861 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1862 | ||
| 1863 | c_inviter = g_strdup(inviter->user_id); | |
| 1864 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
| 1865 | ||
| 1866 | c_name = g_strdup(mwConference_getName(conf)); | |
| 1867 | g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
| 1868 | ||
| 1869 | c_topic = g_strdup(mwConference_getTitle(conf)); | |
| 1870 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
| 1871 | ||
| 1872 | c_invitation = g_strdup(invitation); | |
| 1873 | g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
| 1874 | ||
| 1875 | 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
|
1876 | c_inviter, c_name, |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1877 | c_topic, c_invitation); |
| 10977 | 1878 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1879 | if(! c_topic) c_topic = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1880 | if(! c_invitation) c_invitation = "(no message)"; |
| 35501 | 1881 | purple_serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
| 10977 | 1882 | } |
| 1883 | ||
| 1884 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1885 | /* The following mess helps us relate a mwConference to a PurpleChatConversation |
| 10977 | 1886 | in the various forms by which either may be indicated */ |
| 1887 | ||
| 1888 | #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
| 1889 | #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
| 1890 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1891 | #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
|
1892 | #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
| 10977 | 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 | |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
1906 | if(purple_chat_conversation_get_id(h) == id) { |
| 10977 | 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; |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
1922 | PurpleConversation *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; | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
1941 | purple_chat_conversation_add_user(PURPLE_CHAT_CONVERSATION(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 |
|
41084
72d6941bfa2e
Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41078
diff
changeset
|
2272 | - indicate rejection/cancellation/completion |
| 10977 | 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 |
|
41084
72d6941bfa2e
Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41078
diff
changeset
|
2308 | - update transferred 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 | ||
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2455 | static PurpleConversation *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; |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
2460 | PurpleConversationManager *manager; |
| 15884 | 2461 | PurpleAccount *acct; |
| 10977 | 2462 | |
| 2463 | struct mwIdBlock *idb; | |
| 2464 | ||
| 2465 | srvc = mwConversation_getService(conv); | |
| 2466 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2467 | pd = mwSession_getClientData(session); | |
| 2468 | gc = pd->gc; | |
| 15884 | 2469 | acct = purple_connection_get_account(gc); |
| 10977 | 2470 | |
| 2471 | idb = mwConversation_getTarget(conv); | |
| 2472 | ||
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
2473 | manager = purple_conversation_manager_get_default(); |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
2474 | |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
2475 | return purple_conversation_manager_find_im(manager, acct, idb->user); |
| 10977 | 2476 | } |
| 2477 | ||
| 2478 | ||
| 2479 | static void convo_queue(struct mwConversation *conv, | |
| 2480 | enum mwImSendType type, gconstpointer data) { | |
| 2481 | ||
| 2482 | struct convo_data *cd; | |
| 2483 | struct convo_msg *m; | |
| 2484 | ||
| 2485 | convo_data_new(conv); | |
| 2486 | cd = mwConversation_getClientData(conv); | |
| 2487 | ||
| 2488 | m = g_new0(struct convo_msg, 1); | |
| 2489 | m->type = type; | |
| 2490 | ||
| 2491 | switch(type) { | |
| 2492 | case mwImSend_PLAIN: | |
| 2493 | m->data = g_strdup(data); | |
| 2494 | m->clear = g_free; | |
| 2495 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2496 | |
| 10977 | 2497 | case mwImSend_TYPING: |
| 2498 | default: | |
| 2499 | m->data = (gpointer) data; | |
| 2500 | m->clear = NULL; | |
| 2501 | } | |
| 2502 | ||
| 2503 | cd->queue = g_list_append(cd->queue, m); | |
| 2504 | } | |
| 2505 | ||
| 2506 | ||
| 2507 | /* Does what it takes to get an error displayed for a conversation */ | |
| 2508 | static void convo_error(struct mwConversation *conv, guint32 err) { | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2509 | PurpleConversation *im; |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2510 | PurpleConnection *pc; |
| 10977 | 2511 | char *tmp, *text; |
| 2512 | struct mwIdBlock *idb; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2513 | |
| 10977 | 2514 | idb = mwConversation_getTarget(conv); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2515 | |
| 10977 | 2516 | tmp = mwError(err); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2517 | text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2518 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2519 | 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
|
2520 | if(im && !purple_conversation_present_error(idb->user, |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2521 | purple_conversation_get_account(im), text)) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2522 | |
| 10977 | 2523 | g_free(text); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2524 | text = g_strdup_printf(_("Unable to send message to %s:"), |
| 10977 | 2525 | (idb->user)? idb->user: "(unknown)"); |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2526 | pc = purple_account_get_connection(purple_conversation_get_account(im)); |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2527 | purple_notify_error(pc, NULL, text, tmp, purple_request_cpar_from_connection(pc)); |
| 10977 | 2528 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2529 | |
| 10977 | 2530 | g_free(tmp); |
| 2531 | g_free(text); | |
| 2532 | } | |
| 2533 | ||
| 2534 | ||
| 2535 | static void convo_queue_send(struct mwConversation *conv) { | |
| 2536 | struct convo_data *cd; | |
| 2537 | GList *l; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2538 | |
| 10977 | 2539 | cd = mwConversation_getClientData(conv); |
| 2540 | ||
| 2541 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2542 | struct convo_msg *m = l->data; | |
| 2543 | ||
| 2544 | mwConversation_send(conv, m->type, m->data); | |
| 2545 | ||
| 2546 | if(m->clear) m->clear(m->data); | |
| 2547 | g_free(m); | |
| 2548 | } | |
| 2549 | ||
| 2550 | cd->queue = NULL; | |
| 2551 | } | |
| 2552 | ||
| 2553 | ||
| 15884 | 2554 | /** called when a mw conversation leaves a purple conversation to |
| 2555 | inform the purple conversation that it's unsafe to offer any *cool* | |
| 10977 | 2556 | features. */ |
| 2557 | static void convo_nofeatures(struct mwConversation *conv) { | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2558 | PurpleConversation *im; |
| 15884 | 2559 | PurpleConnection *gc; |
| 10977 | 2560 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2561 | 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
|
2562 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2563 | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2564 | gc = purple_conversation_get_connection(im); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2565 | if(! gc) return; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2566 | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2567 | purple_conversation_set_features(im, purple_connection_get_flags(gc)); |
| 15884 | 2568 | } |
| 2569 | ||
| 2570 | ||
| 2571 | /** called when a mw conversation and purple conversation come together, | |
| 2572 | to inform the purple conversation of what features to offer the | |
| 10977 | 2573 | user */ |
| 2574 | static void convo_features(struct mwConversation *conv) { | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2575 | PurpleConversation *im; |
| 15884 | 2576 | PurpleConnectionFlags feat; |
| 10977 | 2577 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2578 | 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
|
2579 | if(! im) return; |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2580 | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2581 | feat = purple_conversation_get_features(im); |
| 10977 | 2582 | |
| 2583 | if(mwConversation_isOpen(conv)) { | |
| 2584 | if(mwConversation_supports(conv, mwImSend_HTML)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2585 | feat |= PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2586 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2587 | feat &= ~PURPLE_CONNECTION_FLAG_HTML; |
| 10977 | 2588 | } |
| 2589 | ||
| 2590 | if(mwConversation_supports(conv, mwImSend_MIME)) { | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2591 | feat &= ~PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2592 | } else { |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2593 | feat |= PURPLE_CONNECTION_FLAG_NO_IMAGES; |
| 10977 | 2594 | } |
| 2595 | ||
| 2596 | DEBUG_INFO("conversation features set to 0x%04x\n", feat); | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2597 | purple_conversation_set_features(im, feat); |
| 10977 | 2598 | |
| 2599 | } else { | |
| 2600 | convo_nofeatures(conv); | |
| 2601 | } | |
| 2602 | } | |
| 2603 | ||
| 2604 | ||
| 2605 | static void mw_conversation_opened(struct mwConversation *conv) { | |
| 2606 | struct mwServiceIm *srvc; | |
| 2607 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2608 | struct mwPurpleProtocolData *pd; |
| 15884 | 2609 | PurpleConnection *gc; |
| 2610 | PurpleAccount *acct; | |
| 10977 | 2611 | |
| 2612 | struct convo_dat *cd; | |
| 2613 | ||
| 2614 | srvc = mwConversation_getService(conv); | |
| 2615 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2616 | pd = mwSession_getClientData(session); | |
| 2617 | gc = pd->gc; | |
| 15884 | 2618 | acct = purple_connection_get_account(gc); |
| 10977 | 2619 | |
| 2620 | /* set up the queue */ | |
| 2621 | cd = mwConversation_getClientData(conv); | |
| 2622 | if(cd) { | |
| 2623 | convo_queue_send(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2624 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2625 | if(! convo_get_im(conv)) { |
| 10977 | 2626 | mwConversation_free(conv); |
| 2627 | return; | |
| 2628 | } | |
| 2629 | ||
| 2630 | } else { | |
| 2631 | convo_data_new(conv); | |
| 2632 | } | |
| 2633 | ||
| 2634 | { /* record the client key for the buddy */ | |
| 15884 | 2635 | PurpleBuddy *buddy; |
| 10977 | 2636 | struct mwLoginInfo *info; |
| 2637 | info = mwConversation_getTargetInfo(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2638 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
2639 | buddy = purple_blist_find_buddy(acct, info->user_id); |
| 10977 | 2640 | if(buddy) { |
| 15884 | 2641 | purple_blist_node_set_int((PurpleBlistNode *) buddy, |
| 10977 | 2642 | BUDDY_KEY_CLIENT, info->type); |
| 2643 | } | |
| 2644 | } | |
| 2645 | ||
| 2646 | convo_features(conv); | |
| 2647 | } | |
| 2648 | ||
| 2649 | ||
| 2650 | static void mw_conversation_closed(struct mwConversation *conv, | |
| 2651 | guint32 reason) { | |
| 2652 | ||
| 2653 | struct convo_data *cd; | |
| 2654 | ||
| 2655 | g_return_if_fail(conv != NULL); | |
| 2656 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2657 | /* 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
|
2658 | print an error message to the conversation */ |
| 10977 | 2659 | cd = mwConversation_getClientData(conv); |
| 2660 | if(reason && cd && cd->queue) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2661 | GList *l; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2662 | for(l = cd->queue; l; l = l->next) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2663 | struct convo_msg *m = l->data; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2664 | if(m->type != mwImSend_TYPING) { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2665 | convo_error(conv, reason); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2666 | break; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2667 | } |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2668 | } |
| 10977 | 2669 | } |
| 2670 | ||
| 2671 | mwConversation_removeClientData(conv); | |
| 2672 | } | |
| 2673 | ||
| 2674 | ||
| 2675 | 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
|
2676 | struct mwPurpleProtocolData *pd, |
| 10977 | 2677 | const char *msg) { |
| 2678 | ||
| 2679 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2680 | char *txt, *esc; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2681 | const char *t; |
| 10977 | 2682 | |
| 2683 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2684 | |
| 15884 | 2685 | txt = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2686 | t = txt? txt: msg; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2687 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2688 | esc = g_markup_escape_text(t, -1); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2689 | 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
|
2690 | g_free(esc); |
| 10977 | 2691 | |
| 2692 | g_free(txt); | |
| 2693 | } | |
| 2694 | ||
| 2695 | ||
| 2696 | 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
|
2697 | struct mwPurpleProtocolData *pd, |
| 10977 | 2698 | gboolean typing) { |
| 2699 | ||
| 2700 | struct mwIdBlock *idb; | |
| 2701 | idb = mwConversation_getTarget(conv); | |
| 2702 | ||
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2703 | 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
|
2704 | typing? PURPLE_IM_TYPING: PURPLE_IM_NOT_TYPING); |
| 10977 | 2705 | } |
| 2706 | ||
| 2707 | ||
| 2708 | 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
|
2709 | struct mwPurpleProtocolData *pd, |
| 10977 | 2710 | const char *msg) { |
| 2711 | struct mwIdBlock *idb; | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2712 | char *t1, *t2; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2713 | const char *t; |
| 10977 | 2714 | |
| 2715 | idb = mwConversation_getTarget(conv); | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2716 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2717 | /* ensure we're receiving UTF8 */ |
| 15884 | 2718 | t1 = purple_utf8_try_convert(msg); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2719 | t = t1? t1: msg; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2720 | |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2721 | /* convert entities to UTF8 so they'll log correctly */ |
| 15884 | 2722 | t2 = purple_utf8_ncr_decode(t); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2723 | t = t2? t2: t; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2724 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2725 | purple_serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
| 10977 | 2726 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2727 | g_free(t1); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2728 | g_free(t2); |
| 10977 | 2729 | } |
| 2730 | ||
| 2731 | ||
| 2732 | 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
|
2733 | struct mwPurpleProtocolData *pd, |
| 10977 | 2734 | const char *subj) { |
| 2735 | ||
| 2736 | /** @todo somehow indicate receipt of a conversation subject. It | |
| 2737 | would also be nice if we added a /topic command for the | |
| 2738 | protocol */ | |
| 2739 | ; | |
| 2740 | } | |
| 2741 | ||
| 2742 | ||
| 2743 | static void mw_conversation_recv(struct mwConversation *conv, | |
| 2744 | enum mwImSendType type, | |
| 2745 | gconstpointer msg) { | |
| 2746 | struct mwServiceIm *srvc; | |
| 2747 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2748 | struct mwPurpleProtocolData *pd; |
| 10977 | 2749 | |
| 2750 | srvc = mwConversation_getService(conv); | |
| 2751 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2752 | pd = mwSession_getClientData(session); | |
| 2753 | ||
| 2754 | switch(type) { | |
| 2755 | case mwImSend_PLAIN: | |
| 2756 | im_recv_text(conv, pd, msg); | |
| 2757 | break; | |
| 2758 | ||
| 2759 | case mwImSend_TYPING: | |
| 2760 | im_recv_typing(conv, pd, !! msg); | |
| 2761 | break; | |
| 2762 | ||
| 2763 | case mwImSend_HTML: | |
| 2764 | im_recv_html(conv, pd, msg); | |
| 2765 | break; | |
| 2766 | ||
| 2767 | case mwImSend_SUBJECT: | |
| 2768 | im_recv_subj(conv, pd, msg); | |
| 2769 | break; | |
| 2770 | ||
|
39523
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
2771 | case mwImSend_MIME: { |
|
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
2772 | 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
|
2773 | 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
|
2774 | g_free(parsed_message); |
| 10977 | 2775 | break; |
|
39523
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
2776 | } |
| 10977 | 2777 | |
| 2778 | default: | |
| 2779 | DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
| 2780 | ; /* erm... */ | |
| 2781 | } | |
| 2782 | } | |
| 2783 | ||
| 2784 | ||
| 2785 | static void mw_place_invite(struct mwConversation *conv, | |
| 2786 | const char *message, | |
| 2787 | const char *title, const char *name) { | |
| 2788 | struct mwServiceIm *srvc; | |
| 2789 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2790 | struct mwPurpleProtocolData *pd; |
| 10977 | 2791 | |
| 2792 | struct mwIdBlock *idb; | |
| 2793 | GHashTable *ht; | |
| 2794 | ||
| 2795 | srvc = mwConversation_getService(conv); | |
| 2796 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2797 | pd = mwSession_getClientData(session); | |
| 2798 | ||
| 2799 | idb = mwConversation_getTarget(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2800 | |
| 10977 | 2801 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 2802 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
| 2803 | g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
| 2804 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
| 2805 | 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
|
2806 | g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
| 10977 | 2807 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2808 | if(! title) title = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2809 | if(! message) message = "(no message)"; |
| 35501 | 2810 | 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
|
2811 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2812 | mwConversation_close(conv, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2813 | mwConversation_free(conv); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2814 | } |
| 10977 | 2815 | |
| 2816 | ||
| 2817 | static void mw_im_clear(struct mwServiceIm *srvc) { | |
| 2818 | ; | |
| 2819 | } | |
| 2820 | ||
| 2821 | ||
| 2822 | static struct mwImHandler mw_im_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2823 | mw_conversation_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2824 | mw_conversation_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2825 | mw_conversation_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2826 | mw_place_invite, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2827 | mw_im_clear, |
| 10977 | 2828 | }; |
| 2829 | ||
| 2830 | ||
| 2831 | static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
| 2832 | struct mwServiceIm *srvc; | |
| 2833 | srvc = mwServiceIm_new(s, &mw_im_handler); | |
| 2834 | mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
| 2835 | return srvc; | |
| 2836 | } | |
| 2837 | ||
| 2838 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2839 | /* 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
|
2840 | 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
|
2841 | the similar macros from the conference service above */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2842 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2843 | #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2844 | #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
|
2845 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2846 | #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
|
2847 | #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
|
2848 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2849 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2850 | static struct mwPlace * |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2851 | place_find_by_id(struct mwPurpleProtocolData *pd, int id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2852 | struct mwServicePlace *srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2853 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2854 | GList *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2855 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2856 | l = (GList *) mwServicePlace_getPlaces(srvc); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2857 | for(; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2858 | 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
|
2859 | PurpleChatConversation *h = mwPlace_getClientData(p); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2860 | |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
2861 | if(purple_chat_conversation_get_id(h) == id) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2862 | place = p; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2863 | break; |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2867 | return place; |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2871 | static void mw_place_opened(struct mwPlace *place) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2872 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2873 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2874 | struct mwPurpleProtocolData *pd; |
| 15884 | 2875 | PurpleConnection *gc; |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2876 | PurpleConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2877 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2878 | GList *members, *l; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2879 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2880 | const char *n = mwPlace_getName(place); |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2881 | const char *t = mwPlace_getTitle(place); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2882 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2883 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2884 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2885 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2886 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2887 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2888 | members = mwPlace_getMembers(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2889 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2890 | 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
|
2891 | n, g_list_length(members)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2892 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2893 | if(! t) t = "(no title)"; |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2894 | 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
|
2895 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2896 | mwPlace_setClientData(place, gconf, NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2897 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2898 | for(l = members; l; l = l->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2899 | struct mwIdBlock *idb = l->data; |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2900 | purple_chat_conversation_add_user(PURPLE_CHAT_CONVERSATION(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
|
2901 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2902 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2903 | g_list_free(members); |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2907 | static void mw_place_closed(struct mwPlace *place, guint32 code) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2908 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2909 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2910 | struct mwPurpleProtocolData *pd; |
| 15884 | 2911 | PurpleConnection *gc; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2912 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2913 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2914 | char *msg = mwError(code); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2915 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2916 | 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
|
2917 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2918 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2919 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2920 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2921 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2922 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
2923 | 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
|
2924 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
2925 | 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
|
2926 | purple_request_cpar_from_connection(gc)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2927 | g_free(msg); |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2931 | static void mw_place_peerJoined(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2932 | 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
|
2933 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2934 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2935 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2936 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2937 | 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
|
2938 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2939 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2940 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2941 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2942 | 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
|
2943 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
|
11943
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2947 | static void mw_place_peerParted(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2948 | 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
|
2949 | PurpleChatConversation *gconf; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2950 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2951 | const char *n = mwPlace_getName(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2952 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2953 | 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
|
2954 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2955 | gconf = mwPlace_getClientData(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2956 | g_return_if_fail(gconf != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2957 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2958 | purple_chat_conversation_remove_user(gconf, peer->user, NULL); |
|
11943
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2962 | static void mw_place_peerSetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2963 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2964 | guint32 attr, struct mwOpaque *o) { |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2969 | static void mw_place_peerUnsetAttribute(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2970 | const struct mwIdBlock *peer, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2971 | guint32 attr) { |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2976 | static void mw_place_message(struct mwPlace *place, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2977 | const struct mwIdBlock *who, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2978 | const char *msg) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2979 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2980 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2981 | struct mwPurpleProtocolData *pd; |
| 15884 | 2982 | PurpleConnection *gc; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2983 | char *esc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2984 | |
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2985 | if(! msg) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2986 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2987 | srvc = mwPlace_getService(place); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2988 | session = mwService_getSession(MW_SERVICE(srvc)); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2989 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2990 | gc = pd->gc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2991 | |
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2992 | esc = g_markup_escape_text(msg, -1); |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
2993 | 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
|
2994 | PURPLE_MESSAGE_RECV, esc, time(NULL)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2995 | g_free(esc); |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2999 | static void mw_place_clear(struct mwServicePlace *srvc) { |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3004 | static struct mwPlaceHandler mw_place_handler = { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3005 | mw_place_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3006 | mw_place_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3007 | mw_place_peerJoined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3008 | mw_place_peerParted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3009 | mw_place_peerSetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3010 | mw_place_peerUnsetAttribute, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3011 | mw_place_message, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
3012 | mw_place_clear, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3013 | }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3014 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3015 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3016 | static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3017 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3018 | srvc = mwServicePlace_new(s, &mw_place_handler); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3019 | return srvc; |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3022 | |
| 10977 | 3023 | static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
| 3024 | struct mwServiceResolve *srvc; | |
| 3025 | srvc = mwServiceResolve_new(s); | |
| 3026 | return srvc; | |
| 3027 | } | |
| 3028 | ||
| 3029 | ||
| 3030 | static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
| 3031 | struct mwServiceStorage *srvc; | |
| 3032 | srvc = mwServiceStorage_new(s); | |
| 3033 | return srvc; | |
| 3034 | } | |
| 3035 | ||
| 3036 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3037 | /** 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
|
3038 | 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
|
3039 | struct mwPurpleProtocolData *pd; |
| 10977 | 3040 | |
| 3041 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3042 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3043 | pd = g_new0(struct mwPurpleProtocolData, 1); |
| 10977 | 3044 | pd->gc = gc; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3045 | pd->cancellable = g_cancellable_new(); |
| 10977 | 3046 | pd->session = mwSession_new(&mw_session_handler); |
| 3047 | pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
| 3048 | pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
| 3049 | pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
| 3050 | pd->srvc_im = mw_srvc_im_new(pd->session); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3051 | pd->srvc_place = mw_srvc_place_new(pd->session); |
| 10977 | 3052 | pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
| 3053 | pd->srvc_store = mw_srvc_store_new(pd->session); | |
| 3054 | pd->group_list_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 3055 | ||
| 3056 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
| 3057 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
| 3058 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
| 3059 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3060 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
| 10977 | 3061 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
| 3062 | mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
| 3063 | ||
| 3064 | 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
|
3065 | mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 10977 | 3066 | |
| 3067 | 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
|
3068 | purple_connection_set_protocol_data(gc, pd); |
| 10977 | 3069 | |
| 3070 | return pd; | |
| 3071 | } | |
| 3072 | ||
| 3073 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3074 | static void mwPurpleProtocolData_free(struct mwPurpleProtocolData *pd) { |
| 10977 | 3075 | g_return_if_fail(pd != NULL); |
| 3076 | ||
|
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
|
3077 | purple_connection_set_protocol_data(pd->gc, NULL); |
| 10977 | 3078 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3079 | mwSession_removeService(pd->session, mwService_AWARE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3080 | mwSession_removeService(pd->session, mwService_CONFERENCE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3081 | mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3082 | mwSession_removeService(pd->session, mwService_IM); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3083 | mwSession_removeService(pd->session, mwService_PLACE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3084 | mwSession_removeService(pd->session, mwService_RESOLVE); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3085 | mwSession_removeService(pd->session, mwService_STORAGE); |
| 10977 | 3086 | |
| 3087 | mwService_free(MW_SERVICE(pd->srvc_aware)); | |
| 3088 | mwService_free(MW_SERVICE(pd->srvc_conf)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3089 | mwService_free(MW_SERVICE(pd->srvc_ft)); |
| 10977 | 3090 | mwService_free(MW_SERVICE(pd->srvc_im)); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3091 | mwService_free(MW_SERVICE(pd->srvc_place)); |
| 10977 | 3092 | mwService_free(MW_SERVICE(pd->srvc_resolve)); |
| 3093 | mwService_free(MW_SERVICE(pd->srvc_store)); | |
| 3094 | ||
| 3095 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3096 | mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
| 10977 | 3097 | |
| 3098 | mwSession_free(pd->session); | |
| 3099 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3100 | g_clear_object(&pd->cancellable); |
| 10977 | 3101 | 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
|
3102 | g_clear_object(&pd->input); |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3103 | g_clear_object(&pd->output); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3104 | g_clear_object(&pd->stream); |
| 10977 | 3105 | |
| 3106 | g_free(pd); | |
| 3107 | } | |
| 3108 | ||
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3109 | static GList * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3110 | mw_protocol_get_account_options(PurpleProtocol *protocol) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3111 | PurpleAccountOption *opt; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3112 | GList *opts = NULL; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3113 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3114 | /* port to connect to */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3115 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3116 | MW_PLUGIN_DEFAULT_PORT); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3117 | opts = g_list_append(opts, opt); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3118 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3119 | { /* copy the old force login setting from prefs if it's |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3120 | there. Don't delete the preference, since there may be more |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3121 | than one account that wants to check for it. */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3122 | gboolean b = FALSE; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3123 | const gchar *label = _("Force login (ignore server redirects)"); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3124 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3125 | if (purple_prefs_exists(MW_PROTOCOL_OPT_FORCE_LOGIN)) |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3126 | b = purple_prefs_get_bool(MW_PROTOCOL_OPT_FORCE_LOGIN); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3127 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3128 | opt = purple_account_option_bool_new(label, MW_KEY_FORCE, b); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3129 | opts = g_list_append(opts, opt); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3130 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3131 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3132 | /* pretend to be Sametime Connect */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3133 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3134 | MW_KEY_FAKE_IT, FALSE); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3135 | opts = g_list_append(opts, opt); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3136 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3137 | return opts; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3138 | } |
|
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 | static GList * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3141 | mw_protocol_get_user_splits(PurpleProtocol *protocol) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3142 | PurpleAccountUserSplit *split; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3143 | GList *splits = NULL; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3144 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3145 | /* set up account ID as user:server */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3146 | split = purple_account_user_split_new(_("Server"), |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3147 | MW_PLUGIN_DEFAULT_HOST, ':'); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3148 | splits = g_list_append(splits, split); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3149 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3150 | return splits; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3151 | } |
| 10977 | 3152 | |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3153 | 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
|
3154 | 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
|
3155 | if(buddy_is_external(b)) { |
| 15524 | 3156 | 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
|
3157 | } |
| 15524 | 3158 | |
| 3159 | return NULL; | |
| 10977 | 3160 | } |
| 3161 | ||
| 3162 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3163 | static char * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3164 | mw_protocol_status_text(PurpleProtocolClient * client, PurpleBuddy *b) { |
| 15884 | 3165 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3166 | struct mwPurpleProtocolData *pd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3167 | 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
|
3168 | 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
|
3169 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3170 | 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
|
3171 | && (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
|
3172 | 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
|
3173 | |
|
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
|
3174 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3175 | } |
| 3176 | ||
| 3177 | ||
| 15884 | 3178 | static const char *status_text(PurpleBuddy *b) { |
| 3179 | PurplePresence *presence; | |
| 3180 | PurpleStatus *status; | |
| 3181 | ||
| 3182 | presence = purple_buddy_get_presence(b); | |
| 3183 | status = purple_presence_get_active_status(presence); | |
| 3184 | ||
| 3185 | return purple_status_get_name(status); | |
| 10977 | 3186 | } |
| 3187 | ||
| 3188 | ||
| 3189 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3190 | const char *who, guint32 feature) { | |
| 3191 | ||
| 3192 | const struct mwAwareAttribute *attr; | |
| 3193 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3194 | ||
| 3195 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3196 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3197 | } | |
| 3198 | ||
| 3199 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3200 | 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
|
3201 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3202 | const char **f = feat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3203 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3204 | if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3205 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3206 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3207 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3208 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3209 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3210 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3211 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3212 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3213 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3214 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3215 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3216 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3217 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3218 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3219 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3220 | /* jenni loves siege */ |
| 10977 | 3221 | } |
| 3222 | ||
| 3223 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3224 | static void |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3225 | 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
|
3226 | 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
|
3227 | { |
| 15884 | 3228 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3229 | struct mwPurpleProtocolData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3230 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3231 | |
|
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
|
3232 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3233 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3234 | char *tmp; |
| 10977 | 3235 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3236 | 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
|
3237 | && (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
|
3238 | 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
|
3239 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3240 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3241 | |
|
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
|
3242 | 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
|
3243 | 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
|
3244 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3245 | } 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
|
3246 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status); |
| 10977 | 3247 | } |
| 3248 | ||
|
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
|
3249 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3250 | 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
|
3251 | 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
|
3252 | 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
|
3253 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3254 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3255 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3256 | 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
|
3257 | 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
|
3258 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3259 | } |
| 10977 | 3260 | } |
| 3261 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3262 | 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
|
3263 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3264 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3265 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3266 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3267 | 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
|
3268 | 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
|
3269 | 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
|
3270 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3271 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3272 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3273 | 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
|
3274 | 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
|
3275 | 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
|
3276 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3277 | types = g_list_append(types, type); |
|
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 | 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
|
3280 | 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
|
3281 | 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
|
3282 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3283 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3284 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3285 | 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
|
3286 | 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
|
3287 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3288 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3289 | return types; |
| 10977 | 3290 | } |
| 3291 | ||
| 3292 | ||
| 15884 | 3293 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3294 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3295 | ; /* nothing to do */ |
| 10977 | 3296 | } |
| 3297 | ||
| 3298 | ||
| 15884 | 3299 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3300 | PurpleRequestFields *fields) { | |
| 3301 | PurpleAccount *acct; | |
| 3302 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3303 | struct mwPurpleProtocolData *pd; |
| 10977 | 3304 | struct mwServiceConference *srvc; |
| 3305 | ||
| 15884 | 3306 | PurpleRequestField *f; |
| 10977 | 3307 | |
| 3308 | const char *topic, *invite; | |
| 3309 | struct mwConference *conf; | |
| 3310 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3311 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3312 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3313 | 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
|
3314 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3315 | srvc = pd->srvc_conf; |
| 3316 | ||
| 15884 | 3317 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3318 | topic = purple_request_field_string_get_value(f); | |
| 3319 | ||
| 3320 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3321 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3322 | |
| 3323 | conf = mwConference_new(srvc, topic); | |
| 3324 | mwConference_open(conf); | |
| 3325 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3326 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3327 | mwConference_invite(conf, &idb, invite); |
| 3328 | } | |
| 3329 | ||
| 3330 | ||
| 15884 | 3331 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3332 | ||
| 3333 | PurpleRequestFields *fields; | |
| 3334 | PurpleRequestFieldGroup *g; | |
| 3335 | PurpleRequestField *f; | |
| 3336 | ||
| 3337 | PurpleAccount *acct; | |
| 3338 | PurpleConnection *gc; | |
| 10977 | 3339 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3340 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3341 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3342 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3343 | |
| 10977 | 3344 | g_return_if_fail(buddy != NULL); |
| 3345 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3346 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3347 | g_return_if_fail(acct != NULL); |
| 3348 | ||
| 15884 | 3349 | gc = purple_account_get_connection(acct); |
| 10977 | 3350 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3351 | |
| 15884 | 3352 | fields = purple_request_fields_new(); |
| 3353 | ||
| 3354 | g = purple_request_field_group_new(NULL); | |
| 3355 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3356 | |
| 15884 | 3357 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3358 | purple_request_field_group_add_field(g, f); | |
| 3359 | ||
| 3360 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3361 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3362 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3363 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3364 | 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
|
3365 | " 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
|
3366 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3367 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3368 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3369 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3370 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3371 | _("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
|
3372 | purple_request_cpar_from_account(acct), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3373 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3374 | g_free(msg1); |
| 10977 | 3375 | } |
| 3376 | ||
| 3377 | ||
| 15884 | 3378 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3379 | PurpleRequestFields *fields) { | |
| 10977 | 3380 | ; |
| 3381 | } | |
| 3382 | ||
| 3383 | ||
| 15884 | 3384 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3385 | PurpleRequestFields *fields) { | |
| 3386 | 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
|
3387 | GList *l; |
| 10977 | 3388 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3389 | |
| 15884 | 3390 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3391 | msg = purple_request_field_string_get_value(f); | |
| 3392 | ||
| 3393 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3394 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3395 | |
| 3396 | if(l) { | |
| 15884 | 3397 | 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
|
3398 | |
| 10977 | 3399 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3400 | blist_menu_conf_create(buddy, msg); | |
| 3401 | ||
| 3402 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3403 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3404 | mwConference_invite(d, &idb, msg); |
| 3405 | } | |
| 3406 | } | |
| 3407 | } | |
| 3408 | ||
| 3409 | ||
| 15884 | 3410 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3411 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3412 | |
| 15884 | 3413 | PurpleRequestFields *fields; |
| 3414 | PurpleRequestFieldGroup *g; | |
| 3415 | PurpleRequestField *f; | |
| 3416 | ||
| 3417 | PurpleAccount *acct; | |
| 3418 | PurpleConnection *gc; | |
| 10977 | 3419 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3420 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3421 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3422 | char *msg; |
| 10977 | 3423 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3424 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3425 | g_return_if_fail(acct != NULL); |
| 3426 | ||
| 15884 | 3427 | gc = purple_account_get_connection(acct); |
| 10977 | 3428 | g_return_if_fail(gc != NULL); |
| 3429 | ||
| 15884 | 3430 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3431 | |
| 15884 | 3432 | g = purple_request_field_group_new(NULL); |
| 3433 | purple_request_fields_add_group(fields, g); | |
| 3434 | ||
| 3435 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3436 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3437 | for(; confs; confs = confs->next) { |
| 3438 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3439 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3440 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3441 | 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
|
3442 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3443 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3444 | |
| 15884 | 3445 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3446 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3447 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3448 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3449 | 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
|
3450 | " 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
|
3451 | " 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
|
3452 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3453 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3454 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3455 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3456 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3457 | _("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
|
3458 | purple_request_cpar_from_account(acct), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3459 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3460 | g_free(msg); |
| 10977 | 3461 | } |
| 3462 | ||
| 3463 | ||
| 15884 | 3464 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 3465 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3466 | PurpleAccount *acct; | |
| 3467 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3468 | struct mwPurpleProtocolData *pd; |
| 10977 | 3469 | GList *l; |
| 3470 | ||
| 3471 | 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
|
3472 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 10977 | 3473 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3474 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3475 | g_return_if_fail(acct != NULL); |
| 3476 | ||
| 15884 | 3477 | gc = purple_account_get_connection(acct); |
| 10977 | 3478 | g_return_if_fail(gc != NULL); |
| 3479 | ||
|
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
|
3480 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3481 | g_return_if_fail(pd != NULL); |
| 3482 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3483 | /* |
| 10977 | 3484 | - get a list of all conferences on this session |
| 3485 | - if none, prompt to create one, and invite buddy to it | |
| 3486 | - else, prompt to select a conference or create one | |
| 3487 | */ | |
| 3488 | ||
| 3489 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3490 | if(l) { | |
| 3491 | blist_menu_conf_list(buddy, l); | |
| 3492 | g_list_free(l); | |
| 3493 | ||
| 3494 | } else { | |
| 3495 | blist_menu_conf_create(buddy, NULL); | |
| 3496 | } | |
| 3497 | } | |
| 3498 | ||
| 3499 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3500 | static GList * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3501 | 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
|
3502 | PurpleBlistNode *node) |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3503 | { |
| 10977 | 3504 | GList *l = NULL; |
|
39481
4db28449567d
Rename PurpleMenuAction to PurpleActionMenu
Gary Kramlich <grim@reaperworld.com>
parents:
39479
diff
changeset
|
3505 | PurpleActionMenu *act; |
| 15884 | 3506 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3507 | if(! PURPLE_IS_BUDDY(node)) |
| 10977 | 3508 | return l; |
| 3509 | ||
| 3510 | l = g_list_append(l, NULL); | |
| 3511 | ||
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
3512 | act = purple_action_menu_new(_("Invite to Conference..."), |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41084
diff
changeset
|
3513 | G_CALLBACK(blist_menu_conf), NULL, NULL); |
| 10977 | 3514 | l = g_list_append(l, act); |
| 3515 | ||
| 15884 | 3516 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3517 | blist-node-extended-menu signal for that. The function |
| 3518 | blist_node_menu_cb is assigned to this signal in the function | |
| 3519 | services_starting */ | |
| 3520 | ||
| 3521 | return l; | |
| 3522 | } | |
| 3523 | ||
| 3524 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3525 | static GList * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3526 | 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
|
3527 | PurpleConnection *gc) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3528 | { |
| 10977 | 3529 | GList *l = NULL; |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3530 | PurpleProtocolChatEntry *pce; |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3531 | |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3532 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3533 | pce->label = _("Topic:"); |
| 10977 | 3534 | pce->identifier = CHAT_KEY_TOPIC; |
| 3535 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3536 | |
| 10977 | 3537 | return l; |
| 3538 | } | |
| 3539 | ||
| 3540 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3541 | static GHashTable * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3542 | 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
|
3543 | PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3544 | const char *name) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3545 | { |
| 10977 | 3546 | GHashTable *table; |
| 3547 | ||
| 3548 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3549 | ||
| 3550 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3551 | NULL, g_free); | |
| 3552 | ||
| 3553 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3554 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3555 | ||
| 3556 | return table; | |
| 3557 | } | |
| 3558 | ||
| 3559 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3560 | static void mw_protocol_login(PurpleAccount *acct); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3561 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3562 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3563 | static void mw_protocol_login(PurpleAccount *account) { |
| 15884 | 3564 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3565 | struct mwPurpleProtocolData *pd; |
| 10977 | 3566 | |
| 3567 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3568 | guint port; |
| 10977 | 3569 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3570 | GError *error = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3571 | |
| 15884 | 3572 | 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
|
3573 | pd = mwPurpleProtocolData_new(gc); |
| 10977 | 3574 | |
| 3575 | /* 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
|
3576 | purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_IMAGES); |
| 15884 | 3577 | |
| 3578 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3579 | |
| 3580 | host = strrchr(user, ':'); | |
| 3581 | if(host) { | |
| 3582 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3583 | *host++ = '\0'; | |
| 15884 | 3584 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3585 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3586 | |
| 10977 | 3587 | } else { |
| 15884 | 3588 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3589 | MW_PLUGIN_DEFAULT_HOST); |
| 3590 | } | |
| 3591 | ||
| 3592 | if(! host || ! *host) { | |
| 3593 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3594 | 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
|
3595 | 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
|
3596 | 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
|
3597 | 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
|
3598 | _("A server is required to connect this account")); |
| 10977 | 3599 | return; |
| 3600 | } | |
| 3601 | ||
|
34022
c49f6e9ea27d
Make all the prpls build.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
3602 | pass = g_strdup(purple_connection_get_password(gc)); |
| 15884 | 3603 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3604 | |
| 3605 | DEBUG_INFO("user: '%s'\n", user); | |
| 3606 | DEBUG_INFO("host: '%s'\n", host); | |
| 3607 | DEBUG_INFO("port: %u\n", port); | |
| 3608 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3609 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3610 | (char *) no_secret, NULL); |
| 3611 | 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
|
3612 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3613 | |
| 15884 | 3614 | 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
|
3615 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3616 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3617 | /* 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
|
3618 | 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
|
3619 | |
| 15884 | 3620 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3621 | 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
|
3622 | 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
|
3623 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3624 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3625 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3626 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3627 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3628 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3629 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3630 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3631 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3632 | GUINT_TO_POINTER(major), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3633 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3634 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3635 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3636 | } |
| 10977 | 3637 | |
| 15884 | 3638 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3639 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3640 | 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
|
3641 | if (pd->client == NULL) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3642 | purple_connection_take_error(gc, error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3643 | return; |
| 10977 | 3644 | } |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3645 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3646 | g_socket_client_connect_to_host_async( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3647 | pd->client, host, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3648 | port, pd->cancellable, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3649 | connect_cb, pd); |
| 10977 | 3650 | } |
| 3651 | ||
| 3652 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3653 | 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
|
3654 | struct mwPurpleProtocolData *pd; |
| 10977 | 3655 | |
| 3656 | g_return_if_fail(gc != NULL); | |
| 3657 | ||
|
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
|
3658 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3659 | g_return_if_fail(pd != NULL); |
| 3660 | ||
| 3661 | /* get rid of the blist save timeout */ | |
| 3662 | if(pd->save_event) { | |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
3663 | g_source_remove(pd->save_event); |
| 10977 | 3664 | pd->save_event = 0; |
| 3665 | blist_store(pd); | |
| 3666 | } | |
| 3667 | ||
| 3668 | /* stop the session */ | |
| 3669 | mwSession_stop(pd->session, 0x00); | |
| 3670 | ||
| 3671 | /* 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
|
3672 | purple_connection_set_protocol_data(gc, NULL); |
| 10977 | 3673 | |
| 3674 | /* 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
|
3675 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3676 | 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
|
3677 | pd->inpa = 0; |
| 10977 | 3678 | } |
| 3679 | ||
| 3680 | /* clean up the rest */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3681 | mwPurpleProtocolData_free(pd); |
| 10977 | 3682 | } |
| 3683 | ||
| 3684 | ||
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3685 | 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
|
3686 | PurpleMessage *msg) |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3687 | { |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3688 | gchar name[1000]; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3689 | struct mwPurpleProtocolData *pd; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3690 | struct mwIdBlock who = { name, NULL }; |
| 10977 | 3691 | struct mwConversation *conv; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3692 | const gchar *message; |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3693 | PurpleMessageFlags flags; |
| 10977 | 3694 | |
| 3695 | 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
|
3696 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3697 | |
| 3698 | g_return_val_if_fail(pd != NULL, 0); | |
| 3699 | ||
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
3700 | 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
|
3701 | message = purple_message_get_contents(msg); |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3702 | flags = purple_message_get_flags(msg); |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3703 | |
| 10977 | 3704 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 3705 | ||
| 3706 | /* this detection of features to determine how to send the message | |
| 3707 | (plain, html, or mime) is flawed because the other end of the | |
| 3708 | conversation could close their channel at any time, rendering any | |
| 3709 | existing formatting in an outgoing message innapropriate. The end | |
| 3710 | result is that it may be possible that the other side of the | |
| 3711 | conversation will receive a plaintext message with html contents, | |
| 3712 | which is bad. I'm not sure how to fix this correctly. */ | |
| 3713 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3714 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 3715 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 3716 | |
| 3717 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3718 | char *tmp; |
| 10977 | 3719 | int ret; |
| 3720 | ||
| 15884 | 3721 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 3722 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3723 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3724 | |
|
39523
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
3725 | tmp = im_mime_generate(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3726 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3727 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3728 | |
| 10977 | 3729 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3730 | /* send an HTML message */ |
| 10977 | 3731 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3732 | char *ncr; |
| 15884 | 3733 | ncr = purple_utf8_ncr_encode(message); |
| 3734 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3735 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3736 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3737 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3738 | g_free(tmp); |
| 10977 | 3739 | |
| 3740 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3741 | /* default to text */ |
| 15884 | 3742 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
3743 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3744 | g_free(tmp); |
| 10977 | 3745 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3746 | |
| 10977 | 3747 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3748 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3749 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3750 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3751 | /* queue up the message safely as plain text */ |
| 15884 | 3752 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3753 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3754 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3755 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3756 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3757 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3758 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3759 | return 1; |
| 10977 | 3760 | } |
| 3761 | } | |
| 3762 | ||
| 3763 | ||
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3764 | static unsigned int mw_protocol_send_typing(PurpleProtocolIM *im, |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3765 | PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3766 | 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
|
3767 | PurpleIMTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3768 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3769 | struct mwPurpleProtocolData *pd; |
| 10977 | 3770 | struct mwIdBlock who = { (char *) name, NULL }; |
| 3771 | struct mwConversation *conv; | |
| 3772 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
3773 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 3774 | |
| 3775 | 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
|
3776 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3777 | |
| 3778 | g_return_val_if_fail(pd != NULL, 0); | |
| 3779 | ||
| 3780 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 3781 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3782 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3783 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3784 | |
|
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
|
3785 | } 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
|
3786 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3787 | 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
|
3788 | 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
|
3789 | |
| 10977 | 3790 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3791 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3792 | if(! mwConversation_isPending(conv)) { |
| 10977 | 3793 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3794 | } |
| 10977 | 3795 | } |
| 3796 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3797 | return 0; |
| 10977 | 3798 | } |
| 3799 | ||
| 3800 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3801 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3802 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3803 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3804 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3805 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3806 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3807 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3808 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3809 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3810 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3811 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3812 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3813 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3814 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3815 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3816 | return "Lotus Sametime Links"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3817 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3818 | case mwLogin_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3819 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3820 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3821 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3822 | return "Lotus Notes Client"; |
|
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_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3825 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3826 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3827 | return "IBM Community Tools"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3828 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3829 | case mwLogin_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3830 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3831 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3832 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3833 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3834 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3835 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3836 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3837 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3838 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3839 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3840 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3841 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3842 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3843 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3844 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3845 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3846 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3847 | return "Trillian"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3848 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3849 | case mwLogin_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3850 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3851 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3852 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3853 | return NULL; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3854 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3855 | } |
|
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 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3858 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3859 | 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
|
3860 | PurpleConnection *gc, const gchar *who) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3861 | { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3862 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3863 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3864 | struct mwPurpleProtocolData *pd; |
| 15884 | 3865 | PurpleAccount *acct; |
| 3866 | PurpleBuddy *b; | |
| 3867 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3868 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3869 | const char *tmp2; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3870 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3871 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3872 | g_return_if_fail(*who != '\0'); |
| 10977 | 3873 | |
|
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
|
3874 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3875 | |
| 15884 | 3876 | 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
|
3877 | b = purple_blist_find_buddy(acct, who); |
| 15884 | 3878 | user_info = purple_notify_user_info_new(); |
| 3879 | ||
|
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
|
3880 | 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
|
3881 | 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
|
3882 | 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
|
3883 | } |
| 10977 | 3884 | |
|
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
|
3885 | 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
|
3886 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3887 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3888 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3889 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3890 | 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
|
3891 | /* 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
|
3892 | 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
|
3893 | 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
|
3894 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3895 | |
| 15884 | 3896 | 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
|
3897 | 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
|
3898 | 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
|
3899 | 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
|
3900 | 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
|
3901 | } else { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3902 | 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
|
3903 | 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
|
3904 | 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
|
3905 | } |
| 10977 | 3906 | } |
| 3907 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3908 | |
| 10977 | 3909 | tmp = user_supports_text(pd->srvc_aware, who); |
| 3910 | 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
|
3911 | 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
|
3912 | g_free(tmp); |
| 10977 | 3913 | } |
| 3914 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3915 | 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
|
3916 | 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
|
3917 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3918 | /* 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
|
3919 | 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
|
3920 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
| 15884 | 3921 | 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
|
3922 | 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
|
3923 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3924 | } |
| 10977 | 3925 | |
| 3926 | /* @todo emit a signal to allow a plugin to override the display of | |
| 3927 | this notification, so that it can create its own */ | |
| 3928 | ||
| 15884 | 3929 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 3930 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 3931 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3932 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3933 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3934 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3935 | 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
|
3936 | PurpleAccount *acct, PurpleStatus *status) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3937 | { |
| 15884 | 3938 | PurpleConnection *gc; |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3939 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
3940 | char *message = NULL; |
| 10977 | 3941 | struct mwSession *session; |
| 3942 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3943 | |
| 10977 | 3944 | g_return_if_fail(acct != NULL); |
| 15884 | 3945 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3946 | |
| 15884 | 3947 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3948 | |
| 15884 | 3949 | 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
|
3950 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3951 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3952 | |
| 10977 | 3953 | session = gc_to_session(gc); |
| 3954 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3955 | |
| 10977 | 3956 | /* get a working copy of the current status */ |
| 3957 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3958 | |
| 10977 | 3959 | /* determine the state */ |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3960 | if(purple_strequal(state, MW_STATE_ACTIVE)) { |
| 10977 | 3961 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3962 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3963 | } else if(purple_strequal(state, MW_STATE_AWAY)) { |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3964 | stat.status = mwStatus_AWAY; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3965 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3966 | } else if(purple_strequal(state, MW_STATE_BUSY)) { |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3967 | stat.status = mwStatus_BUSY; |
| 10977 | 3968 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3969 | |
| 10977 | 3970 | /* determine the message */ |
| 15884 | 3971 | 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
|
3972 | |
| 10977 | 3973 | if(message) { |
| 3974 | /* all the possible non-NULL values of message up to this point | |
| 3975 | are const, so we don't need to free them */ | |
| 15884 | 3976 | message = purple_markup_strip_html(message); |
| 10977 | 3977 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3978 | |
| 10977 | 3979 | /* out with the old */ |
| 3980 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3981 | |
| 10977 | 3982 | /* in with the new */ |
| 3983 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3984 | |
| 10977 | 3985 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3986 | mwUserStatus_clear(&stat); |
| 10977 | 3987 | } |
| 3988 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3989 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3990 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3991 | 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
|
3992 | PurpleConnection *gc, gint t) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3993 | { |
| 10977 | 3994 | struct mwSession *session; |
| 3995 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3996 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3997 | |
| 10977 | 3998 | session = gc_to_session(gc); |
| 3999 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4000 | |
| 10977 | 4001 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4002 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4003 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4004 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4005 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4006 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4007 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4008 | stat.time = 0; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4009 | } |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4010 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4011 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4012 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4013 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4014 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4015 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4016 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4017 | stat.status = mwStatus_ACTIVE; |
| 4018 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4019 | |
| 10977 | 4020 | mwSession_setUserStatus(session, &stat); |
| 4021 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4022 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4023 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4024 | |
| 15884 | 4025 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4026 | PurpleAccount *acct; | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
4027 | PurpleConversation *im; |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
4028 | PurpleConversationManager *manager; |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4029 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4030 | |
| 15884 | 4031 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4032 | id = g_list_nth_data(row, 1); |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
4033 | |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
4034 | manager = purple_conversation_manager_get_default(); |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
4035 | im = purple_conversation_manager_find_im(manager, acct, id); |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
4036 | if(!PURPLE_IS_IM_CONVERSATION(im)) { |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
4037 | im = purple_im_conversation_new(acct, id); |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40985
diff
changeset
|
4038 | } |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
4039 | purple_conversation_present(im); |
| 15884 | 4040 | } |
| 4041 | ||
| 4042 | ||
| 4043 | 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
|
4044 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4045 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4046 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4047 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4048 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4049 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4050 | |
| 15884 | 4051 | 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
|
4052 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4053 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4054 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4055 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4056 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4057 | 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
|
4058 | g_free(data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4059 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4060 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4061 | |
| 10977 | 4062 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4063 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4064 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4065 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4066 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4067 | char *msg; |
| 10977 | 4068 | |
| 15884 | 4069 | PurpleNotifySearchResults *sres; |
| 4070 | PurpleNotifySearchColumn *scol; | |
| 4071 | ||
| 4072 | sres = purple_notify_searchresults_new(); | |
| 4073 | ||
| 4074 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4075 | purple_notify_searchresults_column_add(sres, scol); | |
| 4076 | ||
| 4077 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4078 | purple_notify_searchresults_column_add(sres, scol); | |
| 4079 | ||
| 4080 | 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
|
4081 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4082 | |
| 15884 | 4083 | 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
|
4084 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4085 | |
| 10977 | 4086 | for(l = result->matches; l; l = l->next) { |
| 4087 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4088 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4089 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4090 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
4091 | match->id, match->name); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4092 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4093 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4094 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4095 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4096 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4097 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4098 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4099 | } |
| 10977 | 4100 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4101 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4102 | 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
|
4103 | " 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
|
4104 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4105 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4106 | |
| 15884 | 4107 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4108 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4109 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4110 | g_free(msg); |
| 10977 | 4111 | } |
| 4112 | ||
| 4113 | ||
| 4114 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4115 | guint32 id, guint32 code, GList *results, | |
| 4116 | gpointer b) { | |
| 4117 | ||
| 4118 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4119 | BuddyAddData *data = b; |
| 15884 | 4120 | PurpleBuddy *buddy = NULL; |
| 4121 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4122 | struct mwPurpleProtocolData *pd; |
| 10977 | 4123 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4124 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4125 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4126 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4127 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4128 | 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
|
4129 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4130 | |
| 4131 | if(results) | |
| 4132 | res = results->data; | |
| 4133 | ||
| 4134 | 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
|
4135 | if(!res->matches->next) { |
| 10977 | 4136 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4137 | |
| 10977 | 4138 | /* only one? that might be the right one! */ |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4139 | if(!purple_strequal(res->name, match->id)) { |
| 10977 | 4140 | /* uh oh, the single result isn't identical to the search |
| 4141 | term, better safe then sorry, so let's make sure it's who | |
| 4142 | the user meant to add */ | |
| 15884 | 4143 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4144 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4145 | |
| 10977 | 4146 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4147 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4148 | /* 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
|
4149 | purple_buddy_set_server_alias(buddy, match->name); |
| 15884 | 4150 | purple_blist_node_set_string((PurpleBlistNode *) buddy, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4151 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4152 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4153 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4154 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4155 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4156 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4157 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4158 | g_free(data); |
| 10977 | 4159 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4160 | |
| 10977 | 4161 | } else { |
| 4162 | /* prompt user if more than one match was returned */ | |
| 15884 | 4163 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4164 | multi_resolved_query(res, gc, data); |
| 10977 | 4165 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4166 | |
| 10977 | 4167 | return; |
| 4168 | } | |
| 4169 | } | |
| 4170 | ||
| 4171 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4172 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4173 | 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
|
4174 | PurpleConnection *gc, PurpleBuddy *buddy, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4175 | PurpleGroup *group, const gchar *message) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4176 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4177 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4178 | struct mwServiceResolve *srvc; |
| 4179 | GList *query; | |
| 4180 | enum mwResolveFlag flags; | |
| 4181 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4182 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4183 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4184 | /* 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
|
4185 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4186 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4187 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4188 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4189 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4190 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4191 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4192 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4193 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4194 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4195 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4196 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4197 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4198 | ||
| 4199 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4200 | data, NULL); |
| 10977 | 4201 | g_list_free(query); |
| 4202 | ||
| 4203 | if(req == SEARCH_ERROR) { | |
| 15884 | 4204 | purple_blist_remove_buddy(buddy); |
| 10977 | 4205 | blist_schedule(pd); |
| 4206 | } | |
| 4207 | } | |
| 4208 | ||
| 4209 | ||
| 15884 | 4210 | 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
|
4211 | struct mwPurpleProtocolData *pd) { |
| 10977 | 4212 | struct mwAwareList *list; |
| 4213 | ||
| 4214 | list = list_ensure(pd, group); | |
| 4215 | mwAwareList_addAware(list, buddies); | |
| 4216 | g_list_free(buddies); | |
| 4217 | } | |
| 4218 | ||
| 4219 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4220 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4221 | 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
|
4222 | PurpleConnection *gc, |
| 10977 | 4223 | GList *buddies, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4224 | GList *groups, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4225 | const char *message) { |
| 10977 | 4226 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4227 | struct mwPurpleProtocolData *pd; |
| 10977 | 4228 | GHashTable *group_sets; |
| 4229 | struct mwAwareIdBlock *idbs, *idb; | |
| 4230 | ||
|
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
|
4231 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4232 | |
| 15884 | 4233 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4234 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4235 | ||
| 4236 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4237 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4238 | ||
| 4239 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4240 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4241 | PurpleBuddy *b = buddies->data; |
| 4242 | PurpleGroup *g; | |
| 10977 | 4243 | const char *fn; |
| 4244 | GList *l; | |
| 4245 | ||
| 4246 | /* nab the saved server alias and stick it on the buddy */ | |
| 15884 | 4247 | 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
|
4248 | purple_buddy_set_server_alias(b, fn); |
| 15884 | 4249 | |
| 4250 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4251 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4252 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4253 | idb->community = NULL; |
| 4254 | ||
| 4255 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4256 | g = purple_buddy_get_group(b); |
| 10977 | 4257 | l = g_hash_table_lookup(group_sets, g); |
| 4258 | l = g_list_prepend(l, idb++); | |
| 4259 | g_hash_table_insert(group_sets, g, l); | |
| 4260 | } | |
| 4261 | ||
| 4262 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4263 | for saving */ | |
| 4264 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4265 | blist_schedule(pd); | |
| 4266 | ||
| 4267 | /* cleanup */ | |
| 4268 | g_hash_table_destroy(group_sets); | |
| 4269 | g_free(idbs); | |
| 4270 | } | |
| 4271 | ||
| 4272 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4273 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4274 | 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
|
4275 | PurpleConnection *gc, PurpleBuddy *buddy, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4276 | PurpleGroup *group) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4277 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4278 | struct mwPurpleProtocolData *pd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4279 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4280 | struct mwAwareList *list; |
| 4281 | ||
| 4282 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4283 | ||
|
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
|
4284 | pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4285 | group = purple_buddy_get_group(buddy); |
| 10977 | 4286 | list = list_ensure(pd, group); |
| 4287 | ||
| 4288 | mwAwareList_removeAware(list, rem); | |
| 4289 | blist_schedule(pd); | |
| 4290 | ||
| 4291 | g_list_free(rem); | |
| 4292 | } | |
| 4293 | ||
| 4294 | ||
| 4295 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4296 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4297 | |
| 10977 | 4298 | struct mwUserItem *u; |
| 4299 | guint count; | |
| 4300 | ||
| 4301 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4302 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4303 | |
| 4304 | priv->count = count; | |
| 4305 | priv->users = g_new0(struct mwUserItem, count); | |
| 4306 | ||
| 4307 | while(count--) { | |
| 4308 | u = priv->users + count; | |
| 4309 | u->id = members->data; | |
| 4310 | members = members->next; | |
| 4311 | } | |
| 4312 | } | |
| 4313 | ||
| 4314 | ||
|
40521
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4315 | 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
|
4316 | 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
|
4317 | { |
| 15884 | 4318 | PurpleAccount *acct; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4319 | struct mwPurpleProtocolData *pd; |
| 10977 | 4320 | struct mwSession *session; |
| 4321 | ||
| 4322 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4323 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4324 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4325 | NULL, /* users */ |
| 10977 | 4326 | }; |
| 4327 | ||
| 4328 | g_return_if_fail(gc != NULL); | |
| 4329 | ||
| 15884 | 4330 | acct = purple_connection_get_account(gc); |
| 10977 | 4331 | g_return_if_fail(acct != NULL); |
| 4332 | ||
|
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
|
4333 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4334 | g_return_if_fail(pd != NULL); |
| 4335 | ||
| 4336 | session = pd->session; | |
| 4337 | g_return_if_fail(session != NULL); | |
| 4338 | ||
|
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
|
4339 | 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
|
4340 | case PURPLE_ACCOUNT_PRIVACY_DENY_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4341 | 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
|
4342 | privacy_fill(&privacy, purple_account_privacy_get_denied(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4343 | privacy.deny = TRUE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4344 | break; |
| 10977 | 4345 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4346 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4347 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL\n"); |
| 10977 | 4348 | privacy.deny = TRUE; |
| 4349 | break; | |
| 4350 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4351 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4352 | 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
|
4353 | privacy_fill(&privacy, purple_account_privacy_get_permitted(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4354 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4355 | break; |
| 10977 | 4356 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4357 | case PURPLE_ACCOUNT_PRIVACY_DENY_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4358 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_DENY_ALL\n"); |
| 10977 | 4359 | privacy.deny = FALSE; |
| 4360 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4361 | |
| 10977 | 4362 | 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
|
4363 | 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
|
4364 | return; |
| 10977 | 4365 | } |
| 4366 | ||
| 4367 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4368 | g_free(privacy.users); | |
| 4369 | } | |
| 4370 | ||
| 4371 | ||
|
40521
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4372 | 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
|
4373 | 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
|
4374 | { |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4375 | 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
|
4376 | } |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4377 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4378 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4379 | 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
|
4380 | 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
|
4381 | { |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4382 | 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
|
4383 | } |
|
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 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4386 | 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
|
4387 | 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
|
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 | 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
|
4390 | } |
|
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 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4393 | 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
|
4394 | 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
|
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 | mw_protocol_set_permit_deny(privacy, gc); |
| 10977 | 4397 | } |
| 4398 | ||
| 4399 | ||
| 4400 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4401 | const char *name) { | |
| 4402 | GList *l, *ll; | |
| 4403 | struct mwConference *conf = NULL; | |
| 4404 | ||
| 4405 | ll = mwServiceConference_getConferences(srvc); | |
| 4406 | for(l = ll; l; l = l->next) { | |
| 4407 | struct mwConference *c = l->data; | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4408 | if(purple_strequal(name, mwConference_getName(c))) { |
| 10977 | 4409 | conf = c; |
| 4410 | break; | |
| 4411 | } | |
| 4412 | } | |
| 4413 | g_list_free(ll); | |
| 4414 | ||
| 4415 | return conf; | |
| 4416 | } | |
| 4417 | ||
| 4418 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4419 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4420 | 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
|
4421 | GHashTable *components) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4422 | { |
| 10977 | 4423 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4424 | struct mwPurpleProtocolData *pd; |
| 10977 | 4425 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4426 | |
|
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
|
4427 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4428 | |
| 4429 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4430 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4431 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4432 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4433 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4434 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4435 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4436 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4437 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4438 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4439 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4440 | |
| 10977 | 4441 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4442 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4443 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4444 | struct mwConference *conf = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4445 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4446 | srvc = pd->srvc_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4447 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4448 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4449 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4450 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4451 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4452 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4453 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4454 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4455 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4456 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4457 | } |
| 10977 | 4458 | } |
| 4459 | } | |
| 4460 | ||
| 4461 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4462 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4463 | 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
|
4464 | PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4465 | GHashTable *components) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4466 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4467 | struct mwPurpleProtocolData *pd; |
| 10977 | 4468 | struct mwServiceConference *srvc; |
| 4469 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4470 | |
|
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
|
4471 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4472 | srvc = pd->srvc_conf; |
| 4473 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4474 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4475 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4476 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4477 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4478 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4479 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4480 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4481 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4482 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4483 | } |
| 10977 | 4484 | } |
| 4485 | } | |
| 4486 | ||
| 4487 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4488 | static char * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4489 | 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
|
4490 | GHashTable *components) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4491 | { |
| 10977 | 4492 | return g_hash_table_lookup(components, CHAT_KEY_NAME); |
| 4493 | } | |
| 4494 | ||
| 4495 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4496 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4497 | 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
|
4498 | 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
|
4499 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4500 | struct mwPurpleProtocolData *pd; |
| 10977 | 4501 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4502 | struct mwPlace *place; |
| 10977 | 4503 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4504 | ||
|
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
|
4505 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4506 | g_return_if_fail(pd != NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4507 | |
| 10977 | 4508 | conf = ID_TO_CONF(pd, id); |
| 4509 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4510 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4511 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4512 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4513 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4514 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4515 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4516 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4517 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4518 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4519 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4520 | } |
| 4521 | ||
| 4522 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4523 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4524 | 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
|
4525 | int id) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4526 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4527 | struct mwPurpleProtocolData *pd; |
| 10977 | 4528 | struct mwConference *conf; |
| 4529 | ||
|
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
|
4530 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4531 | |
| 4532 | g_return_if_fail(pd != NULL); | |
| 4533 | conf = ID_TO_CONF(pd, id); | |
| 4534 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4535 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4536 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4537 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4538 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4539 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4540 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4541 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4542 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4543 | } |
| 10977 | 4544 | } |
| 4545 | ||
| 4546 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4547 | static int |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4548 | 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
|
4549 | int id, PurpleMessage *pmsg) |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
4550 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4551 | struct mwPurpleProtocolData *pd; |
| 10977 | 4552 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4553 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4554 | int ret; |
| 10977 | 4555 | |
|
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
|
4556 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4557 | |
| 4558 | g_return_val_if_fail(pd != NULL, 0); | |
| 4559 | conf = ID_TO_CONF(pd, id); | |
| 4560 | ||
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
4561 | 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
|
4562 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4563 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4564 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4565 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4566 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4567 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4568 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4569 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4570 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4571 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4572 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4573 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4574 | return ret; |
| 10977 | 4575 | } |
| 4576 | ||
| 4577 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4578 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4579 | mw_protocol_keepalive(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4580 | PurpleConnection *gc) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4581 | { |
| 10977 | 4582 | struct mwSession *session; |
| 4583 | ||
| 4584 | g_return_if_fail(gc != NULL); | |
| 4585 | ||
| 4586 | session = gc_to_session(gc); | |
| 4587 | g_return_if_fail(session != NULL); | |
| 4588 | ||
| 4589 | mwSession_sendKeepalive(session); | |
| 4590 | } | |
| 4591 | ||
| 4592 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4593 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4594 | 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
|
4595 | PurpleConnection *gc, const gchar *who, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4596 | const gchar *alias) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4597 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4598 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4599 | g_return_if_fail(pd != NULL); |
| 4600 | ||
| 4601 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4602 | the server copy */ | |
| 4603 | ||
| 4604 | blist_schedule(pd); | |
| 4605 | } | |
| 4606 | ||
| 4607 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4608 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4609 | 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
|
4610 | PurpleConnection *gc, const gchar *who, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4611 | 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
|
4612 | { |
| 10977 | 4613 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
| 4614 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4615 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4616 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4617 | PurpleGroup *group; |
| 10977 | 4618 | struct mwAwareList *list; |
| 4619 | ||
| 4620 | /* 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
|
4621 | group = purple_blist_find_group(new_group); |
| 10977 | 4622 | list = list_ensure(pd, group); |
| 4623 | mwAwareList_addAware(list, gl); | |
| 4624 | ||
| 4625 | /* 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
|
4626 | group = purple_blist_find_group(old_group); |
| 10977 | 4627 | list = list_ensure(pd, group); |
| 4628 | mwAwareList_removeAware(list, gl); | |
| 4629 | ||
| 4630 | g_list_free(gl); | |
| 4631 | ||
| 4632 | /* schedule the changes to be saved */ | |
| 4633 | blist_schedule(pd); | |
| 4634 | } | |
| 4635 | ||
| 4636 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4637 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4638 | 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
|
4639 | PurpleConnection *gc, const gchar *old, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4640 | PurpleGroup *group, GList *buddies) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4641 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4642 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4643 | g_return_if_fail(pd != NULL); |
| 4644 | ||
| 4645 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4646 | the server copy. Also, having this function should prevent all | |
| 4647 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4648 | give a crap what the group is named in Purple other than to record |
| 10977 | 4649 | that as the group name/alias */ |
| 4650 | ||
| 4651 | blist_schedule(pd); | |
| 4652 | } | |
| 4653 | ||
| 4654 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4655 | static void |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4656 | mw_protocol_buddy_free(PurpleProtocolClient *client, PurpleBuddy *buddy) { |
| 10977 | 4657 | /* I don't think we have any cleanup for buddies yet */ |
| 4658 | ; | |
| 4659 | } | |
| 4660 | ||
| 4661 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4662 | static void |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4663 | 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
|
4664 | 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
|
4665 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4666 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4667 | struct mwServiceIm *srvc; |
| 4668 | struct mwConversation *conv; | |
| 4669 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4670 | ||
| 4671 | g_return_if_fail(pd != NULL); | |
| 4672 | ||
| 4673 | srvc = pd->srvc_im; | |
| 4674 | g_return_if_fail(srvc != NULL); | |
| 4675 | ||
| 4676 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 4677 | if(! conv) return; | |
| 4678 | ||
| 4679 | if(mwConversation_isOpen(conv)) | |
| 4680 | mwConversation_free(conv); | |
| 4681 | } | |
| 4682 | ||
| 4683 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4684 | 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
|
4685 | 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
|
4686 | 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
|
4687 | { |
| 10977 | 4688 | |
| 4689 | /* code elsewhere assumes that the return value points to different | |
| 4690 | memory than the passed value, but it won't free the normalized | |
| 4691 | data. wtf? */ | |
| 4692 | ||
| 4693 | 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
|
4694 | g_strlcpy(buf, id, sizeof(buf)); |
| 10977 | 4695 | return buf; |
| 4696 | } | |
| 4697 | ||
| 4698 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4699 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4700 | 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
|
4701 | PurpleConnection *gc, PurpleGroup *group) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4702 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4703 | struct mwPurpleProtocolData *pd; |
| 10977 | 4704 | struct mwAwareList *list; |
| 4705 | ||
|
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
|
4706 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4707 | g_return_if_fail(pd != NULL); |
| 4708 | g_return_if_fail(pd->group_list_map != NULL); | |
| 4709 | ||
| 4710 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 4711 | ||
| 4712 | if(list) { | |
| 4713 | g_hash_table_remove(pd->group_list_map, list); | |
| 4714 | g_hash_table_remove(pd->group_list_map, group); | |
| 4715 | mwAwareList_free(list); | |
| 4716 | ||
| 4717 | blist_schedule(pd); | |
| 4718 | } | |
| 4719 | } | |
| 4720 | ||
| 4721 | ||
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4722 | 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
|
4723 | PurpleConnection *gc, |
| 10977 | 4724 | const char *who) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4725 | struct mwPurpleProtocolData *pd; |
| 10977 | 4726 | struct mwServiceAware *srvc; |
| 15884 | 4727 | PurpleAccount *acct; |
| 10977 | 4728 | |
| 4729 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 4730 | ||
|
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
|
4731 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4732 | g_return_val_if_fail(pd != NULL, FALSE); |
| 4733 | ||
| 4734 | srvc = pd->srvc_aware; | |
| 4735 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4736 | |
| 15884 | 4737 | acct = purple_connection_get_account(gc); |
| 10977 | 4738 | g_return_val_if_fail(acct != NULL, FALSE); |
| 4739 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4740 | return purple_blist_find_buddy(acct, who) && |
| 10977 | 4741 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 4742 | } | |
| 4743 | ||
| 4744 | ||
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4745 | 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
|
4746 | PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4747 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4748 | |
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4749 | PurpleXfer *xfer = mw_protocol_new_xfer(prplxfer, gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4750 | |
| 10977 | 4751 | if(file) { |
| 4752 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 4753 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 4754 | |
| 4755 | } else { | |
| 4756 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 4757 | purple_xfer_request(xfer); |
| 10977 | 4758 | } |
| 4759 | } | |
| 4760 | ||
| 4761 | ||
| 15884 | 4762 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 4763 | struct mwSametimeList *l; |
| 4764 | ||
| 4765 | FILE *file; | |
| 4766 | char buf[BUF_LEN]; | |
| 4767 | size_t len; | |
| 4768 | ||
| 4769 | GString *str; | |
| 4770 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
4771 | file = g_fopen(filename, "r"); |
| 10977 | 4772 | g_return_if_fail(file != NULL); |
| 4773 | ||
| 4774 | str = g_string_new(NULL); | |
| 4775 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 4776 | g_string_append_len(str, buf, len); | |
| 4777 | } | |
| 4778 | ||
| 4779 | fclose(file); | |
| 4780 | ||
| 4781 | l = mwSametimeList_load(str->str); | |
| 4782 | g_string_free(str, TRUE); | |
| 4783 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4784 | blist_merge(gc, l); |
| 10977 | 4785 | mwSametimeList_free(l); |
| 4786 | } | |
| 4787 | ||
| 4788 | ||
| 4789 | /** prompts for a file to import blist from */ | |
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4790 | static void |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4791 | st_import_action(G_GNUC_UNUSED GSimpleAction *action, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4792 | GVariant *parameter, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4793 | G_GNUC_UNUSED gpointer data) |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4794 | { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4795 | const gchar *account_id = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4796 | PurpleAccountManager *manager = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4797 | PurpleAccount *account = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4798 | PurpleConnection *gc = NULL; |
| 10977 | 4799 | char *title; |
| 4800 | ||
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4801 | if(!g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4802 | g_critical("Sametime import action parameter is of incorrect type %s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4803 | g_variant_get_type_string(parameter)); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4804 | } |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4805 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4806 | account_id = g_variant_get_string(parameter, NULL); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4807 | manager = purple_account_manager_get_default(); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4808 | account = purple_account_manager_find_by_id(manager, account_id); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4809 | gc = purple_account_get_connection(account); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4810 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4811 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 4812 | purple_account_get_username(account)); |
| 4813 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4814 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 4815 | 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
|
4816 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4817 | gc); |
| 10977 | 4818 | |
| 4819 | g_free(title); | |
| 4820 | } | |
| 4821 | ||
| 4822 | ||
| 15884 | 4823 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 4824 | struct mwSametimeList *l; |
| 4825 | char *str; | |
| 4826 | FILE *file; | |
| 4827 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
4828 | file = g_fopen(filename, "w"); |
| 10977 | 4829 | g_return_if_fail(file != NULL); |
| 4830 | ||
| 4831 | l = mwSametimeList_new(); | |
| 4832 | blist_export(gc, l); | |
| 4833 | str = mwSametimeList_store(l); | |
| 4834 | mwSametimeList_free(l); | |
| 4835 | ||
| 4836 | fprintf(file, "%s", str); | |
| 4837 | fclose(file); | |
| 4838 | ||
| 4839 | g_free(str); | |
| 4840 | } | |
| 4841 | ||
| 4842 | ||
| 4843 | /** prompts for a file to export blist to */ | |
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4844 | static void |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4845 | st_export_action(G_GNUC_UNUSED GSimpleAction *action, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4846 | GVariant *parameter, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4847 | G_GNUC_UNUSED gpointer data) |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4848 | { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4849 | const gchar *account_id = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4850 | PurpleAccountManager *manager = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4851 | PurpleAccount *account = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4852 | PurpleConnection *gc = NULL; |
| 10977 | 4853 | char *title; |
| 4854 | ||
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4855 | if(!g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4856 | g_critical("Sametime export action parameter is of incorrect type %s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4857 | g_variant_get_type_string(parameter)); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4858 | } |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4859 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4860 | account_id = g_variant_get_string(parameter, NULL); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4861 | manager = purple_account_manager_get_default(); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4862 | account = purple_account_manager_find_by_id(manager, account_id); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4863 | gc = purple_account_get_connection(account); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
4864 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4865 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 4866 | purple_account_get_username(account)); |
| 4867 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4868 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 4869 | 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
|
4870 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4871 | gc); |
| 10977 | 4872 | |
| 4873 | g_free(title); | |
| 4874 | } | |
| 4875 | ||
| 4876 | ||
| 4877 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 4878 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4879 | |
| 15884 | 4880 | 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
|
4881 | GList *l; |
| 10977 | 4882 | |
| 15884 | 4883 | f = purple_request_fields_get_field(fields, "group"); |
| 4884 | l = purple_request_field_list_get_items(f); | |
| 10977 | 4885 | |
| 4886 | for(; l; l = l->next) { | |
| 4887 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4888 | struct named_id *res; |
| 10977 | 4889 | |
| 15884 | 4890 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 4891 | |
| 4892 | g_free(res->id); | |
| 4893 | g_free(res->name); | |
| 4894 | g_free(res); | |
| 4895 | } | |
| 4896 | } | |
| 4897 | ||
| 4898 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4899 | static void remote_group_done(struct mwPurpleProtocolData *pd, |
| 10977 | 4900 | const char *id, const char *name) { |
| 15884 | 4901 | PurpleConnection *gc; |
| 4902 | PurpleAccount *acct; | |
| 4903 | PurpleGroup *group; | |
| 4904 | PurpleBlistNode *gn; | |
| 10977 | 4905 | const char *owner; |
| 4906 | ||
| 4907 | g_return_if_fail(pd != NULL); | |
| 4908 | ||
| 4909 | gc = pd->gc; | |
| 15884 | 4910 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4911 | |
| 10977 | 4912 | /* collision checking */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4913 | group = purple_blist_find_group(name); |
| 10977 | 4914 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4915 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4916 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4917 | char *msg; |
| 10977 | 4918 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4919 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4920 | 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
|
4921 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4922 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
4923 | 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
|
4924 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4925 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4926 | g_free(msg); |
| 10977 | 4927 | return; |
| 4928 | } | |
| 4929 | ||
| 15884 | 4930 | group = purple_group_new(name); |
| 4931 | gn = (PurpleBlistNode *) group; | |
| 4932 | ||
| 4933 | owner = purple_account_get_username(acct); | |
| 4934 | ||
| 4935 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 4936 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 4937 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 4938 | purple_blist_add_group(group, NULL); | |
| 10977 | 4939 | |
| 4940 | group_add(pd, group); | |
| 4941 | blist_schedule(pd); | |
| 4942 | } | |
| 4943 | ||
| 4944 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4945 | static void remote_group_multi_cb(struct mwPurpleProtocolData *pd, |
| 15884 | 4946 | PurpleRequestFields *fields) { |
| 4947 | 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
|
4948 | GList *l; |
| 10977 | 4949 | |
| 15884 | 4950 | f = purple_request_fields_get_field(fields, "group"); |
| 4951 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 4952 | |
| 4953 | if(l) { | |
| 4954 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4955 | struct named_id *res; |
| 10977 | 4956 | |
| 15884 | 4957 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 4958 | remote_group_done(pd, res->id, res->name); |
| 4959 | } | |
| 4960 | ||
| 4961 | remote_group_multi_cleanup(NULL, fields); | |
| 4962 | } | |
| 4963 | ||
| 4964 | ||
| 4965 | 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
|
4966 | struct mwPurpleProtocolData *pd) { |
| 15884 | 4967 | |
| 4968 | PurpleRequestFields *fields; | |
| 4969 | PurpleRequestFieldGroup *g; | |
| 4970 | PurpleRequestField *f; | |
| 10977 | 4971 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4972 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4973 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4974 | char *msg; |
| 10977 | 4975 | |
| 15884 | 4976 | PurpleConnection *gc = pd->gc; |
| 4977 | ||
| 4978 | fields = purple_request_fields_new(); | |
| 4979 | ||
| 4980 | g = purple_request_field_group_new(NULL); | |
| 4981 | purple_request_fields_add_group(fields, g); | |
| 4982 | ||
| 4983 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 4984 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 4985 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 4986 | |
| 4987 | for(l = result->matches; l; l = l->next) { | |
| 4988 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4989 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 4990 | |
| 4991 | res->id = g_strdup(match->id); | |
| 4992 | res->name = g_strdup(match->name); | |
| 4993 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
4994 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 4995 | } |
| 4996 | ||
| 15884 | 4997 | purple_request_field_group_add_field(g, f); |
| 10977 | 4998 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4999 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5000 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 5001 | " Notes Address Book groups. Please select the correct group from" |
| 5002 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5003 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 5004 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5005 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5006 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5007 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5008 | _("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
|
5009 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5010 | pd); |
| 10977 | 5011 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5012 | g_free(msg); |
| 10977 | 5013 | } |
| 5014 | ||
| 5015 | ||
| 5016 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 5017 | guint32 id, guint32 code, GList *results, | |
| 5018 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5019 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5020 | struct mwResolveResult *res = NULL; |
| 10977 | 5021 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5022 | struct mwPurpleProtocolData *pd; |
| 15884 | 5023 | PurpleConnection *gc; |
| 10977 | 5024 | |
| 5025 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5026 | g_return_if_fail(session != NULL); | |
| 5027 | ||
| 5028 | pd = mwSession_getClientData(session); | |
| 5029 | g_return_if_fail(pd != NULL); | |
| 5030 | ||
| 5031 | gc = pd->gc; | |
| 5032 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5033 | |
| 10977 | 5034 | if(!code && results) { |
| 5035 | res = results->data; | |
| 5036 | ||
| 5037 | if(res->matches) { | |
| 5038 | remote_group_multi(res, pd); | |
| 5039 | return; | |
| 5040 | } | |
| 5041 | } | |
| 5042 | ||
| 5043 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5044 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5045 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5046 | char *msg; |
| 10977 | 5047 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5048 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5049 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5050 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5051 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5052 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5053 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5054 | 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
|
5055 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5056 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5057 | g_free(msg); |
| 10977 | 5058 | } |
| 5059 | } | |
| 5060 | ||
| 5061 | ||
| 15884 | 5062 | 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
|
5063 | struct mwPurpleProtocolData *pd; |
| 10977 | 5064 | struct mwServiceResolve *srvc; |
| 5065 | GList *query; | |
| 5066 | enum mwResolveFlag flags; | |
| 5067 | guint32 req; | |
| 5068 | ||
|
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
|
5069 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5070 | srvc = pd->srvc_resolve; |
| 5071 | ||
| 5072 | query = g_list_prepend(NULL, (char *) name); | |
| 5073 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5074 | |
| 10977 | 5075 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5076 | NULL, NULL); | |
| 5077 | g_list_free(query); | |
| 5078 | ||
| 5079 | if(req == SEARCH_ERROR) { | |
| 5080 | /** @todo display error */ | |
| 5081 | } | |
| 5082 | } | |
| 5083 | ||
| 5084 | ||
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5085 | static void |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5086 | remote_group_action(G_GNUC_UNUSED GSimpleAction *action, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5087 | GVariant *parameter, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5088 | G_GNUC_UNUSED gpointer data) |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5089 | { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5090 | const gchar *account_id = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5091 | PurpleAccountManager *manager = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5092 | PurpleAccount *account = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5093 | PurpleConnection *gc = NULL; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5094 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5095 | const char *msgB; |
| 10977 | 5096 | |
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5097 | if(!g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5098 | g_critical("Sametime export action parameter is of incorrect type %s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5099 | g_variant_get_type_string(parameter)); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5100 | } |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5101 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5102 | account_id = g_variant_get_string(parameter, NULL); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5103 | manager = purple_account_manager_get_default(); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5104 | account = purple_account_manager_find_by_id(manager, account_id); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5105 | gc = purple_account_get_connection(account); |
| 10977 | 5106 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5107 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5108 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5109 | " to add the group and its members to your buddy list."); |
| 5110 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5111 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5112 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5113 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5114 | _("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
|
5115 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5116 | gc); |
| 10977 | 5117 | } |
| 5118 | ||
| 5119 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5120 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5121 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5122 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5123 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5124 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5125 | char *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5126 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5127 | |
| 15884 | 5128 | PurpleNotifySearchResults *sres; |
| 5129 | PurpleNotifySearchColumn *scol; | |
| 5130 | ||
| 5131 | sres = purple_notify_searchresults_new(); | |
| 5132 | ||
| 5133 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5134 | purple_notify_searchresults_column_add(sres, scol); | |
| 5135 | ||
| 5136 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5137 | purple_notify_searchresults_column_add(sres, scol); | |
| 5138 | ||
| 5139 | 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
|
5140 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5141 | |
| 15884 | 5142 | 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
|
5143 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5144 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5145 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5146 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5147 | GList *row = NULL; |
|
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(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5150 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5151 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5152 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5153 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5154 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5155 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5156 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5157 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5158 | 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
|
5159 | " 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
|
5160 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5161 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5162 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5163 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5164 | |
| 15884 | 5165 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5166 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5167 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5168 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5169 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5170 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5171 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5172 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5173 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5174 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5175 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5176 | |
| 15884 | 5177 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5178 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5179 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5180 | if(results) res = results->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5181 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5182 | if(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5183 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5184 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5185 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5186 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5187 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5188 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5189 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5190 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5191 | 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
|
5192 | " Sametime community."); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
5193 | msg = g_strdup_printf(msgB, (res && res->name) ? res->name : ""); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5194 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5195 | 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
|
5196 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5197 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5198 | g_free(msg); |
|
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 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5201 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5202 | |
| 15884 | 5203 | 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
|
5204 | struct mwPurpleProtocolData *pd; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5205 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5206 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5207 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5208 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5209 | |
|
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
|
5210 | pd = purple_connection_get_protocol_data(gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5211 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5212 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5213 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5214 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5215 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5216 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5217 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5218 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5219 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5220 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5221 | /** @todo display error */ |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5222 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5223 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5224 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5225 | |
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5226 | static void |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5227 | search_action(G_GNUC_UNUSED GSimpleAction *action, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5228 | GVariant *parameter, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5229 | G_GNUC_UNUSED gpointer data) |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5230 | { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5231 | const gchar *account_id = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5232 | PurpleAccountManager *manager = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5233 | PurpleAccount *account = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5234 | PurpleConnection *gc = NULL; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5235 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5236 | const char *msgB; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5237 | |
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5238 | if(!g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5239 | g_critical("Sametime export action parameter is of incorrect type %s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5240 | g_variant_get_type_string(parameter)); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5241 | } |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5242 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5243 | account_id = g_variant_get_string(parameter, NULL); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5244 | manager = purple_account_manager_get_default(); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5245 | account = purple_account_manager_find_by_id(manager, account_id); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5246 | gc = purple_account_get_connection(account); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5247 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5248 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5249 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5250 | 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
|
5251 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5252 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5253 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5254 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5255 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5256 | _("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
|
5257 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5258 | gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5259 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5260 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5261 | |
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5262 | static const gchar * |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5263 | mw_protocol_actions_get_prefix(PurpleProtocolActions *actions) { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5264 | return PLUGIN_ID; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5265 | } |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5266 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5267 | static GActionGroup * |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5268 | mw_protocol_actions_get_action_group(PurpleProtocolActions *actions, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5269 | PurpleConnection *connection) |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5270 | { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5271 | GSimpleActionGroup *group = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5272 | GActionEntry entries[] = { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5273 | { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5274 | .name = "import", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5275 | .activate = st_import_action, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5276 | .parameter_type = "s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5277 | }, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5278 | { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5279 | .name = "export", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5280 | .activate = st_export_action, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5281 | .parameter_type = "s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5282 | }, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5283 | { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5284 | .name = "notes", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5285 | .activate = remote_group_action, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5286 | .parameter_type = "s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5287 | }, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5288 | { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5289 | .name = "search", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5290 | .activate = search_action, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5291 | .parameter_type = "s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5292 | }, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5293 | }; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5294 | gsize nentries = G_N_ELEMENTS(entries); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5295 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5296 | group = g_simple_action_group_new(); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5297 | g_action_map_add_action_entries(G_ACTION_MAP(group), entries, nentries, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5298 | NULL); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5299 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5300 | return G_ACTION_GROUP(group); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5301 | } |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5302 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5303 | static GMenu * |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5304 | mw_protocol_actions_get_menu(PurpleProtocolActions *actions) { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5305 | GMenu *menu = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5306 | GMenuItem *item = NULL; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5307 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5308 | menu = g_menu_new(); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5309 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5310 | item = g_menu_item_new(_("Import Sametime List..."), |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5311 | PLUGIN_ID ".import"); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5312 | g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5313 | "account"); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5314 | g_menu_append_item(menu, item); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5315 | g_object_unref(item); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5316 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5317 | item = g_menu_item_new(_("Export Sametime List..."), |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5318 | PLUGIN_ID ".export"); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5319 | g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5320 | "account"); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5321 | g_menu_append_item(menu, item); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5322 | g_object_unref(item); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5323 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5324 | item = g_menu_item_new(_("Add Notes Address Book Group..."), |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5325 | PLUGIN_ID ".notes"); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5326 | g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5327 | "account"); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5328 | g_menu_append_item(menu, item); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5329 | g_object_unref(item); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5330 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5331 | item = g_menu_item_new(_("User Search..."), PLUGIN_ID ".search"); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5332 | g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s", |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5333 | "account"); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5334 | g_menu_append_item(menu, item); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5335 | g_object_unref(item); |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5336 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5337 | return menu; |
| 10977 | 5338 | } |
| 5339 | ||
| 5340 | ||
| 5341 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5342 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5343 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5344 | if(! (msg && *msg)) return; |
| 10977 | 5345 | |
| 15884 | 5346 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5347 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5348 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5349 | |
| 5350 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5351 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5352 | |
| 5353 | } else { | |
| 15884 | 5354 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5355 | } |
| 5356 | } | |
| 5357 | ||
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5358 | static void |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5359 | mw_protocol_init(mwProtocol *self) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5360 | { |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5361 | /* set up the preferences */ |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5362 | 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
|
5363 | 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
|
5364 | BLIST_CHOICE_DEFAULT); |
|
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 | /* remove dead preferences */ |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5367 | 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
|
5368 | 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
|
5369 | } |
| 10977 | 5370 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5371 | static void |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5372 | 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
|
5373 | { |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5374 | 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
|
5375 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5376 | 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
|
5377 | 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
|
5378 | protocol_class->status_types = mw_protocol_status_types; |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5379 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5380 | protocol_class->get_account_options = mw_protocol_get_account_options; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5381 | 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
|
5382 | } |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5383 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5384 | static void |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5385 | 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
|
5386 | { |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5387 | } |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5388 | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5389 | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5390 | static void |
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5391 | mw_protocol_actions_iface_init(PurpleProtocolActionsInterface *iface) |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5392 | { |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5393 | iface->get_prefix = mw_protocol_actions_get_prefix; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5394 | iface->get_action_group = mw_protocol_actions_get_action_group; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5395 | iface->get_menu = mw_protocol_actions_get_menu; |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5396 | } |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5397 | |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5398 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5399 | 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
|
5400 | { |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5401 | 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
|
5402 | 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
|
5403 | 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
|
5404 | 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
|
5405 | 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
|
5406 | 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
|
5407 | 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
|
5408 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5409 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5410 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5411 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5412 | 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
|
5413 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5414 | 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
|
5415 | 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
|
5416 | 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
|
5417 | 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
|
5418 | 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
|
5419 | 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
|
5420 | 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
|
5421 | 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
|
5422 | 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
|
5423 | 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
|
5424 | 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
|
5425 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5426 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5427 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5428 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5429 | 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
|
5430 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5431 | 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
|
5432 | 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
|
5433 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5434 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5435 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5436 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5437 | 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
|
5438 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5439 | 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
|
5440 | 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
|
5441 | 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
|
5442 | 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
|
5443 | 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
|
5444 | 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
|
5445 | 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
|
5446 | 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
|
5447 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5448 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5449 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5450 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5451 | 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
|
5452 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5453 | 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
|
5454 | 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
|
5455 | 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
|
5456 | 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
|
5457 | 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
|
5458 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5459 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5460 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5461 | static void |
|
38827
3573c82d32d8
Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
38433
diff
changeset
|
5462 | 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
|
5463 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5464 | 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
|
5465 | 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
|
5466 | 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
|
5467 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5468 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5469 | G_DEFINE_DYNAMIC_TYPE_EXTENDED( |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5470 | 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
|
5471 | |
|
41462
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5472 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_ACTIONS, |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5473 | mw_protocol_actions_iface_init) |
|
70c7466f850b
Convert sametime to new actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41348
diff
changeset
|
5474 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5475 | 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
|
5476 | mw_protocol_client_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5477 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5478 | 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
|
5479 | mw_protocol_server_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5480 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5481 | 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
|
5482 | mw_protocol_im_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5483 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5484 | 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
|
5485 | mw_protocol_chat_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5486 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5487 | 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
|
5488 | mw_protocol_privacy_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5489 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5490 | 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
|
5491 | 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
|
5492 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5493 | static PurpleProtocol * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5494 | mw_protocol_new(void) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5495 | return PURPLE_PROTOCOL(g_object_new( |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5496 | MW_TYPE_PROTOCOL, |
|
41348
74b1a5db343b
Mark the protocol descriptions for translation and tweak them a bit.
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
5497 | "id", "prpl-meanwhile", |
|
74b1a5db343b
Mark the protocol descriptions for translation and tweak them a bit.
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
5498 | "name", "Sametime", |
|
74b1a5db343b
Mark the protocol descriptions for translation and tweak them a bit.
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
5499 | "description", _("HCL Sametime enterprise chat."), |
|
41073
f6d4fe227633
move the sametime protocol plugins icons to a resource in the plugin
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
5500 | "icon-name", "im-meanwhile", |
|
f6d4fe227633
move the sametime protocol plugins icons to a resource in the plugin
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
5501 | "icon-resource-path", "/im/pidgin/libpurple/sametime/icons", |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5502 | NULL)); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5503 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5504 | |
|
40945
bbeb2e98ea5b
Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
5505 | static GPluginPluginInfo * |
|
bbeb2e98ea5b
Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
5506 | sametime_query(GError **error) |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5507 | { |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5508 | const gchar * const authors[] = PLUGIN_AUTHORS; |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5509 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5510 | 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
|
5511 | "id", PLUGIN_ID, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5512 | "name", PLUGIN_NAME, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5513 | "version", DISPLAY_VERSION, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5514 | "category", PLUGIN_CATEGORY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5515 | "summary", PLUGIN_SUMMARY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5516 | "description", PLUGIN_DESC, |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5517 | "authors", authors, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5518 | "website", PLUGIN_HOMEPAGE, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5519 | "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
|
5520 | "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
|
5521 | 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
|
5522 | NULL |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5523 | ); |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5524 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5525 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5526 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5527 | static gboolean |
|
40945
bbeb2e98ea5b
Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
5528 | sametime_load(GPluginPlugin *plugin, GError **error) |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5529 | { |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5530 | PurpleProtocolManager *manager = purple_protocol_manager_get_default(); |
| 36679 | 5531 | GLogLevelFlags logflags = |
| 5532 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5533 | ||
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5534 | 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
|
5535 | |
|
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
|
5536 | 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
|
5537 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5538 | 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
|
5539 | 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
|
5540 | 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
|
5541 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5542 | 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
|
5543 | } |
| 10977 | 5544 | |
| 15884 | 5545 | /* forward all our g_log messages to purple. Generally all the logging |
| 5546 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5547 | get caught here */ |
| 5548 | 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
|
5549 | mw_log_handler, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5550 | |
| 15884 | 5551 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5552 | 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
|
5553 | 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
|
5554 | |
|
39526
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5555 | g_mime_init(); |
|
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5556 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5557 | return TRUE; |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5558 | } |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5559 | |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5560 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5561 | static gboolean |
|
41078
84e48180ef67
Update to gplugin 0.35.0
Gary Kramlich <grim@reaperworld.com>
parents:
41073
diff
changeset
|
5562 | sametime_unload(GPluginPlugin *plugin, gboolean shutdown, GError **error) |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5563 | { |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5564 | 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
|
5565 | |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5566 | 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
|
5567 | return FALSE; |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5568 | } |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5569 | |
|
39526
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5570 | g_mime_shutdown(); |
|
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5571 | |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36660
diff
changeset
|
5572 | 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
|
5573 | 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
|
5574 | |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5575 | g_clear_object(&my_protocol); |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5576 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5577 | return TRUE; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5578 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5579 | |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5580 | |
|
40945
bbeb2e98ea5b
Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
5581 | GPLUGIN_NATIVE_PLUGIN_DECLARE(sametime) |
| 10977 | 5582 | /* The End. */ |
| 5583 |