Sun, 11 Sep 2005 16:36:45 +0000
[gaim-migrate @ 13759]
An insane amount of C99 fixes
| 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 | ||
| 24 | // INCLUDES ============================================================================================ | |
| 25 | ||
| 26 | #include "internal.h" | |
| 27 | ||
| 28 | #include "account.h" | |
| 29 | #include "accountopt.h" | |
| 30 | #include "blist.h" | |
| 31 | #include "cipher.h" | |
| 32 | #include "cmds.h" | |
| 33 | #include "debug.h" | |
| 34 | #include "notify.h" | |
| 35 | #include "privacy.h" | |
| 36 | #include "prpl.h" | |
| 37 | #include "proxy.h" | |
| 38 | #include "request.h" | |
| 39 | #include "server.h" | |
| 40 | #include "util.h" | |
| 41 | #include "version.h" | |
| 42 | ||
| 43 | #include "yahoo.h" | |
| 44 | #include "yahoo_packet.h" | |
| 45 | #include "yahoo_friend.h" | |
| 46 | #include "yahoochat.h" | |
| 47 | #include "ycht.h" | |
| 48 | #include "yahoo_auth.h" | |
| 49 | #include "yahoo_filexfer.h" | |
| 50 | #include "yahoo_picture.h" | |
| 51 | ||
| 52 | #include "whiteboard.h" | |
| 53 | #include "yahoo_doodle.h" | |
| 54 | ||
| 55 | // GLOBALS ============================================================================================= | |
| 56 | ||
| 57 | const int DefaultColorRGB24[] = | |
| 58 | { | |
| 59 | DOODLE_COLOR_RED, | |
| 60 | DOODLE_COLOR_ORANGE, | |
| 61 | DOODLE_COLOR_YELLOW, | |
| 62 | DOODLE_COLOR_GREEN, | |
| 63 | DOODLE_COLOR_CYAN, | |
| 64 | DOODLE_COLOR_BLUE, | |
| 65 | DOODLE_COLOR_VIOLET, | |
| 66 | DOODLE_COLOR_PURPLE, | |
| 67 | DOODLE_COLOR_TAN, | |
| 68 | DOODLE_COLOR_BROWN, | |
| 69 | DOODLE_COLOR_BLACK, | |
| 70 | DOODLE_COLOR_GREY, | |
| 71 | DOODLE_COLOR_WHITE | |
| 72 | }; | |
| 73 | ||
| 74 | // FUNCTIONS ============================================================================================ | |
| 75 | ||
| 76 | GaimCmdRet yahoo_doodle_gaim_cmd_start( GaimConversation *conv, const char *cmd, char **args, char **error, void *data ) | |
| 77 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
78 | GaimAccount *account; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
79 | GaimConnection *gc; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
80 | char *to; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
81 | GaimWhiteboard *wb; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
82 | |
| 11475 | 83 | if( *args && args[0] ) |
| 84 | return( GAIM_CMD_RET_FAILED ); | |
| 85 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
86 | account = gaim_conversation_get_account( conv ); |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
87 | gc = gaim_account_get_connection( account ); |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
88 | to = ( char* )( gaim_conversation_get_name( conv ) ); |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
89 | wb = gaim_whiteboard_get_session( account, to ); |
| 11475 | 90 | |
| 91 | // NOTE Functionalize this code? | |
| 92 | ||
| 93 | if( wb == NULL ) | |
| 94 | { | |
| 95 | // Insert this 'session' in the list. At this point, it's only a requested session. | |
| 96 | wb = gaim_whiteboard_create( account, to, DOODLE_STATE_REQUESTING ); | |
| 97 | } | |
| 98 | //else | |
| 99 | // ; // NOTE Perhaps some careful handling of remote assumed established sessions | |
| 100 | ||
| 101 | yahoo_doodle_command_send_request( gc, to ); | |
| 102 | yahoo_doodle_command_send_ready( gc, to ); | |
| 103 | ||
| 104 | // Write a local message to this conversation showing that | |
| 105 | // a request for a Doodle session has been made | |
| 106 | gaim_conv_im_write( GAIM_CONV_IM( conv ), "", _("Sent Doodle request."), | |
| 107 | GAIM_MESSAGE_NICK | GAIM_MESSAGE_RECV, time( NULL ) ); | |
| 108 | ||
| 109 | return( GAIM_CMD_RET_OK ); | |
| 110 | } | |
| 111 | ||
| 112 | // ------------------------------------------------------------------------------------------------------ | |
| 113 | ||
| 114 | void yahoo_doodle_process( GaimConnection *gc, char *me, char *from, char *command, char *message ) | |
| 115 | { | |
| 116 | // g_print( "-----------------------------------------------\n" ); | |
| 117 | // g_print( "%s : %s : %s -> %s\n", from, imv, command, message ); | |
| 118 | ||
| 119 | // Now check to see what sort of Doodle message it is | |
| 120 | int cmd = atoi( command ); | |
| 121 | ||
| 122 | switch( cmd ) | |
| 123 | { | |
| 124 | case DOODLE_CMD_REQUEST: | |
| 125 | { | |
| 126 | yahoo_doodle_command_got_request( gc, from ); | |
| 127 | } break; | |
| 128 | ||
| 129 | case DOODLE_CMD_READY: | |
| 130 | { | |
| 131 | yahoo_doodle_command_got_ready( gc, from ); | |
| 132 | } break; | |
| 133 | ||
| 134 | case DOODLE_CMD_CLEAR: | |
| 135 | { | |
| 136 | yahoo_doodle_command_got_clear( gc, from ); | |
| 137 | } break; | |
| 138 | ||
| 139 | case DOODLE_CMD_DRAW: | |
| 140 | { | |
| 141 | yahoo_doodle_command_got_draw( gc, from, message ); | |
| 142 | } break; | |
| 143 | ||
| 144 | case DOODLE_CMD_EXTRA: | |
| 145 | { | |
| 146 | yahoo_doodle_command_got_extra( gc, from, message ); | |
| 147 | } break; | |
| 148 | ||
| 149 | case DOODLE_CMD_CONFIRM: | |
| 150 | { | |
| 151 | yahoo_doodle_command_got_confirm( gc, from ); | |
| 152 | } break; | |
| 153 | } | |
| 154 | } | |
| 155 | ||
| 156 | // ------------------------------------------------------------------------------------------------------ | |
| 157 | ||
| 158 | void yahoo_doodle_command_got_request( GaimConnection *gc, char *from ) | |
| 159 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
160 | GaimAccount *account; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
161 | GaimWhiteboard *wb; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
162 | |
| 11475 | 163 | g_print( "-----------------------------------------------\n" ); |
| 164 | g_print( "Got REQUEST (%s)\n", from ); | |
| 165 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
166 | account = gaim_connection_get_account( gc ); |
| 11475 | 167 | |
| 168 | // Only handle this if local client requested Doodle session (else local client would have sent one) | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
169 | wb = gaim_whiteboard_get_session( account, from ); |
| 11475 | 170 | |
| 171 | // If a session with the remote user doesn't exist | |
| 172 | if( wb == NULL ) | |
| 173 | { | |
| 174 | // Ask user if he/she wishes to accept the request for a doodle session | |
| 175 | // TODO Ask local user to start Doodle session with remote user | |
| 176 | // NOTE This if/else statement won't work right--must use dialog results | |
| 177 | ||
| 178 | /* char dialog_message[64]; | |
| 179 | g_sprintf( dialog_message, "%s is requesting to start a Doodle session with you.", from ); | |
| 180 | ||
| 181 | gaim_notify_message( NULL, GAIM_NOTIFY_MSG_INFO, "Doodle", | |
| 182 | dialog_message, NULL, NULL, NULL ); | |
| 183 | */ | |
| 184 | ||
| 185 | wb = gaim_whiteboard_create( account, from, DOODLE_STATE_REQUESTED ); | |
| 186 | ||
| 187 | yahoo_doodle_command_send_request( gc, from ); | |
| 188 | } | |
| 189 | ||
| 190 | // TODO Might be required to clear the canvas of an existing doodle session at this point | |
| 191 | } | |
| 192 | ||
| 193 | // ------------------------------------------------------------------------------------------------------ | |
| 194 | ||
| 195 | void yahoo_doodle_command_got_ready( GaimConnection *gc, char *from ) | |
| 196 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
197 | GaimAccount *account; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
198 | GaimWhiteboard *wb; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
199 | |
| 11475 | 200 | g_print( "-----------------------------------------------\n" ); |
| 201 | g_print( "Got READY (%s)\n", from ); | |
| 202 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
203 | account = gaim_connection_get_account( gc ); |
| 11475 | 204 | |
| 205 | // Only handle this if local client requested Doodle session (else local client would have sent one) | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
206 | wb = gaim_whiteboard_get_session( account, from ); |
| 11475 | 207 | |
| 208 | if( wb == NULL ) | |
| 209 | return; | |
| 210 | ||
| 211 | if( wb->state == DOODLE_STATE_REQUESTING ) | |
| 212 | { | |
| 213 | gaim_whiteboard_start( wb ); | |
| 214 | ||
| 215 | wb->state = DOODLE_STATE_ESTABLISHED; | |
| 216 | ||
| 217 | yahoo_doodle_command_send_confirm( gc, from ); | |
| 218 | } | |
| 219 | ||
| 220 | if( wb->state == DOODLE_STATE_ESTABLISHED ) | |
| 221 | { | |
| 222 | // Ask whether to save picture too | |
| 223 | ||
| 224 | gaim_whiteboard_clear( wb ); | |
| 225 | } | |
| 226 | ||
| 227 | // NOTE Not sure about this... I am trying to handle if the remote user already | |
| 228 | // thinks we're in a session with them (when their chat message contains the doodle;11 imv key) | |
| 229 | if( wb->state == DOODLE_STATE_REQUESTED ) | |
| 230 | { | |
| 231 | g_print( "Hmmmm\n" ); | |
| 232 | ||
| 233 | //gaim_whiteboard_start( wb ); | |
| 234 | yahoo_doodle_command_send_request( gc, from ); | |
| 235 | } | |
| 236 | } | |
| 237 | ||
| 238 | // ------------------------------------------------------------------------------------------------------ | |
| 239 | ||
| 240 | void yahoo_doodle_command_got_draw( GaimConnection *gc, char *from, char *message ) | |
| 241 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
242 | GaimAccount *account; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
243 | GaimWhiteboard *wb; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
244 | int *token; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
245 | int length; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
246 | char *token_end; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
247 | GList *d_list; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
248 | int *n; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
249 | GList *l; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
250 | |
| 11475 | 251 | g_print( "-----------------------------------------------\n" ); |
| 252 | g_print( "Got DRAW (%s)\n", from ); | |
| 253 | ||
| 254 | g_print( "Draw Message: %s\n", message ); | |
| 255 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
256 | account = gaim_connection_get_account( gc ); |
| 11475 | 257 | |
| 258 | // Only handle this if local client requested Doodle session (else local client would have sent one) | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
259 | wb = gaim_whiteboard_get_session( account, from ); |
| 11475 | 260 | |
| 261 | if( wb == NULL ) | |
| 262 | return; | |
| 263 | ||
| 264 | // TODO Functionalize | |
| 265 | // Convert drawing packet message to an integer list | |
| 266 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
267 | token = NULL; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
268 | length = strlen( message ); |
| 11475 | 269 | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
270 | d_list = NULL; // a local list of drawing info |
| 11475 | 271 | |
| 272 | // Check to see if the message begans and ends with quotes | |
| 273 | if( ( message[0] != '\"' ) || ( message[length - 1] != '\"' ) ) | |
| 274 | return; | |
| 275 | ||
| 276 | // Truncate the quotations off of our message (why the hell did they add them anyways!?) | |
| 277 | message[length - 1] = ','; | |
| 278 | message = message + 1; | |
| 279 | ||
| 280 | // Traverse and extract all integers divided by commas | |
| 281 | while( ( token_end = strchr( message, ',' ) ) ) | |
| 282 | { | |
| 283 | token_end[0] = 0; | |
| 284 | ||
| 285 | token = g_new0( int, 1 ); | |
| 286 | ||
| 287 | *token = atoi( message ); | |
| 288 | ||
| 289 | d_list = g_list_append( d_list, ( gpointer )( token ) ); | |
| 290 | ||
| 291 | message = token_end + 1; | |
| 292 | } | |
| 293 | ||
| 294 | yahoo_doodle_draw_stroke( wb, d_list ); | |
| 295 | ||
| 296 | //goodle_doodle_session_set_canvas_as_icon( ds ); | |
| 297 | ||
| 298 | // Remove that shit | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
299 | n = NULL; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
300 | l = d_list; |
| 11475 | 301 | while( l ) |
| 302 | { | |
| 303 | n = l->data; | |
| 304 | ||
| 305 | g_free( n ); | |
| 306 | ||
| 307 | l = l->next; | |
| 308 | } | |
| 309 | ||
| 310 | g_list_free( d_list ); | |
| 311 | d_list = NULL; | |
| 312 | } | |
| 313 | ||
| 314 | // ------------------------------------------------------------------------------------------------------ | |
| 315 | ||
| 316 | void yahoo_doodle_command_got_clear( GaimConnection *gc, char *from ) | |
| 317 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
318 | GaimAccount *account; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
319 | GaimWhiteboard *wb; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
320 | |
| 11475 | 321 | g_print( "-----------------------------------------------\n" ); |
| 322 | g_print( "Got CLEAR (%s)\n", from ); | |
| 323 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
324 | account = gaim_connection_get_account( gc ); |
| 11475 | 325 | |
| 326 | // Only handle this if local client requested Doodle session (else local client would have sent one) | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
327 | wb = gaim_whiteboard_get_session( account, from ); |
| 11475 | 328 | |
| 329 | if( wb == NULL ) | |
| 330 | return; | |
| 331 | ||
| 332 | if( wb->state == DOODLE_STATE_ESTABLISHED ) | |
| 333 | { | |
| 334 | // TODO Ask user whether to save the image before clearing it | |
| 335 | ||
| 336 | gaim_whiteboard_clear( wb ); | |
| 337 | } | |
| 338 | } | |
| 339 | ||
| 340 | // ------------------------------------------------------------------------------------------------------ | |
| 341 | ||
| 342 | void yahoo_doodle_command_got_extra( GaimConnection *gc, char *from, char *message ) | |
| 343 | { | |
| 344 | g_print( "-----------------------------------------------\n" ); | |
| 345 | g_print( "Got EXTRA (%s)\n", from ); | |
| 346 | ||
| 347 | // I do not like these 'extra' features, so I'll only handle them in one way, | |
| 348 | // which is returning them with the command/packet to turn them off | |
| 349 | ||
| 350 | yahoo_doodle_command_send_extra( gc, from, DOODLE_EXTRA_NONE ); | |
| 351 | } | |
| 352 | ||
| 353 | // ------------------------------------------------------------------------------------------------------ | |
| 354 | ||
| 355 | void yahoo_doodle_command_got_confirm( GaimConnection *gc, char *from ) | |
| 356 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
357 | GaimAccount *account; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
358 | GaimWhiteboard *wb; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
359 | |
| 11475 | 360 | g_print( "-----------------------------------------------\n" ); |
| 361 | g_print( "Got CONFIRM (%s)\n", from ); | |
| 362 | ||
| 363 | // Get the doodle session | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
364 | account = gaim_connection_get_account( gc ); |
| 11475 | 365 | |
| 366 | // Only handle this if local client requested Doodle session (else local client would have sent one) | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
367 | wb = gaim_whiteboard_get_session( account, from ); |
| 11475 | 368 | |
| 369 | if( wb == NULL ) | |
| 370 | return; | |
| 371 | ||
| 372 | // TODO Combine the following IF's? | |
| 373 | ||
| 374 | // Check if we requested a doodle session | |
| 375 | if( wb->state == DOODLE_STATE_REQUESTING ) | |
| 376 | { | |
| 377 | wb->state = DOODLE_STATE_ESTABLISHED; | |
| 378 | ||
| 379 | gaim_whiteboard_start( wb ); | |
| 380 | ||
| 381 | yahoo_doodle_command_send_confirm( gc, from ); | |
| 382 | } | |
| 383 | ||
| 384 | // Check if we accepted a request for a doodle session | |
| 385 | if( wb->state == DOODLE_STATE_REQUESTED ) | |
| 386 | { | |
| 387 | wb->state = DOODLE_STATE_ESTABLISHED; | |
| 388 | ||
| 389 | gaim_whiteboard_start( wb ); | |
| 390 | } | |
| 391 | } | |
| 392 | ||
| 393 | // ------------------------------------------------------------------------------------------------------ | |
| 394 | ||
| 395 | void yahoo_doodle_command_got_shutdown( GaimConnection *gc, char *from ) | |
| 396 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
397 | GaimAccount *account; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
398 | GaimWhiteboard *wb; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
399 | |
| 11475 | 400 | g_print( "-----------------------------------------------\n" ); |
| 401 | g_print( "Got SHUTDOWN (%s)\n", from ); | |
| 402 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
403 | account = gaim_connection_get_account( gc ); |
| 11475 | 404 | |
| 405 | // Only handle this if local client requested Doodle session (else local client would have sent one) | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
406 | wb = gaim_whiteboard_get_session( account, from ); |
| 11475 | 407 | |
| 408 | // TODO Ask if user wants to save picture before the session is closed | |
| 409 | ||
| 410 | // If this session doesn't exist, don't try and kill it | |
| 411 | if( wb == NULL ) | |
| 412 | return; | |
| 413 | else | |
| 414 | { | |
| 415 | gaim_whiteboard_destroy( wb ); | |
| 416 | ||
| 417 | //yahoo_doodle_command_send_shutdown( gc, from ); | |
| 418 | } | |
| 419 | } | |
| 420 | ||
| 421 | // ------------------------------------------------------------------------------------------------------ | |
| 422 | ||
| 423 | void yahoo_doodle_command_send_request( GaimConnection *gc, char *to ) | |
| 424 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
425 | struct yahoo_data *yd; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
426 | struct yahoo_packet *pkt; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
427 | |
| 11475 | 428 | g_print( "-----------------------------------------------\n" ); |
| 429 | g_print( "Sent REQUEST (%s)\n", to ); | |
| 430 | ||
| 431 | yd = gc->proto_data; | |
| 432 | ||
| 433 | // Make and send an acknowledge (ready) Doodle packet | |
| 434 | pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | |
| 435 | yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | |
| 436 | yahoo_packet_hash_str( pkt, 1, gaim_account_get_username( gc->account ) ); | |
| 437 | yahoo_packet_hash_str( pkt, 14, "1" ); | |
| 438 | yahoo_packet_hash_str( pkt, 13, "1" ); | |
| 439 | yahoo_packet_hash_str( pkt, 5, to ); | |
| 440 | yahoo_packet_hash_str( pkt, 63, "doodle;11" ); | |
| 441 | yahoo_packet_hash_str( pkt, 64, "1" ); | |
| 442 | yahoo_packet_hash_str( pkt, 1002, "1" ); | |
| 443 | ||
| 444 | yahoo_packet_send_and_free( pkt, yd ); | |
| 445 | } | |
| 446 | ||
| 447 | // ------------------------------------------------------------------------------------------------------ | |
| 448 | ||
| 449 | void yahoo_doodle_command_send_ready( GaimConnection *gc, char *to ) | |
| 450 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
451 | struct yahoo_data *yd; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
452 | struct yahoo_packet *pkt; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
453 | |
| 11475 | 454 | g_print( "-----------------------------------------------\n" ); |
| 455 | g_print( "Sent READY (%s)\n", to ); | |
| 456 | ||
| 457 | yd = gc->proto_data; | |
| 458 | ||
| 459 | // Make and send a request to start a Doodle session | |
| 460 | pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | |
| 461 | yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | |
| 462 | yahoo_packet_hash_str( pkt, 1, gaim_account_get_username( gc->account ) ); | |
| 463 | yahoo_packet_hash_str( pkt, 14, "" ); | |
| 464 | yahoo_packet_hash_str( pkt, 13, "0" ); | |
| 465 | yahoo_packet_hash_str( pkt, 5, to ); | |
| 466 | yahoo_packet_hash_str( pkt, 63, "doodle;11" ); | |
| 467 | yahoo_packet_hash_str( pkt, 64, "0" ); | |
| 468 | yahoo_packet_hash_str( pkt, 1002, "1" ); | |
| 469 | ||
| 470 | yahoo_packet_send_and_free( pkt, yd ); | |
| 471 | } | |
| 472 | ||
| 473 | // ------------------------------------------------------------------------------------------------------ | |
| 474 | ||
| 475 | void yahoo_doodle_command_send_draw( GaimConnection *gc, char *to, char *message ) | |
| 476 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
477 | struct yahoo_data *yd; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
478 | struct yahoo_packet *pkt; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
479 | |
| 11475 | 480 | g_print( "-----------------------------------------------\n" ); |
| 481 | g_print( "Sent DRAW (%s)\n", to ); | |
| 482 | ||
| 483 | yd = gc->proto_data; | |
| 484 | ||
| 485 | // Make and send a drawing packet | |
| 486 | pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | |
| 487 | yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | |
| 488 | yahoo_packet_hash_str( pkt, 1, gaim_account_get_username( gc->account ) ); | |
| 489 | yahoo_packet_hash_str( pkt, 14, message ); | |
| 490 | yahoo_packet_hash_str( pkt, 13, "3" ); | |
| 491 | yahoo_packet_hash_str( pkt, 5, to ); | |
| 492 | yahoo_packet_hash_str( pkt, 63, "doodle;11" ); | |
| 493 | yahoo_packet_hash_str( pkt, 64, "1" ); | |
| 494 | yahoo_packet_hash_str( pkt, 1002, "1" ); | |
| 495 | ||
| 496 | yahoo_packet_send_and_free( pkt, yd ); | |
| 497 | } | |
| 498 | ||
| 499 | // ------------------------------------------------------------------------------------------------------ | |
| 500 | ||
| 501 | void yahoo_doodle_command_send_clear( GaimConnection *gc, char *to ) | |
| 502 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
503 | struct yahoo_data *yd; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
504 | struct yahoo_packet *pkt; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
505 | |
| 11475 | 506 | g_print( "-----------------------------------------------\n" ); |
| 507 | g_print( "Sent CLEAR (%s)\n", to ); | |
| 508 | ||
| 509 | yd = gc->proto_data; | |
| 510 | ||
| 511 | // Make and send a request to clear packet | |
| 512 | pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | |
| 513 | yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | |
| 514 | yahoo_packet_hash_str( pkt, 1, gaim_account_get_username( gc->account ) ); | |
| 515 | yahoo_packet_hash_str( pkt, 14, " " ); | |
| 516 | yahoo_packet_hash_str( pkt, 13, "2" ); | |
| 517 | yahoo_packet_hash_str( pkt, 5, to ); | |
| 518 | yahoo_packet_hash_str( pkt, 63, "doodle;11" ); | |
| 519 | yahoo_packet_hash_str( pkt, 64, "1" ); | |
| 520 | yahoo_packet_hash_str( pkt, 1002, "1" ); | |
| 521 | ||
| 522 | yahoo_packet_send_and_free( pkt, yd ); | |
| 523 | } | |
| 524 | ||
| 525 | // ------------------------------------------------------------------------------------------------------ | |
| 526 | ||
| 527 | void yahoo_doodle_command_send_extra( GaimConnection *gc, char *to, char *message ) | |
| 528 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
529 | struct yahoo_data *yd; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
530 | struct yahoo_packet *pkt; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
531 | |
| 11475 | 532 | g_print( "-----------------------------------------------\n" ); |
| 533 | g_print( "Sent EXTRA (%s)\n", to ); | |
| 534 | ||
| 535 | yd = gc->proto_data; | |
| 536 | ||
| 537 | // Send out a request to use a specified 'extra' feature (message) | |
| 538 | pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | |
| 539 | yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | |
| 540 | yahoo_packet_hash_str( pkt, 1, gaim_account_get_username( gc->account ) ); | |
| 541 | yahoo_packet_hash_str( pkt, 14, message ); | |
| 542 | yahoo_packet_hash_str( pkt, 13, "4" ); | |
| 543 | yahoo_packet_hash_str( pkt, 5, to ); | |
| 544 | yahoo_packet_hash_str( pkt, 63, "doodle;11" ); | |
| 545 | yahoo_packet_hash_str( pkt, 64, "1" ); | |
| 546 | yahoo_packet_hash_str( pkt, 1002, "1" ); | |
| 547 | ||
| 548 | yahoo_packet_send_and_free( pkt, yd ); | |
| 549 | } | |
| 550 | ||
| 551 | // ------------------------------------------------------------------------------------------------------ | |
| 552 | ||
| 553 | void yahoo_doodle_command_send_confirm( GaimConnection *gc, char *to ) | |
| 554 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
555 | struct yahoo_data *yd; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
556 | struct yahoo_packet *pkt; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
557 | |
| 11475 | 558 | g_print( "-----------------------------------------------\n" ); |
| 559 | g_print( "Sent CONFIRM (%s)\n", to ); | |
| 560 | ||
| 561 | yd = gc->proto_data; | |
| 562 | ||
| 563 | // Send ready packet (that local client accepted and is ready) | |
| 564 | pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | |
| 565 | yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | |
| 566 | yahoo_packet_hash_str( pkt, 1, ( char* )( gaim_account_get_username( gc->account ) ) ); | |
| 567 | yahoo_packet_hash_str( pkt, 14, "1" ); | |
| 568 | yahoo_packet_hash_str( pkt, 13, "5" ); | |
| 569 | yahoo_packet_hash_str( pkt, 5, to ); | |
| 570 | yahoo_packet_hash_str( pkt, 63, "doodle;11" ); | |
| 571 | yahoo_packet_hash_str( pkt, 64, "1" ); | |
| 572 | yahoo_packet_hash_str( pkt, 1002, "1" ); | |
| 573 | ||
| 574 | yahoo_packet_send_and_free( pkt, yd ); | |
| 575 | } | |
| 576 | ||
| 577 | // ------------------------------------------------------------------------------------------------------ | |
| 578 | ||
| 579 | void yahoo_doodle_command_send_shutdown( GaimConnection *gc, char *to ) | |
| 580 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
581 | struct yahoo_data *yd; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
582 | struct yahoo_packet *pkt; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
583 | |
| 11475 | 584 | g_print( "-----------------------------------------------\n" ); |
| 585 | g_print( "Sent SHUTDOWN (%s)\n", to ); | |
| 586 | ||
| 587 | yd = gc->proto_data; | |
| 588 | ||
| 589 | // Declare that you are ending the Doodle session | |
| 590 | pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | |
| 591 | yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | |
| 592 | yahoo_packet_hash_str( pkt, 1, gaim_account_get_username( gc->account ) ); | |
| 593 | yahoo_packet_hash_str( pkt, 14, "" ); | |
| 594 | yahoo_packet_hash_str( pkt, 13, "0" ); | |
| 595 | yahoo_packet_hash_str( pkt, 5, to ); | |
| 596 | yahoo_packet_hash_str( pkt, 63, ";0" ); | |
| 597 | yahoo_packet_hash_str( pkt, 64, "0" ); | |
| 598 | yahoo_packet_hash_str( pkt, 1002, "1" ); | |
| 599 | ||
| 600 | yahoo_packet_send_and_free( pkt, yd ); | |
| 601 | } | |
| 602 | ||
| 603 | // ------------------------------------------------------------------------------------------------------ | |
| 604 | ||
| 605 | void yahoo_doodle_start( GaimWhiteboard *wb ) | |
| 606 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
607 | doodle_session *ds = g_new0( doodle_session, 1 ); |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
608 | |
| 11475 | 609 | //g_print( "yahoo_doodle_start()\n" ); |
| 610 | ||
| 611 | // Set default brush size and color | |
| 612 | ds->brush_size = DOODLE_BRUSH_MEDIUM; | |
| 613 | ds->brush_color = 0; // black | |
| 614 | ||
| 615 | wb->proto_data = ds; | |
| 616 | } | |
| 617 | ||
| 618 | // ------------------------------------------------------------------------------------------------------ | |
| 619 | ||
| 620 | void yahoo_doodle_end( GaimWhiteboard *wb ) | |
| 621 | { | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
622 | GaimConnection *gc = gaim_account_get_connection( wb->account ); |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
623 | doodle_session *ds; |
| 11475 | 624 | |
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
625 | //g_print( "yahoo_doodle_end()\n" ); |
| 11475 | 626 | |
| 627 | yahoo_doodle_command_send_shutdown( gc, wb->who ); | |
| 628 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
629 | ds = wb->proto_data; |
| 11475 | 630 | if( ds ) |
| 631 | g_free( ds ); | |
| 632 | } | |
| 633 | ||
| 634 | // ------------------------------------------------------------------------------------------------------ | |
| 635 | ||
| 636 | void yahoo_doodle_get_dimensions( GaimWhiteboard *wb, int *width, int *height ) | |
| 637 | { | |
| 638 | // Standard Doodle canvases are of one size: 368x256 | |
| 639 | *width = DOODLE_CANVAS_WIDTH; | |
| 640 | *height = DOODLE_CANVAS_HEIGHT; | |
| 641 | } | |
| 642 | ||
| 643 | // ------------------------------------------------------------------------------------------------------ | |
| 644 | ||
| 645 | void yahoo_doodle_send_draw_list( GaimWhiteboard *wb, GList *draw_list ) | |
| 646 | { | |
| 647 | doodle_session *ds = wb->proto_data; | |
| 648 | char *message = yahoo_doodle_build_draw_string( ds, draw_list ); | |
| 649 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
650 | //g_print( "yahoo_doodle_send_draw_list()\n" ); |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
651 | |
| 11475 | 652 | if( message ) |
| 653 | yahoo_doodle_command_send_draw( wb->account->gc, wb->who, message ); | |
| 654 | ||
| 655 | } | |
| 656 | ||
| 657 | // ------------------------------------------------------------------------------------------------------ | |
| 658 | ||
| 659 | void yahoo_doodle_clear( GaimWhiteboard *wb ) | |
| 660 | { | |
| 661 | yahoo_doodle_command_send_clear( wb->account->gc, wb->who ); | |
| 662 | } | |
| 663 | ||
| 664 | // ------------------------------------------------------------------------------------------------------ | |
| 665 | ||
| 666 | void yahoo_doodle_draw_stroke( GaimWhiteboard *wb, GList *draw_list ) | |
| 667 | { | |
| 668 | // Traverse through the list and draw the points and lines | |
| 669 | ||
| 670 | GList *l = draw_list; | |
| 671 | ||
| 672 | int *n = NULL; | |
| 673 | ||
| 674 | int brush_color; | |
| 675 | int brush_size; | |
| 676 | int x; | |
| 677 | int y; | |
| 678 | ||
| 679 | int dx, dy; | |
| 680 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
681 | int count = 0; |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
682 | |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
683 | //g_print( "Drawing: color=%d, size=%d, (%d,%d)\n", brush_color, brush_size, x, y ); |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
684 | |
| 11475 | 685 | n = l->data; brush_color = *n; l = l->next; |
| 686 | n = l->data; brush_size = *n; l = l->next; | |
| 687 | n = l->data; x = *n; l = l->next; | |
| 688 | n = l->data; y = *n; l = l->next; | |
| 689 | ||
| 690 | // Pray this works and pray that the list has an even number of elements | |
| 691 | while( l ) | |
| 692 | { | |
| 693 | count++; | |
| 694 | ||
| 695 | n = l->data; dx = *n; l = l->next; | |
| 696 | n = l->data; dy = *n; l = l->next; | |
| 697 | ||
| 698 | gaim_whiteboard_draw_line( wb, | |
| 699 | x, y, | |
| 700 | x + dx, y + dy, | |
| 701 | brush_color, brush_size ); | |
| 702 | ||
| 703 | x = x + dx; | |
| 704 | y = y + dy; | |
| 705 | } | |
| 706 | ||
| 707 | //g_print( "Counted %d deltas\n", count ); | |
| 708 | } | |
| 709 | ||
| 710 | // ------------------------------------------------------------------------------------------------------ | |
| 711 | ||
| 712 | char *yahoo_doodle_build_draw_string( doodle_session *ds, GList *draw_list ) | |
| 713 | { | |
| 714 | //g_print( "yahoo_doodle_build_draw_string()\n" ); | |
| 715 | ||
| 716 | GList *l = draw_list; | |
| 717 | ||
| 718 | int *n = NULL; | |
| 719 | ||
| 720 | static char message[1024]; // Hope that 1024 is enough | |
| 721 | char token_string[16]; // Token string extracted from draw list | |
| 722 | ||
|
11514
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
723 | if( draw_list == NULL ) |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
724 | return( NULL ); |
|
6d39c652e8b8
[gaim-migrate @ 13759]
Mark Doliner <markdoliner@pidgin.im>
parents:
11475
diff
changeset
|
725 | |
| 11475 | 726 | strcpy( message, "\"" ); |
| 727 | ||
| 728 | sprintf( token_string, "%d,%d,", ds->brush_color, ds->brush_size ); | |
| 729 | strcat( message, token_string ); | |
| 730 | ||
| 731 | // Pray this works and pray that the list has an even number of elements | |
| 732 | while( l ) | |
| 733 | { | |
| 734 | n = l->data; | |
| 735 | ||
| 736 | sprintf( token_string, "%d,", *n ); | |
| 737 | ||
| 738 | // This check prevents overflow | |
| 739 | if( ( strlen( message ) + strlen( token_string ) ) < 1024 ) | |
| 740 | strcat( message, token_string ); | |
| 741 | else | |
| 742 | break; | |
| 743 | ||
| 744 | l = l->next; | |
| 745 | } | |
| 746 | ||
| 747 | message[strlen( message ) - 1] = '\"'; | |
| 748 | //message[strlen( message )] = 0; | |
| 749 | //message[511] = 0; | |
| 750 | ||
| 751 | //g_print( "Draw Message: %s\n", message ); | |
| 752 | ||
| 753 | return( message ); | |
| 754 | } | |
| 755 | ||
| 756 | // ------------------------------------------------------------------------------------------------------ | |
| 757 |