From: Eric W. <war...@us...> - 2001-10-06 00:10:35
|
Update of /cvsroot/gaim/gaim/src In directory usw-pr-cvs1:/tmp/cvs-serv18681 Modified Files: core.c core.h gaim.h multi.c multi.h ui.h Log Message: more updates to core. Index: core.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/core.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- core.c 2001/10/05 22:06:27 1.4 +++ core.c 2001/10/06 00:10:29 1.5 @@ -67,7 +67,7 @@ } } -static gint gaim_recv(GIOChannel *source, guchar *buf, gint len) +static gint gaim_recv(GIOChannel *source, void *buf, gint len) { gint total = 0; gint cur; @@ -87,16 +87,24 @@ { struct UI *ui = data; - guchar buf[2] = {0, 0}; + guchar type; + guchar subtype; guint32 len; guchar *in; - gushort type; + /* no byte order worries! this'll change if we go to TCP */ + if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) { + debug_printf("UI has abandoned us!\n"); + uis = g_slist_remove(uis, ui); + g_io_channel_close(ui->channel); + g_source_remove(ui->inpa); + g_free(ui); + return FALSE; + } - /* buf[0] is to specify gaim, buf[1] is for protocol version */ - if ((gaim_recv(source, buf, 2) != 2) || (buf[0] != 102) || (buf[1] != 1)) { - debug_printf("UI has abandoned us! (%d %d)\n", buf[0], buf[1]); + if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) { + debug_printf("UI has abandoned us!\n"); uis = g_slist_remove(uis, ui); g_io_channel_close(ui->channel); g_source_remove(ui->inpa); @@ -104,8 +112,7 @@ return FALSE; } - /* no byte order worries! this'll change if we go to TCP */ - if (gaim_recv(source, (guchar *)&len, sizeof(len)) != sizeof(len)) { + if (gaim_recv(source, &len, sizeof(len)) != sizeof(len)) { debug_printf("UI has abandoned us!\n"); uis = g_slist_remove(uis, ui); g_io_channel_close(ui->channel); @@ -114,10 +121,16 @@ return FALSE; } - in = g_new0(guchar, len + 1); - gaim_recv(source, in, len); + in = g_new0(guchar, len); + if (gaim_recv(source, in, len) != len) { + debug_printf("UI has abandoned us!\n"); + uis = g_slist_remove(uis, ui); + g_io_channel_close(ui->channel); + g_source_remove(ui->inpa); + g_free(ui); + return FALSE; + } - memcpy(&type, in, sizeof(type)); switch (type) { /* case CUI_TYPE_META: Index: core.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/core.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- core.h 2001/10/05 22:06:27 1.2 +++ core.h 2001/10/06 00:10:29 1.3 @@ -94,7 +94,7 @@ #endif struct buddy { - int edittype; /* CUI: this is really a GUI function and we need to put this in ui.h */ + int edittype; /* XXX CUI: this is really a GUI function and we need to put this in ui.h */ char name[80]; char show[80]; int present; @@ -108,7 +108,7 @@ }; struct group { - int edittype; /* CUI: this is really a GUI function and we need to put this in ui.h */ + int edittype; /* XXX CUI: this is really a GUI function and we need to put this in ui.h */ char name[80]; GSList *members; struct gaim_connection *gc; /* the connection it belongs to */ Index: gaim.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/gaim.h,v retrieving revision 1.277 retrieving revision 1.278 diff -u -d -r1.277 -r1.278 --- gaim.h 2001/10/05 22:06:27 1.277 +++ gaim.h 2001/10/06 00:10:29 1.278 @@ -28,9 +28,58 @@ #include "core.h" #include "ui.h" -/* CUI: when this is done being split, the only things below should be things +/* XXX CUI: when this is done being split, the only things below should be things * both the core and the uis depend on e.g. the protocol definitions, etc, and * it won't include core.h or ui.h (i.e. it'll mostly be #define's) */ + +/* this is the basis of the CUI protocol. */ +#define CUI_TYPE_META 1 +#define CUI_TYPE_PLUGIN 2 +#define CUI_TYPE_USER 3 +#define CUI_TYPE_CONN 4 +#define CUI_TYPE_BUDDY 5 /* BUDDY_LIST, i.e., both groups and buddies */ +#define CUI_TYPE_MESSAGE 6 +#define CUI_TYPE_CHAT 7 + +#define CUI_META_LIST 1 /* 1 is always list; this is ignored by the core. + If we move to TCP this can be a keepalive */ +#define CUI_META_QUIT 2 +#define CUI_META_DETACH 3 /* you don't need to send this, you can just close + the socket. the core will understand. */ + +#define CUI_PLUGIN_LIST 1 +#define CUI_PLUGIN_LOAD 2 +#define CUI_PLUGIN_UNLOAD 3 +#define CUI_PLUGIN_RELOAD 4 /* this is redundant and may be removed */ + +#define CUI_USER_LIST 1 +#define CUI_USER_ADD 2 +#define CUI_USER_REMOVE 3 +#define CUI_USER_MODIFY 4 /* this handles moving them in the list too */ + +#define CUI_CONN_LIST 1 +#define CUI_CONN_PROGRESS 2 +#define CUI_CONN_ONLINE 3 +#define CUI_CONN_OFFLINE 4 /* this may send a "reason" for why it was killed */ + +#define CUI_BUDDY_LIST 1 +#define CUI_BUDDY_STATE 2 /* notifies the UI of state changes; UI can use it to + request the current status from the core */ +#define CUI_BUDDY_ADD 3 +#define CUI_BUDDY_REMOVE 4 +#define CUI_BUDDY_MODIFY 5 + +#define CUI_MESSAGE_LIST 1 /* no idea */ +#define CUI_MESSAGE_SEND 2 +#define CUI_MESSAGE_RECV 3 + +#define CUI_CHAT_LIST 1 +#define CUI_CHAT_HISTORY 2 /* is this necessary? should we have one for IMs? */ +#define CUI_CHAT_JOIN 3 /* handles other people joining/parting too */ +#define CUI_CHAT_PART 4 +#define CUI_CHAT_SEND 5 +#define CUI_CHAT_RECV 6 + #define IM_FLAG_AWAY 0x01 Index: multi.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/multi.c,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- multi.c 2001/10/05 19:53:38 1.87 +++ multi.c 2001/10/06 00:10:29 1.88 @@ -66,7 +66,6 @@ gc->prpl = find_prpl(user->protocol); g_snprintf(gc->username, sizeof(gc->username), "%s", user->username); g_snprintf(gc->password, sizeof(gc->password), "%s", user->password); - gc->options = user->options; gc->keepalive = 0; gc->inpa = 0; gc->buddy_chats = NULL; Index: multi.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/multi.h,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- multi.h 2001/10/03 09:48:33 1.35 +++ multi.h 2001/10/06 00:10:29 1.36 @@ -26,7 +26,7 @@ /* ok. now the fun begins. first we create a connection structure */ struct gaim_connection { - int edittype; /* CUI: this is ui-specific and should be removed */ + int edittype; /* XXX CUI: this is ui-specific and should be removed */ /* we need to do either oscar or TOC */ /* we make this as an int in case if we want to add more protocols later */ @@ -54,10 +54,9 @@ char username[64]; char displayname[128]; char password[32]; - int options; /* same as aim_user options */ guint keepalive; /* stuff needed for per-connection idle times */ - guint idle_timer; /* CUI: we need to figure out what to do about idle reporting */ + guint idle_timer; time_t login_time; time_t lastsent; int is_idle; Index: ui.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/ui.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ui.h 2001/10/05 22:23:27 1.3 +++ ui.h 2001/10/06 00:10:29 1.4 @@ -66,7 +66,7 @@ GtkWidget *entry; }; -/* CUI: save_pos and window_size are used by gaimrc.c which is core. +/* XXX CUI: save_pos and window_size are used by gaimrc.c which is core. * Need to figure out options saving. Same goes for several global variables as well. */ struct save_pos { int x; @@ -89,7 +89,7 @@ struct log_conversation *next; }; -/* CUI: away messages aren't really anything more than char* but we need two char*'s +/* XXX CUI: away messages aren't really anything more than char* but we need two char*'s * for the UI so that people can name their away messages when they save them. So these * are really a UI function and struct away_message should be removed from the core. */ struct away_message { |