--- a/src/gtkwhiteboard.c Fri Jul 29 23:23:43 2005 -0400
+++ b/src/gtkwhiteboard.c Fri Aug 05 20:35:59 2005 -0400
@@ -42,6 +42,7 @@
gaim_gtk_whiteboard_create,
gaim_gtk_whiteboard_destroy,
+ gaim_gtk_whiteboard_set_dimensions, gaim_gtk_whiteboard_draw_brush_point,
gaim_gtk_whiteboard_draw_brush_line,
gaim_gtk_whiteboard_clear
@@ -87,10 +88,10 @@
GaimGtkWhiteboard *gtkwb = g_new0( GaimGtkWhiteboard, 1 );
- // Protocol specific ui_ops?
+ // Get dimensions (default?) for the whiteboard canvas + if( wb->prpl_ops && wb->prpl_ops->get_dimensions ) + wb->prpl_ops->get_dimensions( wb, >kwb->width, >kwb->height ); window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
@@ -127,7 +128,6 @@
// Create the drawing area
drawing_area = gtk_drawing_area_new();
gtkwb->drawing_area = drawing_area;
- // NOTE Protocol specific needs UI_OP?
gtk_widget_set_size_request( GTK_WIDGET( drawing_area ), gtkwb->width, gtkwb->height );
gtk_box_pack_start( GTK_BOX( hbox_canvas_and_controls ), drawing_area, TRUE, TRUE, 8 );
@@ -328,19 +328,17 @@
// ------------------------------------------------------------------------------------------------------
gboolean gaim_gtk_whiteboard_brush_down( GtkWidget *widget, GdkEventButton *event, gpointer data )
- //g_print( "BRUSH_DOWN | %s\n", ds->who );
- GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
- GdkPixmap *pixmap = gtkwb->pixmap;
+ GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data ); + //g_print( "gaim_gtk_whiteboard_brush_down | %s\n", gtkwb->wb->who ); + GdkPixmap *pixmap = gtkwb->pixmap; -/* GList *d_list = gtkwb->wb->draw_list;
+ GaimWhiteboard *wb = gtkwb->wb; + GList *draw_list = wb->draw_list; - int *brush_color = NULL;
- int *brush_size = NULL;
if( BrushState != BRUSH_STATE_UP )
// Potential double-click DOWN to DOWN?
@@ -356,54 +354,52 @@
if( event->button == 1 && pixmap != NULL )
-/* // Check if draw_list has contents; if so, clear it
- gaim_whiteboard_draw_list_destroy( d_list );
+ // Check if draw_list has contents; if so, clear it + draw_list = gaim_whiteboard_draw_list_destroy( draw_list ); - brush_color = g_new0( int, 1 );
- brush_size = g_new0( int, 1 );
- // *brush_color = gtkwb->brush_color;
- // *brush_size = gtkwb->brush_size;
// Set tracking variables
- LastX = event->x;//LastX = *x0;
- LastY = event->y;//LastY = *y0;
- d_list = g_list_append( d_list, ( gpointer )( brush_color ) );
- d_list = g_list_append( d_list, ( gpointer )( brush_size ) );
- d_list = g_list_append( d_list, ( gpointer )( x0 ) );
- d_list = g_list_append( d_list, ( gpointer )( y0 ) );
+ draw_list = g_list_append( draw_list, ( gpointer )( x0 ) ); + draw_list = g_list_append( draw_list, ( gpointer )( y0 ) ); gaim_gtk_whiteboard_draw_brush_point( gtkwb->wb,
0,5 );//gtkwb->brush_color, gtkwb->brush_size ); NOTE temp const prot uiop
+ wb->draw_list = draw_list; // ------------------------------------------------------------------------------------------------------
gboolean gaim_gtk_whiteboard_brush_motion( GtkWidget *widget, GdkEventMotion *event, gpointer data )
- //g_print( "BRUSH_MOTION | %s\n", ds->who );
- GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
- GdkPixmap *pixmap = gtkwb->pixmap;
+ GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data ); + //g_print( "gaim_gtk_whiteboard_brush_motion | %s\n", gtkwb->wb->who ); + GdkPixmap *pixmap = gtkwb->pixmap; -// GList *d_list = gtkwb->wb->draw_list;
+ GaimWhiteboard *wb = gtkwb->wb; + GList *draw_list = wb->draw_list; gdk_window_get_pointer( event->window, &x, &y, &state );
@@ -415,7 +411,7 @@
if( state & GDK_BUTTON1_MASK && pixmap != NULL )
if( ( BrushState != BRUSH_STATE_DOWN ) && ( BrushState != BRUSH_STATE_MOTION ) )
g_print( "***Bad brush state transition %d to MOTION\n", BrushState );
@@ -425,59 +421,51 @@
BrushState = BRUSH_STATE_MOTION;
// NOTE 100 is a temporary constant for how many deltas/motions in a stroke (needs UI Ops?)
- d_list = g_list_append( d_list, ( gpointer )( dx ) );
- d_list = g_list_append( d_list, ( gpointer )( dy ) );
+ draw_list = g_list_append( draw_list, ( gpointer )( dx ) ); + draw_list = g_list_append( draw_list, ( gpointer )( dy ) ); - //NOTE Protocol specific here too... UI Ops?
- //char* message = goodle_doodle_session_build_draw_string( d_list );
- //yahoo_doodle_command_send_draw( ds->gc, ds->who, message );
+ // Send draw list to prpl draw_list handler + if( gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->send_draw_list ) + gtkwb->wb->prpl_ops->send_draw_list( gtkwb->wb, draw_list ); // The brush stroke is finished, clear the list for another one
- gaim_whiteboard_draw_list_destroy( d_list );
+ draw_list = gaim_whiteboard_draw_list_destroy( draw_list ); - int *brush_color = g_new0( int, 1 );
- int *brush_size = g_new0( int, 1 );
int *x0 = g_new0( int, 1 );
int *y0 = g_new0( int, 1 );
- // *brush_color = gtkwb->brush_color;
- // *brush_size = gtkwb->brush_size;
- d_list = g_list_append( d_list, ( gpointer )( brush_color ) );
- d_list = g_list_append( d_list, ( gpointer )( brush_size ) );
- d_list = g_list_append( d_list, ( gpointer )( x0 ) );
- d_list = g_list_append( d_list, ( gpointer )( y0 ) );
+ draw_list = g_list_append( draw_list, ( gpointer )( x0 ) ); + draw_list = g_list_append( draw_list, ( gpointer )( y0 ) );
- d_list = g_list_append( d_list, ( gpointer )( dx ) );
- d_list = g_list_append( d_list, ( gpointer )( dy ) );
+ draw_list = g_list_append( draw_list, ( gpointer )( dx ) ); + draw_list = g_list_append( draw_list, ( gpointer )( dy ) ); gaim_gtk_whiteboard_draw_brush_line( gtkwb->wb,
@@ -487,6 +475,8 @@
+ wb->draw_list = draw_list; @@ -495,12 +485,12 @@
gboolean gaim_gtk_whiteboard_brush_up( GtkWidget *widget, GdkEventButton *event, gpointer data )
- //g_print( "BRUSH_UP | %s\n", ds->who );
+ GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data ); + //g_print( "gaim_gtk_whiteboard_brush_up | %s\n", gtkwb->wb->who ); + GdkPixmap *pixmap = gtkwb->pixmap; - GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
- GdkPixmap *pixmap = gtkwb->pixmap;
-// GList *d_list = gtkwb->wb->draw_list;
+ GaimWhiteboard *wb = gtkwb->wb; + GList *draw_list = wb->draw_list; if( ( BrushState != BRUSH_STATE_DOWN ) && ( BrushState != BRUSH_STATE_MOTION ) )
@@ -514,14 +504,14 @@
if( event->button == 1 && pixmap != NULL )
-/* // If the brush was never moved, express two sets of two deltas
+ // If the brush was never moved, express two sets of two deltas // That's a 'point,' but not for Yahoo!
//if( ( event->x == LastX ) && ( event->y == LastY ) )
- for( index = 0; index < 2; index++ )
+ for( index = 0; index < 2; index++ ) // NOTE Yahoo Doodle specific! @@ -529,20 +519,24 @@
- d_list = g_list_append( d_list, ( gpointer )( x0 ) );
- d_list = g_list_append( d_list, ( gpointer )( y0 ) );
+ draw_list = g_list_append( draw_list, ( gpointer )( x0 ) ); + draw_list = g_list_append( draw_list, ( gpointer )( y0 ) ); - //char* message = goodle_doodle_session_build_draw_string( drawList );
- //yahoo_doodle_command_send_draw( ds->gc, ds->who, message );
+ // Send draw list to prpl draw_list handler + if( gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->send_draw_list ) + gtkwb->wb->prpl_ops->send_draw_list( gtkwb->wb, draw_list ); gaim_gtk_whiteboard_set_canvas_as_icon( gtkwb );
// The brush stroke is finished, clear the list for another one
-// gaim_whiteboard_draw_list_destroy( d_list );
+ draw_list = gaim_whiteboard_draw_list_destroy( draw_list ); + wb->draw_list = draw_list; @@ -667,6 +661,16 @@
// ------------------------------------------------------------------------------------------------------
+void gaim_gtk_whiteboard_set_dimensions( GaimWhiteboard *wb, int width, int height ) + GaimGtkWhiteboard *gtkwb = wb->ui_data; + gtkwb->height = height; +// ------------------------------------------------------------------------------------------------------ void gaim_gtk_whiteboard_clear( GaimWhiteboard *wb )
GaimGtkWhiteboard *gtkwb = wb->ui_data;
--- a/src/gtkwhiteboard.h Fri Jul 29 23:23:43 2005 -0400
+++ b/src/gtkwhiteboard.h Fri Aug 05 20:35:59 2005 -0400
@@ -74,6 +74,7 @@
void gaim_gtk_whiteboard_draw_brush_line( GaimWhiteboard *wb,
int x0, int y0, int x1, int y1, int color, int size );
+void gaim_gtk_whiteboard_set_dimensions( GaimWhiteboard *wb, int width, int height ); void gaim_gtk_whiteboard_clear( GaimWhiteboard *wb );
void gaim_gtk_whiteboard_button_clear_press( GtkWidget *widget, gpointer data );
--- a/src/protocols/yahoo/yahoo.c Fri Jul 29 23:23:43 2005 -0400
+++ b/src/protocols/yahoo/yahoo.c Fri Aug 05 20:35:59 2005 -0400
@@ -696,6 +696,8 @@
struct _yahoo_im *im = NULL;
if (pkt->status <= 1 || pkt->status == 5) {
@@ -719,12 +721,35 @@
+ strcpy( imv, pair->value ); } else if (pkt->status == 2) {
gaim_notify_error(gc, NULL,
_("Your Yahoo! message did not get sent."), NULL);
+ // Check for the Doodle IMV + if( !strcmp( imv, "doodle;11" ) ) + g_print( "'doodle;11' found in chat packet\n" ); + GaimWhiteboard *wb = gaim_whiteboard_get_session( gc->account, im->from ); + // If a Doodle session doesn't exist between this user + g_print( "Creating new whiteboard for chat packet request\n" ); + wb = gaim_whiteboard_create( gc->account, im->from, DOODLE_STATE_REQUESTED ); + yahoo_doodle_command_send_request( gc, im->from ); + yahoo_doodle_command_send_ready( gc, im->from ); for (l = list; l; l = l->next) {
@@ -2914,20 +2939,14 @@
yahoo_packet_hash_str(pkt, 97, "1");
yahoo_packet_hash_str(pkt, 14, msg2);
// If this message is to a user who is also Doodling with the local user,
- // format the chat packet with the IMV information (thanks Yahoo!)
- doodle_session *ds = goodle_get_doodle_session( dsList,
- ( char* )( gaim_account_get_username( gc->account ) ),
+ // format the chat packet with the correct IMV information (thanks Yahoo!) + GaimWhiteboard *wb = gaim_whiteboard_get_session(gc->account, (char*)who); + yahoo_packet_hash_str(pkt, 63, "doodle;11"); + yahoo_packet_hash_str(pkt, 63, ";0"); // IMvironment
- yahoo_packet_hash(pkt, 63, "doodle;11");
- yahoo_packet_hash(pkt, 63, ";0"); // IMvironment
- yahoo_packet_hash_str(pkt, 63, ";0"); /* IMvironment */
yahoo_packet_hash_str(pkt, 64, "0"); /* no idea */
yahoo_packet_hash_str(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */
@@ -3485,6 +3504,9 @@
+ yahoo_doodle_get_dimensions, + yahoo_doodle_send_draw_list, --- a/src/protocols/yahoo/yahoo_doodle.c Fri Jul 29 23:23:43 2005 -0400
+++ b/src/protocols/yahoo/yahoo_doodle.c Fri Aug 05 20:35:59 2005 -0400
@@ -201,7 +201,6 @@
if( wb->state == DOODLE_STATE_REQUESTING )
- // TODO Check for active pixmap?
gaim_whiteboard_start( wb );
wb->state = DOODLE_STATE_ESTABLISHED;
@@ -211,11 +210,20 @@
if( wb->state == DOODLE_STATE_ESTABLISHED )
- // TODO Call clear function (requires function to clear canvas (but not send clear command packet)
// Ask whether to save picture too
gaim_whiteboard_clear( wb );
+ // NOTE Not sure about this... I am trying to handle if the remote user already + // thinks we're in a session with them (when their chat message contains the doodle;11 imv key) + if( wb->state == DOODLE_STATE_REQUESTED ) + //gaim_whiteboard_start( wb ); + yahoo_doodle_command_send_request( gc, from ); // ------------------------------------------------------------------------------------------------------
@@ -569,15 +577,18 @@
// ------------------------------------------------------------------------------------------------------
void yahoo_doodle_start( GaimWhiteboard *wb )
+ g_print( "yahoo_doodle_start()\n" ); doodle_session *ds = g_new0( doodle_session, 1 );
// Set default brush size and color
ds->brush_size = DOODLE_BRUSH_MEDIUM;
ds->brush_color = 0; // black
+ g_print( "---wb->proto_data:%p\n", wb->proto_data ); // ------------------------------------------------------------------------------------------------------
@@ -589,26 +600,56 @@
GaimConnection *gc = gaim_account_get_connection( wb->account );
yahoo_doodle_command_send_shutdown( gc, wb->who );
+ doodle_session *ds = wb->proto_data; +// ------------------------------------------------------------------------------------------------------ +void yahoo_doodle_get_dimensions( GaimWhiteboard *wb, int *width, int *height ) + // Standard Doodle canvases are of one size: 368x256 + *width = DOODLE_CANVAS_WIDTH; + *height = DOODLE_CANVAS_HEIGHT; +// ------------------------------------------------------------------------------------------------------ +void yahoo_doodle_send_draw_list( GaimWhiteboard *wb, GList *draw_list ) + g_print( "yahoo_doodle_send_draw_list()\n" ); + doodle_session *ds = wb->proto_data; + g_print( "doodle_session not there?\n" ); + char *message = yahoo_doodle_build_draw_string( ds, draw_list ); + yahoo_doodle_command_send_draw( wb->account->gc, wb->who, message ); + g_print( "no message?\n" ); // ------------------------------------------------------------------------------------------------------
void yahoo_doodle_clear( GaimWhiteboard *wb )
- GaimConnection *gc = gaim_account_get_connection( wb->account );
- yahoo_doodle_command_send_clear( gc, wb->who );
+ yahoo_doodle_command_send_clear( wb->account->gc, wb->who ); // ------------------------------------------------------------------------------------------------------
-void yahoo_doodle_draw_stroke( GaimWhiteboard *wb, GList *d_list )
+void yahoo_doodle_draw_stroke( GaimWhiteboard *wb, GList *draw_list ) // Traverse through the list and draw the points and lines
//g_print( "Drawing: color=%d, size=%d, (%d,%d)\n", brush_color, brush_size, x, y );
@@ -647,18 +688,33 @@
// ------------------------------------------------------------------------------------------------------
-char *goodle_doodle_session_build_draw_string( GList *d_list )
+char *yahoo_doodle_build_draw_string( doodle_session *ds, GList *draw_list )
+ g_print( "yahoo_doodle_build_draw_string()\n" ); + if( draw_list == NULL ) + g_print( "---Oh, shit! The list is empty!?! %p\n", draw_list ); - static char message[1024]; // Hope that 500 is enough
+ static char message[1024]; // Hope that 1024 is enough char token_string[16]; // Token string extracted from draw list
+ g_print( "---SOOOO far!\n" ); + sprintf( token_string, "%d,%d,", ds->brush_color, ds->brush_size ); + strcat( message, token_string ); + g_print( "---Started message with: %s\n", token_string ); // Pray this works and pray that the list has an even number of elements
@@ -675,6 +731,8 @@
+ g_print( "---Finished traversing through list\n" ); message[strlen( message ) - 1] = '\"';
//message[strlen( message )] = 0;
@@ -686,4 +744,3 @@
// ------------------------------------------------------------------------------------------------------
--- a/src/whiteboard.c Fri Jul 29 23:23:43 2005 -0400
+++ b/src/whiteboard.c Fri Aug 05 20:35:59 2005 -0400
@@ -66,6 +66,10 @@
GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( account->gc->prpl );
gaim_whiteboard_set_prpl_ops( wb, prpl_info->whiteboard_prpl_ops );
+ // Start up protocol specifics + if( wb->prpl_ops && wb->prpl_ops->start ) + wb->prpl_ops->start( wb ); wbList = g_list_append( wbList, ( gpointer )( wb ) );
@@ -137,10 +141,7 @@
if( !strcmp( gaim_account_get_username( wb->account ), gaim_account_get_username( account ) ) &&
!strcmp( wb->who, who ) )
- //g_print( "@Found whiteboard session\n" );
@@ -150,22 +151,48 @@
// ------------------------------------------------------------------------------------------------------
-void gaim_whiteboard_draw_list_destroy( GList *d_list )
+GList *gaim_whiteboard_draw_list_destroy( GList *draw_list ) - // Destroy the contents of this list
+ g_print( "gaim_whiteboard_draw_list_destroy()\n" ); + if( draw_list == NULL ) + g_print( "-1-FUCK, the list is empty: %p\n", draw_list );
+ g_print( "-2-d_list:%p\n", draw_list ); + // Destroy the contents of this list + g_print( "-3-n=%d\n", *n );
+ g_list_free( draw_list );
+// ------------------------------------------------------------------------------------------------------ +void gaim_whiteboard_set_dimensions( GaimWhiteboard *wb, int width, int height ) + if( whiteboard_ui_ops && whiteboard_ui_ops->set_dimensions ) + whiteboard_ui_ops->set_dimensions( wb, width, height ); // ------------------------------------------------------------------------------------------------------
--- a/src/whiteboard.h Fri Jul 29 23:23:43 2005 -0400
+++ b/src/whiteboard.h Fri Aug 05 20:35:59 2005 -0400
@@ -28,7 +28,7 @@
// DEFINES =============================================================================================
-typedef struct _GaimWhiteboardPrplOps GaimWhiteboardPrplOps; // NOTE A nasty compiler fix
+typedef struct _GaimWhiteboardPrplOps GaimWhiteboardPrplOps; // NOTE A nasty compiler dependency fix @@ -53,6 +53,7 @@
void ( *create )( GaimWhiteboard *wb );
void ( *destroy )( GaimWhiteboard *wb );
+ void ( *set_dimensions)( GaimWhiteboard *wb, int width, int height ); void ( *draw_point )( GaimWhiteboard *wb, int x, int y, int color, int size );
void ( *draw_line )( GaimWhiteboard *wb, int x1, int y1, int x2, int y2, int color, int size );
void ( *clear )( GaimWhiteboard *wb );
@@ -62,6 +63,9 @@
void ( *start )( GaimWhiteboard *wb );
void ( *end )( GaimWhiteboard *wb );
+ void ( *get_dimensions )( GaimWhiteboard *wb, int *width, int *height ); + void ( *set_dimensions )( GaimWhiteboard *wb, int width, int height ); + void ( *send_draw_list )( GaimWhiteboard *wb, GList *draw_list ); void ( *clear )( GaimWhiteboard *wb );
@@ -75,8 +79,9 @@
GaimWhiteboard *gaim_whiteboard_get_session( GaimAccount *account, char *who );
-void gaim_whiteboard_draw_list_destroy( GList *d_list );
+GList *gaim_whiteboard_draw_list_destroy( GList *draw_list ); +void gaim_whiteboard_set_dimensions( GaimWhiteboard *wb, int width, int height ); void gaim_whiteboard_draw_point( GaimWhiteboard *wb, int x, int y, int color, int size );
void gaim_whiteboard_draw_line( GaimWhiteboard *wb, int x1, int y1, int x2, int y2, int color, int size );
void gaim_whiteboard_clear( GaimWhiteboard *wb );