gaim/gaim

b8da71507169
Parents a75ee5623db1
Children de189eef5bda
Created GaimWhiteboardPrplOps to abstract communication between GaimWhiteboard
and the prpl's. Added an entry to GaimPluginProtocolInfo for this new object
to indentify which prpl's have an available whiteboard service and to allow core
access to these prpl operations. Yahoo users can start Doodle sessions with
the command '/doodle.'
--- a/src/gtkwhiteboard.c Thu Jul 28 16:48:14 2005 -0400
+++ b/src/gtkwhiteboard.c Fri Jul 29 23:23:43 2005 -0400
@@ -29,10 +29,14 @@
//GList *buttonList = NULL;
-int LastX; // Tracks last position of the mouse when drawing
-int LastY;
-int MotionCount; // Tracks how many brush motions made
-int BrushState = BRUSH_STATE_UP;
+//GdkColor DefaultColor[PALETTE_NUM_OF_COLORS];
+
+static gboolean LocalShutdownRequest;
+
+static int LastX; // Tracks last position of the mouse when drawing
+static int LastY;
+static int MotionCount; // Tracks how many brush motions made
+static int BrushState = BRUSH_STATE_UP;
static GaimWhiteboardUiOps ui_ops =
{
@@ -189,19 +193,25 @@
void gaim_gtk_whiteboard_destroy( GaimWhiteboard *wb )
{
//g_print( "gaim_gtk_whiteboard_destroy()\n" );
-
+
GaimGtkWhiteboard *gtkwb = wb->ui_data;
// TODO Ask if user wants to save picture before the session is closed
// Clear graphical memory
if( gtkwb->pixmap )
+ {
+ //g_print( "---gtkwb->pixmap = %p\n", gtkwb->pixmap );
g_object_unref( gtkwb->pixmap );
+ gtkwb->pixmap = NULL;
+ }
- gaim_whiteboard_destroy( gtkwb->wb );
-
- if( gtkwb )
- g_free( gtkwb );
+ if( gtkwb->window )
+ {
+ //g_print( "---gtkwb->window = %p\n", gtkwb->window );
+ gtk_widget_destroy( gtkwb->window );
+ gtkwb->window = NULL;
+ }
}
// ------------------------------------------------------------------------------------------------------
@@ -210,14 +220,40 @@
{
//g_print( "gaim_gtk_whiteboard_exit()\n" );
- GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
+ GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
+ GaimWhiteboard *wb = gtkwb->wb;
+
+ if( gtkwb->window && gtkwb->pixmap )
+ {
+ LocalShutdownRequest = TRUE;
+
+ //g_print( "---gtkwb->window = %p\n", gtkwb->window );
+ gaim_gtk_whiteboard_destroy( wb );
+ }
+ else
+ LocalShutdownRequest = FALSE;
- gaim_gtk_whiteboard_destroy( gtkwb->wb );
+ if( gtkwb )
+ {
+ //g_print( "---gtkwb = %p\n", gtkwb );
+ g_free( gtkwb );
+
+ gtkwb = NULL;
+ wb->ui_data = NULL;
+ }
+
+ // Destroy whiteboard core, if the local user exited the whiteboard window
+ if( wb && LocalShutdownRequest )
+ {
+ //g_print( "---wb = %p\n", wb );
+ gaim_whiteboard_destroy( wb );
+ wb = NULL;
+ }
}
// ------------------------------------------------------------------------------------------------------
/*
-// Whiteboard start button on conversation window (ooo boy... figure this one out)
+// Whiteboard start button on conversation window (move this code to gtkconv? and use new prpl_info member?)
void gaim_gtkwhiteboard_button_start_press( GtkButton *button, gpointer data )
{
GaimConversation *conv = data;
@@ -226,7 +262,7 @@
char *to = ( char* )( gaim_conversation_get_name( conv ) );
// Only handle this if local client requested Doodle session (else local client would have sent one)
- GaimWhiteboard *wb = gaim_whiteboard_get( account, from );
+ GaimWhiteboard *wb = gaim_whiteboard_get( account, to );
// Write a local message to this conversation showing that
// a request for a Doodle session has been made
@@ -237,7 +273,7 @@
yahoo_doodle_command_send_ready( gc, to );
// Insert this 'session' in the list. At this point, it's only a requested session.
- wb = gaim_whiteboard_create( account, from, DOODLE_STATE_REQUESTING );
+ wb = gaim_whiteboard_create( account, to, DOODLE_STATE_REQUESTING );
}
*/
// ------------------------------------------------------------------------------------------------------
@@ -654,12 +690,13 @@
{
GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
- // Proto specific? UI Ops?
- //goodle_send_command_clear( ds->gc, ds->who );
-
gaim_gtk_whiteboard_clear( gtkwb->wb );
gaim_gtk_whiteboard_set_canvas_as_icon( gtkwb );
+
+ // Do protocol specific clearing procedures
+ if( gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->clear )
+ gtkwb->wb->prpl_ops->clear( gtkwb->wb );
}
// ------------------------------------------------------------------------------------------------------
--- a/src/protocols/yahoo/yahoo.c Thu Jul 28 16:48:14 2005 -0400
+++ b/src/protocols/yahoo/yahoo.c Fri Jul 29 23:23:43 2005 -0400
@@ -45,8 +45,8 @@
#include "ycht.h"
#include "yahoo_auth.h"
#include "yahoo_filexfer.h"
+#include "yahoo_picture.h"
#include "yahoo_doodle.h"
-#include "yahoo_picture.h"
extern char *yahoo_crypt(const char *, const char *);
@@ -3474,8 +3474,20 @@
GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_PRPL_ONLY,
"prpl-yahoo", yahoogaim_cmd_buzz,
_("buzz: Buzz a contact to get their attention"), NULL);
+
+ gaim_cmd_register("doodle", "", GAIM_CMD_P_PRPL,
+ GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_PRPL_ONLY,
+ "prpl-yahoo", yahoo_doodle_gaim_cmd_start,
+ _("doodle: Request user to start a Doodle session"), NULL);
}
+static GaimWhiteboardPrplOps yahoo_whiteboard_prpl_ops =
+{
+ yahoo_doodle_start,
+ yahoo_doodle_end,
+ yahoo_doodle_clear
+};
+
static GaimPluginProtocolInfo prpl_info =
{
OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC,
@@ -3535,7 +3547,8 @@
yahoo_roomlist_cancel,
yahoo_roomlist_expand_category,
NULL, /* can_receive_file */
- yahoo_send_file
+ yahoo_send_file,
+ &yahoo_whiteboard_prpl_ops
};
static GaimPluginInfo info =
--- a/src/protocols/yahoo/yahoo_doodle.c Thu Jul 28 16:48:14 2005 -0400
+++ b/src/protocols/yahoo/yahoo_doodle.c Fri Jul 29 23:23:43 2005 -0400
@@ -53,9 +53,8 @@
#include "yahoo_doodle.h"
// GLOBALS =============================================================================================
-GList *drawList = NULL;
-const int DefaultColorRGB24[] =
+const int DefaultColorRGB24[] =
{
DOODLE_COLOR_RED,
DOODLE_COLOR_ORANGE,
@@ -72,166 +71,43 @@
DOODLE_COLOR_WHITE
};
-//GdkColor DefaultColor[PALETTE_NUM_OF_COLORS];
+// FUNCTIONS ============================================================================================
-// FUNCTIONS ============================================================================================
-/*
-// This function is called at the start of Gaim (twice?)
-// Anyhow... this is the biggy... I think :P
-void init_plugin( GaimPlugin *plugin )
+GaimCmdRet yahoo_doodle_gaim_cmd_start( GaimConversation *conv, const char *cmd, char **args, char **error, void *data )
{
- int i;
-
- for( i = 0; i < PALETTE_NUM_OF_COLORS; i++ )
- {
- goodle_rgb24_to_rgb48( DefaultColorRGB24[i], &DefaultColor[i] );
- }
-}
-
-// ------------------------------------------------------------------------------------------------------
+ GaimAccount *account = gaim_conversation_get_account( conv );
+ GaimConnection *gc = gaim_account_get_connection( account );
+ char *to = ( char* )( gaim_conversation_get_name( conv ) );
-// plugin_load is not required. It is called when the plugin is loaded so that you can
-// initialize any variables and so on. Therefore, called when selected in Preferences->Plugins
-gboolean goodle_load( GaimPlugin *plugin )
-{
- // Set up signal/functions for when connections are made/ended
- void *con_handle = gaim_connections_get_handle();
+ if( *args && args[0] )
+ return( GAIM_CMD_RET_FAILED );
- gaim_signal_connect( con_handle, "signed-on", plugin,
- GAIM_CALLBACK( goodle_con_signed_on ), NULL );
+ // NOTE Functionalize this code?
+
+ // Only handle this if local client requested Doodle session (else local client would have sent one)
+ GaimWhiteboard *wb = gaim_whiteboard_get_session( account, to );
- gaim_signal_connect( con_handle, "signed-off", plugin,
- GAIM_CALLBACK( goodle_con_signed_off ), NULL );
-
- // Set up signal/functions for when the conversation/windows are created
- void *conv_handle = gaim_conversations_get_handle();
+ if( wb == NULL )
+ {
+ // Insert this 'session' in the list. At this point, it's only a requested session.
+ wb = gaim_whiteboard_create( account, to, DOODLE_STATE_REQUESTING );
+ }
+ //else
+ // ; // NOTE Perhaps some careful handling of remote assumed established sessions
- gaim_signal_connect( conv_handle, "conversation-created", plugin,
- GAIM_CALLBACK( goodle_conv_created ), NULL );
-
- gaim_signal_connect( conv_handle, "deleting-conversation", plugin,
- GAIM_CALLBACK( goodle_conv_destroyed ), NULL );
+ yahoo_doodle_command_send_request( gc, to );
+ yahoo_doodle_command_send_ready( gc, to );
- return( TRUE );
+ // Write a local message to this conversation showing that
+ // a request for a Doodle session has been made
+ gaim_conv_im_write( GAIM_CONV_IM( conv ), "", _("Sent Doodle request."),
+ GAIM_MESSAGE_NICK | GAIM_MESSAGE_RECV, time( NULL ) );
+
+ return( GAIM_CMD_RET_OK );
}
// ------------------------------------------------------------------------------------------------------
-
-// plugin_destroy is called when plugin is unloaded (unselected)
-gboolean goodle_unload( GaimPlugin *plugin )
-{
- // Destroy any buttons that haven't been destroyed from closing conversation windows
- g_list_free( buttonList );
- buttonList = NULL;
-
- // Clear the list of Doodle sessions (TODO also make sure the pixmaps and perhaps widgets are destroyed too)
-
- //struct doodle_session *ds;
- //GList *l = dsList;
-
-// // Check if a Doodle session exists with this user
-// while( l )
-// {
-// ds = l->data;
-//
-// g_free( ds );
-//
-// //g_print( "%s\n", ds->who );
-//
-// l = l->next;
- }
-
- g_list_free( dsList );
- dsList = NULL;
-
- return( TRUE );
-}
-// ------------------------------------------------------------------------------------------------------
-
-// plugin_destroy is called when plugin is destroyed (fails/crashes)
-void goodle_destroy( GaimPlugin *plugin )
-{
- g_list_free( buttonList );
- buttonList = NULL;
-
- g_list_free( dsList );
- dsList = NULL;
-}
-
-// ------------------------------------------------------------------------------------------------------
-
-void goodle_con_signed_on( GaimConnection *gc, gpointer data )
-{
- g_print( "%s -> SIGNED ON\n", gaim_account_get_username( gc->account ) );
- goodle_set_goodle_functions( TRUE );
-}
-// ------------------------------------------------------------------------------------------------------
-
-void goodle_con_signed_off( GaimConnection *gc, gpointer data )
-{
- g_print( "%s -> SIGNED OFF\n", gaim_account_get_username( gc->account ) );
-}
-// ------------------------------------------------------------------------------------------------------
-
-
-void goodle_conv_created( GaimConversation *conv, gpointer data )
-{
- GtkWidget *button;
- GaimGtkConversation *gtkconv;
- //GaimConversationType type;
-
- // Check if this is a valid conversation window in Gaim ?
- if( ( gtkconv = GAIM_GTK_CONVERSATION( conv ) ) == NULL )
- return;
-
- // Create this button (via Gaim API)
- button = gaim_gtkconv_button_new( NULL,
- "Goodle", "Start a Doodle session with this user",
- gtkconv->tooltips,
- goodle_button_press,
- ( gpointer )( conv ) );
-
- // Stamp this button with essentially information attributing it to this particular conversation?
- g_object_set_data( G_OBJECT( button ), "conv", conv );
-
- // Add this particular button to the global list of buttons
- buttonList = g_list_append( buttonList, ( gpointer )( button ) );
-
- // Place the button at the bottom of the Gaim conversation window
- gtk_box_pack_end( GTK_BOX( gtkconv->bbox ), button, TRUE, TRUE, 0 );
- gtk_size_group_add_widget( gtkconv->sg, button );
- gtk_widget_show( button );
-}
-// ------------------------------------------------------------------------------------------------------
-
-void goodle_conv_destroyed( GaimConversation *conv, gpointer data )
-{
- GaimConversation *stored_conv;
- GtkWidget *button;
- GList *l, *l_next;
-
- // Traverse the list of buttons and destroy the one associated with this conversation window
- for( l = buttonList; l != NULL; l = l_next )
- {
- l_next = l->next;
-
- button = GTK_WIDGET( l->data );
- stored_conv = ( GaimConversation* )g_object_get_data( G_OBJECT( button ), "conv" );
-
- // Does this button's 'stamp' match that of this conversation?
- if( stored_conv == conv )
- {
- gtk_widget_destroy( button );
-
- buttonList = g_list_remove( buttonList, l->data );
- break;
- }
- }
-}
-
-// ------------------------------------------------------------------------------------------------------
-*/
void yahoo_doodle_process( GaimConnection *gc, char *me, char *from, char *command, char *message )
{
// g_print( "-----------------------------------------------\n" );
@@ -469,9 +345,7 @@
{
wb->state = DOODLE_STATE_ESTABLISHED;
- // Check if this session wasn't already started before we start it (again?)
- //if( ds->pixmap == NULL )
- gaim_whiteboard_start( wb );
+ gaim_whiteboard_start( wb );
yahoo_doodle_command_send_confirm( gc, from );
}
@@ -481,9 +355,7 @@
{
wb->state = DOODLE_STATE_ESTABLISHED;
- // Check if this session wasn't already started before we start it (again?)
- //if( ds->pixmap == NULL )
- gaim_whiteboard_start( wb );
+ gaim_whiteboard_start( wb );
}
}
@@ -505,12 +377,16 @@
if( wb == NULL )
return;
else
+ {
gaim_whiteboard_destroy( wb );
+
+ //yahoo_doodle_command_send_shutdown( gc, from );
+ }
}
// ------------------------------------------------------------------------------------------------------
-int yahoo_doodle_command_send_request( GaimConnection *gc, char *to )
+void yahoo_doodle_command_send_request( GaimConnection *gc, char *to )
{
g_print( "-----------------------------------------------\n" );
g_print( "Sent REQUEST (%s)\n", to );
@@ -532,13 +408,11 @@
yahoo_packet_hash_str( pkt, 1002, "1" );
yahoo_packet_send_and_free( pkt, yd );
-
- return( 0 );
}
// ------------------------------------------------------------------------------------------------------
-int yahoo_doodle_command_send_ready( GaimConnection *gc, char *to )
+void yahoo_doodle_command_send_ready( GaimConnection *gc, char *to )
{
g_print( "-----------------------------------------------\n" );
g_print( "Sent READY (%s)\n", to );
@@ -560,8 +434,6 @@
yahoo_packet_hash_str( pkt, 1002, "1" );
yahoo_packet_send_and_free( pkt, yd );
-
- return( 0 );
}
// ------------------------------------------------------------------------------------------------------
@@ -695,126 +567,39 @@
}
// ------------------------------------------------------------------------------------------------------
-/*
-void goodle_doodle_session_start( doodle_session *ds )
-{
- int i;
-
- GtkWidget *window;
- GtkWidget *drawing_area;
-
- GtkWidget *hbox_palette;
- GtkWidget *vbox_palette_above_canvas_and_controls;
- GtkWidget *hbox_canvas_and_controls;
- GtkWidget *vbox_controls;
-
- // --------------------------
- // |[][][][palette[][][][][]|
- // |------------------------|
- // | canvas | con |
- // | | trol|
- // | | s |
- // | | |
- // | | |
- // --------------------------
-
- GtkWidget *clear_button;
- GtkWidget *save_button;
-
- GtkWidget *color_box[PALETTE_NUM_OF_COLORS];
-
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- ds->window = window;
- gtk_widget_set_name( window, ds->who );
- gtk_window_set_title( ( GtkWindow* )( window ), ds->who ); // TODO Try and use alias first
- gtk_window_set_resizable( ( GtkWindow* )( window ), FALSE );
-
- g_signal_connect( G_OBJECT( window ), "destroy",
- G_CALLBACK( goodle_doodle_session_end ), ( gpointer )( ds ) );
-
- // Create vertical box to place palette above the canvas and controls
- vbox_palette_above_canvas_and_controls = gtk_vbox_new( FALSE, 0 );
- gtk_container_add( GTK_CONTAINER( window ), vbox_palette_above_canvas_and_controls );
- gtk_widget_show( vbox_palette_above_canvas_and_controls );
-
- // Create horizontal box for the palette and all its entries
- hbox_palette = gtk_hbox_new( FALSE, 0 );
- gtk_container_add( GTK_CONTAINER( vbox_palette_above_canvas_and_controls ), hbox_palette );
- gtk_widget_show( hbox_palette );
-
- // Create horizontal box to seperate the canvas from the controls
- hbox_canvas_and_controls = gtk_hbox_new( FALSE, 0 );
- gtk_container_add( GTK_CONTAINER( vbox_palette_above_canvas_and_controls ), hbox_canvas_and_controls );
- gtk_widget_show( hbox_canvas_and_controls );
-
- for( i = 0; i < PALETTE_NUM_OF_COLORS; i++ )
-{
- color_box[i] = gtk_label_new( NULL );
- gtk_widget_set_size_request( color_box[i], DOODLE_CANVAS_WIDTH / PALETTE_NUM_OF_COLORS ,32 );
- gtk_container_add( GTK_CONTAINER( hbox_palette ), color_box[i] );
- gtk_widget_show( color_box[i] );
-}
+
+void yahoo_doodle_start( GaimWhiteboard *wb )
+{/*
+ 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
- // Create the drawing area
- drawing_area = gtk_drawing_area_new();
- ds->drawing_area = drawing_area;
- gtk_widget_set_size_request( GTK_WIDGET( drawing_area ), DOODLE_CANVAS_WIDTH, DOODLE_CANVAS_HEIGHT );
- gtk_box_pack_start( GTK_BOX( hbox_canvas_and_controls ), drawing_area, TRUE, TRUE, 8 );
-
- gtk_widget_show( drawing_area );
+ wb->proto_data = ds;*/
+ int n = 0;
+}
- // Signals used to handle backing pixmap
- g_signal_connect( G_OBJECT( drawing_area ), "expose_event",
- G_CALLBACK( goodle_doodle_session_expose_event ), ( gpointer )( ds ) );
-
- g_signal_connect( G_OBJECT( drawing_area ), "configure_event",
- G_CALLBACK( goodle_doodle_session_configure_event ), ( gpointer )( ds ) );
-
- // Event signals
- g_signal_connect( G_OBJECT( drawing_area ), "button_press_event",
- G_CALLBACK( goodle_doodle_session_brush_down ), ( gpointer )( ds ) );
-
- g_signal_connect( G_OBJECT( drawing_area ), "motion_notify_event",
- G_CALLBACK( goodle_doodle_session_brush_motion ), ( gpointer )( ds ) );
-
- g_signal_connect( G_OBJECT( drawing_area ), "button_release_event",
- G_CALLBACK( goodle_doodle_session_brush_up ), ( gpointer )( ds ) );
+// ------------------------------------------------------------------------------------------------------
- gtk_widget_set_events( drawing_area, GDK_EXPOSURE_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_HINT_MASK );
+void yahoo_doodle_end( GaimWhiteboard *wb )
+{
+ g_print( "yahoo_doodle_end()\n" );
- // Create vertical box to contain the controls
- vbox_controls = gtk_vbox_new( FALSE, 0 );
- gtk_container_add( GTK_CONTAINER( hbox_canvas_and_controls ), vbox_controls );
- gtk_widget_show( vbox_controls );
-
- // Add a clear button
- clear_button = gtk_button_new_with_label( "Clear" );
- gtk_widget_set_size_request( clear_button, 96 ,32 );
- gtk_box_pack_start( GTK_BOX( vbox_controls ), clear_button, FALSE, FALSE, 0 );
- gtk_widget_show( clear_button );
+ GaimConnection *gc = gaim_account_get_connection( wb->account );
- g_signal_connect( G_OBJECT( clear_button ), "clicked",
- G_CALLBACK( goodle_doodle_session_button_clear_press ), ( gpointer )( ds ) );
-
- // Add a save button
- save_button = gtk_button_new_with_label( "Save" );
- gtk_widget_set_size_request( save_button, 96 ,32 );
- gtk_box_pack_start( GTK_BOX( vbox_controls ), save_button, FALSE, FALSE, 8 );
- gtk_widget_show( save_button );
+ yahoo_doodle_command_send_shutdown( gc, wb->who );
+}
+
+// ------------------------------------------------------------------------------------------------------
+
+void yahoo_doodle_clear( GaimWhiteboard *wb )
+{
+ GaimConnection *gc = gaim_account_get_connection( wb->account );
- // Make all this (window) visible
- gtk_widget_show( window );
-
- // Set default brush size and color
- ds->brush_size = DOODLE_BRUSH_MEDIUM;
- ds->brush_color = 0; // black
+ yahoo_doodle_command_send_clear( gc, wb->who );
}
-*/
+
// ------------------------------------------------------------------------------------------------------
void yahoo_doodle_draw_stroke( GaimWhiteboard *wb, GList *d_list )
@@ -901,16 +686,4 @@
// ------------------------------------------------------------------------------------------------------
-void goodle_doodle_session_button_clear_press( GtkWidget *widget, gpointer data )
-{
- doodle_session *ds = ( doodle_session* )( data );
-
- yahoo_doodle_command_send_clear( ds->gc, ds->who );
-
- gaim_whiteboard_clear( wb );
-}
-
-// ------------------------------------------------------------------------------------------------------
-
-
*/
--- a/src/protocols/yahoo/yahoo_doodle.h Thu Jul 28 16:48:14 2005 -0400
+++ b/src/protocols/yahoo/yahoo_doodle.h Fri Jul 29 23:23:43 2005 -0400
@@ -27,6 +27,7 @@
// INCLUDES ============================================================================================
#include "whiteboard.h"
+#include "cmds.h"
// DEFINES =============================================================================================
@@ -87,40 +88,35 @@
// PROTOTYPES ==========================================================================================
-/*
-void init_plugin( GaimPlugin *plugin );
-gboolean goodle_load( GaimPlugin *plugin );
-gboolean goodle_unload( GaimPlugin *plugin );
-void goodle_destroy( GaimPlugin *plugin ); // void or gboolean?
+void dummy_func( void );
+
+GaimCmdRet yahoo_doodle_gaim_cmd_start( GaimConversation *conv, const char *cmd, char **args,
+ char **error, void *data );
+
+void yahoo_doodle_process( GaimConnection *gc, char *me, char *from, char *command, char *message );
-void goodle_con_signed_on( GaimConnection *gc, gpointer data );
-void goodle_con_signed_off( GaimConnection *gc, gpointer data );
-void goodle_conv_created( GaimConversation *conv, gpointer data );
-void goodle_conv_destroyed( GaimConversation *conv, gpointer data );
-*/
-
-void yahoo_doodle_process( GaimConnection *gc, char *me, char *from, char *command, char *message );
+void yahoo_doodle_command_got_request( GaimConnection *gc, char *from );
+void yahoo_doodle_command_got_ready( GaimConnection *gc, char *from );
+void yahoo_doodle_command_got_draw( GaimConnection *gc, char *from, char *message );
+void yahoo_doodle_command_got_clear( GaimConnection *gc, char *from );
+void yahoo_doodle_command_got_extra( GaimConnection *gc, char *from, char *message );
+void yahoo_doodle_command_got_confirm( GaimConnection *gc, char *from );
+void yahoo_doodle_command_got_shutdown( GaimConnection *gc, char *from );
-void yahoo_doodle_command_got_request( GaimConnection *gc, char *from );
-void yahoo_doodle_command_got_ready( GaimConnection *gc, char *from );
-void yahoo_doodle_command_got_draw( GaimConnection *gc, char *from, char *message );
-void yahoo_doodle_command_got_clear( GaimConnection *gc, char *from );
-void yahoo_doodle_command_got_extra( GaimConnection *gc, char *from, char *message );
-void yahoo_doodle_command_got_confirm( GaimConnection *gc, char *from );
-void yahoo_doodle_command_got_shutdown( GaimConnection *gc, char *from );
+void yahoo_doodle_command_send_request( GaimConnection *gc, char *to );
+void yahoo_doodle_command_send_ready( GaimConnection *gc, char *to );
+void yahoo_doodle_command_send_draw( GaimConnection *gc, char *to, char *message );
+void yahoo_doodle_command_send_clear( GaimConnection *gc, char *to );
+void yahoo_doodle_command_send_extra( GaimConnection *gc, char *to, char *message );
+void yahoo_doodle_command_send_confirm( GaimConnection *gc, char *to );
+void yahoo_doodle_command_send_shutdown( GaimConnection *gc, char *to );
-int yahoo_doodle_command_send_request( GaimConnection *gc, char *to );
-int yahoo_doodle_command_send_ready( GaimConnection *gc, char *to );
-void yahoo_doodle_command_send_draw( GaimConnection *gc, char *to, char *message );
-void yahoo_doodle_command_send_clear( GaimConnection *gc, char *to );
-void yahoo_doodle_command_send_extra( GaimConnection *gc, char *to, char *message );
-void yahoo_doodle_command_send_confirm( GaimConnection *gc, char *to );
-void yahoo_doodle_command_send_shutdown( GaimConnection *gc, char *to );
+void yahoo_doodle_start( GaimWhiteboard *wb );
+void yahoo_doodle_end( GaimWhiteboard *wb );
+void yahoo_doodle_clear( GaimWhiteboard *wb );
-//void goodle_doodle_session_start( doodle_session *ds );
-
-void yahoo_doodle_draw_stroke( GaimWhiteboard *wb, GList *d_list );
-//char *goodle_doodle_session_build_draw_string( GList *d_list );
+void yahoo_doodle_draw_stroke( GaimWhiteboard *wb, GList *d_list );
+//char *goodle_doodle_session_build_draw_string( GList *d_list );
#endif // _YAHOO_DOODLE_H_
--- a/src/protocols/yahoo/yahoo_filexfer.c Thu Jul 28 16:48:14 2005 -0400
+++ b/src/protocols/yahoo/yahoo_filexfer.c Fri Jul 29 23:23:43 2005 -0400
@@ -401,7 +401,7 @@
yahoo_doodle_process( gc, me, from, command, message );
// If an IMVIRONMENT packet comes without a specific imviroment name
- if( !strcmp( imv, "" ) )
+ if( !strcmp( imv, ";0" ) )
{
// It is unfortunately time to close all IMVironments with remote client
yahoo_doodle_command_got_shutdown( gc, from );
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/prpl.h Fri Jul 29 23:23:43 2005 -0400
@@ -0,0 +1,460 @@
+/**
+ * @file prpl.h Protocol Plugin functions
+ * @ingroup core
+ *
+ * gaim
+ *
+ * Gaim is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* this file should be all that prpls need to include. therefore, by including
+ * this file, they should get glib, proxy, gaim_connection, prpl, etc. */
+
+#ifndef _GAIM_PRPL_H_
+#define _GAIM_PRPL_H_
+
+typedef struct _GaimPluginProtocolInfo GaimPluginProtocolInfo;
+
+/**************************************************************************/
+/** @name Basic Protocol Information */
+/**************************************************************************/
+
+/**
+ * Flags applicable to outgoing/incoming IMs from prpls.
+ */
+typedef enum
+{
+ GAIM_CONV_IM_AUTO_RESP = 0x0001, /**< Auto response. */
+ GAIM_CONV_IM_IMAGES = 0x0002 /**< Contains images. */
+} GaimConvImFlags;
+
+typedef enum
+{
+ GAIM_CONV_CHAT_WHISPER = 0x0001, /**< Whispered message.*/
+ GAIM_CONV_CHAT_DELAYED = 0x0002, /**< Delayed message. */
+ GAIM_CONV_CHAT_ALERT = 0x0004 /**< Alert message. */
+} GaimConvChatFlags;
+
+typedef enum {
+ GAIM_ICON_SCALE_DISPLAY = 0x01, /**< We scale the icon when we display it */
+ GAIM_ICON_SCALE_SEND = 0x02 /**< We scale the icon before we send it to the server */
+} GaimIconScaleRules;
+
+
+/**
+ * A description of a Buddy Icon specification. This tells Gaim what kind of image file
+ * it should give this prpl, and what kind of image file it should expect back.
+ * Dimensions less than 1 should be ignored and the image not scaled.
+ */
+typedef struct {
+ char *format; /**< This is a comma-delimited list of image formats or NULL if icons are not supported.
+ * The core nor the prpl will actually check to see if the data it's given matches this, it's entirely
+ * up to the UI to do what it wants */
+ int min_width; /**< The minimum width of this icon */
+ int min_height; /**< The minimum height of this icon */
+ int max_width; /**< The maximum width of this icon */
+ int max_height; /**< The maximum height of this icon */
+ GaimIconScaleRules scale_rules; /**< How to stretch this icon */
+} GaimBuddyIconSpec;
+
+/**
+ * This \#define exists just to make it easier to fill out the buddy icon
+ * field in the prpl info struct for protocols that couldn't care less.
+ */
+#define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0}
+
+#include "blist.h"
+#include "proxy.h"
+#include "plugin.h"
+#include "roomlist.h"
+#include "status.h"
+#include "whiteboard.h"
+
+struct proto_chat_entry {
+ char *label;
+ char *identifier;
+ gboolean required;
+ gboolean is_int;
+ int min;
+ int max;
+ gboolean secret;
+};
+
+/**
+ * Protocol options
+ *
+ * These should all be stuff that some plugins can do and others can't.
+ */
+typedef enum
+{
+ /**
+ * Use a unique name, not an alias, for chat rooms.
+ *
+ * Jabber lets you choose what name you want for chat.
+ * So it shouldn't be pulling the alias for when you're in chat;
+ * it gets annoying.
+ */
+ OPT_PROTO_UNIQUE_CHATNAME = 0x00000004,
+
+ /**
+ * Chat rooms have topics.
+ *
+ * IRC and Jabber support this.
+ */
+ OPT_PROTO_CHAT_TOPIC = 0x00000008,
+
+ /**
+ * Don't require passwords for sign-in.
+ *
+ * Zephyr doesn't require passwords, so there's no
+ * need for a password prompt.
+ */
+ OPT_PROTO_NO_PASSWORD = 0x00000010,
+
+ /**
+ * Notify on new mail.
+ *
+ * MSN and Yahoo notify you when you have new mail.
+ */
+ OPT_PROTO_MAIL_CHECK = 0x00000020,
+
+ /**
+ * Images in IMs.
+ *
+ * Oscar lets you send images in direct IMs.
+ */
+ OPT_PROTO_IM_IMAGE = 0x00000040,
+
+ /**
+ * Allow passwords to be optional.
+ *
+ * Passwords in IRC are optional, and are needed for certain
+ * functionality.
+ */
+ OPT_PROTO_PASSWORD_OPTIONAL = 0x00000080,
+
+ /**
+ * Allows font size to be specified in sane point size
+ *
+ * Probably just Jabber and Y!M
+ */
+ OPT_PROTO_USE_POINTSIZE = 0x00000100
+
+} GaimProtocolOptions;
+
+/**
+ * A protocol plugin information structure.
+ *
+ * Every protocol plugin initializes this structure. It is the gateway
+ * between gaim and the protocol plugin. Many of this callbacks can be
+ * NULL. If a callback must be implemented, it has a comment indicating so.
+ */
+struct _GaimPluginProtocolInfo
+{
+ GaimProtocolOptions options; /**< Protocol options. */
+
+ GList *user_splits; /* A GList of GaimAccountUserSplit */
+ GList *protocol_options; /* A GList of GaimAccountOption */
+
+ GaimBuddyIconSpec icon_spec; /* The icon spec. */
+
+ /**
+ * Returns the base icon name for the given buddy and account.
+ * If buddy is NULL, it will return the name to use for the account's
+ * icon. This must be implemented.
+ */
+ const char *(*list_icon)(GaimAccount *account, GaimBuddy *buddy);
+
+ /**
+ * Fills the four char**'s with string identifiers for "emblems"
+ * that the UI will interpret and display as relevant
+ */
+ void (*list_emblems)(GaimBuddy *buddy, const char **se, const char **sw,
+ const char **nw, const char **ne);
+
+ /**
+ * Gets a short string representing this buddy's status. This will
+ * be shown on the buddy list.
+ */
+ char *(*status_text)(GaimBuddy *buddy);
+
+ /**
+ * Gets a string to put in the buddy list tooltip.
+ */
+ char *(*tooltip_text)(GaimBuddy *buddy);
+
+ /**
+ * This must be implemented, and must add at least the offline
+ * and online states.
+ */
+ GList *(*status_types)(GaimAccount *account);
+
+ GList *(*blist_node_menu)(GaimBlistNode *node);
+ GList *(*chat_info)(GaimConnection *);
+ GHashTable *(*chat_info_defaults)(GaimConnection *, const char *chat_name);
+
+ /* All the server-related functions */
+
+ /** This must be implemented. */
+ void (*login)(GaimAccount *, GaimStatus *);
+
+ /** This must be implemented. */
+ void (*close)(GaimConnection *);
+ int (*send_im)(GaimConnection *, const char *who,
+ const char *message,
+ GaimConvImFlags flags);
+ void (*set_info)(GaimConnection *, const char *info);
+ int (*send_typing)(GaimConnection *, const char *name, int typing);
+ void (*get_info)(GaimConnection *, const char *who);
+ void (*set_status)(GaimAccount *account, GaimStatus *status);
+
+ void (*set_idle)(GaimConnection *, int idletime);
+ void (*change_passwd)(GaimConnection *, const char *old_pass,
+ const char *new_pass);
+ void (*add_buddy)(GaimConnection *, GaimBuddy *buddy, GaimGroup *group);
+ void (*add_buddies)(GaimConnection *, GList *buddies, GList *groups);
+ void (*remove_buddy)(GaimConnection *, GaimBuddy *buddy, GaimGroup *group);
+ void (*remove_buddies)(GaimConnection *, GList *buddies, GList *groups);
+ void (*add_permit)(GaimConnection *, const char *name);
+ void (*add_deny)(GaimConnection *, const char *name);
+ void (*rem_permit)(GaimConnection *, const char *name);
+ void (*rem_deny)(GaimConnection *, const char *name);
+ void (*set_permit_deny)(GaimConnection *);
+ void (*warn)(GaimConnection *, const char *who, gboolean anonymous);
+ void (*join_chat)(GaimConnection *, GHashTable *components);
+ void (*reject_chat)(GaimConnection *, GHashTable *components);
+ char *(*get_chat_name)(GHashTable *components);
+ void (*chat_invite)(GaimConnection *, int id,
+ const char *who, const char *message);
+ void (*chat_leave)(GaimConnection *, int id);
+ void (*chat_whisper)(GaimConnection *, int id,
+ const char *who, const char *message);
+ int (*chat_send)(GaimConnection *, int id, const char *message);
+ void (*keepalive)(GaimConnection *);
+
+ /* new user registration */
+ void (*register_user)(GaimAccount *);
+
+ /* get "chat buddy" info and away message */
+ void (*get_cb_info)(GaimConnection *, int, const char *who);
+ void (*get_cb_away)(GaimConnection *, int, const char *who);
+
+ /* save/store buddy's alias on server list/roster */
+ void (*alias_buddy)(GaimConnection *, const char *who,
+ const char *alias);
+
+ /* change a buddy's group on a server list/roster */
+ void (*group_buddy)(GaimConnection *, const char *who,
+ const char *old_group, const char *new_group);
+
+ /* rename a group on a server list/roster */
+ void (*rename_group)(GaimConnection *, const char *old_name,
+ GaimGroup *group, GList *moved_buddies);
+
+ void (*buddy_free)(GaimBuddy *);
+
+ void (*convo_closed)(GaimConnection *, const char *who);
+
+ const char *(*normalize)(const GaimAccount *, const char *);
+
+ void (*set_buddy_icon)(GaimConnection *, const char *filename);
+
+ void (*remove_group)(GaimConnection *gc, GaimGroup *group);
+
+ char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who);
+
+ void (*set_chat_topic)(GaimConnection *gc, int id, const char *topic);
+
+ GaimChat *(*find_blist_chat)(GaimAccount *account, const char *name);
+
+ /* room listing prpl callbacks */
+ GaimRoomlist *(*roomlist_get_list)(GaimConnection *gc);
+ void (*roomlist_cancel)(GaimRoomlist *list);
+ void (*roomlist_expand_category)(GaimRoomlist *list, GaimRoomlistRoom *category);
+
+ /* file transfer callbacks */
+ gboolean (*can_receive_file)(GaimConnection *, const char *who);
+ void (*send_file)(GaimConnection *, const char *who, const char *filename);
+
+ GaimWhiteboardPrplOps *whiteboard_prpl_ops;
+};
+
+#define GAIM_IS_PROTOCOL_PLUGIN(plugin) \
+ ((plugin)->info->type == GAIM_PLUGIN_PROTOCOL)
+
+#define GAIM_PLUGIN_PROTOCOL_INFO(plugin) \
+ ((GaimPluginProtocolInfo *)(plugin)->info->extra_info)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**************************************************************************/
+/** @name Protocol Plugin API */
+/**************************************************************************/
+/*@{*/
+
+/**
+ * Notifies Gaim that an account's idle state and time have changed.
+ *
+ * This is meant to be called from protocol plugins.
+ *
+ * @param account The account.
+ * @param idle The user's idle state.
+ * @param idle_time The user's idle time.
+ */
+void gaim_prpl_got_account_idle(GaimAccount *account, gboolean idle,
+ time_t idle_time);
+
+/**
+ * Notifies Gaim of an account's log-in time.
+ *
+ * This is meant to be called from protocol plugins.
+ *
+ * @param account The account the user is on.
+ * @param login_time The user's log-in time.
+ */
+void gaim_prpl_got_account_login_time(GaimAccount *account, time_t login_time);
+
+/**
+ * Notifies Gaim that an account's status has changed.
+ *
+ * This is meant to be called from protocol plugins.
+ *
+ * @param account The account the user is on.
+ * @param status_id The status ID.
+ * @param attr_id The first attribute ID, or NULL for no attribute updates.
+ * @param ... A NULL-terminated list of attribute IDs and values,
+ * beginning with the value for @a attr_id.
+ */
+void gaim_prpl_got_account_status(GaimAccount *account,
+ const char *status_id, const char *attr_id,
+ ...);
+
+/**
+ * Notifies Gaim that an account's warning level has changed.
+ *
+ * This is meant to be called from protocol plugins.
+ *
+ * @param account The account the user is on.
+ * @param username The user that warned the account.
+ * @param level The new warning level.
+ */
+void gaim_prpl_got_account_warning_level(GaimAccount *account,
+ const char *username,
+ unsigned int level);
+
+
+/**
+ * Notifies Gaim that a user's idle state and time have changed.
+ *
+ * This is meant to be called from protocol plugins.
+ *
+ * @param account The account the user is on.
+ * @param name The screen name of the user.
+ * @param idle The user's idle state.
+ * @param idle_time The user's idle time. This is the time at
+ * which the user became idle, in seconds since
+ * the epoch.
+ */
+void gaim_prpl_got_user_idle(GaimAccount *account, const char *name,
+ gboolean idle, time_t idle_time);
+
+/**
+ * Notifies Gaim of a user's log-in time.
+ *
+ * This is meant to be called from protocol plugins.
+ *
+ * @param account The account the user is on.
+ * @param name The screen name of the user.
+ * @param login_time The user's log-in time.
+ */
+void gaim_prpl_got_user_login_time(GaimAccount *account, const char *name,
+ time_t login_time);
+
+/**
+ * Notifies Gaim that a user's status has changed.
+ *
+ * This is meant to be called from protocol plugins.
+ *
+ * @param account The account the user is on.
+ * @param name The screen name of the user.
+ * @param status_id The status ID.
+ * @param attr_id The first attribute ID, or NULL for no attribute updates.
+ * @param ... A NULL-terminated list of attribute IDs and values,
+ * beginning with the value for @a attr_id.
+ */
+void gaim_prpl_got_user_status(GaimAccount *account, const char *name,
+ const char *status_id, const char *attr_id, ...);
+
+/**
+ * Notifies Gaim that a user's warning level has changed.
+ *
+ * This is meant to be called from protocol plugins.
+ *
+ * @param account The account the user is on.
+ * @param name The screen name of the user.
+ * @param level The new warning level.
+ */
+void gaim_prpl_got_user_warning_level(GaimAccount *account, const char *name,
+ unsigned int level);
+
+/**
+ * Informs the server that an account's status changed.
+ *
+ * @param account The account the user is on.
+ * @param old_status The previous status.
+ * @param new_status The status that was activated, or deactivated
+ * (in the case of independent statuses).
+ */
+void gaim_prpl_change_account_status(GaimAccount *account,
+ GaimStatus *old_status,
+ GaimStatus *new_status);
+
+/**
+ * Retrieves the list of stock status types from a prpl.
+ *
+ * @param account The account the user is on.
+ * @param presence The presence for which we're going to get statuses
+ *
+ * @return List of statuses
+ */
+GList *gaim_prpl_get_statuses(GaimAccount *account, GaimPresence *presence);
+
+/*@}*/
+
+/**************************************************************************/
+/** @name Protocol Plugin Subsystem API */
+/**************************************************************************/
+/*@{*/
+
+/**
+ * Finds a protocol plugin structure of the specified type.
+ *
+ * @param id The protocol plugin;
+ */
+GaimPlugin *gaim_find_prpl(const char *id);
+
+/*@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PRPL_H_ */
--- a/src/whiteboard.c Thu Jul 28 16:48:14 2005 -0400
+++ b/src/whiteboard.c Fri Jul 29 23:23:43 2005 -0400
@@ -24,16 +24,18 @@
// INCLUDES =============================================================================================
#include "whiteboard.h"
+#include "prpl.h"
// DATATYPES ============================================================================================
// GLOBALS ==============================================================================================
static GaimWhiteboardUiOps *whiteboard_ui_ops = NULL;
+//static GaimWhiteboardPrplOps *whiteboard_prpl_ops = NULL;
static GList *wbList = NULL;
-static gboolean auto_accept = TRUE;
+//static gboolean auto_accept = TRUE;
// FUNCTIONS ============================================================================================
@@ -44,6 +46,13 @@
// ------------------------------------------------------------------------------------------------------
+void gaim_whiteboard_set_prpl_ops( GaimWhiteboard *wb, GaimWhiteboardPrplOps *ops )
+{
+ wb->prpl_ops = ops;
+}
+
+// ------------------------------------------------------------------------------------------------------
+
GaimWhiteboard *gaim_whiteboard_create( GaimAccount *account, char *who, int state )
{
//g_print( "gaim_whiteboard_create()\n" );
@@ -54,6 +63,9 @@
wb->state = state;
wb->who = g_strdup( who );
+ GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( account->gc->prpl );
+ gaim_whiteboard_set_prpl_ops( wb, prpl_info->whiteboard_prpl_ops );
+
wbList = g_list_append( wbList, ( gpointer )( wb ) );
return( wb );
@@ -64,18 +76,34 @@
void gaim_whiteboard_destroy( GaimWhiteboard *wb )
{
//g_print( "gaim_whiteboard_destroy()\n" );
+
+ if( wb->ui_data )
+ {
+ //g_print( "---wb->ui_data = %p\n", wb->ui_data );
+
+ // Destroy frontend
+ if( whiteboard_ui_ops && whiteboard_ui_ops->destroy )
+ whiteboard_ui_ops->destroy( wb );
+ }
- wb->account = NULL;
- wb->state = 0;
-
- if( wb->who )
- g_free( wb->who );
+ // Do protocol specific session ending procedures
+ if( wb->prpl_ops && wb->prpl_ops->end )
+ wb->prpl_ops->end( wb );
if( wb )
{
+ //g_print( "---wb = %p\n", wb );
+
+ wb->account = NULL;
+ wb->state = 0;
+
+ if( wb->who )
+ g_free( wb->who );
+
wbList = g_list_remove( wbList, wb );
g_free( wb );
+ wb = NULL;
}
}
--- a/src/whiteboard.h Thu Jul 28 16:48:14 2005 -0400
+++ b/src/whiteboard.h Fri Jul 29 23:23:43 2005 -0400
@@ -28,6 +28,8 @@
// DEFINES =============================================================================================
#include "internal.h"
+typedef struct _GaimWhiteboardPrplOps GaimWhiteboardPrplOps; // NOTE A nasty compiler fix
+
#include "account.h"
// INCLUDES ============================================================================================
@@ -35,16 +37,16 @@
// DATATYPES ===========================================================================================
typedef struct _GaimWhiteboard
{
- int state; // State of whiteboard session
+ int state; // State of whiteboard session
- GaimAccount *account; // Account associated with this session
+ GaimAccount *account; // Account associated with this session
+ char *who; // Name of the remote user
- char *who; // Name of the remote user
+ void *ui_data; // Graphical user-interface data
+ void *proto_data; // Protocol specific data
+ GaimWhiteboardPrplOps *prpl_ops; // Protocol-plugin operations
- void *proto_data; // Protocol specific data
- void *ui_data; // Graphical user-interface data
-
- GList *draw_list; // List of drawing elements/deltas to send
+ GList *draw_list; // List of drawing elements/deltas to send
} GaimWhiteboard;
typedef struct _GaimWhiteboardUiOps
@@ -56,6 +58,13 @@
void ( *clear )( GaimWhiteboard *wb );
} GaimWhiteboardUiOps;
+struct _GaimWhiteboardPrplOps
+{
+ void ( *start )( GaimWhiteboard *wb );
+ void ( *end )( GaimWhiteboard *wb );
+ void ( *clear )( GaimWhiteboard *wb );
+};
+
// PROTOTYPES ==========================================================================================
void gaim_whiteboard_set_ui_ops( GaimWhiteboardUiOps *ops );