Mercurial > pidgin
comparison src/protocols/yahoo/yahoo_doodle.c @ 11514:4aa1de1f5545
[gaim-migrate @ 13759]
An insane amount of C99 fixes
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 11 Sep 2005 16:36:45 +0000 |
parents | 7fab28c991f3 |
children | 32bac0647037 |
comparison
equal
deleted
inserted
replaced
11513:c18bd02be106 | 11514:4aa1de1f5545 |
---|---|
73 | 73 |
74 // FUNCTIONS ============================================================================================ | 74 // FUNCTIONS ============================================================================================ |
75 | 75 |
76 GaimCmdRet yahoo_doodle_gaim_cmd_start( GaimConversation *conv, const char *cmd, char **args, char **error, void *data ) | 76 GaimCmdRet yahoo_doodle_gaim_cmd_start( GaimConversation *conv, const char *cmd, char **args, char **error, void *data ) |
77 { | 77 { |
78 GaimAccount *account; | |
79 GaimConnection *gc; | |
80 char *to; | |
81 GaimWhiteboard *wb; | |
82 | |
78 if( *args && args[0] ) | 83 if( *args && args[0] ) |
79 return( GAIM_CMD_RET_FAILED ); | 84 return( GAIM_CMD_RET_FAILED ); |
80 | 85 |
81 GaimAccount *account = gaim_conversation_get_account( conv ); | 86 account = gaim_conversation_get_account( conv ); |
82 GaimConnection *gc = gaim_account_get_connection( account ); | 87 gc = gaim_account_get_connection( account ); |
83 char *to = ( char* )( gaim_conversation_get_name( conv ) ); | 88 to = ( char* )( gaim_conversation_get_name( conv ) ); |
84 GaimWhiteboard *wb = gaim_whiteboard_get_session( account, to ); | 89 wb = gaim_whiteboard_get_session( account, to ); |
85 | 90 |
86 // NOTE Functionalize this code? | 91 // NOTE Functionalize this code? |
87 | 92 |
88 if( wb == NULL ) | 93 if( wb == NULL ) |
89 { | 94 { |
150 | 155 |
151 // ------------------------------------------------------------------------------------------------------ | 156 // ------------------------------------------------------------------------------------------------------ |
152 | 157 |
153 void yahoo_doodle_command_got_request( GaimConnection *gc, char *from ) | 158 void yahoo_doodle_command_got_request( GaimConnection *gc, char *from ) |
154 { | 159 { |
160 GaimAccount *account; | |
161 GaimWhiteboard *wb; | |
162 | |
155 g_print( "-----------------------------------------------\n" ); | 163 g_print( "-----------------------------------------------\n" ); |
156 g_print( "Got REQUEST (%s)\n", from ); | 164 g_print( "Got REQUEST (%s)\n", from ); |
157 | 165 |
158 GaimAccount *account = gaim_connection_get_account( gc ); | 166 account = gaim_connection_get_account( gc ); |
159 | 167 |
160 // Only handle this if local client requested Doodle session (else local client would have sent one) | 168 // Only handle this if local client requested Doodle session (else local client would have sent one) |
161 GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from ); | 169 wb = gaim_whiteboard_get_session( account, from ); |
162 | 170 |
163 // If a session with the remote user doesn't exist | 171 // If a session with the remote user doesn't exist |
164 if( wb == NULL ) | 172 if( wb == NULL ) |
165 { | 173 { |
166 // Ask user if he/she wishes to accept the request for a doodle session | 174 // Ask user if he/she wishes to accept the request for a doodle session |
184 | 192 |
185 // ------------------------------------------------------------------------------------------------------ | 193 // ------------------------------------------------------------------------------------------------------ |
186 | 194 |
187 void yahoo_doodle_command_got_ready( GaimConnection *gc, char *from ) | 195 void yahoo_doodle_command_got_ready( GaimConnection *gc, char *from ) |
188 { | 196 { |
197 GaimAccount *account; | |
198 GaimWhiteboard *wb; | |
199 | |
189 g_print( "-----------------------------------------------\n" ); | 200 g_print( "-----------------------------------------------\n" ); |
190 g_print( "Got READY (%s)\n", from ); | 201 g_print( "Got READY (%s)\n", from ); |
191 | 202 |
192 GaimAccount *account = gaim_connection_get_account( gc ); | 203 account = gaim_connection_get_account( gc ); |
193 | 204 |
194 // Only handle this if local client requested Doodle session (else local client would have sent one) | 205 // Only handle this if local client requested Doodle session (else local client would have sent one) |
195 GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from ); | 206 wb = gaim_whiteboard_get_session( account, from ); |
196 | 207 |
197 if( wb == NULL ) | 208 if( wb == NULL ) |
198 return; | 209 return; |
199 | 210 |
200 if( wb->state == DOODLE_STATE_REQUESTING ) | 211 if( wb->state == DOODLE_STATE_REQUESTING ) |
226 | 237 |
227 // ------------------------------------------------------------------------------------------------------ | 238 // ------------------------------------------------------------------------------------------------------ |
228 | 239 |
229 void yahoo_doodle_command_got_draw( GaimConnection *gc, char *from, char *message ) | 240 void yahoo_doodle_command_got_draw( GaimConnection *gc, char *from, char *message ) |
230 { | 241 { |
242 GaimAccount *account; | |
243 GaimWhiteboard *wb; | |
244 int *token; | |
245 int length; | |
246 char *token_end; | |
247 GList *d_list; | |
248 int *n; | |
249 GList *l; | |
250 | |
231 g_print( "-----------------------------------------------\n" ); | 251 g_print( "-----------------------------------------------\n" ); |
232 g_print( "Got DRAW (%s)\n", from ); | 252 g_print( "Got DRAW (%s)\n", from ); |
233 | 253 |
234 g_print( "Draw Message: %s\n", message ); | 254 g_print( "Draw Message: %s\n", message ); |
235 | 255 |
236 GaimAccount *account = gaim_connection_get_account( gc ); | 256 account = gaim_connection_get_account( gc ); |
237 | 257 |
238 // Only handle this if local client requested Doodle session (else local client would have sent one) | 258 // Only handle this if local client requested Doodle session (else local client would have sent one) |
239 GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from ); | 259 wb = gaim_whiteboard_get_session( account, from ); |
240 | 260 |
241 if( wb == NULL ) | 261 if( wb == NULL ) |
242 return; | 262 return; |
243 | 263 |
244 // TODO Functionalize | 264 // TODO Functionalize |
245 // Convert drawing packet message to an integer list | 265 // Convert drawing packet message to an integer list |
246 | 266 |
247 int *token = NULL; | 267 token = NULL; |
248 int length = strlen( message ); | 268 length = strlen( message ); |
249 char *token_end; | 269 |
250 | 270 d_list = NULL; // a local list of drawing info |
251 GList *d_list = NULL; // a local list of drawing info | |
252 | 271 |
253 // Check to see if the message begans and ends with quotes | 272 // Check to see if the message begans and ends with quotes |
254 if( ( message[0] != '\"' ) || ( message[length - 1] != '\"' ) ) | 273 if( ( message[0] != '\"' ) || ( message[length - 1] != '\"' ) ) |
255 return; | 274 return; |
256 | 275 |
275 yahoo_doodle_draw_stroke( wb, d_list ); | 294 yahoo_doodle_draw_stroke( wb, d_list ); |
276 | 295 |
277 //goodle_doodle_session_set_canvas_as_icon( ds ); | 296 //goodle_doodle_session_set_canvas_as_icon( ds ); |
278 | 297 |
279 // Remove that shit | 298 // Remove that shit |
280 int *n = NULL; | 299 n = NULL; |
281 GList *l = d_list; | 300 l = d_list; |
282 while( l ) | 301 while( l ) |
283 { | 302 { |
284 n = l->data; | 303 n = l->data; |
285 | 304 |
286 g_free( n ); | 305 g_free( n ); |
294 | 313 |
295 // ------------------------------------------------------------------------------------------------------ | 314 // ------------------------------------------------------------------------------------------------------ |
296 | 315 |
297 void yahoo_doodle_command_got_clear( GaimConnection *gc, char *from ) | 316 void yahoo_doodle_command_got_clear( GaimConnection *gc, char *from ) |
298 { | 317 { |
318 GaimAccount *account; | |
319 GaimWhiteboard *wb; | |
320 | |
299 g_print( "-----------------------------------------------\n" ); | 321 g_print( "-----------------------------------------------\n" ); |
300 g_print( "Got CLEAR (%s)\n", from ); | 322 g_print( "Got CLEAR (%s)\n", from ); |
301 | 323 |
302 GaimAccount *account = gaim_connection_get_account( gc ); | 324 account = gaim_connection_get_account( gc ); |
303 | 325 |
304 // Only handle this if local client requested Doodle session (else local client would have sent one) | 326 // Only handle this if local client requested Doodle session (else local client would have sent one) |
305 GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from ); | 327 wb = gaim_whiteboard_get_session( account, from ); |
306 | 328 |
307 if( wb == NULL ) | 329 if( wb == NULL ) |
308 return; | 330 return; |
309 | 331 |
310 if( wb->state == DOODLE_STATE_ESTABLISHED ) | 332 if( wb->state == DOODLE_STATE_ESTABLISHED ) |
330 | 352 |
331 // ------------------------------------------------------------------------------------------------------ | 353 // ------------------------------------------------------------------------------------------------------ |
332 | 354 |
333 void yahoo_doodle_command_got_confirm( GaimConnection *gc, char *from ) | 355 void yahoo_doodle_command_got_confirm( GaimConnection *gc, char *from ) |
334 { | 356 { |
357 GaimAccount *account; | |
358 GaimWhiteboard *wb; | |
359 | |
335 g_print( "-----------------------------------------------\n" ); | 360 g_print( "-----------------------------------------------\n" ); |
336 g_print( "Got CONFIRM (%s)\n", from ); | 361 g_print( "Got CONFIRM (%s)\n", from ); |
337 | 362 |
338 // Get the doodle session | 363 // Get the doodle session |
339 GaimAccount *account = gaim_connection_get_account( gc ); | 364 account = gaim_connection_get_account( gc ); |
340 | 365 |
341 // Only handle this if local client requested Doodle session (else local client would have sent one) | 366 // Only handle this if local client requested Doodle session (else local client would have sent one) |
342 GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from ); | 367 wb = gaim_whiteboard_get_session( account, from ); |
343 | 368 |
344 if( wb == NULL ) | 369 if( wb == NULL ) |
345 return; | 370 return; |
346 | 371 |
347 // TODO Combine the following IF's? | 372 // TODO Combine the following IF's? |
367 | 392 |
368 // ------------------------------------------------------------------------------------------------------ | 393 // ------------------------------------------------------------------------------------------------------ |
369 | 394 |
370 void yahoo_doodle_command_got_shutdown( GaimConnection *gc, char *from ) | 395 void yahoo_doodle_command_got_shutdown( GaimConnection *gc, char *from ) |
371 { | 396 { |
397 GaimAccount *account; | |
398 GaimWhiteboard *wb; | |
399 | |
372 g_print( "-----------------------------------------------\n" ); | 400 g_print( "-----------------------------------------------\n" ); |
373 g_print( "Got SHUTDOWN (%s)\n", from ); | 401 g_print( "Got SHUTDOWN (%s)\n", from ); |
374 | 402 |
375 GaimAccount *account = gaim_connection_get_account( gc ); | 403 account = gaim_connection_get_account( gc ); |
376 | 404 |
377 // Only handle this if local client requested Doodle session (else local client would have sent one) | 405 // Only handle this if local client requested Doodle session (else local client would have sent one) |
378 GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from ); | 406 wb = gaim_whiteboard_get_session( account, from ); |
379 | 407 |
380 // TODO Ask if user wants to save picture before the session is closed | 408 // TODO Ask if user wants to save picture before the session is closed |
381 | 409 |
382 // If this session doesn't exist, don't try and kill it | 410 // If this session doesn't exist, don't try and kill it |
383 if( wb == NULL ) | 411 if( wb == NULL ) |
392 | 420 |
393 // ------------------------------------------------------------------------------------------------------ | 421 // ------------------------------------------------------------------------------------------------------ |
394 | 422 |
395 void yahoo_doodle_command_send_request( GaimConnection *gc, char *to ) | 423 void yahoo_doodle_command_send_request( GaimConnection *gc, char *to ) |
396 { | 424 { |
397 g_print( "-----------------------------------------------\n" ); | |
398 g_print( "Sent REQUEST (%s)\n", to ); | |
399 | |
400 struct yahoo_data *yd; | 425 struct yahoo_data *yd; |
401 struct yahoo_packet *pkt; | 426 struct yahoo_packet *pkt; |
427 | |
428 g_print( "-----------------------------------------------\n" ); | |
429 g_print( "Sent REQUEST (%s)\n", to ); | |
402 | 430 |
403 yd = gc->proto_data; | 431 yd = gc->proto_data; |
404 | 432 |
405 // Make and send an acknowledge (ready) Doodle packet | 433 // Make and send an acknowledge (ready) Doodle packet |
406 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | 434 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); |
418 | 446 |
419 // ------------------------------------------------------------------------------------------------------ | 447 // ------------------------------------------------------------------------------------------------------ |
420 | 448 |
421 void yahoo_doodle_command_send_ready( GaimConnection *gc, char *to ) | 449 void yahoo_doodle_command_send_ready( GaimConnection *gc, char *to ) |
422 { | 450 { |
423 g_print( "-----------------------------------------------\n" ); | |
424 g_print( "Sent READY (%s)\n", to ); | |
425 | |
426 struct yahoo_data *yd; | 451 struct yahoo_data *yd; |
427 struct yahoo_packet *pkt; | 452 struct yahoo_packet *pkt; |
428 | 453 |
454 g_print( "-----------------------------------------------\n" ); | |
455 g_print( "Sent READY (%s)\n", to ); | |
456 | |
429 yd = gc->proto_data; | 457 yd = gc->proto_data; |
430 | 458 |
431 // Make and send a request to start a Doodle session | 459 // Make and send a request to start a Doodle session |
432 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | 460 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); |
433 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | 461 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); |
444 | 472 |
445 // ------------------------------------------------------------------------------------------------------ | 473 // ------------------------------------------------------------------------------------------------------ |
446 | 474 |
447 void yahoo_doodle_command_send_draw( GaimConnection *gc, char *to, char *message ) | 475 void yahoo_doodle_command_send_draw( GaimConnection *gc, char *to, char *message ) |
448 { | 476 { |
449 g_print( "-----------------------------------------------\n" ); | |
450 g_print( "Sent DRAW (%s)\n", to ); | |
451 | |
452 struct yahoo_data *yd; | 477 struct yahoo_data *yd; |
453 struct yahoo_packet *pkt; | 478 struct yahoo_packet *pkt; |
454 | 479 |
480 g_print( "-----------------------------------------------\n" ); | |
481 g_print( "Sent DRAW (%s)\n", to ); | |
482 | |
455 yd = gc->proto_data; | 483 yd = gc->proto_data; |
456 | 484 |
457 // Make and send a drawing packet | 485 // Make and send a drawing packet |
458 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | 486 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); |
459 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | 487 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); |
470 | 498 |
471 // ------------------------------------------------------------------------------------------------------ | 499 // ------------------------------------------------------------------------------------------------------ |
472 | 500 |
473 void yahoo_doodle_command_send_clear( GaimConnection *gc, char *to ) | 501 void yahoo_doodle_command_send_clear( GaimConnection *gc, char *to ) |
474 { | 502 { |
475 g_print( "-----------------------------------------------\n" ); | |
476 g_print( "Sent CLEAR (%s)\n", to ); | |
477 | |
478 struct yahoo_data *yd; | 503 struct yahoo_data *yd; |
479 struct yahoo_packet *pkt; | 504 struct yahoo_packet *pkt; |
480 | 505 |
506 g_print( "-----------------------------------------------\n" ); | |
507 g_print( "Sent CLEAR (%s)\n", to ); | |
508 | |
481 yd = gc->proto_data; | 509 yd = gc->proto_data; |
482 | 510 |
483 // Make and send a request to clear packet | 511 // Make and send a request to clear packet |
484 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | 512 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); |
485 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | 513 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); |
496 | 524 |
497 // ------------------------------------------------------------------------------------------------------ | 525 // ------------------------------------------------------------------------------------------------------ |
498 | 526 |
499 void yahoo_doodle_command_send_extra( GaimConnection *gc, char *to, char *message ) | 527 void yahoo_doodle_command_send_extra( GaimConnection *gc, char *to, char *message ) |
500 { | 528 { |
501 g_print( "-----------------------------------------------\n" ); | |
502 g_print( "Sent EXTRA (%s)\n", to ); | |
503 | |
504 struct yahoo_data *yd; | 529 struct yahoo_data *yd; |
505 struct yahoo_packet *pkt; | 530 struct yahoo_packet *pkt; |
506 | 531 |
532 g_print( "-----------------------------------------------\n" ); | |
533 g_print( "Sent EXTRA (%s)\n", to ); | |
534 | |
507 yd = gc->proto_data; | 535 yd = gc->proto_data; |
508 | 536 |
509 // Send out a request to use a specified 'extra' feature (message) | 537 // Send out a request to use a specified 'extra' feature (message) |
510 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | 538 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); |
511 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | 539 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); |
522 | 550 |
523 // ------------------------------------------------------------------------------------------------------ | 551 // ------------------------------------------------------------------------------------------------------ |
524 | 552 |
525 void yahoo_doodle_command_send_confirm( GaimConnection *gc, char *to ) | 553 void yahoo_doodle_command_send_confirm( GaimConnection *gc, char *to ) |
526 { | 554 { |
527 g_print( "-----------------------------------------------\n" ); | |
528 g_print( "Sent CONFIRM (%s)\n", to ); | |
529 | |
530 struct yahoo_data *yd; | 555 struct yahoo_data *yd; |
531 struct yahoo_packet *pkt; | 556 struct yahoo_packet *pkt; |
532 | 557 |
558 g_print( "-----------------------------------------------\n" ); | |
559 g_print( "Sent CONFIRM (%s)\n", to ); | |
560 | |
533 yd = gc->proto_data; | 561 yd = gc->proto_data; |
534 | 562 |
535 // Send ready packet (that local client accepted and is ready) | 563 // Send ready packet (that local client accepted and is ready) |
536 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | 564 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); |
537 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | 565 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); |
548 | 576 |
549 // ------------------------------------------------------------------------------------------------------ | 577 // ------------------------------------------------------------------------------------------------------ |
550 | 578 |
551 void yahoo_doodle_command_send_shutdown( GaimConnection *gc, char *to ) | 579 void yahoo_doodle_command_send_shutdown( GaimConnection *gc, char *to ) |
552 { | 580 { |
553 g_print( "-----------------------------------------------\n" ); | |
554 g_print( "Sent SHUTDOWN (%s)\n", to ); | |
555 | |
556 struct yahoo_data *yd; | 581 struct yahoo_data *yd; |
557 struct yahoo_packet *pkt; | 582 struct yahoo_packet *pkt; |
558 | 583 |
584 g_print( "-----------------------------------------------\n" ); | |
585 g_print( "Sent SHUTDOWN (%s)\n", to ); | |
586 | |
559 yd = gc->proto_data; | 587 yd = gc->proto_data; |
560 | 588 |
561 // Declare that you are ending the Doodle session | 589 // Declare that you are ending the Doodle session |
562 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); | 590 pkt = yahoo_packet_new( YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, 0 ); |
563 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); | 591 yahoo_packet_hash_str( pkt, 49, "IMVIRONMENT" ); |
574 | 602 |
575 // ------------------------------------------------------------------------------------------------------ | 603 // ------------------------------------------------------------------------------------------------------ |
576 | 604 |
577 void yahoo_doodle_start( GaimWhiteboard *wb ) | 605 void yahoo_doodle_start( GaimWhiteboard *wb ) |
578 { | 606 { |
607 doodle_session *ds = g_new0( doodle_session, 1 ); | |
608 | |
579 //g_print( "yahoo_doodle_start()\n" ); | 609 //g_print( "yahoo_doodle_start()\n" ); |
580 | 610 |
581 doodle_session *ds = g_new0( doodle_session, 1 ); | |
582 | |
583 // Set default brush size and color | 611 // Set default brush size and color |
584 ds->brush_size = DOODLE_BRUSH_MEDIUM; | 612 ds->brush_size = DOODLE_BRUSH_MEDIUM; |
585 ds->brush_color = 0; // black | 613 ds->brush_color = 0; // black |
586 | 614 |
587 wb->proto_data = ds; | 615 wb->proto_data = ds; |
589 | 617 |
590 // ------------------------------------------------------------------------------------------------------ | 618 // ------------------------------------------------------------------------------------------------------ |
591 | 619 |
592 void yahoo_doodle_end( GaimWhiteboard *wb ) | 620 void yahoo_doodle_end( GaimWhiteboard *wb ) |
593 { | 621 { |
622 GaimConnection *gc = gaim_account_get_connection( wb->account ); | |
623 doodle_session *ds; | |
624 | |
594 //g_print( "yahoo_doodle_end()\n" ); | 625 //g_print( "yahoo_doodle_end()\n" ); |
595 | 626 |
596 GaimConnection *gc = gaim_account_get_connection( wb->account ); | |
597 | |
598 yahoo_doodle_command_send_shutdown( gc, wb->who ); | 627 yahoo_doodle_command_send_shutdown( gc, wb->who ); |
599 | 628 |
600 doodle_session *ds = wb->proto_data; | 629 ds = wb->proto_data; |
601 if( ds ) | 630 if( ds ) |
602 g_free( ds ); | 631 g_free( ds ); |
603 } | 632 } |
604 | 633 |
605 // ------------------------------------------------------------------------------------------------------ | 634 // ------------------------------------------------------------------------------------------------------ |
613 | 642 |
614 // ------------------------------------------------------------------------------------------------------ | 643 // ------------------------------------------------------------------------------------------------------ |
615 | 644 |
616 void yahoo_doodle_send_draw_list( GaimWhiteboard *wb, GList *draw_list ) | 645 void yahoo_doodle_send_draw_list( GaimWhiteboard *wb, GList *draw_list ) |
617 { | 646 { |
618 //g_print( "yahoo_doodle_send_draw_list()\n" ); | |
619 | |
620 doodle_session *ds = wb->proto_data; | 647 doodle_session *ds = wb->proto_data; |
621 char *message = yahoo_doodle_build_draw_string( ds, draw_list ); | 648 char *message = yahoo_doodle_build_draw_string( ds, draw_list ); |
622 | 649 |
650 //g_print( "yahoo_doodle_send_draw_list()\n" ); | |
651 | |
623 if( message ) | 652 if( message ) |
624 yahoo_doodle_command_send_draw( wb->account->gc, wb->who, message ); | 653 yahoo_doodle_command_send_draw( wb->account->gc, wb->who, message ); |
625 | 654 |
626 } | 655 } |
627 | 656 |
635 // ------------------------------------------------------------------------------------------------------ | 664 // ------------------------------------------------------------------------------------------------------ |
636 | 665 |
637 void yahoo_doodle_draw_stroke( GaimWhiteboard *wb, GList *draw_list ) | 666 void yahoo_doodle_draw_stroke( GaimWhiteboard *wb, GList *draw_list ) |
638 { | 667 { |
639 // Traverse through the list and draw the points and lines | 668 // Traverse through the list and draw the points and lines |
640 | |
641 //g_print( "Drawing: color=%d, size=%d, (%d,%d)\n", brush_color, brush_size, x, y ); | |
642 | 669 |
643 GList *l = draw_list; | 670 GList *l = draw_list; |
644 | 671 |
645 int *n = NULL; | 672 int *n = NULL; |
646 | 673 |
649 int x; | 676 int x; |
650 int y; | 677 int y; |
651 | 678 |
652 int dx, dy; | 679 int dx, dy; |
653 | 680 |
681 int count = 0; | |
682 | |
683 //g_print( "Drawing: color=%d, size=%d, (%d,%d)\n", brush_color, brush_size, x, y ); | |
684 | |
654 n = l->data; brush_color = *n; l = l->next; | 685 n = l->data; brush_color = *n; l = l->next; |
655 n = l->data; brush_size = *n; l = l->next; | 686 n = l->data; brush_size = *n; l = l->next; |
656 n = l->data; x = *n; l = l->next; | 687 n = l->data; x = *n; l = l->next; |
657 n = l->data; y = *n; l = l->next; | 688 n = l->data; y = *n; l = l->next; |
658 | 689 |
659 int count = 0; | |
660 | |
661 // Pray this works and pray that the list has an even number of elements | 690 // Pray this works and pray that the list has an even number of elements |
662 while( l ) | 691 while( l ) |
663 { | 692 { |
664 count++; | 693 count++; |
665 | 694 |
682 | 711 |
683 char *yahoo_doodle_build_draw_string( doodle_session *ds, GList *draw_list ) | 712 char *yahoo_doodle_build_draw_string( doodle_session *ds, GList *draw_list ) |
684 { | 713 { |
685 //g_print( "yahoo_doodle_build_draw_string()\n" ); | 714 //g_print( "yahoo_doodle_build_draw_string()\n" ); |
686 | 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 | |
687 if( draw_list == NULL ) | 723 if( draw_list == NULL ) |
688 return( NULL ); | 724 return( NULL ); |
689 | |
690 GList *l = draw_list; | |
691 | |
692 int *n = NULL; | |
693 | |
694 static char message[1024]; // Hope that 1024 is enough | |
695 char token_string[16]; // Token string extracted from draw list | |
696 | 725 |
697 strcpy( message, "\"" ); | 726 strcpy( message, "\"" ); |
698 | 727 |
699 sprintf( token_string, "%d,%d,", ds->brush_color, ds->brush_size ); | 728 sprintf( token_string, "%d,%d,", ds->brush_color, ds->brush_size ); |
700 strcat( message, token_string ); | 729 strcat( message, token_string ); |