Thu, 10 Jun 2021 23:40:54 -0500
Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Testing Done:
Ran an instance and verified my enabled accounts connected and everything else was queried successfully.
Reviewed at https://reviews.imfreedom.org/r/741/
| 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 | |
| 37004 | 69 | #define PROTOCOL_ID "prpl-meanwhile" |
|
36638
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
70 | #define PROTOCOL_NAME "Sametime" |
|
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
71 | |
|
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
72 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
73 | /* considering that there's no display of this information for protocols, |
| 10977 | 74 | I don't know why I even bother providing these. Oh valiant reader, |
| 75 | I do it all for you. */ | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
76 | /* 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
|
77 | #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
|
78 | #define PLUGIN_NAME "Sametime Protocol" |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
79 | #define PLUGIN_CATEGORY "Protocol" |
| 10977 | 80 | #define PLUGIN_SUMMARY "Sametime Protocol Plugin" |
| 81 | #define PLUGIN_DESC "Open implementation of a Lotus Sametime client" | |
| 82 | #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/" | |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
83 | #define PLUGIN_AUTHORS \ |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
84 | { "Christopher (siege) O'Brien <siege@preoccupied.net>", NULL } |
| 10977 | 85 | |
| 86 | ||
| 87 | /* plugin preference names */ | |
| 36984 | 88 | #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
|
89 | #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
|
90 | #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
|
91 | #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
|
92 | #define MW_PROTOCOL_OPT_SAVE_DYNAMIC MW_PROTOCOL_OPT_BASE "/save_dynamic" |
| 10977 | 93 | |
| 94 | ||
| 95 | /* stages of connecting-ness */ | |
|
13779
410869639392
[gaim-migrate @ 16189]
Christopher O'Brien <siege@pidgin.im>
parents:
13713
diff
changeset
|
96 | #define MW_CONNECT_STEPS 11 |
| 10977 | 97 | |
| 98 | ||
| 99 | /* stages of conciousness */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
100 | #define MW_STATE_OFFLINE "offline" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
101 | #define MW_STATE_ACTIVE "active" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
102 | #define MW_STATE_AWAY "away" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
103 | #define MW_STATE_BUSY "dnd" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
104 | #define MW_STATE_MESSAGE "message" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
105 | #define MW_STATE_ENLIGHTENED "buddha" |
| 10977 | 106 | |
| 107 | ||
| 108 | /* keys to get/set chat information */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
109 | #define CHAT_KEY_CREATOR "chat.creator" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
110 | #define CHAT_KEY_NAME "chat.name" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
111 | #define CHAT_KEY_TOPIC "chat.topic" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
112 | #define CHAT_KEY_INVITE "chat.invite" |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
113 | #define CHAT_KEY_IS_PLACE "chat.is_place" |
| 10977 | 114 | |
| 115 | ||
| 116 | /* key for associating a mwLoginType with a buddy */ | |
| 117 | #define BUDDY_KEY_CLIENT "meanwhile.client" | |
| 118 | ||
| 119 | /* store the remote alias so that we can re-create it easily */ | |
| 120 | #define BUDDY_KEY_NAME "meanwhile.shortname" | |
| 121 | ||
| 122 | /* enum mwSametimeUserType */ | |
| 123 | #define BUDDY_KEY_TYPE "meanwhile.type" | |
| 124 | ||
| 125 | ||
| 126 | /* key for the real group name for a meanwhile group */ | |
| 127 | #define GROUP_KEY_NAME "meanwhile.group" | |
| 128 | ||
| 129 | /* enum mwSametimeGroupType */ | |
| 130 | #define GROUP_KEY_TYPE "meanwhile.type" | |
| 131 | ||
| 132 | /* NAB group owning account */ | |
| 133 | #define GROUP_KEY_OWNER "meanwhile.account" | |
| 134 | ||
| 135 | /* key gtk blist uses to indicate a collapsed group */ | |
| 136 | #define GROUP_KEY_COLLAPSED "collapsed" | |
| 137 | ||
| 138 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
139 | /* verification replacement */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
140 | #define mwSession_NO_SECRET "meanwhile.no_secret" |
| 10977 | 141 | |
| 142 | ||
| 15884 | 143 | /* keys to get/set purple plugin information */ |
| 10977 | 144 | #define MW_KEY_HOST "server" |
| 145 | #define MW_KEY_PORT "port" | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
146 | #define MW_KEY_FORCE "force_login" |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
147 | #define MW_KEY_FAKE_IT "fake_client_id" |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
148 | #define MW_KEY_CLIENT "client_id_val" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
149 | #define MW_KEY_MAJOR "client_major" |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
150 | #define MW_KEY_MINOR "client_minor" |
| 10977 | 151 | |
| 152 | ||
| 153 | /** number of seconds from the first blist change before a save to the | |
| 154 | storage service occurs. */ | |
| 155 | #define BLIST_SAVE_SECONDS 15 | |
| 156 | ||
| 157 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
158 | /** the possible buddy list storage settings */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
159 | enum blist_choice { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
160 | blist_choice_LOCAL = 1, /**< local only */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
161 | blist_choice_MERGE = 2, /**< merge from server */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
162 | 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
|
163 | blist_choice_SYNCH = 4 /**< sync with server */ |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
164 | }; |
| 10977 | 165 | |
| 166 | ||
| 167 | /** the default blist storage option */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
168 | #define BLIST_CHOICE_DEFAULT blist_choice_SYNCH |
| 10977 | 169 | |
| 170 | ||
| 171 | /* testing for the above */ | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
172 | #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
|
173 | #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
|
174 | #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
|
175 | #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
|
176 | #define BLIST_PREF_IS_SYNCH() BLIST_PREF_IS(blist_choice_SYNCH) |
| 10977 | 177 | |
| 178 | ||
| 179 | /* 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
|
180 | #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
|
181 | #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
|
182 | #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
|
183 | #define DEBUG_WARN(...) purple_debug_warning(G_LOG_DOMAIN, __VA_ARGS__) |
| 10977 | 184 | |
| 185 | ||
| 186 | /** calibrates distinct secure channel nomenclature */ | |
| 187 | static const unsigned char no_secret[] = { | |
| 188 | 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65, | |
| 189 | 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a, | |
| 190 | 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64, | |
| 191 | 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00, | |
| 192 | }; | |
| 193 | ||
| 194 | ||
| 195 | /** handler IDs from g_log_set_handler in mw_plugin_init */ | |
| 196 | static guint log_handler[2] = { 0, 0 }; | |
| 197 | ||
| 198 | ||
| 15884 | 199 | /** 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
|
200 | 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
|
201 | struct mwPurpleProtocolData { |
| 10977 | 202 | struct mwSession *session; |
| 203 | ||
| 204 | struct mwServiceAware *srvc_aware; | |
| 205 | struct mwServiceConference *srvc_conf; | |
| 206 | struct mwServiceFileTransfer *srvc_ft; | |
| 207 | struct mwServiceIm *srvc_im; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
208 | struct mwServicePlace *srvc_place; |
| 10977 | 209 | struct mwServiceResolve *srvc_resolve; |
| 210 | struct mwServiceStorage *srvc_store; | |
| 211 | ||
| 15884 | 212 | /** map of PurpleGroup:mwAwareList and mwAwareList:PurpleGroup */ |
| 10977 | 213 | GHashTable *group_list_map; |
| 214 | ||
| 215 | /** event id for the buddy list save callback */ | |
| 216 | guint save_event; | |
| 217 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
218 | GCancellable *cancellable; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
219 | GSocketClient *client; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
220 | GIOStream *stream; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
221 | GInputStream *input; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
222 | PurpleQueuedOutputStream *output; |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
223 | guint inpa; /* input watcher */ |
| 15884 | 224 | |
| 225 | PurpleConnection *gc; | |
| 10977 | 226 | }; |
| 227 | ||
| 228 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
229 | typedef struct { |
| 15884 | 230 | PurpleBuddy *buddy; |
| 231 | PurpleGroup *group; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
232 | } BuddyAddData; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
233 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
234 | |
| 10977 | 235 | /* blist and aware functions */ |
| 236 | ||
| 15884 | 237 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist); |
| 238 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
239 | 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
|
240 | |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
241 | static void blist_schedule(struct mwPurpleProtocolData *pd); |
| 15884 | 242 | |
| 243 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 244 | ||
| 245 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist); | |
| 246 | ||
| 247 | static gboolean buddy_is_external(PurpleBuddy *b); | |
| 248 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
249 | static void buddy_add(struct mwPurpleProtocolData *pd, PurpleBuddy *buddy); |
| 15884 | 250 | |
| 251 | static PurpleBuddy * | |
| 252 | buddy_ensure(PurpleConnection *gc, PurpleGroup *group, | |
| 10977 | 253 | struct mwSametimeUser *stuser); |
| 254 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
255 | static void group_add(struct mwPurpleProtocolData *pd, PurpleGroup *group); |
| 15884 | 256 | |
| 257 | static PurpleGroup * | |
| 258 | group_ensure(PurpleConnection *gc, struct mwSametimeGroup *stgroup); | |
| 10977 | 259 | |
| 260 | static struct mwAwareList * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
261 | list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group); |
| 10977 | 262 | |
| 263 | ||
| 264 | /* session functions */ | |
| 265 | ||
| 266 | static struct mwSession * | |
| 15884 | 267 | gc_to_session(PurpleConnection *gc); |
| 268 | ||
| 269 | static PurpleConnection *session_to_gc(struct mwSession *session); | |
| 10977 | 270 | |
| 271 | ||
| 272 | /* conference functions */ | |
| 273 | ||
| 274 | static struct mwConference * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
275 | conf_find_by_id(struct mwPurpleProtocolData *pd, int id); |
| 10977 | 276 | |
| 277 | ||
| 278 | /* conversation functions */ | |
| 279 | ||
| 280 | struct convo_msg { | |
| 281 | enum mwImSendType type; | |
| 282 | gpointer data; | |
| 283 | GDestroyNotify clear; | |
| 284 | }; | |
| 285 | ||
| 286 | ||
| 287 | struct convo_data { | |
| 288 | struct mwConversation *conv; | |
| 289 | GList *queue; /**< outgoing message queue, list of convo_msg */ | |
| 290 | }; | |
| 291 | ||
| 292 | static void convo_data_new(struct mwConversation *conv); | |
| 293 | ||
| 294 | static void convo_data_free(struct convo_data *conv); | |
| 295 | ||
| 296 | static void convo_features(struct mwConversation *conv); | |
| 297 | ||
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
298 | static PurpleConversation *convo_get_im(struct mwConversation *conv); |
| 10977 | 299 | |
| 300 | ||
|
12629
14aae7d5da6b
[gaim-migrate @ 14965]
Richard Laager <rlaager@pidgin.im>
parents:
12624
diff
changeset
|
301 | /* name and id */ |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
302 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
303 | struct named_id { |
| 10977 | 304 | char *id; |
| 305 | char *name; | |
| 306 | }; | |
| 307 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
308 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
309 | /* connection functions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
310 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
311 | 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
|
312 | |
| 10977 | 313 | |
| 314 | /* ----- session ------ */ | |
| 315 | ||
| 316 | ||
| 15884 | 317 | /** resolves a mwSession from a PurpleConnection */ |
| 318 | 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
|
319 | struct mwPurpleProtocolData *pd; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
320 | |
| 10977 | 321 | g_return_val_if_fail(gc != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
322 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
323 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 324 | g_return_val_if_fail(pd != NULL, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
325 | |
| 10977 | 326 | return pd->session; |
| 327 | } | |
| 328 | ||
| 329 | ||
| 15884 | 330 | /** resolves a PurpleConnection from a mwSession */ |
| 331 | static PurpleConnection *session_to_gc(struct mwSession *session) { | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
332 | struct mwPurpleProtocolData *pd; |
| 10977 | 333 | |
| 334 | g_return_val_if_fail(session != NULL, NULL); | |
| 335 | ||
| 336 | pd = mwSession_getClientData(session); | |
| 337 | g_return_val_if_fail(pd != NULL, NULL); | |
| 338 | ||
| 339 | return pd->gc; | |
| 340 | } | |
| 341 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
342 | static void |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
343 | 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
|
344 | { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
345 | 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
|
346 | struct mwPurpleProtocolData *pd = data; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
347 | GError *error = NULL; |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
348 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
349 | DEBUG_INFO("write_cb\n"); |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
350 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
351 | 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
|
352 | purple_queued_output_stream_clear_queue(stream); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
353 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
354 | if (error->code != G_IO_ERROR_CANCELLED) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
355 | 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
|
356 | purple_connection_take_error(pd->gc, error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
357 | } else { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
358 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
359 | } |
|
13206
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
360 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
361 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
362 | |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
363 | |
| 10977 | 364 | static int mw_session_io_write(struct mwSession *session, |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
365 | const guchar *buf, gsize len) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
366 | struct mwPurpleProtocolData *pd; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
367 | GBytes *output; |
| 10977 | 368 | |
| 369 | pd = mwSession_getClientData(session); | |
| 370 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
371 | /* the session was already closed. */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
372 | if (pd->stream == NULL) { |
| 10977 | 373 | return 1; |
| 374 | } | |
| 375 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
376 | output = g_bytes_new(buf, len); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
377 | purple_queued_output_stream_push_bytes_async( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
378 | 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
|
379 | write_cb, pd); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
380 | g_bytes_unref(output); |
| 10977 | 381 | |
| 382 | return 0; | |
| 383 | } | |
| 384 | ||
| 385 | ||
| 386 | 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
|
387 | struct mwPurpleProtocolData *pd; |
| 10977 | 388 | |
| 389 | pd = mwSession_getClientData(session); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
390 | g_return_if_fail(pd != NULL); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
391 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
392 | g_cancellable_cancel(pd->cancellable); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
393 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
394 | if (pd->stream) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
395 | if (pd->inpa) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
396 | purple_input_remove(pd->inpa); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
397 | pd->inpa = 0; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
398 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
399 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
400 | 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
|
401 | } |
|
fb1f9f01499c
[gaim-migrate @ 15568]
Christopher O'Brien <siege@pidgin.im>
parents:
13158
diff
changeset
|
402 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
403 | pd->input = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
404 | g_clear_object(&pd->output); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
405 | g_clear_object(&pd->stream); |
| 10977 | 406 | } |
| 407 | ||
| 408 | ||
| 409 | static void mw_session_clear(struct mwSession *session) { | |
| 410 | ; /* nothing for now */ | |
| 411 | } | |
| 412 | ||
| 413 | ||
| 414 | /* ----- aware list ----- */ | |
| 415 | ||
| 416 | ||
| 417 | static void blist_resolve_alias_cb(struct mwServiceResolve *srvc, | |
| 418 | guint32 id, guint32 code, GList *results, | |
| 419 | gpointer data) { | |
| 420 | struct mwResolveResult *result; | |
| 421 | struct mwResolveMatch *match; | |
| 422 | ||
| 423 | g_return_if_fail(results != NULL); | |
| 424 | ||
| 425 | result = results->data; | |
| 426 | g_return_if_fail(result != NULL); | |
| 427 | g_return_if_fail(result->matches != NULL); | |
| 428 | ||
| 429 | match = result->matches->data; | |
| 430 | g_return_if_fail(match != NULL); | |
| 431 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
432 | purple_buddy_set_server_alias(data, match->name); |
| 15884 | 433 | purple_blist_node_set_string(data, BUDDY_KEY_NAME, match->name); |
| 10977 | 434 | } |
| 435 | ||
| 436 | ||
| 437 | static void mw_aware_list_on_aware(struct mwAwareList *list, | |
| 438 | struct mwAwareSnapshot *aware) { | |
| 439 | ||
| 15884 | 440 | PurpleConnection *gc; |
| 441 | PurpleAccount *acct; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
442 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
443 | struct mwPurpleProtocolData *pd; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
444 | guint32 idle; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
445 | guint stat; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
446 | const char *id; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
447 | const char *status = MW_STATE_ACTIVE; |
| 10977 | 448 | |
| 449 | gc = mwAwareList_getClientData(list); | |
| 15884 | 450 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
451 | |
|
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
|
452 | pd = purple_connection_get_protocol_data(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
453 | idle = aware->status.time; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
454 | stat = aware->status.status; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
455 | id = aware->id.user; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
456 | |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
457 | if(idle) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
458 | guint32 idle_len; /*< how long a client has been idle */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
459 | 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
|
460 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
461 | 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
|
462 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
463 | idle_len = time(NULL) - idle; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
464 | ugly_idle_len = ((time(NULL) * 1000) - idle) / 1000; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
465 | |
|
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
|
466 | 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
|
467 | 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
|
468 | 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
|
469 | 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
|
470 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
471 | /* |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
472 | 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
|
473 | 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
|
474 | 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
|
475 | 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
|
476 | 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
|
477 | 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
|
478 | this. |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
479 | */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
480 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
481 | 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
|
482 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
483 | #if 1 |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
484 | if(idle_len <= ugly_idle_len) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
485 | ; /* DEBUG_INFO("sane idle value, let's use it\n"); */ |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
486 | } else { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
487 | idle = time(NULL) - ugly_idle_len; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
488 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
489 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
490 | #else |
|
13588
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
491 | if(idle < 0 || idle > time(NULL)) { |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
492 | 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
|
493 | idle = -1; |
|
c9a9f962837c
[gaim-migrate @ 15972]
Christopher O'Brien <siege@pidgin.im>
parents:
13580
diff
changeset
|
494 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
495 | #endif |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
496 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
497 | |
| 10977 | 498 | switch(stat) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
499 | case mwStatus_ACTIVE: |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
500 | status = MW_STATE_ACTIVE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
501 | idle = 0; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
502 | break; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
503 | |
| 10977 | 504 | case mwStatus_IDLE: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
505 | if(! idle) idle = -1; |
| 10977 | 506 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
507 | |
| 10977 | 508 | case mwStatus_AWAY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
509 | status = MW_STATE_AWAY; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
510 | break; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
511 | |
| 10977 | 512 | case mwStatus_BUSY: |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
513 | status = MW_STATE_BUSY; |
| 10977 | 514 | break; |
| 515 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
516 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
517 | /* NAB group members */ |
| 10977 | 518 | if(aware->group) { |
| 15884 | 519 | PurpleGroup *group; |
| 520 | PurpleBuddy *buddy; | |
| 521 | PurpleBlistNode *bnode; | |
| 10977 | 522 | |
| 523 | 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
|
524 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 15884 | 525 | bnode = (PurpleBlistNode *) buddy; |
| 10977 | 526 | |
| 527 | if(! buddy) { | |
| 528 | struct mwServiceResolve *srvc; | |
| 529 | GList *query; | |
| 530 | ||
| 15884 | 531 | buddy = purple_buddy_new(acct, id, NULL); |
| 532 | purple_blist_add_buddy(buddy, NULL, group, NULL); | |
| 533 | ||
| 534 | bnode = (PurpleBlistNode *) buddy; | |
| 10977 | 535 | |
| 536 | srvc = pd->srvc_resolve; | |
| 537 | query = g_list_append(NULL, (char *) id); | |
| 538 | ||
| 539 | mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS, | |
| 540 | blist_resolve_alias_cb, buddy, NULL); | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
541 | g_list_free(query); |
| 10977 | 542 | } |
| 543 | ||
| 15884 | 544 | purple_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL); |
| 10977 | 545 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
546 | |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
547 | if(aware->online) { |
|
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, status, NULL); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
549 | 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
|
550 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
551 | } else { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
552 | 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
|
553 | } |
| 10977 | 554 | } |
| 555 | ||
| 556 | ||
| 557 | static void mw_aware_list_on_attrib(struct mwAwareList *list, | |
| 558 | struct mwAwareIdBlock *id, | |
| 559 | struct mwAwareAttribute *attrib) { | |
| 560 | ||
| 561 | ; /* nothing. We'll get attribute data as we need it */ | |
| 562 | } | |
| 563 | ||
| 564 | ||
| 565 | static void mw_aware_list_clear(struct mwAwareList *list) { | |
| 566 | ; /* nothing for now */ | |
| 567 | } | |
| 568 | ||
| 569 | ||
| 570 | static struct mwAwareListHandler mw_aware_list_handler = { | |
|
17157
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
571 | mw_aware_list_on_aware, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
572 | mw_aware_list_on_attrib, |
|
dee69ceaf4d0
Another C99 struct falling.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
573 | mw_aware_list_clear, |
| 10977 | 574 | }; |
| 575 | ||
| 576 | ||
| 577 | /** Ensures that an Aware List is associated with the given group, and | |
| 578 | returns that list. */ | |
| 579 | static struct mwAwareList * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
580 | list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
581 | |
| 10977 | 582 | struct mwAwareList *list; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
583 | |
| 10977 | 584 | g_return_val_if_fail(pd != NULL, NULL); |
| 585 | g_return_val_if_fail(group != NULL, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
586 | |
| 10977 | 587 | list = g_hash_table_lookup(pd->group_list_map, group); |
| 588 | if(! list) { | |
| 589 | list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler); | |
| 590 | mwAwareList_setClientData(list, pd->gc, NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
591 | |
| 10977 | 592 | mwAwareList_watchAttributes(list, |
| 593 | mwAttribute_AV_PREFS_SET, | |
| 594 | mwAttribute_MICROPHONE, | |
| 595 | mwAttribute_SPEAKERS, | |
| 596 | mwAttribute_VIDEO_CAMERA, | |
| 597 | mwAttribute_FILE_TRANSFER, | |
| 598 | NULL); | |
| 599 | ||
| 600 | g_hash_table_replace(pd->group_list_map, group, list); | |
| 601 | g_hash_table_insert(pd->group_list_map, list, group); | |
| 602 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
603 | |
| 10977 | 604 | return list; |
| 605 | } | |
| 606 | ||
| 607 | ||
| 15884 | 608 | static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 10977 | 609 | /* - find the account for this connection |
| 610 | - iterate through the buddy list | |
| 611 | - add each buddy matching this account to the stlist | |
| 612 | */ | |
| 613 | ||
| 15884 | 614 | PurpleAccount *acct; |
| 615 | PurpleBlistNode *gn, *cn, *bn; | |
| 616 | PurpleGroup *grp; | |
| 617 | PurpleBuddy *bdy; | |
| 10977 | 618 | |
| 619 | struct mwSametimeGroup *stg = NULL; | |
| 620 | struct mwIdBlock idb = { NULL, NULL }; | |
| 621 | ||
| 15884 | 622 | acct = purple_connection_get_account(gc); |
| 10977 | 623 | g_return_if_fail(acct != NULL); |
| 624 | ||
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
625 | 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
|
626 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 10977 | 627 | const char *owner; |
| 628 | const char *gname; | |
| 629 | enum mwSametimeGroupType gtype; | |
| 630 | gboolean gopen; | |
| 631 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
632 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 633 | grp = (PurpleGroup *) gn; |
| 10977 | 634 | |
| 635 | /* the group's type (normal or dynamic) */ | |
| 15884 | 636 | gtype = purple_blist_node_get_int(gn, GROUP_KEY_TYPE); |
| 10977 | 637 | if(! gtype) gtype = mwSametimeGroup_NORMAL; |
| 638 | ||
| 639 | /* if it's a normal group with none of our people in it, skip it */ | |
| 15884 | 640 | if(gtype == mwSametimeGroup_NORMAL && !purple_group_on_account(grp, acct)) |
| 10977 | 641 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
642 | |
| 10977 | 643 | /* if the group has an owner and we're not it, skip it */ |
| 15884 | 644 | 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
|
645 | if(owner && !purple_strequal(owner, purple_account_get_username(acct))) |
| 10977 | 646 | continue; |
| 647 | ||
| 15884 | 648 | /* the group's actual name may be different from the purple group's |
| 10977 | 649 | name. Find whichever is there */ |
| 15884 | 650 | 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
|
651 | if(! gname) gname = purple_group_get_name(grp); |
| 10977 | 652 | |
| 653 | /* we save this, but never actually honor it */ | |
| 15884 | 654 | gopen = ! purple_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); |
| 10977 | 655 | |
| 656 | 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
|
657 | mwSametimeGroup_setAlias(stg, purple_group_get_name(grp)); |
| 10977 | 658 | mwSametimeGroup_setOpen(stg, gopen); |
| 659 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
660 | /* 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
|
661 | other clients */ |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
662 | if(gtype == mwSametimeGroup_DYNAMIC) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
663 | continue; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
664 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
665 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
666 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
667 | 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
|
668 | if(! PURPLE_IS_CONTACT(cn)) continue; |
| 10977 | 669 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
670 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
671 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
672 | 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
|
673 | 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
|
674 | if(purple_blist_node_is_transient(bn)) continue; |
| 15884 | 675 | |
| 676 | bdy = (PurpleBuddy *) bn; | |
| 10977 | 677 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
678 | if(purple_buddy_get_account(bdy) == acct) { |
| 10977 | 679 | struct mwSametimeUser *stu; |
| 680 | enum mwSametimeUserType utype; | |
| 681 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
682 | idb.user = (char *)purple_buddy_get_name(bdy); |
| 10977 | 683 | |
| 15884 | 684 | utype = purple_blist_node_get_int(bn, BUDDY_KEY_TYPE); |
| 10977 | 685 | if(! utype) utype = mwSametimeUser_NORMAL; |
| 686 | ||
| 687 | 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
|
688 | 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
|
689 | mwSametimeUser_setAlias(stu, purple_buddy_get_local_alias(bdy)); |
| 10977 | 690 | } |
| 691 | } | |
| 692 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
693 | } |
| 10977 | 694 | } |
| 695 | ||
| 696 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
697 | static void blist_store(struct mwPurpleProtocolData *pd) { |
| 10977 | 698 | |
| 699 | struct mwSametimeList *stlist; | |
| 700 | struct mwServiceStorage *srvc; | |
| 701 | struct mwStorageUnit *unit; | |
| 702 | ||
| 15884 | 703 | PurpleConnection *gc; |
| 10977 | 704 | |
| 705 | struct mwPutBuffer *b; | |
| 706 | struct mwOpaque *o; | |
| 707 | ||
| 708 | g_return_if_fail(pd != NULL); | |
| 709 | ||
| 710 | srvc = pd->srvc_store; | |
| 711 | g_return_if_fail(srvc != NULL); | |
| 712 | ||
| 713 | gc = pd->gc; | |
| 714 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
715 | if(BLIST_PREF_IS_LOCAL() || BLIST_PREF_IS_MERGE()) { |
| 10977 | 716 | DEBUG_INFO("preferences indicate not to save remote blist\n"); |
| 717 | return; | |
| 718 | ||
| 719 | } else if(MW_SERVICE_IS_DEAD(srvc)) { | |
| 720 | DEBUG_INFO("aborting save of blist: storage service is not alive\n"); | |
| 721 | return; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
722 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
723 | } else if(BLIST_PREF_IS_STORE() || BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
724 | DEBUG_INFO("saving remote blist\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
725 | |
| 10977 | 726 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
727 | g_return_if_reached(); |
| 10977 | 728 | } |
| 729 | ||
| 730 | /* create and export to a list object */ | |
| 731 | stlist = mwSametimeList_new(); | |
| 732 | blist_export(gc, stlist); | |
| 733 | ||
| 734 | /* write it to a buffer */ | |
| 735 | b = mwPutBuffer_new(); | |
| 736 | mwSametimeList_put(b, stlist); | |
| 737 | mwSametimeList_free(stlist); | |
| 738 | ||
| 739 | /* put the buffer contents into a storage unit */ | |
| 740 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
| 741 | o = mwStorageUnit_asOpaque(unit); | |
| 742 | mwPutBuffer_finalize(o, b); | |
| 743 | ||
| 744 | /* save the storage unit to the service */ | |
| 745 | mwServiceStorage_save(srvc, unit, NULL, NULL, NULL); | |
| 746 | } | |
| 747 | ||
| 748 | ||
| 749 | 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
|
750 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 751 | |
| 752 | blist_store(pd); | |
| 753 | pd->save_event = 0; | |
| 754 | return FALSE; | |
| 755 | } | |
| 756 | ||
| 757 | ||
| 758 | /** 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
|
759 | static void blist_schedule(struct mwPurpleProtocolData *pd) { |
| 10977 | 760 | if(pd->save_event) return; |
| 761 | ||
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
762 | pd->save_event = g_timeout_add_seconds(BLIST_SAVE_SECONDS, |
| 10977 | 763 | blist_save_cb, pd); |
| 764 | } | |
| 765 | ||
| 766 | ||
| 15884 | 767 | static gboolean buddy_is_external(PurpleBuddy *b) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
768 | 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
|
769 | 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
|
770 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
771 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
772 | |
| 10977 | 773 | /** Actually add a buddy to the aware service, and schedule the buddy |
| 774 | 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
|
775 | static void buddy_add(struct mwPurpleProtocolData *pd, |
| 15884 | 776 | PurpleBuddy *buddy) { |
| 10977 | 777 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
778 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) purple_buddy_get_name(buddy), NULL }; |
| 10977 | 779 | struct mwAwareList *list; |
| 780 | ||
| 15884 | 781 | PurpleGroup *group; |
| 10977 | 782 | GList *add; |
| 783 | ||
| 784 | add = g_list_prepend(NULL, &idb); | |
| 785 | ||
| 15884 | 786 | group = purple_buddy_get_group(buddy); |
| 10977 | 787 | list = list_ensure(pd, group); |
| 788 | ||
| 789 | if(mwAwareList_addAware(list, add)) { | |
| 15884 | 790 | purple_blist_remove_buddy(buddy); |
| 10977 | 791 | } |
| 792 | ||
| 793 | blist_schedule(pd); | |
| 794 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
795 | g_list_free(add); |
| 10977 | 796 | } |
| 797 | ||
| 798 | ||
| 15884 | 799 | /** ensure that a PurpleBuddy exists in the group with data |
| 10977 | 800 | appropriately matching the st user entry from the st list */ |
| 15884 | 801 | static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, |
| 10977 | 802 | struct mwSametimeUser *stuser) { |
| 803 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
804 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 805 | PurpleBuddy *buddy; |
| 806 | PurpleAccount *acct = purple_connection_get_account(gc); | |
| 10977 | 807 | |
| 808 | const char *id = mwSametimeUser_getUser(stuser); | |
| 809 | const char *name = mwSametimeUser_getShortName(stuser); | |
| 810 | const char *alias = mwSametimeUser_getAlias(stuser); | |
| 811 | enum mwSametimeUserType type = mwSametimeUser_getType(stuser); | |
| 812 | ||
| 813 | 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
|
814 | g_return_val_if_fail(*id, NULL); |
| 10977 | 815 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
816 | buddy = purple_blist_find_buddy_in_group(acct, id, group); |
| 10977 | 817 | if(! buddy) { |
| 15884 | 818 | buddy = purple_buddy_new(acct, id, alias); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
819 | |
| 15884 | 820 | purple_blist_add_buddy(buddy, NULL, group, NULL); |
| 10977 | 821 | buddy_add(pd, buddy); |
| 822 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
823 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
824 | 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
|
825 | purple_buddy_set_server_alias(buddy, name); |
| 15884 | 826 | purple_blist_node_set_string((PurpleBlistNode *) buddy, BUDDY_KEY_NAME, name); |
| 827 | purple_blist_node_set_int((PurpleBlistNode *) buddy, BUDDY_KEY_TYPE, type); | |
| 10977 | 828 | |
| 829 | return buddy; | |
| 830 | } | |
| 831 | ||
| 832 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
833 | /** 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
|
834 | static void group_add(struct mwPurpleProtocolData *pd, |
| 15884 | 835 | PurpleGroup *group) { |
| 10977 | 836 | |
| 837 | struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL }; | |
| 838 | struct mwAwareList *list; | |
| 839 | const char *n; | |
| 840 | GList *add; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
841 | |
| 15884 | 842 | 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
|
843 | if(! n) n = purple_group_get_name(group); |
| 10977 | 844 | |
| 845 | idb.user = (char *) n; | |
| 846 | add = g_list_prepend(NULL, &idb); | |
| 847 | ||
| 848 | list = list_ensure(pd, group); | |
| 849 | mwAwareList_addAware(list, add); | |
| 850 | g_list_free(add); | |
| 851 | } | |
| 852 | ||
| 853 | ||
| 15884 | 854 | /** ensure that a PurpleGroup exists in the blist with data |
| 10977 | 855 | appropriately matching the st group entry from the st list */ |
| 15884 | 856 | static PurpleGroup *group_ensure(PurpleConnection *gc, |
| 10977 | 857 | struct mwSametimeGroup *stgroup) { |
| 15884 | 858 | PurpleAccount *acct; |
| 859 | PurpleGroup *group = NULL; | |
| 860 | PurpleBuddyList *blist; | |
| 861 | PurpleBlistNode *gn; | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
862 | const char *name, *alias, *owner; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
863 | enum mwSametimeGroupType type; |
| 10977 | 864 | |
| 15884 | 865 | acct = purple_connection_get_account(gc); |
| 866 | owner = purple_account_get_username(acct); | |
| 867 | ||
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
868 | blist = purple_blist_get_default(); |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
869 | g_return_val_if_fail(blist != NULL, NULL); |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
870 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
871 | name = mwSametimeGroup_getName(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
872 | alias = mwSametimeGroup_getAlias(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
873 | type = mwSametimeGroup_getType(stgroup); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
874 | |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
875 | if (!name) { |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
876 | DEBUG_WARN("Can't ensure a null group\n"); |
|
31991
efe4fb3772ad
Fix this compile warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
31983
diff
changeset
|
877 | return NULL; |
|
31979
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
878 | } |
|
d9743aa9882a
sametime: Avoid a theoretical null strcmp
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
879 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
880 | 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
|
881 | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
882 | /* 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
|
883 | 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
|
884 | gn = purple_blist_node_get_sibling_next(gn)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
885 | const char *n, *o; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
886 | if(! PURPLE_IS_GROUP(gn)) continue; |
| 15884 | 887 | n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
| 888 | 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
|
889 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
890 | 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
|
891 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
892 | if(n && purple_strequal(n, name)) { |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36037
diff
changeset
|
893 | if(!o || purple_strequal(o, owner)) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
894 | DEBUG_INFO("that'll work\n"); |
| 15884 | 895 | group = (PurpleGroup *) gn; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
896 | break; |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
897 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
898 | } |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
899 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
900 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
901 | /* try again, by alias */ |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
902 | if(! group) { |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
903 | 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
|
904 | group = purple_blist_find_group(alias); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
905 | } |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
906 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
907 | /* oh well, no such group. Let's create it! */ |
| 10977 | 908 | if(! group) { |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
909 | DEBUG_INFO("creating group\n"); |
| 15884 | 910 | group = purple_group_new(alias); |
| 911 | purple_blist_add_group(group, NULL); | |
| 10977 | 912 | } |
| 913 | ||
| 15884 | 914 | gn = (PurpleBlistNode *) group; |
| 915 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); | |
| 916 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | |
| 10977 | 917 | |
| 918 | if(type == mwSametimeGroup_DYNAMIC) { | |
| 15884 | 919 | 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
|
920 | group_add(purple_connection_get_protocol_data(gc), group); |
| 10977 | 921 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
922 | |
| 10977 | 923 | return group; |
| 924 | } | |
| 925 | ||
| 926 | ||
| 15884 | 927 | /** merge the entries from a st list into the purple blist */ |
| 928 | static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist) { | |
| 10977 | 929 | struct mwSametimeGroup *stgroup; |
| 930 | struct mwSametimeUser *stuser; | |
| 931 | ||
| 15884 | 932 | PurpleGroup *group; |
| 10977 | 933 | |
| 934 | GList *gl, *gtl, *ul, *utl; | |
| 935 | ||
| 936 | gl = gtl = mwSametimeList_getGroups(stlist); | |
| 937 | for(; gl; gl = gl->next) { | |
| 938 | ||
| 939 | stgroup = (struct mwSametimeGroup *) gl->data; | |
| 940 | group = group_ensure(gc, stgroup); | |
| 941 | ||
| 942 | ul = utl = mwSametimeGroup_getUsers(stgroup); | |
| 943 | for(; ul; ul = ul->next) { | |
| 944 | ||
| 945 | stuser = (struct mwSametimeUser *) ul->data; | |
|
33782
1690e0b2c508
Fix a bunch of unused variables
Daniel Atallah <datallah@pidgin.im>
parents:
33745
diff
changeset
|
946 | buddy_ensure(gc, group, stuser); |
| 10977 | 947 | } |
| 948 | g_list_free(utl); | |
| 949 | } | |
| 950 | g_list_free(gtl); | |
| 951 | } | |
| 952 | ||
| 953 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
954 | /** 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
|
955 | is left empty, remove group as well */ |
| 15884 | 956 | static void group_clear(PurpleGroup *group, PurpleAccount *acct, gboolean del) { |
| 957 | PurpleConnection *gc; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
958 | GList *prune = NULL; |
| 15884 | 959 | PurpleBlistNode *gn, *cn, *bn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
960 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
961 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
962 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
963 | 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
|
964 | |
| 15884 | 965 | gc = purple_account_get_connection(acct); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
966 | g_return_if_fail(gc != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
967 | |
| 15884 | 968 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
969 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
970 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
971 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
972 | 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
|
973 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
974 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
975 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
976 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
977 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 978 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 979 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
980 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
981 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
982 | if(purple_buddy_get_account(gb) == acct) { |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
983 | 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
|
984 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
985 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
986 | } |
|
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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
989 | /* quickly unsubscribe from presence for the entire group */ |
| 15884 | 990 | purple_account_remove_group(acct, group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
991 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
992 | /* remove blist entries that need to go */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
993 | while(prune) { |
| 15884 | 994 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
995 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
996 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
997 | DEBUG_INFO("cleared buddies\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
998 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
999 | /* 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
|
1000 | 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
|
1001 | DEBUG_INFO("removing empty group\n"); |
| 15884 | 1002 | purple_blist_remove_group(group); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1003 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1004 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1005 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1006 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1007 | /** prune out group members that shouldn't be there */ |
| 15884 | 1008 | static void group_prune(PurpleConnection *gc, PurpleGroup *group, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1009 | struct mwSametimeGroup *stgroup) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1010 | |
| 15884 | 1011 | PurpleAccount *acct; |
| 1012 | PurpleBlistNode *gn, *cn, *bn; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1013 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1014 | GHashTable *stusers; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1015 | GList *prune = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1016 | GList *ul, *utl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1017 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1018 | g_return_if_fail(group != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1019 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1020 | 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
|
1021 | |
| 15884 | 1022 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1023 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1024 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1025 | 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
|
1026 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1027 | /* 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
|
1028 | contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1029 | utl = mwSametimeGroup_getUsers(stgroup); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1030 | for(ul = utl; ul; ul = ul->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1031 | const char *id = mwSametimeUser_getUser(ul->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1032 | 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
|
1033 | DEBUG_INFO("server copy has %s\n", id); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1034 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1035 | g_list_free(utl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1036 | |
| 15884 | 1037 | gn = (PurpleBlistNode *) group; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1038 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1039 | for(cn = purple_blist_node_get_first_child(gn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1040 | cn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1041 | 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
|
1042 | if(! PURPLE_IS_CONTACT(cn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1043 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1044 | for(bn = purple_blist_node_get_first_child(cn); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1045 | bn; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1046 | bn = purple_blist_node_get_sibling_next(bn)) { |
| 15884 | 1047 | PurpleBuddy *gb = (PurpleBuddy *) bn; |
| 1048 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1049 | if(! PURPLE_IS_BUDDY(bn)) continue; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1050 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1051 | /* 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
|
1052 | them for pruning */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1053 | 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
|
1054 | 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
|
1055 | prune = g_list_prepend(prune, gb); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1056 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1057 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1058 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1059 | DEBUG_INFO("done marking\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1060 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1061 | g_hash_table_destroy(stusers); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1062 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1063 | if(prune) { |
| 15884 | 1064 | purple_account_remove_buddies(acct, prune, NULL); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1065 | while(prune) { |
| 15884 | 1066 | purple_blist_remove_buddy(prune->data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1067 | prune = g_list_delete_link(prune, prune); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1068 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1069 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1070 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1071 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1072 | |
| 15884 | 1073 | /** 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
|
1074 | existing buddies that aren't in the st list */ |
| 15884 | 1075 | static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist) { |
| 1076 | ||
| 1077 | PurpleAccount *acct; | |
| 1078 | PurpleBuddyList *blist; | |
| 1079 | PurpleBlistNode *gn; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1080 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1081 | GHashTable *stgroups; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1082 | GList *g_prune = NULL; |
|
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 | GList *gl, *gtl; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1085 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1086 | const char *acct_n; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1087 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1088 | DEBUG_INFO("synchronizing local buddy list from server list\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1089 | |
| 15884 | 1090 | acct = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1091 | g_return_if_fail(acct != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1092 | |
| 15884 | 1093 | acct_n = purple_account_get_username(acct); |
| 1094 | ||
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1095 | blist = purple_blist_get_default(); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1096 | g_return_if_fail(blist != NULL); |
|
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 | /* 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
|
1099 | list, mapping group name to group structure */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1100 | 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
|
1101 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1102 | gtl = mwSametimeList_getGroups(stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1103 | for(gl = gtl; gl; gl = gl->next) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1104 | const char *name = mwSametimeGroup_getName(gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1105 | g_hash_table_insert(stgroups, (char *) name, gl->data); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1106 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1107 | g_list_free(gtl); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1108 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1109 | /* 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
|
1110 | 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
|
1111 | gn = purple_blist_node_get_sibling_next(gn)) { |
| 15884 | 1112 | PurpleGroup *grp = (PurpleGroup *) gn; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1113 | const char *gname, *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1114 | struct mwSametimeGroup *stgrp; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1115 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1116 | if(! PURPLE_IS_GROUP(gn)) continue; |
|
11943
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 | /* group not belonging to this account */ |
| 15884 | 1119 | if(! purple_group_on_account(grp, acct)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1120 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1121 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1122 | /* dynamic group belonging to this account. don't prune contents */ |
| 15884 | 1123 | 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
|
1124 | if(owner && purple_strequal(owner, acct_n)) |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1125 | continue; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1126 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1127 | /* we actually are synching by this key as opposed to the group |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1128 | title, which can be different things in the st list */ |
| 15884 | 1129 | 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
|
1130 | if(! gname) gname = purple_group_get_name(grp); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1131 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1132 | stgrp = g_hash_table_lookup(stgroups, gname); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1133 | if(! stgrp) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1134 | /* remove the whole group */ |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1135 | 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
|
1136 | g_prune = g_list_prepend(g_prune, grp); |
|
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 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1139 | /* synch the group contents */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1140 | group_prune(gc, grp, stgrp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1141 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1142 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1143 | DEBUG_INFO("done marking groups\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1144 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1145 | /* don't need this anymore */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1146 | g_hash_table_destroy(stgroups); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1147 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1148 | /* prune all marked groups */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1149 | while(g_prune) { |
| 15884 | 1150 | PurpleGroup *grp = g_prune->data; |
| 1151 | PurpleBlistNode *gn = (PurpleBlistNode *) grp; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1152 | const char *owner; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1153 | gboolean del = TRUE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1154 | |
| 15884 | 1155 | 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
|
1156 | if(owner && !purple_strequal(owner, acct_n)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1157 | /* 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
|
1158 | 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
|
1159 | del = FALSE; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1160 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1161 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1162 | group_clear(g_prune->data, acct, del); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1163 | g_prune = g_list_delete_link(g_prune, g_prune); |
|
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 | /* done with the pruning, let's merge in the additions */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1167 | blist_merge(gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1168 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1169 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1170 | |
| 10977 | 1171 | /** callback passed to the storage service when it's told to load the |
| 1172 | st list */ | |
| 1173 | static void fetch_blist_cb(struct mwServiceStorage *srvc, | |
| 1174 | guint32 result, struct mwStorageUnit *item, | |
| 1175 | gpointer data) { | |
| 1176 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1177 | struct mwPurpleProtocolData *pd = data; |
| 10977 | 1178 | struct mwSametimeList *stlist; |
| 1179 | ||
| 1180 | struct mwGetBuffer *b; | |
| 1181 | ||
| 1182 | g_return_if_fail(result == ERR_SUCCESS); | |
| 1183 | ||
| 1184 | /* check our preferences for loading */ | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1185 | if(BLIST_PREF_IS_LOCAL()) { |
| 10977 | 1186 | DEBUG_INFO("preferences indicate not to load remote buddy list\n"); |
| 1187 | return; | |
| 1188 | } | |
| 1189 | ||
| 1190 | b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); | |
| 1191 | ||
| 1192 | stlist = mwSametimeList_new(); | |
| 1193 | mwSametimeList_get(b, stlist); | |
| 1194 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1195 | /* merge or synch depending on preferences */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1196 | if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1197 | blist_merge(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1198 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1199 | } else if(BLIST_PREF_IS_SYNCH()) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1200 | blist_sync(pd->gc, stlist); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1201 | } |
| 10977 | 1202 | |
| 1203 | mwSametimeList_free(stlist); | |
| 22973 | 1204 | mwGetBuffer_free(b); |
| 10977 | 1205 | } |
| 1206 | ||
| 1207 | ||
| 15884 | 1208 | /** signal triggered when a conversation is opened in Purple */ |
| 1209 | 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
|
1210 | struct mwPurpleProtocolData *pd) { |
| 10977 | 1211 | |
| 1212 | /* we need to tell the IM service to negotiate features for the | |
| 1213 | conversation right away, otherwise it'll wait until the first | |
| 1214 | message is sent before offering NotesBuddy features. Therefore | |
| 15884 | 1215 | whenever Purple creates a conversation, we'll immediately open the |
| 10977 | 1216 | channel to the other side and figure out what the target can |
| 1217 | handle. Unfortunately, this makes us vulnerable to Psychic Mode, | |
| 1218 | 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
|
1219 | would not */ |
| 10977 | 1220 | |
| 15884 | 1221 | PurpleConnection *gc; |
| 10977 | 1222 | struct mwIdBlock who = { 0, 0 }; |
| 1223 | struct mwConversation *conv; | |
| 1224 | ||
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1225 | gc = purple_conversation_get_connection(g_conv); |
| 10977 | 1226 | if(pd->gc != gc) |
| 1227 | return; /* not ours */ | |
| 1228 | ||
|
35070
d7350d876fda
libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents:
35005
diff
changeset
|
1229 | if(!PURPLE_IS_IM_CONVERSATION(g_conv)) |
| 10977 | 1230 | return; /* wrong type */ |
| 1231 | ||
| 15884 | 1232 | who.user = (char *) purple_conversation_get_name(g_conv); |
| 10977 | 1233 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 1234 | ||
| 1235 | convo_features(conv); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1236 | |
| 10977 | 1237 | if(mwConversation_isClosed(conv)) |
| 1238 | mwConversation_open(conv); | |
| 1239 | } | |
| 1240 | ||
| 1241 | ||
| 15884 | 1242 | 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
|
1243 | struct mwPurpleProtocolData *pd = data; |
| 15884 | 1244 | PurpleConnection *gc; |
| 1245 | ||
| 1246 | PurpleGroup *group = (PurpleGroup *) node; | |
| 10977 | 1247 | |
| 1248 | GString *str; | |
| 1249 | char *tmp; | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1250 | const char *gname; |
| 10977 | 1251 | |
| 1252 | g_return_if_fail(pd != NULL); | |
| 1253 | ||
| 1254 | gc = pd->gc; | |
| 1255 | g_return_if_fail(gc != NULL); | |
| 1256 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1257 | g_return_if_fail(PURPLE_IS_GROUP(node)); |
| 10977 | 1258 | |
| 1259 | str = g_string_new(NULL); | |
| 1260 | ||
| 15884 | 1261 | 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
|
1262 | gname = purple_group_get_name(group); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1263 | |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1264 | 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
|
1265 | 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
|
1266 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1267 | tmp = g_strdup_printf(_("Info for Group %s"), gname); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1268 | |
| 15884 | 1269 | purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
| 10977 | 1270 | NULL, str->str, NULL, NULL); |
| 1271 | ||
| 1272 | g_free(tmp); | |
| 1273 | g_string_free(str, TRUE); | |
| 1274 | } | |
| 1275 | ||
| 1276 | ||
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36628
diff
changeset
|
1277 | /** The normal blist menu protocol function doesn't get called for groups, |
| 10977 | 1278 | so we use the blist-node-extended-menu signal to trigger this |
| 1279 | handler */ | |
| 15884 | 1280 | 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
|
1281 | GList **menu, struct mwPurpleProtocolData *pd) { |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1282 | const char *owner; |
| 15884 | 1283 | PurpleAccount *acct; |
|
39481
4db28449567d
Rename PurpleMenuAction to PurpleActionMenu
Gary Kramlich <grim@reaperworld.com>
parents:
39479
diff
changeset
|
1284 | PurpleActionMenu *act; |
| 10977 | 1285 | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1286 | /* we only want groups */ |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1287 | if(! PURPLE_IS_GROUP(node)) return; |
| 15884 | 1288 | |
| 1289 | acct = purple_connection_get_account(pd->gc); | |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1290 | g_return_if_fail(acct != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1291 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1292 | /* better make sure we're connected */ |
| 15884 | 1293 | if(! purple_account_is_connected(acct)) return; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1294 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1295 | /* check if it's a NAB group for this account */ |
| 15884 | 1296 | 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
|
1297 | 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
|
1298 | act = purple_action_menu_new(_("Get Notes Address Book Info"), |
| 15884 | 1299 | PURPLE_CALLBACK(blist_menu_nab), pd, NULL); |
| 10977 | 1300 | *menu = g_list_append(*menu, act); |
| 1301 | } | |
| 1302 | } | |
| 1303 | ||
| 1304 | ||
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1305 | /* 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
|
1306 | anymore. */ |
| 15884 | 1307 | static void blist_init(PurpleAccount *acct) { |
| 1308 | PurpleBlistNode *gnode, *cnode, *bnode; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1309 | GList *add_buds = NULL; |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1310 | |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39526
diff
changeset
|
1311 | 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
|
1312 | 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
|
1313 | if(! PURPLE_IS_GROUP(gnode)) continue; |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1314 | |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1315 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1316 | cnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1317 | 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
|
1318 | if(! PURPLE_IS_CONTACT(cnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1319 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1320 | for(bnode = purple_blist_node_get_first_child(cnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1321 | bnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1322 | bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 15884 | 1323 | PurpleBuddy *b; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1324 | if(!PURPLE_IS_BUDDY(bnode)) |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1325 | continue; |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1326 | |
| 15884 | 1327 | b = (PurpleBuddy *)bnode; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
1328 | if(purple_buddy_get_account(b) == acct) { |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1329 | add_buds = g_list_append(add_buds, b); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1330 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1331 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1332 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1333 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1334 | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1335 | if(add_buds) { |
|
32319
ab70b05e538b
sametime: fix build (add_buddies added param)
Paul Aurich <darkrain42@pidgin.im>
parents:
32316
diff
changeset
|
1336 | purple_account_add_buddies(acct, add_buds, NULL); |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1337 | g_list_free(add_buds); |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1338 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1339 | } |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1340 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1341 | |
| 10977 | 1342 | /** 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
|
1343 | static void services_starting(struct mwPurpleProtocolData *pd) { |
| 15884 | 1344 | |
| 1345 | PurpleConnection *gc; | |
| 1346 | PurpleAccount *acct; | |
| 10977 | 1347 | struct mwStorageUnit *unit; |
| 15884 | 1348 | PurpleBlistNode *l; |
| 10977 | 1349 | |
| 1350 | gc = pd->gc; | |
| 15884 | 1351 | acct = purple_connection_get_account(gc); |
| 10977 | 1352 | |
| 1353 | /* grab the buddy list from the server */ | |
| 1354 | unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1355 | mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
| 10977 | 1356 | |
| 1357 | /* 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
|
1358 | 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
|
1359 | l = purple_blist_node_get_sibling_next(l)) { |
| 15884 | 1360 | PurpleGroup *group = (PurpleGroup *) l; |
| 10977 | 1361 | enum mwSametimeGroupType gt; |
| 1362 | const char *owner; | |
| 1363 | ||
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1364 | if(! PURPLE_IS_GROUP(l)) continue; |
| 10977 | 1365 | |
| 1366 | /* if the group is ownerless, or has an owner and we're not it, | |
| 1367 | skip it */ | |
| 15884 | 1368 | 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
|
1369 | if(!owner || !purple_strequal(owner, purple_account_get_username(acct))) |
| 10977 | 1370 | continue; |
| 1371 | ||
| 15884 | 1372 | gt = purple_blist_node_get_int(l, GROUP_KEY_TYPE); |
| 10977 | 1373 | if(gt == mwSametimeGroup_DYNAMIC) |
| 1374 | group_add(pd, group); | |
| 1375 | } | |
| 1376 | ||
| 1377 | /* set the aware attributes */ | |
| 1378 | /* indicate we understand what AV prefs are, but don't support any */ | |
| 1379 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1380 | mwAttribute_AV_PREFS_SET, TRUE); | |
| 1381 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE); | |
| 1382 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS); | |
| 1383 | mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA); | |
| 1384 | ||
| 1385 | /* ... but we can do file transfers! */ | |
| 1386 | mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
| 1387 | mwAttribute_FILE_TRANSFER, TRUE); | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1388 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1389 | blist_init(acct); |
| 10977 | 1390 | } |
| 1391 | ||
| 1392 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1393 | static void session_loginRedirect(struct mwSession *session, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1394 | const char *host) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1395 | struct mwPurpleProtocolData *pd; |
| 15884 | 1396 | PurpleConnection *gc; |
| 1397 | PurpleAccount *account; | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1398 | guint port; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1399 | const char *current_host; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1400 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1401 | pd = mwSession_getClientData(session); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1402 | gc = pd->gc; |
| 15884 | 1403 | account = purple_connection_get_account(gc); |
| 1404 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); | |
| 1405 | 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
|
1406 | MW_PLUGIN_DEFAULT_HOST); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1407 | |
| 15884 | 1408 | 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
|
1409 | !host || purple_strequal(current_host, host)) { |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1410 | /* 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
|
1411 | redirected to the already configured host, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1412 | we'll force the login instead */ |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
1413 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1414 | mwSession_forceLogin(session); |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1415 | return; |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1416 | } |
|
40620
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 | 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
|
1419 | if (pd->client == NULL) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1420 | /* 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
|
1421 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1422 | mwSession_forceLogin(session); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1423 | return; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1424 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1425 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1426 | g_socket_client_connect_to_host_async( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1427 | pd->client, host, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1428 | port, pd->cancellable, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1429 | connect_cb, pd); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1430 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1431 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1432 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
1433 | 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
|
1434 | |
|
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1435 | |
| 10977 | 1436 | /** called from mw_session_stateChange when the session's state is |
| 1437 | mwSession_STARTED. Any finalizing of start-up stuff should go | |
| 1438 | here */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1439 | static void session_started(struct mwPurpleProtocolData *pd) { |
| 15884 | 1440 | PurpleStatus *status; |
| 1441 | PurpleAccount *acct; | |
|
12266
d61e488f64d6
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1442 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1443 | /* set out initial status */ |
| 15884 | 1444 | acct = purple_connection_get_account(pd->gc); |
| 1445 | 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
|
1446 | mw_protocol_set_status(NULL, acct, status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1447 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1448 | /* start watching for new conversations */ |
| 15884 | 1449 | purple_signal_connect(purple_conversations_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1450 | "conversation-created", pd, |
| 15884 | 1451 | PURPLE_CALLBACK(conversation_created_cb), pd); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1452 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1453 | /* watch for group extended menu items */ |
| 15884 | 1454 | purple_signal_connect(purple_blist_get_handle(), |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1455 | "blist-node-extended-menu", pd, |
| 15884 | 1456 | PURPLE_CALLBACK(blist_node_menu_cb), pd); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1457 | |
| 10977 | 1458 | /* use our services to do neat things */ |
| 1459 | services_starting(pd); | |
| 1460 | } | |
| 1461 | ||
| 1462 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1463 | static void session_stopping(struct mwPurpleProtocolData *pd) { |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1464 | /* stop watching the signals from session_started */ |
| 15884 | 1465 | purple_signals_disconnect_by_handle(pd); |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1466 | } |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1467 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1468 | |
| 10977 | 1469 | static void mw_session_stateChange(struct mwSession *session, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1470 | enum mwSessionState state, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1471 | gpointer info) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1472 | struct mwPurpleProtocolData *pd; |
| 15884 | 1473 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1474 | const char *msg = NULL; |
| 10977 | 1475 | |
| 1476 | pd = mwSession_getClientData(session); | |
| 1477 | gc = pd->gc; | |
| 1478 | ||
| 1479 | switch(state) { | |
| 1480 | case mwSession_STARTING: | |
| 1481 | msg = _("Sending Handshake"); | |
| 15884 | 1482 | purple_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS); |
| 10977 | 1483 | break; |
| 1484 | ||
| 1485 | case mwSession_HANDSHAKE: | |
| 1486 | msg = _("Waiting for Handshake Acknowledgement"); | |
| 15884 | 1487 | purple_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS); |
| 10977 | 1488 | break; |
| 1489 | ||
| 1490 | case mwSession_HANDSHAKE_ACK: | |
| 1491 | msg = _("Handshake Acknowledged, Sending Login"); | |
| 15884 | 1492 | purple_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS); |
| 10977 | 1493 | break; |
| 1494 | ||
| 1495 | case mwSession_LOGIN: | |
| 1496 | msg = _("Waiting for Login Acknowledgement"); | |
| 15884 | 1497 | purple_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS); |
| 10977 | 1498 | break; |
| 1499 | ||
| 1500 | case mwSession_LOGIN_REDIR: | |
| 1501 | msg = _("Login Redirected"); | |
| 15884 | 1502 | 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
|
1503 | session_loginRedirect(session, info); |
| 10977 | 1504 | break; |
| 1505 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1506 | case mwSession_LOGIN_CONT: |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1507 | msg = _("Forcing Login"); |
| 15884 | 1508 | 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
|
1509 | break; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1510 | |
| 10977 | 1511 | case mwSession_LOGIN_ACK: |
| 1512 | msg = _("Login Acknowledged"); | |
| 15884 | 1513 | purple_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS); |
| 10977 | 1514 | break; |
| 1515 | ||
| 1516 | case mwSession_STARTED: | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1517 | msg = _("Starting Services"); |
| 15884 | 1518 | purple_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS); |
| 10977 | 1519 | |
| 1520 | session_started(pd); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1521 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1522 | msg = _("Connected"); |
| 15884 | 1523 | 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
|
1524 | purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED); |
| 10977 | 1525 | break; |
| 1526 | ||
| 1527 | case mwSession_STOPPING: | |
|
15426
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1528 | |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1529 | session_stopping(pd); |
|
def1a5724556
[gaim-migrate @ 18157]
Christopher O'Brien <siege@pidgin.im>
parents:
15345
diff
changeset
|
1530 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1531 | if(GPOINTER_TO_UINT(info) & ERR_FAILURE) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1532 | char *err = mwError(GPOINTER_TO_UINT(info)); |
| 21279 | 1533 | PurpleConnectionError reason; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1534 | switch (GPOINTER_TO_UINT(info)) { |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1535 | case VERSION_MISMATCH: |
| 21279 | 1536 | reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1537 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1538 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1539 | case USER_RESTRICTED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1540 | case INCORRECT_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1541 | case USER_UNREGISTERED: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1542 | case GUEST_IN_USE: |
| 21279 | 1543 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1544 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1545 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1546 | case ENCRYPT_MISMATCH: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1547 | case ERR_ENCRYPT_NO_SUPPORT: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1548 | case ERR_NO_COMMON_ENCRYPT: |
| 21279 | 1549 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
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 VERIFICATION_DOWN: |
| 21279 | 1553 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1554 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1555 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1556 | case MULTI_SERVER_LOGIN: |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1557 | case MULTI_SERVER_LOGIN2: |
| 21279 | 1558 | reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1559 | break; |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1560 | |
|
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1561 | default: |
| 21279 | 1562 | reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
20455
058f341481a5
Add disconnection reasons to sametime.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1563 | } |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31991
diff
changeset
|
1564 | purple_connection_error(gc, reason, err); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1565 | g_free(err); |
| 10977 | 1566 | } |
| 1567 | break; | |
| 1568 | ||
| 1569 | case mwSession_STOPPED: | |
| 1570 | break; | |
| 1571 | ||
| 1572 | case mwSession_UNKNOWN: | |
| 1573 | default: | |
| 1574 | DEBUG_WARN("session in unknown state\n"); | |
| 1575 | } | |
| 1576 | } | |
| 1577 | ||
| 1578 | ||
| 1579 | 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
|
1580 | struct mwPurpleProtocolData *pd; |
| 15884 | 1581 | PurpleConnection *gc; |
| 1582 | PurpleAccount *acct; | |
| 10977 | 1583 | struct mwPrivacyInfo *privacy; |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1584 | GSList *list; |
| 10977 | 1585 | guint count; |
| 1586 | ||
| 1587 | DEBUG_INFO("privacy information set from server\n"); | |
| 1588 | ||
| 1589 | g_return_if_fail(session != NULL); | |
| 1590 | ||
| 1591 | pd = mwSession_getClientData(session); | |
| 1592 | g_return_if_fail(pd != NULL); | |
| 1593 | ||
| 1594 | gc = pd->gc; | |
| 1595 | g_return_if_fail(gc != NULL); | |
| 1596 | ||
| 15884 | 1597 | acct = purple_connection_get_account(gc); |
| 10977 | 1598 | g_return_if_fail(acct != NULL); |
| 1599 | ||
| 1600 | privacy = mwSession_getPrivacyInfo(session); | |
| 1601 | count = privacy->count; | |
| 1602 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1603 | if (privacy->deny) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1604 | 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
|
1605 | 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
|
1606 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1607 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1608 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1609 | 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
|
1610 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1611 | } else { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1612 | 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
|
1613 | 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
|
1614 | } |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1615 | while (count--) { |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1616 | struct mwUserItem *u = privacy->users + count; |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
1617 | 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
|
1618 | } |
| 10977 | 1619 | } |
| 1620 | } | |
| 1621 | ||
| 1622 | ||
| 1623 | 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
|
1624 | struct mwPurpleProtocolData *pd; |
| 15884 | 1625 | PurpleConnection *gc; |
| 10977 | 1626 | struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL }; |
| 1627 | struct mwUserStatus *stat; | |
| 1628 | ||
| 1629 | g_return_if_fail(session != NULL); | |
| 1630 | ||
| 1631 | pd = mwSession_getClientData(session); | |
| 1632 | g_return_if_fail(pd != NULL); | |
| 1633 | ||
| 1634 | gc = pd->gc; | |
| 1635 | g_return_if_fail(gc != NULL); | |
| 1636 | ||
| 1637 | idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); | |
| 1638 | stat = mwSession_getUserStatus(session); | |
| 1639 | ||
| 1640 | /* trigger an update of our own status if we're in the buddy list */ | |
| 1641 | mwServiceAware_setStatus(pd->srvc_aware, &idb, stat); | |
| 1642 | } | |
| 1643 | ||
| 1644 | ||
| 1645 | static void mw_session_admin(struct mwSession *session, | |
| 1646 | const char *text) { | |
| 15884 | 1647 | PurpleConnection *gc; |
| 1648 | PurpleAccount *acct; | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1649 | const char *host; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1650 | const char *msg; |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1651 | char *prim; |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1652 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1653 | gc = session_to_gc(session); |
| 10977 | 1654 | g_return_if_fail(gc != NULL); |
| 1655 | ||
| 15884 | 1656 | acct = purple_connection_get_account(gc); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1657 | g_return_if_fail(acct != NULL); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1658 | |
| 15884 | 1659 | 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
|
1660 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
1661 | msg = _("A Sametime administrator has issued the following announcement" |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1662 | " on server %s"); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1663 | prim = g_strdup_printf(msg, host); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1664 | |
| 15884 | 1665 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1666 | _("Sametime Administrator Announcement"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1667 | prim, text, NULL, NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1668 | purple_request_cpar_from_connection(gc)); |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1669 | |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1670 | g_free(prim); |
| 10977 | 1671 | } |
| 1672 | ||
| 1673 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1674 | /** 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
|
1675 | 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
|
1676 | static gboolean |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1677 | read_cb(GObject *stream, gpointer data) |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1678 | { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1679 | struct mwPurpleProtocolData *pd = data; |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1680 | guchar buf[BUF_LEN]; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1681 | gssize len; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1682 | GError *error = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1683 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1684 | 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
|
1685 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1686 | do { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1687 | len = g_pollable_input_stream_read_nonblocking( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1688 | 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
|
1689 | pd->cancellable, &error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1690 | if (len == 0) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1691 | DEBUG_INFO("connection reset\n"); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1692 | purple_connection_error(pd->gc, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1693 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1694 | _("Server closed the connection")); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1695 | return G_SOURCE_REMOVE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1696 | } else if (len < 0) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1697 | /* 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
|
1698 | it and clean up internal state */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1699 | 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
|
1700 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1701 | return G_SOURCE_CONTINUE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1702 | } 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
|
1703 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1704 | } else { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1705 | g_prefix_error(&error, "%s", |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1706 | _("Lost connection with server: ")); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1707 | purple_connection_take_error(pd->gc, error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1708 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1709 | pd->inpa = 0; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1710 | pd->input = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1711 | g_clear_object(&pd->output); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1712 | g_clear_object(&pd->stream); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1713 | return G_SOURCE_REMOVE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1714 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1715 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1716 | mwSession_recv(pd->session, buf, len); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1717 | } while (len > 0); |
| 10977 | 1718 | |
| 1719 | /* normal operation ends here */ | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1720 | return G_SOURCE_CONTINUE; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1721 | } |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1722 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1723 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1724 | /* 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
|
1725 | * 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
|
1726 | static void |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1727 | 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
|
1728 | { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1729 | 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
|
1730 | struct mwPurpleProtocolData *pd = data; |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1731 | GSocketConnection *sockconn = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1732 | GSource *source = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1733 | GError *error = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1734 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1735 | 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
|
1736 | if (sockconn == NULL) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1737 | 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
|
1738 | /* connection was cancelled */ |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1739 | g_error_free(error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1740 | } else if (pd->stream) { |
| 10977 | 1741 | /* this is a redirect connect, force login on existing socket */ |
| 1742 | mwSession_forceLogin(pd->session); | |
| 1743 | ||
| 1744 | } else { | |
| 1745 | /* 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
|
1746 | purple_connection_take_error(pd->gc, error); |
| 10977 | 1747 | } |
| 1748 | ||
| 1749 | return; | |
| 1750 | } | |
| 1751 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1752 | if (pd->stream) { |
| 10977 | 1753 | /* stop any existing login attempt */ |
| 1754 | mwSession_stop(pd->session, ERR_SUCCESS); | |
| 1755 | } | |
| 1756 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1757 | 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
|
1758 | 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
|
1759 | pd->output = purple_queued_output_stream_new( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1760 | 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
|
1761 | source = g_pollable_input_stream_create_source( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1762 | 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
|
1763 | 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
|
1764 | pd->inpa = g_source_attach(source, NULL); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
1765 | g_source_unref(source); |
| 10977 | 1766 | |
| 1767 | mwSession_start(pd->session); | |
| 1768 | } | |
| 1769 | ||
| 1770 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1771 | static void mw_session_announce(struct mwSession *s, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1772 | struct mwLoginInfo *from, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1773 | gboolean may_reply, |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1774 | const char *text) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1775 | struct mwPurpleProtocolData *pd; |
| 15884 | 1776 | PurpleAccount *acct; |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
1777 | PurpleConversation *im; |
| 15884 | 1778 | PurpleBuddy *buddy; |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1779 | char *who = from->user_id; |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1780 | char *msg, *msg2; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1781 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1782 | pd = mwSession_getClientData(s); |
| 15884 | 1783 | acct = purple_connection_get_account(pd->gc); |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1784 | im = purple_conversations_find_im_with_account(who, acct); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1785 | if(! im) im = purple_im_conversation_new(acct, who); |
| 15884 | 1786 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
1787 | buddy = purple_blist_find_buddy(acct, who); |
| 15884 | 1788 | 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
|
1789 | |
|
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1790 | who = g_strdup_printf(_("Announcement from %s"), who); |
| 15884 | 1791 | msg = purple_markup_linkify(text); |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1792 | if (msg && msg[0]) |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1793 | 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
|
1794 | else |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1795 | msg2 = g_strdup(who); |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1796 | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
1797 | purple_conversation_write_system_message(im, msg2, 0); |
|
12263
5f0ddc426a58
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1798 | g_free(who); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1799 | g_free(msg); |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
1800 | g_free(msg2); |
| 10977 | 1801 | } |
| 1802 | ||
| 1803 | ||
| 1804 | static struct mwSessionHandler mw_session_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1805 | mw_session_io_write, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1806 | mw_session_io_close, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1807 | mw_session_clear, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1808 | mw_session_stateChange, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1809 | mw_session_setPrivacyInfo, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1810 | mw_session_setUserStatus, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1811 | mw_session_admin, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1812 | mw_session_announce, |
| 10977 | 1813 | }; |
| 1814 | ||
| 1815 | ||
| 1816 | static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
| 1817 | struct mwAwareAttribute *attrib) { | |
| 1818 | ||
| 1819 | ; /** @todo handle server attributes. There may be some stuff we | |
| 1820 | actually want to look for, but I'm not aware of anything right | |
| 1821 | now.*/ | |
| 1822 | } | |
| 1823 | ||
| 1824 | ||
| 1825 | static void mw_aware_clear(struct mwServiceAware *srvc) { | |
| 1826 | ; /* nothing for now */ | |
| 1827 | } | |
| 1828 | ||
| 1829 | ||
| 1830 | static struct mwAwareHandler mw_aware_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1831 | mw_aware_on_attrib, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
1832 | mw_aware_clear, |
| 10977 | 1833 | }; |
| 1834 | ||
| 1835 | ||
| 1836 | static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
| 1837 | struct mwServiceAware *srvc; | |
| 1838 | srvc = mwServiceAware_new(s, &mw_aware_handler); | |
| 1839 | return srvc; | |
| 1840 | }; | |
| 1841 | ||
| 1842 | ||
| 1843 | static void mw_conf_invited(struct mwConference *conf, | |
| 1844 | struct mwLoginInfo *inviter, | |
| 1845 | const char *invitation) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1846 | |
| 10977 | 1847 | struct mwServiceConference *srvc; |
| 1848 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1849 | struct mwPurpleProtocolData *pd; |
| 15884 | 1850 | PurpleConnection *gc; |
| 10977 | 1851 | |
| 1852 | char *c_inviter, *c_name, *c_topic, *c_invitation; | |
| 1853 | GHashTable *ht; | |
| 1854 | ||
| 1855 | srvc = mwConference_getService(conf); | |
| 1856 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1857 | pd = mwSession_getClientData(session); | |
| 1858 | gc = pd->gc; | |
| 1859 | ||
| 1860 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1861 | ||
| 1862 | c_inviter = g_strdup(inviter->user_id); | |
| 1863 | g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
| 1864 | ||
| 1865 | c_name = g_strdup(mwConference_getName(conf)); | |
| 1866 | g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
| 1867 | ||
| 1868 | c_topic = g_strdup(mwConference_getTitle(conf)); | |
| 1869 | g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
| 1870 | ||
| 1871 | c_invitation = g_strdup(invitation); | |
| 1872 | g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
| 1873 | ||
| 1874 | 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
|
1875 | c_inviter, c_name, |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1876 | c_topic, c_invitation); |
| 10977 | 1877 | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1878 | if(! c_topic) c_topic = "(no title)"; |
|
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1879 | if(! c_invitation) c_invitation = "(no message)"; |
| 35501 | 1880 | purple_serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
| 10977 | 1881 | } |
| 1882 | ||
| 1883 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1884 | /* The following mess helps us relate a mwConference to a PurpleChatConversation |
| 10977 | 1885 | in the various forms by which either may be indicated */ |
| 1886 | ||
| 1887 | #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
| 1888 | #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
| 1889 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1890 | #define CHAT_TO_ID(chat) (purple_chat_conversation_get_id(chat)) |
|
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1891 | #define ID_TO_CHAT(id) (purple_conversations_find_chat(id)) |
| 10977 | 1892 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1893 | #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
|
1894 | #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
| 10977 | 1895 | |
| 1896 | ||
| 1897 | static struct mwConference * | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1898 | conf_find_by_id(struct mwPurpleProtocolData *pd, int id) { |
| 10977 | 1899 | |
| 1900 | struct mwServiceConference *srvc = pd->srvc_conf; | |
| 1901 | struct mwConference *conf = NULL; | |
| 1902 | GList *l, *ll; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1903 | |
| 10977 | 1904 | ll = mwServiceConference_getConferences(srvc); |
| 1905 | for(l = ll; l; l = l->next) { | |
| 1906 | 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
|
1907 | PurpleChatConversation *h = mwConference_getClientData(c); |
| 10977 | 1908 | |
| 1909 | if(CHAT_TO_ID(h) == id) { | |
| 1910 | conf = c; | |
| 1911 | break; | |
| 1912 | } | |
| 1913 | } | |
| 1914 | g_list_free(ll); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1915 | |
| 10977 | 1916 | return conf; |
| 1917 | } | |
| 1918 | ||
| 1919 | ||
| 1920 | static void mw_conf_opened(struct mwConference *conf, GList *members) { | |
| 1921 | struct mwServiceConference *srvc; | |
| 1922 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1923 | struct mwPurpleProtocolData *pd; |
| 15884 | 1924 | PurpleConnection *gc; |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
1925 | PurpleConversation *g_conf; |
| 10977 | 1926 | |
| 1927 | const char *n = mwConference_getName(conf); | |
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1928 | const char *t = mwConference_getTitle(conf); |
| 10977 | 1929 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1930 | DEBUG_INFO("conf %s opened, %u initial members\n", n, g_list_length(members)); |
| 10977 | 1931 | |
| 1932 | srvc = mwConference_getService(conf); | |
| 1933 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1934 | pd = mwSession_getClientData(session); | |
| 1935 | gc = pd->gc; | |
| 1936 | ||
|
12742
88e624a344cb
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1937 | if(! t) t = "(no title)"; |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
1938 | g_conf = purple_serv_got_joined_chat(gc, CONF_TO_ID(conf), t); |
| 10977 | 1939 | |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
1940 | mwConference_setClientData(conf, g_conf, NULL); |
| 10977 | 1941 | |
| 1942 | for(; members; members = members->next) { | |
| 1943 | 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
|
1944 | 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
|
1945 | NULL, PURPLE_CHAT_USER_NONE, FALSE); |
| 10977 | 1946 | } |
| 1947 | } | |
| 1948 | ||
| 1949 | ||
| 1950 | static void mw_conf_closed(struct mwConference *conf, guint32 reason) { | |
| 1951 | struct mwServiceConference *srvc; | |
| 1952 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
1953 | struct mwPurpleProtocolData *pd; |
| 15884 | 1954 | PurpleConnection *gc; |
| 10977 | 1955 | |
| 1956 | const char *n = mwConference_getName(conf); | |
| 1957 | char *msg = mwError(reason); | |
| 1958 | ||
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1959 | DEBUG_INFO("conf %s closed, 0x%08x\n", n, reason); |
| 10977 | 1960 | |
| 1961 | srvc = mwConference_getService(conf); | |
| 1962 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 1963 | pd = mwSession_getClientData(session); | |
| 1964 | gc = pd->gc; | |
| 1965 | ||
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
1966 | purple_serv_got_chat_left(gc, CONF_TO_ID(conf)); |
| 10977 | 1967 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1968 | 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
|
1969 | purple_request_cpar_from_connection(gc)); |
| 10977 | 1970 | g_free(msg); |
| 1971 | } | |
| 1972 | ||
| 1973 | ||
| 1974 | static void mw_conf_peer_joined(struct mwConference *conf, | |
| 1975 | struct mwLoginInfo *peer) { | |
| 1976 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1977 | PurpleChatConversation *g_conf; |
| 10977 | 1978 | |
| 1979 | const char *n = mwConference_getName(conf); | |
| 1980 | ||
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1981 | DEBUG_INFO("%s joined conf %s\n", peer->user_id, n); |
| 10977 | 1982 | |
| 1983 | g_conf = mwConference_getClientData(conf); | |
| 1984 | g_return_if_fail(g_conf != NULL); | |
| 1985 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1986 | 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
|
1987 | NULL, PURPLE_CHAT_USER_NONE, TRUE); |
| 10977 | 1988 | } |
| 1989 | ||
| 1990 | ||
| 1991 | static void mw_conf_peer_parted(struct mwConference *conf, | |
| 1992 | struct mwLoginInfo *peer) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
1993 | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1994 | PurpleChatConversation *g_conf; |
| 10977 | 1995 | |
| 1996 | const char *n = mwConference_getName(conf); | |
| 1997 | ||
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
1998 | DEBUG_INFO("%s left conf %s\n", peer->user_id, n); |
| 10977 | 1999 | |
| 2000 | g_conf = mwConference_getClientData(conf); | |
| 2001 | g_return_if_fail(g_conf != NULL); | |
| 2002 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
2003 | purple_chat_conversation_remove_user(g_conf, peer->user_id, NULL); |
| 10977 | 2004 | } |
| 2005 | ||
| 2006 | ||
| 2007 | static void mw_conf_text(struct mwConference *conf, | |
| 2008 | struct mwLoginInfo *who, const char *text) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2009 | |
| 10977 | 2010 | struct mwServiceConference *srvc; |
| 2011 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2012 | struct mwPurpleProtocolData *pd; |
| 15884 | 2013 | PurpleConnection *gc; |
| 10977 | 2014 | char *esc; |
| 2015 | ||
|
12863
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2016 | if(! text) return; |
|
535f2e11db82
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2017 | |
| 10977 | 2018 | srvc = mwConference_getService(conf); |
| 2019 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2020 | pd = mwSession_getClientData(session); | |
| 2021 | gc = pd->gc; | |
| 2022 | ||
|
12864
072fcb25d27b
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2023 | esc = g_markup_escape_text(text, -1); |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
2024 | purple_serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, PURPLE_MESSAGE_RECV, esc, time(NULL)); |
| 10977 | 2025 | g_free(esc); |
| 2026 | } | |
| 2027 | ||
| 2028 | ||
| 2029 | static void mw_conf_typing(struct mwConference *conf, | |
| 2030 | struct mwLoginInfo *who, gboolean typing) { | |
| 2031 | ||
| 15884 | 2032 | /* purple really has no good way to expose this to the user. */ |
| 10977 | 2033 | |
| 2034 | const char *n = mwConference_getName(conf); | |
| 2035 | const char *w = who->user_id; | |
| 2036 | ||
| 2037 | if(typing) { | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2038 | DEBUG_INFO("%s in conf %s: <typing>\n", w, n); |
| 10977 | 2039 | |
| 2040 | } else { | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2041 | DEBUG_INFO("%s in conf %s: <stopped typing>\n", w, n); |
| 10977 | 2042 | } |
| 2043 | } | |
| 2044 | ||
| 2045 | ||
| 2046 | static void mw_conf_clear(struct mwServiceConference *srvc) { | |
| 2047 | ; | |
| 2048 | } | |
| 2049 | ||
| 2050 | ||
| 2051 | static struct mwConferenceHandler mw_conference_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2052 | mw_conf_invited, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2053 | mw_conf_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2054 | mw_conf_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2055 | mw_conf_peer_joined, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2056 | mw_conf_peer_parted, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2057 | mw_conf_text, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2058 | mw_conf_typing, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2059 | mw_conf_clear, |
| 10977 | 2060 | }; |
| 2061 | ||
| 2062 | ||
| 2063 | static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) { | |
| 2064 | struct mwServiceConference *srvc; | |
| 2065 | srvc = mwServiceConference_new(s, &mw_conference_handler); | |
| 2066 | return srvc; | |
| 2067 | } | |
| 2068 | ||
| 2069 | ||
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2070 | /** size of an outgoing file transfer chunk */ |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2071 | #define MW_FT_LEN (BUF_LONG * 2) |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2072 | |
|
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
|
2073 | #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
|
2074 | 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
|
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 _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
|
2077 | 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
|
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 | 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
|
2080 | }; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2081 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2082 | 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
|
2083 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2084 | |
| 15884 | 2085 | static void ft_incoming_cancel(PurpleXfer *xfer) { |
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29304
diff
changeset
|
2086 | /* 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
|
2087 | 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
|
2088 | if(mw_xfer->ft) mwFileTransfer_reject(mw_xfer->ft); |
| 10977 | 2089 | } |
| 2090 | ||
| 2091 | ||
| 15884 | 2092 | static void ft_incoming_init(PurpleXfer *xfer) { |
| 10977 | 2093 | /* incoming transfer accepted */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2094 | |
| 10977 | 2095 | /* - accept the mwFileTransfer |
| 2096 | - open/create the local FILE "wb" | |
| 2097 | - stick the FILE's fp in xfer->dest_fp | |
| 2098 | */ | |
| 2099 | ||
|
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 | mwXfer *mw_xfer = MW_XFER(xfer); |
| 10977 | 2101 | |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2102 | 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
|
2103 | 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
|
2104 | } |
|
bab07ecb9330
Make 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 | |
|
bab07ecb9330
Make 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 | |
|
bab07ecb9330
Make 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 | 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
|
2108 | 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
|
2109 | 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
|
2110 | |
|
bab07ecb9330
Make 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 | 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
|
2112 | 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
|
2113 | 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
|
2114 | |
|
bab07ecb9330
Make 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 | 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
|
2116 | 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
|
2117 | 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
|
2118 | 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
|
2119 | |
|
bab07ecb9330
Make 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 | 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
|
2121 | |
|
bab07ecb9330
Make 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 | 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
|
2123 | |
|
bab07ecb9330
Make 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 | 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
|
2125 | 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
|
2126 | 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
|
2127 | 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
|
2128 | |
|
bab07ecb9330
Make 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 | 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
|
2130 | |
|
bab07ecb9330
Make 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 | 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
|
2132 | 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
|
2133 | 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
|
2134 | |
|
bab07ecb9330
Make 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 | /* 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
|
2136 | 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
|
2137 | 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
|
2138 | 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
|
2139 | 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
|
2140 | 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
|
2141 | 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
|
2142 | 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
|
2143 | 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
|
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 | 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
|
2146 | |
|
bab07ecb9330
Make 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 | 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
|
2149 | 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
|
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 | |
|
bab07ecb9330
Make 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 | 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
|
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 | 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
|
2155 | 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
|
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 | 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
|
2158 | 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
|
2159 | } |
|
bab07ecb9330
Make 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 | |
|
bab07ecb9330
Make 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 | |
|
bab07ecb9330
Make 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 | 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
|
2163 | 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
|
2164 | 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
|
2165 | 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
|
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_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
|
2168 | 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
|
2169 | 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
|
2170 | 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
|
2171 | default: |
|
39670
8d95b195ce69
Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents:
39669
diff
changeset
|
2172 | 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
|
2173 | 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
|
2174 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2175 | } |
| 10977 | 2176 | |
| 2177 | static void mw_ft_offered(struct mwFileTransfer *ft) { | |
| 2178 | /* | |
| 15884 | 2179 | - create a purple ft object |
| 10977 | 2180 | - offer it |
| 2181 | */ | |
| 2182 | ||
| 2183 | struct mwServiceFileTransfer *srvc; | |
| 2184 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2185 | struct mwPurpleProtocolData *pd; |
| 15884 | 2186 | PurpleConnection *gc; |
| 2187 | PurpleAccount *acct; | |
| 10977 | 2188 | const char *who; |
| 15884 | 2189 | PurpleXfer *xfer; |
| 10977 | 2190 | |
| 2191 | /* @todo add some safety checks */ | |
| 2192 | srvc = mwFileTransfer_getService(ft); | |
| 2193 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2194 | pd = mwSession_getClientData(session); | |
| 2195 | gc = pd->gc; | |
| 15884 | 2196 | acct = purple_connection_get_account(gc); |
| 10977 | 2197 | |
| 2198 | who = mwFileTransfer_getUser(ft)->user; | |
| 2199 | ||
| 2200 | DEBUG_INFO("file transfer %p offered\n", ft); | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2201 | DEBUG_INFO(" from: %s\n", who); |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2202 | DEBUG_INFO(" file: %s\n", mwFileTransfer_getFileName(ft)); |
| 10977 | 2203 | DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft)); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
2204 | DEBUG_INFO(" text: %s\n", mwFileTransfer_getMessage(ft)); |
| 10977 | 2205 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34920
diff
changeset
|
2206 | xfer = purple_xfer_new(acct, PURPLE_XFER_TYPE_RECEIVE, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2207 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2208 | { |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
2209 | g_object_ref(xfer); |
|
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
2210 | mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) g_object_unref); |
| 15884 | 2211 | |
| 2212 | purple_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); | |
| 2213 | purple_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); | |
| 2214 | purple_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); | |
| 2215 | ||
| 2216 | purple_xfer_request(xfer); | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
15205
diff
changeset
|
2217 | } |
| 10977 | 2218 | } |
| 2219 | ||
| 2220 | ||
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2221 | static void ft_send(struct mwFileTransfer *ft) { |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2222 | 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
|
2223 | struct mwOpaque o = { MW_FT_LEN, buf }; |
| 10977 | 2224 | guint32 rem; |
| 15884 | 2225 | PurpleXfer *xfer; |
| 10977 | 2226 | |
| 2227 | xfer = mwFileTransfer_getClientData(ft); | |
| 2228 | ||
| 2229 | rem = mwFileTransfer_getRemaining(ft); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2230 | if(rem < MW_FT_LEN) o.len = rem; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2231 | |
| 36043 | 2232 | if(purple_xfer_read_file(xfer, buf, (size_t) o.len) == (gssize)o.len) { |
| 10977 | 2233 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2234 | /* calculate progress and display it */ |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2235 | 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
|
2236 | |
| 10977 | 2237 | mwFileTransfer_send(ft, &o); |
| 2238 | ||
| 2239 | } else { | |
| 2240 | int err = errno; | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2241 | 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
|
2242 | mwFileTransfer_getFileName(ft), g_strerror(err)); |
| 10977 | 2243 | |
| 2244 | mwFileTransfer_cancel(ft); | |
| 2245 | } | |
| 2246 | } | |
| 2247 | ||
| 2248 | ||
| 2249 | static void mw_ft_opened(struct mwFileTransfer *ft) { | |
| 2250 | /* | |
| 15884 | 2251 | - get purple ft from client data in ft |
| 10977 | 2252 | - set the state to active |
| 2253 | */ | |
| 2254 | ||
| 15884 | 2255 | PurpleXfer *xfer; |
| 10977 | 2256 | |
| 2257 | xfer = mwFileTransfer_getClientData(ft); | |
| 2258 | ||
| 2259 | if(! xfer) { | |
| 2260 | mwFileTransfer_cancel(ft); | |
| 2261 | mwFileTransfer_free(ft); | |
| 2262 | g_return_if_reached(); | |
| 2263 | } | |
| 2264 | ||
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34920
diff
changeset
|
2265 | 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
|
2266 | 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
|
2267 | ft_send(ft); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
2268 | } |
| 10977 | 2269 | } |
| 2270 | ||
| 2271 | ||
| 2272 | static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
| 2273 | /* | |
| 15884 | 2274 | - get purple ft from client data in ft |
| 10977 | 2275 | - indicate rejection/cancelation/completion |
| 2276 | - free the file transfer itself | |
| 2277 | */ | |
| 2278 | ||
| 15884 | 2279 | PurpleXfer *xfer; |
| 10977 | 2280 | |
| 2281 | xfer = mwFileTransfer_getClientData(ft); | |
| 2282 | if(xfer) { | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2283 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2284 | purple_xfer_set_completed(xfer, TRUE); |
| 2285 | purple_xfer_end(xfer); | |
| 10977 | 2286 | |
| 2287 | } else if(mwFileTransfer_isCancelLocal(ft)) { | |
| 15884 | 2288 | /* calling purple_xfer_cancel_local is redundant, since that's |
| 10977 | 2289 | probably what triggered this function to be called */ |
| 2290 | ; | |
| 2291 | ||
| 2292 | } else if(mwFileTransfer_isCancelRemote(ft)) { | |
| 2293 | /* steal the reference for the xfer */ | |
| 2294 | mwFileTransfer_setClientData(ft, NULL, NULL); | |
| 15884 | 2295 | purple_xfer_cancel_remote(xfer); |
| 10977 | 2296 | |
| 2297 | /* 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
|
2298 | g_object_unref(xfer); |
| 10977 | 2299 | return; |
| 2300 | } | |
| 2301 | } | |
| 2302 | ||
| 2303 | mwFileTransfer_free(ft); | |
| 2304 | } | |
| 2305 | ||
| 2306 | ||
| 2307 | static void mw_ft_recv(struct mwFileTransfer *ft, | |
| 2308 | struct mwOpaque *data) { | |
| 2309 | /* | |
| 15884 | 2310 | - get purple ft from client data in ft |
| 10977 | 2311 | - update transfered percentage |
| 15884 | 2312 | - if done, destroy the ft, disassociate from purple ft |
| 10977 | 2313 | */ |
| 2314 | ||
| 15884 | 2315 | PurpleXfer *xfer; |
| 10977 | 2316 | |
| 2317 | xfer = mwFileTransfer_getClientData(ft); | |
| 2318 | g_return_if_fail(xfer != NULL); | |
| 2319 | ||
| 2320 | /* 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
|
2321 | 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
|
2322 | 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
|
2323 | 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
|
2324 | return; |
|
e84f28057053
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
2325 | } |
| 10977 | 2326 | |
| 2327 | /* update the progress */ | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32243
diff
changeset
|
2328 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + data->len); |
| 10977 | 2329 | |
| 2330 | /* let the other side know we got it, and to send some more */ | |
| 2331 | mwFileTransfer_ack(ft); | |
| 2332 | } | |
| 2333 | ||
| 2334 | ||
| 2335 | static void mw_ft_ack(struct mwFileTransfer *ft) { | |
| 15884 | 2336 | PurpleXfer *xfer; |
| 10977 | 2337 | |
| 2338 | xfer = mwFileTransfer_getClientData(ft); | |
| 2339 | g_return_if_fail(xfer != NULL); | |
|
32705
9d97ac4c2c22
Sametime: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents:
32698
diff
changeset
|
2340 | g_return_if_fail(purple_xfer_get_watcher(xfer) == 0); |
| 10977 | 2341 | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2342 | if(! mwFileTransfer_getRemaining(ft)) { |
| 15884 | 2343 | purple_xfer_set_completed(xfer, TRUE); |
| 2344 | purple_xfer_end(xfer); | |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2345 | |
|
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2346 | } else if(mwFileTransfer_isOpen(ft)) { |
|
34917
5bf76308abd1
Refactored sametime to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34912
diff
changeset
|
2347 | ft_send(ft); |
|
13208
3e9365fcfd0e
[gaim-migrate @ 15571]
Christopher O'Brien <siege@pidgin.im>
parents:
13206
diff
changeset
|
2348 | } |
| 10977 | 2349 | } |
| 2350 | ||
| 2351 | ||
| 2352 | static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
| 2353 | ; | |
| 2354 | } | |
| 2355 | ||
| 2356 | ||
| 2357 | static struct mwFileTransferHandler mw_ft_handler = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2358 | mw_ft_offered, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2359 | mw_ft_opened, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2360 | mw_ft_closed, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2361 | mw_ft_recv, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2362 | mw_ft_ack, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
2363 | mw_ft_clear, |
| 10977 | 2364 | }; |
| 2365 | ||
| 2366 | ||
| 2367 | static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
| 2368 | struct mwServiceFileTransfer *srvc; | |
| 2369 | GHashTable *ft_map; | |
| 2370 | ||
| 2371 | ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
| 2372 | ||
| 2373 | srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
| 2374 | mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
| 2375 | (GDestroyNotify) g_hash_table_destroy); | |
| 2376 | ||
| 2377 | return srvc; | |
| 2378 | } | |
| 2379 | ||
| 2380 | ||
|
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
|
2381 | 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
|
2382 | 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
|
2383 | |
|
bab07ecb9330
Make 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 | 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
|
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 | 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
|
2387 | } |
|
bab07ecb9330
Make 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 | |
|
bab07ecb9330
Make 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 | 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
|
2391 | 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
|
2392 | |
|
bab07ecb9330
Make 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 | } |
|
bab07ecb9330
Make 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 | 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
|
2396 | 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
|
2397 | |
|
bab07ecb9330
Make 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 | } |
|
bab07ecb9330
Make 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 | |
|
bab07ecb9330
Make 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 | 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
|
2401 | 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
|
2402 | 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
|
2403 | |
|
bab07ecb9330
Make 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->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
|
2405 | 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
|
2406 | 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
|
2407 | 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
|
2408 | } |
|
bab07ecb9330
Make 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 | |
|
bab07ecb9330
Make 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 | 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
|
2412 | 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
|
2413 | |
|
bab07ecb9330
Make 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 | 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
|
2415 | |
|
bab07ecb9330
Make 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 | 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
|
2417 | 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
|
2418 | "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
|
2419 | "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
|
2420 | "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
|
2421 | 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
|
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 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2424 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2425 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39526
diff
changeset
|
2426 | |
| 10977 | 2427 | static void convo_data_free(struct convo_data *cd) { |
| 2428 | GList *l; | |
| 2429 | ||
| 2430 | /* clean the queue */ | |
| 2431 | for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
| 2432 | struct convo_msg *m = l->data; | |
| 2433 | if(m->clear) m->clear(m->data); | |
| 2434 | g_free(m); | |
| 2435 | } | |
| 2436 | ||
| 2437 | g_free(cd); | |
| 2438 | } | |
| 2439 | ||
| 2440 | ||
| 2441 | /** allocates a convo_data structure and associates it with the | |
| 2442 | conversation in the client data slot */ | |
| 2443 | static void convo_data_new(struct mwConversation *conv) { | |
| 2444 | struct convo_data *cd; | |
| 2445 | ||
| 2446 | g_return_if_fail(conv != NULL); | |
| 2447 | ||
| 2448 | if(mwConversation_getClientData(conv)) | |
| 2449 | return; | |
| 2450 | ||
| 2451 | cd = g_new0(struct convo_data, 1); | |
| 2452 | cd->conv = conv; | |
| 2453 | ||
| 2454 | mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
| 2455 | } | |
| 2456 | ||
| 2457 | ||
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
2458 | static PurpleConversation *convo_get_im(struct mwConversation *conv) { |
| 10977 | 2459 | struct mwServiceIm *srvc; |
| 2460 | struct mwSession *session; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
2461 | struct mwPurpleProtocolData *pd; |
| 15884 | 2462 | PurpleConnection *gc; |
| 2463 | PurpleAccount *acct; | |
| 10977 | 2464 | |
| 2465 | struct mwIdBlock *idb; | |
| 2466 | ||
| 2467 | srvc = mwConversation_getService(conv); | |
| 2468 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 2469 | pd = mwSession_getClientData(session); | |
| 2470 | gc = pd->gc; | |
| 15884 | 2471 | acct = purple_connection_get_account(gc); |
| 10977 | 2472 | |
| 2473 | idb = mwConversation_getTarget(conv); | |
| 2474 | ||
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
2475 | return purple_conversations_find_im_with_account(idb->user, acct); |
| 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 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2861 | if(CHAT_TO_ID(h) == id) { |
|
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 | ||
| 3109 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3110 | static const char *mw_protocol_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
| 10977 | 3111 | /* my little green dude is a chopped up version of the aim running |
| 3112 | guy. First, cut off the head and store someplace safe. Then, | |
| 3113 | take the left-half side of the body and throw it away. Make a | |
| 3114 | copy of the remaining body, and flip it horizontally. Now attach | |
| 3115 | the two pieces into an X shape, and drop the head back on the | |
| 3116 | top, being careful to center it. Then, just change the color | |
| 3117 | saturation to bring the red down a bit, and voila! */ | |
| 3118 | ||
| 3119 | /* then, throw all of that away and use sodipodi to make a new | |
| 3120 | icon. You know, LIKE A REAL MAN. */ | |
| 3121 | ||
| 3122 | return "meanwhile"; | |
| 3123 | } | |
| 3124 | ||
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3125 | static GList * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3126 | mw_protocol_get_account_options(PurpleProtocol *protocol) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3127 | PurpleAccountOption *opt; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3128 | GList *opts = NULL; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3129 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3130 | /* port to connect to */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3131 | opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3132 | MW_PLUGIN_DEFAULT_PORT); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3133 | opts = g_list_append(opts, opt); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3134 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3135 | { /* copy the old force login setting from prefs if it's |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3136 | there. Don't delete the preference, since there may be more |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3137 | than one account that wants to check for it. */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3138 | gboolean b = FALSE; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3139 | const gchar *label = _("Force login (ignore server redirects)"); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3140 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3141 | if (purple_prefs_exists(MW_PROTOCOL_OPT_FORCE_LOGIN)) |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3142 | b = purple_prefs_get_bool(MW_PROTOCOL_OPT_FORCE_LOGIN); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3143 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3144 | opt = purple_account_option_bool_new(label, MW_KEY_FORCE, b); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3145 | opts = g_list_append(opts, opt); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3146 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3147 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3148 | /* pretend to be Sametime Connect */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3149 | opt = purple_account_option_bool_new(_("Hide client identity"), |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3150 | MW_KEY_FAKE_IT, FALSE); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3151 | opts = g_list_append(opts, opt); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3152 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3153 | return opts; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3154 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3155 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3156 | static GList * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3157 | mw_protocol_get_user_splits(PurpleProtocol *protocol) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3158 | PurpleAccountUserSplit *split; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3159 | GList *splits = NULL; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3160 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3161 | /* set up account ID as user:server */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3162 | split = purple_account_user_split_new(_("Server"), |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3163 | MW_PLUGIN_DEFAULT_HOST, ':'); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3164 | splits = g_list_append(splits, split); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3165 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3166 | return splits; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
3167 | } |
| 10977 | 3168 | |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3169 | 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
|
3170 | 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
|
3171 | if(buddy_is_external(b)) { |
| 15524 | 3172 | 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
|
3173 | } |
| 15524 | 3174 | |
| 3175 | return NULL; | |
| 10977 | 3176 | } |
| 3177 | ||
| 3178 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3179 | static char * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3180 | mw_protocol_status_text(PurpleProtocolClient * client, PurpleBuddy *b) { |
| 15884 | 3181 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3182 | struct mwPurpleProtocolData *pd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3183 | 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
|
3184 | 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
|
3185 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3186 | 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
|
3187 | && (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
|
3188 | 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
|
3189 | |
|
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
|
3190 | return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 10977 | 3191 | } |
| 3192 | ||
| 3193 | ||
| 15884 | 3194 | static const char *status_text(PurpleBuddy *b) { |
| 3195 | PurplePresence *presence; | |
| 3196 | PurpleStatus *status; | |
| 3197 | ||
| 3198 | presence = purple_buddy_get_presence(b); | |
| 3199 | status = purple_presence_get_active_status(presence); | |
| 3200 | ||
| 3201 | return purple_status_get_name(status); | |
| 10977 | 3202 | } |
| 3203 | ||
| 3204 | ||
| 3205 | static gboolean user_supports(struct mwServiceAware *srvc, | |
| 3206 | const char *who, guint32 feature) { | |
| 3207 | ||
| 3208 | const struct mwAwareAttribute *attr; | |
| 3209 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
| 3210 | ||
| 3211 | attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
| 3212 | return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
| 3213 | } | |
| 3214 | ||
| 3215 | ||
|
12422
53fba178cadf
[gaim-migrate @ 14729]
Richard Laager <rlaager@pidgin.im>
parents:
12312
diff
changeset
|
3216 | 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
|
3217 | const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3218 | const char **f = feat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3219 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3220 | if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3221 | gboolean mic, speak, video; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3222 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3223 | mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3224 | speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3225 | video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3226 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3227 | if(mic) *f++ = _("Microphone"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3228 | if(speak) *f++ = _("Speakers"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3229 | if(video) *f++ = _("Video Camera"); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3230 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3231 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3232 | if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3233 | *f++ = _("File Transfer"); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3234 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3235 | return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3236 | /* jenni loves siege */ |
| 10977 | 3237 | } |
| 3238 | ||
| 3239 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3240 | static void |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3241 | 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
|
3242 | 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
|
3243 | { |
| 15884 | 3244 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3245 | struct mwPurpleProtocolData *pd = NULL; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3246 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 10977 | 3247 | |
|
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
|
3248 | const char *message = NULL; |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3249 | const char *status; |
|
12954
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3250 | char *tmp; |
| 10977 | 3251 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3252 | 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
|
3253 | && (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
|
3254 | 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
|
3255 | |
|
12953
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3256 | status = status_text(b); |
|
cb41397f42d4
[gaim-migrate @ 15306]
Richard Laager <rlaager@pidgin.im>
parents:
12952
diff
changeset
|
3257 | |
|
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
|
3258 | 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
|
3259 | 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
|
3260 | |
|
a0f02cc2e803
[gaim-migrate @ 15307]
Richard Laager <rlaager@pidgin.im>
parents:
12953
diff
changeset
|
3261 | } 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
|
3262 | purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status); |
| 10977 | 3263 | } |
| 3264 | ||
|
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
|
3265 | if(full && pd != NULL) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3266 | 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
|
3267 | 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
|
3268 | 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
|
3269 | g_free(tmp); |
|
12950
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3270 | } |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3271 | |
|
167358332f4b
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3272 | 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
|
3273 | 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
|
3274 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3275 | } |
| 10977 | 3276 | } |
| 3277 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3278 | 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
|
3279 | { |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3280 | GList *types = NULL; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3281 | PurpleStatusType *type; |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3282 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3283 | 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
|
3284 | 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
|
3285 | 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
|
3286 | NULL); |
|
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 | 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
|
3290 | 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
|
3291 | 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
|
3292 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3293 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3294 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3295 | 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
|
3296 | 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
|
3297 | 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
|
3298 | NULL); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3299 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3300 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3301 | 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
|
3302 | 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
|
3303 | types = g_list_append(types, type); |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3304 | |
|
26bb4211aa76
Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3305 | return types; |
| 10977 | 3306 | } |
| 3307 | ||
| 3308 | ||
| 15884 | 3309 | static void conf_create_prompt_cancel(PurpleBuddy *buddy, |
| 3310 | PurpleRequestFields *fields) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3311 | ; /* nothing to do */ |
| 10977 | 3312 | } |
| 3313 | ||
| 3314 | ||
| 15884 | 3315 | static void conf_create_prompt_join(PurpleBuddy *buddy, |
| 3316 | PurpleRequestFields *fields) { | |
| 3317 | PurpleAccount *acct; | |
| 3318 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3319 | struct mwPurpleProtocolData *pd; |
| 10977 | 3320 | struct mwServiceConference *srvc; |
| 3321 | ||
| 15884 | 3322 | PurpleRequestField *f; |
| 10977 | 3323 | |
| 3324 | const char *topic, *invite; | |
| 3325 | struct mwConference *conf; | |
| 3326 | struct mwIdBlock idb = { NULL, NULL }; | |
| 3327 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3328 | acct = purple_buddy_get_account(buddy); |
| 15884 | 3329 | 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
|
3330 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3331 | srvc = pd->srvc_conf; |
| 3332 | ||
| 15884 | 3333 | f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3334 | topic = purple_request_field_string_get_value(f); | |
| 3335 | ||
| 3336 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
| 3337 | invite = purple_request_field_string_get_value(f); | |
| 10977 | 3338 | |
| 3339 | conf = mwConference_new(srvc, topic); | |
| 3340 | mwConference_open(conf); | |
| 3341 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3342 | idb.user = (char *)purple_buddy_get_name(buddy); |
| 10977 | 3343 | mwConference_invite(conf, &idb, invite); |
| 3344 | } | |
| 3345 | ||
| 3346 | ||
| 15884 | 3347 | static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
| 3348 | ||
| 3349 | PurpleRequestFields *fields; | |
| 3350 | PurpleRequestFieldGroup *g; | |
| 3351 | PurpleRequestField *f; | |
| 3352 | ||
| 3353 | PurpleAccount *acct; | |
| 3354 | PurpleConnection *gc; | |
| 10977 | 3355 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3356 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3357 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3358 | char *msg1; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3359 | |
| 10977 | 3360 | g_return_if_fail(buddy != NULL); |
| 3361 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3362 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3363 | g_return_if_fail(acct != NULL); |
| 3364 | ||
| 15884 | 3365 | gc = purple_account_get_connection(acct); |
| 10977 | 3366 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3367 | |
| 15884 | 3368 | fields = purple_request_fields_new(); |
| 3369 | ||
| 3370 | g = purple_request_field_group_new(NULL); | |
| 3371 | purple_request_fields_add_group(fields, g); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3372 | |
| 15884 | 3373 | f = purple_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
| 3374 | purple_request_field_group_add_field(g, f); | |
| 3375 | ||
| 3376 | f = purple_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); | |
| 3377 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3378 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3379 | msgA = _("Create conference with user"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3380 | 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
|
3381 | " 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
|
3382 | msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3383 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3384 | purple_request_fields(gc, _("New Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3385 | msgA, msg1, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3386 | _("Create"), G_CALLBACK(conf_create_prompt_join), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3387 | _("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
|
3388 | purple_request_cpar_from_account(acct), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3389 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3390 | g_free(msg1); |
| 10977 | 3391 | } |
| 3392 | ||
| 3393 | ||
| 15884 | 3394 | static void conf_select_prompt_cancel(PurpleBuddy *buddy, |
| 3395 | PurpleRequestFields *fields) { | |
| 10977 | 3396 | ; |
| 3397 | } | |
| 3398 | ||
| 3399 | ||
| 15884 | 3400 | static void conf_select_prompt_invite(PurpleBuddy *buddy, |
| 3401 | PurpleRequestFields *fields) { | |
| 3402 | 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
|
3403 | GList *l; |
| 10977 | 3404 | const char *msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3405 | |
| 15884 | 3406 | f = purple_request_fields_get_field(fields, CHAT_KEY_INVITE); |
| 3407 | msg = purple_request_field_string_get_value(f); | |
| 3408 | ||
| 3409 | f = purple_request_fields_get_field(fields, "conf"); | |
| 3410 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 3411 | |
| 3412 | if(l) { | |
| 15884 | 3413 | 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
|
3414 | |
| 10977 | 3415 | if(GPOINTER_TO_INT(d) == 0x01) { |
| 3416 | blist_menu_conf_create(buddy, msg); | |
| 3417 | ||
| 3418 | } else { | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3419 | struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 3420 | mwConference_invite(d, &idb, msg); |
| 3421 | } | |
| 3422 | } | |
| 3423 | } | |
| 3424 | ||
| 3425 | ||
| 15884 | 3426 | static void blist_menu_conf_list(PurpleBuddy *buddy, |
| 10977 | 3427 | GList *confs) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3428 | |
| 15884 | 3429 | PurpleRequestFields *fields; |
| 3430 | PurpleRequestFieldGroup *g; | |
| 3431 | PurpleRequestField *f; | |
| 3432 | ||
| 3433 | PurpleAccount *acct; | |
| 3434 | PurpleConnection *gc; | |
| 10977 | 3435 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3436 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3437 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3438 | char *msg; |
| 10977 | 3439 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3440 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3441 | g_return_if_fail(acct != NULL); |
| 3442 | ||
| 15884 | 3443 | gc = purple_account_get_connection(acct); |
| 10977 | 3444 | g_return_if_fail(gc != NULL); |
| 3445 | ||
| 15884 | 3446 | fields = purple_request_fields_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3447 | |
| 15884 | 3448 | g = purple_request_field_group_new(NULL); |
| 3449 | purple_request_fields_add_group(fields, g); | |
| 3450 | ||
| 3451 | f = purple_request_field_list_new("conf", _("Available Conferences")); | |
| 3452 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 10977 | 3453 | for(; confs; confs = confs->next) { |
| 3454 | struct mwConference *c = confs->data; | |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3455 | purple_request_field_list_add_icon(f, mwConference_getTitle(c), NULL, c); |
| 10977 | 3456 | } |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
3457 | 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
|
3458 | NULL, GINT_TO_POINTER(0x01)); |
| 15884 | 3459 | purple_request_field_group_add_field(g, f); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3460 | |
| 15884 | 3461 | f = purple_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); |
| 3462 | purple_request_field_group_add_field(g, f); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3463 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3464 | msgA = _("Invite user to a conference"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3465 | 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
|
3466 | " 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
|
3467 | " 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
|
3468 | msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
| 10977 | 3469 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3470 | purple_request_fields(gc, _("Invite to Conference"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3471 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3472 | _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3473 | _("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
|
3474 | purple_request_cpar_from_account(acct), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
3475 | buddy); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
3476 | g_free(msg); |
| 10977 | 3477 | } |
| 3478 | ||
| 3479 | ||
| 15884 | 3480 | static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { |
| 3481 | PurpleBuddy *buddy = (PurpleBuddy *) node; | |
| 3482 | PurpleAccount *acct; | |
| 3483 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3484 | struct mwPurpleProtocolData *pd; |
| 10977 | 3485 | GList *l; |
| 3486 | ||
| 3487 | 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
|
3488 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 10977 | 3489 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3490 | acct = purple_buddy_get_account(buddy); |
| 10977 | 3491 | g_return_if_fail(acct != NULL); |
| 3492 | ||
| 15884 | 3493 | gc = purple_account_get_connection(acct); |
| 10977 | 3494 | g_return_if_fail(gc != NULL); |
| 3495 | ||
|
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
|
3496 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3497 | g_return_if_fail(pd != NULL); |
| 3498 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3499 | /* |
| 10977 | 3500 | - get a list of all conferences on this session |
| 3501 | - if none, prompt to create one, and invite buddy to it | |
| 3502 | - else, prompt to select a conference or create one | |
| 3503 | */ | |
| 3504 | ||
| 3505 | l = mwServiceConference_getConferences(pd->srvc_conf); | |
| 3506 | if(l) { | |
| 3507 | blist_menu_conf_list(buddy, l); | |
| 3508 | g_list_free(l); | |
| 3509 | ||
| 3510 | } else { | |
| 3511 | blist_menu_conf_create(buddy, NULL); | |
| 3512 | } | |
| 3513 | } | |
| 3514 | ||
| 3515 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3516 | static GList * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3517 | 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
|
3518 | PurpleBlistNode *node) |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
3519 | { |
| 10977 | 3520 | GList *l = NULL; |
|
39481
4db28449567d
Rename PurpleMenuAction to PurpleActionMenu
Gary Kramlich <grim@reaperworld.com>
parents:
39479
diff
changeset
|
3521 | PurpleActionMenu *act; |
| 15884 | 3522 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
3523 | if(! PURPLE_IS_BUDDY(node)) |
| 10977 | 3524 | return l; |
| 3525 | ||
| 3526 | l = g_list_append(l, NULL); | |
| 3527 | ||
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
3528 | act = purple_action_menu_new(_("Invite to Conference..."), |
| 15884 | 3529 | PURPLE_CALLBACK(blist_menu_conf), NULL, NULL); |
| 10977 | 3530 | l = g_list_append(l, act); |
| 3531 | ||
| 15884 | 3532 | /** note: this never gets called for a PurpleGroup, have to use the |
| 10977 | 3533 | blist-node-extended-menu signal for that. The function |
| 3534 | blist_node_menu_cb is assigned to this signal in the function | |
| 3535 | services_starting */ | |
| 3536 | ||
| 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 GList * |
|
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(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 | { |
| 10977 | 3545 | GList *l = NULL; |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3546 | PurpleProtocolChatEntry *pce; |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3547 | |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
3548 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3549 | pce->label = _("Topic:"); |
| 10977 | 3550 | pce->identifier = CHAT_KEY_TOPIC; |
| 3551 | l = g_list_append(l, pce); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3552 | |
| 10977 | 3553 | return l; |
| 3554 | } | |
| 3555 | ||
| 3556 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3557 | static GHashTable * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3558 | 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
|
3559 | PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3560 | const char *name) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
3561 | { |
| 10977 | 3562 | GHashTable *table; |
| 3563 | ||
| 3564 | g_return_val_if_fail(gc != NULL, NULL); | |
| 3565 | ||
| 3566 | table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 3567 | NULL, g_free); | |
| 3568 | ||
| 3569 | g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
| 3570 | g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
| 3571 | ||
| 3572 | return table; | |
| 3573 | } | |
| 3574 | ||
| 3575 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3576 | static void mw_protocol_login(PurpleAccount *acct); |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3577 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3578 | |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3579 | static void mw_protocol_login(PurpleAccount *account) { |
| 15884 | 3580 | PurpleConnection *gc; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3581 | struct mwPurpleProtocolData *pd; |
| 10977 | 3582 | |
| 3583 | char *user, *pass, *host; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3584 | guint port; |
| 10977 | 3585 | |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3586 | GError *error = NULL; |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3587 | |
| 15884 | 3588 | 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
|
3589 | pd = mwPurpleProtocolData_new(gc); |
| 10977 | 3590 | |
| 3591 | /* 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
|
3592 | purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_IMAGES); |
| 15884 | 3593 | |
| 3594 | user = g_strdup(purple_account_get_username(account)); | |
| 10977 | 3595 | |
| 3596 | host = strrchr(user, ':'); | |
| 3597 | if(host) { | |
| 3598 | /* annoying user split from 1.2.0, need to undo it */ | |
| 3599 | *host++ = '\0'; | |
| 15884 | 3600 | purple_account_set_string(account, MW_KEY_HOST, host); |
| 3601 | purple_account_set_username(account, user); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3602 | |
| 10977 | 3603 | } else { |
| 15884 | 3604 | host = (char *) purple_account_get_string(account, MW_KEY_HOST, |
| 10977 | 3605 | MW_PLUGIN_DEFAULT_HOST); |
| 3606 | } | |
| 3607 | ||
| 3608 | if(! host || ! *host) { | |
| 3609 | /* somehow, we don't have a host to connect to. Well, we need one | |
| 3610 | 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
|
3611 | 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
|
3612 | 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
|
3613 | 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
|
3614 | _("A server is required to connect this account")); |
| 10977 | 3615 | return; |
| 3616 | } | |
| 3617 | ||
|
34022
c49f6e9ea27d
Make all the prpls build.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
3618 | pass = g_strdup(purple_connection_get_password(gc)); |
| 15884 | 3619 | port = purple_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
| 10977 | 3620 | |
| 3621 | DEBUG_INFO("user: '%s'\n", user); | |
| 3622 | DEBUG_INFO("host: '%s'\n", host); | |
| 3623 | DEBUG_INFO("port: %u\n", port); | |
| 3624 | ||
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3625 | mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
| 10977 | 3626 | (char *) no_secret, NULL); |
| 3627 | 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
|
3628 | mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
|
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3629 | |
| 15884 | 3630 | 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
|
3631 | guint client, major, minor; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3632 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3633 | /* 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
|
3634 | 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
|
3635 | |
| 15884 | 3636 | client = purple_account_get_int(account, MW_KEY_CLIENT, mwLogin_BINARY); |
| 3637 | 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
|
3638 | 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
|
3639 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3640 | DEBUG_INFO("client id: 0x%04x\n", client); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3641 | DEBUG_INFO("client major: 0x%04x\n", major); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3642 | DEBUG_INFO("client minor: 0x%04x\n", minor); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3643 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3644 | mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3645 | GUINT_TO_POINTER(client), NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3646 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3647 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MAJOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3648 | GUINT_TO_POINTER(major), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3649 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3650 | mwSession_setProperty(pd->session, mwSession_CLIENT_VER_MINOR, |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3651 | GUINT_TO_POINTER(minor), NULL); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3652 | } |
| 10977 | 3653 | |
| 15884 | 3654 | purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3655 | ||
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3656 | 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
|
3657 | if (pd->client == NULL) { |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3658 | purple_connection_take_error(gc, error); |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3659 | return; |
| 10977 | 3660 | } |
|
40620
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3661 | |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3662 | g_socket_client_connect_to_host_async( |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3663 | pd->client, host, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3664 | port, pd->cancellable, |
|
6507c3c9940b
Convert sametime to Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40521
diff
changeset
|
3665 | connect_cb, pd); |
| 10977 | 3666 | } |
| 3667 | ||
| 3668 | ||
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
3669 | 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
|
3670 | struct mwPurpleProtocolData *pd; |
| 10977 | 3671 | |
| 3672 | g_return_if_fail(gc != NULL); | |
| 3673 | ||
|
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
|
3674 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3675 | g_return_if_fail(pd != NULL); |
| 3676 | ||
| 3677 | /* get rid of the blist save timeout */ | |
| 3678 | if(pd->save_event) { | |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
3679 | g_source_remove(pd->save_event); |
| 10977 | 3680 | pd->save_event = 0; |
| 3681 | blist_store(pd); | |
| 3682 | } | |
| 3683 | ||
| 3684 | /* stop the session */ | |
| 3685 | mwSession_stop(pd->session, 0x00); | |
| 3686 | ||
| 3687 | /* 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
|
3688 | purple_connection_set_protocol_data(gc, NULL); |
| 10977 | 3689 | |
| 3690 | /* 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
|
3691 | if(pd->inpa) { |
|
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
3692 | 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
|
3693 | pd->inpa = 0; |
| 10977 | 3694 | } |
| 3695 | ||
| 3696 | /* clean up the rest */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3697 | mwPurpleProtocolData_free(pd); |
| 10977 | 3698 | } |
| 3699 | ||
| 3700 | ||
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3701 | 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
|
3702 | PurpleMessage *msg) |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3703 | { |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3704 | gchar name[1000]; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3705 | struct mwPurpleProtocolData *pd; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3706 | struct mwIdBlock who = { name, NULL }; |
| 10977 | 3707 | struct mwConversation *conv; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3708 | const gchar *message; |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3709 | PurpleMessageFlags flags; |
| 10977 | 3710 | |
| 3711 | 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
|
3712 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3713 | |
| 3714 | g_return_val_if_fail(pd != NULL, 0); | |
| 3715 | ||
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
3716 | 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
|
3717 | message = purple_message_get_contents(msg); |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3718 | flags = purple_message_get_flags(msg); |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
3719 | |
| 10977 | 3720 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 3721 | ||
| 3722 | /* this detection of features to determine how to send the message | |
| 3723 | (plain, html, or mime) is flawed because the other end of the | |
| 3724 | conversation could close their channel at any time, rendering any | |
| 3725 | existing formatting in an outgoing message innapropriate. The end | |
| 3726 | result is that it may be possible that the other side of the | |
| 3727 | conversation will receive a plaintext message with html contents, | |
| 3728 | which is bad. I'm not sure how to fix this correctly. */ | |
| 3729 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3730 | if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
| 15884 | 3731 | flags |= PURPLE_MESSAGE_IMAGES; |
| 10977 | 3732 | |
| 3733 | if(mwConversation_isOpen(conv)) { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3734 | char *tmp; |
| 10977 | 3735 | int ret; |
| 3736 | ||
| 15884 | 3737 | if((flags & PURPLE_MESSAGE_IMAGES) && |
| 10977 | 3738 | mwConversation_supports(conv, mwImSend_MIME)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3739 | /* send a MIME message */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3740 | |
|
39523
415b0705e48b
sametime: Move MIME handling to a separate file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39483
diff
changeset
|
3741 | tmp = im_mime_generate(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3742 | ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3743 | g_free(tmp); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3744 | |
| 10977 | 3745 | } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3746 | /* send an HTML message */ |
| 10977 | 3747 | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3748 | char *ncr; |
| 15884 | 3749 | ncr = purple_utf8_ncr_encode(message); |
| 3750 | tmp = purple_strdup_withhtml(ncr); | |
|
12813
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3751 | g_free(ncr); |
|
6f67cfa0e6a0
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3752 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3753 | ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3754 | g_free(tmp); |
| 10977 | 3755 | |
| 3756 | } else { | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3757 | /* default to text */ |
| 15884 | 3758 | tmp = purple_markup_strip_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12166
diff
changeset
|
3759 | ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3760 | g_free(tmp); |
| 10977 | 3761 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3762 | |
| 10977 | 3763 | return !ret; |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3764 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3765 | } else { |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3766 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3767 | /* queue up the message safely as plain text */ |
| 15884 | 3768 | char *tmp = purple_markup_strip_html(message); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3769 | convo_queue(conv, mwImSend_PLAIN, tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3770 | g_free(tmp); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3771 | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3772 | if(! mwConversation_isPending(conv)) |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3773 | mwConversation_open(conv); |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3774 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3775 | return 1; |
| 10977 | 3776 | } |
| 3777 | } | |
| 3778 | ||
| 3779 | ||
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3780 | static unsigned int mw_protocol_send_typing(PurpleProtocolIM *im, |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
3781 | PurpleConnection *gc, |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3782 | 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
|
3783 | PurpleIMTypingState state) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3784 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3785 | struct mwPurpleProtocolData *pd; |
| 10977 | 3786 | struct mwIdBlock who = { (char *) name, NULL }; |
| 3787 | struct mwConversation *conv; | |
| 3788 | ||
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13779
diff
changeset
|
3789 | gpointer t = GINT_TO_POINTER(!! state); |
| 10977 | 3790 | |
| 3791 | 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
|
3792 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3793 | |
| 3794 | g_return_val_if_fail(pd != NULL, 0); | |
| 3795 | ||
| 3796 | conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
| 3797 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3798 | if(mwConversation_isOpen(conv)) { |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3799 | mwConversation_send(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3800 | |
|
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
|
3801 | } 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
|
3802 | /* only open a channel for sending typing notification, not for |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3803 | 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
|
3804 | 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
|
3805 | |
| 10977 | 3806 | convo_queue(conv, mwImSend_TYPING, t); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3807 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3808 | if(! mwConversation_isPending(conv)) { |
| 10977 | 3809 | mwConversation_open(conv); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3810 | } |
| 10977 | 3811 | } |
| 3812 | ||
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3813 | return 0; |
| 10977 | 3814 | } |
| 3815 | ||
| 3816 | ||
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3817 | static const char *mw_client_name(guint16 type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3818 | switch(type) { |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3819 | case mwLogin_LIB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3820 | return "Lotus Binary Library"; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3821 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3822 | case mwLogin_JAVA_WEB: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3823 | return "Lotus Java Client Applet"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3824 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3825 | case mwLogin_BINARY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3826 | return "Lotus Sametime Connect"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3827 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3828 | case mwLogin_JAVA_APP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3829 | return "Lotus Java Client Application"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3830 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3831 | case mwLogin_LINKS: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3832 | return "Lotus Sametime Links"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3833 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3834 | case mwLogin_NOTES_6_5: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3835 | case mwLogin_NOTES_6_5_3: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3836 | case mwLogin_NOTES_7_0_beta: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3837 | case mwLogin_NOTES_7_0: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3838 | return "Lotus Notes Client"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3839 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3840 | case mwLogin_ICT: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3841 | case mwLogin_ICT_1_7_8_2: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3842 | case mwLogin_ICT_SIP: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3843 | return "IBM Community Tools"; |
|
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_NOTESBUDDY_4_14: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3846 | case mwLogin_NOTESBUDDY_4_15: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3847 | case mwLogin_NOTESBUDDY_4_16: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3848 | return "Alphaworks NotesBuddy"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3849 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3850 | case 0x1305: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3851 | case 0x1306: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3852 | case 0x1307: |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3853 | return "Lotus Sametime Connect 7.5"; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
3854 | |
|
12311
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3855 | case mwLogin_SANITY: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3856 | return "Sanity"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3857 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3858 | case mwLogin_ST_PERL: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3859 | return "ST-Send-Message"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3860 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3861 | case mwLogin_TRILLIAN: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3862 | case mwLogin_TRILLIAN_IBM: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3863 | return "Trillian"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3864 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3865 | case mwLogin_MEANWHILE: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3866 | return "Meanwhile"; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3867 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3868 | default: |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3869 | return NULL; |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3870 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3871 | } |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3872 | |
|
ee0f62f4fcd4
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3873 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3874 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3875 | 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
|
3876 | PurpleConnection *gc, const gchar *who) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3877 | { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3878 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3879 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
3880 | struct mwPurpleProtocolData *pd; |
| 15884 | 3881 | PurpleAccount *acct; |
| 3882 | PurpleBuddy *b; | |
| 3883 | PurpleNotifyUserInfo *user_info; | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3884 | char *tmp; |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3885 | const char *tmp2; |
|
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 | g_return_if_fail(who != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3888 | g_return_if_fail(*who != '\0'); |
| 10977 | 3889 | |
|
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
|
3890 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 3891 | |
| 15884 | 3892 | 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
|
3893 | b = purple_blist_find_buddy(acct, who); |
| 15884 | 3894 | user_info = purple_notify_user_info_new(); |
| 3895 | ||
|
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
|
3896 | 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
|
3897 | 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
|
3898 | 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
|
3899 | } |
| 10977 | 3900 | |
|
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
|
3901 | 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
|
3902 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3903 | if(b) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3904 | guint32 type; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3905 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
3906 | 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
|
3907 | /* 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
|
3908 | 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
|
3909 | 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
|
3910 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3911 | |
| 15884 | 3912 | 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
|
3913 | 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
|
3914 | 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
|
3915 | 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
|
3916 | 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
|
3917 | } else { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3918 | 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
|
3919 | 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
|
3920 | 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
|
3921 | } |
| 10977 | 3922 | } |
| 3923 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3924 | |
| 10977 | 3925 | tmp = user_supports_text(pd->srvc_aware, who); |
| 3926 | 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
|
3927 | 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
|
3928 | g_free(tmp); |
| 10977 | 3929 | } |
| 3930 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3931 | 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
|
3932 | 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
|
3933 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14976
diff
changeset
|
3934 | /* 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
|
3935 | 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
|
3936 | if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
| 15884 | 3937 | 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
|
3938 | 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
|
3939 | } |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3940 | } |
| 10977 | 3941 | |
| 3942 | /* @todo emit a signal to allow a plugin to override the display of | |
| 3943 | this notification, so that it can create its own */ | |
| 3944 | ||
| 15884 | 3945 | purple_notify_userinfo(gc, who, user_info, NULL, NULL); |
| 3946 | purple_notify_user_info_destroy(user_info); | |
| 10977 | 3947 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3948 | |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3949 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3950 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3951 | 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
|
3952 | PurpleAccount *acct, PurpleStatus *status) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
3953 | { |
| 15884 | 3954 | PurpleConnection *gc; |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3955 | const char *state; |
|
11641
554274717c25
[gaim-migrate @ 13918]
Richard Laager <rlaager@pidgin.im>
parents:
11638
diff
changeset
|
3956 | char *message = NULL; |
| 10977 | 3957 | struct mwSession *session; |
| 3958 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3959 | |
| 10977 | 3960 | g_return_if_fail(acct != NULL); |
| 15884 | 3961 | gc = purple_account_get_connection(acct); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3962 | |
| 15884 | 3963 | state = purple_status_get_id(status); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3964 | |
| 15884 | 3965 | 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
|
3966 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3967 | g_return_if_fail(gc != NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3968 | |
| 10977 | 3969 | session = gc_to_session(gc); |
| 3970 | g_return_if_fail(session != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3971 | |
| 10977 | 3972 | /* get a working copy of the current status */ |
| 3973 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3974 | |
| 10977 | 3975 | /* determine the state */ |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3976 | if(purple_strequal(state, MW_STATE_ACTIVE)) { |
| 10977 | 3977 | stat.status = mwStatus_ACTIVE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3978 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3979 | } else if(purple_strequal(state, MW_STATE_AWAY)) { |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3980 | stat.status = mwStatus_AWAY; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3981 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
3982 | } else if(purple_strequal(state, MW_STATE_BUSY)) { |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
3983 | stat.status = mwStatus_BUSY; |
| 10977 | 3984 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3985 | |
| 10977 | 3986 | /* determine the message */ |
| 15884 | 3987 | 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
|
3988 | |
| 10977 | 3989 | if(message) { |
| 3990 | /* all the possible non-NULL values of message up to this point | |
| 3991 | are const, so we don't need to free them */ | |
| 15884 | 3992 | message = purple_markup_strip_html(message); |
| 10977 | 3993 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3994 | |
| 10977 | 3995 | /* out with the old */ |
| 3996 | g_free(stat.desc); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
3997 | |
| 10977 | 3998 | /* in with the new */ |
| 3999 | stat.desc = (char *) message; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4000 | |
| 10977 | 4001 | mwSession_setUserStatus(session, &stat); |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11547
diff
changeset
|
4002 | mwUserStatus_clear(&stat); |
| 10977 | 4003 | } |
| 4004 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4005 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4006 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4007 | 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
|
4008 | PurpleConnection *gc, gint t) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4009 | { |
| 10977 | 4010 | struct mwSession *session; |
| 4011 | struct mwUserStatus stat; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4012 | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4013 | |
| 10977 | 4014 | session = gc_to_session(gc); |
| 4015 | g_return_if_fail(session != NULL); | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4016 | |
| 10977 | 4017 | mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
| 4018 | ||
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4019 | if(t) { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4020 | time_t now = time(NULL); |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4021 | stat.time = now - t; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4022 | |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4023 | } else { |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4024 | stat.time = 0; |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4025 | } |
|
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4026 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4027 | if(t > 0 && stat.status == mwStatus_ACTIVE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4028 | /* we were active and went idle, so change the status to IDLE. */ |
| 10977 | 4029 | stat.status = mwStatus_IDLE; |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4030 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4031 | } else if(t == 0 && stat.status == mwStatus_IDLE) { |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4032 | /* we only become idle automatically, so change back to ACTIVE */ |
| 10977 | 4033 | stat.status = mwStatus_ACTIVE; |
| 4034 | } | |
|
12105
5ab1009c4164
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4035 | |
| 10977 | 4036 | mwSession_setUserStatus(session, &stat); |
| 4037 | mwUserStatus_clear(&stat); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4038 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4039 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4040 | |
| 15884 | 4041 | static void notify_im(PurpleConnection *gc, GList *row, void *user_data) { |
| 4042 | PurpleAccount *acct; | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
4043 | PurpleConversation *im; |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4044 | char *id; |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4045 | |
| 15884 | 4046 | acct = purple_connection_get_account(gc); |
|
12631
b0e5f1ab374e
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4047 | id = g_list_nth_data(row, 1); |
|
34642
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4048 | im = purple_conversations_find_im_with_account(id, acct); |
|
5ef8e33e5bed
Refactored sametime and yahoo protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34631
diff
changeset
|
4049 | if(! im) im = purple_im_conversation_new(acct, id); |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40865
diff
changeset
|
4050 | purple_conversation_present(im); |
| 15884 | 4051 | } |
| 4052 | ||
| 4053 | ||
| 4054 | 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
|
4055 | BuddyAddData *data = user_data; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4056 | const char *group_name = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4057 | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4058 | if (data && data->group) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4059 | group_name = purple_group_get_name(data->group); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4060 | } |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4061 | |
| 15884 | 4062 | 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
|
4063 | g_list_nth_data(row, 1), group_name, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4064 | g_list_nth_data(row, 0)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4065 | } |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4066 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4067 | |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4068 | 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
|
4069 | g_free(data); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4070 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4071 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4072 | |
| 10977 | 4073 | static void multi_resolved_query(struct mwResolveResult *result, |
| 15884 | 4074 | PurpleConnection *gc, gpointer data) { |
| 10977 | 4075 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4076 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4077 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4078 | char *msg; |
| 10977 | 4079 | |
| 15884 | 4080 | PurpleNotifySearchResults *sres; |
| 4081 | PurpleNotifySearchColumn *scol; | |
| 4082 | ||
| 4083 | sres = purple_notify_searchresults_new(); | |
| 4084 | ||
| 4085 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 4086 | purple_notify_searchresults_column_add(sres, scol); | |
| 4087 | ||
| 4088 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 4089 | purple_notify_searchresults_column_add(sres, scol); | |
| 4090 | ||
| 4091 | 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
|
4092 | notify_im); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4093 | |
| 15884 | 4094 | 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
|
4095 | notify_add); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4096 | |
| 10977 | 4097 | for(l = result->matches; l; l = l->next) { |
| 4098 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4099 | GList *row = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4100 | |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4101 | DEBUG_INFO("multi resolve: %s, %s\n", |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
4102 | match->id, match->name); |
|
12524
e9bf565601ad
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4103 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4104 | if(!match->id || !match->name) |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4105 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4106 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4107 | row = g_list_append(row, g_strdup(match->name)); |
|
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4108 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 4109 | purple_notify_searchresults_row_add(sres, row); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4110 | } |
| 10977 | 4111 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4112 | msgA = _("An ambiguous user ID was entered"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4113 | 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
|
4114 | " 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
|
4115 | " add them to your buddy list."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4116 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4117 | |
| 15884 | 4118 | purple_notify_searchresults(gc, _("Select User"), |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4119 | msgA, msg, sres, notify_close, data); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4120 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4121 | g_free(msg); |
| 10977 | 4122 | } |
| 4123 | ||
| 4124 | ||
| 4125 | static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
| 4126 | guint32 id, guint32 code, GList *results, | |
| 4127 | gpointer b) { | |
| 4128 | ||
| 4129 | struct mwResolveResult *res = NULL; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4130 | BuddyAddData *data = b; |
| 15884 | 4131 | PurpleBuddy *buddy = NULL; |
| 4132 | PurpleConnection *gc; | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4133 | struct mwPurpleProtocolData *pd; |
| 10977 | 4134 | |
|
16121
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4135 | g_return_if_fail(data != NULL); |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4136 | |
|
e5ad074a5f05
Avoid a possible NULL pointer dereference
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
4137 | buddy = data->buddy; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4138 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4139 | 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
|
4140 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4141 | |
| 4142 | if(results) | |
| 4143 | res = results->data; | |
| 4144 | ||
| 4145 | 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
|
4146 | if(!res->matches->next) { |
| 10977 | 4147 | struct mwResolveMatch *match = res->matches->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4148 | |
| 10977 | 4149 | /* only one? that might be the right one! */ |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4150 | if(!purple_strequal(res->name, match->id)) { |
| 10977 | 4151 | /* uh oh, the single result isn't identical to the search |
| 4152 | term, better safe then sorry, so let's make sure it's who | |
| 4153 | the user meant to add */ | |
| 15884 | 4154 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4155 | multi_resolved_query(res, gc, data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4156 | |
| 10977 | 4157 | } else { |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4158 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4159 | /* 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
|
4160 | purple_buddy_set_server_alias(buddy, match->name); |
| 15884 | 4161 | purple_blist_node_set_string((PurpleBlistNode *) buddy, |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4162 | BUDDY_KEY_NAME, match->name); |
|
12829
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4163 | |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4164 | /* subscribe to awareness */ |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4165 | buddy_add(pd, buddy); |
|
c7c8fa0b90db
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4166 | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4167 | blist_schedule(pd); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4168 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4169 | g_free(data); |
| 10977 | 4170 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4171 | |
| 10977 | 4172 | } else { |
| 4173 | /* prompt user if more than one match was returned */ | |
| 15884 | 4174 | purple_blist_remove_buddy(buddy); |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4175 | multi_resolved_query(res, gc, data); |
| 10977 | 4176 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4177 | |
| 10977 | 4178 | return; |
| 4179 | } | |
| 4180 | } | |
| 4181 | ||
| 4182 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4183 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4184 | 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
|
4185 | PurpleConnection *gc, PurpleBuddy *buddy, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4186 | PurpleGroup *group, const gchar *message) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4187 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4188 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4189 | struct mwServiceResolve *srvc; |
| 4190 | GList *query; | |
| 4191 | enum mwResolveFlag flags; | |
| 4192 | guint32 req; | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4193 | BuddyAddData *data; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4194 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4195 | /* 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
|
4196 | if(buddy_is_external(buddy)) { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4197 | buddy_add(pd, buddy); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4198 | return; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4199 | } |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4200 | |
|
24591
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4201 | data = g_new0(BuddyAddData, 1); |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4202 | data->buddy = buddy; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4203 | data->group = group; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4204 | |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4205 | srvc = pd->srvc_resolve; |
|
15f01d981a40
Fix a potential leak, thanks to "KuSh". Fixes #7464.
Daniel Atallah <datallah@pidgin.im>
parents:
23979
diff
changeset
|
4206 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4207 | query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
| 10977 | 4208 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 4209 | ||
| 4210 | req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4211 | data, NULL); |
| 10977 | 4212 | g_list_free(query); |
| 4213 | ||
| 4214 | if(req == SEARCH_ERROR) { | |
| 15884 | 4215 | purple_blist_remove_buddy(buddy); |
| 10977 | 4216 | blist_schedule(pd); |
| 4217 | } | |
| 4218 | } | |
| 4219 | ||
| 4220 | ||
| 15884 | 4221 | 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
|
4222 | struct mwPurpleProtocolData *pd) { |
| 10977 | 4223 | struct mwAwareList *list; |
| 4224 | ||
| 4225 | list = list_ensure(pd, group); | |
| 4226 | mwAwareList_addAware(list, buddies); | |
| 4227 | g_list_free(buddies); | |
| 4228 | } | |
| 4229 | ||
| 4230 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4231 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4232 | 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
|
4233 | PurpleConnection *gc, |
| 10977 | 4234 | GList *buddies, |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4235 | GList *groups, |
|
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32279
diff
changeset
|
4236 | const char *message) { |
| 10977 | 4237 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4238 | struct mwPurpleProtocolData *pd; |
| 10977 | 4239 | GHashTable *group_sets; |
| 4240 | struct mwAwareIdBlock *idbs, *idb; | |
| 4241 | ||
|
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
|
4242 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4243 | |
| 15884 | 4244 | /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 10977 | 4245 | group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4246 | ||
| 4247 | /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
| 4248 | idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
| 4249 | ||
| 4250 | /* first pass collects mwAwareIdBlock lists for each group */ | |
| 4251 | for(; buddies; buddies = buddies->next) { | |
| 15884 | 4252 | PurpleBuddy *b = buddies->data; |
| 4253 | PurpleGroup *g; | |
| 10977 | 4254 | const char *fn; |
| 4255 | GList *l; | |
| 4256 | ||
| 4257 | /* nab the saved server alias and stick it on the buddy */ | |
| 15884 | 4258 | 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
|
4259 | purple_buddy_set_server_alias(b, fn); |
| 15884 | 4260 | |
| 4261 | /* convert PurpleBuddy into a mwAwareIdBlock */ | |
| 10977 | 4262 | idb->type = mwAware_USER; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4263 | idb->user = (char *) purple_buddy_get_name(b); |
| 10977 | 4264 | idb->community = NULL; |
| 4265 | ||
| 4266 | /* put idb into the list associated with the buddy's group */ | |
| 15884 | 4267 | g = purple_buddy_get_group(b); |
| 10977 | 4268 | l = g_hash_table_lookup(group_sets, g); |
| 4269 | l = g_list_prepend(l, idb++); | |
| 4270 | g_hash_table_insert(group_sets, g, l); | |
| 4271 | } | |
| 4272 | ||
| 4273 | /* each group's buddies get added in one shot, and schedule the blist | |
| 4274 | for saving */ | |
| 4275 | g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
| 4276 | blist_schedule(pd); | |
| 4277 | ||
| 4278 | /* cleanup */ | |
| 4279 | g_hash_table_destroy(group_sets); | |
| 4280 | g_free(idbs); | |
| 4281 | } | |
| 4282 | ||
| 4283 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4284 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4285 | 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
|
4286 | PurpleConnection *gc, PurpleBuddy *buddy, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4287 | PurpleGroup *group) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4288 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4289 | struct mwPurpleProtocolData *pd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23979
diff
changeset
|
4290 | struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 10977 | 4291 | struct mwAwareList *list; |
| 4292 | ||
| 4293 | GList *rem = g_list_prepend(NULL, &idb); | |
| 4294 | ||
|
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
|
4295 | pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4296 | group = purple_buddy_get_group(buddy); |
| 10977 | 4297 | list = list_ensure(pd, group); |
| 4298 | ||
| 4299 | mwAwareList_removeAware(list, rem); | |
| 4300 | blist_schedule(pd); | |
| 4301 | ||
| 4302 | g_list_free(rem); | |
| 4303 | } | |
| 4304 | ||
| 4305 | ||
| 4306 | static void privacy_fill(struct mwPrivacyInfo *priv, | |
| 4307 | GSList *members) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4308 | |
| 10977 | 4309 | struct mwUserItem *u; |
| 4310 | guint count; | |
| 4311 | ||
| 4312 | count = g_slist_length(members); | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4313 | DEBUG_INFO("privacy_fill: %u members\n", count); |
| 10977 | 4314 | |
| 4315 | priv->count = count; | |
| 4316 | priv->users = g_new0(struct mwUserItem, count); | |
| 4317 | ||
| 4318 | while(count--) { | |
| 4319 | u = priv->users + count; | |
| 4320 | u->id = members->data; | |
| 4321 | members = members->next; | |
| 4322 | } | |
| 4323 | } | |
| 4324 | ||
| 4325 | ||
|
40521
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4326 | 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
|
4327 | 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
|
4328 | { |
| 15884 | 4329 | PurpleAccount *acct; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4330 | struct mwPurpleProtocolData *pd; |
| 10977 | 4331 | struct mwSession *session; |
| 4332 | ||
| 4333 | struct mwPrivacyInfo privacy = { | |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4334 | FALSE, /* deny */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4335 | 0, /* count */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16545
diff
changeset
|
4336 | NULL, /* users */ |
| 10977 | 4337 | }; |
| 4338 | ||
| 4339 | g_return_if_fail(gc != NULL); | |
| 4340 | ||
| 15884 | 4341 | acct = purple_connection_get_account(gc); |
| 10977 | 4342 | g_return_if_fail(acct != NULL); |
| 4343 | ||
|
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
|
4344 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4345 | g_return_if_fail(pd != NULL); |
| 4346 | ||
| 4347 | session = pd->session; | |
| 4348 | g_return_if_fail(session != NULL); | |
| 4349 | ||
|
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
|
4350 | 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
|
4351 | case PURPLE_ACCOUNT_PRIVACY_DENY_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_DENY_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_denied(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4354 | privacy.deny = TRUE; |
|
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_ALLOW_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_ALLOW_ALL\n"); |
| 10977 | 4359 | privacy.deny = TRUE; |
| 4360 | break; | |
| 4361 | ||
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4362 | case PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4363 | 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
|
4364 | privacy_fill(&privacy, purple_account_privacy_get_permitted(acct)); |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4365 | privacy.deny = FALSE; |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4366 | break; |
| 10977 | 4367 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4368 | case PURPLE_ACCOUNT_PRIVACY_DENY_ALL: |
|
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34570
diff
changeset
|
4369 | DEBUG_INFO("PURPLE_ACCOUNT_PRIVACY_DENY_ALL\n"); |
| 10977 | 4370 | privacy.deny = FALSE; |
| 4371 | break; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4372 | |
| 10977 | 4373 | 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
|
4374 | 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
|
4375 | return; |
| 10977 | 4376 | } |
| 4377 | ||
| 4378 | mwSession_setPrivacyInfo(session, &privacy); | |
| 4379 | g_free(privacy.users); | |
| 4380 | } | |
| 4381 | ||
| 4382 | ||
|
40521
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4383 | 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
|
4384 | 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
|
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 | 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
|
4387 | } |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4388 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4389 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4390 | 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
|
4391 | 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
|
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 | 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
|
4394 | } |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4395 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4396 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4397 | 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
|
4398 | 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
|
4399 | { |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4400 | 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
|
4401 | } |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4402 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4403 | |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4404 | 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
|
4405 | 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
|
4406 | { |
|
c4269b37a13a
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
4407 | mw_protocol_set_permit_deny(privacy, gc); |
| 10977 | 4408 | } |
| 4409 | ||
| 4410 | ||
| 4411 | static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
| 4412 | const char *name) { | |
| 4413 | GList *l, *ll; | |
| 4414 | struct mwConference *conf = NULL; | |
| 4415 | ||
| 4416 | ll = mwServiceConference_getConferences(srvc); | |
| 4417 | for(l = ll; l; l = l->next) { | |
| 4418 | struct mwConference *c = l->data; | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
4419 | if(purple_strequal(name, mwConference_getName(c))) { |
| 10977 | 4420 | conf = c; |
| 4421 | break; | |
| 4422 | } | |
| 4423 | } | |
| 4424 | g_list_free(ll); | |
| 4425 | ||
| 4426 | return conf; | |
| 4427 | } | |
| 4428 | ||
| 4429 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4430 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4431 | 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
|
4432 | GHashTable *components) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4433 | { |
| 10977 | 4434 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4435 | struct mwPurpleProtocolData *pd; |
| 10977 | 4436 | char *c, *t; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4437 | |
|
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
|
4438 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4439 | |
| 4440 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
| 4441 | t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4442 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4443 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4444 | /* use place service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4445 | struct mwServicePlace *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4446 | struct mwPlace *place = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4447 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4448 | srvc = pd->srvc_place; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4449 | place = mwPlace_new(srvc, c, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4450 | mwPlace_open(place); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4451 | |
| 10977 | 4452 | } else { |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4453 | /* use conference service */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4454 | struct mwServiceConference *srvc; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4455 | struct mwConference *conf = NULL; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4456 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4457 | srvc = pd->srvc_conf; |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4458 | if(c) conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4459 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4460 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4461 | DEBUG_INFO("accepting conference invitation\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4462 | mwConference_accept(conf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4463 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4464 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4465 | DEBUG_INFO("creating new conference\n"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4466 | conf = mwConference_new(srvc, t); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4467 | mwConference_open(conf); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4468 | } |
| 10977 | 4469 | } |
| 4470 | } | |
| 4471 | ||
| 4472 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4473 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4474 | 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
|
4475 | PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4476 | GHashTable *components) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4477 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4478 | struct mwPurpleProtocolData *pd; |
| 10977 | 4479 | struct mwServiceConference *srvc; |
| 4480 | char *c; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4481 | |
|
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
|
4482 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4483 | srvc = pd->srvc_conf; |
| 4484 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4485 | if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4486 | ; /* nothing needs doing */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4487 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4488 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4489 | /* reject conference */ |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4490 | c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4491 | if(c) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4492 | struct mwConference *conf = conf_find(srvc, c); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4493 | if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4494 | } |
| 10977 | 4495 | } |
| 4496 | } | |
| 4497 | ||
| 4498 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4499 | static char * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4500 | 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
|
4501 | GHashTable *components) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4502 | { |
| 10977 | 4503 | return g_hash_table_lookup(components, CHAT_KEY_NAME); |
| 4504 | } | |
| 4505 | ||
| 4506 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4507 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4508 | 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
|
4509 | 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
|
4510 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4511 | struct mwPurpleProtocolData *pd; |
| 10977 | 4512 | struct mwConference *conf; |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4513 | struct mwPlace *place; |
| 10977 | 4514 | struct mwIdBlock idb = { (char *) who, NULL }; |
| 4515 | ||
|
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
|
4516 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4517 | g_return_if_fail(pd != NULL); |
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4518 | |
| 10977 | 4519 | conf = ID_TO_CONF(pd, id); |
| 4520 | ||
|
12107
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4521 | if(conf) { |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4522 | mwConference_invite(conf, &idb, invitation); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4523 | return; |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4524 | } |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4525 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4526 | place = ID_TO_PLACE(pd, id); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4527 | g_return_if_fail(place != NULL); |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4528 | |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4529 | /* @todo: use the IM service for invitation */ |
|
f14b83c0df1e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4530 | mwPlace_legacyInvite(place, &idb, invitation); |
| 10977 | 4531 | } |
| 4532 | ||
| 4533 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4534 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4535 | 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
|
4536 | int id) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4537 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4538 | struct mwPurpleProtocolData *pd; |
| 10977 | 4539 | struct mwConference *conf; |
| 4540 | ||
|
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
|
4541 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4542 | |
| 4543 | g_return_if_fail(pd != NULL); | |
| 4544 | conf = ID_TO_CONF(pd, id); | |
| 4545 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4546 | if(conf) { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4547 | mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4548 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4549 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4550 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4551 | g_return_if_fail(place != NULL); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4552 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4553 | mwPlace_destroy(place, ERR_SUCCESS); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4554 | } |
| 10977 | 4555 | } |
| 4556 | ||
| 4557 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4558 | static int |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
4559 | 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
|
4560 | int id, PurpleMessage *pmsg) |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
4561 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4562 | struct mwPurpleProtocolData *pd; |
| 10977 | 4563 | struct mwConference *conf; |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4564 | char *msg; |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4565 | int ret; |
| 10977 | 4566 | |
|
32279
7370dfe843d0
Convert sametime prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
4567 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4568 | |
| 4569 | g_return_val_if_fail(pd != NULL, 0); | |
| 4570 | conf = ID_TO_CONF(pd, id); | |
| 4571 | ||
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
4572 | 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
|
4573 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4574 | if(conf) { |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4575 | ret = ! mwConference_sendText(conf, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4576 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4577 | } else { |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4578 | struct mwPlace *place = ID_TO_PLACE(pd, id); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4579 | g_return_val_if_fail(place != NULL, 0); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4580 | |
|
15772
8e23d860430a
sf patch #1655707, from David Everly
Mark Doliner <markdoliner@pidgin.im>
parents:
15524
diff
changeset
|
4581 | ret = ! mwPlace_sendText(place, msg); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4582 | } |
|
14975
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4583 | |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4584 | g_free(msg); |
|
b177e7cbc8d8
[gaim-migrate @ 17685]
Christopher O'Brien <siege@pidgin.im>
parents:
14899
diff
changeset
|
4585 | return ret; |
| 10977 | 4586 | } |
| 4587 | ||
| 4588 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4589 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4590 | mw_protocol_keepalive(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4591 | PurpleConnection *gc) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4592 | { |
| 10977 | 4593 | struct mwSession *session; |
| 4594 | ||
| 4595 | g_return_if_fail(gc != NULL); | |
| 4596 | ||
| 4597 | session = gc_to_session(gc); | |
| 4598 | g_return_if_fail(session != NULL); | |
| 4599 | ||
| 4600 | mwSession_sendKeepalive(session); | |
| 4601 | } | |
| 4602 | ||
| 4603 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4604 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4605 | 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
|
4606 | PurpleConnection *gc, const gchar *who, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4607 | const gchar *alias) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4608 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4609 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4610 | g_return_if_fail(pd != NULL); |
| 4611 | ||
| 4612 | /* it's a change to the buddy list, so we've gotta reflect that in | |
| 4613 | the server copy */ | |
| 4614 | ||
| 4615 | blist_schedule(pd); | |
| 4616 | } | |
| 4617 | ||
| 4618 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4619 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4620 | 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
|
4621 | PurpleConnection *gc, const gchar *who, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4622 | 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
|
4623 | { |
| 10977 | 4624 | struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
| 4625 | GList *gl = g_list_prepend(NULL, &idb); | |
| 4626 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4627 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 15884 | 4628 | PurpleGroup *group; |
| 10977 | 4629 | struct mwAwareList *list; |
| 4630 | ||
| 4631 | /* 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
|
4632 | group = purple_blist_find_group(new_group); |
| 10977 | 4633 | list = list_ensure(pd, group); |
| 4634 | mwAwareList_addAware(list, gl); | |
| 4635 | ||
| 4636 | /* 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
|
4637 | group = purple_blist_find_group(old_group); |
| 10977 | 4638 | list = list_ensure(pd, group); |
| 4639 | mwAwareList_removeAware(list, gl); | |
| 4640 | ||
| 4641 | g_list_free(gl); | |
| 4642 | ||
| 4643 | /* schedule the changes to be saved */ | |
| 4644 | blist_schedule(pd); | |
| 4645 | } | |
| 4646 | ||
| 4647 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4648 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4649 | 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
|
4650 | PurpleConnection *gc, const gchar *old, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4651 | PurpleGroup *group, GList *buddies) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4652 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4653 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4654 | g_return_if_fail(pd != NULL); |
| 4655 | ||
| 4656 | /* it's a change in the buddy list, so we've gotta reflect that in | |
| 4657 | the server copy. Also, having this function should prevent all | |
| 4658 | those buddies from being removed and re-added. We don't really | |
| 15884 | 4659 | give a crap what the group is named in Purple other than to record |
| 10977 | 4660 | that as the group name/alias */ |
| 4661 | ||
| 4662 | blist_schedule(pd); | |
| 4663 | } | |
| 4664 | ||
| 4665 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4666 | static void |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4667 | mw_protocol_buddy_free(PurpleProtocolClient *client, PurpleBuddy *buddy) { |
| 10977 | 4668 | /* I don't think we have any cleanup for buddies yet */ |
| 4669 | ; | |
| 4670 | } | |
| 4671 | ||
| 4672 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4673 | static void |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4674 | 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
|
4675 | 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
|
4676 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4677 | struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4678 | struct mwServiceIm *srvc; |
| 4679 | struct mwConversation *conv; | |
| 4680 | struct mwIdBlock idb = { (char *) who, NULL }; | |
| 4681 | ||
| 4682 | g_return_if_fail(pd != NULL); | |
| 4683 | ||
| 4684 | srvc = pd->srvc_im; | |
| 4685 | g_return_if_fail(srvc != NULL); | |
| 4686 | ||
| 4687 | conv = mwServiceIm_findConversation(srvc, &idb); | |
| 4688 | if(! conv) return; | |
| 4689 | ||
| 4690 | if(mwConversation_isOpen(conv)) | |
| 4691 | mwConversation_free(conv); | |
| 4692 | } | |
| 4693 | ||
| 4694 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
4695 | 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
|
4696 | 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
|
4697 | 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
|
4698 | { |
| 10977 | 4699 | |
| 4700 | /* code elsewhere assumes that the return value points to different | |
| 4701 | memory than the passed value, but it won't free the normalized | |
| 4702 | data. wtf? */ | |
| 4703 | ||
| 4704 | 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
|
4705 | g_strlcpy(buf, id, sizeof(buf)); |
| 10977 | 4706 | return buf; |
| 4707 | } | |
| 4708 | ||
| 4709 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4710 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4711 | 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
|
4712 | PurpleConnection *gc, PurpleGroup *group) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
4713 | { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4714 | struct mwPurpleProtocolData *pd; |
| 10977 | 4715 | struct mwAwareList *list; |
| 4716 | ||
|
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
|
4717 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4718 | g_return_if_fail(pd != NULL); |
| 4719 | g_return_if_fail(pd->group_list_map != NULL); | |
| 4720 | ||
| 4721 | list = g_hash_table_lookup(pd->group_list_map, group); | |
| 4722 | ||
| 4723 | if(list) { | |
| 4724 | g_hash_table_remove(pd->group_list_map, list); | |
| 4725 | g_hash_table_remove(pd->group_list_map, group); | |
| 4726 | mwAwareList_free(list); | |
| 4727 | ||
| 4728 | blist_schedule(pd); | |
| 4729 | } | |
| 4730 | } | |
| 4731 | ||
| 4732 | ||
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4733 | 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
|
4734 | PurpleConnection *gc, |
| 10977 | 4735 | const char *who) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4736 | struct mwPurpleProtocolData *pd; |
| 10977 | 4737 | struct mwServiceAware *srvc; |
| 15884 | 4738 | PurpleAccount *acct; |
| 10977 | 4739 | |
| 4740 | g_return_val_if_fail(gc != NULL, FALSE); | |
| 4741 | ||
|
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
|
4742 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 4743 | g_return_val_if_fail(pd != NULL, FALSE); |
| 4744 | ||
| 4745 | srvc = pd->srvc_aware; | |
| 4746 | g_return_val_if_fail(srvc != NULL, FALSE); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4747 | |
| 15884 | 4748 | acct = purple_connection_get_account(gc); |
| 10977 | 4749 | g_return_val_if_fail(acct != NULL, FALSE); |
| 4750 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4751 | return purple_blist_find_buddy(acct, who) && |
| 10977 | 4752 | user_supports(srvc, who, mwAttribute_FILE_TRANSFER); |
| 4753 | } | |
| 4754 | ||
| 4755 | ||
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4756 | 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
|
4757 | PurpleConnection *gc, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4758 | const char *who, const char *file) { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4759 | |
|
38841
518362268798
make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents:
38839
diff
changeset
|
4760 | PurpleXfer *xfer = mw_protocol_new_xfer(prplxfer, gc, who); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12135
diff
changeset
|
4761 | |
| 10977 | 4762 | if(file) { |
| 4763 | DEBUG_INFO("file != NULL\n"); | |
| 15884 | 4764 | purple_xfer_request_accepted(xfer, file); |
| 10977 | 4765 | |
| 4766 | } else { | |
| 4767 | DEBUG_INFO("file == NULL\n"); | |
| 15884 | 4768 | purple_xfer_request(xfer); |
| 10977 | 4769 | } |
| 4770 | } | |
| 4771 | ||
| 4772 | ||
| 15884 | 4773 | static void st_import_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 4774 | struct mwSametimeList *l; |
| 4775 | ||
| 4776 | FILE *file; | |
| 4777 | char buf[BUF_LEN]; | |
| 4778 | size_t len; | |
| 4779 | ||
| 4780 | GString *str; | |
| 4781 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
4782 | file = g_fopen(filename, "r"); |
| 10977 | 4783 | g_return_if_fail(file != NULL); |
| 4784 | ||
| 4785 | str = g_string_new(NULL); | |
| 4786 | while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
| 4787 | g_string_append_len(str, buf, len); | |
| 4788 | } | |
| 4789 | ||
| 4790 | fclose(file); | |
| 4791 | ||
| 4792 | l = mwSametimeList_load(str->str); | |
| 4793 | g_string_free(str, TRUE); | |
| 4794 | ||
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4795 | blist_merge(gc, l); |
| 10977 | 4796 | mwSametimeList_free(l); |
| 4797 | } | |
| 4798 | ||
| 4799 | ||
| 4800 | /** prompts for a file to import blist from */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4801 | static void st_import_action(PurpleProtocolAction *act) { |
| 15884 | 4802 | PurpleConnection *gc; |
| 4803 | PurpleAccount *account; | |
| 10977 | 4804 | char *title; |
| 4805 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4806 | gc = act->connection; |
| 15884 | 4807 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4808 | title = g_strdup_printf(_("Import Sametime List for Account %s"), |
| 15884 | 4809 | purple_account_get_username(account)); |
| 4810 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4811 | purple_request_file(gc, title, NULL, FALSE, |
| 10977 | 4812 | 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
|
4813 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4814 | gc); |
| 10977 | 4815 | |
| 4816 | g_free(title); | |
| 4817 | } | |
| 4818 | ||
| 4819 | ||
| 15884 | 4820 | static void st_export_action_cb(PurpleConnection *gc, char *filename) { |
| 10977 | 4821 | struct mwSametimeList *l; |
| 4822 | char *str; | |
| 4823 | FILE *file; | |
| 4824 | ||
|
13158
3b4295931fd6
[gaim-migrate @ 15520]
Richard Laager <rlaager@pidgin.im>
parents:
13107
diff
changeset
|
4825 | file = g_fopen(filename, "w"); |
| 10977 | 4826 | g_return_if_fail(file != NULL); |
| 4827 | ||
| 4828 | l = mwSametimeList_new(); | |
| 4829 | blist_export(gc, l); | |
| 4830 | str = mwSametimeList_store(l); | |
| 4831 | mwSametimeList_free(l); | |
| 4832 | ||
| 4833 | fprintf(file, "%s", str); | |
| 4834 | fclose(file); | |
| 4835 | ||
| 4836 | g_free(str); | |
| 4837 | } | |
| 4838 | ||
| 4839 | ||
| 4840 | /** prompts for a file to export blist to */ | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4841 | static void st_export_action(PurpleProtocolAction *act) { |
| 15884 | 4842 | PurpleConnection *gc; |
| 4843 | PurpleAccount *account; | |
| 10977 | 4844 | char *title; |
| 4845 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4846 | gc = act->connection; |
| 15884 | 4847 | account = purple_connection_get_account(gc); |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4848 | title = g_strdup_printf(_("Export Sametime List for Account %s"), |
| 15884 | 4849 | purple_account_get_username(account)); |
| 4850 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4851 | purple_request_file(gc, title, NULL, TRUE, |
| 10977 | 4852 | 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
|
4853 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4854 | gc); |
| 10977 | 4855 | |
| 4856 | g_free(title); | |
| 4857 | } | |
| 4858 | ||
| 4859 | ||
| 4860 | static void remote_group_multi_cleanup(gpointer ignore, | |
| 15884 | 4861 | PurpleRequestFields *fields) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4862 | |
| 15884 | 4863 | 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
|
4864 | GList *l; |
| 10977 | 4865 | |
| 15884 | 4866 | f = purple_request_fields_get_field(fields, "group"); |
| 4867 | l = purple_request_field_list_get_items(f); | |
| 10977 | 4868 | |
| 4869 | for(; l; l = l->next) { | |
| 4870 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4871 | struct named_id *res; |
| 10977 | 4872 | |
| 15884 | 4873 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 4874 | |
| 4875 | g_free(res->id); | |
| 4876 | g_free(res->name); | |
| 4877 | g_free(res); | |
| 4878 | } | |
| 4879 | } | |
| 4880 | ||
| 4881 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4882 | static void remote_group_done(struct mwPurpleProtocolData *pd, |
| 10977 | 4883 | const char *id, const char *name) { |
| 15884 | 4884 | PurpleConnection *gc; |
| 4885 | PurpleAccount *acct; | |
| 4886 | PurpleGroup *group; | |
| 4887 | PurpleBlistNode *gn; | |
| 10977 | 4888 | const char *owner; |
| 4889 | ||
| 4890 | g_return_if_fail(pd != NULL); | |
| 4891 | ||
| 4892 | gc = pd->gc; | |
| 15884 | 4893 | acct = purple_connection_get_account(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
4894 | |
| 10977 | 4895 | /* collision checking */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34726
diff
changeset
|
4896 | group = purple_blist_find_group(name); |
| 10977 | 4897 | if(group) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4898 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4899 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4900 | char *msg; |
| 10977 | 4901 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4902 | msgA = _("Unable to add group: group exists"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4903 | 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
|
4904 | msg = g_strdup_printf(msgB, name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4905 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
4906 | 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
|
4907 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4908 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4909 | g_free(msg); |
| 10977 | 4910 | return; |
| 4911 | } | |
| 4912 | ||
| 15884 | 4913 | group = purple_group_new(name); |
| 4914 | gn = (PurpleBlistNode *) group; | |
| 4915 | ||
| 4916 | owner = purple_account_get_username(acct); | |
| 4917 | ||
| 4918 | purple_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
| 4919 | purple_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
| 4920 | purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
| 4921 | purple_blist_add_group(group, NULL); | |
| 10977 | 4922 | |
| 4923 | group_add(pd, group); | |
| 4924 | blist_schedule(pd); | |
| 4925 | } | |
| 4926 | ||
| 4927 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
4928 | static void remote_group_multi_cb(struct mwPurpleProtocolData *pd, |
| 15884 | 4929 | PurpleRequestFields *fields) { |
| 4930 | 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
|
4931 | GList *l; |
| 10977 | 4932 | |
| 15884 | 4933 | f = purple_request_fields_get_field(fields, "group"); |
| 4934 | l = purple_request_field_list_get_selected(f); | |
| 10977 | 4935 | |
| 4936 | if(l) { | |
| 4937 | const char *i = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4938 | struct named_id *res; |
| 10977 | 4939 | |
| 15884 | 4940 | res = purple_request_field_list_get_data(f, i); |
| 10977 | 4941 | remote_group_done(pd, res->id, res->name); |
| 4942 | } | |
| 4943 | ||
| 4944 | remote_group_multi_cleanup(NULL, fields); | |
| 4945 | } | |
| 4946 | ||
| 4947 | ||
| 4948 | 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
|
4949 | struct mwPurpleProtocolData *pd) { |
| 15884 | 4950 | |
| 4951 | PurpleRequestFields *fields; | |
| 4952 | PurpleRequestFieldGroup *g; | |
| 4953 | PurpleRequestField *f; | |
| 10977 | 4954 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4955 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4956 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4957 | char *msg; |
| 10977 | 4958 | |
| 15884 | 4959 | PurpleConnection *gc = pd->gc; |
| 4960 | ||
| 4961 | fields = purple_request_fields_new(); | |
| 4962 | ||
| 4963 | g = purple_request_field_group_new(NULL); | |
| 4964 | purple_request_fields_add_group(fields, g); | |
| 4965 | ||
| 4966 | f = purple_request_field_list_new("group", _("Possible Matches")); | |
| 4967 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 4968 | purple_request_field_set_required(f, TRUE); | |
| 10977 | 4969 | |
| 4970 | for(l = result->matches; l; l = l->next) { | |
| 4971 | struct mwResolveMatch *match = l->data; | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4972 | struct named_id *res = g_new0(struct named_id, 1); |
| 10977 | 4973 | |
| 4974 | res->id = g_strdup(match->id); | |
| 4975 | res->name = g_strdup(match->name); | |
| 4976 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
24591
diff
changeset
|
4977 | purple_request_field_list_add_icon(f, res->name, NULL, res); |
| 10977 | 4978 | } |
| 4979 | ||
| 15884 | 4980 | purple_request_field_group_add_field(g, f); |
| 10977 | 4981 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4982 | msgA = _("Notes Address Book group results"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4983 | msgB = _("The identifier '%s' may possibly refer to any of the following" |
| 10977 | 4984 | " Notes Address Book groups. Please select the correct group from" |
| 4985 | " the list below to add it to your buddy list."); | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4986 | msg = g_strdup_printf(msgB, result->name); |
| 10977 | 4987 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4988 | purple_request_fields(gc, _("Select Notes Address Book"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4989 | msgA, msg, fields, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4990 | _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4991 | _("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
|
4992 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
4993 | pd); |
| 10977 | 4994 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
4995 | g_free(msg); |
| 10977 | 4996 | } |
| 4997 | ||
| 4998 | ||
| 4999 | static void remote_group_resolved(struct mwServiceResolve *srvc, | |
| 5000 | guint32 id, guint32 code, GList *results, | |
| 5001 | gpointer b) { | |
|
11133
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5002 | |
|
9418ce240eca
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5003 | struct mwResolveResult *res = NULL; |
| 10977 | 5004 | struct mwSession *session; |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5005 | struct mwPurpleProtocolData *pd; |
| 15884 | 5006 | PurpleConnection *gc; |
| 10977 | 5007 | |
| 5008 | session = mwService_getSession(MW_SERVICE(srvc)); | |
| 5009 | g_return_if_fail(session != NULL); | |
| 5010 | ||
| 5011 | pd = mwSession_getClientData(session); | |
| 5012 | g_return_if_fail(pd != NULL); | |
| 5013 | ||
| 5014 | gc = pd->gc; | |
| 5015 | g_return_if_fail(gc != NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5016 | |
| 10977 | 5017 | if(!code && results) { |
| 5018 | res = results->data; | |
| 5019 | ||
| 5020 | if(res->matches) { | |
| 5021 | remote_group_multi(res, pd); | |
| 5022 | return; | |
| 5023 | } | |
| 5024 | } | |
| 5025 | ||
| 5026 | if(res && res->name) { | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5027 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5028 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5029 | char *msg; |
| 10977 | 5030 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5031 | msgA = _("Unable to add group: group not found"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5032 | |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5033 | msgB = _("The identifier '%s' did not match any Notes Address Book" |
| 10977 | 5034 | " groups in your Sametime community."); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5035 | msg = g_strdup_printf(msgB, res->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5036 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5037 | 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
|
5038 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5039 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5040 | g_free(msg); |
| 10977 | 5041 | } |
| 5042 | } | |
| 5043 | ||
| 5044 | ||
| 15884 | 5045 | 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
|
5046 | struct mwPurpleProtocolData *pd; |
| 10977 | 5047 | struct mwServiceResolve *srvc; |
| 5048 | GList *query; | |
| 5049 | enum mwResolveFlag flags; | |
| 5050 | guint32 req; | |
| 5051 | ||
|
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
|
5052 | pd = purple_connection_get_protocol_data(gc); |
| 10977 | 5053 | srvc = pd->srvc_resolve; |
| 5054 | ||
| 5055 | query = g_list_prepend(NULL, (char *) name); | |
| 5056 | flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5057 | |
| 10977 | 5058 | req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, |
| 5059 | NULL, NULL); | |
| 5060 | g_list_free(query); | |
| 5061 | ||
| 5062 | if(req == SEARCH_ERROR) { | |
| 5063 | /** @todo display error */ | |
| 5064 | } | |
| 5065 | } | |
| 5066 | ||
| 5067 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5068 | static void remote_group_action(PurpleProtocolAction *act) { |
| 15884 | 5069 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5070 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5071 | const char *msgB; |
| 10977 | 5072 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5073 | gc = act->connection; |
| 10977 | 5074 | |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5075 | msgA = _("Notes Address Book Group"); |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5076 | msgB = _("Enter the name of a Notes Address Book group in the field below" |
| 10977 | 5077 | " to add the group and its members to your buddy list."); |
| 5078 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5079 | purple_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
| 10977 | 5080 | FALSE, FALSE, NULL, |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5081 | _("Add"), G_CALLBACK(remote_group_action_cb), |
|
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5082 | _("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
|
5083 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5084 | gc); |
| 10977 | 5085 | } |
| 5086 | ||
| 5087 | ||
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5088 | static void search_notify(struct mwResolveResult *result, |
| 15884 | 5089 | PurpleConnection *gc) { |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5090 | GList *l; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5091 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5092 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5093 | char *msg1; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5094 | char *msg2; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5095 | |
| 15884 | 5096 | PurpleNotifySearchResults *sres; |
| 5097 | PurpleNotifySearchColumn *scol; | |
| 5098 | ||
| 5099 | sres = purple_notify_searchresults_new(); | |
| 5100 | ||
| 5101 | scol = purple_notify_searchresults_column_new(_("User Name")); | |
| 5102 | purple_notify_searchresults_column_add(sres, scol); | |
| 5103 | ||
| 5104 | scol = purple_notify_searchresults_column_new(_("Sametime ID")); | |
| 5105 | purple_notify_searchresults_column_add(sres, scol); | |
| 5106 | ||
| 5107 | 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
|
5108 | notify_im); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5109 | |
| 15884 | 5110 | 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
|
5111 | notify_add); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5112 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5113 | for(l = result->matches; l; l = l->next) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5114 | struct mwResolveMatch *match = l->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5115 | GList *row = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5116 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5117 | if(!match->id || !match->name) |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5118 | continue; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5119 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5120 | row = g_list_append(row, g_strdup(match->name)); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5121 | row = g_list_append(row, g_strdup(match->id)); |
| 15884 | 5122 | purple_notify_searchresults_row_add(sres, row); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5123 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5124 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5125 | msgA = _("Search results for '%s'"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5126 | 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
|
5127 | " 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
|
5128 | " messages with the action buttons below."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5129 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5130 | msg1 = g_strdup_printf(msgA, result->name); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5131 | msg2 = g_strdup_printf(msgB, result->name); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5132 | |
| 15884 | 5133 | purple_notify_searchresults(gc, _("Search Results"), |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5134 | msg1, msg2, sres, notify_close, NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5135 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5136 | g_free(msg1); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5137 | g_free(msg2); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5138 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5139 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5140 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5141 | static void search_resolved(struct mwServiceResolve *srvc, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5142 | guint32 id, guint32 code, GList *results, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5143 | gpointer b) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5144 | |
| 15884 | 5145 | PurpleConnection *gc = b; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5146 | struct mwResolveResult *res = NULL; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5147 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5148 | if(results) res = results->data; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5149 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5150 | if(!code && res && res->matches) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5151 | search_notify(res, gc); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5152 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5153 | } else { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5154 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5155 | const char *msgB; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5156 | char *msg; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5157 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5158 | msgA = _("No matches"); |
|
13287
18cc0c33773d
[gaim-migrate @ 15652]
Evan Schoenberg <evands@pidgin.im>
parents:
13211
diff
changeset
|
5159 | 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
|
5160 | " Sametime community."); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39894
diff
changeset
|
5161 | msg = g_strdup_printf(msgB, (res && res->name) ? res->name : ""); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5162 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
5163 | 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
|
5164 | purple_request_cpar_from_connection(gc)); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5165 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5166 | g_free(msg); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5167 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5168 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5169 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5170 | |
| 15884 | 5171 | 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
|
5172 | struct mwPurpleProtocolData *pd; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5173 | struct mwServiceResolve *srvc; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5174 | GList *query; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5175 | enum mwResolveFlag flags; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5176 | guint32 req; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5177 | |
|
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
|
5178 | pd = purple_connection_get_protocol_data(gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5179 | srvc = pd->srvc_resolve; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5180 | |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5181 | query = g_list_prepend(NULL, (char *) name); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5182 | flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5183 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5184 | req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5185 | gc, NULL); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5186 | g_list_free(query); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5187 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5188 | if(req == SEARCH_ERROR) { |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5189 | /** @todo display error */ |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5190 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5191 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5192 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5193 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5194 | static void search_action(PurpleProtocolAction *act) { |
| 15884 | 5195 | PurpleConnection *gc; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5196 | const char *msgA; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13021
diff
changeset
|
5197 | const char *msgB; |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5198 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5199 | gc = act->connection; |
|
12630
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 | msgA = _("Search for a user"); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5202 | 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
|
5203 | " for matching users in your Sametime community."); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5204 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5205 | purple_request_input(gc, _("User Search"), msgA, msgB, NULL, |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5206 | FALSE, FALSE, NULL, |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5207 | _("Search"), G_CALLBACK(search_action_cb), |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5208 | _("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
|
5209 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
5210 | gc); |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5211 | } |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5212 | |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5213 | |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
5214 | static GList * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40620
diff
changeset
|
5215 | mw_protocol_get_actions(PurpleProtocolClient *client, PurpleConnection *gc) { |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5216 | PurpleProtocolAction *act; |
| 10977 | 5217 | GList *l = NULL; |
| 5218 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5219 | act = purple_protocol_action_new(_("Import Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5220 | st_import_action); |
| 10977 | 5221 | l = g_list_append(l, act); |
| 5222 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5223 | act = purple_protocol_action_new(_("Export Sametime List..."), |
|
11943
81ee4bc13c28
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5224 | st_export_action); |
| 10977 | 5225 | l = g_list_append(l, act); |
| 5226 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5227 | act = purple_protocol_action_new(_("Add Notes Address Book Group..."), |
| 10977 | 5228 | remote_group_action); |
| 5229 | l = g_list_append(l, act); | |
| 5230 | ||
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5231 | act = purple_protocol_action_new(_("User Search..."), |
|
12630
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5232 | search_action); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5233 | l = g_list_append(l, act); |
|
b0fad57c3fc0
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5234 | |
| 10977 | 5235 | return l; |
| 5236 | } | |
| 5237 | ||
| 5238 | ||
| 5239 | static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 5240 | const gchar *msg, gpointer data) { | |
|
12005
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5241 | |
|
0256aeef8411
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5242 | if(! (msg && *msg)) return; |
| 10977 | 5243 | |
| 15884 | 5244 | /* handle g_log requests via purple's built-in debug logging */ |
| 10977 | 5245 | if(flags & G_LOG_LEVEL_ERROR) { |
| 15884 | 5246 | purple_debug_error(domain, "%s\n", msg); |
| 10977 | 5247 | |
| 5248 | } else if(flags & G_LOG_LEVEL_WARNING) { | |
| 15884 | 5249 | purple_debug_warning(domain, "%s\n", msg); |
| 10977 | 5250 | |
| 5251 | } else { | |
| 15884 | 5252 | purple_debug_info(domain, "%s\n", msg); |
| 10977 | 5253 | } |
| 5254 | } | |
| 5255 | ||
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5256 | static void |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5257 | mw_protocol_init(mwProtocol *self) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5258 | { |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5259 | /* set up the preferences */ |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5260 | 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
|
5261 | 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
|
5262 | BLIST_CHOICE_DEFAULT); |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5263 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5264 | /* remove dead preferences */ |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5265 | purple_prefs_remove(MW_PROTOCOL_OPT_PSYCHIC); |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5266 | 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
|
5267 | } |
| 10977 | 5268 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5269 | static void |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5270 | 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
|
5271 | { |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5272 | 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
|
5273 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5274 | 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
|
5275 | 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
|
5276 | protocol_class->status_types = mw_protocol_status_types; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5277 | protocol_class->list_icon = mw_protocol_list_icon; |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5278 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5279 | protocol_class->get_account_options = mw_protocol_get_account_options; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5280 | 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
|
5281 | } |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5282 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5283 | static void |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5284 | 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
|
5285 | { |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5286 | } |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5287 | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5288 | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36679
diff
changeset
|
5289 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5290 | 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
|
5291 | { |
|
36736
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5292 | client_iface->get_actions = mw_protocol_get_actions; |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5293 | 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
|
5294 | 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
|
5295 | 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
|
5296 | 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
|
5297 | 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
|
5298 | 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
|
5299 | 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
|
5300 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5301 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5302 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5303 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5304 | 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
|
5305 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5306 | 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
|
5307 | 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
|
5308 | 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
|
5309 | 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
|
5310 | 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
|
5311 | 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
|
5312 | 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
|
5313 | 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
|
5314 | 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
|
5315 | 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
|
5316 | 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
|
5317 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5318 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5319 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5320 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5321 | 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
|
5322 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5323 | 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
|
5324 | 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
|
5325 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5326 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5327 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5328 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5329 | 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
|
5330 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5331 | 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
|
5332 | 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
|
5333 | 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
|
5334 | 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
|
5335 | 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
|
5336 | 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
|
5337 | 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
|
5338 | 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
|
5339 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5340 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5341 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5342 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
5343 | 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
|
5344 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5345 | 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
|
5346 | 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
|
5347 | 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
|
5348 | 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
|
5349 | 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
|
5350 | } |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5351 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5352 | |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5353 | static void |
|
38827
3573c82d32d8
Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
38433
diff
changeset
|
5354 | 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
|
5355 | { |
|
164cbd1113d4
Refactored sametime, silc, simple to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
5356 | 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
|
5357 | 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
|
5358 | 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
|
5359 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5360 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5361 | G_DEFINE_DYNAMIC_TYPE_EXTENDED( |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5362 | 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
|
5363 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5364 | 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
|
5365 | mw_protocol_client_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5366 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5367 | 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
|
5368 | mw_protocol_server_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5369 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5370 | 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
|
5371 | mw_protocol_im_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5372 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5373 | 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
|
5374 | mw_protocol_chat_iface_init) |
|
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 | 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
|
5377 | mw_protocol_privacy_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5378 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5379 | 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
|
5380 | 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
|
5381 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5382 | static PurpleProtocol * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5383 | mw_protocol_new(void) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5384 | return PURPLE_PROTOCOL(g_object_new( |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5385 | MW_TYPE_PROTOCOL, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5386 | "id", PROTOCOL_ID, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5387 | "name", PROTOCOL_NAME, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5388 | NULL)); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5389 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5390 | |
|
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
|
5391 | 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
|
5392 | sametime_query(GError **error) |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5393 | { |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5394 | const gchar * const authors[] = PLUGIN_AUTHORS; |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5395 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5396 | 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
|
5397 | "id", PLUGIN_ID, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5398 | "name", PLUGIN_NAME, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5399 | "version", DISPLAY_VERSION, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5400 | "category", PLUGIN_CATEGORY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5401 | "summary", PLUGIN_SUMMARY, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5402 | "description", PLUGIN_DESC, |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
5403 | "authors", authors, |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5404 | "website", PLUGIN_HOMEPAGE, |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5405 | "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
|
5406 | "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
|
5407 | 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
|
5408 | NULL |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5409 | ); |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5410 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5411 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5412 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5413 | 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
|
5414 | 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
|
5415 | { |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5416 | PurpleProtocolManager *manager = purple_protocol_manager_get_default(); |
| 36679 | 5417 | GLogLevelFlags logflags = |
| 5418 | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
| 5419 | ||
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
5420 | 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
|
5421 | |
|
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
|
5422 | 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
|
5423 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40811
diff
changeset
|
5424 | 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
|
5425 | 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
|
5426 | 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
|
5427 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5428 | 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
|
5429 | } |
| 10977 | 5430 | |
| 15884 | 5431 | /* forward all our g_log messages to purple. Generally all the logging |
| 5432 | calls are using purple_log directly, but the g_return macros will | |
| 10977 | 5433 | get caught here */ |
| 5434 | 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
|
5435 | mw_log_handler, NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30708
diff
changeset
|
5436 | |
| 15884 | 5437 | /* redirect meanwhile's logging to purple's */ |
| 10977 | 5438 | 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
|
5439 | 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
|
5440 | |
|
39526
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5441 | g_mime_init(); |
|
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5442 | |
|
36531
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5443 | return TRUE; |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5444 | } |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5445 | |
|
6d45c74af198
Refactored sametime to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36414
diff
changeset
|
5446 | |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5447 | 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
|
5448 | sametime_unload(GPluginPlugin *plugin, GError **error) |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5449 | { |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5450 | 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
|
5451 | |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5452 | 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
|
5453 | return FALSE; |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5454 | } |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5455 | |
|
39526
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5456 | g_mime_shutdown(); |
|
4f678f514b69
Switch to GMime for sametime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39523
diff
changeset
|
5457 | |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36660
diff
changeset
|
5458 | g_log_remove_handler(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
|
5459 | 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
|
5460 | |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
5461 | g_clear_object(&my_protocol); |
|
36592
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5462 | |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5463 | return TRUE; |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5464 | } |
|
431166bcb802
Refactored sametime to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
5465 | |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36701
diff
changeset
|
5466 | |
|
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
|
5467 | GPLUGIN_NATIVE_PLUGIN_DECLARE(sametime) |
| 10977 | 5468 | /* The End. */ |
| 5469 |