# HG changeset patch # User Mark Doliner # Date 1111886081 0 # Node ID 1b927566fcc4328f6d61b1218b747171b26cde7f # Parent 279eee07dd42b48c5a54eadf5befffcffb763625 [gaim-migrate @ 12346] Some lovin' for stuff that isn't compiled by default. committer: Tailor Script diff -r 279eee07dd42 -r 1b927566fcc4 plugins/chkmail.c --- a/plugins/chkmail.c Sun Mar 27 00:33:58 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,199 +0,0 @@ -/* This is some funky code. It is still being developed by Rob Flynn - rob@linuxpimps.com - * I recommend not using this code right now. :) -*/ - -#define GAIM_PLUGINS - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "internal.h" -#include "gtkgaim.h" - -char username[] = ""; -char password[] = ""; -char mailhost[] = ""; -int mailport = 110; -int state = 0; - -static void *handle = NULL; -extern GtkWidget *buddies; - -int lastnum = 0; -int orig = 0; -int mytimer; - -void update_mail(); -void check_mail(); - -int num_msgs() -{ - struct in_addr *sin; - char recv[1024]; - char command[256]; - int fd; - int num = 0; - int step = 0; - int len; - - sin = (struct in_addr *)get_address(mailhost); - fd = connect_address(sin->s_addr, mailport); - while ((len = read(fd, recv, 1023))>0) { - recv[len] = 0; - if (!strncmp(recv, "-ERR", strlen("-ERR"))) { - step = 4; - break; - } else if (!strncmp(recv, "+OK", strlen("+OK"))) { - if (step == 3) { - if (sscanf(recv, "+OK %d %d\n", &num, &step) != 2) - break; - g_snprintf(command, sizeof(command), "QUIT\n"); - write(fd, command, strlen(command)); - close(fd); - return num; - } - - if (step == 0) { - g_snprintf(command, sizeof(command), "USER %s\n", username); - write(fd, command, strlen(command)); - step = 1; - } else if (step == 1) { - g_snprintf(command, sizeof(command), "PASS %s\n", password); - write(fd, command, strlen(command)); - step = 2; - } else if (step == 2) { - g_snprintf(command, sizeof(command), "STAT\n"); - write(fd, command, strlen(command)); - step = 3; - } - } - } - close(fd); - - return 0; -} - -void destroy_mail_list() -{ - GList *list; - GtkWidget *w; - - list = GTK_TREE(buddies)->children; - while (list) { - w = (GtkWidget *)list->data; - if (!strcmp(GTK_LABEL(GTK_BIN(w)->child)->label, _("Mail Server"))) { - gtk_tree_remove_items(GTK_TREE(buddies), list); - list = GTK_TREE(buddies)->children; - if (!list) - break; - } - list = list->next; - } -} - -void setup_mail_list() -{ - GList *list; - GtkWidget *w; - GtkWidget *item; - GtkWidget *tree; - gchar *buf; - - list = GTK_TREE(buddies)->children; - - while (list) { - w = (GtkWidget *)list->data; - if (!strcmp(GTK_LABEL(GTK_BIN(w)->child)->label, _("Mail Server"))) { - gtk_tree_remove_items(GTK_TREE(buddies), list); - list = GTK_TREE(buddies)->children; - if (!list) - break; - } - list = list->next; - } - - item = gtk_tree_item_new_with_label(_("Mail Server")); - tree = gtk_tree_new(); - gtk_widget_show(item); - gtk_widget_show(tree); - gtk_tree_append(GTK_TREE(buddies), item); - gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), tree); - gtk_tree_item_expand(GTK_TREE_ITEM(item)); - - /* XXX - This needs to use ngettext() */ - buf = g_strdup_printf(_("%s (%d new/%d total)"), mailhost, lastnum - orig, lastnum); - item = gtk_tree_item_new_with_label(buf); - g_free(buf); - - gtk_tree_append(GTK_TREE(tree), item); - gtk_widget_show(item); -} - -void gaim_plugin_init(void *h) { - handle = h; - - orig = num_msgs(); - lastnum = orig; - - gaim_signal_connect(handle, event_blist_update, setup_mail_list, NULL); - setup_mail_list(); - - mytimer = g_timeout_add(30000, check_mail, NULL); -} - -void check_mail() { - pthread_t mail_thread; - pthread_attr_t attr; - - if (state == 0) { - state = 1; - pthread_attr_init(&attr); - pthread_create(&mail_thread, &attr, (void *)&update_mail, NULL); - } -} - -void update_mail () { - int newnum; - - g_source_remove(mytimer); - - newnum = num_msgs(); - - if ((newnum >= lastnum) && (newnum > 0)) { - newnum = newnum - lastnum; - } else { - newnum = 0; - } - - if (newnum < lastnum) { - orig = lastnum; - } - - lastnum = newnum; - mytimer = g_timeout_add(30000, check_mail, NULL); - setup_mail_list(); - state = 0; -} - -void gaim_plugin_remove() { - g_source_remove(mytimer); - while (state == 1) { } - destroy_mail_list(); - handle = NULL; -} - -char *name() { - return _("Check Mail"); -} - -char *description() { - return _("Check email every X seconds.\n"); -} diff -r 279eee07dd42 -r 1b927566fcc4 plugins/filectl.c --- a/plugins/filectl.c Sun Mar 27 00:33:58 2005 +0000 +++ b/plugins/filectl.c Sun Mar 27 01:14:41 2005 +0000 @@ -64,14 +64,13 @@ account = gaim_accounts_find(arg1, arg2); if (account != NULL) /* username found */ - gaim_account_connect(account, gaim_account_get_status(account, "online")); + gaim_account_connect(account); free(arg1); free(arg2); } else if (!strncasecmp(command, "logout", 7)) { GaimAccount *account; - GaimConnection *gc; arg1 = getarg(buffer, 1, 1); arg2 = getarg(buffer, 2, 1); diff -r 279eee07dd42 -r 1b927566fcc4 src/protocols/toc/toc.c --- a/src/protocols/toc/toc.c Sun Mar 27 00:33:58 2005 +0000 +++ b/src/protocols/toc/toc.c Sun Mar 27 01:14:41 2005 +0000 @@ -25,6 +25,7 @@ #include "conversation.h" #include "debug.h" #include "notify.h" +#include "privacy.h" #include "proxy.h" #include "prpl.h" #include "request.h" @@ -559,6 +560,96 @@ return buf; } +static void +parse_toc_buddy_list(GaimAccount *account, char *config) +{ + char *c; + char current[256]; + GList *buddies = NULL; + + if (config == NULL) + return; + + /* skip "CONFIG:" (if it exists) */ + c = strncmp(config + 6 /* sizeof(struct sflap_hdr) */ , "CONFIG:", strlen("CONFIG:")) ? + strtok(config, "\n") : + strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n"); + do { + if (c == NULL) + break; + if (*c == 'g') { + char *utf8 = NULL; + utf8 = gaim_utf8_try_convert(c + 2); + if (utf8 == NULL) { + g_strlcpy(current, _("Invalid Groupname"), sizeof(current)); + } else { + g_strlcpy(current, utf8, sizeof(current)); + g_free(utf8); + } + if (!gaim_find_group(current)) { + GaimGroup *g = gaim_group_new(current); + gaim_blist_add_group(g, NULL); + } + } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/ + char nm[80], sw[388], *a, *utf8 = NULL; + + if ((a = strchr(c + 2, ':')) != NULL) { + *a++ = '\0'; /* nul the : */ + } + + g_strlcpy(nm, c + 2, sizeof(nm)); + if (a) { + utf8 = gaim_utf8_try_convert(a); + if (utf8 == NULL) { + gaim_debug(GAIM_DEBUG_ERROR, "toc blist", + "Failed to convert alias for " + "'%s' to UTF-8\n", nm); + } + } + if (utf8 == NULL) { + sw[0] = '\0'; + } else { + /* This can leave a partial sequence at the end, + * but who cares? */ + g_strlcpy(sw, utf8, sizeof(sw)); + g_free(utf8); + } + + if (!gaim_find_buddy(account, nm)) { + GaimBuddy *b = gaim_buddy_new(account, nm, sw); + GaimGroup *g = gaim_find_group(current); + gaim_blist_add_buddy(b, NULL, g, NULL); + buddies = g_list_append(buddies, b); + } + } else if (*c == 'p') { + gaim_privacy_permit_add(account, c + 2, TRUE); + } else if (*c == 'd') { + gaim_privacy_deny_add(account, c + 2, TRUE); + } else if (!strncmp("toc", c, 3)) { + sscanf(c + strlen(c) - 1, "%d", &account->perm_deny); + gaim_debug(GAIM_DEBUG_MISC, "toc blist", + "permdeny: %d\n", account->perm_deny); + if (account->perm_deny == 0) + account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; + } else if (*c == 'm') { + sscanf(c + 2, "%d", &account->perm_deny); + gaim_debug(GAIM_DEBUG_MISC, "toc blist", + "permdeny: %d\n", account->perm_deny); + if (account->perm_deny == 0) + account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; + } + } while ((c = strtok(NULL, "\n"))); + + if (account->gc) { + if (buddies != NULL) { + serv_add_buddies(account->gc, buddies); + g_list_free(buddies); + } + serv_set_permit_deny(account->gc); + } + g_list_free(buddies); +} + static void toc_callback(gpointer data, gint source, GaimInputCondition condition) { GaimConnection *gc = (GaimConnection *)data; @@ -602,9 +693,9 @@ "Client sends TOC \"toc_signon\" message\n"); /* i hate icq. */ if (username[0] >= '0' && username[0] <= '9') - password = g_strndup(gaim_connection_get_password(connection), 8); + password = g_strndup(gaim_connection_get_password(gc), 8); else - password = g_strdup(gaim_connection_get_password(connection)); + password = g_strdup(gaim_connection_get_password(gc)); g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", AUTH_HOST, AUTH_PORT, gaim_normalize(account, username), roast_password(password), LANGUAGE, REVISION); @@ -684,7 +775,7 @@ g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", AUTH_HOST, AUTH_PORT, gaim_normalize(account, gaim_account_get_username(account)), - roast_password(gaim_connection_get_password(connection)), + roast_password(gaim_connection_get_password(gc)), LANGUAGE, REVISION); if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { gaim_connection_error(gc, _("Disconnected.")); @@ -698,7 +789,7 @@ } } else if (!g_ascii_strcasecmp(c, "CONFIG")) { c = strtok(NULL, ":"); - gaim_blist_parse_toc_buddy_list(account, c); + parse_toc_buddy_list(account, c); } else if (!g_ascii_strcasecmp(c, "NICK")) { /* ignore NICK so that things get imported/exported properly c = strtok(NULL, ":"); diff -r 279eee07dd42 -r 1b927566fcc4 src/protocols/trepia/trepia.c --- a/src/protocols/trepia/trepia.c Sun Mar 27 00:33:58 2005 +0000 +++ b/src/protocols/trepia/trepia.c Sun Mar 27 01:14:41 2005 +0000 @@ -23,6 +23,7 @@ #include "account.h" #include "accountopt.h" +#include "cipher.h" #include "debug.h" #include "notify.h" #include "request.h" @@ -30,7 +31,6 @@ #include "util.h" #include "version.h" -#include "md5.h" #include "profile.h" /* XXX */ @@ -123,7 +123,7 @@ #endif static void -__clear_user_list(TrepiaSession *session) +_clear_user_list(TrepiaSession *session) { GaimBlistNode *gnode, *cnode, *bnode; for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { @@ -152,7 +152,7 @@ #if 0 static char * -__get_mac_address(const char *ip) +_get_mac_address(const char *ip) { char *mac = NULL; #ifndef _WIN32 @@ -484,7 +484,7 @@ } static void -__free_parser_data(gpointer user_data) +_free_parser_data(gpointer user_data) { #if 0 TrepiaParserData *data = user_data; @@ -500,7 +500,7 @@ } static void -__start_element_handler(GMarkupParseContext *context, +_start_element_handler(GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, @@ -522,7 +522,7 @@ } static void -__end_element_handler(GMarkupParseContext *context, const gchar *element_name, +_end_element_handler(GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) { TrepiaParserData *data = user_data; @@ -550,7 +550,7 @@ } static void -__text_handler(GMarkupParseContext *context, const gchar *text, +_text_handler(GMarkupParseContext *context, const gchar *text, gsize text_len, gpointer user_data, GError **error) { TrepiaParserData *data = user_data; @@ -563,15 +563,15 @@ static GMarkupParser accounts_parser = { - __start_element_handler, - __end_element_handler, - __text_handler, + _start_element_handler, + _end_element_handler, + _text_handler, NULL, NULL }; static int -__parse_message(const char *buf, TrepiaMessageType *type, GHashTable **info) +_parse_message(const char *buf, TrepiaMessageType *type, GHashTable **info) { TrepiaParserData *parser_data = g_new0(TrepiaParserData, 1); GMarkupParseContext *context; @@ -582,7 +582,7 @@ parser_data->type = type; context = g_markup_parse_context_new(&accounts_parser, 0, - parser_data, __free_parser_data); + parser_data, _free_parser_data); if (!g_markup_parse_context_parse(context, buf, strlen(buf), NULL)) { g_markup_parse_context_free(context); @@ -625,7 +625,7 @@ account = gaim_connection_get_account(session->gc); - ret = __parse_message(buf, &type, &info); + ret = _parse_message(buf, &type, &info); if (ret == 1) return TRUE; @@ -974,7 +974,7 @@ } static void -__login_cb(gpointer data, gint source, GaimInputCondition cond) +_login_cb(gpointer data, gint source, GaimInputCondition cond) { TrepiaSession *session = data; GaimAccount *account; @@ -983,8 +983,9 @@ char *mac = "00:01:02:03:04:05"; char buf[3]; char md5_password[17]; - md5_state_t st; - md5_byte_t di[16]; + GaimCipher *cipher; + GaimCipherContext *context; + guint8 di[16]; int i; if (source < 0) { @@ -993,7 +994,7 @@ } #if 0 - mac = __get_mac_address(); + mac = _get_mac_address(); #endif session->fd = source; @@ -1002,9 +1003,10 @@ password = gaim_connection_get_password(session->gc); - md5_init(&st); - md5_append(&st, (const md5_byte_t *)password, strlen(password)); - md5_finish(&st, di); + cipher = gaim_ciphers_find_cipher("md5"); + context = gaim_cipher_context_new(cipher, NULL); + gaim_cipher_context_append(context, password, strlen(password)); + gaim_cipher_context_digest(context, sizeof(di), di, NULL); *md5_password = '\0'; @@ -1063,12 +1065,12 @@ session->user_profiles = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL); - __clear_user_list(session); + _clear_user_list(session); gaim_connection_update_progress(gc, _("Connecting"), 0, TREPIA_CONNECT_STEPS); - i = gaim_proxy_connect(account, server, port, __login_cb, session); + i = gaim_proxy_connect(account, server, port, _login_cb, session); if (i != 0) gaim_connection_error(gc, _("Unable to create socket")); @@ -1195,7 +1197,7 @@ "" "", mac, "", TREPIA_VERSION, gaim_account_get_username(account), - gaim_connection_get_password(gc->account)); + gaim_connection_get_password(account->gc)); } static GaimPluginProtocolInfo prpl_info =