Mercurial > pidgin
changeset 2334:b53cd5b63a99
[gaim-migrate @ 2347]
i feel like everyone's watching me
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 21 Sep 2001 00:14:12 +0000 |
parents | de907b3cf529 |
children | 2c595fc5f1f8 |
files | src/buddy.c src/conversation.c src/dialogs.c src/gaim.h src/protocols/toc/toc.c src/prpl.h src/server.c |
diffstat | 7 files changed, 154 insertions(+), 113 deletions(-) [+] |
line wrap: on
line diff
--- a/src/buddy.c Thu Sep 20 21:44:52 2001 +0000 +++ b/src/buddy.c Fri Sep 21 00:14:12 2001 +0000 @@ -869,7 +869,6 @@ delb = (struct buddy *)mem->data; delg->members = g_slist_remove(delg->members, delb); - serv_remove_buddy(gc, delb->name); gs = find_group_show(rem_g->name); if (gs) { @@ -907,9 +906,8 @@ update_buttons_by_protocol(c); g_free(delb); - /* flush buddy list to cache */ - - do_export(gc); + /* we don't flush buddy list to cache because in the case of remove_group that would + * mean writing to the buddy list file once for each buddy, plus one more time */ } void remove_group(struct gaim_connection *gc, struct group *rem_g) @@ -917,6 +915,7 @@ GSList *grp; GSList *mem; struct group_show *gs; + GList *tmp = NULL; struct group *delg; struct buddy *delb; @@ -930,6 +929,7 @@ while(delg->members) { delb = (struct buddy *)delg->members->data; + tmp = g_list_append(tmp, g_strdup(delb->name)); remove_buddy(gc, delg, delb); /* this should take care of removing the group_show if necessary */ } @@ -944,9 +944,14 @@ } g_free(delg); - /* flush buddy list to cache */ - - do_export(gc); + serv_remove_buddies(gc, tmp); + while (tmp) { + g_free(tmp->data); + tmp = g_list_remove(tmp, tmp->data); + } + + /* don't flush buddy list to cache in order to be consistent with remove_buddy, + * mostly. remove_group is only called from one place, so we'll let it handle it. */ } @@ -1386,6 +1391,7 @@ b = (struct buddy *)type; g = find_group_by_buddy(b->gc, b->name); gct = b->gc; + serv_remove_buddy(b->gc, b->name); remove_buddy(b->gc, g, b); gtk_ctree_remove_node(GTK_CTREE(edittree), node); do_export(gct);
--- a/src/conversation.c Thu Sep 20 21:44:52 2001 +0000 +++ b/src/conversation.c Fri Sep 21 00:14:12 2001 +0000 @@ -532,7 +532,9 @@ { if (c->gc && find_buddy(c->gc, c->name) != NULL) { debug_printf(_("Removing '%s' from buddylist.\n"), c->name); + serv_remove_buddy(c->gc, c->name); remove_buddy(c->gc, find_group_by_buddy(c->gc, c->name), find_buddy(c->gc, c->name)); + do_export(c->gc); build_edit_tree(); update_convo_add_button(c); } else {
--- a/src/dialogs.c Thu Sep 20 21:44:52 2001 +0000 +++ b/src/dialogs.c Fri Sep 21 00:14:12 2001 +0000 @@ -454,107 +454,6 @@ -void show_error_dialog(char *d) -{ - - int no = atoi(d); - char *w; - char buf[256]; - char buf2[32]; - - plugin_event(event_error, (void *)no, 0, 0, 0); - - w = strtok(NULL, ":"); - - - switch(no) { - case 69: - g_snprintf(buf, sizeof(buf), _("Unable to write file %s."), w); - break; - case 169: - g_snprintf(buf, sizeof(buf), _("Unable to read file %s."), w); - break; - case 269: - g_snprintf(buf, sizeof(buf), _("Message too long, last %s bytes truncated."), w); - break; - case 901: - g_snprintf(buf, sizeof(buf), _("%s not currently logged in."), w); - break; - case 902: - g_snprintf(buf, sizeof(buf), _("Warning of %s not allowed."), w); - break; - case 903: - g_snprintf(buf, sizeof(buf), _("A message has been dropped, you are exceeding the server speed limit.")); - break; - case 950: - g_snprintf(buf, sizeof(buf), _("Chat in %s is not available."), w); - break; - case 960: - g_snprintf(buf, sizeof(buf), _("You are sending messages too fast to %s."), w); - break; - case 961: - g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was too big."), w); - break; - case 962: - g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was sent too fast."), w); - break; - case 970: - g_snprintf(buf, sizeof(buf), _("Failure.")); - break; - case 971: - g_snprintf(buf, sizeof(buf), _("Too many matches.")); - break; - case 972: - g_snprintf(buf, sizeof(buf), _("Need more qualifiers.")); - break; - case 973: - g_snprintf(buf, sizeof(buf), _("Dir service temporarily unavailable.")); - break; - case 974: - g_snprintf(buf, sizeof(buf), _("Email lookup restricted.")); - break; - case 975: - g_snprintf(buf, sizeof(buf), _("Keyword ignored.")); - break; - case 976: - g_snprintf(buf, sizeof(buf), _("No keywords.")); - break; - case 977: - g_snprintf(buf, sizeof(buf), _("User has no directory information.")); - /* g_snprintf(buf, sizeof(buf), "Language not supported."); */ - break; - case 978: - g_snprintf(buf, sizeof(buf), _("Country not supported.")); - break; - case 979: - g_snprintf(buf, sizeof(buf), _("Failure unknown: %s."), w); - break; - case 980: - g_snprintf(buf, sizeof(buf), _("Incorrect nickname or password.")); - break; - case 981: - g_snprintf(buf, sizeof(buf), _("The service is temporarily unavailable.")); - break; - case 982: - g_snprintf(buf, sizeof(buf), _("Your warning level is currently too high to log in.")); - break; - case 983: - g_snprintf(buf, sizeof(buf), _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); - break; - case 989: - g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w); - break; - default: - g_snprintf(buf, sizeof(buf), _("An unknown error, %d, has occured. Info: %s"), no, w); - } - - g_snprintf(buf2, sizeof(buf2), _("Gaim - Error %d"), no); - - - do_error_dialog(buf, buf2); - return; -} - static void do_im(GtkWidget *widget, GtkWidget *imentry) { char *who;
--- a/src/gaim.h Thu Sep 20 21:44:52 2001 +0000 +++ b/src/gaim.h Fri Sep 21 00:14:12 2001 +0000 @@ -664,6 +664,7 @@ extern void serv_add_buddy(struct gaim_connection *, char *); extern void serv_add_buddies(struct gaim_connection *, GList *); extern void serv_remove_buddy(struct gaim_connection *, char *); +extern void serv_remove_buddies(struct gaim_connection *, GList *); extern void serv_add_permit(struct gaim_connection *, char *); extern void serv_add_deny(struct gaim_connection *, char *); extern void serv_rem_permit(struct gaim_connection *, char *); @@ -843,7 +844,6 @@ extern void do_export(struct gaim_connection *); extern void show_warn_dialog(struct gaim_connection *, char *); extern GtkWidget *do_error_dialog(char *, char *); -extern void show_error_dialog(char *); extern void show_im_dialog(); extern void some_name(char *); extern void show_info_dialog();
--- a/src/protocols/toc/toc.c Thu Sep 20 21:44:52 2001 +0000 +++ b/src/protocols/toc/toc.c Fri Sep 21 00:14:12 2001 +0000 @@ -236,6 +236,9 @@ len = MSG_LEN; } + if (olen < 0) + debug_printf("TOC C: %s\n", buf); + hdr.ast = '*'; hdr.type = type; hdr.seqno = htons(tdt->seqno++ & 0xffff); @@ -308,6 +311,98 @@ g_show_info_text(url_text, NULL); } +static char *show_error_message(char *d) +{ + int no = atoi(strtok(NULL, ":")); + char *w = strtok(NULL, ":"); + static char buf[256]; + + plugin_event(event_error, (void *)no, 0, 0, 0); + + switch(no) { + case 69: + g_snprintf(buf, sizeof(buf), _("Unable to write file %s."), w); + break; + case 169: + g_snprintf(buf, sizeof(buf), _("Unable to read file %s."), w); + break; + case 269: + g_snprintf(buf, sizeof(buf), _("Message too long, last %s bytes truncated."), w); + break; + case 901: + g_snprintf(buf, sizeof(buf), _("%s not currently logged in."), w); + break; + case 902: + g_snprintf(buf, sizeof(buf), _("Warning of %s not allowed."), w); + break; + case 903: + g_snprintf(buf, sizeof(buf), _("A message has been dropped, you are exceeding the server speed limit.")); + break; + case 950: + g_snprintf(buf, sizeof(buf), _("Chat in %s is not available."), w); + break; + case 960: + g_snprintf(buf, sizeof(buf), _("You are sending messages too fast to %s."), w); + break; + case 961: + g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was too big."), w); + break; + case 962: + g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was sent too fast."), w); + break; + case 970: + g_snprintf(buf, sizeof(buf), _("Failure.")); + break; + case 971: + g_snprintf(buf, sizeof(buf), _("Too many matches.")); + break; + case 972: + g_snprintf(buf, sizeof(buf), _("Need more qualifiers.")); + break; + case 973: + g_snprintf(buf, sizeof(buf), _("Dir service temporarily unavailable.")); + break; + case 974: + g_snprintf(buf, sizeof(buf), _("Email lookup restricted.")); + break; + case 975: + g_snprintf(buf, sizeof(buf), _("Keyword ignored.")); + break; + case 976: + g_snprintf(buf, sizeof(buf), _("No keywords.")); + break; + case 977: + g_snprintf(buf, sizeof(buf), _("User has no directory information.")); + /* g_snprintf(buf, sizeof(buf), "Language not supported."); */ + break; + case 978: + g_snprintf(buf, sizeof(buf), _("Country not supported.")); + break; + case 979: + g_snprintf(buf, sizeof(buf), _("Failure unknown: %s."), w); + break; + case 980: + g_snprintf(buf, sizeof(buf), _("Incorrect nickname or password.")); + break; + case 981: + g_snprintf(buf, sizeof(buf), _("The service is temporarily unavailable.")); + break; + case 982: + g_snprintf(buf, sizeof(buf), _("Your warning level is currently too high to log in.")); + break; + case 983: + g_snprintf(buf, sizeof(buf), _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); + break; + case 989: + g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w); + break; + default: + g_snprintf(buf, sizeof(buf), _("An unknown error, %d, has occured. Info: %s"), no, w); + } + + return buf; +} + static void toc_callback(gpointer data, gint source, GaimInputCondition condition) { struct gaim_connection *gc = (struct gaim_connection *)data; @@ -363,7 +458,12 @@ if (g_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { debug_printf("Didn't get SIGN_ON! buf was: %s\n", buf + sizeof(struct sflap_hdr)); - hide_login_progress(gc, _("Authentication Failed")); + if (!g_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { + strtok(buf + sizeof(struct sflap_hdr), ":"); + hide_login_progress(gc, show_error_message(buf + + sizeof(struct sflap_hdr))); + } else + hide_login_progress(gc, _("Authentication Failed")); signoff(gc); return; } @@ -396,7 +496,7 @@ return; } - debug_printf("From TOC server: %s\n", buf + sizeof(struct sflap_hdr)); + debug_printf("TOC S: %s\n", buf + sizeof(struct sflap_hdr)); c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ @@ -489,7 +589,7 @@ serv_got_update(gc, c, logged, evil, signon, time_idle, type, 0); } else if (!strcasecmp(c, "ERROR")) { c = strtok(NULL, ":"); - show_error_dialog(c); + show_error_message(c); } else if (!strcasecmp(c, "EVILED")) { int lev; char *name; @@ -847,7 +947,7 @@ toc_set_config(g); } -static void toc_add_buddies(struct gaim_connection *g, GList * buddies) +static void toc_add_buddies(struct gaim_connection *g, GList *buddies) { char buf[BUF_LEN * 2]; int n; @@ -872,6 +972,24 @@ toc_set_config(g); } +static void toc_remove_buddies(struct gaim_connection *g, GList *buddies) +{ + char buf[BUF_LEN * 2]; + int n; + + n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); + while (buddies) { + if (strlen(normalize(buddies->data)) + n + 32 > MSG_LEN) { + sflap_send(g, buf, -1, TYPE_DATA); + n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); + } + n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); + buddies = buddies->next; + } + sflap_send(g, buf, -1, TYPE_DATA); + toc_set_config(g); +} + static void toc_set_idle(struct gaim_connection *g, int time) { char buf[BUF_LEN * 2]; @@ -1190,6 +1308,7 @@ ret->add_buddy = toc_add_buddy; ret->add_buddies = toc_add_buddies; ret->remove_buddy = toc_remove_buddy; + ret->remove_buddies = toc_remove_buddies; ret->add_permit = toc_add_permit; ret->add_deny = toc_add_deny; ret->rem_permit = toc_rem_permit;
--- a/src/prpl.h Thu Sep 20 21:44:52 2001 +0000 +++ b/src/prpl.h Fri Sep 21 00:14:12 2001 +0000 @@ -116,6 +116,7 @@ void (* add_buddy) (struct gaim_connection *, char *name); void (* add_buddies) (struct gaim_connection *, GList *buddies); void (* remove_buddy) (struct gaim_connection *, char *name); + void (* remove_buddies) (struct gaim_connection *, GList *buddies); void (* add_permit) (struct gaim_connection *, char *name); void (* add_deny) (struct gaim_connection *, char *name); void (* rem_permit) (struct gaim_connection *, char *name);
--- a/src/server.c Thu Sep 20 21:44:52 2001 +0000 +++ b/src/server.c Fri Sep 21 00:14:12 2001 +0000 @@ -234,6 +234,20 @@ (*g->prpl->remove_buddy)(g, name); } +void serv_remove_buddies(struct gaim_connection *gc, GList *g) +{ + if (!gc->prpl) + return; /* how the hell did that happen? */ + if (gc->prpl->remove_buddies) + (*gc->prpl->remove_buddies)(gc, g); + else { + while (g) { + serv_remove_buddy(gc, g->data); + g = g->next; + } + } +} + void serv_add_permit(struct gaim_connection *g, char *name) { if (g->prpl && g->prpl->add_permit)