# HG changeset patch # User Nathan Walp # Date 1063770304 0 # Node ID dd0eecfbe41387feba3dbc374024620742716e76 # Parent 714fc8f45cf2baae9c81f3a434ebd2308781dee0 [gaim-migrate @ 7418] ok, these are some tweaks i've made to core code working on the new jabber plugin. - add gaim_find_buddy_in_group() that searches a specific group instead of the entire list. kinda handy. - re-did the base64 encoding function. i think it may have been broken, i'm not sure, but this i know works. - fix the formatted notify dialog to be more to my liking, and to have a working Close button. committer: Tailor Script diff -r 714fc8f45cf2 -r dd0eecfbe413 src/blist.c --- a/src/blist.c Wed Sep 17 03:22:44 2003 +0000 +++ b/src/blist.c Wed Sep 17 03:45:04 2003 +0000 @@ -1221,6 +1221,24 @@ return NULL; } +GaimBuddy *gaim_find_buddy_in_group(GaimAccount *account, const char *name, + GaimGroup *group) +{ + struct _gaim_hbuddy hb; + + if (!gaimbuddylist) + return NULL; + + if (!name) + return NULL; + + hb.name = normalize(name); + hb.account = account; + hb.group = (GaimBlistNode*)group; + + return g_hash_table_lookup(gaimbuddylist->buddies, &hb); +} + GSList *gaim_find_buddies(GaimAccount *account, const char *name) { struct buddy *buddy; @@ -2028,8 +2046,10 @@ } else if(!strcmp(element_name, "buddy")) { GaimAccount *account = gaim_accounts_find(blist_parser_account_name, blist_parser_account_protocol); - if(account) { - GaimBuddy *b = gaim_buddy_new(account, blist_parser_buddy_name, blist_parser_buddy_alias); + if(account && !gaim_find_buddy_in_group(account, + blist_parser_buddy_name, blist_parser_group)) { + GaimBuddy *b = gaim_buddy_new(account, blist_parser_buddy_name, + blist_parser_buddy_alias); gaim_blist_add_buddy(b,blist_parser_contact, blist_parser_group, gaim_blist_get_last_child((GaimBlistNode*)blist_parser_contact)); if(blist_parser_buddy_settings) { diff -r 714fc8f45cf2 -r dd0eecfbe413 src/blist.h --- a/src/blist.h Wed Sep 17 03:22:44 2003 +0000 +++ b/src/blist.h Wed Sep 17 03:45:04 2003 +0000 @@ -505,14 +505,24 @@ /** * Finds the buddy struct given a screenname and an account * - * @param name The buddy's screenname or NULL to search for more buddies with the same screenname - * as the previous search + * @param name The buddy's screenname * @param account The account this buddy belongs to * @return The buddy or NULL if the buddy does not exist */ GaimBuddy *gaim_find_buddy(GaimAccount *account, const char *name); /** + * Finds the buddy struct given a screenname, an account, and a group + * + * @param name The buddy's screenname + * @param account The account this buddy belongs to + * @param group The group to look in + * @return The buddy or NULL if the buddy does not exist in the group + */ +GaimBuddy *gaim_find_buddy_in_group(GaimAccount *account, const char *name, + GaimGroup *group); + +/** * Finds all buddies struct given a screenname and an account * * @param name The buddy's screenname diff -r 714fc8f45cf2 -r dd0eecfbe413 src/gtknotify.c --- a/src/gtknotify.c Wed Sep 17 03:22:44 2003 +0000 +++ b/src/gtknotify.c Wed Sep 17 03:45:04 2003 +0000 @@ -278,7 +278,7 @@ /* Setup the descriptive label */ g_snprintf(label_text, sizeof(label_text), - "%s\n\n%s", + "%s\n%s", primary, (secondary ? secondary : "")); label = gtk_label_new(NULL); @@ -311,7 +311,7 @@ gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); gtk_widget_show(button); - g_signal_connect(G_OBJECT(button), "clicked", + g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gtk_widget_destroy), window); /* Add the text to the gtkimhtml */ diff -r 714fc8f45cf2 -r dd0eecfbe413 src/util.c --- a/src/util.c Wed Sep 17 03:22:44 2003 +0000 +++ b/src/util.c Wed Sep 17 03:45:04 2003 +0000 @@ -319,47 +319,33 @@ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" "0123456789+/"; -/* This was borrowed from the Kame source, and then tweaked to our needs */ -char *tobase64(const unsigned char *buf, size_t len) +char *tobase64(const unsigned char *in, size_t inlen) { - char *s = NULL, *rv = NULL; - unsigned long tmp; - - s = g_malloc((4 * (len + 1)) / 3 + 1); + char *out, *rv; - rv = s; - while (len >= 3) { - tmp = buf[0] << 16 | buf[1] << 8 | buf[2]; - s[0] = alphabet[tmp >> 18]; - s[1] = alphabet[(tmp >> 12) & 077]; - s[2] = alphabet[(tmp >> 6) & 077]; - s[3] = alphabet[tmp & 077]; - len -= 3; - buf += 3; - s += 4; - } + rv = out = g_malloc((4 * (inlen + 1)) / 3 + 1); - /* RFC 1521 enumerates these three possibilities... */ - switch(len) { - case 2: - tmp = buf[0] << 16 | buf[1] << 8; - s[0] = alphabet[(tmp >> 18) & 077]; - s[1] = alphabet[(tmp >> 12) & 077]; - s[2] = alphabet[(tmp >> 6) & 077]; - s[3] = '='; - s[4] = '\0'; - break; - case 1: - tmp = buf[0] << 16; - s[0] = alphabet[(tmp >> 18) & 077]; - s[1] = alphabet[(tmp >> 12) & 077]; - s[2] = s[3] = '='; - s[4] = '\0'; - break; - case 0: - s[0] = '\0'; - break; - } + for (; inlen >= 3; inlen -= 3) + { + *out++ = alphabet[in[0] >> 2]; + *out++ = alphabet[((in[0] << 4) & 0x30) | (in[1] >> 4)]; + *out++ = alphabet[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; + *out++ = alphabet[in[2] & 0x3f]; + in += 3; + } + if (inlen > 0) + { + unsigned char fragment; + + *out++ = alphabet[in[0] >> 2]; + fragment = (in[0] << 4) & 0x30; + if (inlen > 1) + fragment |= in[1] >> 4; + *out++ = alphabet[fragment]; + *out++ = (inlen < 2) ? '=' : alphabet[(in[1] << 2) & 0x3c]; + *out++ = '='; + } + *out = '\0'; return rv; }