Mercurial > pidgin
changeset 1292:cb84b5c6d9ab
[gaim-migrate @ 1302]
Patches from Decklin and "Falling
Thanks guys :)
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Mon, 18 Dec 2000 05:17:58 +0000 |
parents | ddfb2f68c590 |
children | fbc0cbf24a62 |
files | src/away.c src/dialogs.c src/gaim.h src/gaimrc.c src/server.c src/util.c |
diffstat | 6 files changed, 55 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/src/away.c Mon Dec 18 05:08:46 2000 +0000 +++ b/src/away.c Mon Dec 18 05:17:58 2000 +0000 @@ -69,26 +69,6 @@ } -/* - * rcg10312000 This could be more robust, but it works for my current - * goal: to remove those annoying <BR> tags. :) - */ -static void strncpy_nohtml(gchar * dest, const gchar * src, size_t destsize) -{ - gchar *ptr; - g_snprintf(dest, destsize, "%s", src); - - while (1) { - ptr = strstr(dest, "<BR>"); - if (ptr == NULL) /* done? */ - return; - - /* replace <BR> with a newline. */ - *ptr = '\n'; - memmove(ptr + 1, ptr + 4, strlen(ptr + 4) + 1); - } -} - void do_away_message(GtkWidget *w, struct away_message *a) { GtkWidget *back;
--- a/src/dialogs.c Mon Dec 18 05:08:46 2000 +0000 +++ b/src/dialogs.c Mon Dec 18 05:17:58 2000 +0000 @@ -995,7 +995,13 @@ void do_new_bp(GtkWidget *w, struct addbp *b) { struct buddy_pounce *bp = g_new0(struct buddy_pounce, 1); - + + if(strlen(gtk_entry_get_text(GTK_ENTRY(b->nameentry))) == 0) { + do_error_dialog(_("Please enter a buddy to pounce."), _("Buddy Pounce Error")); + g_free(bp); + return; + } + g_snprintf(bp->name, 80, "%s", gtk_entry_get_text(GTK_ENTRY(b->nameentry))); g_snprintf(bp->message, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->messentry))); g_snprintf(bp->command, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->commentry))); @@ -1243,22 +1249,13 @@ junk = gtk_editable_get_chars(GTK_EDITABLE(b->text), 0, -1); if (b->user) { - g_snprintf(b->user->user_info, sizeof(b->user->user_info), "%s", junk); + strncpy_withhtml(b->user->user_info, junk, sizeof b->user->user_info); gc = b->user->gc; save_prefs(); - if (gc) { - buf = g_malloc(strlen(junk) * 4); - if (!buf) { - buf = g_malloc(1); - buf[0] = 0; - } - //g_snprintf(buf, MIN(strlen(junk) * 2, 4096), "%s", junk); - strncpy_withhtml(buf, junk, MIN(strlen(junk) * 2, 4096)); - serv_set_info(gc, buf); - g_free(buf); - } + if (gc) + serv_set_info(gc, b->user->user_info); } g_free(junk); destroy_dialog(NULL, b->window); @@ -1624,13 +1621,18 @@ static void info_choose(GtkWidget *opt, struct set_info_dlg *b) { - int text_len; + int text_len = gtk_text_get_length(GTK_TEXT(b->text)); struct aim_user *u = gtk_object_get_user_data(GTK_OBJECT(opt)); + gchar *buf = g_malloc(strlen(u->user_info)+1); b->user = u; - text_len = gtk_text_get_length(GTK_TEXT(b->text)); + + strncpy_nohtml(buf, u->user_info, strlen(u->user_info)+1); + gtk_text_set_point(GTK_TEXT(b->text), 0); gtk_text_forward_delete(GTK_TEXT(b->text), text_len); - gtk_text_insert(GTK_TEXT(b->text), NULL, NULL, NULL, u->user_info, -1); + gtk_text_insert(GTK_TEXT(b->text), NULL, NULL, NULL, buf, -1); + + g_free(buf); } static void info_user_menu(struct set_info_dlg *b, GtkWidget *box) @@ -1678,7 +1680,9 @@ { GtkWidget *buttons; GtkWidget *vbox; - + gchar *buf; + struct aim_user *tmp; + struct set_info_dlg *b = g_new0(struct set_info_dlg, 1); b->window = gtk_window_new(GTK_WINDOW_DIALOG); @@ -1714,9 +1718,12 @@ gtk_text_set_editable(GTK_TEXT(b->text), TRUE); gtk_widget_set_usize(b->text, 300, 200); if (aim_users) { - gtk_text_insert(GTK_TEXT(b->text), NULL, NULL, NULL, - ((struct gaim_connection *)connections->data)->user->user_info, -1); - b->user = ((struct gaim_connection *)connections->data)->user; + tmp = ((struct gaim_connection *)connections->data)->user; + buf = g_malloc(strlen(tmp->user_info)+1); + strncpy_nohtml(buf, tmp->user_info, strlen(tmp->user_info)+1); + gtk_text_insert(GTK_TEXT(b->text), NULL, NULL, NULL, buf, -1); + b->user = tmp; + g_free(buf); } gtk_widget_show(b->text); @@ -1731,6 +1738,7 @@ aol_icon(b->window->window); gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Set User Info")); + gtk_window_set_focus(GTK_WINDOW(b->window), b->text); gtk_widget_show(b->window); }
--- a/src/gaim.h Mon Dec 18 05:08:46 2000 +0000 +++ b/src/gaim.h Mon Dec 18 05:17:58 2000 +0000 @@ -565,6 +565,7 @@ extern int do_auto_login (char *); extern int file_is_dir (char *, GtkWidget *); extern char *gaim_user_dir(); +extern void strncpy_nohtml(gchar *, const gchar *, size_t); extern void strncpy_withhtml(gchar *, const gchar *, size_t); extern void away_on_login(char *);
--- a/src/gaimrc.c Mon Dec 18 05:08:46 2000 +0000 +++ b/src/gaimrc.c Mon Dec 18 05:17:58 2000 +0000 @@ -480,6 +480,10 @@ } } + if (i = strlen(u->user_info)) { + u->user_info[i-1] = '\0'; + } + if (!fgets(buf, sizeof(buf), f)) { return u; }
--- a/src/server.c Mon Dec 18 05:08:46 2000 +0000 +++ b/src/server.c Mon Dec 18 05:17:58 2000 +0000 @@ -97,10 +97,10 @@ char *buf; if (strlen(gc->user->user_info)) { - buf = g_malloc(strlen(gc->user->user_info) * 4); - strncpy_withhtml(buf, gc->user->user_info, strlen(gc->user->user_info) * 4); - serv_set_info(gc, buf); - g_free(buf); + //g_malloc(strlen(gc->user->user_info) * 4); + //strncpy_withhtml(buf, gc->user->user_info, strlen(gc->user->user_info) * 4); + serv_set_info(gc, gc->user->user_info); + //g_free(buf); } if (gc->idle_timer > 0)
--- a/src/util.c Mon Dec 18 05:08:46 2000 +0000 +++ b/src/util.c Mon Dec 18 05:17:58 2000 +0000 @@ -1257,11 +1257,27 @@ return g_strjoin(G_DIR_SEPARATOR_S, g_get_home_dir(), ".gaim", NULL); } +/* + * rcg10312000 This could be more robust, but it works for my current + * goal: to remove those annoying <BR> tags. :) + * dtf12162000 made the loop more readable. i am a neat freak. ;) */ +void strncpy_nohtml(gchar *dest, const gchar *src, size_t destsize) +{ + gchar *ptr; + g_snprintf(dest, destsize, "%s", src); + + while (ptr = strstr(dest, "<BR>")) { + /* replace <BR> with a newline. */ + *ptr = '\n'; + memmove(ptr + 1, ptr + 4, strlen(ptr + 4) + 1); + } +} + void strncpy_withhtml(gchar *dest, const gchar *src, size_t destsize) { gchar *end = dest + destsize; - while (dest < end) { + while (*src && dest < end) { if (*src == '\n' && dest < end - 4) { strcpy(dest, "<BR>"); src++; @@ -1269,6 +1285,7 @@ } else *dest++ = *src++; } + dest[destsize-1] = '\0'; }