Mercurial > pidgin
changeset 684:b29c92be568b
[gaim-migrate @ 694]
bmiller translated perl to C so now gaim can import winaim lists. oh yeah,
the permit/deny stuff isn't quite working right. argh.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 15 Aug 2000 17:02:00 +0000 |
parents | 2186b43872b7 |
children | 94a27f7567c5 |
files | ChangeLog FIXME HACKING TODO doc/CREDITS src/dialogs.c src/gaim.h src/server.c src/util.c |
diffstat | 9 files changed, 193 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Aug 15 16:20:27 2000 +0000 +++ b/ChangeLog Tue Aug 15 17:02:00 2000 +0000 @@ -15,6 +15,7 @@ * Removed the Lag-O-Meter * Socks 4/5 Proxy works * Buddy Pounces are now saved in .gaimrc + # Ability to merge gaim, aim2, aim4 buddylists. Thanks again bmiller! version 0.9.20 (07/14/2000): * More plugin events, more plugin features
--- a/FIXME Tue Aug 15 16:20:27 2000 +0000 +++ b/FIXME Tue Aug 15 17:02:00 2000 +0000 @@ -1,3 +1,5 @@ GAIM: Items to be fixed ------------------------ - +For the Permit/Deny Stuff, everything is working, except for "Deny people in 'Deny'", +which sucks for people like me who have 16 people in their deny list. The Oscar side +of things is broken beyond repair too.
--- a/HACKING Tue Aug 15 16:20:27 2000 +0000 +++ b/HACKING Tue Aug 15 17:02:00 2000 +0000 @@ -13,6 +13,9 @@ of the information that's printed is useless anyway though; so the --enable-debug option really doesn't do a whole lot. +This was written around August 8, 2000. It's now August 15, 2000, and I'm +sure a lot of it is already out of date. + PROGRAM FLOW ============
--- a/TODO Tue Aug 15 16:20:27 2000 +0000 +++ b/TODO Tue Aug 15 17:02:00 2000 +0000 @@ -1,5 +1,4 @@ --- STUFF FOR 0.10.1 RELEASE --- - Ability to merge gaim, toc, aim2, aim4 buddylists Third sound option for people without soundcards who still want sound events. Make a PC Speaker Beep (^G / Char 7) Save Buddy Chats
--- a/doc/CREDITS Tue Aug 15 16:20:27 2000 +0000 +++ b/doc/CREDITS Tue Aug 15 17:02:00 2000 +0000 @@ -36,6 +36,10 @@ Info box looks nicer David <IM: CrazyDavy> The neato-bigger text box +S D Erle + Writing a cool perl script to translate WinAIM lists to gaim +BMiller + Translating perl code to C so gaim can import lists itself G. Sumner Hayes <IM: SumnerFool> Security Patches Brian Ryner for a little make file patch :)
--- a/src/dialogs.c Tue Aug 15 16:20:27 2000 +0000 +++ b/src/dialogs.c Tue Aug 15 17:02:00 2000 +0000 @@ -2705,7 +2705,38 @@ fgets(first, 64, f); + /* AIM 4 buddy list */ if (!strcasecmp(first, "Config {\n")) { + debug_print("aim 4\n"); + rewind(f); + translate_blt (f, buf); + sprintf(debug_buff, "%s\n", buf); + debug_print(debug_buff); + buf2 = buf; + buf = g_malloc(8193); + g_snprintf(buf, 8192, "toc_set_config {%s}\n", buf2); + g_free(buf2); + /* AIM 3 buddy list */ + } else if (strstr(first, "group") != NULL) { + debug_print("aim 3\n"); + rewind(f); + translate_lst (f, buf); + sprintf(debug_buff, "%s\n", buf); + debug_print(debug_buff); + buf2 = buf; + buf = g_malloc(8193); + g_snprintf(buf, 8192, "toc_set_config {%s}\n", buf2); + g_free(buf2); + /* GAIM buddy list - no translation */ + } else if (first[0] == 'm') { + rewind(f); + fread(buf, BUF_LONG, 1, f); + buf2 = buf; + buf = g_malloc(8193); + g_snprintf(buf, 8192, "toc_set_config {%s}\n", buf2); + g_free(buf2); + /* Something else */ + } else { if ( show_dialog == 1 ) { destroy_dialog(NULL, importdialog); importdialog = NULL; @@ -2714,35 +2745,15 @@ g_free(first); fclose( f ); return; - } else if (buf[0] == 'm') { - buf2 = buf; - buf = g_malloc(8193); - g_snprintf(buf, 8192, "toc_set_config {%s}\n", buf2); - g_free(buf2); - } - - - fseek(f, 0, SEEK_SET); - - fread(buf, BUF_LONG, 1, f); - - grp = groups; - - /* why is this being done? if we merge them than this shouldn't happen - while(grp) { - grp2 = grp->next; - remove_group((struct group *)grp->data); - grp = grp2; - } - */ - + } + parse_toc_buddy_list(buf, 1); serv_save_config(); - + build_edit_tree(); build_permit_tree(); - + fclose( f ); if ( show_dialog == 1 ) { @@ -2752,7 +2763,7 @@ destroy_dialog(NULL, importdialog); importdialog = NULL; } - + g_free(buf); g_free(first); }
--- a/src/gaim.h Tue Aug 15 16:20:27 2000 +0000 +++ b/src/gaim.h Tue Aug 15 17:02:00 2000 +0000 @@ -393,7 +393,7 @@ #define TYPE_SIGNOFF 4 #define TYPE_KEEPALIVE 5 -#define REVISION "gaim:$Revision: 688 $" +#define REVISION "gaim:$Revision: 694 $" #define FLAPON "FLAPON\r\n\r\n" #define ROAST "Tic/Toc" @@ -570,6 +570,8 @@ extern char *away_subs(char *, char *); extern GtkWidget *picture_button(GtkWidget *, char *, char **); extern GtkWidget *picture_button2(GtkWidget *, char *, char **); +extern void translate_lst (FILE *, char *); +extern void translate_blt (FILE *, char *); /* Functions in server.c */ /* input to serv */
--- a/src/server.c Tue Aug 15 16:20:27 2000 +0000 +++ b/src/server.c Tue Aug 15 17:02:00 2000 +0000 @@ -384,54 +384,33 @@ switch (permdeny) { case PERMIT_ALL: - /* toc_add_permit current_user to go to permit mode, - toc_add_deny <none> to deny none */ sprintf(buf, "toc_add_deny %s", current_user->username); sflap_send(buf, -1, TYPE_DATA); break; case PERMIT_NONE: - /* toc_add_deny current_user to go to deny mode, - toc_add_permit <none> to permit none */ sprintf(buf, "toc_add_permit %s", current_user->username); sflap_send(buf, -1, TYPE_DATA); break; case PERMIT_SOME: - /* toc_add_permit <permit> */ - /* if permit is empty this is the same as PERMIT_NONE */ - if (permit) { - at = g_snprintf(buf, sizeof(buf), "toc_add_permit"); - list = permit; - while (list) { - at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); - list = list->next; - } - buf[at] = 0; /* is this necessary? */ - sflap_send(buf, -1, TYPE_DATA); - } else { - sprintf(buf, "toc_add_deny %s", current_user->username); - sflap_send(buf, -1, TYPE_DATA); - sprintf(buf, "toc_add_permit"); - sflap_send(buf, -1, TYPE_DATA); + at = g_snprintf(buf, sizeof(buf), "toc_add_permit"); + list = permit; + while (list) { + at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); + list = list->next; } + buf[at] = 0; /* is this necessary? */ + sflap_send(buf, -1, TYPE_DATA); break; case DENY_SOME: - /* toc_add_deny <deny> */ - /* if deny is empty this is the same as PERMIT_ALL */ - if (deny) { - at = g_snprintf(buf, sizeof(buf), "toc_add_deny"); - list = deny; - while (list) { - at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); - list = list->next; - } - buf[at] = 0; /* is this necessary? */ - sflap_send(buf, -1, TYPE_DATA); - } else { - sprintf(buf, "toc_add_permit %s", current_user->username); - sflap_send(buf, -1, TYPE_DATA); - sprintf(buf, "toc_add_deny"); - sflap_send(buf, -1, TYPE_DATA); + /* FIXME! This still doesn't work */ + at = g_snprintf(buf, sizeof(buf), "toc_add_deny"); + list = deny; + while (list) { + at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); + list = list->next; } + buf[at] = 0; /* is this necessary? */ + sflap_send(buf, -1, TYPE_DATA); break; } } else { @@ -476,6 +455,8 @@ if (list) at += g_snprintf(&buf[at], sizeof(buf) - at, "&"); } + sprintf(debug_buff, "denying %s\n", buf); + debug_print(debug_buff); aim_bos_changevisibility(gaim_sess, gaim_conn, AIM_VISIBILITYCHANGE_DENYADD, buf); } else {
--- a/src/util.c Tue Aug 15 16:20:27 2000 +0000 +++ b/src/util.c Tue Aug 15 17:02:00 2000 +0000 @@ -971,3 +971,129 @@ return button; } + +/* remove leading whitespace from a string */ +char *remove_spaces (char *str) +{ + int i; + char *new; + + if (str == NULL) + return NULL; + + i = strspn (str, " \t\n\r\f"); + new = &str[i]; + + return new; +} + + +/* translate an AIM 3 buddylist (*.lst) to a GAIM buddylist */ +void translate_lst (FILE *src_fp, char *dest) +{ + char line[BUF_LEN], *line2; + char *name; + int i; + + sprintf (dest, "m 1\n"); + + while (fgets (line, BUF_LEN, src_fp)) { + line2 = remove_spaces (line); + if (strstr (line2, "group") == line2) { + name = strpbrk (line2, " \t\n\r\f") + 1; + strcat (dest, "g "); + for (i = 0; i < strcspn (name, "\n\r"); i++) + if (name[i] != '\"') + strncat (dest, &name[i], 1); + strcat (dest, "\n"); + } + if (strstr (line2, "buddy") == line2) { + name = strpbrk (line2, " \t\n\r\f") + 1; + strcat (dest, "b "); + for (i = 0; i < strcspn (name, "\n\r"); i++) + if (name[i] != '\"') + strncat (dest, &name[i], 1); + strcat (dest, "\n"); + } + } + + return; +} + + +/* translate an AIM 4 buddylist (*.blt) to GAIM format */ +void translate_blt (FILE *src_fp, char *dest) +{ + int i; + char line[BUF_LEN]; + char *buddy; + + sprintf (dest, "m 1\n"); + + while (strstr (fgets (line, BUF_LEN, src_fp), "Buddy") == NULL) ; + while (strstr (fgets (line, BUF_LEN, src_fp), "list") == NULL) ; + + while (1) { + fgets (line, BUF_LEN, src_fp); + if (strchr (line, '}') != NULL) + break; + + /* Syntax starting with "<group> {" */ + if (strchr (line, '{') != NULL) { + strcat (dest, "g "); + buddy = remove_spaces (strtok (line, "{")); + for (i = 0; i < strlen(buddy); i++) { + if (buddy[i] != '\"') + strncat (dest, &buddy[i], 1); + } + strcat (dest, "\n"); + while (strchr (fgets (line, BUF_LEN, src_fp), '}') == NULL) { + buddy = remove_spaces (line); + strcat (dest, "b "); + if (strchr (buddy, '\"') != NULL) { + strncat (dest, &buddy[1], strlen(buddy)-3); + strcat (dest, "\n"); + } else + strcat (dest, buddy); + } + } + /* Syntax "group buddy buddy ..." */ + else { + buddy = remove_spaces (strtok (line, " \n")); + strcat (dest, "g "); + if (strchr (buddy, '\"') != NULL) { + strcat (dest, &buddy[1]); + strcat (dest, " "); + buddy = remove_spaces (strtok (NULL, " \n")); + while (strchr (buddy, '\"') == NULL) { + strcat (dest, buddy); + strcat (dest, " "); + buddy = remove_spaces (strtok (NULL, " \n")); + } + strncat (dest, buddy, strlen(buddy)-1); + } else { + strcat (dest, buddy); + } + strcat (dest, "\n"); + while ((buddy = remove_spaces (strtok (NULL, " \n"))) != NULL) { + strcat (dest, "b "); + if (strchr (buddy, '\"') != NULL) { + strcat (dest, &buddy[1]); + strcat (dest, " "); + buddy = remove_spaces (strtok (NULL, " \n")); + while (strchr (buddy, '\"') == NULL) { + strcat (dest, buddy); + strcat (dest, " "); + buddy = remove_spaces (strtok (NULL, " \n")); + } + strncat (dest, buddy, strlen(buddy)-1); + } else { + strcat (dest, buddy); + } + strcat (dest, "\n"); + } + } + } + + return; +}