annotate src/protocols/sametime/sametime.c @ 12923:f50a99d5ba9b

[gaim-migrate @ 15276] fixing gaim_menu_action_new warnings committer: Tailor Script <tailor@pidgin.im>
author Christopher O'Brien <siege@pidgin.im>
date Wed, 18 Jan 2006 02:58:15 +0000
parents 66e424d4bc77
children 82e918444965
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2 /*
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3 Meanwhile Protocol Plugin for Gaim
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4 Adds Lotus Sametime support to Gaim using the Meanwhile library
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
6 Copyright (C) 2004 Christopher (siege) O'Brien <siege@preoccupied.net>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
7
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
8 This program is free software; you can redistribute it and/or modify
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
10 the Free Software Foundation; either version 2 of the License, or (at
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
11 your option) any later version.
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
12
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful, but
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
16 General Public License for more details.
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
17
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
19 along with this program; if not, write to the Free Software
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
21 USA.
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
22 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
23
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
24
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
25 /* system includes */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
26 #include <stdlib.h>
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
27 #include <time.h>
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
28
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
29 /* glib includes */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
30 #include <glib.h>
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
31 #include <glib/ghash.h>
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
32 #include <glib/glist.h>
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
33
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
34 /* gaim includes */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
35 #include <internal.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
36 #include <gaim.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
37 #include <config.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
38
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
39 #include <account.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
40 #include <accountopt.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
41 #include <conversation.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
42 #include <debug.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
43 #include <ft.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
44 #include <imgstore.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
45 #include <mime.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
46 #include <notify.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
47 #include <plugin.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
48 #include <privacy.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
49 #include <prpl.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
50 #include <request.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
51 #include <util.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
52 #include <version.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
53
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
54 /* meanwhile includes */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
55 #include <mw_cipher.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
56 #include <mw_common.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
57 #include <mw_error.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
58 #include <mw_service.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
59 #include <mw_session.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
60 #include <mw_srvc_aware.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
61 #include <mw_srvc_conf.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
62 #include <mw_srvc_ft.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
63 #include <mw_srvc_im.h>
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
64 #include <mw_srvc_place.h>
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
65 #include <mw_srvc_resolve.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
66 #include <mw_srvc_store.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
67 #include <mw_st_list.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
68
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
69 /* plugin includes */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
70 #include "sametime.h"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
71
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
72
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
73 /* considering that there's no display of this information for prpls,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
74 I don't know why I even bother providing these. Oh valiant reader,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
75 I do it all for you. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
76 /* scratch that, I just added it to the prpl options panel */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
77 #define PLUGIN_ID "prpl-meanwhile"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
78 #define PLUGIN_NAME "Sametime"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
79 #define PLUGIN_SUMMARY "Sametime Protocol Plugin"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
80 #define PLUGIN_DESC "Open implementation of a Lotus Sametime client"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
81 #define PLUGIN_AUTHOR "Christopher (siege) O'Brien <siege@preoccupied.net>"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
82 #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
83
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
84
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
85 /* plugin preference names */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
86 #define MW_PRPL_OPT_BASE "/plugins/prpl/meanwhile"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
87 #define MW_PRPL_OPT_BLIST_ACTION MW_PRPL_OPT_BASE "/blist_action"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
88 #define MW_PRPL_OPT_PSYCHIC MW_PRPL_OPT_BASE "/psychic"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
89 #define MW_PRPL_OPT_FORCE_LOGIN MW_PRPL_OPT_BASE "/force_login"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
90 #define MW_PRPL_OPT_SAVE_DYNAMIC MW_PRPL_OPT_BASE "/save_dynamic"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
91
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
92
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
93 /* stages of connecting-ness */
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
94 #define MW_CONNECT_STEPS 10
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
95
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
96
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
97 /* stages of conciousness */
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
98 #define MW_STATE_OFFLINE "offline"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
99 #define MW_STATE_ACTIVE "active"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
100 #define MW_STATE_AWAY "away"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
101 #define MW_STATE_BUSY "dnd"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
102 #define MW_STATE_MESSAGE "message"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
103 #define MW_STATE_ENLIGHTENED "buddha"
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
104
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
105
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
106 /* keys to get/set chat information */
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
107 #define CHAT_KEY_CREATOR "chat.creator"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
108 #define CHAT_KEY_NAME "chat.name"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
109 #define CHAT_KEY_TOPIC "chat.topic"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
110 #define CHAT_KEY_INVITE "chat.invite"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
111 #define CHAT_KEY_IS_PLACE "chat.is_place"
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
112
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
113
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
114 /* key for associating a mwLoginType with a buddy */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
115 #define BUDDY_KEY_CLIENT "meanwhile.client"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
116
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
117 /* store the remote alias so that we can re-create it easily */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
118 #define BUDDY_KEY_NAME "meanwhile.shortname"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
119
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
120 /* enum mwSametimeUserType */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
121 #define BUDDY_KEY_TYPE "meanwhile.type"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
122
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
123
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
124 /* key for the real group name for a meanwhile group */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
125 #define GROUP_KEY_NAME "meanwhile.group"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
126
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
127 /* enum mwSametimeGroupType */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
128 #define GROUP_KEY_TYPE "meanwhile.type"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
129
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
130 /* NAB group owning account */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
131 #define GROUP_KEY_OWNER "meanwhile.account"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
132
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
133 /* key gtk blist uses to indicate a collapsed group */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
134 #define GROUP_KEY_COLLAPSED "collapsed"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
135
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
136
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
137 /* verification replacement */
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
138 #define mwSession_NO_SECRET "meanwhile.no_secret"
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
139
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
140
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
141 /* keys to get/set gaim plugin information */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
142 #define MW_KEY_HOST "server"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
143 #define MW_KEY_PORT "port"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
144 #define MW_KEY_ACTIVE_MSG "active_msg"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
145 #define MW_KEY_AWAY_MSG "away_msg"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
146 #define MW_KEY_BUSY_MSG "busy_msg"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
147 #define MW_KEY_MSG_PROMPT "msg_prompt"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
148 #define MW_KEY_INVITE "conf_invite"
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
149 #define MW_KEY_ENCODING "encoding"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
150 #define MW_KEY_FORCE "force_login"
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
151 #define MW_KEY_FAKE_IT "fake_client_id"
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
152
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
153
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
154 /** number of seconds from the first blist change before a save to the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
155 storage service occurs. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
156 #define BLIST_SAVE_SECONDS 15
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
157
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
158
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
159 /** the possible buddy list storage settings */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
160 enum blist_choice {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
161 blist_choice_LOCAL = 1, /**< local only */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
162 blist_choice_MERGE = 2, /**< merge from server */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
163 blist_choice_STORE = 3, /**< merge from and save to server */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
164 blist_choice_SYNCH = 4, /**< sync with server */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
165 };
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
166
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
167
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
168 /** the default blist storage option */
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
169 #define BLIST_CHOICE_DEFAULT blist_choice_SYNCH
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
170
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
171
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
172 /* testing for the above */
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
173 #define BLIST_PREF_IS(n) (gaim_prefs_get_int(MW_PRPL_OPT_BLIST_ACTION)==(n))
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
174 #define BLIST_PREF_IS_LOCAL() BLIST_PREF_IS(blist_choice_LOCAL)
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
175 #define BLIST_PREF_IS_MERGE() BLIST_PREF_IS(blist_choice_MERGE)
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
176 #define BLIST_PREF_IS_STORE() BLIST_PREF_IS(blist_choice_STORE)
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
177 #define BLIST_PREF_IS_SYNCH() BLIST_PREF_IS(blist_choice_SYNCH)
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
178
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
179
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
180 /* debugging output */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
181 #define DEBUG_ERROR(a...) gaim_debug_error(G_LOG_DOMAIN, a)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
182 #define DEBUG_INFO(a...) gaim_debug_info(G_LOG_DOMAIN, a)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
183 #define DEBUG_MISC(a...) gaim_debug_misc(G_LOG_DOMAIN, a)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
184 #define DEBUG_WARN(a...) gaim_debug_warning(G_LOG_DOMAIN, a)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
185
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
186
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
187 /** ensure non-null strings */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
188 #ifndef NSTR
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
189 # define NSTR(str) ((str)? (str): "(null)")
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
190 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
191
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
192
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
193 /** calibrates distinct secure channel nomenclature */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
194 static const unsigned char no_secret[] = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
195 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
196 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
197 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
198 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
199 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
200
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
201
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
202 /** handler IDs from g_log_set_handler in mw_plugin_init */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
203 static guint log_handler[2] = { 0, 0 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
204
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
205
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
206 /** the gaim plugin data.
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
207 available as gc->proto_data and mwSession_getClientData */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
208 struct mwGaimPluginData {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
209 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
210
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
211 struct mwServiceAware *srvc_aware;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
212 struct mwServiceConference *srvc_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
213 struct mwServiceFileTransfer *srvc_ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
214 struct mwServiceIm *srvc_im;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
215 struct mwServicePlace *srvc_place;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
216 struct mwServiceResolve *srvc_resolve;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
217 struct mwServiceStorage *srvc_store;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
218
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
219 /** map of GaimGroup:mwAwareList and mwAwareList:GaimGroup */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
220 GHashTable *group_list_map;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
221
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
222 /** event id for the buddy list save callback */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
223 guint save_event;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
224
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
225 /** socket fd */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
226 int socket;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
227
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
228 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
229 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
230
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
231
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
232 /* blist and aware functions */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
233
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
234 static void blist_export(GaimConnection *gc, struct mwSametimeList *stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
235
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
236 static void blist_store(struct mwGaimPluginData *pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
237
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
238 static void blist_schedule(struct mwGaimPluginData *pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
239
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
240 static void blist_merge(GaimConnection *gc, struct mwSametimeList *stlist);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
241
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
242 static void blist_sync(GaimConnection *gc, struct mwSametimeList *stlist);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
243
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
244 static gboolean buddy_is_external(GaimBuddy *b);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
245
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
246 static void buddy_add(struct mwGaimPluginData *pd, GaimBuddy *buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
247
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
248 static GaimBuddy *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
249 buddy_ensure(GaimConnection *gc, GaimGroup *group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
250 struct mwSametimeUser *stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
251
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
252 static void group_add(struct mwGaimPluginData *pd, GaimGroup *group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
253
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
254 static GaimGroup *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
255 group_ensure(GaimConnection *gc, struct mwSametimeGroup *stgroup);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
256
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
257 static struct mwAwareList *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
258 list_ensure(struct mwGaimPluginData *pd, GaimGroup *group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
259
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
260
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
261 /* session functions */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
262
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
263 static struct mwSession *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
264 gc_to_session(GaimConnection *gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
265
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
266 static GaimConnection *session_to_gc(struct mwSession *session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
267
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
268
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
269 /* conference functions */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
270
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
271 static struct mwConference *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
272 conf_find_by_id(struct mwGaimPluginData *pd, int id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
273
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
274
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
275 /* conversation functions */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
276
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
277 struct convo_msg {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
278 enum mwImSendType type;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
279 gpointer data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
280 GDestroyNotify clear;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
281 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
282
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
283
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
284 struct convo_data {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
285 struct mwConversation *conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
286 GList *queue; /**< outgoing message queue, list of convo_msg */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
287 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
288
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
289 static void convo_data_new(struct mwConversation *conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
290
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
291 static void convo_data_free(struct convo_data *conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
292
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
293 static void convo_features(struct mwConversation *conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
294
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
295 static GaimConversation *convo_get_gconv(struct mwConversation *conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
296
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
297
12629
fee6a32644a4 [gaim-migrate @ 14965]
Richard Laager <rlaager@wiktel.com>
parents: 12624
diff changeset
298 /* name and id */
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
299
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
300 struct named_id {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
301 char *id;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
302 char *name;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
303 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
304
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
305
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
306 /* connection functions */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
307
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
308 static void connect_cb(gpointer data, gint source, GaimInputCondition cond);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
309
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
310
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
311 /* ----- session ------ */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
312
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
313
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
314 /** resolves a mwSession from a GaimConnection */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
315 static struct mwSession *gc_to_session(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
316 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
317
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
318 g_return_val_if_fail(gc != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
319
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
320 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
321 g_return_val_if_fail(pd != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
322
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
323 return pd->session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
324 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
325
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
326
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
327 /** resolves a GaimConnection from a mwSession */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
328 static GaimConnection *session_to_gc(struct mwSession *session) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
329 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
330
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
331 g_return_val_if_fail(session != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
332
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
333 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
334 g_return_val_if_fail(pd != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
335
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
336 return pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
337 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
338
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
339
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
340 static int mw_session_io_write(struct mwSession *session,
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
341 const guchar *buf, gsize len) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
342 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
343 int ret = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
344
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
345 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
346
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
347 /* socket was already closed. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
348 if(pd->socket == 0)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
349 return 1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
350
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
351 while(len) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
352 ret = write(pd->socket, buf, len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
353 if(ret <= 0) break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
354 len -= ret;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
355 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
356
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
357 if(len > 0) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
358 DEBUG_ERROR("write returned %i, %i bytes left unwritten\n", ret, len);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
359 gaim_connection_error(pd->gc, _("Connection closed (writing)"));
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
360
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
361 #if 0
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
362 close(pd->socket);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
363 pd->socket = 0;
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
364 #endif
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
365
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
366 return -1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
367 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
368
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
369 return 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
370 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
371
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
372
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
373 static void mw_session_io_close(struct mwSession *session) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
374 struct mwGaimPluginData *pd;
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
375 GaimConnection *gc;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
376
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
377 pd = mwSession_getClientData(session);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
378 g_return_if_fail(pd != NULL);
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
379
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
380 gc = pd->gc;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
381
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
382 if(pd->socket) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
383 close(pd->socket);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
384 pd->socket = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
385 }
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
386
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
387 if(gc->inpa) {
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
388 gaim_input_remove(gc->inpa);
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
389 gc->inpa = 0;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
390 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
391 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
392
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
393
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
394 static void mw_session_clear(struct mwSession *session) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
395 ; /* nothing for now */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
396 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
397
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
398
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
399 /* ----- aware list ----- */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
400
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
401
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
402 static void blist_resolve_alias_cb(struct mwServiceResolve *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
403 guint32 id, guint32 code, GList *results,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
404 gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
405 struct mwResolveResult *result;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
406 struct mwResolveMatch *match;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
407
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
408 g_return_if_fail(results != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
409
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
410 result = results->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
411 g_return_if_fail(result != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
412 g_return_if_fail(result->matches != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
413
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
414 match = result->matches->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
415 g_return_if_fail(match != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
416
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
417 gaim_blist_server_alias_buddy(data, match->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
418 gaim_blist_node_set_string(data, BUDDY_KEY_NAME, match->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
419 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
420
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
421
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
422 static void mw_aware_list_on_aware(struct mwAwareList *list,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
423 struct mwAwareSnapshot *aware) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
424
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
425 GaimConnection *gc;
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
426 GaimAccount *acct;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
427
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
428 struct mwGaimPluginData *pd;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
429 time_t idle;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
430 guint stat;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
431 const char *id;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
432 const char *status = MW_STATE_ACTIVE;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
433
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
434 gc = mwAwareList_getClientData(list);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
435 acct = gaim_connection_get_account(gc);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
436
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
437 pd = gc->proto_data;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
438 idle = aware->status.time;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
439 stat = aware->status.status;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
440 id = aware->id.user;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
441
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
442 /* not sure which client sends this yet */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
443 if(idle == 0xdeadbeef) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
444 /* knock knock!
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
445 who's there?
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
446 rude interrupting cow.
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
447 rude interr...
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
448 MOO! */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
449 idle = -1;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
450 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
451
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
452 switch(stat) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
453 case mwStatus_ACTIVE:
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
454 status = MW_STATE_ACTIVE;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
455 idle = 0;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
456 break;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
457
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
458 case mwStatus_IDLE:
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
459 if(! idle) idle = -1;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
460 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
461
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
462 case mwStatus_AWAY:
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
463 status = MW_STATE_AWAY;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
464 break;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
465
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
466 case mwStatus_BUSY:
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
467 status = MW_STATE_BUSY;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
468 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
469 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
470
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
471 /* NAB group members */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
472 if(aware->group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
473 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
474 GaimBuddy *buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
475 GaimBlistNode *bnode;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
476
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
477 group = g_hash_table_lookup(pd->group_list_map, list);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
478 buddy = gaim_find_buddy_in_group(acct, id, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
479 bnode = (GaimBlistNode *) buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
480
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
481 if(! buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
482 struct mwServiceResolve *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
483 GList *query;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
484
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
485 buddy = gaim_buddy_new(acct, id, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
486 gaim_blist_add_buddy(buddy, NULL, group, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
487
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
488 bnode = (GaimBlistNode *) buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
489
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
490 srvc = pd->srvc_resolve;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
491 query = g_list_append(NULL, (char *) id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
492
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
493 mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
494 blist_resolve_alias_cb, buddy, NULL);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
495 g_list_free(query);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
496 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
497
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
498 gaim_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
499 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
500
12263
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
501 if(aware->online) {
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
502 gaim_prpl_got_user_status(acct, id, status, NULL);
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
503 gaim_prpl_got_user_idle(acct, id, !!idle, idle);
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
504
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
505 } else {
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
506 gaim_prpl_got_user_status(acct, id, MW_STATE_OFFLINE, NULL);
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
507 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
508 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
509
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
510
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
511 static void mw_aware_list_on_attrib(struct mwAwareList *list,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
512 struct mwAwareIdBlock *id,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
513 struct mwAwareAttribute *attrib) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
514
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
515 ; /* nothing. We'll get attribute data as we need it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
516 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
517
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
518
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
519 static void mw_aware_list_clear(struct mwAwareList *list) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
520 ; /* nothing for now */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
521 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
522
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
523
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
524 static struct mwAwareListHandler mw_aware_list_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
525 .on_aware = mw_aware_list_on_aware,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
526 .on_attrib = mw_aware_list_on_attrib,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
527 .clear = mw_aware_list_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
528 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
529
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
530
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
531 /** Ensures that an Aware List is associated with the given group, and
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
532 returns that list. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
533 static struct mwAwareList *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
534 list_ensure(struct mwGaimPluginData *pd, GaimGroup *group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
535
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
536 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
537
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
538 g_return_val_if_fail(pd != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
539 g_return_val_if_fail(group != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
540
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
541 list = g_hash_table_lookup(pd->group_list_map, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
542 if(! list) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
543 list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
544 mwAwareList_setClientData(list, pd->gc, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
545
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
546 mwAwareList_watchAttributes(list,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
547 mwAttribute_AV_PREFS_SET,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
548 mwAttribute_MICROPHONE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
549 mwAttribute_SPEAKERS,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
550 mwAttribute_VIDEO_CAMERA,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
551 mwAttribute_FILE_TRANSFER,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
552 NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
553
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
554 g_hash_table_replace(pd->group_list_map, group, list);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
555 g_hash_table_insert(pd->group_list_map, list, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
556 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
557
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
558 return list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
559 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
560
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
561
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
562 static void blist_export(GaimConnection *gc, struct mwSametimeList *stlist) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
563 /* - find the account for this connection
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
564 - iterate through the buddy list
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
565 - add each buddy matching this account to the stlist
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
566 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
567
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
568 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
569 GaimBuddyList *blist;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
570 GaimBlistNode *gn, *cn, *bn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
571 GaimGroup *grp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
572 GaimBuddy *bdy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
573
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
574 struct mwSametimeGroup *stg = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
575 struct mwIdBlock idb = { NULL, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
576
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
577 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
578 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
579
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
580 blist = gaim_get_blist();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
581 g_return_if_fail(blist != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
582
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
583 for(gn = blist->root; gn; gn = gn->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
584 const char *owner;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
585 const char *gname;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
586 enum mwSametimeGroupType gtype;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
587 gboolean gopen;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
588
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
589 if(! GAIM_BLIST_NODE_IS_GROUP(gn)) continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
590 grp = (GaimGroup *) gn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
591
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
592 /* the group's type (normal or dynamic) */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
593 gtype = gaim_blist_node_get_int(gn, GROUP_KEY_TYPE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
594 if(! gtype) gtype = mwSametimeGroup_NORMAL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
595
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
596 /* if it's a normal group with none of our people in it, skip it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
597 if(gtype == mwSametimeGroup_NORMAL && !gaim_group_on_account(grp, acct))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
598 continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
599
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
600 /* if the group has an owner and we're not it, skip it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
601 owner = gaim_blist_node_get_string(gn, GROUP_KEY_OWNER);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
602 if(owner && strcmp(owner, gaim_account_get_username(acct)))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
603 continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
604
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
605 /* the group's actual name may be different from the gaim group's
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
606 name. Find whichever is there */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
607 gname = gaim_blist_node_get_string(gn, GROUP_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
608 if(! gname) gname = grp->name;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
609
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
610 /* we save this, but never actually honor it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
611 gopen = ! gaim_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
612
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
613 stg = mwSametimeGroup_new(stlist, gtype, gname);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
614 mwSametimeGroup_setAlias(stg, grp->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
615 mwSametimeGroup_setOpen(stg, gopen);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
616
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
617 /* don't attempt to put buddies in a dynamic group, it breaks
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
618 other clients */
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
619 if(gtype == mwSametimeGroup_DYNAMIC)
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
620 continue;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
621
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
622 for(cn = gn->child; cn; cn = cn->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
623 if(! GAIM_BLIST_NODE_IS_CONTACT(cn)) continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
624
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
625 for(bn = cn->child; bn; bn = bn->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
626 if(! GAIM_BLIST_NODE_IS_BUDDY(bn)) continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
627 if(! GAIM_BLIST_NODE_SHOULD_SAVE(bn)) continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
628
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
629 bdy = (GaimBuddy *) bn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
630
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
631 if(bdy->account == acct) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
632 struct mwSametimeUser *stu;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
633 enum mwSametimeUserType utype;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
634
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
635 idb.user = bdy->name;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
636
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
637 utype = gaim_blist_node_get_int(bn, BUDDY_KEY_TYPE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
638 if(! utype) utype = mwSametimeUser_NORMAL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
639
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
640 stu = mwSametimeUser_new(stg, utype, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
641 mwSametimeUser_setShortName(stu, bdy->server_alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
642 mwSametimeUser_setAlias(stu, bdy->alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
643 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
644 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
645 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
646 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
647 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
648
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
649
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
650 static void blist_store(struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
651
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
652 struct mwSametimeList *stlist;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
653 struct mwServiceStorage *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
654 struct mwStorageUnit *unit;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
655
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
656 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
657
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
658 struct mwPutBuffer *b;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
659 struct mwOpaque *o;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
660
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
661 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
662
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
663 srvc = pd->srvc_store;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
664 g_return_if_fail(srvc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
665
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
666 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
667
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
668 if(BLIST_PREF_IS_LOCAL() || BLIST_PREF_IS_MERGE()) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
669 DEBUG_INFO("preferences indicate not to save remote blist\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
670 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
671
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
672 } else if(MW_SERVICE_IS_DEAD(srvc)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
673 DEBUG_INFO("aborting save of blist: storage service is not alive\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
674 return;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
675
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
676 } else if(BLIST_PREF_IS_STORE() || BLIST_PREF_IS_SYNCH()) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
677 DEBUG_INFO("saving remote blist\n");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
678
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
679 } else {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
680 g_return_if_reached();
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
681 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
682
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
683 /* create and export to a list object */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
684 stlist = mwSametimeList_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
685 blist_export(gc, stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
686
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
687 /* write it to a buffer */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
688 b = mwPutBuffer_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
689 mwSametimeList_put(b, stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
690 mwSametimeList_free(stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
691
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
692 /* put the buffer contents into a storage unit */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
693 unit = mwStorageUnit_new(mwStore_AWARE_LIST);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
694 o = mwStorageUnit_asOpaque(unit);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
695 mwPutBuffer_finalize(o, b);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
696
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
697 /* save the storage unit to the service */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
698 mwServiceStorage_save(srvc, unit, NULL, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
699 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
700
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
701
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
702 static gboolean blist_save_cb(gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
703 struct mwGaimPluginData *pd = data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
704
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
705 blist_store(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
706 pd->save_event = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
707 return FALSE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
708 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
709
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
710
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
711 /** schedules the buddy list to be saved to the server */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
712 static void blist_schedule(struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
713 if(pd->save_event) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
714
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
715 pd->save_event = gaim_timeout_add(BLIST_SAVE_SECONDS * 1000,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
716 blist_save_cb, pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
717 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
718
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
719
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
720 static gboolean buddy_is_external(GaimBuddy *b) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
721 g_return_val_if_fail(b != NULL, FALSE);
12166
d6417efb990c [gaim-migrate @ 14467]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12147
diff changeset
722 return gaim_str_has_prefix(b->name, "@E ");
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
723 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
724
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
725
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
726 /** Actually add a buddy to the aware service, and schedule the buddy
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
727 list to be saved to the server */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
728 static void buddy_add(struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
729 GaimBuddy *buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
730
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
731 struct mwAwareIdBlock idb = { mwAware_USER, (char *) buddy->name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
732 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
733
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
734 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
735 GList *add;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
736
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
737 add = g_list_prepend(NULL, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
738
12088
980c877bd238 [gaim-migrate @ 14385]
Mark Doliner <mark@kingant.net>
parents: 12006
diff changeset
739 group = gaim_buddy_get_group(buddy);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
740 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
741
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
742 if(mwAwareList_addAware(list, add)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
743 gaim_blist_remove_buddy(buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
744 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
745
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
746 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
747
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
748 g_list_free(add);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
749 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
750
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
751
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
752 /** ensure that a GaimBuddy exists in the group with data
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
753 appropriately matching the st user entry from the st list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
754 static GaimBuddy *buddy_ensure(GaimConnection *gc, GaimGroup *group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
755 struct mwSametimeUser *stuser) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
756
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
757 struct mwGaimPluginData *pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
758 GaimBuddy *buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
759 GaimAccount *acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
760
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
761 const char *id = mwSametimeUser_getUser(stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
762 const char *name = mwSametimeUser_getShortName(stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
763 const char *alias = mwSametimeUser_getAlias(stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
764 enum mwSametimeUserType type = mwSametimeUser_getType(stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
765
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
766 g_return_val_if_fail(id != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
767 g_return_val_if_fail(strlen(id) > 0, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
768
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
769 buddy = gaim_find_buddy_in_group(acct, id, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
770 if(! buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
771 buddy = gaim_buddy_new(acct, id, alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
772
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
773 gaim_blist_add_buddy(buddy, NULL, group, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
774 buddy_add(pd, buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
775 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
776
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
777 gaim_blist_alias_buddy(buddy, alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
778 gaim_blist_server_alias_buddy(buddy, name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
779 gaim_blist_node_set_string((GaimBlistNode *) buddy, BUDDY_KEY_NAME, name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
780 gaim_blist_node_set_int((GaimBlistNode *) buddy, BUDDY_KEY_TYPE, type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
781
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
782 return buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
783 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
784
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
785
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
786 /** add aware watch for a dynamic group */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
787 static void group_add(struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
788 GaimGroup *group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
789
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
790 struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
791 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
792 const char *n;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
793 GList *add;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
794
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
795 n = gaim_blist_node_get_string((GaimBlistNode *) group, GROUP_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
796 if(! n) n = group->name;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
797
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
798 idb.user = (char *) n;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
799 add = g_list_prepend(NULL, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
800
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
801 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
802 mwAwareList_addAware(list, add);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
803 g_list_free(add);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
804 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
805
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
806
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
807 /** ensure that a GaimGroup exists in the blist with data
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
808 appropriately matching the st group entry from the st list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
809 static GaimGroup *group_ensure(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
810 struct mwSametimeGroup *stgroup) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
811 GaimAccount *acct;
12006
de25a063aebe [gaim-migrate @ 14299]
Christopher O'Brien <siege@pidgin.im>
parents: 12005
diff changeset
812 GaimGroup *group = NULL;
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
813 GaimBuddyList *blist;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
814 GaimBlistNode *gn;
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
815 const char *name, *alias, *owner;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
816 enum mwSametimeGroupType type;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
817
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
818 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
819 owner = gaim_account_get_username(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
820
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
821 blist = gaim_get_blist();
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
822 g_return_val_if_fail(blist != NULL, NULL);
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
823
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
824 name = mwSametimeGroup_getName(stgroup);
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
825 alias = mwSametimeGroup_getAlias(stgroup);
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
826 type = mwSametimeGroup_getType(stgroup);
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
827
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
828 DEBUG_INFO("attempting to ensure group %s, called %s\n",
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
829 NSTR(name), NSTR(alias));
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
830
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
831 /* first attempt at finding the group, by the name key */
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
832 for(gn = blist->root; gn; gn = gn->next) {
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
833 const char *n, *o;
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
834 if(! GAIM_BLIST_NODE_IS_GROUP(gn)) continue;
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
835 n = gaim_blist_node_get_string(gn, GROUP_KEY_NAME);
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
836 o = gaim_blist_node_get_string(gn, GROUP_KEY_OWNER);
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
837
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
838 DEBUG_INFO("found group named %s, owned by %s\n", NSTR(n), NSTR(o));
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
839
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
840 if(n && !strcmp(n, name)) {
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
841 if(!o || !strcmp(o, owner)) {
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
842 DEBUG_INFO("that'll work\n");
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
843 group = (GaimGroup *) gn;
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
844 break;
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
845 }
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
846 }
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
847 }
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
848
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
849 /* try again, by alias */
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
850 if(! group) {
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
851 DEBUG_INFO("searching for group by alias %s\n", NSTR(alias));
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
852 group = gaim_find_group(alias);
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
853 }
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
854
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
855 /* oh well, no such group. Let's create it! */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
856 if(! group) {
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
857 DEBUG_INFO("creating group\n");
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
858 group = gaim_group_new(alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
859 gaim_blist_add_group(group, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
860 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
861
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
862 gn = (GaimBlistNode *) group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
863 gaim_blist_node_set_string(gn, GROUP_KEY_NAME, name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
864 gaim_blist_node_set_int(gn, GROUP_KEY_TYPE, type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
865
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
866 if(type == mwSametimeGroup_DYNAMIC) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
867 gaim_blist_node_set_string(gn, GROUP_KEY_OWNER, owner);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
868 group_add(gc->proto_data, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
869 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
870
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
871 return group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
872 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
873
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
874
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
875 /** merge the entries from a st list into the gaim blist */
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
876 static void blist_merge(GaimConnection *gc, struct mwSametimeList *stlist) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
877 struct mwSametimeGroup *stgroup;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
878 struct mwSametimeUser *stuser;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
879
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
880 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
881 GaimBuddy *buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
882
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
883 GList *gl, *gtl, *ul, *utl;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
884
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
885 gl = gtl = mwSametimeList_getGroups(stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
886 for(; gl; gl = gl->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
887
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
888 stgroup = (struct mwSametimeGroup *) gl->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
889 group = group_ensure(gc, stgroup);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
890
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
891 ul = utl = mwSametimeGroup_getUsers(stgroup);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
892 for(; ul; ul = ul->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
893
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
894 stuser = (struct mwSametimeUser *) ul->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
895 buddy = buddy_ensure(gc, group, stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
896 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
897 g_list_free(utl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
898 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
899 g_list_free(gtl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
900 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
901
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
902
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
903 /** remove all buddies on account from group. If del is TRUE and group
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
904 is left empty, remove group as well */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
905 static void group_clear(GaimGroup *group, GaimAccount *acct, gboolean del) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
906 GaimConnection *gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
907 GList *prune = NULL;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
908 GaimBlistNode *gn, *cn, *bn;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
909
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
910 g_return_if_fail(group != NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
911
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
912 DEBUG_INFO("clearing members from pruned group %s\n", NSTR(group->name));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
913
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
914 gc = gaim_account_get_connection(acct);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
915 g_return_if_fail(gc != NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
916
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
917 gn = (GaimBlistNode *) group;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
918
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
919 for(cn = gn->child; cn; cn = cn->next) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
920 if(! GAIM_BLIST_NODE_IS_CONTACT(cn)) continue;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
921
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
922 for(bn = cn->child; bn; bn = bn->next) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
923 GaimBuddy *gb = (GaimBuddy *) bn;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
924
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
925 if(! GAIM_BLIST_NODE_IS_BUDDY(bn)) continue;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
926
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
927 if(gb->account == acct) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
928 DEBUG_INFO("clearing %s from group\n", NSTR(gb->name));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
929 prune = g_list_prepend(prune, gb);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
930 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
931 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
932 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
933
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
934 /* quickly unsubscribe from presence for the entire group */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
935 gaim_account_remove_group(acct, group);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
936
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
937 /* remove blist entries that need to go */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
938 while(prune) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
939 gaim_blist_remove_buddy(prune->data);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
940 prune = g_list_delete_link(prune, prune);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
941 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
942 DEBUG_INFO("cleared buddies\n");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
944 /* optionally remove group from blist */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
945 if(del && !gaim_blist_get_group_size(group, TRUE)) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
946 DEBUG_INFO("removing empty group\n");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
947 gaim_blist_remove_group(group);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
948 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
949 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
950
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
951
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
952 /** prune out group members that shouldn't be there */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
953 static void group_prune(GaimConnection *gc, GaimGroup *group,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
954 struct mwSametimeGroup *stgroup) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
955
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
956 GaimAccount *acct;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
957 GaimBlistNode *gn, *cn, *bn;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
958
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
959 GHashTable *stusers;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
960 GList *prune = NULL;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
961 GList *ul, *utl;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
962
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
963 g_return_if_fail(group != NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
964
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
965 DEBUG_INFO("pruning membership of group %s\n", NSTR(group->name));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
966
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
967 acct = gaim_connection_get_account(gc);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
968 g_return_if_fail(acct != NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
969
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
970 stusers = g_hash_table_new(g_str_hash, g_str_equal);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
971
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
972 /* build a hash table for quick lookup while pruning the group
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
973 contents */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
974 utl = mwSametimeGroup_getUsers(stgroup);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
975 for(ul = utl; ul; ul = ul->next) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
976 const char *id = mwSametimeUser_getUser(ul->data);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
977 g_hash_table_insert(stusers, (char *) id, ul->data);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
978 DEBUG_INFO("server copy has %s\n", NSTR(id));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
979 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
980 g_list_free(utl);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
981
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
982 gn = (GaimBlistNode *) group;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
983
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
984 for(cn = gn->child; cn; cn = cn->next) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
985 if(! GAIM_BLIST_NODE_IS_CONTACT(cn)) continue;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
986
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
987 for(bn = cn->child; bn; bn = bn->next) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
988 GaimBuddy *gb = (GaimBuddy *) bn;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
989
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
990 if(! GAIM_BLIST_NODE_IS_BUDDY(bn)) continue;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
991
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
992 /* if the account is correct and they're not in our table, mark
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
993 them for pruning */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
994 if(gb->account == acct && !g_hash_table_lookup(stusers, gb->name)) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
995 DEBUG_INFO("marking %s for pruning\n", NSTR(gb->name));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
996 prune = g_list_prepend(prune, gb);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
997 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
998 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
999 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1000 DEBUG_INFO("done marking\n");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1001
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1002 g_hash_table_destroy(stusers);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1003
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1004 if(prune) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1005 gaim_account_remove_buddies(acct, prune, NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1006 while(prune) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1007 gaim_blist_remove_buddy(prune->data);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1008 prune = g_list_delete_link(prune, prune);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1009 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1010 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1011 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1012
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1013
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1014 /** synch the entries from a st list into the gaim blist, removing any
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1015 existing buddies that aren't in the st list */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1016 static void blist_sync(GaimConnection *gc, struct mwSametimeList *stlist) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1017
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1018 GaimAccount *acct;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1019 GaimBuddyList *blist;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1020 GaimBlistNode *gn;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1021
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1022 GHashTable *stgroups;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1023 GList *g_prune = NULL;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1024
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1025 GList *gl, *gtl;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1026
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1027 const char *acct_n;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1028
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1029 DEBUG_INFO("synchronizing local buddy list from server list\n");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1030
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1031 acct = gaim_connection_get_account(gc);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1032 g_return_if_fail(acct != NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1033
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1034 acct_n = gaim_account_get_username(acct);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1035
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1036 blist = gaim_get_blist();
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1037 g_return_if_fail(blist != NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1038
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1039 /* build a hash table for quick lookup while pruning the local
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1040 list, mapping group name to group structure */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1041 stgroups = g_hash_table_new(g_str_hash, g_str_equal);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1042
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1043 gtl = mwSametimeList_getGroups(stlist);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1044 for(gl = gtl; gl; gl = gl->next) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1045 const char *name = mwSametimeGroup_getName(gl->data);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1046 g_hash_table_insert(stgroups, (char *) name, gl->data);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1047 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1048 g_list_free(gtl);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1049
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1050 /* find all groups which should be pruned from the local list */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1051 for(gn = blist->root; gn; gn = gn->next) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1052 GaimGroup *grp = (GaimGroup *) gn;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1053 const char *gname, *owner;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1054 struct mwSametimeGroup *stgrp;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1055
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1056 if(! GAIM_BLIST_NODE_IS_GROUP(gn)) continue;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1057
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1058 /* group not belonging to this account */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1059 if(! gaim_group_on_account(grp, acct))
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1060 continue;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1061
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1062 /* dynamic group belonging to this account. don't prune contents */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1063 owner = gaim_blist_node_get_string(gn, GROUP_KEY_OWNER);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1064 if(owner && !strcmp(owner, acct_n))
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1065 continue;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1066
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1067 /* we actually are synching by this key as opposed to the group
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1068 title, which can be different things in the st list */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1069 gname = gaim_blist_node_get_string(gn, GROUP_KEY_NAME);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1070 if(! gname) gname = grp->name;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1071
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1072 stgrp = g_hash_table_lookup(stgroups, gname);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1073 if(! stgrp) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1074 /* remove the whole group */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1075 DEBUG_INFO("marking group %s for pruning\n", grp->name);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1076 g_prune = g_list_prepend(g_prune, grp);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1077
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1078 } else {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1079 /* synch the group contents */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1080 group_prune(gc, grp, stgrp);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1081 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1082 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1083 DEBUG_INFO("done marking groups\n");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1084
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1085 /* don't need this anymore */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1086 g_hash_table_destroy(stgroups);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1087
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1088 /* prune all marked groups */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1089 while(g_prune) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1090 GaimGroup *grp = g_prune->data;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1091 GaimBlistNode *gn = (GaimBlistNode *) grp;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1092 const char *owner;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1093 gboolean del = TRUE;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1094
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1095 owner = gaim_blist_node_get_string(gn, GROUP_KEY_OWNER);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1096 if(owner && strcmp(owner, acct_n)) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1097 /* it's a specialty group belonging to another account with some
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1098 of our members in it, so don't fully delete it */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1099 del = FALSE;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1100 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1101
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1102 group_clear(g_prune->data, acct, del);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1103 g_prune = g_list_delete_link(g_prune, g_prune);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1104 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1105
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1106 /* done with the pruning, let's merge in the additions */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1107 blist_merge(gc, stlist);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1108 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1109
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1110
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1111 /** callback passed to the storage service when it's told to load the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1112 st list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1113 static void fetch_blist_cb(struct mwServiceStorage *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1114 guint32 result, struct mwStorageUnit *item,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1115 gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1116
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1117 struct mwGaimPluginData *pd = data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1118 struct mwSametimeList *stlist;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1119 struct mwSession *s;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1120
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1121 struct mwGetBuffer *b;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1122
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1123 g_return_if_fail(result == ERR_SUCCESS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1124
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1125 /* check our preferences for loading */
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1126 if(BLIST_PREF_IS_LOCAL()) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1127 DEBUG_INFO("preferences indicate not to load remote buddy list\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1128 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1129 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1130
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1131 b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1132
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1133 stlist = mwSametimeList_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1134 mwSametimeList_get(b, stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1135
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1136 s = mwService_getSession(MW_SERVICE(srvc));
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1137
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1138 /* merge or synch depending on preferences */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1139 if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1140 blist_merge(pd->gc, stlist);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1141
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1142 } else if(BLIST_PREF_IS_SYNCH()) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1143 blist_sync(pd->gc, stlist);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1144 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1145
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1146 mwSametimeList_free(stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1147 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1148
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1149
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1150 /** signal triggered when a conversation is opened in Gaim */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1151 static void conversation_created_cb(GaimConversation *g_conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1152 struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1153
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1154 /* we need to tell the IM service to negotiate features for the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1155 conversation right away, otherwise it'll wait until the first
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1156 message is sent before offering NotesBuddy features. Therefore
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1157 whenever Gaim creates a conversation, we'll immediately open the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1158 channel to the other side and figure out what the target can
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1159 handle. Unfortunately, this makes us vulnerable to Psychic Mode,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1160 whereas a more lazy negotiation based on the first message
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1161 would not */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1162
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1163 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1164 struct mwIdBlock who = { 0, 0 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1165 struct mwConversation *conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1166
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1167 gc = gaim_conversation_get_gc(g_conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1168 if(pd->gc != gc)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1169 return; /* not ours */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1170
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11257
diff changeset
1171 if(gaim_conversation_get_type(g_conv) != GAIM_CONV_TYPE_IM)
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1172 return; /* wrong type */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1173
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1174 who.user = (char *) gaim_conversation_get_name(g_conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1175 conv = mwServiceIm_getConversation(pd->srvc_im, &who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1176
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1177 convo_features(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1178
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1179 if(mwConversation_isClosed(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1180 mwConversation_open(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1181 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1182
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1183
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1184 static void blist_menu_nab(GaimBlistNode *node, gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1185 struct mwGaimPluginData *pd = data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1186 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1187
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1188 GaimGroup *group = (GaimGroup *) node;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1189
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1190 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1191 char *tmp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1192
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1193 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1194
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1195 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1196 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1197
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1198 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(node));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1199
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1200 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1201
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1202 tmp = (char *) gaim_blist_node_get_string(node, GROUP_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1203
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1204 g_string_append_printf(str, _("<b>Group Title:</b> %s<br>"), group->name);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1205 g_string_append_printf(str, _("<b>Notes Group ID:</b> %s<br>"), tmp);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1206
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1207 tmp = g_strdup_printf(_("Info for Group %s"), group->name);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1208
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1209 gaim_notify_formatted(gc, tmp, _("Notes Address Book Information"),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1210 NULL, str->str, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1211
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1212 g_free(tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1213 g_string_free(str, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1214 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1215
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1216
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1217 /** The normal blist menu prpl function doesn't get called for groups,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1218 so we use the blist-node-extended-menu signal to trigger this
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1219 handler */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1220 static void blist_node_menu_cb(GaimBlistNode *node,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1221 GList **menu, struct mwGaimPluginData *pd) {
12107
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1222 const char *owner;
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1223 GaimGroup *group;
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1224 GaimAccount *acct;
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12864
diff changeset
1225 GaimMenuAction *act;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1226
12107
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1227 /* we only want groups */
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1228 if(! GAIM_BLIST_NODE_IS_GROUP(node)) return;
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1229 group = (GaimGroup *) node;
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1230
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1231 acct = gaim_connection_get_account(pd->gc);
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1232 g_return_if_fail(acct != NULL);
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1233
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1234 /* better make sure we're connected */
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1235 if(! gaim_account_is_connected(acct)) return;
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1236
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1237 #if 0
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1238 /* if there's anyone in the group for this acct, offer to invite
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1239 them all to a conference */
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1240 if(gaim_group_on_account(group, acct)) {
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12864
diff changeset
1241 act = gaim_menu_action_new(_("Invite Group to Conference..."),
12923
f50a99d5ba9b [gaim-migrate @ 15276]
Christopher O'Brien <siege@pidgin.im>
parents: 12921
diff changeset
1242 GAIM_CALLBACK(blist_menu_group_invite),
f50a99d5ba9b [gaim-migrate @ 15276]
Christopher O'Brien <siege@pidgin.im>
parents: 12921
diff changeset
1243 pd, NULL);
12107
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1244 *menu = g_list_append(*menu, NULL);
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1245 }
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1246 #endif
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1247
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1248 /* check if it's a NAB group for this account */
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1249 owner = gaim_blist_node_get_string(node, GROUP_KEY_OWNER);
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
1250 if(owner && !strcmp(owner, gaim_account_get_username(acct))) {
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12864
diff changeset
1251 act = gaim_menu_action_new(_("Get Notes Address Book Info"),
12921
66e424d4bc77 [gaim-migrate @ 15274]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12919
diff changeset
1252 GAIM_CALLBACK(blist_menu_nab), pd, NULL);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1253 *menu = g_list_append(*menu, act);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1254 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1255 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1256
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1257
12266
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1258 /* lifted this from oldstatus, since HEAD doesn't do this at login
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1259 anymore. */
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1260 static void blist_init(GaimAccount *acct) {
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1261 GaimBlistNode *gnode, *cnode, *bnode;
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1262 GList *add_buds = NULL;
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1263
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1264 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1265 if(! GAIM_BLIST_NODE_IS_GROUP(gnode)) continue;
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1266
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1267 for(cnode = gnode->child; cnode; cnode = cnode->next) {
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1268 if(! GAIM_BLIST_NODE_IS_CONTACT(cnode))
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1269 continue;
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1270 for(bnode = cnode->child; bnode; bnode = bnode->next) {
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1271 GaimBuddy *b;
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1272 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1273 continue;
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1274
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1275 b = (GaimBuddy *)bnode;
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1276 if(b->account == acct) {
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1277 add_buds = g_list_append(add_buds, b);
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1278 }
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1279 }
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1280 }
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1281 }
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1282
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1283 if(add_buds) {
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1284 gaim_account_add_buddies(acct, add_buds);
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1285 g_list_free(add_buds);
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1286 }
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1287 }
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1288
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1289
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1290 /** Last thing to happen from a started session */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1291 static void services_starting(struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1292
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1293 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1294 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1295 struct mwStorageUnit *unit;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1296 GaimBuddyList *blist;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1297 GaimBlistNode *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1298
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1299 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1300 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1301
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1302 /* grab the buddy list from the server */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1303 unit = mwStorageUnit_new(mwStore_AWARE_LIST);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1304 mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1305
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1306 /* find all the NAB groups and subscribe to them */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1307 blist = gaim_get_blist();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1308 for(l = blist->root; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1309 GaimGroup *group = (GaimGroup *) l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1310 enum mwSametimeGroupType gt;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1311 const char *owner;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1312
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1313 if(! GAIM_BLIST_NODE_IS_GROUP(l)) continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1314
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1315 /* if the group is ownerless, or has an owner and we're not it,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1316 skip it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1317 owner = gaim_blist_node_get_string(l, GROUP_KEY_OWNER);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1318 if(!owner || strcmp(owner, gaim_account_get_username(acct)))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1319 continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1320
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1321 gt = gaim_blist_node_get_int(l, GROUP_KEY_TYPE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1322 if(gt == mwSametimeGroup_DYNAMIC)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1323 group_add(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1324 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1325
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1326 /* set the aware attributes */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1327 /* indicate we understand what AV prefs are, but don't support any */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1328 mwServiceAware_setAttributeBoolean(pd->srvc_aware,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1329 mwAttribute_AV_PREFS_SET, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1330 mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1331 mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1332 mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1333
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1334 /* ... but we can do file transfers! */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1335 mwServiceAware_setAttributeBoolean(pd->srvc_aware,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1336 mwAttribute_FILE_TRANSFER, TRUE);
12266
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1337
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1338 blist_init(acct);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1339 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1340
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1341
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1342 static void session_loginRedirect(struct mwSession *session,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1343 const char *host) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1344 struct mwGaimPluginData *pd;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1345 GaimConnection *gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1346 GaimAccount *account;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1347 guint port;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1348
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1349 pd = mwSession_getClientData(session);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1350 gc = pd->gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1351 account = gaim_connection_get_account(gc);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1352 port = gaim_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1353
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1354 if(gaim_account_get_bool(account, MW_KEY_FORCE, FALSE) ||
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1355 gaim_proxy_connect(account, host, port, connect_cb, pd)) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1356
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1357 mwSession_forceLogin(session);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1358 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1359 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1360
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1361
12266
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1362 static void mw_prpl_set_status(GaimAccount *acct, GaimStatus *status);
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1363
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1364
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1365 /** called from mw_session_stateChange when the session's state is
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1366 mwSession_STARTED. Any finalizing of start-up stuff should go
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1367 here */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1368 static void session_started(struct mwGaimPluginData *pd) {
12266
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1369 GaimStatus *status;
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1370 GaimAccount *acct;
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1371
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1372 /* set out initial status */
12266
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1373 acct = gaim_connection_get_account(pd->gc);
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1374 status = gaim_account_get_active_status(acct);
0e467757b57a [gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents: 12263
diff changeset
1375 mw_prpl_set_status(acct, status);
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1376
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1377 /* start watching for new conversations */
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1378 gaim_signal_connect(gaim_conversations_get_handle(),
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1379 "conversation-created", pd->gc,
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1380 GAIM_CALLBACK(conversation_created_cb), pd);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1381
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1382 /* watch for group extended menu items */
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1383 gaim_signal_connect(gaim_blist_get_handle(),
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1384 "blist-node-extended-menu", pd->gc,
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1385 GAIM_CALLBACK(blist_node_menu_cb), pd);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1386
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1387 /* use our services to do neat things */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1388 services_starting(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1389 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1390
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1391
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1392 static void mw_session_stateChange(struct mwSession *session,
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1393 enum mwSessionState state,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1394 gpointer info) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1395 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1396 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1397 char *msg = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1398
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1399 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1400 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1401
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1402 switch(state) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1403 case mwSession_STARTING:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1404 msg = _("Sending Handshake");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1405 gaim_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1406 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1407
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1408 case mwSession_HANDSHAKE:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1409 msg = _("Waiting for Handshake Acknowledgement");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1410 gaim_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1411 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1412
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1413 case mwSession_HANDSHAKE_ACK:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1414 msg = _("Handshake Acknowledged, Sending Login");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1415 gaim_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1416 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1417
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1418 case mwSession_LOGIN:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1419 msg = _("Waiting for Login Acknowledgement");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1420 gaim_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1421 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1422
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1423 case mwSession_LOGIN_REDIR:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1424 msg = _("Login Redirected");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1425 gaim_connection_update_progress(gc, msg, 6, MW_CONNECT_STEPS);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1426 session_loginRedirect(session, info);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1427 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1428
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1429 case mwSession_LOGIN_CONT:
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1430 msg = _("Forcing Login");
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1431 gaim_connection_update_progress(gc, msg, 7, MW_CONNECT_STEPS);
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1432
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1433 case mwSession_LOGIN_ACK:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1434 msg = _("Login Acknowledged");
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1435 gaim_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1436 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1437
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1438 case mwSession_STARTED:
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1439 msg = _("Starting Services");
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1440 gaim_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1441
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1442 session_started(pd);
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1443
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1444 msg = _("Connected");
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1445 gaim_connection_update_progress(gc, msg, 10, MW_CONNECT_STEPS);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1446 gaim_connection_set_state(gc, GAIM_CONNECTED);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1447 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1448
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1449 case mwSession_STOPPING:
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1450 if(GPOINTER_TO_UINT(info) & ERR_FAILURE) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1451 msg = mwError(GPOINTER_TO_UINT(info));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1452 gaim_connection_error(gc, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1453 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1454 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1455 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1456
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1457 case mwSession_STOPPED:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1458 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1459
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1460 case mwSession_UNKNOWN:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1461 default:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1462 DEBUG_WARN("session in unknown state\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1463 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1464 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1465
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1466
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1467 static void mw_session_setPrivacyInfo(struct mwSession *session) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1468 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1469 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1470 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1471 struct mwPrivacyInfo *privacy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1472 GSList *l, **ll;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1473 guint count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1474
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1475 DEBUG_INFO("privacy information set from server\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1476
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1477 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1478
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1479 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1480 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1481
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1482 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1483 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1484
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1485 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1486 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1487
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1488 privacy = mwSession_getPrivacyInfo(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1489 count = privacy->count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1490
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1491 ll = (privacy->deny)? &acct->deny: &acct->permit;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1492 for(l = *ll; l; l = l->next) g_free(l->data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1493 g_slist_free(*ll);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1494 l = *ll = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1495
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1496 while(count--) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1497 struct mwUserItem *u = privacy->users + count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1498 l = g_slist_prepend(l, g_strdup(u->id));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1499 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1500 *ll = l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1501 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1502
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1503
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1504 static void mw_session_setUserStatus(struct mwSession *session) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1505 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1506 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1507 struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1508 struct mwUserStatus *stat;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1509
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1510 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1511
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1512 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1513 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1514
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1515 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1516 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1517
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1518 idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1519 stat = mwSession_getUserStatus(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1520
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1521 /* trigger an update of our own status if we're in the buddy list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1522 mwServiceAware_setStatus(pd->srvc_aware, &idb, stat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1523 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1524
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1525
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1526 static void mw_session_admin(struct mwSession *session,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1527 const char *text) {
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1528 GaimConnection *gc;
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1529 GaimAccount *acct;
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1530 const char *host;
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1531 char *prim;
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1532
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1533 gc = session_to_gc(session);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1534 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1535
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1536 acct = gaim_connection_get_account(gc);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1537 g_return_if_fail(acct != NULL);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1538
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1539 host = gaim_account_get_string(acct, MW_KEY_HOST, NULL);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1540
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1541 prim = _("A Sametime administrator has issued the following announcement"
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1542 " on server %s");
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1543 prim = g_strdup_printf(prim, NSTR(host));
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1544
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1545 gaim_notify_message(gc, GAIM_NOTIFY_MSG_INFO,
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1546 _("Sametime Administrator Announcement"),
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1547 prim, text, NULL, NULL);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1548
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
1549 g_free(prim);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1550 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1551
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1552
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1553 /** called from read_cb, attempts to read available data from sock and
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1554 pass it to the session, passing back the return code from the read
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1555 call for handling in read_cb */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1556 static int read_recv(struct mwSession *session, int sock) {
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
1557 guchar buf[BUF_LEN];
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1558 int len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1559
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1560 len = read(sock, buf, BUF_LEN);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1561 if(len > 0) mwSession_recv(session, buf, len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1562
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1563 return len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1564 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1565
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1566
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1567 /** callback triggered from gaim_input_add, watches the socked for
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1568 available data to be processed by the session */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1569 static void read_cb(gpointer data, gint source,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1570 GaimInputCondition cond) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1571
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1572 struct mwGaimPluginData *pd = data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1573 int ret = 0, err = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1574
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1575 /* How the heck can this happen? Fix submitted to Gaim so that it
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1576 won't happen anymore. */
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1577 if(! cond) return;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1578
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1579 g_return_if_fail(pd != NULL);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1580 g_return_if_fail(cond & GAIM_INPUT_READ);
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1581
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1582 ret = read_recv(pd->session, pd->socket);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1583
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1584 /* normal operation ends here */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1585 if(ret > 0) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1586
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1587 /* fetch the global error value */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1588 err = errno;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1589
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1590 /* read problem occured if we're here, so we'll need to take care of
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1591 it and clean up internal state */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1592
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1593 if(pd->socket) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1594 close(pd->socket);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1595 pd->socket = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1596 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1597
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1598 if(pd->gc->inpa) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1599 gaim_input_remove(pd->gc->inpa);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1600 pd->gc->inpa = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1601 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1602
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1603 if(! ret) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1604 DEBUG_INFO("connection reset\n");
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1605 gaim_connection_error(pd->gc, _("Connection reset"));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1606
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1607 } else if(ret < 0) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1608 char *msg = strerror(err);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1609
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1610 DEBUG_INFO("error in read callback: %s\n", msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1611
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1612 msg = g_strdup_printf(_("Error reading from socket: %s"), msg);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1613 gaim_connection_error(pd->gc, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1614 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1615 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1616 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1617
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1618
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1619 /** Callback passed to gaim_proxy_connect when an account is logged
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1620 in, and if the session logging in receives a redirect message */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1621 static void connect_cb(gpointer data, gint source,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1622 GaimInputCondition cond) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1623
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1624 struct mwGaimPluginData *pd = data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1625 GaimConnection *gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1626
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1627 if(! g_list_find(gaim_connections_get_all(), pd->gc)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1628 close(source);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1629 g_return_if_reached();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1630 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1631
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1632 if(source < 0) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1633 /* connection failed */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1634
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1635 if(pd->socket) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1636 /* this is a redirect connect, force login on existing socket */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1637 mwSession_forceLogin(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1638
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1639 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1640 /* this is a regular connect, error out */
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1641 gaim_connection_error(pd->gc, _("Unable to connect to host"));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1642 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1643
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1644 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1645 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1646
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1647 if(pd->socket) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1648 /* stop any existing login attempt */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1649 mwSession_stop(pd->session, ERR_SUCCESS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1650 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1651
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1652 pd->socket = source;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1653 gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, read_cb, pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1654
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1655 mwSession_start(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1656 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1657
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1658
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1659 static void mw_session_announce(struct mwSession *s,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1660 struct mwLoginInfo *from,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1661 gboolean may_reply,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1662 const char *text) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1663 struct mwGaimPluginData *pd;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1664 GaimAccount *acct;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1665 GaimConversation *conv;
12126
35c4797c5c57 [gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents: 12107
diff changeset
1666 GaimBuddy *buddy;
12263
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
1667 char *who = from->user_id;
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
1668 char *msg;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1669
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1670 pd = mwSession_getClientData(s);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1671 acct = gaim_connection_get_account(pd->gc);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1672 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, acct);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1673 if(! conv) conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, who);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1674
12126
35c4797c5c57 [gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents: 12107
diff changeset
1675 buddy = gaim_find_buddy(acct, who);
12263
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
1676 if(buddy) who = (char *) gaim_buddy_get_contact_alias(buddy);
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
1677
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
1678 who = g_strdup_printf(_("Announcement from %s"), who);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1679 msg = gaim_markup_linkify(text);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1680
12263
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
1681 gaim_conversation_write(conv, who, msg, GAIM_MESSAGE_RECV, time(NULL));
8190a70d2c34 [gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents: 12216
diff changeset
1682 g_free(who);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1683 g_free(msg);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1684 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1685
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1686
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1687 static struct mwSessionHandler mw_session_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1688 .io_write = mw_session_io_write,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1689 .io_close = mw_session_io_close,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1690 .clear = mw_session_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1691 .on_stateChange = mw_session_stateChange,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1692 .on_setPrivacyInfo = mw_session_setPrivacyInfo,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1693 .on_setUserStatus = mw_session_setUserStatus,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1694 .on_admin = mw_session_admin,
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1695 .on_announce = mw_session_announce,
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1696 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1697
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1698
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1699 static void mw_aware_on_attrib(struct mwServiceAware *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1700 struct mwAwareAttribute *attrib) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1701
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1702 ; /** @todo handle server attributes. There may be some stuff we
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1703 actually want to look for, but I'm not aware of anything right
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1704 now.*/
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1705 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1706
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1707
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1708 static void mw_aware_clear(struct mwServiceAware *srvc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1709 ; /* nothing for now */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1710 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1711
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1712
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1713 static struct mwAwareHandler mw_aware_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1714 .on_attrib = mw_aware_on_attrib,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1715 .clear = mw_aware_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1716 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1717
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1718
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1719 static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1720 struct mwServiceAware *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1721 srvc = mwServiceAware_new(s, &mw_aware_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1722 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1723 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1724
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1725
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1726 static void mw_conf_invited(struct mwConference *conf,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1727 struct mwLoginInfo *inviter,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1728 const char *invitation) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1729
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1730 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1731 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1732 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1733 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1734
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1735 char *c_inviter, *c_name, *c_topic, *c_invitation;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1736 GHashTable *ht;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1737
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1738 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1739 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1740 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1741 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1742
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1743 ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1744
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1745 c_inviter = g_strdup(inviter->user_id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1746 g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1747
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1748 c_name = g_strdup(mwConference_getName(conf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1749 g_hash_table_insert(ht, CHAT_KEY_NAME, c_name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1750
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1751 c_topic = g_strdup(mwConference_getTitle(conf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1752 g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1753
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1754 c_invitation = g_strdup(invitation);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1755 g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1756
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1757 DEBUG_INFO("received invitation from '%s' to join ('%s','%s'): '%s'\n",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1758 NSTR(c_inviter), NSTR(c_name),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1759 NSTR(c_topic), NSTR(c_invitation));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1760
12742
258871a62600 [gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents: 12735
diff changeset
1761 if(! c_topic) c_topic = "(no title)";
258871a62600 [gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents: 12735
diff changeset
1762 if(! c_invitation) c_invitation = "(no message)";
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1763 serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1764 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1765
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1766
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1767 /* The following mess helps us relate a mwConference to a GaimConvChat
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1768 in the various forms by which either may be indicated */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1769
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1770 #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1771 #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id)))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1772
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1773 #define CHAT_TO_ID(chat) (gaim_conv_chat_get_id(chat))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1774 #define ID_TO_CHAT(id) (gaim_find_chat(id))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1775
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1776 #define CHAT_TO_CONF(pd, chat) (ID_TO_CONF((pd), CHAT_TO_ID(chat)))
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
1777 #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf)))
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1778
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1779
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1780 static struct mwConference *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1781 conf_find_by_id(struct mwGaimPluginData *pd, int id) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1782
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1783 struct mwServiceConference *srvc = pd->srvc_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1784 struct mwConference *conf = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1785 GList *l, *ll;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1786
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1787 ll = mwServiceConference_getConferences(srvc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1788 for(l = ll; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1789 struct mwConference *c = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1790 GaimConvChat *h = mwConference_getClientData(c);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1791
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1792 if(CHAT_TO_ID(h) == id) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1793 conf = c;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1794 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1795 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1796 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1797 g_list_free(ll);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1798
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1799 return conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1800 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1801
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1802
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1803 static void mw_conf_opened(struct mwConference *conf, GList *members) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1804 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1805 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1806 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1807 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1808 GaimConversation *g_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1809
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1810 const char *n = mwConference_getName(conf);
12742
258871a62600 [gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents: 12735
diff changeset
1811 const char *t = mwConference_getTitle(conf);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1812
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1813 DEBUG_INFO("conf %s opened, %u initial members\n",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1814 NSTR(n), g_list_length(members));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1815
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1816 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1817 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1818 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1819 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1820
12742
258871a62600 [gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents: 12735
diff changeset
1821 if(! t) t = "(no title)";
258871a62600 [gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents: 12735
diff changeset
1822 g_conf = serv_got_joined_chat(gc, CONF_TO_ID(conf), t);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1823
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1824 mwConference_setClientData(conf, GAIM_CONV_CHAT(g_conf), NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1825
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1826 for(; members; members = members->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1827 struct mwLoginInfo *peer = members->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1828 gaim_conv_chat_add_user(GAIM_CONV_CHAT(g_conf), peer->user_id,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1829 NULL, GAIM_CBFLAGS_NONE, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1830 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1831 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1832
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1833
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1834 static void mw_conf_closed(struct mwConference *conf, guint32 reason) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1835 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1836 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1837 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1838 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1839
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1840 const char *n = mwConference_getName(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1841 char *msg = mwError(reason);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1842
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1843 DEBUG_INFO("conf %s closed, 0x%08x\n", NSTR(n), reason);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1844
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1845 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1846 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1847 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1848 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1849
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1850 serv_got_chat_left(gc, CONF_TO_ID(conf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1851
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
1852 gaim_notify_error(gc, _("Conference Closed"), NULL, msg);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1853 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1854 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1855
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1856
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1857 static void mw_conf_peer_joined(struct mwConference *conf,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1858 struct mwLoginInfo *peer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1859
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1860 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1861 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1862 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1863 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1864 GaimConvChat *g_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1865
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1866 const char *n = mwConference_getName(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1867
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1868 DEBUG_INFO("%s joined conf %s\n", NSTR(peer->user_id), NSTR(n));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1869
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1870 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1871 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1872 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1873 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1874
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1875 g_conf = mwConference_getClientData(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1876 g_return_if_fail(g_conf != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1877
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1878 gaim_conv_chat_add_user(g_conf, peer->user_id,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1879 NULL, GAIM_CBFLAGS_NONE, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1880 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1881
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1882
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1883 static void mw_conf_peer_parted(struct mwConference *conf,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1884 struct mwLoginInfo *peer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1885
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1886 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1887 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1888 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1889 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1890 GaimConvChat *g_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1891
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1892 const char *n = mwConference_getName(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1893
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1894 DEBUG_INFO("%s left conf %s\n", NSTR(peer->user_id), NSTR(n));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1895
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1896 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1897 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1898 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1899 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1900
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1901 g_conf = mwConference_getClientData(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1902 g_return_if_fail(g_conf != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1903
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1904 gaim_conv_chat_remove_user(g_conf, peer->user_id, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1905 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1906
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1907
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1908 static void mw_conf_text(struct mwConference *conf,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1909 struct mwLoginInfo *who, const char *text) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1910
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1911 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1912 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1913 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1914 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1915 char *esc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1916
12863
7a2169f04bdf [gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents: 12830
diff changeset
1917 if(! text) return;
7a2169f04bdf [gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents: 12830
diff changeset
1918
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1919 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1920 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1921 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1922 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1923
12864
2c0f8815aa2e [gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents: 12863
diff changeset
1924 esc = g_markup_escape_text(text, -1);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1925 serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, 0, esc, time(NULL));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1926 g_free(esc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1927 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1928
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1929
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1930 static void mw_conf_typing(struct mwConference *conf,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1931 struct mwLoginInfo *who, gboolean typing) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1932
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1933 /* gaim really has no good way to expose this to the user. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1934
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1935 const char *n = mwConference_getName(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1936 const char *w = who->user_id;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1937
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1938 if(typing) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1939 DEBUG_INFO("%s in conf %s: <typing>\n", NSTR(w), NSTR(n));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1940
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1941 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1942 DEBUG_INFO("%s in conf %s: <stopped typing>\n", NSTR(w), NSTR(n));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1943 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1944 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1945
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1946
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1947 static void mw_conf_clear(struct mwServiceConference *srvc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1948 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1949 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1950
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1951
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1952 static struct mwConferenceHandler mw_conference_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1953 .on_invited = mw_conf_invited,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1954 .conf_opened = mw_conf_opened,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1955 .conf_closed = mw_conf_closed,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1956 .on_peer_joined = mw_conf_peer_joined,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1957 .on_peer_parted = mw_conf_peer_parted,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1958 .on_text = mw_conf_text,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1959 .on_typing = mw_conf_typing,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1960 .clear = mw_conf_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1961 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1962
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1963
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1964 static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1965 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1966 srvc = mwServiceConference_new(s, &mw_conference_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1967 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1968 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1969
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1970
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1971 static void ft_incoming_cancel(GaimXfer *xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1972 /* incoming transfer rejected or canceled in-progress */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1973 struct mwFileTransfer *ft = xfer->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1974 if(ft) mwFileTransfer_reject(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1975 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1976
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1978 static void ft_incoming_init(GaimXfer *xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1979 /* incoming transfer accepted */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1980
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1981 /* - accept the mwFileTransfer
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1982 - open/create the local FILE "wb"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1983 - stick the FILE's fp in xfer->dest_fp
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1984 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1985
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1986 struct mwFileTransfer *ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1987 FILE *fp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1988
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1989 ft = xfer->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1990
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1991 fp = g_fopen(xfer->local_filename, "wb");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1992 if(! fp) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1993 mwFileTransfer_cancel(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1994 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1995 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1996
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1997 xfer->dest_fp = fp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1998 mwFileTransfer_accept(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1999 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2000
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2001
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2002 static void mw_ft_offered(struct mwFileTransfer *ft) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2003 /*
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2004 - create a gaim ft object
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2005 - offer it
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2006 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2007
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2008 struct mwServiceFileTransfer *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2009 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2010 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2011 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2012 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2013 const char *who;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2014 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2015
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2016 /* @todo add some safety checks */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2017 srvc = mwFileTransfer_getService(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2018 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2019 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2020 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2021 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2022
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2023 who = mwFileTransfer_getUser(ft)->user;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2024
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2025 DEBUG_INFO("file transfer %p offered\n", ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2026 DEBUG_INFO(" from: %s\n", NSTR(who));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2027 DEBUG_INFO(" file: %s\n", NSTR(mwFileTransfer_getFileName(ft)));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2028 DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2029 DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft)));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2030
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2031 xfer = gaim_xfer_new(acct, GAIM_XFER_RECEIVE, who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2032
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2033 gaim_xfer_ref(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2034 mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) gaim_xfer_unref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2035 xfer->data = ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2036
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2037 gaim_xfer_set_init_fnc(xfer, ft_incoming_init);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2038 gaim_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2039 gaim_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2040
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2041 gaim_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2042 gaim_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2043 gaim_xfer_set_message(xfer, mwFileTransfer_getMessage(ft));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2044
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2045 gaim_xfer_request(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2046 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2047
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2048
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2049 static void ft_send(struct mwFileTransfer *ft, FILE *fp) {
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
2050 guchar buf[BUF_LONG];
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2051 struct mwOpaque o = { .data = buf, .len = BUF_LONG };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2052 guint32 rem;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2053 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2054
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2055 xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2056
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2057 rem = mwFileTransfer_getRemaining(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2058 if(rem < BUF_LONG) o.len = rem;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2059
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2060 if(fread(buf, (size_t) o.len, 1, fp)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2061
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2062 /* calculate progress first. update is displayed upon ack */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2063 xfer->bytes_sent += o.len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2064 xfer->bytes_remaining -= o.len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2065
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2066 /* ... send data second */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2067 mwFileTransfer_send(ft, &o);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2068
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2069 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2070 int err = errno;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2071 DEBUG_WARN("problem reading from file %s: %s",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2072 NSTR(mwFileTransfer_getFileName(ft)), strerror(err));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2073
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2074 mwFileTransfer_cancel(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2075 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2076 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2077
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2078
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2079 static gboolean ft_idle_cb(struct mwFileTransfer *ft) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2080 GaimXfer *xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2081 g_return_val_if_fail(xfer != NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2082
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2083 xfer->watcher = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2084 ft_send(ft, xfer->dest_fp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2085
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2086 return FALSE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2087 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2088
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2089
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2090 static void mw_ft_opened(struct mwFileTransfer *ft) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2091 /*
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2092 - get gaim ft from client data in ft
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2093 - set the state to active
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2094 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2095
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2096 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2097
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2098 xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2099
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2100 if(! xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2101 mwFileTransfer_cancel(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2102 mwFileTransfer_free(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2103 g_return_if_reached();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2104 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2105
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2106 gaim_xfer_update_progress(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2107
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2108 if(gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2109 xfer->watcher = g_idle_add((GSourceFunc)ft_idle_cb, ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2110 xfer->dest_fp = g_fopen(xfer->local_filename, "rb");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2111 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2112 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2113
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2114
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2115 static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2116 /*
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2117 - get gaim ft from client data in ft
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2118 - indicate rejection/cancelation/completion
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2119 - free the file transfer itself
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2120 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2121
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2122 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2123
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2124 xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2125 if(xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2126 xfer->data = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2127
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2128 if(mwFileTransfer_isDone(ft)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2129 gaim_xfer_set_completed(xfer, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2130 gaim_xfer_end(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2131
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2132 } else if(mwFileTransfer_isCancelLocal(ft)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2133 /* calling gaim_xfer_cancel_local is redundant, since that's
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2134 probably what triggered this function to be called */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2135 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2136
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2137 } else if(mwFileTransfer_isCancelRemote(ft)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2138 /* steal the reference for the xfer */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2139 mwFileTransfer_setClientData(ft, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2140 gaim_xfer_cancel_remote(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2141
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2142 /* drop the stolen reference */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2143 gaim_xfer_unref(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2144 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2145 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2146 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2147
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2148 mwFileTransfer_free(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2149 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2150
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2151
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2152 static void mw_ft_recv(struct mwFileTransfer *ft,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2153 struct mwOpaque *data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2154 /*
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2155 - get gaim ft from client data in ft
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2156 - update transfered percentage
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2157 - if done, destroy the ft, disassociate from gaim ft
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2158 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2159
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2160 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2161 FILE *fp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2162
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2163 xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2164 g_return_if_fail(xfer != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2165
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2166 fp = xfer->dest_fp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2167 g_return_if_fail(fp != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2168
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2169 /* we must collect and save our precious data */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2170 fwrite(data->data, 1, data->len, fp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2171
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2172 /* update the progress */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2173 xfer->bytes_sent += data->len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2174 xfer->bytes_remaining -= data->len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2175 gaim_xfer_update_progress(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2176
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2177 /* let the other side know we got it, and to send some more */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2178 mwFileTransfer_ack(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2179 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2180
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2181
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2182 static void mw_ft_ack(struct mwFileTransfer *ft) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2183 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2184
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2185 xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2186 g_return_if_fail(xfer != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2187 g_return_if_fail(xfer->watcher == 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2188
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2189 gaim_xfer_update_progress(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2190
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2191 if(mwFileTransfer_isOpen(ft))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2192 xfer->watcher = g_idle_add((GSourceFunc)ft_idle_cb, ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2193 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2194
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2195
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2196 static void mw_ft_clear(struct mwServiceFileTransfer *srvc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2197 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2198 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2199
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2200
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2201 static struct mwFileTransferHandler mw_ft_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2202 .ft_offered = mw_ft_offered,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2203 .ft_opened = mw_ft_opened,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2204 .ft_closed = mw_ft_closed,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2205 .ft_recv = mw_ft_recv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2206 .ft_ack = mw_ft_ack,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2207 .clear = mw_ft_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2208 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2209
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2210
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2211 static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2212 struct mwServiceFileTransfer *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2213 GHashTable *ft_map;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2214
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2215 ft_map = g_hash_table_new(g_direct_hash, g_direct_equal);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2216
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2217 srvc = mwServiceFileTransfer_new(s, &mw_ft_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2218 mwService_setClientData(MW_SERVICE(srvc), ft_map,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2219 (GDestroyNotify) g_hash_table_destroy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2220
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2221 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2222 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2223
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2224
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2225 static void convo_data_free(struct convo_data *cd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2226 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2227
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2228 /* clean the queue */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2229 for(l = cd->queue; l; l = g_list_delete_link(l, l)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2230 struct convo_msg *m = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2231 if(m->clear) m->clear(m->data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2232 g_free(m);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2233 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2234
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2235 g_free(cd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2236 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2237
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2238
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2239 /** allocates a convo_data structure and associates it with the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2240 conversation in the client data slot */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2241 static void convo_data_new(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2242 struct convo_data *cd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2243
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2244 g_return_if_fail(conv != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2245
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2246 if(mwConversation_getClientData(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2247 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2248
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2249 cd = g_new0(struct convo_data, 1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2250 cd->conv = conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2251
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2252 mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2253 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2254
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2255
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2256 static GaimConversation *convo_get_gconv(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2257 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2258 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2259 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2260 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2261 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2262
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2263 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2264
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2265 srvc = mwConversation_getService(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2266 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2267 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2268 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2269 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2270
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2271 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2272
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2273 return gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2274 idb->user, acct);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2275 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2276
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2277
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2278 static void convo_queue(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2279 enum mwImSendType type, gconstpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2280
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2281 struct convo_data *cd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2282 struct convo_msg *m;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2283
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2284 convo_data_new(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2285 cd = mwConversation_getClientData(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2286
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2287 m = g_new0(struct convo_msg, 1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2288 m->type = type;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2289
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2290 switch(type) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2291 case mwImSend_PLAIN:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2292 m->data = g_strdup(data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2293 m->clear = g_free;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2294 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2295
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2296 case mwImSend_TYPING:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2297 default:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2298 m->data = (gpointer) data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2299 m->clear = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2300 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2301
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2302 cd->queue = g_list_append(cd->queue, m);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2303 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2304
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2305
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2306 /* Does what it takes to get an error displayed for a conversation */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2307 static void convo_error(struct mwConversation *conv, guint32 err) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2308 GaimConversation *gconv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2309 char *tmp, *text;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2310 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2311
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2312 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2313
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2314 tmp = mwError(err);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2315 text = g_strconcat(_("Unable to send message: "), tmp, NULL);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2316
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2317 gconv = convo_get_gconv(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2318 if(gconv && !gaim_conv_present_error(idb->user, gconv->account, text)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2319
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2320 g_free(text);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2321 text = g_strdup_printf(_("Unable to send message to %s:"),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2322 (idb->user)? idb->user: "(unknown)");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2323 gaim_notify_error(gaim_account_get_connection(gconv->account),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2324 NULL, text, tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2325 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2326
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2327 g_free(tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2328 g_free(text);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2329 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2330
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2331
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2332 static void convo_queue_send(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2333 struct convo_data *cd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2334 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2335
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2336 cd = mwConversation_getClientData(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2337
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2338 for(l = cd->queue; l; l = g_list_delete_link(l, l)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2339 struct convo_msg *m = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2340
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2341 mwConversation_send(conv, m->type, m->data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2342
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2343 if(m->clear) m->clear(m->data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2344 g_free(m);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2345 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2346
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2347 cd->queue = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2348 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2349
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2350
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2351 /** called when a mw conversation leaves a gaim conversation to
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2352 inform the gaim conversation that it's unsafe to offer any *cool*
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2353 features. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2354 static void convo_nofeatures(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2355 GaimConversation *gconv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2356 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2357
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2358 gconv = convo_get_gconv(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2359 if(! gconv) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2360
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2361 gc = gaim_conversation_get_gc(gconv);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2362 if(! gc) return;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2363
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2364 gaim_conversation_set_features(gconv, gc->flags);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2365 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2366
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2367
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2368 /** called when a mw conversation and gaim conversation come together,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2369 to inform the gaim conversation of what features to offer the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2370 user */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2371 static void convo_features(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2372 GaimConversation *gconv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2373 GaimConnectionFlags feat;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2374
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2375 gconv = convo_get_gconv(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2376 if(! gconv) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2377
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2378 feat = gaim_conversation_get_features(gconv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2379
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2380 if(mwConversation_isOpen(conv)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2381 if(mwConversation_supports(conv, mwImSend_HTML)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2382 feat |= GAIM_CONNECTION_HTML;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2383 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2384 feat &= ~GAIM_CONNECTION_HTML;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2385 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2386
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2387 if(mwConversation_supports(conv, mwImSend_MIME)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2388 feat &= ~GAIM_CONNECTION_NO_IMAGES;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2389 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2390 feat |= GAIM_CONNECTION_NO_IMAGES;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2391 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2392
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2393 DEBUG_INFO("conversation features set to 0x%04x\n", feat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2394 gaim_conversation_set_features(gconv, feat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2395
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2396 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2397 convo_nofeatures(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2398 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2399 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2400
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2401
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2402 #if 0
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2403 /** triggered from mw_conversation_opened if the appropriate plugin
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2404 preference is set. This will open a window for the conversation
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2405 before the first message is sent. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2406 static void convo_do_psychic(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2407 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2408 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2409 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2410 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2411 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2412
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2413 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2414
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2415 GaimConversation *gconv;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2416 GaimConvWindow *win;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2417
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2418 srvc = mwConversation_getService(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2419 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2420 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2421 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2422 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2423
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2424 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2425
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2426 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2427 idb->user, acct);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2428 if(! gconv) {
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11257
diff changeset
2429 gconv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, idb->user);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2430 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2431
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2432 g_return_if_fail(gconv != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2433
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2434 win = gaim_conversation_get_window(gconv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2435 g_return_if_fail(win != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2436
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2437 gaim_conv_window_show(win);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2438 }
11547
726264a8f48f [gaim-migrate @ 13802]
Tim Ringenbach <marv@pidgin.im>
parents: 11536
diff changeset
2439 #endif
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2440
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2441
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2442 static void mw_conversation_opened(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2443 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2444 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2445 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2446 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2447 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2448
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2449 struct convo_dat *cd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2450
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2451 srvc = mwConversation_getService(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2452 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2453 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2454 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2455 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2456
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2457 /* set up the queue */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2458 cd = mwConversation_getClientData(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2459 if(cd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2460 convo_queue_send(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2461
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2462 if(! convo_get_gconv(conv)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2463 mwConversation_free(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2464 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2465 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2466
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2467 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2468 convo_data_new(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2469 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2470
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2471 { /* record the client key for the buddy */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2472 GaimBuddy *buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2473 struct mwLoginInfo *info;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2474 info = mwConversation_getTargetInfo(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2475
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2476 buddy = gaim_find_buddy(acct, info->user_id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2477 if(buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2478 gaim_blist_node_set_int((GaimBlistNode *) buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2479 BUDDY_KEY_CLIENT, info->type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2480 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2481 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2482
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2483 convo_features(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2484 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2485
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2486
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2487 static void mw_conversation_closed(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2488 guint32 reason) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2489
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2490 struct convo_data *cd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2491
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2492 g_return_if_fail(conv != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2493
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2494 /* if there's an error code and a non-typing message in the queue,
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2495 print an error message to the conversation */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2496 cd = mwConversation_getClientData(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2497 if(reason && cd && cd->queue) {
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2498 GList *l;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2499 for(l = cd->queue; l; l = l->next) {
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2500 struct convo_msg *m = l->data;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2501 if(m->type != mwImSend_TYPING) {
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2502 convo_error(conv, reason);
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2503 break;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2504 }
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2505 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2506 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2507
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2508 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2509 /* don't do this, to prevent the occasional weird sending of
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2510 formatted messages as plaintext when the other end closes the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2511 conversation after we've begun composing the message */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2512 convo_nofeatures(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2513 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2514
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2515 mwConversation_removeClientData(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2516 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2517
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2518
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2519 static void im_recv_text(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2520 struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2521 const char *msg) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2522
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2523 struct mwIdBlock *idb;
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2524 char *txt, *esc;
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2525 const char *t;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2526
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2527 idb = mwConversation_getTarget(conv);
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2528
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2529 txt = gaim_utf8_try_convert(msg);
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2530 t = txt? txt: msg;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2531
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2532 esc = g_markup_escape_text(t, -1);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2533 serv_got_im(pd->gc, idb->user, esc, 0, time(NULL));
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2534 g_free(esc);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2535
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2536 g_free(txt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2537 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2538
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2539
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2540 static void im_recv_typing(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2541 struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2542 gboolean typing) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2543
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2544 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2545 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2546
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2547 serv_got_typing(pd->gc, idb->user, 0,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2548 typing? GAIM_TYPING: GAIM_NOT_TYPING);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2549 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2550
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2551
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2552 static void im_recv_html(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2553 struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2554 const char *msg) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2555 struct mwIdBlock *idb;
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2556 char *t1, *t2;
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2557 const char *t;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2558
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2559 idb = mwConversation_getTarget(conv);
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2560
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2561 /* ensure we're receiving UTF8 */
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2562 t1 = gaim_utf8_try_convert(msg);
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2563 t = t1? t1: msg;
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2564
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2565 /* convert entities to UTF8 so they'll log correctly */
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2566 t2 = gaim_utf8_ncr_decode(t);
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2567 t = t2? t2: t;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2568
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2569 serv_got_im(pd->gc, idb->user, t, 0, time(NULL));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2570
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2571 g_free(t1);
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2572 g_free(t2);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2573 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2574
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2575
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2576 static void im_recv_subj(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2577 struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2578 const char *subj) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2579
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2580 /** @todo somehow indicate receipt of a conversation subject. It
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2581 would also be nice if we added a /topic command for the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2582 protocol */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2583 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2584 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2585
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2586
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2587 /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2588 static char *make_cid(const char *cid) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2589 gsize n;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2590 char *c, *d;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2591
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2592 g_return_val_if_fail(cid != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2593
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2594 n = strlen(cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2595 g_return_val_if_fail(n > 2, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2596
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2597 c = g_strndup(cid+1, n-2);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2598 d = g_strdup_printf("cid:%s", c);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2599
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2600 g_free(c);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2601 return d;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2602 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2603
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2604
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2605 static void im_recv_mime(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2606 struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2607 const char *data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2608
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2609 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2610
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2611 GHashTable *img_by_cid;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2612 GList *images;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2613
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2614 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2615
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2616 GaimMimeDocument *doc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2617 const GList *parts;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2618
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2619 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2620
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2621 img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2622 images = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2623
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2624 /* don't want the contained string to ever be NULL */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2625 str = g_string_new("");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2626
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2627 doc = gaim_mime_document_parse(data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2628
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2629 /* handle all the MIME parts */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2630 parts = gaim_mime_document_get_parts(doc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2631 for(; parts; parts = parts->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2632 GaimMimePart *part = parts->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2633 const char *type;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2634
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2635 type = gaim_mime_part_get_field(part, "content-type");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2636 DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2637
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2638 if(! type) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2639 ; /* feh */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2640
12166
d6417efb990c [gaim-migrate @ 14467]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12147
diff changeset
2641 } else if(gaim_str_has_prefix(type, "image")) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2642 /* put images into the image store */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2643
11183
8dca96cbcd64 [gaim-migrate @ 13295]
Mark Doliner <mark@kingant.net>
parents: 11133
diff changeset
2644 guchar *d_dat;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2645 gsize d_len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2646 char *cid;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2647 int img;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2648
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2649 /* obtain and unencode the data */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2650 gaim_mime_part_get_data_decoded(part, &d_dat, &d_len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2651
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2652 /* look up the content id */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2653 cid = (char *) gaim_mime_part_get_field(part, "Content-ID");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2654 cid = make_cid(cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2655
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2656 /* add image to the gaim image store */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2657 img = gaim_imgstore_add(d_dat, d_len, cid);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2658 g_free(d_dat);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2659
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2660 /* map the cid to the image store identifier */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2661 g_hash_table_insert(img_by_cid, cid, GINT_TO_POINTER(img));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2662
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2663 /* recall the image for dereferencing later */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2664 images = g_list_append(images, GINT_TO_POINTER(img));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2665
12166
d6417efb990c [gaim-migrate @ 14467]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12147
diff changeset
2666 } else if(gaim_str_has_prefix(type, "text")) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2667
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2668 /* concatenate all the text parts together */
11183
8dca96cbcd64 [gaim-migrate @ 13295]
Mark Doliner <mark@kingant.net>
parents: 11133
diff changeset
2669 guchar *data;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2670 gsize len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2671
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2672 gaim_mime_part_get_data_decoded(part, &data, &len);
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2673 g_string_append(str, (const char *)data);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
2674 g_free(data);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2675 }
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2676 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2677
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2678 gaim_mime_document_free(doc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2679
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2680 /* @todo should put this in its own function */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2681 { /* replace each IMG tag's SRC attribute with an ID attribute. This
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2682 actually modifies the contents of str */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2683 GData *attribs;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2684 char *start, *end;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2685 char *tmp = str->str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2686
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2687 while(*tmp && gaim_markup_find_tag("img", tmp, (const char **) &start,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2688 (const char **) &end, &attribs)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2689
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2690 char *alt, *align, *border, *src;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2691 int img;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2692
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2693 alt = g_datalist_get_data(&attribs, "alt");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2694 align = g_datalist_get_data(&attribs, "align");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2695 border = g_datalist_get_data(&attribs, "border");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2696 src = g_datalist_get_data(&attribs, "src");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2697
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2698 img = GPOINTER_TO_INT(g_hash_table_lookup(img_by_cid, src));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2699 if(img) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2700 GString *atstr;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2701 gsize len = (end - start);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2702 gsize mov;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2703
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2704 atstr = g_string_new("");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2705 if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2706 if(align) g_string_append_printf(atstr, " align=\"%s\"", align);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2707 if(border) g_string_append_printf(atstr, " border=\"%s\"", border);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2708
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2709 mov = g_snprintf(start, len, "<img%s id=\"%i\"", atstr->str, img);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2710 while(mov < len) start[mov++] = ' ';
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2711
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2712 g_string_free(atstr, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2713 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2714
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2715 g_datalist_clear(&attribs);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2716 tmp = end + 1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2717 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2718 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2719
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
2720 im_recv_html(conv, pd, str->str);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2721
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2722 g_string_free(str, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2723
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2724 /* clean up the cid table */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2725 g_hash_table_destroy(img_by_cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2726
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2727 /* dereference all the imgages */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2728 while(images) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2729 gaim_imgstore_unref(GPOINTER_TO_INT(images->data));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2730 images = g_list_delete_link(images, images);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2731 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2732 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2733
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2734
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2735 static void mw_conversation_recv(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2736 enum mwImSendType type,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2737 gconstpointer msg) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2738 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2739 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2740 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2741
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2742 srvc = mwConversation_getService(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2743 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2744 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2745
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2746 switch(type) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2747 case mwImSend_PLAIN:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2748 im_recv_text(conv, pd, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2749 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2750
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2751 case mwImSend_TYPING:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2752 im_recv_typing(conv, pd, !! msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2753 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2754
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2755 case mwImSend_HTML:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2756 im_recv_html(conv, pd, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2757 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2758
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2759 case mwImSend_SUBJECT:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2760 im_recv_subj(conv, pd, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2761 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2762
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2763 case mwImSend_MIME:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2764 im_recv_mime(conv, pd, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2765 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2766
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2767 default:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2768 DEBUG_INFO("conversation received strange type, 0x%04x\n", type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2769 ; /* erm... */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2770 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2771 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2772
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2773
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2774 static void mw_place_invite(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2775 const char *message,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2776 const char *title, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2777 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2778 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2779 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2780
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2781 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2782 GHashTable *ht;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2783
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2784 srvc = mwConversation_getService(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2785 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2786 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2787
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2788 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2789
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2790 ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2791 g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2792 g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2793 g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2794 g_hash_table_insert(ht, CHAT_KEY_INVITE, g_strdup(message));
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2795 g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2796
12742
258871a62600 [gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents: 12735
diff changeset
2797 if(! title) title = "(no title)";
258871a62600 [gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents: 12735
diff changeset
2798 if(! message) message = "(no message)";
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2799 serv_got_chat_invite(pd->gc, title, idb->user, message, ht);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2800
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2801 mwConversation_close(conv, ERR_SUCCESS);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2802 mwConversation_free(conv);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2803 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2804
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2805
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2806 static void mw_im_clear(struct mwServiceIm *srvc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2807 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2808 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2809
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2810
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2811 static struct mwImHandler mw_im_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2812 .conversation_opened = mw_conversation_opened,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2813 .conversation_closed = mw_conversation_closed,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2814 .conversation_recv = mw_conversation_recv,
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2815 .place_invite = mw_place_invite,
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2816 .clear = mw_im_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2817 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2818
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2819
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2820 static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2821 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2822 srvc = mwServiceIm_new(s, &mw_im_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2823 mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2824 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2825 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2826
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2827
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2828 /* The following helps us relate a mwPlace to a GaimConvChat in the
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2829 various forms by which either may be indicated. Uses some of
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2830 the similar macros from the conference service above */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2831
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2832 #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place))
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2833 #define ID_TO_PLACE(pd, id) (place_find_by_id((pd), (id)))
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2834
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2835 #define CHAT_TO_PLACE(pd, chat) (ID_TO_PLACE((pd), CHAT_TO_ID(chat)))
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2836 #define PLACE_TO_CHAT(place) (ID_TO_CHAT(PLACE_TO_ID(place)))
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2837
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2838
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2839 static struct mwPlace *
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2840 place_find_by_id(struct mwGaimPluginData *pd, int id) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2841 struct mwServicePlace *srvc = pd->srvc_place;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2842 struct mwPlace *place = NULL;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2843 GList *l;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2844
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2845 l = (GList *) mwServicePlace_getPlaces(srvc);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2846 for(; l; l = l->next) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2847 struct mwPlace *p = l->data;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2848 GaimConvChat *h = GAIM_CONV_CHAT(mwPlace_getClientData(p));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2849
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2850 if(CHAT_TO_ID(h) == id) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2851 place = p;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2852 break;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2853 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2854 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2855
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2856 return place;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2857 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2858
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2859
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2860 static void mw_place_opened(struct mwPlace *place) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2861 struct mwServicePlace *srvc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2862 struct mwSession *session;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2863 struct mwGaimPluginData *pd;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2864 GaimConnection *gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2865 GaimConversation *gconf;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2866
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2867 GList *members, *l;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2868
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2869 const char *n = mwPlace_getName(place);
12742
258871a62600 [gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents: 12735
diff changeset
2870 const char *t = mwPlace_getTitle(place);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2871
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2872 srvc = mwPlace_getService(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2873 session = mwService_getSession(MW_SERVICE(srvc));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2874 pd = mwSession_getClientData(session);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2875 gc = pd->gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2876
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2877 members = mwPlace_getMembers(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2878
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2879 DEBUG_INFO("place %s opened, %u initial members\n",
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2880 NSTR(n), g_list_length(members));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2881
12742
258871a62600 [gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents: 12735
diff changeset
2882 if(! t) t = "(no title)";
258871a62600 [gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents: 12735
diff changeset
2883 gconf = serv_got_joined_chat(gc, PLACE_TO_ID(place), t);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2884
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2885 mwPlace_setClientData(place, gconf, NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2886
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2887 for(l = members; l; l = l->next) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2888 struct mwIdBlock *idb = l->data;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2889 gaim_conv_chat_add_user(GAIM_CONV_CHAT(gconf), idb->user,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2890 NULL, GAIM_CBFLAGS_NONE, FALSE);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2891 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2892 g_list_free(members);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2893 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2894
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2895
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2896 static void mw_place_closed(struct mwPlace *place, guint32 code) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2897 struct mwServicePlace *srvc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2898 struct mwSession *session;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2899 struct mwGaimPluginData *pd;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2900 GaimConnection *gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2901
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2902 const char *n = mwPlace_getName(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2903 char *msg = mwError(code);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2904
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2905 DEBUG_INFO("place %s closed, 0x%08x\n", NSTR(n), code);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2906
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2907 srvc = mwPlace_getService(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2908 session = mwService_getSession(MW_SERVICE(srvc));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2909 pd = mwSession_getClientData(session);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2910 gc = pd->gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2911
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2912 serv_got_chat_left(gc, PLACE_TO_ID(place));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2913
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2914 gaim_notify_error(gc, _("Place Closed"), NULL, msg);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2915 g_free(msg);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2916 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2917
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2918
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2919 static void mw_place_peerJoined(struct mwPlace *place,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2920 const struct mwIdBlock *peer) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2921 struct mwServicePlace *srvc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2922 struct mwSession *session;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2923 struct mwGaimPluginData *pd;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2924 GaimConnection *gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2925 GaimConversation *gconf;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2926
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2927 const char *n = mwPlace_getName(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2928
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2929 DEBUG_INFO("%s joined place %s\n", NSTR(peer->user), NSTR(n));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2930
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2931 srvc = mwPlace_getService(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2932 session = mwService_getSession(MW_SERVICE(srvc));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2933 pd = mwSession_getClientData(session);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2934 gc = pd->gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2935
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2936 gconf = mwPlace_getClientData(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2937 g_return_if_fail(gconf != NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2938
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2939 gaim_conv_chat_add_user(GAIM_CONV_CHAT(gconf), peer->user,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2940 NULL, GAIM_CBFLAGS_NONE, TRUE);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2941 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2942
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2944 static void mw_place_peerParted(struct mwPlace *place,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2945 const struct mwIdBlock *peer) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2946 struct mwServicePlace *srvc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2947 struct mwSession *session;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2948 struct mwGaimPluginData *pd;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2949 GaimConnection *gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2950 GaimConversation *gconf;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2951
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2952 const char *n = mwPlace_getName(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2953
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2954 DEBUG_INFO("%s left place %s\n", NSTR(peer->user), NSTR(n));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2955
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2956 srvc = mwPlace_getService(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2957 session = mwService_getSession(MW_SERVICE(srvc));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2958 pd = mwSession_getClientData(session);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2959 gc = pd->gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2960
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2961 gconf = mwPlace_getClientData(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2962 g_return_if_fail(gconf != NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2963
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2964 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(gconf), peer->user, NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2965 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2966
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2967
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2968 static void mw_place_peerSetAttribute(struct mwPlace *place,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2969 const struct mwIdBlock *peer,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2970 guint32 attr, struct mwOpaque *o) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2971 ;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2972 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2973
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2974
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2975 static void mw_place_peerUnsetAttribute(struct mwPlace *place,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2976 const struct mwIdBlock *peer,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2977 guint32 attr) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2978 ;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2979 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2980
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2981
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2982 static void mw_place_message(struct mwPlace *place,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2983 const struct mwIdBlock *who,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2984 const char *msg) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2985 struct mwServicePlace *srvc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2986 struct mwSession *session;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2987 struct mwGaimPluginData *pd;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2988 GaimConnection *gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2989 char *esc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2990
12863
7a2169f04bdf [gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents: 12830
diff changeset
2991 if(! msg) return;
7a2169f04bdf [gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents: 12830
diff changeset
2992
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2993 srvc = mwPlace_getService(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2994 session = mwService_getSession(MW_SERVICE(srvc));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2995 pd = mwSession_getClientData(session);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2996 gc = pd->gc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2997
12864
2c0f8815aa2e [gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents: 12863
diff changeset
2998 esc = g_markup_escape_text(msg, -1);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
2999 serv_got_chat_in(gc, PLACE_TO_ID(place), who->user, 0, esc, time(NULL));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3000 g_free(esc);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3001 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3002
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3003
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3004 static void mw_place_clear(struct mwServicePlace *srvc) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3005 ;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3006 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3007
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3008
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3009 static struct mwPlaceHandler mw_place_handler = {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3010 .opened = mw_place_opened,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3011 .closed = mw_place_closed,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3012 .peerJoined = mw_place_peerJoined,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3013 .peerParted = mw_place_peerParted,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3014 .peerSetAttribute = mw_place_peerSetAttribute,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3015 .peerUnsetAttribute = mw_place_peerUnsetAttribute,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3016 .message = mw_place_message,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3017 .clear = mw_place_clear,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3018 };
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3019
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3020
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3021 static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3022 struct mwServicePlace *srvc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3023 srvc = mwServicePlace_new(s, &mw_place_handler);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3024 return srvc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3025 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3026
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3027
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3028 static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3029 struct mwServiceResolve *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3030 srvc = mwServiceResolve_new(s);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3031 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3032 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3033
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3034
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3035 static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3036 struct mwServiceStorage *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3037 srvc = mwServiceStorage_new(s);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3038 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3039 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3040
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3041
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3042 /** allocate and associate a mwGaimPluginData with a GaimConnection */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3043 static struct mwGaimPluginData *mwGaimPluginData_new(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3044 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3045
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3046 g_return_val_if_fail(gc != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3047
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3048 pd = g_new0(struct mwGaimPluginData, 1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3049 pd->gc = gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3050 pd->session = mwSession_new(&mw_session_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3051 pd->srvc_aware = mw_srvc_aware_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3052 pd->srvc_conf = mw_srvc_conf_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3053 pd->srvc_ft = mw_srvc_ft_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3054 pd->srvc_im = mw_srvc_im_new(pd->session);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3055 pd->srvc_place = mw_srvc_place_new(pd->session);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3056 pd->srvc_resolve = mw_srvc_resolve_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3057 pd->srvc_store = mw_srvc_store_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3058 pd->group_list_map = g_hash_table_new(g_direct_hash, g_direct_equal);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3059
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3060 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3061 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3062 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3063 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im));
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3064 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3065 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3066 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3067
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3068 mwSession_addCipher(pd->session, mwCipher_new_RC2_40(pd->session));
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3069 mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3070
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3071 mwSession_setClientData(pd->session, pd, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3072 gc->proto_data = pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3073
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3074 return pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3075 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3076
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3077
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3078 static void mwGaimPluginData_free(struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3079 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3080
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3081 pd->gc->proto_data = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3082
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3083 mwSession_removeService(pd->session, mwService_AWARE);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3084 mwSession_removeService(pd->session, mwService_CONFERENCE);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3085 mwSession_removeService(pd->session, mwService_FILE_TRANSFER);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3086 mwSession_removeService(pd->session, mwService_IM);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3087 mwSession_removeService(pd->session, mwService_PLACE);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3088 mwSession_removeService(pd->session, mwService_RESOLVE);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3089 mwSession_removeService(pd->session, mwService_STORAGE);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3090
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3091 mwService_free(MW_SERVICE(pd->srvc_aware));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3092 mwService_free(MW_SERVICE(pd->srvc_conf));
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3093 mwService_free(MW_SERVICE(pd->srvc_ft));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3094 mwService_free(MW_SERVICE(pd->srvc_im));
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3095 mwService_free(MW_SERVICE(pd->srvc_place));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3096 mwService_free(MW_SERVICE(pd->srvc_resolve));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3097 mwService_free(MW_SERVICE(pd->srvc_store));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3098
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3099 mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40));
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3100 mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3101
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3102 mwSession_free(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3103
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3104 g_hash_table_destroy(pd->group_list_map);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3105
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3106 g_free(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3107 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3108
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3109
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3110 static const char *mw_prpl_list_icon(GaimAccount *a, GaimBuddy *b) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3111 /* my little green dude is a chopped up version of the aim running
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3112 guy. First, cut off the head and store someplace safe. Then,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3113 take the left-half side of the body and throw it away. Make a
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3114 copy of the remaining body, and flip it horizontally. Now attach
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3115 the two pieces into an X shape, and drop the head back on the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3116 top, being careful to center it. Then, just change the color
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3117 saturation to bring the red down a bit, and voila! */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3118
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3119 /* then, throw all of that away and use sodipodi to make a new
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3120 icon. You know, LIKE A REAL MAN. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3121
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3122 return "meanwhile";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3123 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3124
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3125
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3126 static void mw_prpl_list_emblems(GaimBuddy *b,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3127 const char **se, const char **sw,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3128 const char **nw, const char **ne) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3129
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3130 /* speaking of custom icons, the external icon here is an ugly
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3131 little example of what happens when I use Gimp */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3132
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3133 GaimPresence *presence;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3134 GaimStatus *status;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3135 const char *status_id;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3136
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3137 presence = gaim_buddy_get_presence(b);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3138 status = gaim_presence_get_active_status(presence);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3139 status_id = gaim_status_get_id(status);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3140
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3141 if(! GAIM_BUDDY_IS_ONLINE(b)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3142 *se = "offline";
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3143 } else if(!strcmp(status_id, MW_STATE_AWAY)) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3144 *se = "away";
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3145 } else if(!strcmp(status_id, MW_STATE_BUSY)) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3146 *se = "dnd";
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3147 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3148
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3149 if(buddy_is_external(b)) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3150 /* best assignment ever */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3151 *(*se?sw:se) = "external";
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3152 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3153 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3154
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3155
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3156 static char *mw_prpl_status_text(GaimBuddy *b) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3157 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3158 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3159 struct mwAwareIdBlock t = { mwAware_USER, b->name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3160 const char *ret;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3161
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3162 gc = b->account->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3163 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3164
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3165 ret = mwServiceAware_getText(pd->srvc_aware, &t);
12496
f9d0ab1474ac [gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents: 12489
diff changeset
3166 return ret? g_markup_escape_text(ret, -1): NULL;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3167 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3168
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3169
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3170 static const char *status_text(GaimBuddy *b) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3171 GaimPresence *presence;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3172 GaimStatus *status;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3173
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3174 presence = gaim_buddy_get_presence(b);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3175 status = gaim_presence_get_active_status(presence);
11536
16796e09b9c1 [gaim-migrate @ 13790]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11533
diff changeset
3176
16796e09b9c1 [gaim-migrate @ 13790]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11533
diff changeset
3177 return gaim_status_get_name(status);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3178 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3179
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3180
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3181 static gboolean user_supports(struct mwServiceAware *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3182 const char *who, guint32 feature) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3183
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3184 const struct mwAwareAttribute *attr;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3185 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3186
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3187 attr = mwServiceAware_getAttribute(srvc, &idb, feature);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3188 return (attr != NULL) && mwAwareAttribute_asBoolean(attr);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3189 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3190
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3191
12422
fe42d9c111f9 [gaim-migrate @ 14729]
Richard Laager <rlaager@wiktel.com>
parents: 12312
diff changeset
3192 static char *user_supports_text(struct mwServiceAware *srvc, const char *who) {
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3193 char *feat[] = {NULL, NULL, NULL, NULL, NULL};
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3194 char **f = feat;
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3195
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3196 if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) {
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3197 gboolean mic, speak, video;
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3198
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3199 mic = user_supports(srvc, who, mwAttribute_MICROPHONE);
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3200 speak = user_supports(srvc, who, mwAttribute_SPEAKERS);
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3201 video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA);
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3202
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3203 if(mic) *f++ = _("Microphone");
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3204 if(speak) *f++ = _("Speakers");
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3205 if(video) *f++ = _("Video Camera");
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3206 }
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3207
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3208 if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER))
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3209 *f++ = _("File Transfer");
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3210
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3211 return (*feat)? g_strjoinv(", ", feat): NULL;
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3212 /* jenni loves siege */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3213 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3214
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3215
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3216 static char *mw_prpl_tooltip_text(GaimBuddy *b) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3217 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3218 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3219 struct mwAwareIdBlock idb = { mwAware_USER, b->name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3220
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3221 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3222 const char *tmp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3223
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3224 gc = b->account->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3225 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3226
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3227 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3228
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3229 tmp = status_text(b);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3230 g_string_append_printf(str, _("\n<b>Status</b>: %s"), tmp);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3231
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3232 tmp = mwServiceAware_getText(pd->srvc_aware, &idb);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3233 if(tmp) {
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3234 tmp = g_markup_escape_text(tmp, -1);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3235 g_string_append_printf(str, _("\n<b>Message</b>: %s"), tmp);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3236 g_free((char *) tmp);
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3237 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3238
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3239 tmp = user_supports_text(pd->srvc_aware, b->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3240 if(tmp) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3241 g_string_append_printf(str, _("\n<b>Supports</b>: %s"), tmp);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3242 g_free((char *) tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3243 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3244
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3245 if(buddy_is_external(b)) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3246 g_string_append(str, _("\n<b>External User</b>"));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3247 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3248
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3249 tmp = str->str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3250 g_string_free(str, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3251 return (char *) tmp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3252 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3253
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3254
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3255 static GList *mw_prpl_status_types(GaimAccount *acct) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3256 GList *types = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3257 GaimStatusType *type;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3258
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3259 type = gaim_status_type_new(GAIM_STATUS_AVAILABLE, MW_STATE_ACTIVE,
12830
3b4a6e426b99 [gaim-migrate @ 15178]
Christopher O'Brien <siege@pidgin.im>
parents: 12829
diff changeset
3260 _("Available"), TRUE);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3261 gaim_status_type_add_attr(type, MW_STATE_MESSAGE, _("Message"),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3262 gaim_value_new(GAIM_TYPE_STRING));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3263 types = g_list_append(types, type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3264
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3265 type = gaim_status_type_new(GAIM_STATUS_AWAY, MW_STATE_AWAY,
12595
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12524
diff changeset
3266 NULL, TRUE);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3267 gaim_status_type_add_attr(type, MW_STATE_MESSAGE, _("Message"),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3268 gaim_value_new(GAIM_TYPE_STRING));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3269 types = g_list_append(types, type);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3270
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3271 type = gaim_status_type_new(GAIM_STATUS_UNAVAILABLE, MW_STATE_BUSY,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3272 _("Do Not Disturb"), TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3273 gaim_status_type_add_attr(type, MW_STATE_MESSAGE, _("Message"),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3274 gaim_value_new(GAIM_TYPE_STRING));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3275 types = g_list_append(types, type);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3276
12658
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12650
diff changeset
3277 type = gaim_status_type_new(GAIM_STATUS_OFFLINE, MW_STATE_OFFLINE,
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12650
diff changeset
3278 NULL, TRUE);
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12650
diff changeset
3279 types = g_list_append(types, type);
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12650
diff changeset
3280
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3281 return types;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3282 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3283
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3284
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3285 static void conf_create_prompt_cancel(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3286 GaimRequestFields *fields) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3287 ; /* nothing to do */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3288 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3289
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3290
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3291 static void conf_create_prompt_join(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3292 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3293 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3294 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3295 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3296 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3297
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3298 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3299
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3300 const char *topic, *invite;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3301 struct mwConference *conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3302 struct mwIdBlock idb = { NULL, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3303
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3304 acct = buddy->account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3305 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3306 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3307 srvc = pd->srvc_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3308
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3309 f = gaim_request_fields_get_field(fields, CHAT_KEY_TOPIC);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3310 topic = gaim_request_field_string_get_value(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3311
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3312 f = gaim_request_fields_get_field(fields, CHAT_KEY_INVITE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3313 invite = gaim_request_field_string_get_value(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3314
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3315 conf = mwConference_new(srvc, topic);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3316 mwConference_open(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3317
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3318 idb.user = buddy->name;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3319 mwConference_invite(conf, &idb, invite);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3320 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3321
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3322
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3323 static void blist_menu_conf_create(GaimBuddy *buddy, const char *msg) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3324
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3325 GaimRequestFields *fields;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3326 GaimRequestFieldGroup *g;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3327 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3328
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3329 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3330 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3331
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3332 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3333
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3334 g_return_if_fail(buddy != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3335
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3336 acct = buddy->account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3337 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3338
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3339 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3340 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3341
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3342 fields = gaim_request_fields_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3343
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3344 g = gaim_request_field_group_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3345 gaim_request_fields_add_group(fields, g);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3346
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3347 f = gaim_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3348 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3349
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3350 f = gaim_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3351 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3352
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3353 msgA = _("Create conference with user");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3354 msgB = _("Please enter a topic for the new conference, and an invitation"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3355 " message to be sent to %s");
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3356 msgB = g_strdup_printf(msgB, buddy->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3357
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3358 gaim_request_fields(gc, _("New Conference"),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3359 msgA, msgB, fields,
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3360 _("Create"), G_CALLBACK(conf_create_prompt_join),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3361 _("Cancel"), G_CALLBACK(conf_create_prompt_cancel),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3362 buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3363 g_free(msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3364 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3365
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3366
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3367 static void conf_select_prompt_cancel(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3368 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3369 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3370 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3371
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3372
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3373 static void conf_select_prompt_invite(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3374 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3375 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3376 const GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3377 const char *msg;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3378
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3379 f = gaim_request_fields_get_field(fields, CHAT_KEY_INVITE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3380 msg = gaim_request_field_string_get_value(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3381
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3382 f = gaim_request_fields_get_field(fields, "conf");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3383 l = gaim_request_field_list_get_selected(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3384
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3385 if(l) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3386 gpointer d = gaim_request_field_list_get_data(f, l->data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3387
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3388 if(GPOINTER_TO_INT(d) == 0x01) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3389 blist_menu_conf_create(buddy, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3390
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3391 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3392 struct mwIdBlock idb = { buddy->name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3393 mwConference_invite(d, &idb, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3394 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3395 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3396 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3397
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3398
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3399 static void blist_menu_conf_list(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3400 GList *confs) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3401
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3402 GaimRequestFields *fields;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3403 GaimRequestFieldGroup *g;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3404 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3405
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3406 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3407 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3408
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3409 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3410
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3411 acct = buddy->account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3412 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3413
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3414 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3415 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3416
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3417 fields = gaim_request_fields_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3418
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3419 g = gaim_request_field_group_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3420 gaim_request_fields_add_group(fields, g);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3421
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3422 f = gaim_request_field_list_new("conf", _("Available Conferences"));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3423 gaim_request_field_list_set_multi_select(f, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3424 for(; confs; confs = confs->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3425 struct mwConference *c = confs->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3426 gaim_request_field_list_add(f, mwConference_getTitle(c), c);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3427 }
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3428 gaim_request_field_list_add(f, _("Create New Conference..."),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3429 GINT_TO_POINTER(0x01));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3430 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3431
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3432 f = gaim_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3433 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3434
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3435 msgA = _("Invite user to a conference");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3436 msgB = _("Select a conference from the list below to send an invite to"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3437 " user %s. Select \"Create New Conference\" if you'd like to"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3438 " create a new conference to invite this user to.");
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3439 msgB = g_strdup_printf(msgB, buddy->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3440
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3441 gaim_request_fields(gc, _("Invite to Conference"),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3442 msgA, msgB, fields,
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3443 _("Invite"), G_CALLBACK(conf_select_prompt_invite),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3444 _("Cancel"), G_CALLBACK(conf_select_prompt_cancel),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3445 buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3446 g_free(msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3447 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3448
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3449
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3450 static void blist_menu_conf(GaimBlistNode *node, gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3451 GaimBuddy *buddy = (GaimBuddy *) node;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3452 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3453 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3454 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3455 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3456
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3457 g_return_if_fail(node != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3458 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3459
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3460 acct = buddy->account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3461 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3462
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3463 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3464 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3465
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3466 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3467 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3468
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3469 /*
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3470 - get a list of all conferences on this session
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3471 - if none, prompt to create one, and invite buddy to it
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3472 - else, prompt to select a conference or create one
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3473 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3474
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3475 l = mwServiceConference_getConferences(pd->srvc_conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3476 if(l) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3477 blist_menu_conf_list(buddy, l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3478 g_list_free(l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3479
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3480 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3481 blist_menu_conf_create(buddy, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3482 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3483 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3484
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3485
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3486 static GList *mw_prpl_blist_node_menu(GaimBlistNode *node) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3487 GList *l = NULL;
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12864
diff changeset
3488 GaimMenuAction *act;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3489
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3490 if(! GAIM_BLIST_NODE_IS_BUDDY(node))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3491 return l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3492
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3493 l = g_list_append(l, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3494
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12864
diff changeset
3495 act = gaim_menu_action_new(_("Invite to Conference..."),
12923
f50a99d5ba9b [gaim-migrate @ 15276]
Christopher O'Brien <siege@pidgin.im>
parents: 12921
diff changeset
3496 GAIM_CALLBACK(blist_menu_conf), NULL, NULL);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3497 l = g_list_append(l, act);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3498
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3499 /** note: this never gets called for a GaimGroup, have to use the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3500 blist-node-extended-menu signal for that. The function
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3501 blist_node_menu_cb is assigned to this signal in the function
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3502 services_starting */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3503
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3504 return l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3505 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3506
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3507
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3508 static GList *mw_prpl_chat_info(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3509 GList *l = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3510 struct proto_chat_entry *pce;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3511
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3512 pce = g_new0(struct proto_chat_entry, 1);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3513 pce->label = _("Topic:");
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3514 pce->identifier = CHAT_KEY_TOPIC;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3515 l = g_list_append(l, pce);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3516
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3517 return l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3518 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3519
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3520
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3521 static GHashTable *mw_prpl_chat_info_defaults(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3522 const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3523 GHashTable *table;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3524
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3525 g_return_val_if_fail(gc != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3526
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3527 table = g_hash_table_new_full(g_str_hash, g_str_equal,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3528 NULL, g_free);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3529
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3530 g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3531 g_hash_table_insert(table, CHAT_KEY_INVITE, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3532
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3533 return table;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3534 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3535
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3536
11837
fa742ad8068c [gaim-migrate @ 14128]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
3537 static void mw_prpl_login(GaimAccount *acct);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3538
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3539
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3540 static void prompt_host_cancel_cb(GaimConnection *gc) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3541 gaim_connection_error(gc, _("No Sametime Community Server specified"));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3542 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3543
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3544
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3545 static void prompt_host_ok_cb(GaimConnection *gc, const char *host) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3546 if(host && *host) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3547 GaimAccount *acct = gaim_connection_get_account(gc);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3548 gaim_account_set_string(acct, MW_KEY_HOST, host);
11837
fa742ad8068c [gaim-migrate @ 14128]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
3549 mw_prpl_login(acct);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3550
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3551 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3552 prompt_host_cancel_cb(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3553 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3554 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3555
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3556
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3557 static void prompt_host(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3558 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3559 char *msg;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3560
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3561 acct = gaim_connection_get_account(gc);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3562 msg = _("No host or IP address has been configured for the"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3563 " Meanwhile account %s. Please enter one below to"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3564 " continue logging in.");
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3565 msg = g_strdup_printf(msg, NSTR(gaim_account_get_username(acct)));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3566
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3567 gaim_request_input(gc, _("Meanwhile Connection Setup"),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3568 _("No Sametime Community Server Specified"), msg,
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3569 MW_PLUGIN_DEFAULT_HOST, FALSE, FALSE, NULL,
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3570 _("Connect"), G_CALLBACK(prompt_host_ok_cb),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3571 _("Cancel"), G_CALLBACK(prompt_host_cancel_cb),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3572 gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3573
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3574 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3575 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3576
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3577
11837
fa742ad8068c [gaim-migrate @ 14128]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
3578 static void mw_prpl_login(GaimAccount *account) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3579 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3580 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3581
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3582 char *user, *pass, *host;
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
3583 guint port, client;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3584
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3585 gc = gaim_account_get_connection(account);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3586 pd = mwGaimPluginData_new(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3587
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3588 /* while we do support images, the default is to not offer it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3589 gc->flags |= GAIM_CONNECTION_NO_IMAGES;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3590
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3591 user = g_strdup(gaim_account_get_username(account));
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3592 pass = g_strdup(gaim_account_get_password(account));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3593
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3594 host = strrchr(user, ':');
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3595 if(host) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3596 /* annoying user split from 1.2.0, need to undo it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3597 *host++ = '\0';
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3598 gaim_account_set_string(account, MW_KEY_HOST, host);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3599 gaim_account_set_username(account, user);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3600
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3601 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3602 host = (char *) gaim_account_get_string(account, MW_KEY_HOST,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3603 MW_PLUGIN_DEFAULT_HOST);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3604 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3605
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3606 if(! host || ! *host) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3607 /* somehow, we don't have a host to connect to. Well, we need one
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3608 to actually continue, so let's ask the user directly. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3609 prompt_host(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3610 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3611 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3612
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3613 port = gaim_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3614
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3615 DEBUG_INFO("user: '%s'\n", user);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3616 DEBUG_INFO("host: '%s'\n", host);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3617 DEBUG_INFO("port: %u\n", port);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3618
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3619 mwSession_setProperty(pd->session, mwSession_NO_SECRET,
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3620 (char *) no_secret, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3621 mwSession_setProperty(pd->session, mwSession_AUTH_USER_ID, user, g_free);
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3622 mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free);
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3623
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3624 client = mwLogin_MEANWHILE;
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
3625 if(gaim_account_get_bool(account, MW_KEY_FAKE_IT, FALSE))
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
3626 client = mwLogin_BINARY;
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
3627
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
3628 DEBUG_INFO("client id: 0x%04x\n", client);
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
3629
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3630 mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID,
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
3631 GUINT_TO_POINTER(client), NULL);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3632
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3633 gaim_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3634
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3635 if(gaim_proxy_connect(account, host, port, connect_cb, pd)) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3636 gaim_connection_error(gc, _("Unable to connect to host"));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3637 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3638 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3639
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3640
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3641 static void mw_prpl_close(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3642 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3643
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3644 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3645
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3646 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3647 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3648
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3649 /* get rid of the blist save timeout */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3650 if(pd->save_event) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3651 gaim_timeout_remove(pd->save_event);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3652 pd->save_event = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3653 blist_store(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3654 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3655
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3656 /* stop the session */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3657 mwSession_stop(pd->session, 0x00);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3658
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3659 /* no longer necessary */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3660 gc->proto_data = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3661
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3662 /* stop watching the socket */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3663 if(gc->inpa) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3664 gaim_input_remove(gc->inpa);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3665 gc->inpa = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3666 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3667
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3668 /* clean up the rest */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3669 mwGaimPluginData_free(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3670 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3671
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3672
12735
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3673 static int mw_rand() {
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3674 static int seed = 0;
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3675
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3676 /* for diversity, not security. don't touch */
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3677 srand(time(NULL) ^ seed);
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3678 seed = rand();
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3679
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3680 return seed;
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3681 }
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3682
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3683
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3684 /** generates a random-ish content id string */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3685 static char *im_mime_content_id() {
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3686 return g_strdup_printf("%03x@%05xmeanwhile",
12735
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3687 mw_rand() & 0xfff, mw_rand() & 0xfffff);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3688 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3689
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3690
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3691 /** generates a multipart/related content type with a random-ish
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3692 boundary value */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3693 static char *im_mime_content_type() {
12422
fe42d9c111f9 [gaim-migrate @ 14729]
Richard Laager <rlaager@wiktel.com>
parents: 12312
diff changeset
3694 return g_strdup_printf("multipart/related; boundary=related_MW%03x_%04x",
12735
da9fd490cef9 [gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents: 12658
diff changeset
3695 mw_rand() & 0xfff, mw_rand() & 0xffff);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3696 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3697
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3698
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3699 /** determine content type from extension. Not so happy about this,
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3700 but I don't want to actually write image type detection */
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3701 static char *im_mime_img_content_type(GaimStoredImage *img) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3702 const char *fn = gaim_imgstore_get_filename(img);
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3703 const char *ct = NULL;
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3704
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3705 ct = strrchr(fn, '.');
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3706 if(! ct) {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3707 ct = "image";
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3708
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3709 } else if(! strcmp(".png", ct)) {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3710 ct = "image/png";
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3711
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3712 } else if(! strcmp(".jpg", ct)) {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3713 ct = "image/jpeg";
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3714
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3715 } else if(! strcmp(".jpeg", ct)) {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3716 ct = "image/jpeg";
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3717
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3718 } else if(! strcmp(".gif", ct)) {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3719 ct = "image/gif";
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3720
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3721 } else {
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3722 ct = "image";
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3723 }
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3724
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3725 return g_strdup_printf("%s; name=\"%s\"", ct, fn);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3726 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3727
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3728
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3729 static char *im_mime_img_content_disp(GaimStoredImage *img) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3730 const char *fn = gaim_imgstore_get_filename(img);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3731 return g_strdup_printf("attachment; filename=\"%s\"", fn);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3732 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3733
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3734
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3735 #if NB_HACK
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3736 static char *nb_im_encode(GaimConnection *gc, const char *message) {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3737 GaimAccount *acct;
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3738 const char *enc;
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3739 char *ret;
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3740 GError *error = NULL;
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3741
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3742 acct = gaim_connection_get_account(gc);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3743 g_return_val_if_fail(acct != NULL, NULL);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3744
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3745 enc = gaim_account_get_string(acct, MW_KEY_ENCODING,
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3746 MW_PLUGIN_DEFAULT_ENCODING);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3747 g_return_val_if_fail(enc != NULL, NULL);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3748
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3749 ret = g_convert_with_fallback(message, strlen(message),
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3750 enc, "UTF-8", "?",
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3751 NULL, NULL, &error);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3752
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3753 if(error) {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3754 DEBUG_INFO("problem converting to %s: %s\n",
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3755 enc, NSTR(error->message));
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3756 g_error_free(error);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3757 }
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3758
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3759 /* something went so wrong that not even the fallback worked */
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3760 if(! ret) ret = g_strdup(message);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3761
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3762 return ret;
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3763 }
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3764 #endif
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3765
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3766
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3767 #if NB_HACK
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3768 static gboolean is_nb(struct mwConversation *conv) {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3769 struct mwLoginInfo *info;
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3770
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3771 info = mwConversation_getTargetInfo(conv);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3772 if(! info) return FALSE;
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3773
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3774 /* NotesBuddy can be at least three different type IDs (all in the
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3775 0x1400 range), or it can show up as 0x1000. However, if we're
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3776 calling this check, then we're already in HTML or MIME mode, so
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3777 we can discount the real 0x1000 */
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3778 /* I tried to avoid having any client-type-dependant code in here, I
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3779 really did. Oh well. CURSE YOU NOTESBUDDY */
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3780 return ((info->type == 0x1000) || ((info->type & 0xff00) == 0x1400));
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3781 }
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3782 #endif
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3783
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3784
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3785 /** turn an IM with embedded images into a multi-part mime document */
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3786 static char *im_mime_convert(GaimConnection *gc,
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3787 struct mwConversation *conv,
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3788 const char *message) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3789 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3790 GaimMimeDocument *doc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3791 GaimMimePart *part;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3792
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3793 GData *attr;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3794 char *tmp, *start, *end;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3795
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3796 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3797
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3798 doc = gaim_mime_document_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3799
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3800 gaim_mime_document_set_field(doc, "Mime-Version", "1.0");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3801 gaim_mime_document_set_field(doc, "Content-Disposition", "inline");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3802
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3803 tmp = im_mime_content_type();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3804 gaim_mime_document_set_field(doc, "Content-Type", tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3805 g_free(tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3806
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3807 tmp = (char *) message;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3808 while(*tmp && gaim_markup_find_tag("img", tmp, (const char **) &start,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3809 (const char **) &end, &attr)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3810 char *id;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3811 GaimStoredImage *img = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3812
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3813 gsize len = (start - tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3814
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3815 /* append the in-between-tags text */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3816 if(len) g_string_append_len(str, tmp, len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3817
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3818 /* find the imgstore data by the id tag */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3819 id = g_datalist_get_data(&attr, "id");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3820 if(id && *id)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3821 img = gaim_imgstore_get(atoi(id));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3822
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3823 if(img) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3824 char *cid;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3825 gpointer data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3826 size_t size;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3827
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3828 part = gaim_mime_part_new(doc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3829
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3830 data = im_mime_img_content_disp(img);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3831 gaim_mime_part_set_field(part, "Content-Disposition", data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3832 g_free(data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3833
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3834 data = im_mime_img_content_type(img);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3835 gaim_mime_part_set_field(part, "Content-Type", data);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3836 g_free(data);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3837
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3838 cid = im_mime_content_id();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3839 data = g_strdup_printf("<%s>", cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3840 gaim_mime_part_set_field(part, "Content-ID", data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3841 g_free(data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3842
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3843 gaim_mime_part_set_field(part, "Content-transfer-encoding", "base64");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3844
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3845 /* obtain and base64 encode the image data, and put it in the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3846 mime part */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3847 data = gaim_imgstore_get_data(img);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3848 size = gaim_imgstore_get_size(img);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3849 data = gaim_base64_encode(data, (gsize) size);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3850 gaim_mime_part_set_data(part, data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3851 g_free(data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3852
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3853 /* append the modified tag */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3854 g_string_append_printf(str, "<img src=\"cid:%s\">", cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3855 g_free(cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3856
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3857 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3858 /* append the literal image tag, since we couldn't find a
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3859 relative imgstore object */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3860 gsize len = (end - start) + 1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3861 g_string_append_len(str, start, len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3862 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3863
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3864 g_datalist_clear(&attr);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3865 tmp = end + 1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3866 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3867
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3868 /* append left-overs */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3869 g_string_append(str, tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3870
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3871 /* add the text/html part */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3872 part = gaim_mime_part_new(doc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3873 gaim_mime_part_set_field(part, "Content-Disposition", "inline");
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3874
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3875 #if NB_HACK
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3876 if(is_nb(conv)) {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3877 GaimAccount *acct = gaim_connection_get_account(gc);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3878
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3879 tmp = (char *) gaim_account_get_string(acct, MW_KEY_ENCODING,
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3880 MW_PLUGIN_DEFAULT_ENCODING);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3881 tmp = g_strdup_printf("text/html; charset=\"%s\"", tmp);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3882 gaim_mime_part_set_field(part, "Content-Type", tmp);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3883 g_free(tmp);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3884
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3885 gaim_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit");
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3886
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3887 tmp = nb_im_encode(gc, str->str);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3888 gaim_mime_part_set_data(part, tmp);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3889 g_free(tmp);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3890
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3891 } else {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3892 gaim_mime_part_set_field(part, "Content-Type", "text/html");
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3893 gaim_mime_part_set_field(part, "Content-Transfer-Encoding", "8bit");
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3894 gaim_mime_part_set_data(part, str->str);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3895 }
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3896
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3897 #else
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3898 tmp = gaim_utf8_ncr_encode(str->str);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3899 gaim_mime_part_set_field(part, "Content-Type", "text/html");
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3900 gaim_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit");
12821
aacda65b3449 [gaim-migrate @ 15169]
Christopher O'Brien <siege@pidgin.im>
parents: 12813
diff changeset
3901 gaim_mime_part_set_data(part, tmp);
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3902 g_free(tmp);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3903 #endif
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3904
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3905 g_string_free(str, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3906
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3907 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3908 gaim_mime_document_write(doc, str);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3909 tmp = str->str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3910 g_string_free(str, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3911
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3912 return tmp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3913 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3914
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3915
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3916 static int mw_prpl_send_im(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3917 const char *name,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3918 const char *message,
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12166
diff changeset
3919 GaimMessageFlags flags) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3920
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3921 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3922 struct mwIdBlock who = { (char *) name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3923 struct mwConversation *conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3924
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3925 g_return_val_if_fail(gc != NULL, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3926 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3927
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3928 g_return_val_if_fail(pd != NULL, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3929
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3930 conv = mwServiceIm_getConversation(pd->srvc_im, &who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3931
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3932 /* this detection of features to determine how to send the message
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3933 (plain, html, or mime) is flawed because the other end of the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3934 conversation could close their channel at any time, rendering any
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3935 existing formatting in an outgoing message innapropriate. The end
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3936 result is that it may be possible that the other side of the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3937 conversation will receive a plaintext message with html contents,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3938 which is bad. I'm not sure how to fix this correctly. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3939
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3940 if(strstr(message, "<img ") || strstr(message, "<IMG "))
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12166
diff changeset
3941 flags |= GAIM_MESSAGE_IMAGES;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3942
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3943 if(mwConversation_isOpen(conv)) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3944 char *tmp;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3945 int ret;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3946
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12166
diff changeset
3947 if((flags & GAIM_MESSAGE_IMAGES) &&
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3948 mwConversation_supports(conv, mwImSend_MIME)) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3949 /* send a MIME message */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3950
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3951 tmp = im_mime_convert(gc, conv, message);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3952 ret = mwConversation_send(conv, mwImSend_MIME, tmp);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3953 g_free(tmp);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3954
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3955 } else if(mwConversation_supports(conv, mwImSend_HTML)) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3956 /* send an HTML message */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3957
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3958 #if NB_HACK
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
3959 if(is_nb(conv)) {
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3960
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3961 /* html messages need the notesbuddy hack */
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3962 char *msg = nb_im_encode(gc, message);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3963 tmp = gaim_strdup_withhtml(msg);
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
3964 g_free(msg);
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3965
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3966 } else {
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3967 /* need to do this to get the \n to <br> conversion */
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3968 tmp = gaim_strdup_withhtml(message);
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
3969 }
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
3970
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3971 #else
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3972 char *ncr;
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3973 ncr = gaim_utf8_ncr_encode(message);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3974 tmp = gaim_strdup_withhtml(ncr);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3975 g_free(ncr);
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3976 #endif
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
3977
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3978 ret = mwConversation_send(conv, mwImSend_HTML, tmp);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3979 g_free(tmp);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3980
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3981 } else {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3982 /* default to text */
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3983 tmp = gaim_markup_strip_html(message);
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12166
diff changeset
3984 ret = mwConversation_send(conv, mwImSend_PLAIN, tmp);
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
3985 g_free(tmp);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3986 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3987
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3988 return !ret;
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3989
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3990 } else {
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3991
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3992 /* queue up the message safely as plain text */
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
3993 char *tmp = gaim_markup_strip_html(message);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3994 convo_queue(conv, mwImSend_PLAIN, tmp);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3995 g_free(tmp);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
3996
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3997 if(! mwConversation_isPending(conv))
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3998 mwConversation_open(conv);
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
3999
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
4000 return 1;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4001 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4002 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4003
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4004
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4005 static int mw_prpl_send_typing(GaimConnection *gc, const char *name,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4006 int typing) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4007
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4008 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4009 struct mwIdBlock who = { (char *) name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4010 struct mwConversation *conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4011
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4012 gpointer t = GINT_TO_POINTER(!! typing);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4013
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4014 g_return_val_if_fail(gc != NULL, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4015 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4016
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4017 g_return_val_if_fail(pd != NULL, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4018
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4019 conv = mwServiceIm_getConversation(pd->srvc_im, &who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4020
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4021 if(mwConversation_isOpen(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4022 return ! mwConversation_send(conv, mwImSend_TYPING, t);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4023
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4024 if(typing) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4025 /* let's only open a channel for typing, not for not-typing.
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4026 Otherwise two users in psychic mode will continually open
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4027 conversations to each other, never able to get rid of them, as
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4028 when the other person closes, it psychicaly opens again */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4029
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4030 convo_queue(conv, mwImSend_TYPING, t);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4031
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4032 if(! mwConversation_isPending(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4033 mwConversation_open(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4034 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4035
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4036 return 1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4037 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4038
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4039
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4040 static const char *mw_client_name(guint16 type) {
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4041 switch(type) {
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4042 case mwLogin_LIB:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4043 return "Lotus Binary Library";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4044
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4045 case mwLogin_JAVA_WEB:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4046 return "Lotus Java Client Applet";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4047
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4048 case mwLogin_BINARY:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4049 return "Lotus Sametime Connect";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4050
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4051 case mwLogin_JAVA_APP:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4052 return "Lotus Java Client Application";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4053
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4054 case mwLogin_LINKS:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4055 return "Lotus Sametime Links";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4056
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4057 case mwLogin_NOTES_6_5:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4058 case mwLogin_NOTES_6_5_3:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4059 case mwLogin_NOTES_7_0_beta:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4060 case mwLogin_NOTES_7_0:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4061 return "Lotus Notes Client";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4062
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4063 case mwLogin_ICT:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4064 case mwLogin_ICT_1_7_8_2:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4065 case mwLogin_ICT_SIP:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4066 return "IBM Community Tools";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4067
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4068 case mwLogin_NOTESBUDDY_4_14:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4069 case mwLogin_NOTESBUDDY_4_15:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4070 case mwLogin_NOTESBUDDY_4_16:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4071 return "Alphaworks NotesBuddy";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4072
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4073 case mwLogin_SANITY:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4074 return "Sanity";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4075
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4076 case mwLogin_ST_PERL:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4077 return "ST-Send-Message";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4078
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4079 case mwLogin_TRILLIAN:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4080 case mwLogin_TRILLIAN_IBM:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4081 return "Trillian";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4082
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4083 case mwLogin_MEANWHILE:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4084 return "Meanwhile";
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4085
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4086 default:
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4087 return NULL;
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4088 }
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4089 }
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4090
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4091
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4092 static void mw_prpl_get_info(GaimConnection *gc, const char *who) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4093
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4094 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL };
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4095
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4096 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4097 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4098 GaimBuddy *b;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4099
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4100 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4101 const char *tmp;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4102
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4103 g_return_if_fail(who != NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4104 g_return_if_fail(*who != '\0');
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4105
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4106 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4107
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4108 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4109 b = gaim_find_buddy(acct, who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4110
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4111 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4112
12166
d6417efb990c [gaim-migrate @ 14467]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12147
diff changeset
4113 if(gaim_str_has_prefix(who, "@E ")) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4114 g_string_append(str, _("<b>External User</b><br>"));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4115 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4116
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4117 g_string_append_printf(str, _("<b>User ID:</b> %s<br>"), who);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4118
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4119 if(b) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4120 guint32 type;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4121
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4122 if(b->server_alias) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4123 g_string_append_printf(str, _("<b>Full Name:</b> %s<br>"),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4124 b->server_alias);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4125 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4126
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4127 type = gaim_blist_node_get_int((GaimBlistNode *) b, BUDDY_KEY_CLIENT);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4128 if(type) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4129 g_string_append(str, _("<b>Last Known Client:</b> "));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4130
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
4131 tmp = mw_client_name(type);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4132 if(tmp) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4133 g_string_append(str, tmp);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4134 g_string_append(str, "<br>");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4135
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4136 } else {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4137 g_string_append_printf(str, _("Unknown (0x%04x)<br>"), type);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4138 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4139 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4140 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4141
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4142 tmp = user_supports_text(pd->srvc_aware, who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4143 if(tmp) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4144 g_string_append_printf(str, _("<b>Supports:</b> %s<br>"), tmp);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4145 g_free((char *) tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4146 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4147
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4148 if(b) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4149 tmp = status_text(b);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4150 g_string_append_printf(str, _("<b>Status:</b> %s"), tmp);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4151
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4152 g_string_append(str, "<hr>");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4153
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4154 tmp = mwServiceAware_getText(pd->srvc_aware, &idb);
12496
f9d0ab1474ac [gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents: 12489
diff changeset
4155 if(tmp) {
f9d0ab1474ac [gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents: 12489
diff changeset
4156 tmp = g_markup_escape_text(tmp, -1);
f9d0ab1474ac [gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents: 12489
diff changeset
4157 g_string_append(str, tmp);
f9d0ab1474ac [gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents: 12489
diff changeset
4158 g_free((char *) tmp);
f9d0ab1474ac [gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents: 12489
diff changeset
4159 }
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4160 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4161
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4162 /* @todo emit a signal to allow a plugin to override the display of
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4163 this notification, so that it can create its own */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4164
11533
c9b815aeddc1 [gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents: 11531
diff changeset
4165 gaim_notify_userinfo(gc, who, str->str, NULL, NULL);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4166
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4167 g_string_free(str, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4168 }
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4169
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4170
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4171 static void mw_prpl_set_status(GaimAccount *acct, GaimStatus *status) {
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4172 GaimConnection *gc;
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4173 const char *state;
11641
925c1960af34 [gaim-migrate @ 13918]
Richard Laager <rlaager@wiktel.com>
parents: 11638
diff changeset
4174 char *message = NULL;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4175 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4176 struct mwUserStatus stat;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4177
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4178 g_return_if_fail(acct != NULL);
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4179 gc = gaim_account_get_connection(acct);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4180
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4181 state = gaim_status_get_id(status);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4182
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4183 DEBUG_INFO("Set status to %s\n", gaim_status_get_name(status));
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4184
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4185 g_return_if_fail(gc != NULL);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4186
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4187 session = gc_to_session(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4188 g_return_if_fail(session != NULL);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4189
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4190 /* get a working copy of the current status */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4191 mwUserStatus_clone(&stat, mwSession_getUserStatus(session));
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4192
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4193 /* determine the state */
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4194 if(! strcmp(state, MW_STATE_ACTIVE)) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4195 stat.status = mwStatus_ACTIVE;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4196
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4197 } else if(! strcmp(state, MW_STATE_AWAY)) {
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4198 stat.status = mwStatus_AWAY;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4199
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4200 } else if(! strcmp(state, MW_STATE_BUSY)) {
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4201 stat.status = mwStatus_BUSY;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4202 }
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4203
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4204 /* determine the message */
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4205 message = (char *) gaim_status_get_attr_string(status, MW_STATE_MESSAGE);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4206
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4207 if(message) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4208 /* all the possible non-NULL values of message up to this point
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4209 are const, so we don't need to free them */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4210 message = gaim_markup_strip_html(message);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4211 }
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4212
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4213 /* out with the old */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4214 g_free(stat.desc);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4215
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4216 /* in with the new */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4217 stat.desc = (char *) message;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4218
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4219 mwSession_setUserStatus(session, &stat);
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
4220 mwUserStatus_clear(&stat);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4221 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4222
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4223
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4224 static void mw_prpl_set_idle(GaimConnection *gc, int t) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4225 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4226 struct mwUserStatus stat;
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4227
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4228
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4229 session = gc_to_session(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4230 g_return_if_fail(session != NULL);
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4231
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4232 mwUserStatus_clone(&stat, mwSession_getUserStatus(session));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4233
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4234 if(t) {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4235 time_t now = time(NULL);
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4236 stat.time = now - t;
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4237
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4238 } else {
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4239 stat.time = 0;
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4240 }
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4241
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4242 if(t > 0 && stat.status == mwStatus_ACTIVE) {
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4243 /* we were active and went idle, so change the status to IDLE. */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4244 stat.status = mwStatus_IDLE;
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4245
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4246 } else if(t == 0 && stat.status == mwStatus_IDLE) {
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4247 /* we only become idle automatically, so change back to ACTIVE */
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4248 stat.status = mwStatus_ACTIVE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4249 }
12105
d4cd7d443795 [gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents: 12088
diff changeset
4250
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4251 mwSession_setUserStatus(session, &stat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4252 mwUserStatus_clear(&stat);
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4253 }
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4254
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4255
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4256 static void notify_im(GaimConnection *gc, GList *row) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4257 GaimAccount *acct;
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4258 GaimConversation *conv;
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4259 char *id;
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4260
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4261 acct = gaim_connection_get_account(gc);
12631
e8da8f12e694 [gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents: 12630
diff changeset
4262 id = g_list_nth_data(row, 1);
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4263 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, id, acct);
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4264 if(! conv) conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, id);
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4265 gaim_conversation_present(conv);
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4266 }
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4267
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4268
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4269 static void notify_add(GaimConnection *gc, GList *row) {
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4270 gaim_blist_request_add_buddy(gaim_connection_get_account(gc),
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4271 g_list_nth_data(row, 1), NULL,
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4272 g_list_nth_data(row, 0));
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4273 }
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4274
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4275
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4276 static void notify_close(gpointer data) {
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4277 ;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4278 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4279
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4280
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4281 static void multi_resolved_query(struct mwResolveResult *result,
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4282 GaimConnection *gc) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4283 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4284 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4285
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4286 GaimNotifySearchResults *sres;
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4287 GaimNotifySearchColumn *scol;
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4288
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4289 sres = gaim_notify_searchresults_new();
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4290
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4291 scol = gaim_notify_searchresults_column_new(_("User Name"));
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4292 gaim_notify_searchresults_column_add(sres, scol);
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4293
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4294 scol = gaim_notify_searchresults_column_new(_("Sametime ID"));
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4295 gaim_notify_searchresults_column_add(sres, scol);
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4296
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4297 gaim_notify_searchresults_button_add(sres, GAIM_NOTIFY_BUTTON_IM,
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4298 notify_im);
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4299
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4300 gaim_notify_searchresults_button_add(sres, GAIM_NOTIFY_BUTTON_ADD,
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4301 notify_add);
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4302
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4303 for(l = result->matches; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4304 struct mwResolveMatch *match = l->data;
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4305 GList *row = NULL;
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
4306
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
4307 DEBUG_INFO("multi resolve: %s, %s\n",
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
4308 NSTR(match->id), NSTR(match->name));
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
4309
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4310 if(!match->id || !match->name)
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4311 continue;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4312
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4313 row = g_list_append(row, g_strdup(match->name));
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4314 row = g_list_append(row, g_strdup(match->id));
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4315 gaim_notify_searchresults_row_add(sres, row);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4316 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4317
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4318 msgA = _("An ambiguous user ID was entered");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4319 msgB = _("The identifier '%s' may possibly refer to any of the following"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4320 " users. Please select the correct user from the list below to"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4321 " add them to your buddy list.");
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4322 msgB = g_strdup_printf(msgB, result->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4323
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4324 gaim_notify_searchresults(gc, _("Select User"),
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4325 msgA, msgB, sres, notify_close, NULL);
12630
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
4326
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
4327 g_free(msgB);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4328 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4329
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4330
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4331 static void add_buddy_resolved(struct mwServiceResolve *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4332 guint32 id, guint32 code, GList *results,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4333 gpointer b) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4334
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4335 struct mwResolveResult *res = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4336 GaimBuddy *buddy = b;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4337 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4338 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4339
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4340 gc = gaim_account_get_connection(buddy->account);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4341 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4342
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4343 if(results)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4344 res = results->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4345
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4346 if(!code && res && res->matches) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4347 if(g_list_length(res->matches) == 1) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4348 struct mwResolveMatch *match = res->matches->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4349
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4350 /* only one? that might be the right one! */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4351 if(strcmp(res->name, match->id)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4352 /* uh oh, the single result isn't identical to the search
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4353 term, better safe then sorry, so let's make sure it's who
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4354 the user meant to add */
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4355 gaim_blist_remove_buddy(buddy);
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4356 multi_resolved_query(res, gc);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4357
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4358 } else {
12829
3848e5eb7962 [gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents: 12821
diff changeset
4359
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4360 /* same person, set the server alias */
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4361 gaim_blist_server_alias_buddy(buddy, match->name);
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4362 gaim_blist_node_set_string((GaimBlistNode *) buddy,
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4363 BUDDY_KEY_NAME, match->name);
12829
3848e5eb7962 [gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents: 12821
diff changeset
4364
3848e5eb7962 [gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents: 12821
diff changeset
4365 /* subscribe to awareness */
3848e5eb7962 [gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents: 12821
diff changeset
4366 buddy_add(pd, buddy);
3848e5eb7962 [gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents: 12821
diff changeset
4367
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4368 blist_schedule(pd);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4369 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4370
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4371 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4372 /* prompt user if more than one match was returned */
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4373 gaim_blist_remove_buddy(buddy);
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
4374 multi_resolved_query(res, gc);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4375 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4376
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4377 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4378 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4379
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4380 /* fall-through indicates that we couldn't find a matching user in
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4381 the resolve service (ether error or zero results), so we remove
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4382 this buddy */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4383
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4384 DEBUG_INFO("no such buddy in community\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4385 gaim_blist_remove_buddy(buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4386 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4387
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4388 if(res && res->name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4389 /* compose and display an error message */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4390 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4391
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4392 msgA = _("Unable to add user: user not found");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4393
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4394 msgB = _("The identifier '%s' did not match any users in your"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4395 " Sametime community. This entry has been removed from"
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4396 " your buddy list.");
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4397 msgB = g_strdup_printf(msgB, NSTR(res->name));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4398
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4399 gaim_notify_error(gc, _("Unable to add user"), msgA, msgB);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4400
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4401 g_free(msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4402 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4403 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4404
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4405
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4406 static void mw_prpl_add_buddy(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4407 GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4408 GaimGroup *group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4409
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4410 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4411 struct mwServiceResolve *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4412 GList *query;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4413 enum mwResolveFlag flags;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4414 guint32 req;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4415
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4416 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4417 srvc = pd->srvc_resolve;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4418
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4419 /* catch external buddies. They won't be in the resolve service */
12524
977ebab0435f [gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents: 12496
diff changeset
4420 if(buddy_is_external(buddy)) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4421 buddy_add(pd, buddy);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4422 return;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4423 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4424
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4425 query = g_list_prepend(NULL, buddy->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4426 flags = mwResolveFlag_FIRST | mwResolveFlag_USERS;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4427
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4428 req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4429 buddy, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4430 g_list_free(query);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4431
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4432 if(req == SEARCH_ERROR) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4433 gaim_blist_remove_buddy(buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4434 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4435 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4436 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4437
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4438
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4439 static void foreach_add_buddies(GaimGroup *group, GList *buddies,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4440 struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4441 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4442
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4443 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4444 mwAwareList_addAware(list, buddies);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4445 g_list_free(buddies);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4446 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4447
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4448
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4449 static void mw_prpl_add_buddies(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4450 GList *buddies,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4451 GList *groups) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4452
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4453 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4454 GHashTable *group_sets;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4455 struct mwAwareIdBlock *idbs, *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4456
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4457 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4458
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4459 /* map GaimGroup:GList of mwAwareIdBlock */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4460 group_sets = g_hash_table_new(g_direct_hash, g_direct_equal);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4461
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4462 /* bunch of mwAwareIdBlock allocated at once, free'd at once */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4463 idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4464
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4465 /* first pass collects mwAwareIdBlock lists for each group */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4466 for(; buddies; buddies = buddies->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4467 GaimBuddy *b = buddies->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4468 GaimGroup *g;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4469 const char *fn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4470 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4471
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4472 /* nab the saved server alias and stick it on the buddy */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4473 fn = gaim_blist_node_get_string((GaimBlistNode *) b, BUDDY_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4474 gaim_blist_server_alias_buddy(b, fn);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4475
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4476 /* convert GaimBuddy into a mwAwareIdBlock */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4477 idb->type = mwAware_USER;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4478 idb->user = (char *) b->name;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4479 idb->community = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4480
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4481 /* put idb into the list associated with the buddy's group */
12088
980c877bd238 [gaim-migrate @ 14385]
Mark Doliner <mark@kingant.net>
parents: 12006
diff changeset
4482 g = gaim_buddy_get_group(b);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4483 l = g_hash_table_lookup(group_sets, g);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4484 l = g_list_prepend(l, idb++);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4485 g_hash_table_insert(group_sets, g, l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4486 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4487
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4488 /* each group's buddies get added in one shot, and schedule the blist
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4489 for saving */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4490 g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4491 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4492
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4493 /* cleanup */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4494 g_hash_table_destroy(group_sets);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4495 g_free(idbs);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4496 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4497
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4498
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4499 static void mw_prpl_remove_buddy(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4500 GaimBuddy *buddy, GaimGroup *group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4501
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4502 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4503 struct mwAwareIdBlock idb = { mwAware_USER, buddy->name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4504 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4505
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4506 GList *rem = g_list_prepend(NULL, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4507
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4508 pd = gc->proto_data;
12088
980c877bd238 [gaim-migrate @ 14385]
Mark Doliner <mark@kingant.net>
parents: 12006
diff changeset
4509 group = gaim_buddy_get_group(buddy);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4510 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4511
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4512 mwAwareList_removeAware(list, rem);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4513 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4514
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4515 g_list_free(rem);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4516 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4517
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4518
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4519 static void privacy_fill(struct mwPrivacyInfo *priv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4520 GSList *members) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4521
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4522 struct mwUserItem *u;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4523 guint count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4524
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4525 count = g_slist_length(members);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
4526 DEBUG_INFO("privacy_fill: %u members\n", count);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4527
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4528 priv->count = count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4529 priv->users = g_new0(struct mwUserItem, count);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4530
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4531 while(count--) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4532 u = priv->users + count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4533 u->id = members->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4534 members = members->next;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4535 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4536 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4537
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4538
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4539 static void mw_prpl_set_permit_deny(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4540 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4541 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4542 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4543
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4544 struct mwPrivacyInfo privacy = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4545 .deny = FALSE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4546 .count = 0,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4547 .users = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4548 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4549
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4550 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4551
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4552 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4553 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4554
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4555 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4556 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4557
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4558 session = pd->session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4559 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4560
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4561 switch(acct->perm_deny) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4562 case GAIM_PRIVACY_DENY_USERS:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4563 DEBUG_INFO("GAIM_PRIVACY_DENY_USERS\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4564 privacy_fill(&privacy, acct->deny);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
4565 privacy.deny = TRUE;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
4566 break;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4567
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4568 case GAIM_PRIVACY_ALLOW_ALL:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4569 DEBUG_INFO("GAIM_PRIVACY_ALLOW_ALL\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4570 privacy.deny = TRUE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4571 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4572
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4573 case GAIM_PRIVACY_ALLOW_USERS:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4574 DEBUG_INFO("GAIM_PRIVACY_ALLOW_USERS\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4575 privacy_fill(&privacy, acct->permit);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
4576 privacy.deny = FALSE;
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
4577 break;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4578
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4579 case GAIM_PRIVACY_DENY_ALL:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4580 DEBUG_INFO("GAIM_PRIVACY_DENY_ALL\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4581 privacy.deny = FALSE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4582 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4583
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4584 default:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4585 DEBUG_INFO("acct->perm_deny is 0x%x\n", acct->perm_deny);
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
4586 return;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4587 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4588
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4589 mwSession_setPrivacyInfo(session, &privacy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4590 g_free(privacy.users);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4591 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4592
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4593
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4594 static void mw_prpl_add_permit(GaimConnection *gc, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4595 mw_prpl_set_permit_deny(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4596 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4597
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4598
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4599 static void mw_prpl_add_deny(GaimConnection *gc, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4600 mw_prpl_set_permit_deny(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4601 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4602
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4603
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4604 static void mw_prpl_rem_permit(GaimConnection *gc, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4605 mw_prpl_set_permit_deny(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4606 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4607
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4608
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4609 static void mw_prpl_rem_deny(GaimConnection *gc, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4610 mw_prpl_set_permit_deny(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4611 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4612
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4613
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4614 static struct mwConference *conf_find(struct mwServiceConference *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4615 const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4616 GList *l, *ll;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4617 struct mwConference *conf = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4618
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4619 ll = mwServiceConference_getConferences(srvc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4620 for(l = ll; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4621 struct mwConference *c = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4622 if(! strcmp(name, mwConference_getName(c))) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4623 conf = c;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4624 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4625 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4626 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4627 g_list_free(ll);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4628
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4629 return conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4630 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4631
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4632
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4633 static void mw_prpl_join_chat(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4634 GHashTable *components) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4635
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4636 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4637 char *c, *t;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4638
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4639 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4640
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4641 c = g_hash_table_lookup(components, CHAT_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4642 t = g_hash_table_lookup(components, CHAT_KEY_TOPIC);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4643
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4644 if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4645 /* use place service */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4646 struct mwServicePlace *srvc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4647 struct mwPlace *place = NULL;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4648
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4649 srvc = pd->srvc_place;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4650 place = mwPlace_new(srvc, c, t);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4651 mwPlace_open(place);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4652
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4653 } else {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4654 /* use conference service */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4655 struct mwServiceConference *srvc;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4656 struct mwConference *conf = NULL;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4657
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4658 srvc = pd->srvc_conf;
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4659 if(c) conf = conf_find(srvc, c);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4660
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4661 if(conf) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4662 DEBUG_INFO("accepting conference invitation\n");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4663 mwConference_accept(conf);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4664
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4665 } else {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4666 DEBUG_INFO("creating new conference\n");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4667 conf = mwConference_new(srvc, t);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4668 mwConference_open(conf);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4669 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4670 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4671 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4672
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4673
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4674 static void mw_prpl_reject_chat(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4675 GHashTable *components) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4676
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4677 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4678 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4679 char *c;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4680
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4681 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4682 srvc = pd->srvc_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4683
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4684 if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4685 ; /* nothing needs doing */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4686
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4687 } else {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4688 /* reject conference */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4689 c = g_hash_table_lookup(components, CHAT_KEY_NAME);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4690 if(c) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4691 struct mwConference *conf = conf_find(srvc, c);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4692 if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4693 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4694 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4695 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4696
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4697
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4698 static char *mw_prpl_get_chat_name(GHashTable *components) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4699 return g_hash_table_lookup(components, CHAT_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4700 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4701
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4702
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4703 static void mw_prpl_chat_invite(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4704 int id,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4705 const char *invitation,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4706 const char *who) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4707
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4708 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4709 struct mwConference *conf;
12107
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4710 struct mwPlace *place;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4711 struct mwIdBlock idb = { (char *) who, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4712
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4713 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4714 g_return_if_fail(pd != NULL);
12107
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4715
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4716 conf = ID_TO_CONF(pd, id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4717
12107
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4718 if(conf) {
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4719 mwConference_invite(conf, &idb, invitation);
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4720 return;
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4721 }
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4722
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4723 place = ID_TO_PLACE(pd, id);
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4724 g_return_if_fail(place != NULL);
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4725
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4726 /* @todo: use the IM service for invitation */
40724851e95e [gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents: 12105
diff changeset
4727 mwPlace_legacyInvite(place, &idb, invitation);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4728 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4729
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4730
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4731 static void mw_prpl_chat_leave(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4732 int id) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4733
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4734 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4735 struct mwConference *conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4736
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4737 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4738
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4739 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4740 conf = ID_TO_CONF(pd, id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4741
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4742 if(conf) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4743 mwConference_destroy(conf, ERR_SUCCESS, "Leaving");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4744
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4745 } else {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4746 struct mwPlace *place = ID_TO_PLACE(pd, id);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4747 g_return_if_fail(place != NULL);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4748
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4749 mwPlace_destroy(place, ERR_SUCCESS);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4750 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4751 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4752
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4753
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4754 static void mw_prpl_chat_whisper(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4755 int id,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4756 const char *who,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4757 const char *message) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4758
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4759 mw_prpl_send_im(gc, who, message, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4760 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4761
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4762
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4763 static int mw_prpl_chat_send(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4764 int id,
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12166
diff changeset
4765 const char *message,
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12166
diff changeset
4766 GaimMessageFlags flags) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4767
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4768 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4769 struct mwConference *conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4770
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4771 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4772
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4773 g_return_val_if_fail(pd != NULL, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4774 conf = ID_TO_CONF(pd, id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4775
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4776 if(conf) {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4777 return ! mwConference_sendText(conf, message);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4778
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4779 } else {
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4780 struct mwPlace *place = ID_TO_PLACE(pd, id);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4781 g_return_val_if_fail(place != NULL, 0);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4782
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4783 return ! mwPlace_sendText(place, message);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4784 }
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4785 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4786
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4787
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4788 static void mw_prpl_keepalive(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4789 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4790
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4791 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4792
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4793 session = gc_to_session(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4794 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4795
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4796 mwSession_sendKeepalive(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4797 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4798
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4799
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4800 static void mw_prpl_alias_buddy(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4801 const char *who,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4802 const char *alias) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4803
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4804 struct mwGaimPluginData *pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4805 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4806
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4807 /* it's a change to the buddy list, so we've gotta reflect that in
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4808 the server copy */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4809
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4810 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4811 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4812
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4813
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4814 static void mw_prpl_group_buddy(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4815 const char *who,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4816 const char *old_group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4817 const char *new_group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4818
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4819 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4820 GList *gl = g_list_prepend(NULL, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4821
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4822 struct mwGaimPluginData *pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4823 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4824 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4825
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4826 /* add who to new_group's aware list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4827 group = gaim_find_group(new_group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4828 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4829 mwAwareList_addAware(list, gl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4830
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4831 /* remove who from old_group's aware list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4832 group = gaim_find_group(old_group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4833 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4834 mwAwareList_removeAware(list, gl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4835
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4836 g_list_free(gl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4837
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4838 /* schedule the changes to be saved */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4839 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4840 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4841
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4842
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4843 static void mw_prpl_rename_group(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4844 const char *old,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4845 GaimGroup *group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4846 GList *buddies) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4847
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4848 struct mwGaimPluginData *pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4849 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4850
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4851 /* it's a change in the buddy list, so we've gotta reflect that in
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4852 the server copy. Also, having this function should prevent all
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4853 those buddies from being removed and re-added. We don't really
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4854 give a crap what the group is named in Gaim other than to record
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4855 that as the group name/alias */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4856
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4857 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4858 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4859
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4860
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4861 static void mw_prpl_buddy_free(GaimBuddy *buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4862 /* I don't think we have any cleanup for buddies yet */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4863 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4864 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4865
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4866
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4867 static void mw_prpl_convo_closed(GaimConnection *gc, const char *who) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4868 struct mwGaimPluginData *pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4869 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4870 struct mwConversation *conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4871 struct mwIdBlock idb = { (char *) who, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4872
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4873 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4874
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4875 srvc = pd->srvc_im;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4876 g_return_if_fail(srvc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4877
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4878 conv = mwServiceIm_findConversation(srvc, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4879 if(! conv) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4880
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4881 if(mwConversation_isOpen(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4882 mwConversation_free(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4883 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4884
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4885
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4886 static const char *mw_prpl_normalize(const GaimAccount *account,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4887 const char *id) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4888
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4889 /* code elsewhere assumes that the return value points to different
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4890 memory than the passed value, but it won't free the normalized
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4891 data. wtf? */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4892
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4893 static char buf[BUF_LEN];
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4894 strncpy(buf, id, sizeof(buf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4895 return buf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4896 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4897
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4898
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4899 static void mw_prpl_remove_group(GaimConnection *gc, GaimGroup *group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4900 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4901 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4902
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4903 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4904 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4905 g_return_if_fail(pd->group_list_map != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4906
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4907 list = g_hash_table_lookup(pd->group_list_map, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4908
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4909 if(list) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4910 g_hash_table_remove(pd->group_list_map, list);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4911 g_hash_table_remove(pd->group_list_map, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4912 mwAwareList_free(list);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4913
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4914 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4915 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4916 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4917
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4918
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4919 static gboolean mw_prpl_can_receive_file(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4920 const char *who) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4921 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4922 struct mwServiceAware *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4923 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4924
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4925 g_return_val_if_fail(gc != NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4926
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4927 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4928 g_return_val_if_fail(pd != NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4929
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4930 srvc = pd->srvc_aware;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4931 g_return_val_if_fail(srvc != NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4932
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4933 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4934 g_return_val_if_fail(acct != NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4935
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4936 return gaim_find_buddy(acct, who) &&
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4937 user_supports(srvc, who, mwAttribute_FILE_TRANSFER);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4938 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4939
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4940
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4941 static void ft_outgoing_init(GaimXfer *xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4942 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4943 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4944
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4945 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4946 struct mwServiceFileTransfer *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4947 struct mwFileTransfer *ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4948
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4949 const char *filename;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4950 gsize filesize;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4951 FILE *fp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4952
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4953 struct mwIdBlock idb = { NULL, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4954
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4955 DEBUG_INFO("ft_outgoing_init\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4956
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4957 acct = gaim_xfer_get_account(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4958 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4959 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4960 srvc = pd->srvc_ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4961
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4962 filename = gaim_xfer_get_local_filename(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4963 filesize = gaim_xfer_get_size(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4964 idb.user = xfer->who;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4965
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4966 /* test that we can actually send the file */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4967 fp = g_fopen(filename, "rb");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4968 if(! fp) {
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
4969 char *msg = g_strdup_printf(_("Error reading file %s: \n%s\n"),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4970 filename, strerror(errno));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4971 gaim_xfer_error(gaim_xfer_get_type(xfer), acct, xfer->who, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4972 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4973 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4974 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4975 fclose(fp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4976
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4977 {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4978 char *tmp = strrchr(filename, G_DIR_SEPARATOR);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4979 if(tmp++) filename = tmp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4980 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4981
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4982 ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4983
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4984 gaim_xfer_ref(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4985 mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) gaim_xfer_unref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4986 xfer->data = ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4987
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4988 mwFileTransfer_offer(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4989 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4990
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4991
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4992 static void ft_outgoing_cancel(GaimXfer *xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4993 struct mwFileTransfer *ft = xfer->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4994 if(ft) mwFileTransfer_cancel(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4995 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4996
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4997
12147
9ce0a5f9443b [gaim-migrate @ 14448]
Ethan Blanton <elb@pidgin.im>
parents: 12143
diff changeset
4998 static GaimXfer *mw_prpl_new_xfer(GaimConnection *gc, const char *who) {
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4999 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5000 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5001
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5002 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5003
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5004 xfer = gaim_xfer_new(acct, GAIM_XFER_SEND, who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5005 gaim_xfer_set_init_fnc(xfer, ft_outgoing_init);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5006 gaim_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5007
12143
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 12135
diff changeset
5008 return xfer;
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 12135
diff changeset
5009 }
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 12135
diff changeset
5010
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 12135
diff changeset
5011 static void mw_prpl_send_file(GaimConnection *gc,
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 12135
diff changeset
5012 const char *who, const char *file) {
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 12135
diff changeset
5013
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 12135
diff changeset
5014 GaimXfer *xfer = mw_prpl_new_xfer(gc, who);
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 12135
diff changeset
5015
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5016 if(file) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5017 DEBUG_INFO("file != NULL\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5018 gaim_xfer_request_accepted(xfer, file);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5019
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5020 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5021 DEBUG_INFO("file == NULL\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5022 gaim_xfer_request(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5023 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5024 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5025
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5026
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5027 static GaimPluginProtocolInfo mw_prpl_info = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5028 .options = OPT_PROTO_IM_IMAGE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5029 .user_splits = NULL, /*< set in mw_plugin_init */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5030 .protocol_options = NULL, /*< set in mw_plugin_init */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5031 .icon_spec = NO_BUDDY_ICONS,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5032 .list_icon = mw_prpl_list_icon,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5033 .list_emblems = mw_prpl_list_emblems,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5034 .status_text = mw_prpl_status_text,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5035 .tooltip_text = mw_prpl_tooltip_text,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5036 .status_types = mw_prpl_status_types,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5037 .blist_node_menu = mw_prpl_blist_node_menu,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5038 .chat_info = mw_prpl_chat_info,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5039 .chat_info_defaults = mw_prpl_chat_info_defaults,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5040 .login = mw_prpl_login,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5041 .close = mw_prpl_close,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5042 .send_im = mw_prpl_send_im,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5043 .set_info = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5044 .send_typing = mw_prpl_send_typing,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5045 .get_info = mw_prpl_get_info,
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11547
diff changeset
5046 .set_status = mw_prpl_set_status,
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5047 .set_idle = mw_prpl_set_idle,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5048 .change_passwd = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5049 .add_buddy = mw_prpl_add_buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5050 .add_buddies = mw_prpl_add_buddies,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5051 .remove_buddy = mw_prpl_remove_buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5052 .remove_buddies = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5053 .add_permit = mw_prpl_add_permit,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5054 .add_deny = mw_prpl_add_deny,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5055 .rem_permit = mw_prpl_rem_permit,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5056 .rem_deny = mw_prpl_rem_deny,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5057 .set_permit_deny = mw_prpl_set_permit_deny,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5058 .join_chat = mw_prpl_join_chat,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5059 .reject_chat = mw_prpl_reject_chat,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5060 .get_chat_name = mw_prpl_get_chat_name,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5061 .chat_invite = mw_prpl_chat_invite,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5062 .chat_leave = mw_prpl_chat_leave,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5063 .chat_whisper = mw_prpl_chat_whisper,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5064 .chat_send = mw_prpl_chat_send,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5065 .keepalive = mw_prpl_keepalive,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5066 .register_user = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5067 .get_cb_info = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5068 .get_cb_away = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5069 .alias_buddy = mw_prpl_alias_buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5070 .group_buddy = mw_prpl_group_buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5071 .rename_group = mw_prpl_rename_group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5072 .buddy_free = mw_prpl_buddy_free,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5073 .convo_closed = mw_prpl_convo_closed,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5074 .normalize = mw_prpl_normalize,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5075 .set_buddy_icon = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5076 .remove_group = mw_prpl_remove_group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5077 .get_cb_real_name = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5078 .set_chat_topic = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5079 .find_blist_chat = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5080 .roomlist_get_list = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5081 .roomlist_expand_category = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5082 .can_receive_file = mw_prpl_can_receive_file,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5083 .send_file = mw_prpl_send_file,
12143
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 12135
diff changeset
5084 .new_xfer = mw_prpl_new_xfer,
12650
2926e3c3185e [gaim-migrate @ 14988]
Mark Doliner <mark@kingant.net>
parents: 12631
diff changeset
5085 .offline_message = NULL,
2926e3c3185e [gaim-migrate @ 14988]
Mark Doliner <mark@kingant.net>
parents: 12631
diff changeset
5086 .whiteboard_prpl_ops = NULL,
2926e3c3185e [gaim-migrate @ 14988]
Mark Doliner <mark@kingant.net>
parents: 12631
diff changeset
5087 .media_prpl_ops = NULL,
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5088 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5089
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5090
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5091 static GaimPluginPrefFrame *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5092 mw_plugin_get_plugin_pref_frame(GaimPlugin *plugin) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5093 GaimPluginPrefFrame *frame;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5094 GaimPluginPref *pref;
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5095
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5096 frame = gaim_plugin_pref_frame_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5097
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5098 pref = gaim_plugin_pref_new_with_label(_("Remotely Stored Buddy List"));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5099 gaim_plugin_pref_frame_add(frame, pref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5100
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5101
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5102 pref = gaim_plugin_pref_new_with_name(MW_PRPL_OPT_BLIST_ACTION);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5103 gaim_plugin_pref_set_label(pref, _("Buddy List Storage Mode"));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5104
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5105 gaim_plugin_pref_set_type(pref, GAIM_PLUGIN_PREF_CHOICE);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5106 gaim_plugin_pref_add_choice(pref, _("Local Buddy List Only"),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5107 GINT_TO_POINTER(blist_choice_LOCAL));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5108 gaim_plugin_pref_add_choice(pref, _("Merge List from Server"),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5109 GINT_TO_POINTER(blist_choice_MERGE));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5110 gaim_plugin_pref_add_choice(pref, _("Merge and Save List to Server"),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5111 GINT_TO_POINTER(blist_choice_STORE));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5112 gaim_plugin_pref_add_choice(pref, _("Synchronize List with Server"),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5113 GINT_TO_POINTER(blist_choice_SYNCH));
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5114
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5115 gaim_plugin_pref_frame_add(frame, pref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5116
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5117 return frame;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5118 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5119
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5120
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5121 static GaimPluginUiInfo mw_plugin_ui_info = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5122 .get_plugin_pref_frame = mw_plugin_get_plugin_pref_frame,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5123 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5124
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5125
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5126 static void st_import_action_cb(GaimConnection *gc, char *filename) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5127 struct mwSametimeList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5128
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5129 FILE *file;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5130 char buf[BUF_LEN];
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5131 size_t len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5132
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5133 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5134
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5135 file = fopen(filename, "r");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5136 g_return_if_fail(file != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5137
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5138 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5139 while( (len = fread(buf, 1, BUF_LEN, file)) ) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5140 g_string_append_len(str, buf, len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5141 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5142
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5143 fclose(file);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5144
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5145 l = mwSametimeList_load(str->str);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5146 g_string_free(str, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5147
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5148 blist_merge(gc, l);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5149 mwSametimeList_free(l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5150 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5151
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5152
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5153 /** prompts for a file to import blist from */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5154 static void st_import_action(GaimPluginAction *act) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5155 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5156 GaimAccount *account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5157 char *title;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5158
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5159 gc = act->context;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5160 account = gaim_connection_get_account(gc);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5161 title = g_strdup_printf(_("Import Sametime List for Account %s"),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5162 gaim_account_get_username(account));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5163
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5164 gaim_request_file(gc, title, NULL, FALSE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5165 G_CALLBACK(st_import_action_cb), NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5166 gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5167
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5168 g_free(title);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5169 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5170
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5171
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5172 static void st_export_action_cb(GaimConnection *gc, char *filename) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5173 struct mwSametimeList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5174 char *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5175 FILE *file;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5176
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5177 file = fopen(filename, "w");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5178 g_return_if_fail(file != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5179
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5180 l = mwSametimeList_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5181 blist_export(gc, l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5182 str = mwSametimeList_store(l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5183 mwSametimeList_free(l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5184
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5185 fprintf(file, "%s", str);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5186 fclose(file);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5187
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5188 g_free(str);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5189 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5190
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5191
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5192 /** prompts for a file to export blist to */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5193 static void st_export_action(GaimPluginAction *act) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5194 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5195 GaimAccount *account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5196 char *title;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5197
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5198 gc = act->context;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5199 account = gaim_connection_get_account(gc);
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5200 title = g_strdup_printf(_("Export Sametime List for Account %s"),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5201 gaim_account_get_username(account));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5202
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5203 gaim_request_file(gc, title, NULL, TRUE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5204 G_CALLBACK(st_export_action_cb), NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5205 gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5206
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5207 g_free(title);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5208 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5209
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5210
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5211 static void remote_group_multi_cleanup(gpointer ignore,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5212 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5213
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5214 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5215 const GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5216
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5217 f = gaim_request_fields_get_field(fields, "group");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5218 l = gaim_request_field_list_get_items(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5219
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5220 for(; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5221 const char *i = l->data;
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
5222 struct named_id *res;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5223
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5224 res = gaim_request_field_list_get_data(f, i);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5225
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5226 g_free(res->id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5227 g_free(res->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5228 g_free(res);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5229 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5230 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5231
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5232
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5233 static void remote_group_done(struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5234 const char *id, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5235 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5236 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5237 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5238 GaimBlistNode *gn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5239 const char *owner;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5240
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5241 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5242
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5243 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5244 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5245
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5246 /* collision checking */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5247 group = gaim_find_group(name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5248 if(group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5249 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5250
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5251 msgA = _("Unable to add group: group exists");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5252 msgB = _("A group named '%s' already exists in your buddy list.");
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5253 msgB = g_strdup_printf(msgB, name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5254
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5255 gaim_notify_error(gc, _("Unable to add group"), msgA, msgB);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5256
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5257 g_free(msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5258 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5259 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5260
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5261 group = gaim_group_new(name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5262 gn = (GaimBlistNode *) group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5263
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5264 owner = gaim_account_get_username(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5265
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5266 gaim_blist_node_set_string(gn, GROUP_KEY_NAME, id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5267 gaim_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5268 gaim_blist_node_set_string(gn, GROUP_KEY_OWNER, owner);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5269 gaim_blist_add_group(group, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5270
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5271 group_add(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5272 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5273 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5274
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5275
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5276 static void remote_group_multi_cb(struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5277 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5278 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5279 const GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5280
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5281 f = gaim_request_fields_get_field(fields, "group");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5282 l = gaim_request_field_list_get_selected(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5283
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5284 if(l) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5285 const char *i = l->data;
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
5286 struct named_id *res;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5287
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5288 res = gaim_request_field_list_get_data(f, i);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5289 remote_group_done(pd, res->id, res->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5290 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5291
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5292 remote_group_multi_cleanup(NULL, fields);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5293 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5294
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5295
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5296 static void remote_group_multi(struct mwResolveResult *result,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5297 struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5298
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5299 GaimRequestFields *fields;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5300 GaimRequestFieldGroup *g;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5301 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5302 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5303 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5304
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5305 GaimConnection *gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5306
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5307 fields = gaim_request_fields_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5308
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5309 g = gaim_request_field_group_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5310 gaim_request_fields_add_group(fields, g);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5311
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5312 f = gaim_request_field_list_new("group", _("Possible Matches"));
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5313 gaim_request_field_list_set_multi_select(f, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5314 gaim_request_field_set_required(f, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5315
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5316 for(l = result->matches; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5317 struct mwResolveMatch *match = l->data;
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12595
diff changeset
5318 struct named_id *res = g_new0(struct named_id, 1);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5319
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5320 res->id = g_strdup(match->id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5321 res->name = g_strdup(match->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5322
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5323 gaim_request_field_list_add(f, res->name, res);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5324 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5325
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5326 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5327
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5328 msgA = _("Notes Address Book group results");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5329 msgB = _("The identifier '%s' may possibly refer to any of the following"
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5330 " Notes Address Book groups. Please select the correct group from"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5331 " the list below to add it to your buddy list.");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5332 msgB = g_strdup_printf(msgB, result->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5333
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5334 gaim_request_fields(gc, _("Select Notes Address Book"),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5335 msgA, msgB, fields,
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5336 _("Add Group"), G_CALLBACK(remote_group_multi_cb),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5337 _("Cancel"), G_CALLBACK(remote_group_multi_cleanup),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5338 pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5339
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5340 g_free(msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5341 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5342
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5343
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5344 static void remote_group_resolved(struct mwServiceResolve *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5345 guint32 id, guint32 code, GList *results,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5346 gpointer b) {
11133
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
5347
1081735edc10 [gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents: 11132
diff changeset
5348 struct mwResolveResult *res = NULL;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5349 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5350 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5351 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5352
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5353 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5354 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5355
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5356 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5357 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5358
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5359 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5360 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5361
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5362 if(!code && results) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5363 res = results->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5364
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5365 if(res->matches) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5366 remote_group_multi(res, pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5367 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5368 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5369 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5370
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5371 if(res && res->name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5372 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5373
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5374 msgA = _("Unable to add group: group not found");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5375
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5376 msgB = _("The identifier '%s' did not match any Notes Address Book"
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5377 " groups in your Sametime community.");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5378 msgB = g_strdup_printf(msgB, res->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5379
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5380 gaim_notify_error(gc, _("Unable to add group"), msgA, msgB);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5381
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5382 g_free(msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5383 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5384 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5385
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5386
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5387 static void remote_group_action_cb(GaimConnection *gc, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5388 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5389 struct mwServiceResolve *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5390 GList *query;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5391 enum mwResolveFlag flags;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5392 guint32 req;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5393
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5394 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5395 srvc = pd->srvc_resolve;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5396
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5397 query = g_list_prepend(NULL, (char *) name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5398 flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5399
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5400 req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5401 NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5402 g_list_free(query);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5403
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5404 if(req == SEARCH_ERROR) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5405 /** @todo display error */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5406 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5407 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5408
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5409
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5410 static void remote_group_action(GaimPluginAction *act) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5411 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5412 const char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5413
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5414 gc = act->context;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5415
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5416 msgA = _("Notes Address Book Group");
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5417 msgB = _("Enter the name of a Notes Address Book group in the field below"
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5418 " to add the group and its members to your buddy list.");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5419
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5420 gaim_request_input(gc, _("Add Group"), msgA, msgB, NULL,
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5421 FALSE, FALSE, NULL,
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5422 _("Add"), G_CALLBACK(remote_group_action_cb),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5423 _("Cancel"), NULL,
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5424 gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5425 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5426
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5427
12630
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5428 static void search_notify(struct mwResolveResult *result,
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5429 GaimConnection *gc) {
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5430 GList *l;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5431 char *msgA, *msgB;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5432
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5433 GaimNotifySearchResults *sres;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5434 GaimNotifySearchColumn *scol;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5435
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5436 sres = gaim_notify_searchresults_new();
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5437
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5438 scol = gaim_notify_searchresults_column_new(_("User Name"));
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5439 gaim_notify_searchresults_column_add(sres, scol);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5440
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5441 scol = gaim_notify_searchresults_column_new(_("Sametime ID"));
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5442 gaim_notify_searchresults_column_add(sres, scol);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5443
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5444 gaim_notify_searchresults_button_add(sres, GAIM_NOTIFY_BUTTON_IM,
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5445 notify_im);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5446
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5447 gaim_notify_searchresults_button_add(sres, GAIM_NOTIFY_BUTTON_ADD,
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5448 notify_add);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5449
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5450 for(l = result->matches; l; l = l->next) {
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5451 struct mwResolveMatch *match = l->data;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5452 GList *row = NULL;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5453
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5454 if(!match->id || !match->name)
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5455 continue;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5456
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5457 row = g_list_append(row, g_strdup(match->name));
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5458 row = g_list_append(row, g_strdup(match->id));
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5459 gaim_notify_searchresults_row_add(sres, row);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5460 }
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5461
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5462 msgA = _("Search results for '%s'");
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5463 msgB = _("The identifier '%s' may possibly refer to any of the following"
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5464 " users. You may add these users to your buddy list or send them"
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5465 " messages with the action buttons below.");
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5466
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5467 msgA = g_strdup_printf(msgA, result->name);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5468 msgB = g_strdup_printf(msgB, result->name);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5469
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5470 gaim_notify_searchresults(gc, _("Search Results"),
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5471 msgA, msgB, sres, notify_close, NULL);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5472
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5473 g_free(msgA);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5474 g_free(msgB);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5475 }
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5476
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5477
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5478 static void search_resolved(struct mwServiceResolve *srvc,
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5479 guint32 id, guint32 code, GList *results,
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5480 gpointer b) {
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5481
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5482 GaimConnection *gc = b;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5483 struct mwResolveResult *res = NULL;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5484
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5485 if(results) res = results->data;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5486
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5487 if(!code && res && res->matches) {
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5488 search_notify(res, gc);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5489
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5490 } else {
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5491 char *msgA, *msgB;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5492 msgA = _("No matches");
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5493 msgB = _("The identifier '%s' did not match and users in your"
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5494 " Sametime community.");
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5495 msgB = g_strdup_printf(msgB, NSTR(res->name));
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5496
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5497 gaim_notify_error(gc, _("No Matches"), msgA, msgB);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5498
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5499 g_free(msgB);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5500 }
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5501 }
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5502
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5503
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5504 static void search_action_cb(GaimConnection *gc, const char *name) {
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5505 struct mwGaimPluginData *pd;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5506 struct mwServiceResolve *srvc;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5507 GList *query;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5508 enum mwResolveFlag flags;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5509 guint32 req;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5510
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5511 pd = gc->proto_data;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5512 srvc = pd->srvc_resolve;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5513
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5514 query = g_list_prepend(NULL, (char *) name);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5515 flags = mwResolveFlag_FIRST | mwResolveFlag_USERS;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5516
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5517 req = mwServiceResolve_resolve(srvc, query, flags, search_resolved,
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5518 gc, NULL);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5519 g_list_free(query);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5520
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5521 if(req == SEARCH_ERROR) {
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5522 /** @todo display error */
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5523 }
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5524 }
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5525
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5526
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5527 static void search_action(GaimPluginAction *act) {
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5528 GaimConnection *gc;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5529 const char *msgA, *msgB;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5530
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5531 gc = act->context;
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5532
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5533 msgA = _("Search for a user");
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5534 msgB = _("Enter a name or partial ID in the field below to search"
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5535 " for matching users in your Sametime community.");
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5536
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5537 gaim_request_input(gc, _("User Search"), msgA, msgB, NULL,
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5538 FALSE, FALSE, NULL,
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5539 _("Search"), G_CALLBACK(search_action_cb),
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5540 _("Cancel"), NULL,
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5541 gc);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5542 }
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5543
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5544
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5545 static GList *mw_plugin_actions(GaimPlugin *plugin, gpointer context) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5546 GaimPluginAction *act;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5547 GList *l = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5548
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5549 act = gaim_plugin_action_new(_("Import Sametime List..."),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5550 st_import_action);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5551 l = g_list_append(l, act);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5552
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5553 act = gaim_plugin_action_new(_("Export Sametime List..."),
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5554 st_export_action);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5555 l = g_list_append(l, act);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5556
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5557 act = gaim_plugin_action_new(_("Add Notes Address Book Group..."),
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5558 remote_group_action);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5559 l = g_list_append(l, act);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5560
12630
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5561 act = gaim_plugin_action_new(_("User Search..."),
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5562 search_action);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5563 l = g_list_append(l, act);
97ec28aaae47 [gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents: 12629
diff changeset
5564
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5565 return l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5566 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5567
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5568
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5569 static gboolean mw_plugin_load(GaimPlugin *plugin) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5570 return TRUE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5571 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5572
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5573
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5574 static gboolean mw_plugin_unload(GaimPlugin *plugin) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5575 return TRUE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5576 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5577
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5578
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5579 static void mw_plugin_destroy(GaimPlugin *plugin) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5580 g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5581 g_log_remove_handler("meanwhile", log_handler[1]);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5582 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5583
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5584
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5585 static GaimPluginInfo mw_plugin_info = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5586 .magic = GAIM_PLUGIN_MAGIC,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5587 .major_version = GAIM_MAJOR_VERSION,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5588 .minor_version = GAIM_MINOR_VERSION,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5589 .type = GAIM_PLUGIN_PROTOCOL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5590 .ui_requirement = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5591 .flags = 0,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5592 .dependencies = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5593 .priority = GAIM_PRIORITY_DEFAULT,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5594 .id = PLUGIN_ID,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5595 .name = PLUGIN_NAME,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5596 .version = VERSION,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5597 .summary = PLUGIN_SUMMARY,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5598 .description = PLUGIN_DESC,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5599 .author = PLUGIN_AUTHOR,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5600 .homepage = PLUGIN_HOMEPAGE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5601 .load = mw_plugin_load,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5602 .unload = mw_plugin_unload,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5603 .destroy = mw_plugin_destroy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5604 .ui_info = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5605 .extra_info = &mw_prpl_info,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5606 .prefs_info = &mw_plugin_ui_info,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5607 .actions = mw_plugin_actions,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5608 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5609
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5610
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5611 static void mw_log_handler(const gchar *domain, GLogLevelFlags flags,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5612 const gchar *msg, gpointer data) {
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
5613
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
5614 if(! (msg && *msg)) return;
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5615
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5616 /* handle g_log requests via gaim's built-in debug logging */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5617 if(flags & G_LOG_LEVEL_ERROR) {
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
5618 gaim_debug_error(domain, "%s\n", msg);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5619
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5620 } else if(flags & G_LOG_LEVEL_WARNING) {
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
5621 gaim_debug_warning(domain, "%s\n", msg);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5622
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5623 } else {
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
5624 gaim_debug_info(domain, "%s\n", msg);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5625 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5626 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5627
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5628
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5629 static void mw_plugin_init(GaimPlugin *plugin) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5630 GaimAccountOption *opt;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5631 GList *l = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5632
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5633 GLogLevelFlags logflags =
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5634 G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5635
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5636 /* set up the preferences */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5637 gaim_prefs_add_none(MW_PRPL_OPT_BASE);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5638 gaim_prefs_add_int(MW_PRPL_OPT_BLIST_ACTION, BLIST_CHOICE_DEFAULT);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5639
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5640 /* remove dead preferences */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5641 gaim_prefs_remove(MW_PRPL_OPT_PSYCHIC);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5642 gaim_prefs_remove(MW_PRPL_OPT_SAVE_DYNAMIC);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5643
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5644 /* host to connect to */
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5645 opt = gaim_account_option_string_new(_("Server"), MW_KEY_HOST,
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5646 MW_PLUGIN_DEFAULT_HOST);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5647 l = g_list_append(l, opt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5648
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5649 /* port to connect to */
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5650 opt = gaim_account_option_int_new(_("Port"), MW_KEY_PORT,
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5651 MW_PLUGIN_DEFAULT_PORT);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5652 l = g_list_append(l, opt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5653
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
5654 #if NB_HACK
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
5655 /* notesbuddy hack encoding */
12489
12db50600de5 [gaim-migrate @ 14801]
Mark Doliner <mark@kingant.net>
parents: 12422
diff changeset
5656 opt = gaim_account_option_string_new(_("NotesBuddy encoding"),
12005
5b3368008513 [gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents: 11953
diff changeset
5657 MW_KEY_ENCODING,
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5658 MW_PLUGIN_DEFAULT_ENCODING);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5659 l = g_list_append(l, opt);
12813
547c199072c8 [gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents: 12742
diff changeset
5660 #endif
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5661
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5662 { /* copy the old force login setting from prefs if it's
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5663 there. Don't delete the preference, since there may be more
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5664 than one account that wants to check for it. */
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5665 gboolean b = FALSE;
12489
12db50600de5 [gaim-migrate @ 14801]
Mark Doliner <mark@kingant.net>
parents: 12422
diff changeset
5666 const char *label = _("Force login (ignore server redirects)");
11943
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5667
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5668 if(gaim_prefs_exists(MW_PRPL_OPT_FORCE_LOGIN))
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5669 b = gaim_prefs_get_bool(MW_PRPL_OPT_FORCE_LOGIN);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5670
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5671 opt = gaim_account_option_bool_new(label, MW_KEY_FORCE, b);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5672 l = g_list_append(l, opt);
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5673 }
0110fc7c6a8a [gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents: 11837
diff changeset
5674
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
5675 /* pretend to be Sametime Connect */
12489
12db50600de5 [gaim-migrate @ 14801]
Mark Doliner <mark@kingant.net>
parents: 12422
diff changeset
5676 opt = gaim_account_option_bool_new(_("Hide client identity"),
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
5677 MW_KEY_FAKE_IT, FALSE);
12312
1c8ea8f3b84e [gaim-migrate @ 14616]
Christopher O'Brien <siege@pidgin.im>
parents: 12311
diff changeset
5678 l = g_list_append(l, opt);
12311
a2ebf585d8c6 [gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents: 12266
diff changeset
5679
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5680 mw_prpl_info.protocol_options = l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5681 l = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5682
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5683 /* forward all our g_log messages to gaim. Generally all the logging
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5684 calls are using gaim_log directly, but the g_return macros will
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5685 get caught here */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5686 log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5687 mw_log_handler, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5688
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5689 /* redirect meanwhile's logging to gaim's */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5690 log_handler[1] = g_log_set_handler("meanwhile", logflags,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5691 mw_log_handler, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5692 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5693
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5694
11949
47e1723a89d7 [gaim-migrate @ 14240]
Christopher O'Brien <siege@pidgin.im>
parents: 11943
diff changeset
5695 GAIM_INIT_PLUGIN(sametime, mw_plugin_init, mw_plugin_info);
10977
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5696 /* The End. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5697