From: Sean E. <sea...@us...> - 2002-03-12 17:24:45
|
Update of /cvsroot/gaim/gaim/src In directory usw-pr-cvs1:/tmp/cvs-serv29919/src Modified Files: buddy.c conversation.c core.c gaim.h perl.c prpl.h server.c ui.h Log Message: Laying the ground work for image send. Also an IRC fix. Index: buddy.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/buddy.c,v retrieving revision 1.288 retrieving revision 1.289 diff -u -d -r1.288 -r1.289 --- buddy.c 12 Mar 2002 02:44:22 -0000 1.288 +++ buddy.c 12 Mar 2002 17:21:41 -0000 1.289 @@ -1518,7 +1518,7 @@ set_convo_gc(c, u->gc); write_to_conv(c, b->message, WFLAG_SEND, NULL, time(NULL), -1); - serv_send_im(u->gc, name, b->message, 0); + serv_send_im(u->gc, name, b->message, -1, 0); } } if (b->options & OPT_POUNCE_COMMAND) { Index: conversation.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/conversation.c,v retrieving revision 1.336 retrieving revision 1.337 diff -u -d -r1.336 -r1.337 --- conversation.c 8 Mar 2002 00:58:38 -0000 1.336 +++ conversation.c 12 Mar 2002 17:21:42 -0000 1.337 @@ -927,7 +927,7 @@ void send_callback(GtkWidget *widget, struct conversation *c) { char *buf, *buf2; - int limit; + int limit, length=0; int err = 0; if (!c->gc) @@ -1033,20 +1033,63 @@ int imflags = 0; if (c->check && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->check))) imflags = IM_FLAG_CHECKBOX; - err = serv_send_im(c->gc, c->name, buffy, imflags); + if (c->images) { + int id, offset; + char *bigbuf; + GSList *tmplist = c->images; + id = 1; + length = strlen(buffy) + strlen("<BINARY></BINARY>"); + bigbuf = g_malloc(length); + g_snprintf(bigbuf, strlen(buffy)+strlen("<BINARY> "), "%s<BINARY>", buffy); + offset = strlen(buffy) + strlen("<BINARY>"); + while (tmplist) { + FILE *imgfile; + struct stat st; + char imgtag[1024]; + if (stat(tmplist->data, &st) != 0) { + debug_printf("Could not stat %s\n", tmplist->data); + break; + } + g_snprintf(imgtag, sizeof(imgtag), + "<DATA ID=\"%d\" SIZE=\"%d\">", + id, st.st_size); + length = length + strlen(imgtag) + st.st_size; + bigbuf = realloc(bigbuf, length); + if (!(imgfile = fopen(c->images->data, "r"))) { + debug_printf("Could not open %s\n", tmplist->data); + break; + } + g_snprintf(bigbuf + offset, strlen(imgtag) + 1, "%s", imgtag); + offset = offset + strlen(imgtag); + fread(bigbuf + offset, 1, st.st_size, imgfile); + offset = offset + st.st_size; + g_snprintf(bigbuf + offset, strlen("</DATA>"), "</DATA>"); + offset= offset + strlen("</DATA>"); + id++; + tmplist = tmplist->next; + } + + g_snprintf(bigbuf + offset, strlen("</BINARY>"), "</BINARY>"); + if (serv_send_im(c->gc, c->name, bigbuf, length, imflags) > 0) { + write_to_conv(c, bigbuf, WFLAG_SEND, NULL, time(NULL), length); + if (c->makesound && (sound_options & OPT_SOUND_SEND)) + play_sound(SEND); + if (im_options & OPT_IM_POPDOWN) + gtk_widget_hide(c->window); + + } + g_free(bigbuf); + } else { + if (serv_send_im(c->gc, c->name, buffy, -1, imflags) > 0) + write_to_conv(c, buf, WFLAG_SEND, NULL, time(NULL), -1); + if (c->makesound && (sound_options & OPT_SOUND_SEND)) + play_sound(SEND); + if (im_options & OPT_IM_POPDOWN) + gtk_widget_hide(c->window); + } g_free(buffy); } - - - if (err > 0) { - write_to_conv(c, buf, WFLAG_SEND, NULL, time(NULL), -1); - - if (c->makesound && (sound_options & OPT_SOUND_SEND)) - play_sound(SEND); - - if (im_options & OPT_IM_POPDOWN) - gtk_widget_hide(c->window); - } + } else { err = serv_chat_send(c->gc, c->id, buf); Index: core.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/core.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- core.c 19 Nov 2001 08:23:32 -0000 1.18 +++ core.c 12 Mar 2002 17:21:42 -0000 1.19 @@ -259,7 +259,7 @@ pos += len; memcpy(&flags, data + pos, sizeof(flags)); - serv_send_im(gc, who, msg, flags); + serv_send_im(gc, who, msg, -1, flags); g_free(who); g_free(msg); Index: gaim.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/gaim.h,v retrieving revision 1.312 retrieving revision 1.313 diff -u -d -r1.312 -r1.313 --- gaim.h 12 Mar 2002 02:44:22 -0000 1.312 +++ gaim.h 12 Mar 2002 17:21:42 -0000 1.313 @@ -356,7 +356,7 @@ extern void serv_login(struct aim_user *); extern void serv_close(struct gaim_connection *); extern void serv_touch_idle(struct gaim_connection *); -extern int serv_send_im(struct gaim_connection *, char *, char *, int); +extern int serv_send_im(struct gaim_connection *, char *, char *, int, int); extern void serv_get_info(struct gaim_connection *, char *); extern void serv_get_dir(struct gaim_connection *, char *); extern void serv_set_idle(struct gaim_connection *, int); Index: perl.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/perl.c,v retrieving revision 1.68 retrieving revision 1.69 diff -u -d -r1.68 -r1.69 --- perl.c 8 Dec 2001 09:48:51 -0000 1.68 +++ perl.c 12 Mar 2002 17:21:42 -0000 1.69 @@ -586,7 +586,7 @@ XSRETURN(0); return; } - serv_send_im(gc, nick, what, isauto); + serv_send_im(gc, nick, what, -1, isauto); XSRETURN(0); } @@ -613,7 +613,7 @@ c = new_conversation(nick); set_convo_gc(c, gc); write_to_conv(c, what, WFLAG_SEND | (isauto ? WFLAG_AUTO : 0), NULL, time(NULL), -1); - serv_send_im(c->gc, nick, what, isauto ? IM_FLAG_AWAY : 0); + serv_send_im(c->gc, nick, what, -1, isauto ? IM_FLAG_AWAY : 0); XSRETURN(0); } Index: prpl.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/prpl.h,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- prpl.h 4 Mar 2002 04:18:02 -0000 1.61 +++ prpl.h 12 Mar 2002 17:21:42 -0000 1.62 @@ -102,7 +102,7 @@ void (* login) (struct aim_user *); void (* close) (struct gaim_connection *); - int (* send_im) (struct gaim_connection *, char *who, char *message, int away); + int (* send_im) (struct gaim_connection *, char *who, char *message, int len, int away); void (* set_info) (struct gaim_connection *, char *info); int (* send_typing) (struct gaim_connection *, char *name, int typing); void (* get_info) (struct gaim_connection *, char *who); Index: server.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/server.c,v retrieving revision 1.221 retrieving revision 1.222 diff -u -d -r1.221 -r1.222 --- server.c 4 Mar 2002 07:01:57 -0000 1.221 +++ server.c 12 Mar 2002 17:21:42 -0000 1.222 @@ -152,11 +152,11 @@ else return 0; } -int serv_send_im(struct gaim_connection *gc, char *name, char *message, int flags) +int serv_send_im(struct gaim_connection *gc, char *name, char *message, int len, int flags) { int val = -EINVAL; if (gc->prpl && gc->prpl->send_im) - val = gc->prpl->send_im(gc, name, message, flags); + val = gc->prpl->send_im(gc, name, message, len, flags); if (!(flags & IM_FLAG_AWAY)) serv_touch_idle(gc); @@ -494,7 +494,7 @@ if ((away_options & OPT_AWAY_TIK_HACK) && gc->away && strlen(gc->away) && (len < 0) && !strcmp(message, ">>>Automated Message: Getting Away Message<<<")) { char *tmpmsg = stylize(awaymessage->message, MSG_LEN); - serv_send_im(gc, name, tmpmsg, IM_FLAG_AWAY); + serv_send_im(gc, name, tmpmsg, -1, IM_FLAG_AWAY); g_free(tmpmsg); g_free(name); g_free(message); @@ -621,7 +621,7 @@ /* apply default fonts and colors */ tmpmsg = stylize(gc->away, MSG_LEN); - serv_send_im(gc, name, away_subs(tmpmsg, alias), IM_FLAG_AWAY); + serv_send_im(gc, name, away_subs(tmpmsg, alias), -1, IM_FLAG_AWAY); if (!cnv && clistqueue && (away_options & OPT_AWAY_QUEUE)) { struct queued_message *qm; qm = g_new0(struct queued_message, 1); Index: ui.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/ui.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- ui.h 2 Mar 2002 04:52:21 -0000 1.31 +++ ui.h 12 Mar 2002 17:21:43 -0000 1.32 @@ -154,6 +154,7 @@ GtkWidget *menu; GtkWidget *check; GtkWidget *progress; + GSList *images; /* A list of filenames to embed */ gint unseen; guint typing_timeout; time_t type_again; |