annotate src/protocols/sametime/sametime.c @ 10977:2ce8ec01a064

[gaim-migrate @ 12803] adding sametime support to the build committer: Tailor Script <tailor@pidgin.im>
author Christopher O'Brien <siege@pidgin.im>
date Tue, 07 Jun 2005 02:52:39 +0000
parents
children a4611130e3eb
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
24 #include <stdlib.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
25
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
26 #include <internal.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
27 #include <gaim.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
28 #include <config.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
29
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
30 #include <account.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
31 #include <accountopt.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
32 #include <conversation.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
33 #include <debug.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
34 #include <ft.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
35 #include <imgstore.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
36 #include <mime.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
37 #include <notify.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
38 #include <plugin.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
39 #include <privacy.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
40 #include <prpl.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
41 #include <request.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
42 #include <util.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
43 #include <version.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
44
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
45 #include <glib.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
46 #include <glib/ghash.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
47 #include <glib/glist.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
48
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
49 #include <mw_cipher.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
50 #include <mw_common.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
51 #include <mw_error.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
52 #include <mw_service.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
53 #include <mw_session.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
54 #include <mw_srvc_aware.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
55 #include <mw_srvc_conf.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
56 #include <mw_srvc_ft.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
57 #include <mw_srvc_im.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
58 #include <mw_srvc_resolve.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
59 #include <mw_srvc_store.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
60 #include <mw_st_list.h>
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
61
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
62 #include "sametime.h"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
63
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
64
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
65 /* considering that there's no display of this information for prpls,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
66 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
67 I do it all for you. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
68 /* scratch that, I just added it to the prpl options panel */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
69 #define PLUGIN_ID "prpl-meanwhile"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
70 #define PLUGIN_NAME "Sametime"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
71 #define PLUGIN_SUMMARY "Sametime Protocol Plugin"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
72 #define PLUGIN_DESC "Open implementation of a Lotus Sametime client"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
73 #define PLUGIN_AUTHOR "Christopher (siege) O'Brien <siege@preoccupied.net>"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
74 #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
75
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
76
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
77 /* plugin preference names */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
78 #define MW_PRPL_OPT_BASE "/plugins/prpl/meanwhile"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
79 #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
80 #define MW_PRPL_OPT_PSYCHIC MW_PRPL_OPT_BASE "/psychic"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
81 #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
82 #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
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 /* stages of connecting-ness */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
86 #define MW_CONNECT_STEPS 9
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
87
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
88
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
89 /* stages of conciousness */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
90 #define MW_STATE_OFFLINE "offline"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
91 #define MW_STATE_ONLINE "online"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
92 #define MW_STATE_ACTIVE "available"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
93 #define MW_STATE_AWAY "away"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
94 #define MW_STATE_BUSY "busy"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
95 #define MW_STATE_IDLE "idle"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
96 #define MW_STATE_UNKNOWN "unknown"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
97 #define MW_STATE_BUDHA "enlightened"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
98
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
99 #define MW_STATE_MESSAGE "message"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
100
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
101
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
102 /* keys to get/set chat information */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
103 #define CHAT_KEY_CREATOR "chat.creator"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
104 #define CHAT_KEY_NAME "chat.name"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
105 #define CHAT_KEY_TOPIC "chat.topic"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
106 #define CHAT_KEY_INVITE "chat.invite"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
107
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
108
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
109 /* key for associating a mwLoginType with a buddy */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
110 #define BUDDY_KEY_CLIENT "meanwhile.client"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
111
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
112 /* 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
113 #define BUDDY_KEY_NAME "meanwhile.shortname"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
114
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
115 /* enum mwSametimeUserType */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
116 #define BUDDY_KEY_TYPE "meanwhile.type"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
117
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
118
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
119 /* key for the real group name for a meanwhile group */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
120 #define GROUP_KEY_NAME "meanwhile.group"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
121
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
122 /* enum mwSametimeGroupType */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
123 #define GROUP_KEY_TYPE "meanwhile.type"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
124
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
125 /* NAB group owning account */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
126 #define GROUP_KEY_OWNER "meanwhile.account"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
127
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
128 /* key gtk blist uses to indicate a collapsed group */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
129 #define GROUP_KEY_COLLAPSED "collapsed"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
130
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
131
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
132 #define SESSION_NO_SECRET "meanwhile.no_secret"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
133
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
134
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
135 /* keys to get/set gaim plugin information */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
136 #define MW_KEY_HOST "server"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
137 #define MW_KEY_PORT "port"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
138 #define MW_KEY_ACTIVE_MSG "active_msg"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
139 #define MW_KEY_AWAY_MSG "away_msg"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
140 #define MW_KEY_BUSY_MSG "busy_msg"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
141 #define MW_KEY_MSG_PROMPT "msg_prompt"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
142 #define MW_KEY_INVITE "conf_invite"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
143
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
144
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
145 /** 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
146 storage service occurs. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
147 #define BLIST_SAVE_SECONDS 15
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
148
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
149
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
150 /** blist storage option, local only */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
151 #define BLIST_CHOICE_NONE 1
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 /** blist storage option, load from server */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
154 #define BLIST_CHOICE_LOAD 2
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
155
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
156 /** blist storage option, load and save to server */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
157 #define BLIST_CHOICE_SAVE 3
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
158
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
159 /** blist storage option, server only */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
160 #define BLIST_CHOICE_SERVER 4
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
161
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
162
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
163 /** the default blist storage option */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
164 #define BLIST_CHOICE_DEFAULT BLIST_CHOICE_SAVE
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
165
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 /* testing for the above */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
168 #define BLIST_CHOICE_IS(n) (gaim_prefs_get_int(MW_PRPL_OPT_BLIST_ACTION)==(n))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
169 #define BLIST_CHOICE_IS_NONE() BLIST_CHOICE_IS(BLIST_CHOICE_NONE)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
170 #define BLIST_CHOICE_IS_LOAD() BLIST_CHOICE_IS(BLIST_CHOICE_LOAD)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
171 #define BLIST_CHOICE_IS_SAVE() BLIST_CHOICE_IS(BLIST_CHOICE_SAVE)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
172
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
173
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
174 /** warning text placed next to blist option */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
175 #define BLIST_WARNING \
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
176 ("Please note:\n" \
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
177 "The 'merge and save' option above is still mildly experimental." \
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
178 " You should back-up your buddy list with an official client" \
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
179 " before enabling this option. Loading takes effect at login.")
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
180
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
181
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
182 /* debugging output */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
183 #define DEBUG_ERROR(a...) gaim_debug_error(G_LOG_DOMAIN, a)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
184 #define DEBUG_INFO(a...) gaim_debug_info(G_LOG_DOMAIN, a)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
185 #define DEBUG_MISC(a...) gaim_debug_misc(G_LOG_DOMAIN, a)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
186 #define DEBUG_WARN(a...) gaim_debug_warning(G_LOG_DOMAIN, a)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
187
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
188
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
189 /** ensure non-null strings */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
190 #ifndef NSTR
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
191 # define NSTR(str) ((str)? (str): "(null)")
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
192 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
193
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
194
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
195 /** calibrates distinct secure channel nomenclature */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
196 static const unsigned char no_secret[] = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
197 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
198 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
199 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
200 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00,
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
203
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
204 /** handler IDs from g_log_set_handler in mw_plugin_init */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
205 static guint log_handler[2] = { 0, 0 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
206
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
207
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
208 /** the gaim plugin data.
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
209 available as gc->proto_data and mwSession_getClientData */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
210 struct mwGaimPluginData {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
211 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
212
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
213 struct mwServiceAware *srvc_aware;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
214 struct mwServiceConference *srvc_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
215 struct mwServiceFileTransfer *srvc_ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
216 struct mwServiceIm *srvc_im;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
217 struct mwServiceResolve *srvc_resolve;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
218 struct mwServiceStorage *srvc_store;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
219
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
220 /** map of GaimGroup:mwAwareList and mwAwareList:GaimGroup */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
221 GHashTable *group_list_map;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
222
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
223 /** event id for the buddy list save callback */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
224 guint save_event;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
225
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
226 /** socket fd */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
227 int socket;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
228
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
229 GaimConnection *gc;
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
233 /* blist and aware functions */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
234
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
235 static void blist_export(GaimConnection *gc, struct mwSametimeList *stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
236
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
237 static void blist_store(struct mwGaimPluginData *pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
238
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
239 static void blist_schedule(struct mwGaimPluginData *pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
240
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
241 static void blist_import(GaimConnection *gc, struct mwSametimeList *stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
242
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
243 static void buddy_add(struct mwGaimPluginData *pd, GaimBuddy *buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
244
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
245 static GaimBuddy *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
246 buddy_ensure(GaimConnection *gc, GaimGroup *group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
247 struct mwSametimeUser *stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
248
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
249 static void group_add(struct mwGaimPluginData *pd, GaimGroup *group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
250
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
251 static GaimGroup *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
252 group_ensure(GaimConnection *gc, struct mwSametimeGroup *stgroup);
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 struct mwAwareList *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
255 list_ensure(struct mwGaimPluginData *pd, GaimGroup *group);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
258 /* session functions */
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 static struct mwSession *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
261 gc_to_session(GaimConnection *gc);
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 GaimConnection *session_to_gc(struct mwSession *session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
264
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 /* conference functions */
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 static struct mwConference *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
269 conf_find_by_id(struct mwGaimPluginData *pd, int id);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
272 /* conversation functions */
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 struct convo_msg {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
275 enum mwImSendType type;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
276 gpointer data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
277 GDestroyNotify clear;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
278 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
279
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
280
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
281 struct convo_data {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
282 struct mwConversation *conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
283 GList *queue; /**< outgoing message queue, list of convo_msg */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
284 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
285
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
286 static void convo_data_new(struct mwConversation *conv);
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 static void convo_data_free(struct convo_data *conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
289
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
290 static void convo_features(struct mwConversation *conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
291
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
292 static GaimConversation *convo_get_gconv(struct mwConversation *conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
293
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 /* resolved id */
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 struct resolved_id {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
298 char *id;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
299 char *name;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
300 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
301
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
302
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
303 /* ----- session ------ */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
304
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
305
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
306 /** resolves a mwSession from a GaimConnection */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
307 static struct mwSession *gc_to_session(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
308 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
309
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
310 g_return_val_if_fail(gc != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
311
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
312 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
313 g_return_val_if_fail(pd != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
314
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
315 return pd->session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
316 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
319 /** resolves a GaimConnection from a mwSession */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
320 static GaimConnection *session_to_gc(struct mwSession *session) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
321 struct mwGaimPluginData *pd;
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 g_return_val_if_fail(session != NULL, NULL);
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 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
326 g_return_val_if_fail(pd != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
327
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
328 return pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
329 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
332 static int mw_session_io_write(struct mwSession *session,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
333 const char *buf, gsize len) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
334 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
335 int ret = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
336
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
337 pd = mwSession_getClientData(session);
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 /* socket was already closed. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
340 if(pd->socket == 0)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
341 return 1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
342
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
343 while(len) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
344 ret = write(pd->socket, buf, len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
345 if(ret <= 0) break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
346 len -= ret;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
347 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
348
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
349 if(len > 0) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
350 DEBUG_ERROR("write returned %i, %i bytes left unwritten\n", ret, len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
351 gaim_connection_error(pd->gc, "Connection closed (writing)");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
352 close(pd->socket);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
353 pd->socket = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
354 return -1;
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 return 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
358 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
359
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
360
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
361 static void mw_session_io_close(struct mwSession *session) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
362 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
363
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
364 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
365 if(pd->socket) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
366 close(pd->socket);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
367 pd->socket = 0;
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 }
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 static void mw_session_clear(struct mwSession *session) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
373 ; /* nothing for now */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
374 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
375
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 /* ----- aware list ----- */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
378
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
379
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
380 static void blist_resolve_alias_cb(struct mwServiceResolve *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
381 guint32 id, guint32 code, GList *results,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
382 gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
383 struct mwResolveResult *result;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
384 struct mwResolveMatch *match;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
385
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
386 g_return_if_fail(results != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
387
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
388 result = results->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
389 g_return_if_fail(result != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
390 g_return_if_fail(result->matches != NULL);
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 match = result->matches->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
393 g_return_if_fail(match != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
394
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
395 gaim_blist_server_alias_buddy(data, match->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
396 gaim_blist_node_set_string(data, BUDDY_KEY_NAME, match->name);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
400 static void mw_aware_list_on_aware(struct mwAwareList *list,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
401 struct mwAwareSnapshot *aware) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
402
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
403 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
404 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
405
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
406 time_t idle = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
407 guint stat = aware->status.status;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
408
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
409 const char *id = aware->id.user;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
410
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
411 gc = mwAwareList_getClientData(list);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
412 pd = gc->proto_data;
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 switch(stat) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
415 case mwStatus_IDLE:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
416 idle = -1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
417 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
418
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
419 case mwStatus_AWAY:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
420 case mwStatus_BUSY:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
421 /* need to let gaim know that these are 'unavailable' states */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
422
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
423 /* XXX */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
424 /* stat |= UC_UNAVAILABLE; */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
425
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
426 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
427 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
428
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
429 if(aware->group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
430 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
431 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
432 GaimBuddy *buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
433 GaimBlistNode *bnode;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
434
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
435 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
436 group = g_hash_table_lookup(pd->group_list_map, list);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
437 buddy = gaim_find_buddy_in_group(acct, id, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
438 bnode = (GaimBlistNode *) buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
439
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
440 if(! buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
441 struct mwServiceResolve *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
442 GList *query;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
443
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
444 buddy = gaim_buddy_new(acct, id, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
445 gaim_blist_add_buddy(buddy, NULL, group, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
446
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
447 bnode = (GaimBlistNode *) buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
448
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
449 /* mark buddy as transient if preferences do not indicate that
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
450 we should save the buddy between gaim sessions */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
451 if(! gaim_prefs_get_bool(MW_PRPL_OPT_SAVE_DYNAMIC))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
452 bnode->flags |= GAIM_BLIST_NODE_FLAG_NO_SAVE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
453
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
454 srvc = pd->srvc_resolve;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
455 query = g_list_append(NULL, (char *) id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
456
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
457 mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
458 blist_resolve_alias_cb, buddy, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
459 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
460
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
461 gaim_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
462 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
463
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
464 /* XXX */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
465 /* serv_got_update(gc, id, aware->online, 0, 0, idle, stat); */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
466 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
467
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
468
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
469 static void mw_aware_list_on_attrib(struct mwAwareList *list,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
470 struct mwAwareIdBlock *id,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
471 struct mwAwareAttribute *attrib) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
472
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
473 ; /* nothing. We'll get attribute data as we need it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
474 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
475
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 static void mw_aware_list_clear(struct mwAwareList *list) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
478 ; /* nothing for now */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
479 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
482 static struct mwAwareListHandler mw_aware_list_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
483 .on_aware = mw_aware_list_on_aware,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
484 .on_attrib = mw_aware_list_on_attrib,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
485 .clear = mw_aware_list_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
486 };
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
489 /** 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
490 returns that list. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
491 static struct mwAwareList *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
492 list_ensure(struct mwGaimPluginData *pd, GaimGroup *group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
493
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
494 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
495
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
496 g_return_val_if_fail(pd != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
497 g_return_val_if_fail(group != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
498
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
499 list = g_hash_table_lookup(pd->group_list_map, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
500 if(! list) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
501 list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
502 mwAwareList_setClientData(list, pd->gc, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
503
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
504 mwAwareList_watchAttributes(list,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
505 mwAttribute_AV_PREFS_SET,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
506 mwAttribute_MICROPHONE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
507 mwAttribute_SPEAKERS,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
508 mwAttribute_VIDEO_CAMERA,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
509 mwAttribute_FILE_TRANSFER,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
510 NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
511
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
512 g_hash_table_replace(pd->group_list_map, group, list);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
513 g_hash_table_insert(pd->group_list_map, list, group);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
516 return list;
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
520 static void blist_export(GaimConnection *gc, struct mwSametimeList *stlist) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
521 /* - find the account for this connection
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
522 - iterate through the buddy list
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
523 - add each buddy matching this account to the stlist
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
524 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
525
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
526 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
527 GaimBuddyList *blist;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
528 GaimBlistNode *gn, *cn, *bn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
529 GaimGroup *grp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
530 GaimBuddy *bdy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
531
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
532 struct mwSametimeGroup *stg = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
533 struct mwIdBlock idb = { NULL, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
534
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
535 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
536 g_return_if_fail(acct != NULL);
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 blist = gaim_get_blist();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
539 g_return_if_fail(blist != 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 for(gn = blist->root; gn; gn = gn->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
542 const char *owner;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
543 const char *gname;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
544 enum mwSametimeGroupType gtype;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
545 gboolean gopen;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
546
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
547 if(! GAIM_BLIST_NODE_IS_GROUP(gn)) continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
548 grp = (GaimGroup *) gn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
549
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
550 /* the group's type (normal or dynamic) */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
551 gtype = gaim_blist_node_get_int(gn, GROUP_KEY_TYPE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
552 if(! gtype) gtype = mwSametimeGroup_NORMAL;
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 /* 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
555 if(gtype == mwSametimeGroup_NORMAL && !gaim_group_on_account(grp, acct))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
556 continue;
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 /* 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
559 owner = gaim_blist_node_get_string(gn, GROUP_KEY_OWNER);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
560 if(owner && strcmp(owner, gaim_account_get_username(acct)))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
561 continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
562
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
563 /* 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
564 name. Find whichever is there */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
565 gname = gaim_blist_node_get_string(gn, GROUP_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
566 if(! gname) gname = grp->name;
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 /* we save this, but never actually honor it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
569 gopen = ! gaim_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
570
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
571 stg = mwSametimeGroup_new(stlist, gtype, gname);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
572 mwSametimeGroup_setAlias(stg, grp->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
573 mwSametimeGroup_setOpen(stg, gopen);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
574
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
575 for(cn = gn->child; cn; cn = cn->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
576 if(! GAIM_BLIST_NODE_IS_CONTACT(cn)) continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
577
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
578 for(bn = cn->child; bn; bn = bn->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
579 if(! GAIM_BLIST_NODE_IS_BUDDY(bn)) continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
580 if(! GAIM_BLIST_NODE_SHOULD_SAVE(bn)) continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
581
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
582 bdy = (GaimBuddy *) bn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
583
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
584 if(bdy->account == acct) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
585 struct mwSametimeUser *stu;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
586 enum mwSametimeUserType utype;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
587
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
588 idb.user = bdy->name;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
589
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
590 utype = gaim_blist_node_get_int(bn, BUDDY_KEY_TYPE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
591 if(! utype) utype = mwSametimeUser_NORMAL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
592
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
593 stu = mwSametimeUser_new(stg, utype, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
594 mwSametimeUser_setShortName(stu, bdy->server_alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
595 mwSametimeUser_setAlias(stu, bdy->alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
596 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
597 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
598 }
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
601
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
602
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
603 static void blist_store(struct mwGaimPluginData *pd) {
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 struct mwSametimeList *stlist;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
606 struct mwServiceStorage *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
607 struct mwStorageUnit *unit;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
608
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
609 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
610
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
611 struct mwPutBuffer *b;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
612 struct mwOpaque *o;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
613
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
614 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
615
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
616 srvc = pd->srvc_store;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
617 g_return_if_fail(srvc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
618
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
619 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
620
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
621 /* check if we should do this, according to user prefs */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
622 if(! BLIST_CHOICE_IS_SAVE()) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
623 DEBUG_INFO("preferences indicate not to save remote blist\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
624 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
625
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
626 } else if(MW_SERVICE_IS_DEAD(srvc)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
627 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
628 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
629
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
630 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
631 DEBUG_INFO("saving remote blist\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
632 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
633
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
634 /* create and export to a list object */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
635 stlist = mwSametimeList_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
636 blist_export(gc, stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
637
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
638 /* write it to a buffer */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
639 b = mwPutBuffer_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
640 mwSametimeList_put(b, stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
641 mwSametimeList_free(stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
642
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
643 /* put the buffer contents into a storage unit */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
644 unit = mwStorageUnit_new(mwStore_AWARE_LIST);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
645 o = mwStorageUnit_asOpaque(unit);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
646 mwPutBuffer_finalize(o, b);
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 /* save the storage unit to the service */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
649 mwServiceStorage_save(srvc, unit, NULL, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
650 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
653 static gboolean blist_save_cb(gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
654 struct mwGaimPluginData *pd = data;
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 blist_store(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
657 pd->save_event = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
658 return FALSE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
659 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
662 /** schedules the buddy list to be saved to the server */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
663 static void blist_schedule(struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
664 if(pd->save_event) return;
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 pd->save_event = gaim_timeout_add(BLIST_SAVE_SECONDS * 1000,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
667 blist_save_cb, pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
668 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
669
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
670
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
671 /** 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
672 list to be saved to the server */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
673 static void buddy_add(struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
674 GaimBuddy *buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
675
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
676 struct mwAwareIdBlock idb = { mwAware_USER, (char *) buddy->name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
677 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
678
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
679 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
680 GList *add;
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 add = g_list_prepend(NULL, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
683
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
684 group = gaim_find_buddys_group(buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
685 list = list_ensure(pd, group);
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 if(mwAwareList_addAware(list, add)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
688 gaim_blist_remove_buddy(buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
689 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
690
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
691 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
692
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
693 g_list_free(add);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
694 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
695
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 /** ensure that a GaimBuddy exists in the group with data
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
698 appropriately matching the st user entry from the st list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
699 static GaimBuddy *buddy_ensure(GaimConnection *gc, GaimGroup *group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
700 struct mwSametimeUser *stuser) {
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 struct mwGaimPluginData *pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
703 GaimBuddy *buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
704 GaimAccount *acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
705
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
706 const char *id = mwSametimeUser_getUser(stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
707 const char *name = mwSametimeUser_getShortName(stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
708 const char *alias = mwSametimeUser_getAlias(stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
709 enum mwSametimeUserType type = mwSametimeUser_getType(stuser);
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 g_return_val_if_fail(id != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
712 g_return_val_if_fail(strlen(id) > 0, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
713
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
714 buddy = gaim_find_buddy_in_group(acct, id, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
715 if(! buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
716 buddy = gaim_buddy_new(acct, id, alias);
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 gaim_blist_add_buddy(buddy, NULL, group, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
719 buddy_add(pd, buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
720 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
721
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
722 gaim_blist_alias_buddy(buddy, alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
723 gaim_blist_server_alias_buddy(buddy, name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
724 gaim_blist_node_set_string((GaimBlistNode *) buddy, BUDDY_KEY_NAME, name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
725 gaim_blist_node_set_int((GaimBlistNode *) buddy, BUDDY_KEY_TYPE, type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
726
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
727 return buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
728 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
729
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 static void group_add(struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
732 GaimGroup *group) {
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 struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
735 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
736 const char *n;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
737 GList *add;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
738
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
739 n = gaim_blist_node_get_string((GaimBlistNode *) group, GROUP_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
740 if(! n) n = group->name;
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 idb.user = (char *) n;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
743 add = g_list_prepend(NULL, &idb);
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 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
746 mwAwareList_addAware(list, add);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
747 g_list_free(add);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
748 }
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 /** ensure that a GaimGroup exists in the blist with data
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
752 appropriately matching the st group entry from the st list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
753 static GaimGroup *group_ensure(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
754 struct mwSametimeGroup *stgroup) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
755 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
756 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
757 GaimBlistNode *gn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
758 const char *name = mwSametimeGroup_getName(stgroup);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
759 const char *alias = mwSametimeGroup_getAlias(stgroup);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
760 const char *owner;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
761 enum mwSametimeGroupType type = mwSametimeGroup_getType(stgroup);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
762
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
763 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
764 owner = gaim_account_get_username(acct);
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 group = gaim_find_group(alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
767 if(! group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
768 group = gaim_group_new(alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
769 gaim_blist_add_group(group, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
770 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
771
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
772 gn = (GaimBlistNode *) group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
773
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
774 gaim_blist_node_set_string(gn, GROUP_KEY_NAME, name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
775 gaim_blist_node_set_int(gn, GROUP_KEY_TYPE, type);
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 if(type == mwSametimeGroup_DYNAMIC) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
778 gaim_blist_node_set_string(gn, GROUP_KEY_OWNER, owner);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
779 group_add(gc->proto_data, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
780 }
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 group;
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
786 /** merge the entries from a st list into the gaim blist */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
787 static void blist_import(GaimConnection *gc, struct mwSametimeList *stlist) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
788 struct mwSametimeGroup *stgroup;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
789 struct mwSametimeUser *stuser;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
790
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
791 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
792 GaimBuddy *buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
793
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
794 GList *gl, *gtl, *ul, *utl;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
795
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
796 gl = gtl = mwSametimeList_getGroups(stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
797 for(; gl; gl = gl->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
798
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
799 stgroup = (struct mwSametimeGroup *) gl->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
800 group = group_ensure(gc, stgroup);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
801
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
802 ul = utl = mwSametimeGroup_getUsers(stgroup);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
803 for(; ul; ul = ul->next) {
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 stuser = (struct mwSametimeUser *) ul->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
806 buddy = buddy_ensure(gc, group, stuser);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
807 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
808 g_list_free(utl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
809 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
810 g_list_free(gtl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
811 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
812
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
813
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
814 /** 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
815 st list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
816 static void fetch_blist_cb(struct mwServiceStorage *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
817 guint32 result, struct mwStorageUnit *item,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
818 gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
819
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
820 struct mwGaimPluginData *pd = data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
821 struct mwSametimeList *stlist;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
822 struct mwSession *s;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
823
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
824 struct mwGetBuffer *b;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
825
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
826 g_return_if_fail(result == ERR_SUCCESS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
827
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
828 /* check our preferences for loading */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
829 if(BLIST_CHOICE_IS_NONE()) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
830 DEBUG_INFO("preferences indicate not to load remote buddy list\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
831 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
832 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
833
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
834 b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
835
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
836 stlist = mwSametimeList_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
837 mwSametimeList_get(b, stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
838
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
839 s = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
840 blist_import(pd->gc, stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
841
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
842 mwSametimeList_free(stlist);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
843 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
844
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
845
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
846 /** callback passed to the storage service when it's told to load one
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
847 of the default status messages */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
848 static void fetch_msg_cb(struct mwServiceStorage *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
849 guint32 result, struct mwStorageUnit *item,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
850 gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
851
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
852 struct mwGaimPluginData *pd = data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
853 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
854 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
855 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
856 char *msg, *m;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
857
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
858 g_return_if_fail(result == ERR_SUCCESS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
859
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
860 g_return_if_fail(pd != NULL);
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 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
863 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
864
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
865 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
866 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
867
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
868 session = pd->session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
869 g_return_if_fail(session != NULL);
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 m = msg = mwStorageUnit_asString(item);
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 /* only load the first (non-empty) line of the collection of
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
874 status messages */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
875 if(m && *m) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
876 while(*m && isspace(*m)) m++;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
877 if(*m) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
878 char *tail;
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 tail = strchr(m, '\r');
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
881 if(tail) *tail = '\0';
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
882 tail = strchr(m, '\n');
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
883 if(tail) *tail = '\0';
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
886
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
887 switch(mwStorageUnit_getKey(item)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
888 case mwStore_AWAY_MESSAGES:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
889 DEBUG_INFO("setting away message to \"%s\"\n", NSTR(m));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
890 gaim_account_set_string(acct, MW_KEY_AWAY_MSG, m);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
891 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
892
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
893 case mwStore_BUSY_MESSAGES:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
894 DEBUG_INFO("setting busy message to \"%s\"\n", NSTR(m));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
895 gaim_account_set_string(acct, MW_KEY_BUSY_MSG, m);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
896 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
897
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
898 case mwStore_ACTIVE_MESSAGES:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
899 DEBUG_INFO("setting active message to \"%s\"\n", NSTR(m));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
900 gaim_account_set_string(acct, MW_KEY_ACTIVE_MSG, m);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
901 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
902
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
903 default:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
904 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
905 g_return_if_reached();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
906 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
907
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
908 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
909 msg = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
910
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
911 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
912 /* XXX */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
913 if(!gc->away_state || !strcmp(gc->away_state, MW_STATE_ACTIVE)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
914 msg = MW_STATE_ACTIVE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
915 } else if(gc->away_state && !strcmp(gc->away_state, MW_STATE_AWAY)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
916 msg = MW_STATE_AWAY;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
917 } else if(gc->away_state && !strcmp(gc->away_state, MW_STATE_BUSY)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
918 msg = MW_STATE_BUSY;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
919 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
920
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
921 if(msg)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
922 serv_set_away(gc, msg, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
923 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
924 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
925
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
926
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
927 /** signal triggered when a conversation is opened in Gaim */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
928 static void conversation_created_cb(GaimConversation *g_conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
929 struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
930
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
931 /* 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
932 conversation right away, otherwise it'll wait until the first
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
933 message is sent before offering NotesBuddy features. Therefore
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
934 whenever Gaim creates a conversation, we'll immediately open the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
935 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
936 handle. Unfortunately, this makes us vulnerable to Psychic Mode,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
937 whereas a more lazy negotiation based on the first message
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
938 isn't */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
939
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
940 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
941 struct mwIdBlock who = { 0, 0 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
942 struct mwConversation *conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
943
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
944 gc = gaim_conversation_get_gc(g_conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
945 if(pd->gc != gc)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
946 return; /* not ours */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
947
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
948 if(gaim_conversation_get_type(g_conv) != GAIM_CONV_IM)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
949 return; /* wrong type */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
950
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
951 who.user = (char *) gaim_conversation_get_name(g_conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
952 conv = mwServiceIm_getConversation(pd->srvc_im, &who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
953
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
954 convo_features(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
955
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
956 if(mwConversation_isClosed(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
957 mwConversation_open(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
958 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
959
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
960
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
961 static void blist_menu_nab(GaimBlistNode *node, gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
962 struct mwGaimPluginData *pd = data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
963 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
964
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
965 GaimGroup *group = (GaimGroup *) node;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
966
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
967 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
968 char *tmp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
969
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
970 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
971
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
972 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
973 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
974
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
975 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(node));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
976
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
977 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
978
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
979 tmp = (char *) gaim_blist_node_get_string(node, GROUP_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
980
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
981 g_string_append_printf(str, "<b>Group Title:</b> %s<br>", group->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
982 g_string_append_printf(str, "<b>Notes Group ID:</b> %s<br>", tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
983
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
984 tmp = g_strdup_printf("Info for Group %s", group->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
985
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
986 gaim_notify_formatted(gc, tmp, "Notes Address Book Information",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
987 NULL, str->str, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
988
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
989 g_free(tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
990 g_string_free(str, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
991 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
992
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
993
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
994 /** 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
995 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
996 handler */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
997 static void blist_node_menu_cb(GaimBlistNode *node,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
998 GList **menu, struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
999 GaimBlistNodeAction *act;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1000
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1001 if(GAIM_BLIST_NODE_IS_GROUP(node)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1002 const char *owner;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1003 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1004
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1005 owner = gaim_blist_node_get_string(node, GROUP_KEY_OWNER);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1006 if(! owner) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1007
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1008 acct = gaim_accounts_find(owner, PLUGIN_ID);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1009 if(! acct) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1010 if(! gaim_account_is_connected(acct)) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1011 if(acct != gaim_connection_get_account(pd->gc)) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1012
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1013 act = gaim_blist_node_action_new("Get Notes Address Book Info",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1014 blist_menu_nab, pd, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1015
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1016 *menu = g_list_append(*menu, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1017 *menu = g_list_append(*menu, act);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1018 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1019 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1020
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1021
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1022 /** Last thing to happen from a started session */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1023 static void services_starting(struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1024
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1025 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1026 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1027 struct mwStorageUnit *unit;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1028 GaimBuddyList *blist;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1029 GaimBlistNode *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1030
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1031 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1032 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1033
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1034 /* grab the buddy list from the server */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1035 unit = mwStorageUnit_new(mwStore_AWARE_LIST);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1036 mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1037
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1038 /* fetch the away/busy/active messages from the server */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1039 unit = mwStorageUnit_new(mwStore_AWAY_MESSAGES);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1040 mwServiceStorage_load(pd->srvc_store, unit, fetch_msg_cb, pd, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1041
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1042 unit = mwStorageUnit_new(mwStore_BUSY_MESSAGES);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1043 mwServiceStorage_load(pd->srvc_store, unit, fetch_msg_cb, pd, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1044
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1045 unit = mwStorageUnit_new(mwStore_ACTIVE_MESSAGES);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1046 mwServiceStorage_load(pd->srvc_store, unit, fetch_msg_cb, pd, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1047
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1048 /* start watching for new conversations */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1049 gaim_signal_connect(gaim_conversations_get_handle(),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1050 "conversation-created", gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1051 GAIM_CALLBACK(conversation_created_cb), pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1052
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1053 /* watch for group extended menu items */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1054 gaim_signal_connect(gaim_blist_get_handle(),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1055 "blist-node-extended-menu", gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1056 GAIM_CALLBACK(blist_node_menu_cb), pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1057
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1058 /* find all the NAB groups and subscribe to them */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1059 blist = gaim_get_blist();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1060 for(l = blist->root; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1061 GaimGroup *group = (GaimGroup *) l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1062 enum mwSametimeGroupType gt;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1063 const char *owner;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1064
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1065 if(! GAIM_BLIST_NODE_IS_GROUP(l)) continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1066
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1067 /* 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
1068 skip it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1069 owner = gaim_blist_node_get_string(l, GROUP_KEY_OWNER);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1070 if(!owner || strcmp(owner, gaim_account_get_username(acct)))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1071 continue;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1072
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1073 gt = gaim_blist_node_get_int(l, GROUP_KEY_TYPE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1074 if(gt == mwSametimeGroup_DYNAMIC)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1075 group_add(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1076 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1077
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1078 /* set the aware attributes */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1079 /* 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
1080 mwServiceAware_setAttributeBoolean(pd->srvc_aware,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1081 mwAttribute_AV_PREFS_SET, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1082 mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1083 mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1084 mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1085
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1086 /* ... but we can do file transfers! */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1087 mwServiceAware_setAttributeBoolean(pd->srvc_aware,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1088 mwAttribute_FILE_TRANSFER, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1089 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1090
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1091
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1092 /** called from mw_session_stateChange when the session's state is
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1093 mwSession_STARTED. Any finalizing of start-up stuff should go
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1094 here */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1095 static void session_started(struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1096
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1097 /* XXX setup status */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1098
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1099 /* use our services to do neat things */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1100 services_starting(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1101 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1102
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1103
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1104 static void mw_session_stateChange(struct mwSession *session,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1105 enum mwSessionState state, guint32 info) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1106 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1107 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1108 char *msg = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1109
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1110 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1111 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1112
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1113 switch(state) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1114 case mwSession_STARTING:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1115 msg = _("Sending Handshake");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1116 gaim_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1117 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1118
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1119 case mwSession_HANDSHAKE:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1120 msg = _("Waiting for Handshake Acknowledgement");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1121 gaim_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1122 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1123
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1124 case mwSession_HANDSHAKE_ACK:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1125 msg = _("Handshake Acknowledged, Sending Login");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1126 gaim_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1127 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1128
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1129 case mwSession_LOGIN:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1130 msg = _("Waiting for Login Acknowledgement");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1131 gaim_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1132 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1133
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1134 case mwSession_LOGIN_REDIR:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1135 msg = _("Login Redirected");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1136 gaim_connection_update_progress(gc, msg, 6, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1137 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1138
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1139 case mwSession_LOGIN_ACK:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1140 msg = _("Login Acknowledged");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1141 gaim_connection_update_progress(gc, msg, 7, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1142 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1143
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1144 case mwSession_STARTED:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1145 msg = _("Connected to Sametime Community Server");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1146 gaim_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1147 gaim_connection_set_state(gc, GAIM_CONNECTED);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1148 /* XXX serv_finish_login(gc); */
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 session_started(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1151 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1152
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1153 case mwSession_STOPPING:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1154 if(info & ERR_FAILURE) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1155 msg = mwError(info);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1156 gaim_connection_error(gc, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1157 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1158 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1159 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1160
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1161 case mwSession_STOPPED:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1162 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1163
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1164 case mwSession_UNKNOWN:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1165 default:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1166 DEBUG_WARN("session in unknown state\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1167 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1168 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1169
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1170
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1171 static void mw_session_setPrivacyInfo(struct mwSession *session) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1172 /** @todo implement privacy one of these days */
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 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1175 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1176 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1177 struct mwPrivacyInfo *privacy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1178 GSList *l, **ll;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1179 guint count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1180
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1181 DEBUG_INFO("privacy information set from server\n");
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 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1184
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1185 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1186 g_return_if_fail(pd != NULL);
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 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1189 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1190
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1191 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1192 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1193
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1194 privacy = mwSession_getPrivacyInfo(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1195 count = privacy->count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1196
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1197 ll = (privacy->deny)? &acct->deny: &acct->permit;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1198 for(l = *ll; l; l = l->next) g_free(l->data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1199 g_slist_free(*ll);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1200 l = *ll = 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 while(count--) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1203 struct mwUserItem *u = privacy->users + count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1204 l = g_slist_prepend(l, g_strdup(u->id));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1205 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1206 *ll = l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1207 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1208
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1209
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1210 static void mw_session_setUserStatus(struct mwSession *session) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1211 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1212 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1213 struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1214 struct mwUserStatus *stat;
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 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1217
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1218 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1219 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1220
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1221 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1222 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1223
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1224 idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1225 stat = mwSession_getUserStatus(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1226
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1227 /* 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
1228 mwServiceAware_setStatus(pd->srvc_aware, &idb, stat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1229 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1230
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1231
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1232 static void mw_session_admin(struct mwSession *session,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1233 const char *text) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1234
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1235 GaimConnection *gc = session_to_gc(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1236 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1237
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1238 /** @todo Admin alerts should probably be in a conversation window
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1239 rather than a gaim_notify_message. Or in some sort of updating
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1240 dialog, or something. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1241
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1242 gaim_notify_message(gc, GAIM_NOTIFY_MSG_INFO, _("Admin Alert"),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1243 text, NULL, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1244 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1245
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1246
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1247 /** 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
1248 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
1249 call for handling in read_cb */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1250 static int read_recv(struct mwSession *session, int sock) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1251 char buf[BUF_LEN];
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1252 int len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1253
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1254 len = read(sock, buf, BUF_LEN);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1255 if(len > 0) mwSession_recv(session, buf, len);
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 return len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1258 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1259
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1260
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1261 /** callback triggered from gaim_input_add, watches the socked for
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1262 available data to be processed by the session */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1263 static void read_cb(gpointer data, gint source,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1264 GaimInputCondition cond) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1265
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1266 struct mwGaimPluginData *pd = data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1267 int ret = 0, err = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1268
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1269 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1270
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1271 if(cond & GAIM_INPUT_READ) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1272 ret = read_recv(pd->session, pd->socket);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1273 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1274
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1275 /* normal operation ends here */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1276 if(ret > 0) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1277
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1278 err = errno;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1279
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1280 /* 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
1281 it and clean up internal state */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1282
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1283 if(pd->socket) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1284 close(pd->socket);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1285 pd->socket = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1286 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1287
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1288 if(pd->gc->inpa) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1289 gaim_input_remove(pd->gc->inpa);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1290 pd->gc->inpa = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1291 }
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 if(! ret) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1294 DEBUG_INFO("connection reset\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1295 gaim_connection_error(pd->gc, "Connection reset");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1296
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1297 } else if(ret < 0) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1298 char *msg = strerror(err);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1299 DEBUG_INFO("error in read callback: %s\n", msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1300
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1301 msg = g_strdup_printf("Error reading from socket: %s", msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1302 gaim_connection_error(pd->gc, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1303 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1304 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1307
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1308 /** Callback passed to gaim_proxy_connect when an account is logged
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1309 in, and if the session logging in receives a redirect message */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1310 static void connect_cb(gpointer data, gint source,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1311 GaimInputCondition cond) {
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 struct mwGaimPluginData *pd = data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1314 GaimConnection *gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1315
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1316 if(! g_list_find(gaim_connections_get_all(), pd->gc)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1317 close(source);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1318 g_return_if_reached();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1319 }
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 if(source < 0) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1322 /* connection failed */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1323
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1324 if(pd->socket) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1325 /* this is a redirect connect, force login on existing socket */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1326 mwSession_forceLogin(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1327
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1328 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1329 /* this is a regular connect, error out */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1330 gaim_connection_error(pd->gc, "Unable to connect to host");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1331 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1332
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1333 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1334 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1335
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1336 if(pd->socket) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1337 /* stop any existing login attempt */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1338 mwSession_stop(pd->session, ERR_SUCCESS);
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 pd->socket = source;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1342 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
1343
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1344 mwSession_start(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1345 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1346
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1347
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1348 static void mw_session_loginRedirect(struct mwSession *session,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1349 const char *host) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1350
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1351 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1352 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1353 GaimAccount *account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1354 guint port;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1355
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1356 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1357 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1358 account = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1359 port = gaim_account_get_int(account, "port", MW_PLUGIN_DEFAULT_PORT);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1360
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1361 if(gaim_prefs_get_bool(MW_PRPL_OPT_FORCE_LOGIN) ||
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1362 gaim_proxy_connect(account, host, port, connect_cb, pd)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1363
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1364 mwSession_forceLogin(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1365 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1366 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1367
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1368
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1369 static struct mwSessionHandler mw_session_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1370 .io_write = mw_session_io_write,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1371 .io_close = mw_session_io_close,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1372 .clear = mw_session_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1373 .on_stateChange = mw_session_stateChange,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1374 .on_setPrivacyInfo = mw_session_setPrivacyInfo,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1375 .on_setUserStatus = mw_session_setUserStatus,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1376 .on_admin = mw_session_admin,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1377 .on_loginRedirect = mw_session_loginRedirect,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1378 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1379
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1380
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1381 static void mw_aware_on_attrib(struct mwServiceAware *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1382 struct mwAwareAttribute *attrib) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1383
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1384 ; /** @todo handle server attributes. There may be some stuff we
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1385 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
1386 now.*/
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1387 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1388
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 static void mw_aware_clear(struct mwServiceAware *srvc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1391 ; /* nothing for now */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1392 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1393
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1394
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1395 static struct mwAwareHandler mw_aware_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1396 .on_attrib = mw_aware_on_attrib,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1397 .clear = mw_aware_clear,
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1400
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1401 static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1402 struct mwServiceAware *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1403 srvc = mwServiceAware_new(s, &mw_aware_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1404 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1405 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1406
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 static void mw_conf_invited(struct mwConference *conf,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1409 struct mwLoginInfo *inviter,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1410 const char *invitation) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1411
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1412 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1413 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1414 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1415 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1416
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1417 char *c_inviter, *c_name, *c_topic, *c_invitation;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1418 GHashTable *ht;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1419
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1420 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1421 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1422 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1423 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1424
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1425 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
1426
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1427 c_inviter = g_strdup(inviter->user_id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1428 g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1429
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1430 c_name = g_strdup(mwConference_getName(conf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1431 g_hash_table_insert(ht, CHAT_KEY_NAME, c_name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1432
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1433 c_topic = g_strdup(mwConference_getTitle(conf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1434 g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1435
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1436 c_invitation = g_strdup(invitation);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1437 g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1438
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1439 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
1440 NSTR(c_inviter), NSTR(c_name),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1441 NSTR(c_topic), NSTR(c_invitation));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1442
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1443 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
1444 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1445
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1446
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1447 /* The following mess helps us relate a mwConference to a GaimConvChat
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1448 in the various forms by which either may be indicated */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1449
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1450 #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1451 #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
1452
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1453 #define CHAT_TO_ID(chat) (gaim_conv_chat_get_id(chat))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1454 #define ID_TO_CHAT(id) (gaim_find_chat(id))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1455
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1456 #define CHAT_TO_CONF(pd, chat) \
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1457 (ID_TO_CONF((pd), CHAT_TO_ID(chat)))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1458
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1459 #define CONF_TO_CHAT(conf) \
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1460 (ID_TO_CHAT(CONF_TO_ID(conf)))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1461
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1462
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1463 static struct mwConference *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1464 conf_find_by_id(struct mwGaimPluginData *pd, int id) {
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 struct mwServiceConference *srvc = pd->srvc_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1467 struct mwConference *conf = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1468 GList *l, *ll;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1469
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1470 ll = mwServiceConference_getConferences(srvc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1471 for(l = ll; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1472 struct mwConference *c = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1473 GaimConvChat *h = mwConference_getClientData(c);
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 if(CHAT_TO_ID(h) == id) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1476 conf = c;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1477 break;
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1480 g_list_free(ll);
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 return conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1483 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1486 static void mw_conf_opened(struct mwConference *conf, GList *members) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1487 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1488 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1489 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1490 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1491 GaimConversation *g_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1492
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1493 const char *n = mwConference_getName(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1494
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1495 DEBUG_INFO("conf %s opened, %u initial members\n",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1496 NSTR(n), g_list_length(members));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1497
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1498 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1499 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1500 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1501 gc = pd->gc;
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 g_conf = serv_got_joined_chat(gc, CONF_TO_ID(conf),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1504 mwConference_getTitle(conf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1505
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1506 mwConference_setClientData(conf, GAIM_CONV_CHAT(g_conf), NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1507
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1508 for(; members; members = members->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1509 struct mwLoginInfo *peer = members->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1510 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
1511 NULL, GAIM_CBFLAGS_NONE, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1512 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1513 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1516 static void mw_conf_closed(struct mwConference *conf, guint32 reason) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1517 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1518 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1519 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1520 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1521
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1522 const char *n = mwConference_getName(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1523 char *msg = mwError(reason);
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 DEBUG_INFO("conf %s closed, 0x%08x\n", NSTR(n), reason);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1526
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1527 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1528 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1529 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1530 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1531
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1532 serv_got_chat_left(gc, CONF_TO_ID(conf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1533
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1534 gaim_notify_error(gc, "Conference Closed", NULL, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1535 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1536 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1537
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1538
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1539 static void mw_conf_peer_joined(struct mwConference *conf,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1540 struct mwLoginInfo *peer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1541
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1542 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1543 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1544 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1545 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1546 GaimConvChat *g_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1547
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1548 const char *n = mwConference_getName(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1549
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1550 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
1551
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1552 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1553 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1554 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1555 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1556
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1557 g_conf = mwConference_getClientData(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1558 g_return_if_fail(g_conf != NULL);
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 gaim_conv_chat_add_user(g_conf, peer->user_id,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1561 NULL, GAIM_CBFLAGS_NONE, TRUE);
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
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 static void mw_conf_peer_parted(struct mwConference *conf,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1566 struct mwLoginInfo *peer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1567
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1568 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1569 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1570 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1571 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1572 GaimConvChat *g_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1573
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1574 const char *n = mwConference_getName(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1575
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1576 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
1577
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1578 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1579 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1580 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1581 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1582
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1583 g_conf = mwConference_getClientData(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1584 g_return_if_fail(g_conf != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1585
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1586 gaim_conv_chat_remove_user(g_conf, peer->user_id, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1587 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1588
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 static void mw_conf_text(struct mwConference *conf,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1591 struct mwLoginInfo *who, const char *text) {
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 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1594 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1595 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1596 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1597 char *esc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1598
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1599 srvc = mwConference_getService(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1600 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1601 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1602 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1603
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1604 esc = g_markup_escape_text(text, -1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1605 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
1606 g_free(esc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1607 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1608
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1609
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1610 static void mw_conf_typing(struct mwConference *conf,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1611 struct mwLoginInfo *who, gboolean typing) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1612
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1613 /* 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
1614
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1615 const char *n = mwConference_getName(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1616 const char *w = who->user_id;
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 if(typing) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1619 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
1620
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1621 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1622 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
1623 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1624 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1625
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 static void mw_conf_clear(struct mwServiceConference *srvc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1628 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1629 }
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 static struct mwConferenceHandler mw_conference_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1633 .on_invited = mw_conf_invited,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1634 .conf_opened = mw_conf_opened,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1635 .conf_closed = mw_conf_closed,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1636 .on_peer_joined = mw_conf_peer_joined,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1637 .on_peer_parted = mw_conf_peer_parted,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1638 .on_text = mw_conf_text,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1639 .on_typing = mw_conf_typing,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1640 .clear = mw_conf_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1641 };
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 static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1645 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1646 srvc = mwServiceConference_new(s, &mw_conference_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1647 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1648 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1649
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 static void ft_incoming_cancel(GaimXfer *xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1652 /* incoming transfer rejected or canceled in-progress */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1653 struct mwFileTransfer *ft = xfer->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1654 if(ft) mwFileTransfer_reject(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1655 }
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 static void ft_incoming_init(GaimXfer *xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1659 /* incoming transfer accepted */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1660
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1661 /* - accept the mwFileTransfer
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1662 - open/create the local FILE "wb"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1663 - stick the FILE's fp in xfer->dest_fp
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1664 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1665
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1666 struct mwFileTransfer *ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1667 FILE *fp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1668
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1669 ft = xfer->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1670
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1671 fp = g_fopen(xfer->local_filename, "wb");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1672 if(! fp) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1673 mwFileTransfer_cancel(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1674 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1675 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1676
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1677 xfer->dest_fp = fp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1678 mwFileTransfer_accept(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1679 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1680
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1681
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1682 static void mw_ft_offered(struct mwFileTransfer *ft) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1683 /*
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1684 - create a gaim ft object
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1685 - offer it
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1688 struct mwServiceFileTransfer *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1689 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1690 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1691 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1692 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1693 const char *who;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1694 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1695
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1696 /* @todo add some safety checks */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1697 srvc = mwFileTransfer_getService(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1698 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1699 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1700 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1701 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1702
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1703 who = mwFileTransfer_getUser(ft)->user;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1704
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1705 DEBUG_INFO("file transfer %p offered\n", ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1706 DEBUG_INFO(" from: %s\n", NSTR(who));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1707 DEBUG_INFO(" file: %s\n", NSTR(mwFileTransfer_getFileName(ft)));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1708 DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1709 DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft)));
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 xfer = gaim_xfer_new(acct, GAIM_XFER_RECEIVE, who);
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 gaim_xfer_ref(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1714 mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) gaim_xfer_unref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1715 xfer->data = ft;
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 gaim_xfer_set_init_fnc(xfer, ft_incoming_init);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1718 gaim_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1719 gaim_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1720
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1721 gaim_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1722 gaim_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1723 gaim_xfer_set_message(xfer, mwFileTransfer_getMessage(ft));
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 gaim_xfer_request(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1726 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1727
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1728
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1729 static void ft_send(struct mwFileTransfer *ft, FILE *fp) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1730 char buf[BUF_LONG];
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1731 struct mwOpaque o = { .data = buf, .len = BUF_LONG };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1732 guint32 rem;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1733 GaimXfer *xfer;
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 xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1736
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1737 rem = mwFileTransfer_getRemaining(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1738 if(rem < BUF_LONG) o.len = rem;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1739
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1740 if(fread(buf, (size_t) o.len, 1, fp)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1741
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1742 /* calculate progress first. update is displayed upon ack */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1743 xfer->bytes_sent += o.len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1744 xfer->bytes_remaining -= o.len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1745
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1746 /* ... send data second */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1747 mwFileTransfer_send(ft, &o);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1748
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1749 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1750 int err = errno;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1751 DEBUG_WARN("problem reading from file %s: %s",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1752 NSTR(mwFileTransfer_getFileName(ft)), strerror(err));
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 mwFileTransfer_cancel(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1755 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1758
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1759 static gboolean ft_idle_cb(struct mwFileTransfer *ft) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1760 GaimXfer *xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1761 g_return_val_if_fail(xfer != NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1762
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1763 xfer->watcher = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1764 ft_send(ft, xfer->dest_fp);
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 return FALSE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1767 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1768
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 static void mw_ft_opened(struct mwFileTransfer *ft) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1771 /*
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1772 - get gaim ft from client data in ft
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1773 - set the state to active
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1774 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1775
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1776 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1777
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1778 xfer = mwFileTransfer_getClientData(ft);
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 if(! xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1781 mwFileTransfer_cancel(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1782 mwFileTransfer_free(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1783 g_return_if_reached();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1784 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1785
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1786 gaim_xfer_update_progress(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1787
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1788 if(gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1789 xfer->watcher = g_idle_add((GSourceFunc)ft_idle_cb, ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1790 xfer->dest_fp = g_fopen(xfer->local_filename, "rb");
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1793
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1794
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1795 static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) {
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 - get gaim ft from client data in ft
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1798 - indicate rejection/cancelation/completion
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1799 - free the file transfer itself
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 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1803
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1804 xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1805 if(xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1806 xfer->data = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1807
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1808 if(mwFileTransfer_isDone(ft)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1809 gaim_xfer_set_completed(xfer, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1810 gaim_xfer_end(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1811
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1812 } else if(mwFileTransfer_isCancelLocal(ft)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1813 /* calling gaim_xfer_cancel_local is redundant, since that's
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1814 probably what triggered this function to be called */
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1817 } else if(mwFileTransfer_isCancelRemote(ft)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1818 /* steal the reference for the xfer */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1819 mwFileTransfer_setClientData(ft, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1820 gaim_xfer_cancel_remote(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1821
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1822 /* drop the stolen reference */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1823 gaim_xfer_unref(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1824 return;
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1827
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1828 mwFileTransfer_free(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1829 }
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 static void mw_ft_recv(struct mwFileTransfer *ft,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1833 struct mwOpaque *data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1834 /*
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1835 - get gaim ft from client data in ft
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1836 - update transfered percentage
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1837 - if done, destroy the ft, disassociate from gaim ft
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1838 */
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 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1841 FILE *fp;
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 xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1844 g_return_if_fail(xfer != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1845
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1846 fp = xfer->dest_fp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1847 g_return_if_fail(fp != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1848
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1849 /* we must collect and save our precious data */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1850 fwrite(data->data, 1, data->len, fp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1851
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1852 /* update the progress */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1853 xfer->bytes_sent += data->len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1854 xfer->bytes_remaining -= data->len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1855 gaim_xfer_update_progress(xfer);
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 /* 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
1858 mwFileTransfer_ack(ft);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1861
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1862 static void mw_ft_ack(struct mwFileTransfer *ft) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1863 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1864
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1865 xfer = mwFileTransfer_getClientData(ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1866 g_return_if_fail(xfer != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1867 g_return_if_fail(xfer->watcher == 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1868
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1869 gaim_xfer_update_progress(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1870
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1871 if(mwFileTransfer_isOpen(ft))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1872 xfer->watcher = g_idle_add((GSourceFunc)ft_idle_cb, ft);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1873 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1876 static void mw_ft_clear(struct mwServiceFileTransfer *srvc) {
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1879
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 static struct mwFileTransferHandler mw_ft_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1882 .ft_offered = mw_ft_offered,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1883 .ft_opened = mw_ft_opened,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1884 .ft_closed = mw_ft_closed,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1885 .ft_recv = mw_ft_recv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1886 .ft_ack = mw_ft_ack,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1887 .clear = mw_ft_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1888 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1889
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1890
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1891 static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1892 struct mwServiceFileTransfer *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1893 GHashTable *ft_map;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1894
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1895 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
1896
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1897 srvc = mwServiceFileTransfer_new(s, &mw_ft_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1898 mwService_setClientData(MW_SERVICE(srvc), ft_map,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1899 (GDestroyNotify) g_hash_table_destroy);
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 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1902 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1905 static void convo_data_free(struct convo_data *cd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1906 GList *l;
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 /* clean the queue */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1909 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
1910 struct convo_msg *m = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1911 if(m->clear) m->clear(m->data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1912 g_free(m);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1913 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1914
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1915 g_free(cd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1916 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1917
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1918
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1919 /** allocates a convo_data structure and associates it with the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1920 conversation in the client data slot */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1921 static void convo_data_new(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1922 struct convo_data *cd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1923
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1924 g_return_if_fail(conv != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1925
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1926 if(mwConversation_getClientData(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1927 return;
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 cd = g_new0(struct convo_data, 1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1930 cd->conv = conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1931
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1932 mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1933 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1936 static GaimConversation *convo_get_gconv(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1937 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1938 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1939 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1940 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1941 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1942
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1943 struct mwIdBlock *idb;
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 srvc = mwConversation_getService(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1946 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1947 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1948 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1949 acct = gaim_connection_get_account(gc);
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 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1952
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1953 return gaim_find_conversation_with_account(GAIM_CONV_IM,idb->user, acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1954 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1955
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1956
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1957 static void convo_queue(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1958 enum mwImSendType type, gconstpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1959
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1960 struct convo_data *cd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1961 struct convo_msg *m;
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 convo_data_new(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1964 cd = mwConversation_getClientData(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1965
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1966 m = g_new0(struct convo_msg, 1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1967 m->type = type;
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 switch(type) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1970 case mwImSend_PLAIN:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1971 m->data = g_strdup(data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1972 m->clear = g_free;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1973 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1974
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1975 case mwImSend_TYPING:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1976 default:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1977 m->data = (gpointer) data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1978 m->clear = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1979 }
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 cd->queue = g_list_append(cd->queue, m);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1982 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1983
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 /* 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
1986 static void convo_error(struct mwConversation *conv, guint32 err) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1987 GaimConversation *gconv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1988 char *tmp, *text;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1989 struct mwIdBlock *idb;
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 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1992
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1993 tmp = mwError(err);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1994 text = g_strconcat("Unable to send message: ", tmp, NULL);
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 gconv = convo_get_gconv(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1997 if(gconv && !gaim_conv_present_error(idb->user, gconv->account, text)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1998
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1999 g_free(text);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2000 text = g_strdup_printf("Unable to send message to %s:",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2001 (idb->user)? idb->user: "(unknown)");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2002 gaim_notify_error(gaim_account_get_connection(gconv->account),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2003 NULL, text, tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2004 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2005
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2006 g_free(tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2007 g_free(text);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2008 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2009
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2010
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2011 static void convo_queue_send(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2012 struct convo_data *cd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2013 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2014
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2015 cd = mwConversation_getClientData(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2016
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2017 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
2018 struct convo_msg *m = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2019
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2020 mwConversation_send(conv, m->type, m->data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2021
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2022 if(m->clear) m->clear(m->data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2023 g_free(m);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2026 cd->queue = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2027 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2028
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2029
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2030 /** called when a mw conversation leaves a gaim conversation to
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2031 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
2032 features. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2033 static void convo_nofeatures(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2034 GaimConversation *gconv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2035 GaimConnection *gc;
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 gconv = convo_get_gconv(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2038 if(! gconv) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2039
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2040 gc = gaim_conversation_get_gc(gconv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2041
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2042 /* If the account is disconnecting, then the conversation's closing
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2043 will call this, and gc will be NULL */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2044 if(gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2045 gaim_conversation_set_features(gconv, gc->flags);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2050 /** called when a mw conversation and gaim conversation come together,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2051 to inform the gaim conversation of what features to offer the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2052 user */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2053 static void convo_features(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2054 GaimConversation *gconv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2055 GaimConnectionFlags feat;
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 gconv = convo_get_gconv(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2058 if(! gconv) return;
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 feat = gaim_conversation_get_features(gconv);
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 if(mwConversation_isOpen(conv)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2063 if(mwConversation_supports(conv, mwImSend_HTML)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2064 feat |= GAIM_CONNECTION_HTML;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2065 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2066 feat &= ~GAIM_CONNECTION_HTML;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2067 }
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 if(mwConversation_supports(conv, mwImSend_MIME)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2070 feat &= ~GAIM_CONNECTION_NO_IMAGES;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2071 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2072 feat |= GAIM_CONNECTION_NO_IMAGES;
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2075 DEBUG_INFO("conversation features set to 0x%04x\n", feat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2076 gaim_conversation_set_features(gconv, feat);
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 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2079 convo_nofeatures(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2080 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2081 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2084 /** triggered from mw_conversation_opened if the appropriate plugin
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2085 preference is set. This will open a window for the conversation
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2086 before the first message is sent. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2087 static void convo_do_psychic(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2088 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2089 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2090 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2091 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2092 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2093
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2094 struct mwIdBlock *idb;
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 GaimConversation *gconv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2097 GaimConvWindow *win;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2098
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2099 srvc = mwConversation_getService(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2100 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2101 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2102 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2103 acct = gaim_connection_get_account(gc);
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 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2106
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2107 gconv = gaim_find_conversation_with_account(GAIM_CONV_IM, idb->user, acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2108 if(! gconv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2109 gconv = gaim_conversation_new(GAIM_CONV_IM, acct, idb->user);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2110 }
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 g_return_if_fail(gconv != NULL);
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 win = gaim_conversation_get_window(gconv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2115 g_return_if_fail(win != NULL);
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 gaim_conv_window_show(win);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2118 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2119
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 static void mw_conversation_opened(struct mwConversation *conv) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2122 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2123 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2124 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2125 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2126 GaimAccount *acct;
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 struct convo_dat *cd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2129
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2130 srvc = mwConversation_getService(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2131 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2132 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2133 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2134 acct = gaim_connection_get_account(gc);
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 /* set up the queue */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2137 cd = mwConversation_getClientData(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2138 if(cd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2139 convo_queue_send(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2140
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2141 if(! convo_get_gconv(conv)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2142 mwConversation_free(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2143 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2144 }
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 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2147 convo_data_new(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2148
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2149 if(gaim_prefs_get_bool(MW_PRPL_OPT_PSYCHIC)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2150 convo_do_psychic(conv);
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2153
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2154 { /* record the client key for the buddy */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2155 GaimBuddy *buddy;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2156 struct mwLoginInfo *info;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2157 info = mwConversation_getTargetInfo(conv);
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 buddy = gaim_find_buddy(acct, info->user_id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2160 if(buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2161 gaim_blist_node_set_int((GaimBlistNode *) buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2162 BUDDY_KEY_CLIENT, info->type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2163 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2164 }
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 convo_features(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2167 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2170 static void mw_conversation_closed(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2171 guint32 reason) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2172
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2173 struct convo_data *cd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2174
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2175 g_return_if_fail(conv != NULL);
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 cd = mwConversation_getClientData(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2178 if(reason && cd && cd->queue) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2179 convo_error(conv, reason);
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 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2183 /* don't do this, to prevent the occasional weird sending of
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2184 formatted messages as plaintext when the other end closes the
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2185 conversation after we've begun composing the message */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2186 convo_nofeatures(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2187 #endif
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 mwConversation_removeClientData(conv);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2192
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2193 static void im_recv_text(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2194 struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2195 const char *msg) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2196
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2197 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2198 char *txt, *esc;
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 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2201 txt = gaim_utf8_try_convert(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2202 esc = g_markup_escape_text(txt, -1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2203
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2204 serv_got_im(pd->gc, idb->user, esc, 0, time(NULL));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2205
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2206 g_free(txt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2207 g_free(esc);
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 void im_recv_typing(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2212 struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2213 gboolean typing) {
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 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2216 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2217
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2218 serv_got_typing(pd->gc, idb->user, 0,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2219 typing? GAIM_TYPING: GAIM_NOT_TYPING);
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
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 static void im_recv_html(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2224 struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2225 const char *msg) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2226
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2227 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2228 char *txt;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2229
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2230 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2231 txt = gaim_utf8_try_convert(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2232
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2233 serv_got_im(pd->gc, idb->user, txt, 0, time(NULL));
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(txt);
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 static void im_recv_subj(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2240 struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2241 const char *subj) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2242
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2243 /** @todo somehow indicate receipt of a conversation subject. It
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2244 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
2245 protocol */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2246 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2247 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2250 /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2251 static char *make_cid(const char *cid) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2252 gsize n;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2253 char *c, *d;
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 g_return_val_if_fail(cid != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2256
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2257 n = strlen(cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2258 g_return_val_if_fail(n > 2, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2259
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2260 c = g_strndup(cid+1, n-2);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2261 d = g_strdup_printf("cid:%s", c);
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 g_free(c);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2264 return d;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2265 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2266
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2267
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2268 static void im_recv_mime(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2269 struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2270 const char *data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2271
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2272 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2273
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2274 GHashTable *img_by_cid;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2275 GList *images;
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 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2278
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2279 GaimMimeDocument *doc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2280 const GList *parts;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2281
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2282 idb = mwConversation_getTarget(conv);
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 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
2285 images = NULL;
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 /* don't want the contained string to ever be NULL */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2288 str = g_string_new("");
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 doc = gaim_mime_document_parse(data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2291
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2292 /* handle all the MIME parts */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2293 parts = gaim_mime_document_get_parts(doc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2294 for(; parts; parts = parts->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2295 GaimMimePart *part = parts->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2296 const char *type;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2297
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2298 type = gaim_mime_part_get_field(part, "content-type");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2299 DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type));
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 if(! type) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2302 ; /* feh */
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 } else if(g_str_has_prefix(type, "image")) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2305 /* put images into the image store */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2306
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2307 char *d_dat;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2308 gsize d_len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2309 char *cid;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2310 int img;
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 /* obtain and unencode the data */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2313 gaim_mime_part_get_data_decoded(part, &d_dat, &d_len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2314
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2315 /* look up the content id */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2316 cid = (char *) gaim_mime_part_get_field(part, "Content-ID");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2317 cid = make_cid(cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2318
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2319 /* add image to the gaim image store */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2320 img = gaim_imgstore_add(d_dat, d_len, cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2321
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2322 /* map the cid to the image store identifier */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2323 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
2324
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2325 /* recall the image for dereferencing later */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2326 images = g_list_append(images, GINT_TO_POINTER(img));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2327
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2328 } else if(g_str_has_prefix(type, "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 /* concatenate all the text parts together */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2331 char *data, *txt;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2332 gsize len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2333
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2334 gaim_mime_part_get_data_decoded(part, &data, &len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2335 txt = gaim_utf8_try_convert(data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2336 g_string_append(str, txt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2337 g_free(txt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2338 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2339 }
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 gaim_mime_document_free(doc);
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 { /* 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
2344 actually modifies the contents of str */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2345 GData *attribs;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2346 char *start, *end;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2347 char *tmp = str->str;
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 while(*tmp && gaim_markup_find_tag("img", tmp, (const char **) &start,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2350 (const char **) &end, &attribs)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2351
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2352 char *alt, *align, *border, *src;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2353 int img;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2354
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2355 alt = g_datalist_get_data(&attribs, "alt");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2356 align = g_datalist_get_data(&attribs, "align");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2357 border = g_datalist_get_data(&attribs, "border");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2358 src = g_datalist_get_data(&attribs, "src");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2359
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2360 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
2361 if(img) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2362 GString *atstr;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2363 gsize len = (end - start);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2364 gsize mov;
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 atstr = g_string_new("");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2367 if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2368 if(align) g_string_append_printf(atstr, " align=\"%s\"", align);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2369 if(border) g_string_append_printf(atstr, " border=\"%s\"", border);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2370
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2371 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
2372 while(mov < len) start[mov++] = ' ';
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2373
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2374 g_string_free(atstr, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2375 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2376
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2377 g_datalist_clear(&attribs);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2378 tmp = end + 1;
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2381
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2382 /* actually display the message */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2383 serv_got_im(pd->gc, idb->user, str->str, 0, time(NULL));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2384
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2385 g_string_free(str, TRUE);
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 /* clean up the cid table */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2388 g_hash_table_destroy(img_by_cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2389
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2390 /* dereference all the imgages */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2391 while(images) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2392 gaim_imgstore_unref(GPOINTER_TO_INT(images->data));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2393 images = g_list_delete_link(images, images);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2394 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2397
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2398 static void mw_conversation_recv(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2399 enum mwImSendType type,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2400 gconstpointer msg) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2401 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2402 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2403 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2404
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2405 srvc = mwConversation_getService(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2406 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2407 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2408
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2409 switch(type) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2410 case mwImSend_PLAIN:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2411 im_recv_text(conv, pd, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2412 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2413
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2414 case mwImSend_TYPING:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2415 im_recv_typing(conv, pd, !! msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2416 break;
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 case mwImSend_HTML:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2419 im_recv_html(conv, pd, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2420 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2421
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2422 case mwImSend_SUBJECT:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2423 im_recv_subj(conv, pd, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2424 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2425
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2426 case mwImSend_MIME:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2427 im_recv_mime(conv, pd, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2428 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2429
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2430 default:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2431 DEBUG_INFO("conversation received strange type, 0x%04x\n", type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2432 ; /* erm... */
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2435
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 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2438 /* this will be appropriate when meanwhile supports the Place service */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2439 static void mw_place_invite(struct mwConversation *conv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2440 const char *message,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2441 const char *title, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2442 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2443 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2444 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2445
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2446 struct mwIdBlock *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2447 GHashTable *ht;
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 srvc = mwConversation_getService(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2450 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2451 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2452
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2453 idb = mwConversation_getTarget(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2454
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2455 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
2456 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
2457 g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2458 g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2459 g_hash_table_insert(ht, CHAT_KEY_INVITE, g_strdup(message));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2460
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2461 serv_got_chat_invite(pd->gc, title, idb->user, message, ht);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2462 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2463 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2464
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 static void mw_im_clear(struct mwServiceIm *srvc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2467 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2468 }
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 static struct mwImHandler mw_im_handler = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2472 .conversation_opened = mw_conversation_opened,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2473 .conversation_closed = mw_conversation_closed,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2474 .conversation_recv = mw_conversation_recv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2475 .place_invite = NULL, /* = mw_place_invite, */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2476 .clear = mw_im_clear,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2477 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2478
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2479
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2480 static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2481 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2482 srvc = mwServiceIm_new(s, &mw_im_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2483 mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2484 return srvc;
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2488 static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2489 struct mwServiceResolve *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2490 srvc = mwServiceResolve_new(s);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2491 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2492 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2493
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2494
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2495 static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2496 struct mwServiceStorage *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2497 srvc = mwServiceStorage_new(s);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2498 return srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2499 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2500
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2501
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2502 /** allocate and associate a mwGaimPluginData with a GaimConnection */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2503 static struct mwGaimPluginData *mwGaimPluginData_new(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2504 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2505
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2506 g_return_val_if_fail(gc != NULL, NULL);
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 pd = g_new0(struct mwGaimPluginData, 1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2509 pd->gc = gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2510 pd->session = mwSession_new(&mw_session_handler);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2511 pd->srvc_aware = mw_srvc_aware_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2512 pd->srvc_conf = mw_srvc_conf_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2513 pd->srvc_ft = mw_srvc_ft_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2514 pd->srvc_im = mw_srvc_im_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2515 pd->srvc_resolve = mw_srvc_resolve_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2516 pd->srvc_store = mw_srvc_store_new(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2517 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
2518
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2519 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2520 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2521 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2522 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2523 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2524 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2525
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2526 mwSession_addCipher(pd->session, mwCipher_new_RC2_40(pd->session));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2527
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2528 mwSession_setClientData(pd->session, pd, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2529 gc->proto_data = pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2530
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2531 return pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2532 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2533
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2534
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2535 static void mwGaimPluginData_free(struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2536 g_return_if_fail(pd != NULL);
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 pd->gc->proto_data = NULL;
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 mwSession_removeService(pd->session, SERVICE_AWARE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2541 mwSession_removeService(pd->session, SERVICE_CONFERENCE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2542 mwSession_removeService(pd->session, SERVICE_IM);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2543 mwSession_removeService(pd->session, SERVICE_RESOLVE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2544 mwSession_removeService(pd->session, SERVICE_STORAGE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2545
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2546 mwService_free(MW_SERVICE(pd->srvc_aware));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2547 mwService_free(MW_SERVICE(pd->srvc_conf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2548 mwService_free(MW_SERVICE(pd->srvc_im));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2549 mwService_free(MW_SERVICE(pd->srvc_resolve));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2550 mwService_free(MW_SERVICE(pd->srvc_store));
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 mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2553
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2554 mwSession_free(pd->session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2555
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2556 g_hash_table_destroy(pd->group_list_map);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2557
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2558 g_free(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2559 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2560
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2561
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2562 static const char *mw_prpl_list_icon(GaimAccount *a, GaimBuddy *b) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2563 /* 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
2564 guy. First, cut off the head and store someplace safe. Then,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2565 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
2566 copy of the remaining body, and flip it horizontally. Now attach
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2567 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
2568 top, being careful to center it. Then, just change the color
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2569 saturation to bring the red down a bit, and voila! */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2570
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2571 /* 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
2572 icon. You know, LIKE A REAL MAN. */
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 return "meanwhile";
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2577
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2578 static void mw_prpl_list_emblems(GaimBuddy *b,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2579 const char **se, const char **sw,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2580 const char **nw, const char **ne) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2581
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2582 /* we have to add the UC_UNAVAILABLE flag so that Gaim will recognie
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2583 certain away states as indicating the buddy is unavailable */
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 if(! GAIM_BUDDY_IS_ONLINE(b)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2586 *se = "offline";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2587 } else if(b->uc == (mwStatus_AWAY /* XXX | UC_UNAVAILABLE */)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2588 *se = "away";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2589 } else if(b->uc == (mwStatus_BUSY /* XXX | UC_UNAVAILABLE */)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2590 *se = "dnd";
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 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2595 static char *mw_prpl_status_text(GaimBuddy *b) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2596 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2597 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2598 struct mwAwareIdBlock t = { mwAware_USER, b->name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2599 const char *ret;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2600
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2601 gc = b->account->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2602 pd = gc->proto_data;
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 ret = mwServiceAware_getText(pd->srvc_aware, &t);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2605 return (ret)? g_strdup(ret): NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2606 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2607
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 static const char *status_text(GaimBuddy *b) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2610 guint status = b->uc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2611
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2612 if(! GAIM_BUDDY_IS_ONLINE(b) ) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2613 return MW_STATE_OFFLINE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2614
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2615 } else if(status == (mwStatus_AWAY /* XXX | UC_UNAVAILABLE */)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2616 return MW_STATE_AWAY;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2617
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2618 } else if(status == (mwStatus_BUSY /* XXX | UC_UNAVAILABLE */)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2619 return MW_STATE_BUSY;
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 } else if(status == mwStatus_IDLE) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2622 return MW_STATE_IDLE;
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 } else if(status == mwStatus_ACTIVE) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2625 return MW_STATE_ACTIVE;
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 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2628 return MW_STATE_UNKNOWN;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2629 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2630 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2631
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2632
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2633 static gboolean user_supports(struct mwServiceAware *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2634 const char *who, guint32 feature) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2635
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2636 const struct mwAwareAttribute *attr;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2637 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2638
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2639 attr = mwServiceAware_getAttribute(srvc, &idb, feature);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2640 return (attr != NULL) && mwAwareAttribute_asBoolean(attr);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2641 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2642
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2643
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2644 char *user_supports_text(struct mwServiceAware *srvc, const char *who) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2645 char *feat[] = {NULL, NULL, NULL, NULL, NULL};
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2646 char **f = feat;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2647
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2648 if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2649 gboolean mic, speak, video;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2650
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2651 mic = user_supports(srvc, who, mwAttribute_MICROPHONE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2652 speak = user_supports(srvc, who, mwAttribute_SPEAKERS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2653 video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2654
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2655 if(mic) *f++ = "Microphone";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2656 if(speak) *f++ = "Speakers";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2657 if(video) *f++ = "Video Camera";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2658 }
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 if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2661 *f++ = "File Transfer";
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 return (*feat)? g_strjoinv(", ", feat): NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2664 /* jenni loves siege */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2665 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2666
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 static char *mw_prpl_tooltip_text(GaimBuddy *b) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2669 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2670 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2671 struct mwAwareIdBlock idb = { mwAware_USER, b->name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2672
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2673 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2674 const char *tmp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2675
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2676 gc = b->account->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2677 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2678
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2679 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2680
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2681 tmp = status_text(b);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2682 g_string_append_printf(str, "\n<b>Status</b>: %s", tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2683
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2684 tmp = mwServiceAware_getText(pd->srvc_aware, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2685 if(tmp) g_string_append_printf(str, "\n<b>Message</b>: %s", tmp);
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 tmp = user_supports_text(pd->srvc_aware, b->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2688 if(tmp) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2689 g_string_append_printf(str, "\n<b>Supports</b>: %s", tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2690 g_free((char *) tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2691 }
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 tmp = str->str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2694 g_string_free(str, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2695 return (char *) tmp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2696 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2699 static GList *mw_prpl_status_types(GaimAccount *acct) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2700 GList *types = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2701 GaimStatusType *type;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2702
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2703 type = gaim_status_type_new(GAIM_STATUS_OFFLINE, MW_STATE_OFFLINE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2704 _("Offline"), TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2705 types = g_list_append(types, type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2706
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2707 type = gaim_status_type_new(GAIM_STATUS_ONLINE, MW_STATE_ONLINE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2708 _("Online"), TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2709
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2710 type = gaim_status_type_new(GAIM_STATUS_AVAILABLE, MW_STATE_ACTIVE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2711 _("Active"), TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2712 gaim_status_type_add_attr(type, MW_STATE_MESSAGE, _("Message"),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2713 gaim_value_new(GAIM_TYPE_STRING));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2714 types = g_list_append(types, type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2715
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2716 type = gaim_status_type_new(GAIM_STATUS_AWAY, MW_STATE_AWAY,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2717 _("Away"), TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2718 gaim_status_type_add_attr(type, MW_STATE_MESSAGE, _("Message"),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2719 gaim_value_new(GAIM_TYPE_STRING));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2720 types = g_list_append(types, type);
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 type = gaim_status_type_new(GAIM_STATUS_UNAVAILABLE, MW_STATE_BUSY,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2723 _("Do Not Disturb"), TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2724 gaim_status_type_add_attr(type, MW_STATE_MESSAGE, _("Message"),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2725 gaim_value_new(GAIM_TYPE_STRING));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2726 types = g_list_append(types, type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2727
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2728 return types;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2729 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2730
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 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2733 static GList *mw_prpl_away_states(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2734 GList *l = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2735
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2736 l = g_list_append(l, MW_STATE_ACTIVE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2737 l = g_list_append(l, MW_STATE_AWAY);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2738 l = g_list_append(l, MW_STATE_BUSY);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2739 l = g_list_append(l, (char *) GAIM_AWAY_CUSTOM);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2740
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2741 return l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2742 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2743 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2744
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 static void conf_create_prompt_cancel(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2747 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2748 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2749 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2752 static void conf_create_prompt_join(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2753 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2754 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2755 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2756 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2757 struct mwServiceConference *srvc;
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 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2760
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2761 const char *topic, *invite;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2762 struct mwConference *conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2763 struct mwIdBlock idb = { NULL, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2764
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2765 acct = buddy->account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2766 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2767 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2768 srvc = pd->srvc_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2769
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2770 f = gaim_request_fields_get_field(fields, CHAT_KEY_TOPIC);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2771 topic = gaim_request_field_string_get_value(f);
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 f = gaim_request_fields_get_field(fields, CHAT_KEY_INVITE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2774 invite = gaim_request_field_string_get_value(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2775
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2776 conf = mwConference_new(srvc, topic);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2777 mwConference_open(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2778
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2779 idb.user = buddy->name;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2780 mwConference_invite(conf, &idb, invite);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2781 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2782
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 static void blist_menu_conf_create(GaimBuddy *buddy, const char *msg) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2785
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2786 GaimRequestFields *fields;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2787 GaimRequestFieldGroup *g;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2788 GaimRequestField *f;
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 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2791 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2792
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2793 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2794
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2795 g_return_if_fail(buddy != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2796
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2797 acct = buddy->account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2798 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2799
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2800 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2801 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2802
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2803 fields = gaim_request_fields_new();
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 g = gaim_request_field_group_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2806 gaim_request_fields_add_group(fields, g);
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 f = gaim_request_field_string_new(CHAT_KEY_TOPIC, "Topic", NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2809 gaim_request_field_group_add_field(g, f);
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 f = gaim_request_field_string_new(CHAT_KEY_INVITE, "Message", msg, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2812 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2813
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2814 msgA = ("Create conference with user");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2815 msgB = ("Please enter a topic for the new conference, and an invitation"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2816 " message to be sent to %s");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2817 msgB = g_strdup_printf(msgB, buddy->name);
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 gaim_request_fields(gc, "New Conference",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2820 msgA, msgB, fields,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2821 "Create", G_CALLBACK(conf_create_prompt_join),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2822 "Cancel", G_CALLBACK(conf_create_prompt_cancel),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2823 buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2824 g_free(msgB);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2828 static void conf_select_prompt_cancel(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2829 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2830 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2831 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2832
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2833
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2834 static void conf_select_prompt_invite(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2835 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2836 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2837 const GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2838 const char *msg;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2839
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2840 f = gaim_request_fields_get_field(fields, CHAT_KEY_INVITE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2841 msg = gaim_request_field_string_get_value(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2842
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2843 f = gaim_request_fields_get_field(fields, "conf");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2844 l = gaim_request_field_list_get_selected(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2845
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2846 if(l) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2847 gpointer d = gaim_request_field_list_get_data(f, l->data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2848
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2849 if(GPOINTER_TO_INT(d) == 0x01) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2850 blist_menu_conf_create(buddy, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2851
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2852 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2853 struct mwIdBlock idb = { buddy->name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2854 mwConference_invite(d, &idb, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2855 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2856 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2857 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2858
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2859
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2860 static void blist_menu_conf_list(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2861 GList *confs) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2862
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2863 GaimRequestFields *fields;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2864 GaimRequestFieldGroup *g;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2865 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2866
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2867 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2868 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2869
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2870 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2871
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2872 acct = buddy->account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2873 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2874
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2875 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2876 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2877
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2878 fields = gaim_request_fields_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2879
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2880 g = gaim_request_field_group_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2881 gaim_request_fields_add_group(fields, g);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2882
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2883 f = gaim_request_field_list_new("conf", "Available Conferences");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2884 gaim_request_field_list_set_multi_select(f, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2885 for(; confs; confs = confs->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2886 struct mwConference *c = confs->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2887 gaim_request_field_list_add(f, mwConference_getTitle(c), c);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2888 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2889 gaim_request_field_list_add(f, "Create New Conference...",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2890 GINT_TO_POINTER(0x01));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2891 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2892
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2893 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
2894 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2895
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2896 msgA = "Invite user to a conference";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2897 msgB = ("Select a conference from the list below to send an invite to"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2898 " user %s. Select \"Create New Conference\" if you'd like to"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2899 " create a new conference to invite this user to.");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2900 msgB = g_strdup_printf(msgB, buddy->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2901
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2902 gaim_request_fields(gc, "Invite to Conference",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2903 msgA, msgB, fields,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2904 "Invite", G_CALLBACK(conf_select_prompt_invite),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2905 "Cancel", G_CALLBACK(conf_select_prompt_cancel),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2906 buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2907 g_free(msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2908 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2909
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2910
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2911 static void blist_menu_conf(GaimBlistNode *node, gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2912 GaimBuddy *buddy = (GaimBuddy *) node;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2913 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2914 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2915 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2916 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2917
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2918 g_return_if_fail(node != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2919 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2920
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2921 acct = buddy->account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2922 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2923
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2924 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2925 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2926
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2927 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2928 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2929
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2930 /* @todo prompt for which conference to join
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2931
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2932 - get a list of all conferences on this session
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2933 - if none, prompt to create one, and invite buddy to it
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2934 - else, prompt to select a conference or create one
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2935 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2936
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2937 l = mwServiceConference_getConferences(pd->srvc_conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2938 if(l) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2939 blist_menu_conf_list(buddy, l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2940 g_list_free(l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2941
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2942 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2943 blist_menu_conf_create(buddy, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2944 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2945 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2946
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2947
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2948 static GList *mw_prpl_blist_node_menu(GaimBlistNode *node) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2949 GList *l = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2950 GaimBlistNodeAction *act;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2951
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2952 if(! GAIM_BLIST_NODE_IS_BUDDY(node))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2953 return l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2954
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2955 l = g_list_append(l, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2956
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2957 act = gaim_blist_node_action_new("Invite to Conference...",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2958 blist_menu_conf, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2959 l = g_list_append(l, act);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2960
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2961 /** 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
2962 blist-node-extended-menu signal for that. The function
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2963 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
2964 services_starting */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2965
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2966 return l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2967 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2968
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2969
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2970 static GList *mw_prpl_chat_info(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2971 GList *l = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2972 struct proto_chat_entry *pce;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2973
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2974 pce = g_new0(struct proto_chat_entry, 1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2975 pce->label = "Topic:";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2976 pce->identifier = CHAT_KEY_TOPIC;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2977 l = g_list_append(l, pce);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2978
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2979 return l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2980 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2981
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2982
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2983 static GHashTable *mw_prpl_chat_info_defaults(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2984 const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2985 GHashTable *table;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2986
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2987 g_return_val_if_fail(gc != NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2988
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2989 DEBUG_INFO("mw_prpl_chat_info_defaults for %s\n", NSTR(name));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2990
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2991 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
2992 NULL, g_free);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2993
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2994 g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2995 g_hash_table_insert(table, CHAT_KEY_INVITE, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2996
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2997 return table;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2998 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2999
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3000
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3001 static void mw_prpl_login(GaimAccount *acct, GaimStatus *stat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3002
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3003
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3004 static void prompt_host_cancel_cb(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3005 gaim_connection_error(gc, "No Sametime Community Server specified");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3006 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3007
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3008
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3009 static void prompt_host_ok_cb(GaimConnection *gc, const char *host) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3010 if(host && *host) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3011 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3012 GaimPresence *pres;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3013 GaimStatus *stat;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3014
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3015 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3016 gaim_account_set_string(acct, MW_KEY_HOST, host);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3017
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3018 pres = gaim_account_get_presence(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3019 stat = gaim_presence_get_active_status(pres);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3020
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3021 mw_prpl_login(acct, stat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3022
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3023 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3024 prompt_host_cancel_cb(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3025 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3026 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3027
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3028
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3029 static void prompt_host(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3030 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3031 char *msg;
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 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3034 msg = ("No host or IP address has been configured for the"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3035 " Meanwhile account %s. Please enter one below to"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3036 " continue logging in.");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3037 msg = g_strdup_printf(msg, NSTR(gaim_account_get_username(acct)));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3038
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3039 gaim_request_input(gc, "Meanwhile Connection Setup",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3040 "No Sametime Community Server Specified", msg,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3041 MW_PLUGIN_DEFAULT_HOST, FALSE, FALSE, NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3042 "Connect", G_CALLBACK(prompt_host_ok_cb),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3043 "Cancel", G_CALLBACK(prompt_host_cancel_cb),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3044 gc);
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_free(msg);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3049
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3050 static void mw_prpl_login(GaimAccount *account, GaimStatus *stat) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3051 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3052 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3053
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3054 char *user, *pass, *host;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3055 guint port;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3056
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3057 gc = gaim_account_get_connection(account);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3058 pd = mwGaimPluginData_new(gc);
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 /* 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
3061 gc->flags |= GAIM_CONNECTION_NO_IMAGES;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3062
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3063 user = g_strdup(gaim_account_get_username(account));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3064 pass = (char *) gaim_account_get_password(account);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3065
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3066 DEBUG_INFO("mw_prpl_login\n");
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 #if 1
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3069 host = strrchr(user, ':');
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3070 if(host) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3071 /* annoying user split from 1.2.0, need to undo it */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3072 *host++ = '\0';
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3073 gaim_account_set_string(account, MW_KEY_HOST, host);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3074 gaim_account_set_username(account, user);
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 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3077 host = (char *) gaim_account_get_string(account, MW_KEY_HOST,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3078 MW_PLUGIN_DEFAULT_HOST);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3079 }
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 #else
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3082 /* the 1.2.0 way to obtain the host string from an account split. I
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3083 didn't like this, it didn't solve a problem, but it created a
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3084 few. The above code undoes it. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3085 host = strrchr(user, ':');
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3086 if(host) *host++ = '\0';
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3087
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3088 if(! host) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3089 const char *h;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3090 char *t;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3091
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3092 /* for those without the host string, let's see if they have host
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3093 specified in the account setting instead. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3094
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3095 h = gaim_account_get_string(account, MW_KEY_HOST, MW_PLUGIN_DEFAULT_HOST);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3096 if(h) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3097 t = g_strdup_printf("%s:%s", user, h);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3098 gaim_account_set_username(account, t);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3099 g_free(t);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3100 host = (char *) h;
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 }
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 /* de-uglify */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3105 if(! gaim_account_get_alias(account))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3106 gaim_account_set_alias(account, user);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3107 #endif
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 if(! host || ! *host) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3110 /* 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
3111 to actually continue, so let's ask the user directly. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3112 prompt_host(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3113 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3114 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3115
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3116 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
3117
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3118 DEBUG_INFO("user: '%s'\n", user);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3119 DEBUG_INFO("host: '%s'\n", host);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3120 DEBUG_INFO("port: %u\n", port);
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 mwSession_setProperty(pd->session, SESSION_NO_SECRET,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3123 (char *) no_secret, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3124 mwSession_setProperty(pd->session, mwSession_AUTH_USER_ID, user, g_free);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3125 mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3126 mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3127 GUINT_TO_POINTER(MW_CLIENT_TYPE_ID), NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3128
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3129 gaim_connection_update_progress(gc, "Connecting", 1, MW_CONNECT_STEPS);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3130
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3131 if(gaim_proxy_connect(account, host, port, connect_cb, pd)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3132 gaim_connection_error(gc, "Unable to connect to host");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3133 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3134 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3135
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3136
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3137 static void mw_prpl_close(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3138 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3139
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3140 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3141
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3142 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3143 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3144
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3145 /* get rid of the blist save timeout */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3146 if(pd->save_event) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3147 gaim_timeout_remove(pd->save_event);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3148 pd->save_event = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3149 blist_store(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3150 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3151
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3152 /* stop the session */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3153 mwSession_stop(pd->session, 0x00);
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 /* no longer necessary */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3156 gc->proto_data = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3157
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3158 /* stop watching the socket */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3159 if(gc->inpa) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3160 gaim_input_remove(gc->inpa);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3161 gc->inpa = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3162 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3163
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3164 /* clean up the rest */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3165 mwGaimPluginData_free(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3166 }
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 static char *im_mime_content_id() {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3170 const char *c = "%03x@%05xmeanwhile";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3171 srand(time(0) ^ rand());
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3172 return g_strdup_printf(c, rand() & 0xfff, rand() & 0xfffff);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3173 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3174
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3175
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3176 static char *im_mime_content_type() {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3177 const char *c = "multipart/related; boundary=related_MW%03x_%04x";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3178 srand(time(0) ^ rand());
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3179 return g_strdup_printf(c, rand() & 0xfff, rand() & 0xffff);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3182
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3183 static const char *im_mime_img_content_type(GaimStoredImage *img) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3184 const char *fn = gaim_imgstore_get_filename(img);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3185
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3186 fn = strrchr(fn, '.');
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3187 if(! fn) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3188 return "image";
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 } else if(! strcmp(".png", fn)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3191 return "image/png";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3192
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3193 } else if(! strcmp(".jpg", fn)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3194 return "image/jpeg";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3195
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3196 } else if(! strcmp(".jpeg", fn)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3197 return "image/jpeg";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3198
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3199 } else if(! strcmp(".gif", fn)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3200 return "image/gif";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3201
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3202 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3203 return "image";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3204 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3205 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3206
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3207
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3208 static char *im_mime_img_content_disp(GaimStoredImage *img) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3209 const char *fn = gaim_imgstore_get_filename(img);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3210 return g_strdup_printf("attachment; filename=\"%s\"", fn);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3211 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3212
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 static char *im_mime_convert(const char *message) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3215 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3216 GaimMimeDocument *doc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3217 GaimMimePart *part;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3218
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3219 GData *attr;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3220 char *tmp, *start, *end;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3221
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3222 str = g_string_new(NULL);
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 doc = gaim_mime_document_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3225
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3226 gaim_mime_document_set_field(doc, "Mime-Version", "1.0");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3227 gaim_mime_document_set_field(doc, "Content-Disposition", "inline");
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 = im_mime_content_type();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3230 gaim_mime_document_set_field(doc, "Content-Type", tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3231 g_free(tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3232
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3233 tmp = (char *) message;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3234 while(*tmp && gaim_markup_find_tag("img", tmp, (const char **) &start,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3235 (const char **) &end, &attr)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3236 char *id;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3237 GaimStoredImage *img = NULL;
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 gsize len = (start - tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3240
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3241 /* append the in-between-tags text */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3242 if(len) g_string_append_len(str, tmp, len);
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 /* find the imgstore data by the id tag */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3245 id = g_datalist_get_data(&attr, "id");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3246 if(id && *id)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3247 img = gaim_imgstore_get(atoi(id));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3248
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3249 if(img) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3250 char *cid;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3251 gpointer data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3252 size_t size;
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 part = gaim_mime_part_new(doc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3255
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3256 data = im_mime_img_content_disp(img);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3257 gaim_mime_part_set_field(part, "Content-Disposition", data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3258 g_free(data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3259
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3260 cid = im_mime_content_id();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3261 data = g_strdup_printf("<%s>", cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3262 gaim_mime_part_set_field(part, "Content-ID", data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3263 g_free(data);
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 gaim_mime_part_set_field(part, "Content-transfer-encoding", "base64");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3266 gaim_mime_part_set_field(part, "Content-Type",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3267 im_mime_img_content_type(img));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3268
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3269
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3270 /* 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
3271 mime part */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3272 data = gaim_imgstore_get_data(img);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3273 size = gaim_imgstore_get_size(img);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3274 data = gaim_base64_encode(data, (gsize) size);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3275 gaim_mime_part_set_data(part, data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3276 g_free(data);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3277
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3278 /* append the modified tag */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3279 g_string_append_printf(str, "<img src=\"cid:%s\">", cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3280 g_free(cid);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3281
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3282 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3283 /* append the literal image tag, since we couldn't find a
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3284 relative imgstore object */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3285 gsize len = (end - start) + 1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3286 g_string_append_len(str, start, len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3287 }
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 g_datalist_clear(&attr);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3290 tmp = end + 1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3291 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3292
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3293 /* append left-overs */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3294 g_string_append(str, tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3295
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3296 part = gaim_mime_part_new(doc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3297 gaim_mime_part_set_field(part, "Content-Type", "text/html");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3298 gaim_mime_part_set_field(part, "Content-Disposition", "inline");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3299 gaim_mime_part_set_field(part, "Content-Transfer-Encoding", "8bit");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3300
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3301 gaim_mime_part_set_data(part, str->str);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3302 g_string_free(str, TRUE);
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 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3305 gaim_mime_document_write(doc, str);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3306 tmp = str->str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3307 g_string_free(str, FALSE);
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 return tmp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3310 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3313 static int mw_prpl_send_im(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3314 const char *name,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3315 const char *message,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3316 GaimConvImFlags flags) {
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 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3319 struct mwIdBlock who = { (char *) name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3320 struct mwConversation *conv;
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 g_return_val_if_fail(gc != NULL, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3323 pd = gc->proto_data;
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 g_return_val_if_fail(pd != NULL, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3326
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3327 conv = mwServiceIm_getConversation(pd->srvc_im, &who);
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 /* this detection of features to determine how to send the message
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3330 (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
3331 conversation could close their channel at any time, rendering any
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3332 existing formatting in an outgoing message innapropriate. The end
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3333 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
3334 conversation will receive a plaintext message with html contents,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3335 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
3336
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3337 /* @todo support chunking messages over a certain size into multiple
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3338 smaller messages */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3339
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3340 if(strstr(message, "<img ") || strstr(message, "<IMG "))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3341 flags |= GAIM_CONV_IM_IMAGES;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3342
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3343 if(mwConversation_isOpen(conv)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3344 char *msg = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3345 int ret;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3346
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3347 if((flags & GAIM_CONV_IM_IMAGES) &&
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3348 mwConversation_supports(conv, mwImSend_MIME)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3349
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3350 msg = im_mime_convert(message);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3351 ret = mwConversation_send(conv, mwImSend_MIME, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3352
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3353 } else if(mwConversation_supports(conv, mwImSend_HTML)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3354
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3355 /* need to do this to get the \n to <br> conversion */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3356 msg = gaim_strdup_withhtml(message);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3357 ret = mwConversation_send(conv, mwImSend_HTML, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3358
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3359 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3360 ret = mwConversation_send(conv, mwImSend_PLAIN, message);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3361 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3362
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3363 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3364 return !ret;
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 /* queue up the message */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3368 convo_queue(conv, mwImSend_PLAIN, message);
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 if(! mwConversation_isPending(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3371 mwConversation_open(conv);
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 return 1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3374 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3375
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3376
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3377 static int mw_prpl_send_typing(GaimConnection *gc, const char *name,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3378 int typing) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3379
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3380 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3381 struct mwIdBlock who = { (char *) name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3382 struct mwConversation *conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3383
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3384 gpointer t = GINT_TO_POINTER(!! typing);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3385
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3386 g_return_val_if_fail(gc != NULL, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3387 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3388
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3389 g_return_val_if_fail(pd != NULL, 0);
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 conv = mwServiceIm_getConversation(pd->srvc_im, &who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3392
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3393 if(mwConversation_isOpen(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3394 return ! mwConversation_send(conv, mwImSend_TYPING, t);
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 if(typing) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3397 /* 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
3398 Otherwise two users in psychic mode will continually open
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3399 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
3400 when the other person closes, it psychicaly opens again */
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 convo_queue(conv, mwImSend_TYPING, t);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3403
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3404 if(! mwConversation_isPending(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3405 mwConversation_open(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3406 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3407
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3408 return 1;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3409 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3412 static void mw_prpl_get_info(GaimConnection *gc, const char *who) {
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 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3415 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, 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 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3418 GaimBuddy *b;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3419
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3420 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3421 const char *tmp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3422 guint32 type;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3423
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3424 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3425
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3426 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3427 b = gaim_find_buddy(acct, who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3428
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3429 g_return_if_fail(b != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3430
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3431 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3432
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3433 g_string_append_printf(str, "<b>User ID:</b> %s<br>", b->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3434
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3435 if(b->server_alias) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3436 g_string_append_printf(str, "<b>Full Name:</b> %s<br>",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3437 b->server_alias);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3438 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3439
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3440 type = gaim_blist_node_get_int((GaimBlistNode *) b, BUDDY_KEY_CLIENT);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3441 if(type) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3442 g_string_append(str, "<b>Last Known Client:</b> ");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3443
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3444 tmp = mwLoginType_getName(type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3445 if(tmp) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3446 g_string_append(str, tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3447 g_string_append(str, "<br>");
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 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3450 g_string_append_printf(str, "Unknown (0x%04x)<br>", type);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3451 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3452 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3453
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3454 tmp = user_supports_text(pd->srvc_aware, who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3455 if(tmp) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3456 g_string_append_printf(str, "<b>Supports:</b> %s<br>", tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3457 g_free((char *) tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3458 }
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 tmp = status_text(b);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3461 g_string_append_printf(str, "<b>Status:</b> %s", tmp);
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 g_string_append(str, "<hr>");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3464
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3465 tmp = mwServiceAware_getText(pd->srvc_aware, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3466 g_string_append(str, tmp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3467
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3468 /* @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
3469 this notification, so that it can create its own */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3470
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3471 gaim_notify_userinfo(gc, who, "Buddy Information",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3472 "Meanwhile User Status", NULL, str->str, NULL, NULL);
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 g_string_free(str, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3475 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3476
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3477
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3478 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3479 static void mw_prpl_set_away(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3480 const char *state,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3481 const char *message) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3482 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3483 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3484 struct mwUserStatus stat;
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 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3487 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3488
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3489 session = gc_to_session(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3490 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3491
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3492 /* get a working copy of the current status */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3493 mwUserStatus_clone(&stat, mwSession_getUserStatus(session));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3494
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3495 /* determine the state */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3496 if(state) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3497 if(! strcmp(state, GAIM_AWAY_CUSTOM)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3498 if(message) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3499 stat.status = mwStatus_AWAY;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3500 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3501 stat.status = mwStatus_ACTIVE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3502 }
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 } else if(! strcmp(state, MW_STATE_AWAY)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3505 stat.status = mwStatus_AWAY;
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 } else if(! strcmp(state, MW_STATE_BUSY)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3508 stat.status = mwStatus_BUSY;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3509
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3510 } else if(! strcmp(state, MW_STATE_ACTIVE)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3511 stat.status = mwStatus_ACTIVE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3512 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3513
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3514 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3515 stat.status = mwStatus_ACTIVE;
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3518 /* determine the message */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3519 if(! message) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3520 switch(stat.status) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3521 case mwStatus_AWAY:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3522 message = gaim_account_get_string(acct, MW_KEY_AWAY_MSG,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3523 MW_PLUGIN_DEFAULT_AWAY_MSG);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3524 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3525
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3526 case mwStatus_BUSY:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3527 message = gaim_account_get_string(acct, MW_KEY_BUSY_MSG,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3528 MW_PLUGIN_DEFAULT_BUSY_MSG);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3529 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3530
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3531 case mwStatus_ACTIVE:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3532 message = gaim_account_get_string(acct, MW_KEY_ACTIVE_MSG,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3533 MW_PLUGIN_DEFAULT_ACTIVE_MSG);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3534 stat.time = 0;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3535 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3536 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3537 }
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 if(message) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3540 /* 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
3541 are const, so we don't need to free them */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3542 message = gaim_markup_strip_html(message);
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 /* out with the old */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3546 g_free(stat.desc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3547 g_free(gc->away);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3548
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3549 /* in with the new */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3550 stat.desc = (char *) message;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3551 gc->away = g_strdup(message);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3552
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3553 mwSession_setUserStatus(session, &stat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3554 mwUserStatus_clear(&stat);
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 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3557
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3558
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3559 static void mw_prpl_set_idle(GaimConnection *gc, int time) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3560 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3561 struct mwUserStatus stat;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3562
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3563 session = gc_to_session(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3564 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3565
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3566 mwUserStatus_clone(&stat, mwSession_getUserStatus(session));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3567
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3568 if(time > 0 && stat.status == mwStatus_ACTIVE) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3569 stat.status = mwStatus_IDLE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3570
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3571 } else if(time == 0 && stat.status == mwStatus_IDLE) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3572 stat.status = mwStatus_ACTIVE;
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3575 /** @todo actually put the idle time in the user status */
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 mwSession_setUserStatus(session, &stat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3578 mwUserStatus_clear(&stat);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3579 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3580
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 static void add_resolved_done(const char *id, const char *name,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3583 GaimBuddy *buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3584 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3585 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3586 struct mwGaimPluginData *pd;
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 g_return_if_fail(id != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3589
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3590 g_return_if_fail(buddy != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3591 acct = buddy->account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3592
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3593 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3594 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3595
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3596 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3597 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3598
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3599 gaim_blist_rename_buddy(buddy, id);
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 gaim_blist_server_alias_buddy(buddy, name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3602 gaim_blist_node_set_string((GaimBlistNode *) buddy, BUDDY_KEY_NAME, name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3603
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3604 buddy_add(pd, buddy);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3607
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3608 static void multi_resolved_cleanup(GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3609
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3610 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3611 const GList *l;
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 f = gaim_request_fields_get_field(fields, "user");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3614 l = gaim_request_field_list_get_items(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3615
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3616 for(; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3617 const char *i = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3618 struct resolved_id *res;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3619
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3620 res = gaim_request_field_list_get_data(f, i);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3621
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3622 g_free(res->id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3623 g_free(res->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3624 g_free(res);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3625 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3626 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3627
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3628
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3629 static void multi_resolved_cancel(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3630 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3631 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3632 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3633
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3634 gc = gaim_account_get_connection(buddy->account);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3635 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3636
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3637 gaim_blist_remove_buddy(buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3638 multi_resolved_cleanup(fields);
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 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3641 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3642
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 static void multi_resolved_cb(GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3645 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3646 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3647 const GList *l;
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 f = gaim_request_fields_get_field(fields, "user");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3650 l = gaim_request_field_list_get_selected(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3651
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3652 if(l) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3653 const char *i = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3654 struct resolved_id *res;
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 res = gaim_request_field_list_get_data(f, i);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3657
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3658 add_resolved_done(res->id, res->name, buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3659 multi_resolved_cleanup(fields);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3660
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3661 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3662 multi_resolved_cancel(buddy, fields);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3663 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3664 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3665
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 static void multi_resolved_query(struct mwResolveResult *result,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3668 GaimBuddy *buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3669 GaimRequestFields *fields;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3670 GaimRequestFieldGroup *g;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3671 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3672 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3673 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3674
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3675 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3676 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3677
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3678 g_return_if_fail(buddy != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3679
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3680 acct = buddy->account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3681 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3682
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3683 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3684 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3685
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3686 fields = gaim_request_fields_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3687
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3688 g = gaim_request_field_group_new(NULL);
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 /* note that Gaim segfaults if you don't add the group to the fields
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3691 before you add a required field to the group. Feh. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3692 gaim_request_fields_add_group(fields, g);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3693
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3694 f = gaim_request_field_list_new("user", "Possible Matches");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3695 gaim_request_field_list_set_multi_select(f, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3696 gaim_request_field_set_required(f, TRUE);
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 for(l = result->matches; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3699 struct mwResolveMatch *match = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3700 struct resolved_id *res = g_new0(struct resolved_id, 1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3701 char *label;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3702
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3703 res->id = g_strdup(match->id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3704 res->name = g_strdup(match->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3705
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3706 /* fixes bug 1178603 by making the selection label a combination
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3707 of the full name and the user id. Problems arrise when multiple
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3708 entries have identical labels */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3709 label = g_strdup_printf("%s (%s)", NSTR(res->name), NSTR(res->id));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3710 gaim_request_field_list_add(f, label, res);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3711 g_free(label);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3712 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3713
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3714 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3715
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3716 msgA = ("An ambiguous user ID was entered");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3717 msgB = ("The identifier '%s' may possibly refer to any of the following"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3718 " users. Please select the correct user from the list below to"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3719 " add them to your buddy list.");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3720 msgB = g_strdup_printf(msgB, result->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3721
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3722 gaim_request_fields(gc, "Select User to Add",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3723 msgA, msgB, fields,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3724 "Add User", G_CALLBACK(multi_resolved_cb),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3725 "Cancel", G_CALLBACK(multi_resolved_cancel),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3726 buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3727 g_free(msgB);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3730
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3731 static void add_buddy_resolved(struct mwServiceResolve *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3732 guint32 id, guint32 code, GList *results,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3733 gpointer b) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3734
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3735 struct mwResolveResult *res = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3736 GaimBuddy *buddy = b;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3737 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3738 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3739
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3740 gc = gaim_account_get_connection(buddy->account);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3741 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3742
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3743 if(results)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3744 res = results->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3745
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3746 if(!code && res && res->matches) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3747 if(g_list_length(res->matches) == 1) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3748 struct mwResolveMatch *match = res->matches->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3749
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3750 DEBUG_INFO("searched for %s, got only %s\n",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3751 NSTR(res->name), NSTR(match->id));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3752
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3753 /* only one? that might be the right one! */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3754 if(strcmp(res->name, match->id)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3755 /* uh oh, the single result isn't identical to the search
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3756 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
3757 the user meant to add */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3758 multi_resolved_query(res, buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3759
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3760 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3761 /* same person, add 'em */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3762 add_resolved_done(match->id, match->name, buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3763 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3764
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3765 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3766 /* prompt user if more than one match was returned */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3767 multi_resolved_query(res, buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3768 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3769
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3770 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3771 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3772
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3773 /* 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
3774 the resolve service (ether error or zero results), so we remove
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3775 this buddy */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3776
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3777 DEBUG_INFO("no such buddy in community\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3778 gaim_blist_remove_buddy(buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3779 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3780
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3781 if(res && res->name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3782 /* compose and display an error message */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3783 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3784
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3785 msgA = "Unable to add user: user not found";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3786
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3787 msgB = ("The identifier '%s' did not match any users in your"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3788 " Sametime community. This entry has been removed from"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3789 " your buddy list.");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3790 msgB = g_strdup_printf(msgB, NSTR(res->name));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3791
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3792 gaim_notify_error(gc, "Unable to add user", msgA, msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3793
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3794 g_free(msgB);
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 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3799 static void mw_prpl_add_buddy(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3800 GaimBuddy *buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3801 GaimGroup *group) {
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 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3804 struct mwServiceResolve *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3805 GList *query;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3806 enum mwResolveFlag flags;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3807 guint32 req;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3808
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3809 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3810 srvc = pd->srvc_resolve;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3811
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3812 query = g_list_prepend(NULL, buddy->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3813 flags = mwResolveFlag_FIRST | mwResolveFlag_USERS;
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 req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3816 buddy, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3817 g_list_free(query);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3818
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3819 if(req == SEARCH_ERROR) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3820 gaim_blist_remove_buddy(buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3821 blist_schedule(pd);
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3824
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3825
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3826 static void foreach_add_buddies(GaimGroup *group, GList *buddies,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3827 struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3828
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3829 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3830
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3831 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3832 mwAwareList_addAware(list, buddies);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3833 g_list_free(buddies);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3834 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3835
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3836
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3837 static void mw_prpl_add_buddies(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3838 GList *buddies,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3839 GList *groups) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3840
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3841 /** @todo make this use a single call to each mwAwareList */
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 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3844 GHashTable *group_sets;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3845 struct mwAwareIdBlock *idbs, *idb;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3846
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3847 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3848
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3849 /* map GaimGroup:GList of mwAwareIdBlock */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3850 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
3851
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3852 /* bunch of mwAwareIdBlock allocated at once, free'd at once */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3853 idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3854
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3855 /* first pass collects mwAwareIdBlock lists for each group */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3856 for(; buddies; buddies = buddies->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3857 GaimBuddy *b = buddies->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3858 GaimGroup *g;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3859 const char *fn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3860 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3861
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3862 /* nab the saved server alias and stick it on the buddy */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3863 fn = gaim_blist_node_get_string((GaimBlistNode *) b, BUDDY_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3864 gaim_blist_server_alias_buddy(b, fn);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3865
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3866 /* convert GaimBuddy into a mwAwareIdBlock */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3867 idb->type = mwAware_USER;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3868 idb->user = (char *) b->name;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3869 idb->community = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3870
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3871 /* put idb into the list associated with the buddy's group */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3872 g = gaim_find_buddys_group(b);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3873 l = g_hash_table_lookup(group_sets, g);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3874 l = g_list_prepend(l, idb++);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3875 g_hash_table_insert(group_sets, g, l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3876 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3877
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3878 /* 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
3879 for saving */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3880 g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3881 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3882
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3883 /* cleanup */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3884 g_hash_table_destroy(group_sets);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3885 g_free(idbs);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3886 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3887
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3888
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3889 static void mw_prpl_remove_buddy(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3890 GaimBuddy *buddy, GaimGroup *group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3891
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3892 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3893 struct mwAwareIdBlock idb = { mwAware_USER, buddy->name, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3894 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3895
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3896 GList *rem = g_list_prepend(NULL, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3897
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3898 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3899 group = gaim_find_buddys_group(buddy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3900 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3901
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3902 mwAwareList_removeAware(list, rem);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3903 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3904
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3905 g_list_free(rem);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3908
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3909 static void privacy_fill(struct mwPrivacyInfo *priv,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3910 GSList *members) {
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 struct mwUserItem *u;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3913 guint count;
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 DEBUG_INFO("privacy_fill\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3916
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3917 count = g_slist_length(members);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3918 DEBUG_INFO(" %u (%i) members\n", count, (int) count);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3919
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3920 priv->count = count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3921 priv->users = g_new0(struct mwUserItem, count);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3922
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3923 while(count--) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3924 u = priv->users + count;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3925 u->id = members->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3926 members = members->next;
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 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3931 static void mw_prpl_set_permit_deny(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3932 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3933 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3934 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3935
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3936 struct mwPrivacyInfo privacy = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3937 .deny = FALSE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3938 .count = 0,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3939 .users = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3940 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3941
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3942 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3943
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3944 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3945 g_return_if_fail(acct != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3946
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3947 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3948 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3949
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3950 session = pd->session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3951 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3952
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3953 switch(acct->perm_deny) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3954 case GAIM_PRIVACY_DENY_USERS:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3955 DEBUG_INFO("GAIM_PRIVACY_DENY_USERS\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3956 privacy_fill(&privacy, acct->deny);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3957 /* fall-through */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3958
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3959 case GAIM_PRIVACY_ALLOW_ALL:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3960 DEBUG_INFO("GAIM_PRIVACY_ALLOW_ALL\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3961 privacy.deny = TRUE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3962 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3963
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3964 case GAIM_PRIVACY_ALLOW_USERS:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3965 DEBUG_INFO("GAIM_PRIVACY_ALLOW_USERS\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3966 privacy_fill(&privacy, acct->permit);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3967 /* fall-through */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3968
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3969 case GAIM_PRIVACY_DENY_ALL:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3970 DEBUG_INFO("GAIM_PRIVACY_DENY_ALL\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3971 privacy.deny = FALSE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3972 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3973
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3974 default:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3975 DEBUG_INFO("acct->perm_deny is 0x%x\n", acct->perm_deny);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3976 g_return_if_reached();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3977 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3978
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3979 mwSession_setPrivacyInfo(session, &privacy);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3980 g_free(privacy.users);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3981 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3982
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3983
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3984 static void mw_prpl_add_permit(GaimConnection *gc, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3985 mw_prpl_set_permit_deny(gc);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3989 static void mw_prpl_add_deny(GaimConnection *gc, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3990 mw_prpl_set_permit_deny(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3991 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3992
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3993
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3994 static void mw_prpl_rem_permit(GaimConnection *gc, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3995 mw_prpl_set_permit_deny(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3996 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3997
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3998
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3999 static void mw_prpl_rem_deny(GaimConnection *gc, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4000 mw_prpl_set_permit_deny(gc);
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 static struct mwConference *conf_find(struct mwServiceConference *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4005 const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4006 GList *l, *ll;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4007 struct mwConference *conf = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4008
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4009 ll = mwServiceConference_getConferences(srvc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4010 for(l = ll; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4011 struct mwConference *c = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4012 if(! strcmp(name, mwConference_getName(c))) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4013 conf = c;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4014 break;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4015 }
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_list_free(ll);
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 return conf;
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4022
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4023 static void mw_prpl_join_chat(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4024 GHashTable *components) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4025
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4026 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4027 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4028 struct mwConference *conf = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4029 char *c, *t;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4030
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4031 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4032 srvc = pd->srvc_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4033
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4034 c = g_hash_table_lookup(components, CHAT_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4035 t = g_hash_table_lookup(components, CHAT_KEY_TOPIC);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4036
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4037 if(c) conf = conf_find(srvc, c);
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 if(conf) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4040 DEBUG_INFO("accepting conference invitation\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4041 mwConference_accept(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4042
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4043 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4044 DEBUG_INFO("creating new conference\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4045 conf = mwConference_new(srvc, t);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4046 mwConference_open(conf);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4047 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4048 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4049
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4050
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4051 static void mw_prpl_reject_chat(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4052 GHashTable *components) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4053
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4054 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4055 struct mwServiceConference *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4056 char *c;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4057
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4058 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4059 srvc = pd->srvc_conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4060
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4061 c = g_hash_table_lookup(components, CHAT_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4062 if(c) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4063 struct mwConference *conf = conf_find(srvc, c);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4064 if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4065 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4066 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4067
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4068
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4069 static char *mw_prpl_get_chat_name(GHashTable *components) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4070 return g_hash_table_lookup(components, CHAT_KEY_NAME);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4071 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4072
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4073
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4074 static void mw_prpl_chat_invite(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4075 int id,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4076 const char *invitation,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4077 const char *who) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4078
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4079 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4080 struct mwConference *conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4081 struct mwIdBlock idb = { (char *) who, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4082
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4083 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4084
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4085 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4086 conf = ID_TO_CONF(pd, id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4087
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4088 g_return_if_fail(conf != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4089
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4090 mwConference_invite(conf, &idb, invitation);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4091 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4092
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4093
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4094 static void mw_prpl_chat_leave(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4095 int id) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4096
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4097 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4098 struct mwConference *conf;
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 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4101
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4102 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4103 conf = ID_TO_CONF(pd, id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4104
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4105 g_return_if_fail(conf != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4106
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4107 mwConference_destroy(conf, ERR_SUCCESS, "Leaving");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4108 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4109
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 static void mw_prpl_chat_whisper(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4112 int id,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4113 const char *who,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4114 const char *message) {
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 mw_prpl_send_im(gc, who, message, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4117 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4118
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4119
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4120 static int mw_prpl_chat_send(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4121 int id,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4122 const char *message) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4123
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4124 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4125 struct mwConference *conf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4126
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4127 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4128
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4129 g_return_val_if_fail(pd != NULL, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4130 conf = ID_TO_CONF(pd, id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4131
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4132 g_return_val_if_fail(conf != NULL, 0);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4133
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4134 return ! mwConference_sendText(conf, message);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4135 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4136
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4137
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4138 static void mw_prpl_keepalive(GaimConnection *gc) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4139 struct mwSession *session;
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 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4142
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4143 session = gc_to_session(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4144 g_return_if_fail(session != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4145
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4146 mwSession_sendKeepalive(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4147 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4148
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4149
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4150 static void mw_prpl_alias_buddy(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4151 const char *who,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4152 const char *alias) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4153
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4154 struct mwGaimPluginData *pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4155 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4156
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4157 /* 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
4158 the server copy */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4159
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4160 blist_schedule(pd);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4163
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4164 static void mw_prpl_group_buddy(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4165 const char *who,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4166 const char *old_group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4167 const char *new_group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4168
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4169 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4170 GList *gl = g_list_prepend(NULL, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4171
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4172 struct mwGaimPluginData *pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4173 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4174 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4175
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4176 /* add who to new_group's aware list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4177 group = gaim_find_group(new_group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4178 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4179 mwAwareList_addAware(list, gl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4180
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4181 /* remove who from old_group's aware list */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4182 group = gaim_find_group(old_group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4183 list = list_ensure(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4184 mwAwareList_removeAware(list, gl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4185
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4186 g_list_free(gl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4187
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4188 /* schedule the changes to be saved */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4189 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4190 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4191
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4192
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4193 static void mw_prpl_rename_group(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4194 const char *old,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4195 GaimGroup *group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4196 GList *buddies) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4197
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4198 struct mwGaimPluginData *pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4199 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4200
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4201 /* 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
4202 the server copy. Also, having this function should prevent all
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4203 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
4204 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
4205 that as the group name/alias */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4206
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4207 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4208 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4209
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4210
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4211 static void mw_prpl_buddy_free(GaimBuddy *buddy) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4212 /* I don't think we have any cleanup for buddies yet */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4213 ;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4214 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4215
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4216
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4217 static void mw_prpl_convo_closed(GaimConnection *gc, const char *who) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4218 struct mwGaimPluginData *pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4219 struct mwServiceIm *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4220 struct mwConversation *conv;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4221 struct mwIdBlock idb = { (char *) who, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4222
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4223 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4224
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4225 srvc = pd->srvc_im;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4226 g_return_if_fail(srvc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4227
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4228 conv = mwServiceIm_findConversation(srvc, &idb);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4229 if(! conv) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4230
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4231 if(mwConversation_isOpen(conv))
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4232 mwConversation_free(conv);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4233 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4234
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4235
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4236 static const char *mw_prpl_normalize(const GaimAccount *account,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4237 const char *id) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4238
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4239 /* code elsewhere assumes that the return value points to different
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4240 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
4241 data. wtf? */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4242
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4243 static char buf[BUF_LEN];
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4244 strncpy(buf, id, sizeof(buf));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4245 return buf;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4246 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4247
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4248
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4249 static void mw_prpl_remove_group(GaimConnection *gc, GaimGroup *group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4250 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4251 struct mwAwareList *list;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4252
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4253 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4254 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4255 g_return_if_fail(pd->group_list_map != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4256
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4257 list = g_hash_table_lookup(pd->group_list_map, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4258
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4259 if(list) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4260 g_hash_table_remove(pd->group_list_map, list);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4261 g_hash_table_remove(pd->group_list_map, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4262 mwAwareList_free(list);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4263
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4264 blist_schedule(pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4265 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4266 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4267
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4268
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4269 static gboolean mw_prpl_can_receive_file(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4270 const char *who) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4271 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4272 struct mwServiceAware *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4273 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4274
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4275 g_return_val_if_fail(gc != NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4276
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4277 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4278 g_return_val_if_fail(pd != NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4279
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4280 srvc = pd->srvc_aware;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4281 g_return_val_if_fail(srvc != NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4282
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4283 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4284 g_return_val_if_fail(acct != NULL, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4285
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4286 return gaim_find_buddy(acct, who) &&
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4287 user_supports(srvc, who, mwAttribute_FILE_TRANSFER);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4288 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4289
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4290
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4291 static void ft_outgoing_init(GaimXfer *xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4292 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4293 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4294
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4295 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4296 struct mwServiceFileTransfer *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4297 struct mwFileTransfer *ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4298
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4299 const char *filename;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4300 gsize filesize;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4301 FILE *fp;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4302
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4303 struct mwIdBlock idb = { NULL, NULL };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4304
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4305 DEBUG_INFO("ft_outgoing_init\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4306
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4307 acct = gaim_xfer_get_account(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4308 gc = gaim_account_get_connection(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4309 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4310 srvc = pd->srvc_ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4311
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4312 filename = gaim_xfer_get_local_filename(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4313 filesize = gaim_xfer_get_size(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4314 idb.user = xfer->who;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4315
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4316 /* test that we can actually send the file */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4317 fp = g_fopen(filename, "rb");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4318 if(! fp) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4319 char *msg = g_strdup_printf("Error reading %s: \n%s\n",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4320 filename, strerror(errno));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4321 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
4322 g_free(msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4323 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4324 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4325 fclose(fp);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4326
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4327 {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4328 char *tmp = strrchr(filename, G_DIR_SEPARATOR);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4329 if(tmp++) filename = tmp;
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4332 ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4333
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4334 gaim_xfer_ref(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4335 mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) gaim_xfer_unref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4336 xfer->data = ft;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4337
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4338 mwFileTransfer_offer(ft);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4341
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4342 static void ft_outgoing_cancel(GaimXfer *xfer) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4343 struct mwFileTransfer *ft = xfer->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4344 if(ft) mwFileTransfer_cancel(ft);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4347
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4348 static void mw_prpl_send_file(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4349 const char *who, const char *file) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4350
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4351 /** @todo depends on the meanwhile implementation of the file
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4352 transfer service */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4353
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4354 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4355 GaimXfer *xfer;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4356
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4357 DEBUG_INFO("mw_prpl_send_file\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4358
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4359 acct = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4360
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4361 xfer = gaim_xfer_new(acct, GAIM_XFER_SEND, who);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4362 gaim_xfer_set_init_fnc(xfer, ft_outgoing_init);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4363 gaim_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4364
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4365 if(file) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4366 DEBUG_INFO("file != NULL\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4367 gaim_xfer_request_accepted(xfer, file);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4368
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4369 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4370 DEBUG_INFO("file == NULL\n");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4371 gaim_xfer_request(xfer);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4372 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4373 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4374
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 static GaimPluginProtocolInfo mw_prpl_info = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4377 .options = OPT_PROTO_IM_IMAGE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4378 .user_splits = NULL, /*< set in mw_plugin_init */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4379 .protocol_options = NULL, /*< set in mw_plugin_init */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4380 .icon_spec = NO_BUDDY_ICONS,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4381 .list_icon = mw_prpl_list_icon,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4382 .list_emblems = mw_prpl_list_emblems,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4383 .status_text = mw_prpl_status_text,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4384 .tooltip_text = mw_prpl_tooltip_text,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4385 .status_types = mw_prpl_status_types,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4386 .blist_node_menu = mw_prpl_blist_node_menu,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4387 .chat_info = mw_prpl_chat_info,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4388 .chat_info_defaults = mw_prpl_chat_info_defaults,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4389 .login = mw_prpl_login,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4390 .close = mw_prpl_close,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4391 .send_im = mw_prpl_send_im,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4392 .set_info = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4393 .send_typing = mw_prpl_send_typing,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4394 .get_info = mw_prpl_get_info,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4395 .set_idle = mw_prpl_set_idle,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4396 .change_passwd = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4397 .add_buddy = mw_prpl_add_buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4398 .add_buddies = mw_prpl_add_buddies,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4399 .remove_buddy = mw_prpl_remove_buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4400 .remove_buddies = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4401 .add_permit = mw_prpl_add_permit,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4402 .add_deny = mw_prpl_add_deny,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4403 .rem_permit = mw_prpl_rem_permit,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4404 .rem_deny = mw_prpl_rem_deny,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4405 .set_permit_deny = mw_prpl_set_permit_deny,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4406 .warn = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4407 .join_chat = mw_prpl_join_chat,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4408 .reject_chat = mw_prpl_reject_chat,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4409 .get_chat_name = mw_prpl_get_chat_name,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4410 .chat_invite = mw_prpl_chat_invite,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4411 .chat_leave = mw_prpl_chat_leave,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4412 .chat_whisper = mw_prpl_chat_whisper,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4413 .chat_send = mw_prpl_chat_send,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4414 .keepalive = mw_prpl_keepalive,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4415 .register_user = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4416 .get_cb_info = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4417 .get_cb_away = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4418 .alias_buddy = mw_prpl_alias_buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4419 .group_buddy = mw_prpl_group_buddy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4420 .rename_group = mw_prpl_rename_group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4421 .buddy_free = mw_prpl_buddy_free,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4422 .convo_closed = mw_prpl_convo_closed,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4423 .normalize = mw_prpl_normalize,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4424 .set_buddy_icon = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4425 .remove_group = mw_prpl_remove_group,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4426 .get_cb_real_name = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4427 .set_chat_topic = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4428 .find_blist_chat = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4429 .roomlist_get_list = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4430 .roomlist_expand_category = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4431 .can_receive_file = mw_prpl_can_receive_file,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4432 .send_file = mw_prpl_send_file,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4433 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4434
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 static GaimPluginPrefFrame *
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4437 mw_plugin_get_plugin_pref_frame(GaimPlugin *plugin) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4438 GaimPluginPrefFrame *frame;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4439 GaimPluginPref *pref;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4440
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4441 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4442 char *msg;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4443 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4444
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4445 frame = gaim_plugin_pref_frame_new();
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 pref = gaim_plugin_pref_new_with_label("Remotely Stored Buddy List");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4448 gaim_plugin_pref_frame_add(frame, pref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4449
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4450
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4451 pref = gaim_plugin_pref_new_with_name(MW_PRPL_OPT_BLIST_ACTION);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4452 gaim_plugin_pref_set_label(pref, "Buddy List Storage Mode");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4453
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4454 gaim_plugin_pref_set_type(pref, GAIM_PLUGIN_PREF_CHOICE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4455 gaim_plugin_pref_add_choice(pref, "Local Buddy List Only",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4456 GINT_TO_POINTER(BLIST_CHOICE_NONE));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4457 gaim_plugin_pref_add_choice(pref, "Merge List from Server",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4458 GINT_TO_POINTER(BLIST_CHOICE_LOAD));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4459 gaim_plugin_pref_add_choice(pref, "Merge and Save List to Server",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4460 GINT_TO_POINTER(BLIST_CHOICE_SAVE));
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 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4463 /* possible ways to handle:
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4464 - mark all buddies as NO_SAVE
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4465 - load server list, delete all local buddies not in server list
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4466 */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4467 gaim_plugin_pref_add_choice(pref, "Server Buddy List Only",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4468 GINT_TO_POINTER(BLIST_CHOISE_SERVER));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4469 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4470
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4471 gaim_plugin_pref_frame_add(frame, pref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4472
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4473 pref = gaim_plugin_pref_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4474 gaim_plugin_pref_set_type(pref, GAIM_PLUGIN_PREF_INFO);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4475 gaim_plugin_pref_set_label(pref, BLIST_WARNING);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4476 gaim_plugin_pref_frame_add(frame, pref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4477
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4478 pref = gaim_plugin_pref_new_with_label("General Options");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4479 gaim_plugin_pref_frame_add(frame, pref);
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 pref = gaim_plugin_pref_new_with_name(MW_PRPL_OPT_FORCE_LOGIN);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4482 gaim_plugin_pref_set_type(pref, GAIM_PLUGIN_PREF_NONE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4483 gaim_plugin_pref_set_label(pref, "Force Login (Ignore Login Redirects)");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4484 gaim_plugin_pref_frame_add(frame, pref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4485
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4486 pref = gaim_plugin_pref_new_with_name(MW_PRPL_OPT_PSYCHIC);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4487 gaim_plugin_pref_set_type(pref, GAIM_PLUGIN_PREF_NONE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4488 gaim_plugin_pref_set_label(pref, "Enable Psychic Mode");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4489 gaim_plugin_pref_frame_add(frame, pref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4490
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4491 pref = gaim_plugin_pref_new_with_name(MW_PRPL_OPT_SAVE_DYNAMIC);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4492 gaim_plugin_pref_set_type(pref, GAIM_PLUGIN_PREF_NONE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4493 gaim_plugin_pref_set_label(pref, "Save NAB group members locally");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4494 gaim_plugin_pref_frame_add(frame, pref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4495
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4496 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4497 pref = gaim_plugin_pref_new_with_label("Credits");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4498 gaim_plugin_pref_frame_add(frame, pref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4499
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4500 msg = ( PLUGIN_NAME " - " PLUGIN_DESC "\n"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4501 "Version " VERSION "\n"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4502 PLUGIN_AUTHOR "\n"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4503 PLUGIN_HOMEPAGE );
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4504
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4505 pref = gaim_plugin_pref_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4506 gaim_plugin_pref_set_type(pref, GAIM_PLUGIN_PREF_INFO);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4507 gaim_plugin_pref_set_label(pref, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4508 gaim_plugin_pref_frame_add(frame, pref);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4509 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4510
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4511 return frame;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4512 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4513
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 static GaimPluginUiInfo mw_plugin_ui_info = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4516 .get_plugin_pref_frame = mw_plugin_get_plugin_pref_frame,
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4520 static void status_msg_action_cb(GaimConnection *gc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4521 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4522 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4523 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4524 const char *msg;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4525 /* gboolean prompt; */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4526
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4527 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4528 struct mwServiceStorage *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4529 struct mwStorageUnit *unit;
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 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4532 srvc = pd->srvc_store;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4533
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4534 acct = gaim_connection_get_account(gc);
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 f = gaim_request_fields_get_field(fields, "active");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4537 msg = gaim_request_field_string_get_value(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4538 gaim_account_set_string(acct, MW_KEY_ACTIVE_MSG, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4539 unit = mwStorageUnit_newString(mwStore_ACTIVE_MESSAGES, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4540 mwServiceStorage_save(srvc, unit, NULL, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4541
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4542 f = gaim_request_fields_get_field(fields, "away");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4543 msg = gaim_request_field_string_get_value(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4544 gaim_account_set_string(acct, MW_KEY_AWAY_MSG, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4545 unit = mwStorageUnit_newString(mwStore_AWAY_MESSAGES, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4546 mwServiceStorage_save(srvc, unit, NULL, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4547
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4548 f = gaim_request_fields_get_field(fields, "busy");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4549 msg = gaim_request_field_string_get_value(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4550 gaim_account_set_string(acct, MW_KEY_BUSY_MSG, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4551 unit = mwStorageUnit_newString(mwStore_BUSY_MESSAGES, msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4552 mwServiceStorage_save(srvc, unit, NULL, NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4553
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4554 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4555 /** @todo not yet used. It should be possible to prompt the user for
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4556 a message (ala the Sametime Connect client) when changing to one
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4557 of the default states, and that preference is here */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4558 f = gaim_request_fields_get_field(fields, "prompt");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4559 prompt = gaim_request_field_bool_get_value(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4560 gaim_account_set_bool(acct, MW_KEY_MSG_PROMPT, prompt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4561 #endif
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4562
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4563 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4564 /* XXX */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4565 /* need to propagate the message change if we're in any of those
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4566 default states */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4567 msg = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4568 if(!gc->away_state || !strcmp(gc->away_state, MW_STATE_ACTIVE)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4569 msg = MW_STATE_ACTIVE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4570 } else if(gc->away_state && !strcmp(gc->away_state, MW_STATE_AWAY)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4571 msg = MW_STATE_AWAY;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4572 } else if(gc->away_state && !strcmp(gc->away_state, MW_STATE_BUSY)) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4573 msg = MW_STATE_BUSY;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4574 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4575 if(msg)
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4576 serv_set_away(gc, msg, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4577 #endif
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4580
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4581 /** Prompt for messages for the three default status types. These
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4582 values should be mirrored as strings in the storage service */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4583 static void status_msg_action(GaimPluginAction *act) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4584 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4585 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4586
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4587 GaimRequestFields *fields;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4588 GaimRequestFieldGroup *g;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4589 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4590
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4591 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4592 const char *val;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4593 /* gboolean prompt; */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4594
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4595 gc = act->context;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4596 acct = gaim_connection_get_account(gc);
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 fields = gaim_request_fields_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4599
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4600 g = gaim_request_field_group_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4601 gaim_request_fields_add_group(fields, g);
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 val = gaim_account_get_string(acct, MW_KEY_ACTIVE_MSG,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4604 MW_PLUGIN_DEFAULT_ACTIVE_MSG);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4605 f = gaim_request_field_string_new("active", "Active Message", val, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4606 gaim_request_field_set_required(f, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4607 gaim_request_field_group_add_field(g, f);
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 val = gaim_account_get_string(acct, MW_KEY_AWAY_MSG,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4610 MW_PLUGIN_DEFAULT_AWAY_MSG);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4611 f = gaim_request_field_string_new("away", "Away Message", val, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4612 gaim_request_field_set_required(f, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4613 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4614
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4615 val = gaim_account_get_string(acct, MW_KEY_BUSY_MSG,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4616 MW_PLUGIN_DEFAULT_BUSY_MSG);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4617 f = gaim_request_field_string_new("busy", "Busy Message", val, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4618 gaim_request_field_set_required(f, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4619 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4620
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4621 #if 0
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4622 /** @todo not yet used. It should be possible to prompt the user for
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4623 a message (ala the Sametime Connect client) when changing to one
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4624 of the default states, and that preference is here */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4625 prompt = gaim_account_get_bool(acct, MW_KEY_MSG_PROMPT, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4626 f = gaim_request_field_bool_new("prompt",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4627 ("Prompt for message when changing"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4628 " to one of these states?"), FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4629 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4630 #endif
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 msgA = ("Default status messages");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4633 msgB = ("");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4634
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4635 gaim_request_fields(gc, "Edit Status Messages",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4636 msgA, msgB, fields,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4637 _("OK"), G_CALLBACK(status_msg_action_cb),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4638 _("Cancel"), NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4639 gc);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4642
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4643 static void st_import_action_cb(GaimConnection *gc, char *filename) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4644 struct mwSametimeList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4645
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4646 FILE *file;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4647 char buf[BUF_LEN];
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4648 size_t len;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4649
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4650 GString *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4651
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4652 file = fopen(filename, "r");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4653 g_return_if_fail(file != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4654
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4655 str = g_string_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4656 while( (len = fread(buf, 1, BUF_LEN, file)) ) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4657 g_string_append_len(str, buf, len);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4658 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4659
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4660 fclose(file);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4661
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4662 l = mwSametimeList_load(str->str);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4663 g_string_free(str, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4664
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4665 blist_import(gc, l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4666 mwSametimeList_free(l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4667 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4668
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4669
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4670 /** prompts for a file to import blist from */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4671 static void st_import_action(GaimPluginAction *act) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4672 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4673 GaimAccount *account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4674 char *title;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4675
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4676 gc = act->context;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4677 account = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4678 title = g_strdup_printf("Import Sametime List for Account %s",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4679 gaim_account_get_username(account));
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 gaim_request_file(gc, title, NULL, FALSE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4682 G_CALLBACK(st_import_action_cb), NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4683 gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4684
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4685 g_free(title);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4686 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4687
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4688
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4689 static void st_export_action_cb(GaimConnection *gc, char *filename) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4690 struct mwSametimeList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4691 char *str;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4692 FILE *file;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4693
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4694 file = fopen(filename, "w");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4695 g_return_if_fail(file != NULL);
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 l = mwSametimeList_new();
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4698 blist_export(gc, l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4699 str = mwSametimeList_store(l);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4700 mwSametimeList_free(l);
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 fprintf(file, "%s", str);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4703 fclose(file);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4704
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4705 g_free(str);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4706 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4709 /** prompts for a file to export blist to */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4710 static void st_export_action(GaimPluginAction *act) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4711 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4712 GaimAccount *account;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4713 char *title;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4714
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4715 gc = act->context;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4716 account = gaim_connection_get_account(gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4717 title = g_strdup_printf("Export Sametime List for Account %s",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4718 gaim_account_get_username(account));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4719
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4720 gaim_request_file(gc, title, NULL, TRUE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4721 G_CALLBACK(st_export_action_cb), NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4722 gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4723
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4724 g_free(title);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4725 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4726
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4727
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4728 static void remote_group_multi_cleanup(gpointer ignore,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4729 GaimRequestFields *fields) {
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 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4732 const GList *l;
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 f = gaim_request_fields_get_field(fields, "group");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4735 l = gaim_request_field_list_get_items(f);
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 for(; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4738 const char *i = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4739 struct resolved_id *res;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4740
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4741 res = gaim_request_field_list_get_data(f, i);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4742
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4743 g_free(res->id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4744 g_free(res->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4745 g_free(res);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4746 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4747 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4748
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4749
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4750 static void remote_group_done(struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4751 const char *id, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4752 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4753 GaimAccount *acct;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4754 GaimGroup *group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4755 GaimBlistNode *gn;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4756 const char *owner;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4757
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4758 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4759
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4760 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4761 acct = gaim_connection_get_account(gc);
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 /* collision checking */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4764 group = gaim_find_group(name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4765 if(group) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4766 char *msgA, *msgB;
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 msgA = "Unable to add group: group exists";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4769 msgB = "A group named '%s' already exists in your buddy list.";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4770 msgB = g_strdup_printf(msgB, name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4771
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4772 gaim_notify_error(gc, "Unable to add group", msgA, msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4773
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4774 g_free(msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4775 return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4776 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4777
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4778 group = gaim_group_new(name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4779 gn = (GaimBlistNode *) group;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4780
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4781 owner = gaim_account_get_username(acct);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4782
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4783 gaim_blist_node_set_string(gn, GROUP_KEY_NAME, id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4784 gaim_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4785 gaim_blist_node_set_string(gn, GROUP_KEY_OWNER, owner);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4786 gaim_blist_add_group(group, NULL);
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 group_add(pd, group);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4789 blist_schedule(pd);
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
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 static void remote_group_multi_cb(struct mwGaimPluginData *pd,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4794 GaimRequestFields *fields) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4795 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4796 const GList *l;
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 f = gaim_request_fields_get_field(fields, "group");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4799 l = gaim_request_field_list_get_selected(f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4800
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4801 if(l) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4802 const char *i = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4803 struct resolved_id *res;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4804
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4805 res = gaim_request_field_list_get_data(f, i);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4806 remote_group_done(pd, res->id, res->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4807 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4808
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4809 remote_group_multi_cleanup(NULL, fields);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4810 }
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 static void remote_group_multi(struct mwResolveResult *result,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4814 struct mwGaimPluginData *pd) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4815
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4816 GaimRequestFields *fields;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4817 GaimRequestFieldGroup *g;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4818 GaimRequestField *f;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4819 GList *l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4820 char *msgA, *msgB;
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 GaimConnection *gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4823
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4824 fields = gaim_request_fields_new();
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 g = gaim_request_field_group_new(NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4827 gaim_request_fields_add_group(fields, g);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4828
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4829 f = gaim_request_field_list_new("group", "Possible Matches");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4830 gaim_request_field_list_set_multi_select(f, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4831 gaim_request_field_set_required(f, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4832
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4833 for(l = result->matches; l; l = l->next) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4834 struct mwResolveMatch *match = l->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4835 struct resolved_id *res = g_new0(struct resolved_id, 1);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4836
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4837 res->id = g_strdup(match->id);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4838 res->name = g_strdup(match->name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4839
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4840 gaim_request_field_list_add(f, res->name, res);
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 gaim_request_field_group_add_field(g, f);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4844
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4845 msgA = ("Notes Address Book group results");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4846 msgB = ("The identifier '%s' may possibly refer to any of the following"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4847 " Notes Address Book groups. Please select the correct group from"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4848 " the list below to add it to your buddy list.");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4849 msgB = g_strdup_printf(msgB, result->name);
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 gaim_request_fields(gc, "Select Notes Address Book",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4852 msgA, msgB, fields,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4853 "Add Group", G_CALLBACK(remote_group_multi_cb),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4854 "Cancel", G_CALLBACK(remote_group_multi_cleanup),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4855 pd);
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 g_free(msgB);
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 remote_group_resolved(struct mwServiceResolve *srvc,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4862 guint32 id, guint32 code, GList *results,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4863 gpointer b) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4864 struct mwSession *session;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4865 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4866 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4867
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4868 struct mwResolveResult *res = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4869
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4870 session = mwService_getSession(MW_SERVICE(srvc));
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4871 g_return_if_fail(session != 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 pd = mwSession_getClientData(session);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4874 g_return_if_fail(pd != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4875
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4876 gc = pd->gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4877 g_return_if_fail(gc != NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4878
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4879 if(!code && results) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4880 res = results->data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4881
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4882 if(res->matches) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4883 remote_group_multi(res, pd);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4884 return;
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 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4887
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4888 if(res && res->name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4889 char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4890
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4891 msgA = "Unable to add group: group not found";
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 msgB = ("The identifier '%s' did not match any Notes Address Book"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4894 " groups in your Sametime community.");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4895 msgB = g_strdup_printf(msgB, res->name);
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 gaim_notify_error(gc, "Unable to add group", msgA, msgB);
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 g_free(msgB);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4900 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4901 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4904 static void remote_group_action_cb(GaimConnection *gc, const char *name) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4905 struct mwGaimPluginData *pd;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4906 struct mwServiceResolve *srvc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4907 GList *query;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4908 enum mwResolveFlag flags;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4909 guint32 req;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4910
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4911 pd = gc->proto_data;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4912 srvc = pd->srvc_resolve;
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 query = g_list_prepend(NULL, (char *) name);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4915 flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS;
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 req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4918 NULL, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4919 g_list_free(query);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4920
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4921 if(req == SEARCH_ERROR) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4922 /** @todo display error */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4923 }
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
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 static void remote_group_action(GaimPluginAction *act) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4928 GaimConnection *gc;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4929 const char *msgA, *msgB;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4930
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4931 gc = act->context;
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 msgA = "Notes Address Book Group";
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4934 msgB = ("Enter the name of a Notes Address Book group in the field below"
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4935 " to add the group and its members to your buddy list.");
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4936
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4937 gaim_request_input(gc, "Add Group", msgA, msgB, NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4938 FALSE, FALSE, NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4939 "Add", G_CALLBACK(remote_group_action_cb),
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4940 "Cancel", NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4941 gc);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4942 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4943
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 static GList *mw_plugin_actions(GaimPlugin *plugin, gpointer context) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4946 GaimPluginAction *act;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4947 GList *l = NULL;
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 act = gaim_plugin_action_new("Set Status Messages...", status_msg_action);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4950 l = g_list_append(l, act);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4951
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4952 act = gaim_plugin_action_new("Import Sametime List...", st_import_action);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4953 l = g_list_append(l, act);
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 act = gaim_plugin_action_new("Export Sametime List...", st_export_action);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4956 l = g_list_append(l, act);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4957
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4958 act = gaim_plugin_action_new("Add Notes Address Book Group...",
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4959 remote_group_action);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4960 l = g_list_append(l, act);
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 return l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4963 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4964
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 static gboolean mw_plugin_load(GaimPlugin *plugin) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4967 return TRUE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4968 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4969
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4970
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4971 static gboolean mw_plugin_unload(GaimPlugin *plugin) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4972 return TRUE;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4973 }
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4976 static void mw_plugin_destroy(GaimPlugin *plugin) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4977 g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4978 g_log_remove_handler("meanwhile", log_handler[1]);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4979 }
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 static GaimPluginInfo mw_plugin_info = {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4983 .magic = GAIM_PLUGIN_MAGIC,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4984 .major_version = GAIM_MAJOR_VERSION,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4985 .minor_version = GAIM_MINOR_VERSION,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4986 .type = GAIM_PLUGIN_PROTOCOL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4987 .ui_requirement = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4988 .flags = 0,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4989 .dependencies = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4990 .priority = GAIM_PRIORITY_DEFAULT,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4991 .id = PLUGIN_ID,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4992 .name = PLUGIN_NAME,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4993 .version = VERSION,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4994 .summary = PLUGIN_SUMMARY,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4995 .description = PLUGIN_DESC,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4996 .author = PLUGIN_AUTHOR,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4997 .homepage = PLUGIN_HOMEPAGE,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4998 .load = mw_plugin_load,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4999 .unload = mw_plugin_unload,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5000 .destroy = mw_plugin_destroy,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5001 .ui_info = NULL,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5002 .extra_info = &mw_prpl_info,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5003 .prefs_info = &mw_plugin_ui_info,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5004 .actions = mw_plugin_actions,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5005 };
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5006
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5007
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5008 static void mw_log_handler(const gchar *domain, GLogLevelFlags flags,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5009 const gchar *msg, gpointer data) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5010 char *nl;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5011
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5012 if(! msg) return;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5013
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5014 /* annoying! */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5015 nl = g_strdup_printf("%s\n", msg);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5016
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5017 /* handle g_log requests via gaim's built-in debug logging */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5018 if(flags & G_LOG_LEVEL_ERROR) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5019 gaim_debug_error(domain, nl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5020
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5021 } else if(flags & G_LOG_LEVEL_WARNING) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5022 gaim_debug_warning(domain, nl);
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 } else {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5025 gaim_debug_info(domain, nl);
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
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5028 g_free(nl);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5029 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5030
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5031
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5032 static void mw_plugin_init(GaimPlugin *plugin) {
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5033 GaimAccountOption *opt;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5034 GList *l = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5035
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5036 GLogLevelFlags logflags =
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5037 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
5038
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5039 /* host to connect to */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5040 opt = gaim_account_option_string_new("Server", MW_KEY_HOST,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5041 MW_PLUGIN_DEFAULT_HOST);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5042 l = g_list_append(l, opt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5043
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5044 /* port to connect to */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5045 opt = gaim_account_option_int_new("Port", MW_KEY_PORT,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5046 MW_PLUGIN_DEFAULT_PORT);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5047 l = g_list_append(l, opt);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5048
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5049 mw_prpl_info.protocol_options = l;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5050 l = NULL;
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5051
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5052 /* set up the prefs for blist options */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5053 gaim_prefs_add_none(MW_PRPL_OPT_BASE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5054 gaim_prefs_add_int(MW_PRPL_OPT_BLIST_ACTION, BLIST_CHOICE_DEFAULT);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5055 gaim_prefs_add_bool(MW_PRPL_OPT_PSYCHIC, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5056 gaim_prefs_add_bool(MW_PRPL_OPT_FORCE_LOGIN, FALSE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5057 gaim_prefs_add_bool(MW_PRPL_OPT_SAVE_DYNAMIC, TRUE);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5058
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5059 /* 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
5060 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
5061 get caught here */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5062 log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5063 mw_log_handler, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5064
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5065 /* redirect meanwhile's logging to gaim's */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5066 log_handler[1] = g_log_set_handler("meanwhile", logflags,
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5067 mw_log_handler, NULL);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5068 }
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5069
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5070
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5071 GAIM_INIT_PLUGIN(meanwhile, mw_plugin_init, mw_plugin_info);
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5072 /* The End. */
2ce8ec01a064 [gaim-migrate @ 12803]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5073