# HG changeset patch # User Eric Warmenhoven # Date 1002327029 0 # Node ID 5cbe86a444d9d3a7342a04287b19d8a56cc6b689 # Parent aa63f3ceea03820fc43bd6d3960a229400597fd2 [gaim-migrate @ 2451] more updates to core. committer: Tailor Script diff -r aa63f3ceea03 -r 5cbe86a444d9 src/core.c --- a/src/core.c Fri Oct 05 22:23:27 2001 +0000 +++ b/src/core.c Sat Oct 06 00:10:29 2001 +0000 @@ -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,25 +87,14 @@ { struct UI *ui = data; - guchar buf[2] = {0, 0}; + guchar type; + guchar subtype; guint32 len; guchar *in; - gushort type; - - /* 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]); - uis = g_slist_remove(uis, ui); - g_io_channel_close(ui->channel); - g_source_remove(ui->inpa); - g_free(ui); - 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, &type, sizeof(type)) != sizeof(type)) { debug_printf("UI has abandoned us!\n"); uis = g_slist_remove(uis, ui); g_io_channel_close(ui->channel); @@ -114,10 +103,34 @@ return FALSE; } - in = g_new0(guchar, len + 1); - gaim_recv(source, in, len); + 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); + g_free(ui); + return FALSE; + } - memcpy(&type, in, sizeof(type)); + 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); + g_source_remove(ui->inpa); + g_free(ui); + return FALSE; + } + + 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; + } + switch (type) { /* case CUI_TYPE_META: diff -r aa63f3ceea03 -r 5cbe86a444d9 src/core.h --- a/src/core.h Fri Oct 05 22:23:27 2001 +0000 +++ b/src/core.h Sat Oct 06 00:10:29 2001 +0000 @@ -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 */ diff -r aa63f3ceea03 -r 5cbe86a444d9 src/gaim.h --- a/src/gaim.h Fri Oct 05 22:23:27 2001 +0000 +++ b/src/gaim.h Sat Oct 06 00:10:29 2001 +0000 @@ -28,10 +28,59 @@ #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 #define IM_FLAG_CHECKBOX 0x02 diff -r aa63f3ceea03 -r 5cbe86a444d9 src/multi.c --- a/src/multi.c Fri Oct 05 22:23:27 2001 +0000 +++ b/src/multi.c Sat Oct 06 00:10:29 2001 +0000 @@ -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; diff -r aa63f3ceea03 -r 5cbe86a444d9 src/multi.h --- a/src/multi.h Fri Oct 05 22:23:27 2001 +0000 +++ b/src/multi.h Sat Oct 06 00:10:29 2001 +0000 @@ -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; diff -r aa63f3ceea03 -r 5cbe86a444d9 src/ui.h --- a/src/ui.h Fri Oct 05 22:23:27 2001 +0000 +++ b/src/ui.h Sat Oct 06 00:10:29 2001 +0000 @@ -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 {