Mercurial > pidgin.yaz
annotate src/protocols/yahoo/yahoo_doodle.c @ 13047:473d3a454615
[gaim-migrate @ 15408]
15:52:32 <NSA_> In the system tray, the "Custom Status..." should be changed to
"New Status..." to be more consistent.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Thu, 26 Jan 2006 20:54:00 +0000 |
parents | 9d562dde0a3a |
children | 3e27ed592e02 |
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 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
119 wb = 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 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
196 wb = 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 |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
257 gaim_debug_info("yahoo", "doodle: Got Draw (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
258 gaim_debug_info("yahoo", "doodle: Draw message: %s\n", message); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
259 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
260 account = gaim_connection_get_account(gc); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
261 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
262 /* Only handle this if local client requested Doodle session (else local |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
263 * client would have sent one) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
264 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
265 wb = gaim_whiteboard_get_session(account, from); |
11801
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 if(wb == NULL) |
11475 | 268 return; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
269 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
270 /* TODO Functionalize |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
271 * Convert drawing packet message to an integer list |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
272 */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
273 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
274 /* 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
|
275 if((message[0] != '\"') || (message[strlen(message) - 1] != '\"')) |
11475 | 276 return; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
277 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
278 /* Ignore the inital quotation mark. */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
279 message += 1; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
280 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
281 tokens = g_strsplit(message, ",", 0); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
282 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
283 /* Traverse and extract all integers divided by commas */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
284 for (i = 0; tokens[i] != NULL; i++) |
11475 | 285 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
286 int last = strlen(tokens[i]) - 1; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
287 if (tokens[i][last] == '"') |
11916 | 288 tokens[i][last] = '\0'; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
289 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
290 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
|
291 } |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
292 d_list = g_list_reverse(d_list); |
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 g_strfreev(tokens); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
295 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
296 yahoo_doodle_draw_stroke(wb, d_list); |
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 /* goodle_doodle_session_set_canvas_as_icon(ds); */ |
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 g_list_free(d_list); |
11475 | 301 } |
302 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
303 void yahoo_doodle_command_got_clear(GaimConnection *gc, const char *from) |
11475 | 304 { |
11514 | 305 GaimAccount *account; |
306 GaimWhiteboard *wb; | |
307 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
308 gaim_debug_info("yahoo", "doodle: Got Clear (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
309 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
310 account = gaim_connection_get_account(gc); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
311 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
312 /* Only handle this if local client requested Doodle session (else local |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
313 * client would have sent one) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
314 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
315 wb = gaim_whiteboard_get_session(account, from); |
11801
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 if(wb == NULL) |
11475 | 318 return; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
319 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
320 if(wb->state == DOODLE_STATE_ESTABLISHED) |
11475 | 321 { |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
322 /* TODO Ask user whether to save the image before clearing it */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
323 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
324 gaim_whiteboard_clear(wb); |
11475 | 325 } |
326 } | |
327 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
328 void |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
329 yahoo_doodle_command_got_extra(GaimConnection *gc, const char *from, const char *message) |
11475 | 330 { |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
331 gaim_debug_info("yahoo", "doodle: Got Extra (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
332 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
333 /* 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
|
334 * 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
|
335 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
336 yahoo_doodle_command_send_extra(gc, from, DOODLE_EXTRA_NONE); |
11475 | 337 } |
338 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
339 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
|
340 { |
11514 | 341 GaimAccount *account; |
342 GaimWhiteboard *wb; | |
343 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
344 gaim_debug_info("yahoo", "doodle: Got Confirm (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
345 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
346 /* Get the doodle session */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
347 account = gaim_connection_get_account(gc); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
348 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
349 /* Only handle this if local client requested Doodle session (else local |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
350 * client would have sent one) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
351 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
352 wb = gaim_whiteboard_get_session(account, from); |
11801
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 if(wb == NULL) |
11475 | 355 return; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
356 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
357 /* TODO Combine the following IF's? */ |
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 /* Check if we requested a doodle session */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
360 if(wb->state == DOODLE_STATE_REQUESTING) |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
361 { |
11475 | 362 wb->state = DOODLE_STATE_ESTABLISHED; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
363 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
364 gaim_whiteboard_start(wb); |
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 yahoo_doodle_command_send_confirm(gc, from); |
11475 | 367 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
368 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
369 /* Check if we accepted a request for a doodle session */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
370 if(wb->state == DOODLE_STATE_REQUESTED) |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
371 { |
11475 | 372 wb->state = DOODLE_STATE_ESTABLISHED; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
373 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
374 gaim_whiteboard_start(wb); |
11475 | 375 } |
376 } | |
377 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
378 void yahoo_doodle_command_got_shutdown(GaimConnection *gc, const char *from) |
11475 | 379 { |
11514 | 380 GaimAccount *account; |
381 GaimWhiteboard *wb; | |
382 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
383 gaim_debug_info("yahoo", "doodle: Got Shutdown (%s)\n", from); |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
384 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
385 account = gaim_connection_get_account(gc); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
386 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
387 /* Only handle this if local client requested Doodle session (else local |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
388 * client would have sent one) |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
389 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
390 wb = gaim_whiteboard_get_session(account, from); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
391 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
392 /* 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
|
393 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
394 /* 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
|
395 if(wb == NULL) |
11475 | 396 return; |
397 else | |
398 { | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
399 gaim_whiteboard_destroy(wb); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
400 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
401 /* yahoo_doodle_command_send_shutdown(gc, from); */ |
11475 | 402 } |
403 } | |
404 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
405 static void yahoo_doodle_command_send_generic(const char *type, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
406 GaimConnection *gc, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
407 const char *to, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
408 const char *message, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
409 const char *thirteen, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
410 const char *sixtythree, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
411 const char *sixtyfour) |
11475 | 412 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
413 struct yahoo_data *yd; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
414 struct yahoo_packet *pkt; |
11514 | 415 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
416 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
|
417 |
11475 | 418 yd = gc->proto_data; |
419 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
420 /* Make and send an acknowledge (ready) Doodle packet */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
421 pkt = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
422 yahoo_packet_hash_str(pkt, 49, "IMVIRONMENT"); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
423 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
|
424 yahoo_packet_hash_str(pkt, 14, message); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
425 yahoo_packet_hash_str(pkt, 13, thirteen); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
426 yahoo_packet_hash_str(pkt, 5, to); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
427 yahoo_packet_hash_str(pkt, 63, sixtythree ? sixtythree : "doodle;11"); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
428 yahoo_packet_hash_str(pkt, 64, sixtyfour); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
429 yahoo_packet_hash_str(pkt, 1002, "1"); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
430 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
431 yahoo_packet_send_and_free(pkt, yd); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
432 } |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
433 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
434 void yahoo_doodle_command_send_request(GaimConnection *gc, const char *to) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
435 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
436 yahoo_doodle_command_send_generic("Request", gc, to, "1", "1", NULL, "1"); |
11475 | 437 } |
438 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
439 void yahoo_doodle_command_send_ready(GaimConnection *gc, const char *to) |
11475 | 440 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
441 yahoo_doodle_command_send_generic("Ready", gc, to, "", "0", NULL, "0"); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
442 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
443 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
444 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
|
445 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
446 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
|
447 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
448 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
449 void yahoo_doodle_command_send_clear(GaimConnection *gc, const char *to) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
450 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
451 yahoo_doodle_command_send_generic("Clear", gc, to, " ", "2", NULL, "1"); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
452 } |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
453 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
454 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
|
455 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
456 yahoo_doodle_command_send_generic("Extra", gc, to, message, "4", NULL, "1"); |
11475 | 457 } |
458 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
459 void yahoo_doodle_command_send_confirm(GaimConnection *gc, const char *to) |
11475 | 460 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
461 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
|
462 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
463 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
464 void yahoo_doodle_command_send_shutdown(GaimConnection *gc, const char *to) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
465 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
466 yahoo_doodle_command_send_generic("Shutdown", gc, to, "", "0", ";0", "0"); |
11475 | 467 } |
468 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
469 void yahoo_doodle_start(GaimWhiteboard *wb) |
11475 | 470 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
471 doodle_session *ds = g_new0(doodle_session, 1); |
11514 | 472 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
473 /* gaim_debug_debug("yahoo", "doodle: yahoo_doodle_start()\n"); */ |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
474 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
475 /* Set default brush size and color */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
476 ds->brush_size = DOODLE_BRUSH_SMALL; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
477 ds->brush_color = DOODLE_COLOR_RED; |
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 wb->proto_data = ds; |
11475 | 480 } |
481 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
482 void yahoo_doodle_end(GaimWhiteboard *wb) |
11475 | 483 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
484 GaimConnection *gc = gaim_account_get_connection(wb->account); |
11514 | 485 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
486 /* g_debug_debug("yahoo", "doodle: yahoo_doodle_end()\n"); */ |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
487 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
488 yahoo_doodle_command_send_shutdown(gc, wb->who); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
489 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
490 g_free(wb->proto_data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
491 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
492 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
493 void yahoo_doodle_get_dimensions(GaimWhiteboard *wb, int *width, int *height) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
494 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
495 /* standard Doodle canvases are of one size: 368x256 */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
496 *width = DOODLE_CANVAS_WIDTH; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
497 *height = DOODLE_CANVAS_HEIGHT; |
11475 | 498 } |
499 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
500 static char *yahoo_doodle_build_draw_string(doodle_session *ds, GList *draw_list) |
11475 | 501 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
502 GString *message; |
11514 | 503 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
504 g_return_val_if_fail(draw_list != NULL, NULL); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
505 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
506 message = g_string_new(""); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
507 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
|
508 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
509 for(; draw_list != NULL; draw_list = draw_list->next) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
510 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
511 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
|
512 } |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
513 g_string_append_c(message, '"'); |
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 return g_string_free(message, FALSE); |
11475 | 516 } |
517 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
518 void yahoo_doodle_send_draw_list(GaimWhiteboard *wb, GList *draw_list) |
11475 | 519 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
520 doodle_session *ds = wb->proto_data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
521 char *message; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
522 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
523 g_return_if_fail(draw_list != NULL); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
524 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
525 message = yahoo_doodle_build_draw_string(ds, draw_list); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
526 yahoo_doodle_command_send_draw(wb->account->gc, wb->who, message); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
527 g_free(message); |
11475 | 528 } |
529 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
530 void yahoo_doodle_clear(GaimWhiteboard *wb) |
11475 | 531 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
532 yahoo_doodle_command_send_clear(wb->account->gc, wb->who); |
11475 | 533 } |
534 | |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
535 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
536 /* Traverse through the list and draw the points and lines */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
537 void yahoo_doodle_draw_stroke(GaimWhiteboard *wb, GList *draw_list) |
11475 | 538 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
539 int brush_color; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
540 int brush_size; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
541 int x; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
542 int y; |
11475 | 543 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
544 g_return_if_fail(draw_list != NULL); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
545 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
546 brush_color = GPOINTER_TO_INT(draw_list->data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
547 draw_list = draw_list->next; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
548 g_return_if_fail(draw_list != NULL); |
11475 | 549 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
550 brush_size = 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 x = 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); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
557 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
558 y = 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 |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
562 /* |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
563 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
|
564 */ |
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
565 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
566 while(draw_list != NULL && draw_list->next != NULL) |
11475 | 567 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
568 int dx = GPOINTER_TO_INT(draw_list->data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
569 int dy = GPOINTER_TO_INT(draw_list->next->data); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
570 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
571 gaim_whiteboard_draw_line(wb, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
572 x, y, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
573 x + dx, y + dy, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
574 brush_color, brush_size); |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
575 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
576 x += dx; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
577 y += dy; |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
578 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
579 draw_list = draw_list->next->next; |
11475 | 580 } |
581 } | |
582 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
583 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
|
584 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
585 doodle_session *ds = (doodle_session *)wb->proto_data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
586 *size = ds->brush_size; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
587 *color = ds->brush_color; |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11916
diff
changeset
|
588 } |
11801
81806e9241be
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
589 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
590 void yahoo_doodle_set_brush(GaimWhiteboard *wb, int size, int color) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
591 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
592 doodle_session *ds = (doodle_session *)wb->proto_data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
593 ds->brush_size = size; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11801
diff
changeset
|
594 ds->brush_color = color; |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11916
diff
changeset
|
595 |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11916
diff
changeset
|
596 /* Notify the core about the changes */ |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11916
diff
changeset
|
597 gaim_whiteboard_set_brush(wb, size, color); |
11475 | 598 } |
599 |