Mercurial > pidgin.yaz
annotate src/protocols/yahoo/yahoo_doodle.c @ 14142:89d043d547cc
[gaim-migrate @ 16784]
Never allow Yahoo! to insert a NULL value into the outgoing packet
hash. This fixes some random crashes when the packet gets sent,
and yahoo_packet_length() is called, which eventually calls
strlen(NULL), which crashes
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 16 Aug 2006 06:58:59 +0000 |
parents | 967ef719cb62 |
children |
rev | line source |
---|---|
11475 | 1 /* |
2 * gaim | |
3 * | |
4 * Gaim is the legal property of its developers, whose names are too numerous | |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 */ | |
23 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
24 /****************************************************************************** |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
25 * INCLUDES |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
26 *****************************************************************************/ |
11475 | 27 #include "internal.h" |
28 | |
29 #include "account.h" | |
30 #include "accountopt.h" | |
31 #include "blist.h" | |
32 #include "cipher.h" | |
33 #include "cmds.h" | |
34 #include "debug.h" | |
35 #include "notify.h" | |
36 #include "privacy.h" | |
37 #include "prpl.h" | |
38 #include "proxy.h" | |
39 #include "request.h" | |
40 #include "server.h" | |
41 #include "util.h" | |
42 #include "version.h" | |
43 | |
44 #include "yahoo.h" | |
45 #include "yahoo_packet.h" | |
46 #include "yahoo_friend.h" | |
47 #include "yahoochat.h" | |
48 #include "ycht.h" | |
49 #include "yahoo_auth.h" | |
50 #include "yahoo_filexfer.h" | |
51 #include "yahoo_picture.h" | |
52 | |
53 #include "whiteboard.h" | |
54 #include "yahoo_doodle.h" | |
55 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
56 /****************************************************************************** |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
57 * Globals |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
58 *****************************************************************************/ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
59 const int DefaultColorRGB24[] = |
11475 | 60 { |
61 DOODLE_COLOR_RED, | |
62 DOODLE_COLOR_ORANGE, | |
63 DOODLE_COLOR_YELLOW, | |
64 DOODLE_COLOR_GREEN, | |
65 DOODLE_COLOR_CYAN, | |
66 DOODLE_COLOR_BLUE, | |
67 DOODLE_COLOR_VIOLET, | |
68 DOODLE_COLOR_PURPLE, | |
69 DOODLE_COLOR_TAN, | |
70 DOODLE_COLOR_BROWN, | |
71 DOODLE_COLOR_BLACK, | |
72 DOODLE_COLOR_GREY, | |
73 DOODLE_COLOR_WHITE | |
74 }; | |
75 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
76 /****************************************************************************** |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
77 * Functions |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
78 *****************************************************************************/ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
79 GaimCmdRet yahoo_doodle_gaim_cmd_start(GaimConversation *conv, const char *cmd, char **args, char **error, void *data) |
11475 | 80 { |
11514 | 81 GaimAccount *account; |
82 GaimConnection *gc; | |
11800
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
83 const gchar *name; |
11514 | 84 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
85 if(*args && args[0]) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
86 return GAIM_CMD_RET_FAILED; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
87 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
88 account = gaim_conversation_get_account(conv); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
89 gc = gaim_account_get_connection(account); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
90 name = gaim_conversation_get_name(conv); |
11800
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
91 yahoo_doodle_initiate(gc, name); |
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
92 |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
93 /* Write a local message to this conversation showing that a request for a |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
94 * Doodle session has been made |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
95 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
96 gaim_conv_im_write(GAIM_CONV_IM(conv), "", _("Sent Doodle request."), |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
97 GAIM_MESSAGE_NICK | GAIM_MESSAGE_RECV, time(NULL)); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
98 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
99 return GAIM_CMD_RET_OK; |
11800
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
100 } |
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
101 |
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
102 void yahoo_doodle_initiate(GaimConnection *gc, const char *name) |
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
103 { |
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
104 GaimAccount *account; |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
105 char *to = (char*)name; |
11800
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
106 GaimWhiteboard *wb; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
107 |
11800
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
108 g_return_if_fail(gc); |
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
109 g_return_if_fail(name); |
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
110 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
111 account = gaim_connection_get_account(gc); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
112 wb = gaim_whiteboard_get_session(account, to); |
11800
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
113 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
114 if(wb == NULL) |
11475 | 115 { |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
116 /* Insert this 'session' in the list. At this point, it's only a |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
117 * requested session. |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
118 */ |
13711
967ef719cb62
[gaim-migrate @ 16115]
Richard Laager <rlaager@wiktel.com>
parents:
13460
diff
changeset
|
119 gaim_whiteboard_create(account, to, DOODLE_STATE_REQUESTING); |
11475 | 120 } |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
121 |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
122 /* NOTE Perhaps some careful handling of remote assumed established |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
123 * sessions |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
124 */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
125 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
126 yahoo_doodle_command_send_request(gc, to); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
127 yahoo_doodle_command_send_ready(gc, to); |
11800
32bac0647037
[gaim-migrate @ 14091]
Gary Kramlich <grim@reaperworld.com>
parents:
11514
diff
changeset
|
128 |
11475 | 129 } |
130 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
131 void yahoo_doodle_process(GaimConnection *gc, const char *me, const char *from, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
132 const char *command, const char *message) |
11475 | 133 { |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
134 if(!command) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
135 return; |
11475 | 136 |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
137 /* Now check to see what sort of Doodle message it is */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
138 switch(atoi(command)) |
11475 | 139 { |
140 case DOODLE_CMD_REQUEST: | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
141 yahoo_doodle_command_got_request(gc, from); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
142 break; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
143 |
11475 | 144 case DOODLE_CMD_READY: |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
145 yahoo_doodle_command_got_ready(gc, from); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
146 break; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
147 |
11475 | 148 case DOODLE_CMD_CLEAR: |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
149 yahoo_doodle_command_got_clear(gc, from); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
150 break; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
151 |
11475 | 152 case DOODLE_CMD_DRAW: |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
153 yahoo_doodle_command_got_draw(gc, from, message); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
154 break; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
155 |
11475 | 156 case DOODLE_CMD_EXTRA: |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
157 yahoo_doodle_command_got_extra(gc, from, message); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
158 break; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
159 |
11475 | 160 case DOODLE_CMD_CONFIRM: |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
161 yahoo_doodle_command_got_confirm(gc, from); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
162 break; |
11475 | 163 } |
164 } | |
165 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
166 void yahoo_doodle_command_got_request(GaimConnection *gc, const char *from) |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
167 { |
11514 | 168 GaimAccount *account; |
169 GaimWhiteboard *wb; | |
170 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
171 gaim_debug_info("yahoo", "doodle: Got Request (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
172 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
173 account = gaim_connection_get_account(gc); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
174 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
175 /* Only handle this if local client requested Doodle session (else local |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
176 * client would have sent one) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
177 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
178 wb = gaim_whiteboard_get_session(account, from); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
179 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
180 /* If a session with the remote user doesn't exist */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
181 if(wb == NULL) |
11475 | 182 { |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
183 /* Ask user if they wish to accept the request for a doodle session */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
184 /* TODO Ask local user to start Doodle session with remote user */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
185 /* NOTE This if/else statement won't work right--must use dialog |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
186 * results |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
187 */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
188 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
189 /* char dialog_message[64]; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
190 g_sprintf(dialog_message, "%s is requesting to start a Doodle session with you.", from); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
191 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
192 gaim_notify_message(NULL, GAIM_NOTIFY_MSG_INFO, "Doodle", |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
193 dialog_message, NULL, NULL, NULL); |
11475 | 194 */ |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
195 |
13711
967ef719cb62
[gaim-migrate @ 16115]
Richard Laager <rlaager@wiktel.com>
parents:
13460
diff
changeset
|
196 gaim_whiteboard_create(account, from, DOODLE_STATE_REQUESTED); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
197 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
198 yahoo_doodle_command_send_request(gc, from); |
11475 | 199 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
200 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
201 /* TODO Might be required to clear the canvas of an existing doodle |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
202 * session at this point |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
203 */ |
11475 | 204 } |
205 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
206 void yahoo_doodle_command_got_ready(GaimConnection *gc, const char *from) |
11475 | 207 { |
11514 | 208 GaimAccount *account; |
209 GaimWhiteboard *wb; | |
210 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
211 gaim_debug_info("yahoo", "doodle: Got Ready (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
212 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
213 account = gaim_connection_get_account(gc); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
214 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
215 /* Only handle this if local client requested Doodle session (else local |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
216 * client would have sent one) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
217 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
218 wb = gaim_whiteboard_get_session(account, from); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
219 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
220 if(wb == NULL) |
11475 | 221 return; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
222 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
223 if(wb->state == DOODLE_STATE_REQUESTING) |
11475 | 224 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
225 gaim_whiteboard_start(wb); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
226 |
11475 | 227 wb->state = DOODLE_STATE_ESTABLISHED; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
228 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
229 yahoo_doodle_command_send_confirm(gc, from); |
11475 | 230 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
231 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
232 if(wb->state == DOODLE_STATE_ESTABLISHED) |
11475 | 233 { |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
234 /* TODO Ask whether to save picture too */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
235 gaim_whiteboard_clear(wb); |
11475 | 236 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
237 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
238 /* NOTE Not sure about this... I am trying to handle if the remote user |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
239 * already thinks we're in a session with them (when their chat message |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
240 * contains the doodle;11 imv key) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
241 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
242 if(wb->state == DOODLE_STATE_REQUESTED) |
11475 | 243 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
244 /* gaim_whiteboard_start(wb); */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
245 yahoo_doodle_command_send_request(gc, from); |
11475 | 246 } |
247 } | |
248 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
249 void yahoo_doodle_command_got_draw(GaimConnection *gc, const char *from, const char *message) |
11475 | 250 { |
11514 | 251 GaimAccount *account; |
252 GaimWhiteboard *wb; | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
253 char **tokens; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
254 int i; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
255 GList *d_list = NULL; /* a local list of drawing info */ |
11514 | 256 |
13460
ca43d58cdc43
[gaim-migrate @ 15835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13459
diff
changeset
|
257 g_return_if_fail(message != NULL); |
ca43d58cdc43
[gaim-migrate @ 15835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13459
diff
changeset
|
258 |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
259 gaim_debug_info("yahoo", "doodle: Got Draw (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
260 gaim_debug_info("yahoo", "doodle: Draw message: %s\n", message); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
261 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
262 account = gaim_connection_get_account(gc); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
263 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
264 /* Only handle this if local client requested Doodle session (else local |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
265 * client would have sent one) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
266 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
267 wb = gaim_whiteboard_get_session(account, from); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
268 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
269 if(wb == NULL) |
11475 | 270 return; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
271 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
272 /* TODO Functionalize |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
273 * Convert drawing packet message to an integer list |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
274 */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
275 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
276 /* Check to see if the message begans and ends with quotes */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
277 if((message[0] != '\"') || (message[strlen(message) - 1] != '\"')) |
11475 | 278 return; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
279 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
280 /* Ignore the inital quotation mark. */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
281 message += 1; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
282 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
283 tokens = g_strsplit(message, ",", 0); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
284 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
285 /* Traverse and extract all integers divided by commas */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
286 for (i = 0; tokens[i] != NULL; i++) |
11475 | 287 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
288 int last = strlen(tokens[i]) - 1; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
289 if (tokens[i][last] == '"') |
11916 | 290 tokens[i][last] = '\0'; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
291 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
292 d_list = g_list_prepend(d_list, GINT_TO_POINTER(atoi(tokens[i]))); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
293 } |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
294 d_list = g_list_reverse(d_list); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
295 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
296 g_strfreev(tokens); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
297 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
298 yahoo_doodle_draw_stroke(wb, d_list); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
299 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
300 /* goodle_doodle_session_set_canvas_as_icon(ds); */ |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
301 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
302 g_list_free(d_list); |
11475 | 303 } |
304 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
305 void yahoo_doodle_command_got_clear(GaimConnection *gc, const char *from) |
11475 | 306 { |
11514 | 307 GaimAccount *account; |
308 GaimWhiteboard *wb; | |
309 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
310 gaim_debug_info("yahoo", "doodle: Got Clear (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
311 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
312 account = gaim_connection_get_account(gc); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
313 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
314 /* Only handle this if local client requested Doodle session (else local |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
315 * client would have sent one) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
316 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
317 wb = gaim_whiteboard_get_session(account, from); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
318 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
319 if(wb == NULL) |
11475 | 320 return; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
321 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
322 if(wb->state == DOODLE_STATE_ESTABLISHED) |
11475 | 323 { |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
324 /* TODO Ask user whether to save the image before clearing it */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
325 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
326 gaim_whiteboard_clear(wb); |
11475 | 327 } |
328 } | |
329 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
330 void |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
331 yahoo_doodle_command_got_extra(GaimConnection *gc, const char *from, const char *message) |
11475 | 332 { |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
333 gaim_debug_info("yahoo", "doodle: Got Extra (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
334 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
335 /* I do not like these 'extra' features, so I'll only handle them in one |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
336 * way, which is returning them with the command/packet to turn them off |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
337 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
338 yahoo_doodle_command_send_extra(gc, from, DOODLE_EXTRA_NONE); |
11475 | 339 } |
340 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
341 void yahoo_doodle_command_got_confirm(GaimConnection *gc, const char *from) |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
342 { |
11514 | 343 GaimAccount *account; |
344 GaimWhiteboard *wb; | |
345 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
346 gaim_debug_info("yahoo", "doodle: Got Confirm (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
347 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
348 /* Get the doodle session */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
349 account = gaim_connection_get_account(gc); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
350 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
351 /* Only handle this if local client requested Doodle session (else local |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
352 * client would have sent one) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
353 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
354 wb = gaim_whiteboard_get_session(account, from); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
355 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
356 if(wb == NULL) |
11475 | 357 return; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
358 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
359 /* TODO Combine the following IF's? */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
360 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
361 /* Check if we requested a doodle session */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
362 if(wb->state == DOODLE_STATE_REQUESTING) |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
363 { |
11475 | 364 wb->state = DOODLE_STATE_ESTABLISHED; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
365 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
366 gaim_whiteboard_start(wb); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
367 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
368 yahoo_doodle_command_send_confirm(gc, from); |
11475 | 369 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
370 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
371 /* Check if we accepted a request for a doodle session */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
372 if(wb->state == DOODLE_STATE_REQUESTED) |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
373 { |
11475 | 374 wb->state = DOODLE_STATE_ESTABLISHED; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
375 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
376 gaim_whiteboard_start(wb); |
11475 | 377 } |
378 } | |
379 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
380 void yahoo_doodle_command_got_shutdown(GaimConnection *gc, const char *from) |
11475 | 381 { |
11514 | 382 GaimAccount *account; |
383 GaimWhiteboard *wb; | |
384 | |
13459
3e27ed592e02
[gaim-migrate @ 15834]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
385 g_return_if_fail(from != NULL); |
3e27ed592e02
[gaim-migrate @ 15834]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
386 |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
387 gaim_debug_info("yahoo", "doodle: Got Shutdown (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
388 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
389 account = gaim_connection_get_account(gc); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
390 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
391 /* Only handle this if local client requested Doodle session (else local |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
392 * client would have sent one) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
393 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
394 wb = gaim_whiteboard_get_session(account, from); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
395 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
396 /* TODO Ask if user wants to save picture before the session is closed */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
397 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
398 /* If this session doesn't exist, don't try and kill it */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
399 if(wb == NULL) |
11475 | 400 return; |
401 else | |
402 { | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
403 gaim_whiteboard_destroy(wb); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
404 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
405 /* yahoo_doodle_command_send_shutdown(gc, from); */ |
11475 | 406 } |
407 } | |
408 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
409 static void yahoo_doodle_command_send_generic(const char *type, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
410 GaimConnection *gc, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
411 const char *to, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
412 const char *message, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
413 const char *thirteen, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
414 const char *sixtythree, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
415 const char *sixtyfour) |
11475 | 416 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
417 struct yahoo_data *yd; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
418 struct yahoo_packet *pkt; |
11514 | 419 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
420 gaim_debug_info("yahoo", "doodle: Sent %s (%s)\n", type, to); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
421 |
11475 | 422 yd = gc->proto_data; |
423 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
424 /* Make and send an acknowledge (ready) Doodle packet */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
425 pkt = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
426 yahoo_packet_hash_str(pkt, 49, "IMVIRONMENT"); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
427 yahoo_packet_hash_str(pkt, 1, gaim_account_get_username(gc->account)); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
428 yahoo_packet_hash_str(pkt, 14, message); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
429 yahoo_packet_hash_str(pkt, 13, thirteen); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
430 yahoo_packet_hash_str(pkt, 5, to); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
431 yahoo_packet_hash_str(pkt, 63, sixtythree ? sixtythree : "doodle;11"); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
432 yahoo_packet_hash_str(pkt, 64, sixtyfour); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
433 yahoo_packet_hash_str(pkt, 1002, "1"); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
434 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
435 yahoo_packet_send_and_free(pkt, yd); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
436 } |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
437 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
438 void yahoo_doodle_command_send_request(GaimConnection *gc, const char *to) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
439 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
440 yahoo_doodle_command_send_generic("Request", gc, to, "1", "1", NULL, "1"); |
11475 | 441 } |
442 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
443 void yahoo_doodle_command_send_ready(GaimConnection *gc, const char *to) |
11475 | 444 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
445 yahoo_doodle_command_send_generic("Ready", gc, to, "", "0", NULL, "0"); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
446 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
447 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
448 void yahoo_doodle_command_send_draw(GaimConnection *gc, const char *to, const char *message) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
449 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
450 yahoo_doodle_command_send_generic("Draw", gc, to, message, "3", NULL, "1"); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
451 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
452 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
453 void yahoo_doodle_command_send_clear(GaimConnection *gc, const char *to) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
454 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
455 yahoo_doodle_command_send_generic("Clear", gc, to, " ", "2", NULL, "1"); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
456 } |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
457 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
458 void yahoo_doodle_command_send_extra(GaimConnection *gc, const char *to, const char *message) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
459 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
460 yahoo_doodle_command_send_generic("Extra", gc, to, message, "4", NULL, "1"); |
11475 | 461 } |
462 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
463 void yahoo_doodle_command_send_confirm(GaimConnection *gc, const char *to) |
11475 | 464 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
465 yahoo_doodle_command_send_generic("Confirm", gc, to, "1", "5", NULL, "1"); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
466 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
467 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
468 void yahoo_doodle_command_send_shutdown(GaimConnection *gc, const char *to) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
469 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
470 yahoo_doodle_command_send_generic("Shutdown", gc, to, "", "0", ";0", "0"); |
11475 | 471 } |
472 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
473 void yahoo_doodle_start(GaimWhiteboard *wb) |
11475 | 474 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
475 doodle_session *ds = g_new0(doodle_session, 1); |
11514 | 476 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
477 /* gaim_debug_debug("yahoo", "doodle: yahoo_doodle_start()\n"); */ |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
478 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
479 /* Set default brush size and color */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
480 ds->brush_size = DOODLE_BRUSH_SMALL; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
481 ds->brush_color = DOODLE_COLOR_RED; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
482 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
483 wb->proto_data = ds; |
11475 | 484 } |
485 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
486 void yahoo_doodle_end(GaimWhiteboard *wb) |
11475 | 487 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
488 GaimConnection *gc = gaim_account_get_connection(wb->account); |
11514 | 489 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
490 /* g_debug_debug("yahoo", "doodle: yahoo_doodle_end()\n"); */ |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
491 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
492 yahoo_doodle_command_send_shutdown(gc, wb->who); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
493 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
494 g_free(wb->proto_data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
495 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
496 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
497 void yahoo_doodle_get_dimensions(GaimWhiteboard *wb, int *width, int *height) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
498 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
499 /* standard Doodle canvases are of one size: 368x256 */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
500 *width = DOODLE_CANVAS_WIDTH; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
501 *height = DOODLE_CANVAS_HEIGHT; |
11475 | 502 } |
503 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
504 static char *yahoo_doodle_build_draw_string(doodle_session *ds, GList *draw_list) |
11475 | 505 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
506 GString *message; |
11514 | 507 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
508 g_return_val_if_fail(draw_list != NULL, NULL); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
509 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
510 message = g_string_new(""); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
511 g_string_printf(message, "\"%d,%d", ds->brush_color, ds->brush_size); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
512 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
513 for(; draw_list != NULL; draw_list = draw_list->next) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
514 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
515 g_string_append_printf(message, ",%d", GPOINTER_TO_INT(draw_list->data)); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
516 } |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
517 g_string_append_c(message, '"'); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
518 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
519 return g_string_free(message, FALSE); |
11475 | 520 } |
521 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
522 void yahoo_doodle_send_draw_list(GaimWhiteboard *wb, GList *draw_list) |
11475 | 523 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
524 doodle_session *ds = wb->proto_data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
525 char *message; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
526 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
527 g_return_if_fail(draw_list != NULL); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
528 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
529 message = yahoo_doodle_build_draw_string(ds, draw_list); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
530 yahoo_doodle_command_send_draw(wb->account->gc, wb->who, message); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
531 g_free(message); |
11475 | 532 } |
533 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
534 void yahoo_doodle_clear(GaimWhiteboard *wb) |
11475 | 535 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
536 yahoo_doodle_command_send_clear(wb->account->gc, wb->who); |
11475 | 537 } |
538 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
539 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
540 /* Traverse through the list and draw the points and lines */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
541 void yahoo_doodle_draw_stroke(GaimWhiteboard *wb, GList *draw_list) |
11475 | 542 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
543 int brush_color; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
544 int brush_size; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
545 int x; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
546 int y; |
11475 | 547 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
548 g_return_if_fail(draw_list != NULL); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
549 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
550 brush_color = GPOINTER_TO_INT(draw_list->data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
551 draw_list = draw_list->next; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
552 g_return_if_fail(draw_list != NULL); |
11475 | 553 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
554 brush_size = GPOINTER_TO_INT(draw_list->data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
555 draw_list = draw_list->next; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
556 g_return_if_fail(draw_list != NULL); |
11475 | 557 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
558 x = GPOINTER_TO_INT(draw_list->data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
559 draw_list = draw_list->next; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
560 g_return_if_fail(draw_list != NULL); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
561 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
562 y = GPOINTER_TO_INT(draw_list->data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
563 draw_list = draw_list->next; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
564 g_return_if_fail(draw_list != NULL); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
565 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
566 /* |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
567 gaim_debug_debug("yahoo", "doodle: Drawing: color=%d, size=%d, (%d,%d)\n", brush_color, brush_size, x, y); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
568 */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
569 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
570 while(draw_list != NULL && draw_list->next != NULL) |
11475 | 571 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
572 int dx = GPOINTER_TO_INT(draw_list->data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
573 int dy = GPOINTER_TO_INT(draw_list->next->data); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
574 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
575 gaim_whiteboard_draw_line(wb, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
576 x, y, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
577 x + dx, y + dy, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
578 brush_color, brush_size); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
579 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
580 x += dx; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
581 y += dy; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
582 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
583 draw_list = draw_list->next->next; |
11475 | 584 } |
585 } | |
586 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
587 void yahoo_doodle_get_brush(GaimWhiteboard *wb, int *size, int *color) |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11916
diff
changeset
|
588 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
589 doodle_session *ds = (doodle_session *)wb->proto_data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
590 *size = ds->brush_size; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
591 *color = ds->brush_color; |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11916
diff
changeset
|
592 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
593 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
594 void yahoo_doodle_set_brush(GaimWhiteboard *wb, int size, int color) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
595 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
596 doodle_session *ds = (doodle_session *)wb->proto_data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
597 ds->brush_size = size; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
598 ds->brush_color = color; |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11916
diff
changeset
|
599 |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11916
diff
changeset
|
600 /* Notify the core about the changes */ |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11916
diff
changeset
|
601 gaim_whiteboard_set_brush(wb, size, color); |
11475 | 602 } |
603 |