You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(106) |
Oct
(334) |
Nov
(246) |
Dec
(145) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(42) |
Feb
(53) |
Mar
(232) |
Apr
(109) |
May
(137) |
Jun
(63) |
Jul
(26) |
Aug
(263) |
Sep
(193) |
Oct
(507) |
Nov
(440) |
Dec
(241) |
2003 |
Jan
(567) |
Feb
(195) |
Mar
(504) |
Apr
(481) |
May
(524) |
Jun
(522) |
Jul
(594) |
Aug
(502) |
Sep
(643) |
Oct
(508) |
Nov
(430) |
Dec
(377) |
2004 |
Jan
(361) |
Feb
(251) |
Mar
(219) |
Apr
(499) |
May
(461) |
Jun
(419) |
Jul
(314) |
Aug
(519) |
Sep
(416) |
Oct
(247) |
Nov
(305) |
Dec
(382) |
2005 |
Jan
(267) |
Feb
(282) |
Mar
(327) |
Apr
(338) |
May
(189) |
Jun
(400) |
Jul
(462) |
Aug
(530) |
Sep
(316) |
Oct
(523) |
Nov
(481) |
Dec
(650) |
2006 |
Jan
(536) |
Feb
(361) |
Mar
(287) |
Apr
(146) |
May
(101) |
Jun
(169) |
Jul
(221) |
Aug
(498) |
Sep
(300) |
Oct
(236) |
Nov
(209) |
Dec
(205) |
2007 |
Jan
(30) |
Feb
(23) |
Mar
(26) |
Apr
(15) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ro...@us...> - 2006-07-23 04:11:24
|
Revision: 16545 Author: roast Date: 2006-07-22 21:11:21 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16545&view=rev Log Message: ----------- xml logger now recognizes and logs message.type="action" Modified Paths: -------------- branches/soc-2006-file-loggers/src/log.c Modified: branches/soc-2006-file-loggers/src/log.c =================================================================== --- branches/soc-2006-file-loggers/src/log.c 2006-07-23 04:10:52 UTC (rev 16544) +++ branches/soc-2006-file-loggers/src/log.c 2006-07-23 04:11:21 UTC (rev 16545) @@ -1085,8 +1085,9 @@ } } - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\"%s auto=\"true\">%s</message>\n", - date, from, recv_from_self ? " self=\"true\"" : "", msg_fixed); + g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\"%s%s auto=\"true\">%s</message>\n", + date, from, recv_from_self ? " self=\"true\"" : "", + gaim_message_is_meify(msg_fixed, -1) ? " type=\"action\"": "", msg_fixed); } else if (type & GAIM_MESSAGE_SEND || type & GAIM_MESSAGE_RECV) { gboolean recv_from_self = FALSE; @@ -1100,8 +1101,9 @@ } } - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\"%s>%s</message>\n", - date, from, recv_from_self ? " self=\"true\"" : "", msg_fixed); + g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\"%s%s>%s</message>\n", + date, from, recv_from_self ? " self=\"true\"" : "", + gaim_message_is_meify(msg_fixed, -1) ? " type=\"action\"": "", msg_fixed); } else { gaim_debug_error("log", "Unhandled message type."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2006-07-23 04:10:58
|
Revision: 16544 Author: roast Date: 2006-07-22 21:10:52 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16544&view=rev Log Message: ----------- made a non-destructive gaim_message_is_meify() that returns the same as gaim_message_meify(), but does not modify the message Modified Paths: -------------- branches/soc-2006-file-loggers/src/util.c branches/soc-2006-file-loggers/src/util.h Modified: branches/soc-2006-file-loggers/src/util.c =================================================================== --- branches/soc-2006-file-loggers/src/util.c 2006-07-23 03:47:07 UTC (rev 16543) +++ branches/soc-2006-file-loggers/src/util.c 2006-07-23 04:10:52 UTC (rev 16544) @@ -4183,7 +4183,7 @@ } } -gboolean gaim_message_meify(char *message, size_t len) +gboolean gaim_message_is_meify(char *message, size_t len) { char *c; gboolean inside_html = FALSE; @@ -4206,11 +4206,29 @@ } if(*c && !g_ascii_strncasecmp(c, "/me ", 4)) { - memmove(c, c+4, len-3); return TRUE; } return FALSE; +} + +gboolean gaim_message_meify(char *message, size_t len) +{ + size_t length; + gboolean is_action; + + if (len == -1) + length = strlen(message); + else + length = len; + + is_action = gaim_message_is_meify(message, length); + + if (is_action) { + memmove(message, message+4, length-3); + } + + return is_action; } char *gaim_text_strip_mnemonic(const char *in) Modified: branches/soc-2006-file-loggers/src/util.h =================================================================== --- branches/soc-2006-file-loggers/src/util.h 2006-07-23 03:47:07 UTC (rev 16543) +++ branches/soc-2006-file-loggers/src/util.h 2006-07-23 04:10:52 UTC (rev 16544) @@ -994,6 +994,16 @@ * @param message The message to check * @param len The message length, or -1 * + * @return TRUE if it starts with /me, otherwise FALSE + */ +gboolean gaim_message_is_meify(char *message, size_t len); + +/** + * Trims the leading "/me " off of the message if it's there. + * + * @param message The message to check + * @param len The message length, or -1 + * * @return TRUE if it starts with /me, and it has been removed, otherwise FALSE */ gboolean gaim_message_meify(char *message, size_t len); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2006-07-23 03:47:14
|
Revision: 16543 Author: roast Date: 2006-07-22 20:47:07 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16543&view=rev Log Message: ----------- removed gaim namespace from message.type for bell and whisper Modified Paths: -------------- branches/soc-2006-file-loggers/src/log.c Modified: branches/soc-2006-file-loggers/src/log.c =================================================================== --- branches/soc-2006-file-loggers/src/log.c 2006-07-23 02:03:19 UTC (rev 16542) +++ branches/soc-2006-file-loggers/src/log.c 2006-07-23 03:47:07 UTC (rev 16543) @@ -1068,10 +1068,10 @@ g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\" gaim:type=\"error\">%s</message>\n", date, from, msg_fixed); } else if (type & GAIM_MESSAGE_WHISPER) { - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\" gaim:type=\"whisper\">%s</message>\n", date, from, msg_fixed); + g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\" type=\"whisper\">%s</message>\n", date, from, msg_fixed); } else if (type & GAIM_MESSAGE_BELL) { - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\" gaim:type=\"bell\">%s</message>\n", date, from, msg_fixed); + g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\" type=\"bell\">%s</message>\n", date, from, msg_fixed); } else if (type & GAIM_MESSAGE_AUTO_RESP && (type & GAIM_MESSAGE_SEND || type & GAIM_MESSAGE_RECV)) { gboolean recv_from_self = FALSE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-07-23 02:03:26
|
Revision: 16542 Author: sadrul Date: 2006-07-22 19:03:19 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16542&view=rev Log Message: ----------- Show the mail-notification checkbox in the account-dialog only if the prpl has support for it. Modified Paths: -------------- trunk/console/gntaccount.c trunk/console/libgnt/gntbox.c trunk/console/libgnt/gntwidget.c trunk/console/libgnt/gntwidget.h Modified: trunk/console/gntaccount.c =================================================================== --- trunk/console/gntaccount.c 2006-07-23 01:40:43 UTC (rev 16541) +++ trunk/console/gntaccount.c 2006-07-23 02:03:19 UTC (rev 16542) @@ -396,6 +396,10 @@ if (dialog->account) gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->newmail), gaim_account_get_check_mail(dialog->account)); + if (!prplinfo || !(prplinfo->options & OPT_PROTO_MAIL_CHECK)) + gnt_widget_set_visible(dialog->newmail, FALSE); + else + gnt_widget_set_visible(dialog->newmail, TRUE); if (dialog->remember == NULL) dialog->remember = gnt_check_box_new(_("Remember password")); Modified: trunk/console/libgnt/gntbox.c =================================================================== --- trunk/console/libgnt/gntbox.c 2006-07-23 01:40:43 UTC (rev 16541) +++ trunk/console/libgnt/gntbox.c 2006-07-23 02:03:19 UTC (rev 16542) @@ -89,6 +89,8 @@ for (iter = box->list; iter; iter = iter->next) { + if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(iter->data), GNT_WIDGET_INVISIBLE)) + continue; gnt_widget_set_position(GNT_WIDGET(iter->data), curx, cury); gnt_widget_get_size(GNT_WIDGET(iter->data), &w, &h); if (box->vertical) @@ -217,6 +219,7 @@ static GntWidget * find_focusable_widget(GntBox *box) { + /* XXX: Make sure the widget is visible? */ if (box->focus == NULL && GNT_WIDGET(box)->parent == NULL) g_list_foreach(box->list, add_to_focus, box); @@ -229,11 +232,17 @@ static void find_next_focus(GntBox *box) { - GList *iter = g_list_find(box->focus, box->active); - if (iter && iter->next) - box->active = iter->next->data; - else if (box->focus) - box->active = box->focus->data; + gpointer last = box->active; + do + { + GList *iter = g_list_find(box->focus, box->active); + if (iter && iter->next) + box->active = iter->next->data; + else if (box->focus) + box->active = box->focus->data; + if (!GNT_WIDGET_IS_FLAG_SET(box->active, GNT_WIDGET_INVISIBLE)) + break; + } while (box->active != last); } static gboolean @@ -564,6 +573,9 @@ int height, width; int x, y; + if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_INVISIBLE)) + continue; + if (GNT_IS_BOX(w)) gnt_box_sync_children(GNT_BOX(w)); Modified: trunk/console/libgnt/gntwidget.c =================================================================== --- trunk/console/libgnt/gntwidget.c 2006-07-23 01:40:43 UTC (rev 16541) +++ trunk/console/libgnt/gntwidget.c 2006-07-23 02:03:19 UTC (rev 16542) @@ -329,6 +329,7 @@ mvwvline(widget->window, 1, widget->priv.width, ' ', widget->priv.height); #endif gnt_screen_release(widget); + GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_INVISIBLE); GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_MAPPED); } @@ -509,3 +510,11 @@ return ret; } +void gnt_widget_set_visible(GntWidget *widget, gboolean set) +{ + if (set) + GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_INVISIBLE); + else + GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_INVISIBLE); +} + Modified: trunk/console/libgnt/gntwidget.h =================================================================== --- trunk/console/libgnt/gntwidget.h 2006-07-23 01:40:43 UTC (rev 16541) +++ trunk/console/libgnt/gntwidget.h 2006-07-23 02:03:19 UTC (rev 16542) @@ -39,6 +39,7 @@ GNT_WIDGET_URGENT = 1 << 7, GNT_WIDGET_GROW_X = 1 << 8, GNT_WIDGET_GROW_Y = 1 << 9, + GNT_WIDGET_INVISIBLE = 1 << 10, } GntWidgetFlags; /* XXX: I'll have to ask grim what he's using this for in guifications. */ @@ -125,6 +126,9 @@ void gnt_widget_queue_update(GntWidget *widget); void gnt_widget_set_take_focus(GntWidget *widget, gboolean set); + +void gnt_widget_set_visible(GntWidget *widget, gboolean set); + G_END_DECLS #endif /* GNT_WIDGET_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2006-07-23 01:40:49
|
Revision: 16541 Author: roast Date: 2006-07-22 18:40:43 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16541&view=rev Log Message: ----------- fixed gaim_ulf parsing function. it was barfing if a corresponding required closing tag wasn't there. Modified Paths: -------------- branches/soc-2006-file-loggers/src/util.c Modified: branches/soc-2006-file-loggers/src/util.c =================================================================== --- branches/soc-2006-file-loggers/src/util.c 2006-07-23 01:10:06 UTC (rev 16540) +++ branches/soc-2006-file-loggers/src/util.c 2006-07-23 01:40:43 UTC (rev 16541) @@ -1547,6 +1547,20 @@ } c = p; } + // we can't only be expecting "</chat>". + // let's move on by clobbering the tag and, if it's exists, the newline + else { + const char *p = c; + while (*p && *p != '>') { + p++; + } + if (*p == '>') { + p++; + if (*p == '\n') + p++; + } + c = p; + } } else { /* opening tag */ if(!g_ascii_strncasecmp(c, "<?xml", 5)) { const char *p = c; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-07-23 01:10:22
|
Revision: 16540 Author: sadrul Date: 2006-07-22 18:10:06 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16540&view=rev Log Message: ----------- Complete the notify-ui. I have been unable to test the searchresult-ui. But "looks like" it will work. The accounts-ui is also mostly . I am yet to add the proxy-options. And you cannot still delete an account. That will happen after the request-ui is complete. The account-edit dialog needs some work, but it's usable. Added GntCheckBox, and add some features to some other gnt-widgets. Modified Paths: -------------- trunk/console/gntaccount.c trunk/console/gntaccount.h trunk/console/gntnotify.c trunk/console/libgnt/Makefile.am trunk/console/libgnt/gntbutton.c trunk/console/libgnt/gntcombobox.c trunk/console/libgnt/gntcombobox.h trunk/console/libgnt/gntentry.c trunk/console/libgnt/gntentry.h trunk/console/libgnt/gnttree.c trunk/console/libgnt/gnttree.h trunk/console/libgnt/gntwidget.c trunk/console/libgnt/test/combo.c Added Paths: ----------- trunk/console/libgnt/gntcheckbox.c trunk/console/libgnt/gntcheckbox.h Modified: trunk/console/gntaccount.c =================================================================== --- trunk/console/gntaccount.c 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/gntaccount.c 2006-07-23 01:10:06 UTC (rev 16540) @@ -1,6 +1,7 @@ #include <gnt.h> #include <gntbox.h> #include <gntbutton.h> +#include <gntcheckbox.h> #include <gntcombobox.h> #include <gntentry.h> #include <gntlabel.h> @@ -17,6 +18,8 @@ #include "gntaccount.h" #include "gntgaim.h" +#include <string.h> + typedef struct { GntWidget *window; @@ -38,17 +41,157 @@ GntWidget *splits; GList *split_entries; + + GList *prpl_entries; + GntWidget *prpls; + + GntWidget *newmail; + GntWidget *remember; } AccountEditDialog; static void +account_add(GaimAccount *account) +{ + gnt_tree_add_choice(GNT_TREE(accounts.tree), account, + gnt_tree_create_row(GNT_TREE(accounts.tree), + gaim_account_get_username(account), + gaim_account_get_protocol_name(account)), + NULL, NULL); + gnt_tree_set_choice(GNT_TREE(accounts.tree), account, + gaim_account_get_enabled(account, GAIM_GNT_UI)); +} + +static void edit_dialog_destroy(AccountEditDialog *dialog) { + g_list_free(dialog->prpl_entries); + g_list_free(dialog->split_entries); g_free(dialog); } static void save_account_cb(AccountEditDialog *dialog) { + GaimAccount *account; + GaimPlugin *plugin; + GaimPluginProtocolInfo *prplinfo; + const char *value; + GString *username; + + /* XXX: Do some error checking first. */ + + plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); + prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plugin); + + /* Screenname && user-splits */ + value = gnt_entry_get_text(GNT_ENTRY(dialog->screenname)); + + if (value == NULL || *value == '\0') + { + gaim_notify_error(NULL, _("Error"), _("Account was not added"), + _("Screenname of an account must be non-empty.")); + return; + } + + username = g_string_new(value); + + if (prplinfo != NULL) + { + GList *iter, *entries; + for (iter = prplinfo->user_splits, entries = dialog->split_entries; + iter && entries; iter = iter->next, entries = entries->next) + { + GaimAccountUserSplit *split = iter->data; + GntWidget *entry = entries->data; + + value = gnt_entry_get_text(GNT_ENTRY(entry)); + if (value == NULL || *value == '\0') + value = gaim_account_user_split_get_default_value(split); + g_string_append_printf(username, "%c%s", + gaim_account_user_split_get_separator(split), + value); + } + } + + if (dialog->account == NULL) + { + account = gaim_account_new(username->str, gaim_plugin_get_id(plugin)); + gaim_accounts_add(account); + } + else + { + account = dialog->account; + + /* Protocol */ + gaim_account_set_protocol_id(account, gaim_plugin_get_id(plugin)); + gaim_account_set_username(account, username->str); + } + g_string_free(username, TRUE); + + /* Alias */ + value = gnt_entry_get_text(GNT_ENTRY(dialog->alias)); + if (value && *value) + gaim_account_set_alias(account, value); + + /* Remember password and password */ + gaim_account_set_remember_password(account, + gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->remember))); + value = gnt_entry_get_text(GNT_ENTRY(dialog->password)); + if (value && *value && gaim_account_get_remember_password(account)) + gaim_account_set_password(account, value); + else + gaim_account_set_password(account, NULL); + + /* Mail notification */ + /* XXX: Only if the protocol has anything to do with emails */ + gaim_account_set_check_mail(account, + gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->newmail))); + + /* Protocol options */ + if (prplinfo) + { + GList *iter, *entries; + + for (iter = prplinfo->protocol_options, entries = dialog->prpl_entries; + iter && entries; iter = iter->next, entries = entries->next) + { + GaimAccountOption *option = iter->data; + GntWidget *entry = entries->data; + GaimPrefType type = gaim_account_option_get_type(option); + const char *setting = gaim_account_option_get_setting(option); + + if (type == GAIM_PREF_STRING) + { + const char *value = gnt_entry_get_text(GNT_ENTRY(entry)); + gaim_account_set_string(account, setting, value); + } + else if (type == GAIM_PREF_INT) + { + const char *str = gnt_entry_get_text(GNT_ENTRY(entry)); + int value = 0; + if (str) + value = atoi(str); + gaim_account_set_int(account, setting, value); + } + else if (type == GAIM_PREF_BOOLEAN) + { + gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(entry)); + gaim_account_set_bool(account, setting, value); + } + else if (type == GAIM_PREF_STRING_LIST) + { + /* TODO: */ + } + else + { + g_assert_not_reached(); + } + } + } + + /* XXX: Proxy options */ + + gnt_widget_destroy(dialog->window); } static void @@ -57,7 +200,7 @@ GntWidget *hbox; GaimPlugin *plugin; GaimPluginProtocolInfo *prplinfo; - GList *iter; + GList *iter, *entries; char *username = NULL; if (dialog->splits) @@ -99,20 +242,180 @@ g_free(buf); } - /* XXX: Add default/custom values to the splits */ + for (iter = g_list_last(prplinfo->user_splits), entries = g_list_last(dialog->split_entries); + iter && entries; iter = iter->prev, entries = entries->prev) + { + GntWidget *entry = entries->data; + GaimAccountUserSplit *split = iter->data; + const char *value = NULL; + char *s; + + if (dialog->account) + { + s = strrchr(username, gaim_account_user_split_get_separator(split)); + if (s != NULL) + { + *s = '\0'; + s++; + value = s; + } + } + if (value == NULL) + value = gaim_account_user_split_get_default_value(split); + + if (value != NULL) + gnt_entry_set_text(GNT_ENTRY(entry), value); + } + + if (username != NULL) + gnt_entry_set_text(GNT_ENTRY(dialog->screenname), username); + g_free(username); } static void +add_protocol_options(AccountEditDialog *dialog) +{ + GaimPlugin *plugin; + GaimPluginProtocolInfo *prplinfo; + GList *iter; + GntWidget *vbox, *box; + GaimAccount *account; + + if (dialog->prpls) + gnt_box_remove_all(GNT_BOX(dialog->prpls)); + else + { + dialog->prpls = vbox = gnt_vbox_new(FALSE); + gnt_box_set_pad(GNT_BOX(vbox), 0); + gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_LEFT); + gnt_box_set_fill(GNT_BOX(vbox), TRUE); + } + + if (dialog->prpl_entries) + { + g_list_free(dialog->prpl_entries); + dialog->prpl_entries = NULL; + } + + vbox = dialog->prpls; + + plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); + if (!plugin) + return; + + prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plugin); + + account = dialog->account; + + for (iter = prplinfo->protocol_options; iter; iter = iter->next) + { + GaimAccountOption *option = iter->data; + GaimPrefType type = gaim_account_option_get_type(option); + + box = gnt_hbox_new(TRUE); + gnt_box_set_pad(GNT_BOX(box), 0); + gnt_box_add_widget(GNT_BOX(vbox), box); + + if (type == GAIM_PREF_BOOLEAN) + { + GntWidget *widget = gnt_check_box_new(gaim_account_option_get_text(option)); + gnt_box_add_widget(GNT_BOX(box), widget); + dialog->prpl_entries = g_list_append(dialog->prpl_entries, widget); + + if (account) + gnt_check_box_set_checked(GNT_CHECK_BOX(widget), + gaim_account_get_bool(account, + gaim_account_option_get_setting(option), + gaim_account_option_get_default_bool(option))); + else + gnt_check_box_set_checked(GNT_CHECK_BOX(widget), + gaim_account_option_get_default_bool(option)); + } + else + { + gnt_box_add_widget(GNT_BOX(box), + gnt_label_new(gaim_account_option_get_text(option))); + + if (type == GAIM_PREF_STRING_LIST) + { + /* TODO: Use a combobox */ + /* Don't forget to append the widget to prpl_entries */ + } + else + { + GntWidget *entry = gnt_entry_new(NULL); + gnt_box_add_widget(GNT_BOX(box), entry); + dialog->prpl_entries = g_list_append(dialog->prpl_entries, entry); + + if (type == GAIM_PREF_STRING) + { + const char *dv = gaim_account_option_get_default_string(option); + + if (account) + gnt_entry_set_text(GNT_ENTRY(entry), + gaim_account_get_string(account, + gaim_account_option_get_setting(option), dv)); + else + gnt_entry_set_text(GNT_ENTRY(entry), dv); + } + else if (type == GAIM_PREF_INT) + { + char str[32]; + int value = gaim_account_option_get_default_int(option); + if (account) + value = gaim_account_get_int(account, + gaim_account_option_get_setting(option), value); + snprintf(str, sizeof(str), "%d", value); + gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT); + gnt_entry_set_text(GNT_ENTRY(entry), str); + } + else + { + g_assert_not_reached(); + } + } + } + } +} + +static void +update_user_options(AccountEditDialog *dialog) +{ + GaimPlugin *plugin; + GaimPluginProtocolInfo *prplinfo; + + plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); + if (!plugin) + return; + + prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plugin); + + if (dialog->newmail == NULL) + dialog->newmail = gnt_check_box_new(_("New mail notifications")); + if (dialog->account) + gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->newmail), + gaim_account_get_check_mail(dialog->account)); + + if (dialog->remember == NULL) + dialog->remember = gnt_check_box_new(_("Remember password")); + if (dialog->account) + gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->remember), + gaim_account_get_remember_password(dialog->account)); +} + +static void prpl_changed_cb(GntWidget *combo, GaimPlugin *old, GaimPlugin *new, AccountEditDialog *dialog) { update_user_splits(dialog); + add_protocol_options(dialog); + update_user_options(dialog); /* This may not be necessary here */ gnt_box_readjust(GNT_BOX(dialog->window)); gnt_widget_draw(dialog->window); } static void -add_account(GntWidget *b, gpointer null) +edit_account(GaimAccount *account) { GntWidget *window, *hbox; GntWidget *combo, *button, *entry; @@ -122,8 +425,9 @@ dialog = g_new0(AccountEditDialog, 1); dialog->window = window = gnt_box_new(FALSE, TRUE); + dialog->account = account; gnt_box_set_toplevel(GNT_BOX(window), TRUE); - gnt_box_set_title(GNT_BOX(window), _("New Account")); + gnt_box_set_title(GNT_BOX(window), account ? _("Modify Account") : _("New Account")); gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); gnt_box_set_pad(GNT_BOX(window), 0); @@ -138,6 +442,12 @@ gnt_combo_box_add_data(GNT_COMBO_BOX(combo), iter->data, ((GaimPlugin*)iter->data)->info->name); } + if (account) + gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), + gaim_plugins_find_with_id(gaim_account_get_protocol_id(account))); + else + gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), list->data); + g_signal_connect(G_OBJECT(combo), "selection-changed", G_CALLBACK(prpl_changed_cb), dialog); gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Protocol:"))); gnt_box_add_widget(GNT_BOX(hbox), combo); @@ -157,8 +467,11 @@ gnt_box_add_widget(GNT_BOX(window), hbox); dialog->password = entry = gnt_entry_new(NULL); + gnt_entry_set_masked(GNT_ENTRY(entry), TRUE); gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Password:"))); gnt_box_add_widget(GNT_BOX(hbox), entry); + if (account) + gnt_entry_set_text(GNT_ENTRY(entry), gaim_account_get_password(account)); hbox = gnt_box_new(TRUE, FALSE); gnt_box_add_widget(GNT_BOX(window), hbox); @@ -166,9 +479,23 @@ dialog->alias = entry = gnt_entry_new(NULL); gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Alias:"))); gnt_box_add_widget(GNT_BOX(hbox), entry); + if (account) + gnt_entry_set_text(GNT_ENTRY(entry), gaim_account_get_alias(account)); + /* User options */ + update_user_options(dialog); + gnt_box_add_widget(GNT_BOX(window), dialog->remember); + gnt_box_add_widget(GNT_BOX(window), dialog->newmail); + gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); - + + /* The advanced box */ + add_protocol_options(dialog); + gnt_box_add_widget(GNT_BOX(window), dialog->prpls); + + /* TODO: Add proxy options */ + + /* The button box */ hbox = gnt_box_new(FALSE, FALSE); gnt_box_add_widget(GNT_BOX(window), hbox); @@ -183,9 +510,33 @@ g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(edit_dialog_destroy), dialog); gnt_widget_show(window); + gnt_box_readjust(GNT_BOX(window)); + gnt_widget_draw(window); } static void +add_account_cb(GntWidget *widget, gpointer null) +{ + edit_account(NULL); +} + +static void +modify_account_cb(GntWidget *widget, GntTree *tree) +{ + GaimAccount *account = gnt_tree_get_selection_data(tree); + if (!account) + return; + edit_account(account); +} + +static void +delete_account_cb(GntWidget *widget, GntTree *tree) +{ + /* XXX: After the request-api is complete */ + /* Note: remove the modify-dialog for the account */ +} + +static void account_toggled(GntWidget *widget, void *key, gpointer null) { GaimAccount *account = key; @@ -193,7 +544,7 @@ gaim_account_set_enabled(account, GAIM_GNT_UI, gnt_tree_get_choice(GNT_TREE(widget), key)); } -void gg_accounts_init() +void gg_accounts_show_all() { GList *iter; GntWidget *box, *button; @@ -216,14 +567,7 @@ for (iter = gaim_accounts_get_all(); iter; iter = iter->next) { GaimAccount *account = iter->data; - - gnt_tree_add_choice(GNT_TREE(accounts.tree), account, - gnt_tree_create_row(GNT_TREE(accounts.tree), - gaim_account_get_username(account), - gaim_account_get_protocol_name(account)), - NULL, NULL); - gnt_tree_set_choice(GNT_TREE(accounts.tree), account, - gaim_account_get_enabled(account, GAIM_GNT_UI)); + account_add(account); } g_signal_connect(G_OBJECT(accounts.tree), "toggled", G_CALLBACK(account_toggled), NULL); @@ -238,19 +582,59 @@ button = gnt_button_new(_("Add")); gnt_box_add_widget(GNT_BOX(box), button); - g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(add_account), NULL); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(add_account_cb), NULL); button = gnt_button_new(_("Modify")); gnt_box_add_widget(GNT_BOX(box), button); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(modify_account_cb), accounts.tree); button = gnt_button_new(_("Delete")); gnt_box_add_widget(GNT_BOX(box), button); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(delete_account_cb), accounts.tree); gnt_box_add_widget(GNT_BOX(accounts.window), box); gnt_widget_show(accounts.window); } +static gpointer +gg_accounts_get_handle() +{ + static int handle; + + return &handle; +} + +static void +account_added_callback(GaimAccount *account) +{ + if (accounts.window == NULL) + return; + account_add(account); + gnt_widget_draw(accounts.tree); +} + +static void +account_removed_callback(GaimAccount *account) +{ + if (accounts.window == NULL) + return; + + gnt_tree_remove(GNT_TREE(accounts.tree), account); +} + +void gg_accounts_init() +{ + gaim_signal_connect(gaim_accounts_get_handle(), "account-added", + gg_accounts_get_handle(), GAIM_CALLBACK(account_added_callback), + NULL); + gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", + gg_accounts_get_handle(), GAIM_CALLBACK(account_removed_callback), + NULL); + + gg_accounts_show_all(); +} + void gg_accounts_uninit() { gnt_widget_destroy(accounts.window); Modified: trunk/console/gntaccount.h =================================================================== --- trunk/console/gntaccount.h 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/gntaccount.h 2006-07-23 01:10:06 UTC (rev 16540) @@ -5,3 +5,6 @@ void gg_accounts_init(); void gg_accounts_uninit(); + +void gg_accounts_show_all(); + Modified: trunk/console/gntnotify.c =================================================================== --- trunk/console/gntnotify.c 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/gntnotify.c 2006-07-23 01:10:06 UTC (rev 16540) @@ -57,7 +57,13 @@ /* handle is, in all/most occasions, a GntWidget * */ static void gg_close_notify(GaimNotifyType type, void *handle) { - gnt_widget_destroy(GNT_WIDGET(handle)); + GntWidget *widget = handle; + while (widget->parent) + widget = widget->parent; + + if (type == GAIM_NOTIFY_SEARCHRESULTS) + gaim_notify_searchresults_free(g_object_get_data(handle, "notify-results")); + gnt_widget_destroy(widget); } static void *gg_notify_formatted(const char *title, const char *primary, @@ -180,6 +186,112 @@ return ui_handle; } +static void +notify_button_activated(GntWidget *widget, GaimNotifySearchButton *b) +{ + GList *list = NULL; + GaimAccount *account = g_object_get_data(G_OBJECT(widget), "notify-account"); + gpointer data = g_object_get_data(G_OBJECT(widget), "notify-data"); + + list = gnt_tree_get_selection_text_list(GNT_TREE(widget)); + + b->callback(gaim_account_get_connection(account), list, data); + g_list_foreach(list, (GFunc)g_free, NULL); + g_list_free(list); +} + +static void +gg_notify_sr_new_rows(GaimConnection *gc, + GaimNotifySearchResults *results, void *data) +{ + GntTree *tree = GNT_TREE(data); + GList *o; + + /* XXX: Do I need to empty the tree here? */ + + for (o = results->rows; o; o = o->next) + { + gnt_tree_add_row_after(GNT_TREE(tree), o->data, + gnt_tree_create_row_from_list(GNT_TREE(tree), o->data), + NULL, NULL); + } +} + +static void * +gg_notify_searchresults(GaimConnection *gc, const char *title, + const char *primary, const char *secondary, + GaimNotifySearchResults *results, gpointer data) +{ + GntWidget *window, *tree, *box, *button; + GList *iter; + + window = gnt_vbox_new(FALSE); + gnt_box_set_toplevel(GNT_BOX(window), TRUE); + gnt_box_set_title(GNT_BOX(window), title); + gnt_box_set_fill(GNT_BOX(window), FALSE); + gnt_box_set_pad(GNT_BOX(window), 0); + gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); + + gnt_box_add_widget(GNT_BOX(window), + gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD)); + gnt_box_add_widget(GNT_BOX(window), + gnt_label_new_with_format(secondary, GNT_TEXT_FLAG_NORMAL)); + + tree = gnt_tree_new_with_columns(g_list_length(results->columns)); + gnt_tree_set_show_title(GNT_TREE(tree), TRUE); + gnt_box_add_widget(GNT_BOX(window), tree); + + box = gnt_hbox_new(TRUE); + + for (iter = results->buttons; iter; iter = iter->next) + { + GaimNotifySearchButton *b = iter->data; + const char *text; + + switch (b->type) + { + case GAIM_NOTIFY_BUTTON_LABELED: + text = b->label; + break; + case GAIM_NOTIFY_BUTTON_CONTINUE: + text = _("Continue"); + break; + case GAIM_NOTIFY_BUTTON_ADD: + text = _("Add"); + break; + case GAIM_NOTIFY_BUTTON_INFO: + text = _("Info"); + break; + case GAIM_NOTIFY_BUTTON_IM: + text = _("IM"); + break; + case GAIM_NOTIFY_BUTTON_JOIN: + text = _("Join"); + break; + case GAIM_NOTIFY_BUTTON_INVITE: + text = _("Invite"); + break; + } + + button = gnt_button_new(text); + g_object_set_data(G_OBJECT(button), "notify-account", gaim_connection_get_account(gc)); + g_object_set_data(G_OBJECT(button), "notify-data", data); + g_signal_connect_swapped(G_OBJECT(button), "activate", + G_CALLBACK(notify_button_activated), b); + + gnt_box_add_widget(GNT_BOX(box), button); + } + + gnt_box_add_widget(GNT_BOX(window), box); + + gg_notify_sr_new_rows(gc, results, tree); + + gnt_widget_show(window); + g_object_set_data(G_OBJECT(window), "notify-results", results); + + return tree; +} + static GaimNotifyUiOps ops = { .notify_message = gg_notify_message, @@ -190,8 +302,8 @@ .notify_emails = gg_notify_emails, .notify_userinfo = gg_notify_userinfo, - .notify_searchresults = NULL, /* We are going to need multi-column GntTree's for this */ - .notify_searchresults_new_rows = NULL, + .notify_searchresults = gg_notify_searchresults, + .notify_searchresults_new_rows = gg_notify_sr_new_rows, .notify_uri = NULL /* This is of low-priority to me */ }; Modified: trunk/console/libgnt/Makefile.am =================================================================== --- trunk/console/libgnt/Makefile.am 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/libgnt/Makefile.am 2006-07-23 01:10:06 UTC (rev 16540) @@ -7,6 +7,7 @@ gntwidget.c \ gntbox.c \ gntbutton.c \ + gntcheckbox.c \ gntcolors.c \ gntcombobox.c \ gntentry.c \ @@ -21,6 +22,7 @@ gntwidget.h \ gntbox.h \ gntbutton.h \ + gntcheckbox.h \ gntcolors.h \ gntcombobox.h \ gntentry.h \ Modified: trunk/console/libgnt/gntbutton.c =================================================================== --- trunk/console/libgnt/gntbutton.c 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/libgnt/gntbutton.c 2006-07-23 01:10:06 UTC (rev 16540) @@ -22,7 +22,7 @@ type = GNT_COLOR_NORMAL; wbkgdset(widget->window, '\0' | COLOR_PAIR(type)); - mvwprintw(widget->window, 1, 1, button->priv->text); + mvwprintw(widget->window, 1, 2, button->priv->text); DEBUG; } @@ -31,8 +31,10 @@ gnt_button_size_request(GntWidget *widget) { GntButton *button = GNT_BUTTON(widget); - widget->priv.width = g_utf8_strlen(button->priv->text, -1) + 2; - widget->priv.height = 3; + widget->priv.width = g_utf8_strlen(button->priv->text, -1) + 4; + widget->priv.height = 1; + if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_SHADOW)) + widget->priv.height += 2; } static void Added: trunk/console/libgnt/gntcheckbox.c =================================================================== --- trunk/console/libgnt/gntcheckbox.c (rev 0) +++ trunk/console/libgnt/gntcheckbox.c 2006-07-23 01:10:06 UTC (rev 16540) @@ -0,0 +1,153 @@ +#include "gntcheckbox.h" + +enum +{ + SIG_TOGGLED = 1, + SIGS, +}; + +static GntButtonClass *parent_class = NULL; +static guint signals[SIGS] = { 0 }; + +static void +gnt_check_box_draw(GntWidget *widget) +{ + GntCheckBox *cb = GNT_CHECK_BOX(widget); + GntColorType type; + char *text; + + if (gnt_widget_has_focus(widget)) + type = GNT_COLOR_HIGHLIGHT; + else + type = GNT_COLOR_NORMAL; + + wbkgdset(widget->window, '\0' | COLOR_PAIR(type)); + + text = g_strdup_printf("[%c]", cb->checked ? 'X' : ' '); + mvwprintw(widget->window, 0, 0, text); + g_free(text); + + wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); + mvwprintw(widget->window, 0, 4, GNT_BUTTON(cb)->priv->text); + + DEBUG; +} + +static void +gnt_check_box_size_request(GntWidget *widget) +{ +} + +static void +gnt_check_box_map(GntWidget *widget) +{ + if (widget->priv.width == 0 || widget->priv.height == 0) + gnt_widget_size_request(widget); + DEBUG; +} + +static gboolean +gnt_check_box_key_pressed(GntWidget *widget, const char *text) +{ + if (text[0] == ' ' && text[1] == '\0') + { + GNT_CHECK_BOX(widget)->checked = !GNT_CHECK_BOX(widget)->checked; + g_signal_emit(widget, signals[SIG_TOGGLED], 0); + gnt_widget_draw(widget); + return TRUE; + } + + return FALSE; +} + +static void +gnt_check_box_destroy(GntWidget *widget) +{ +} + +static void +gnt_check_box_class_init(GntCheckBoxClass *klass) +{ + GntWidgetClass *wclass = GNT_WIDGET_CLASS(klass); + + parent_class = GNT_BUTTON_CLASS(klass); + /*parent_class->destroy = gnt_check_box_destroy;*/ + wclass->draw = gnt_check_box_draw; + /*parent_class->map = gnt_check_box_map;*/ + /*parent_class->size_request = gnt_check_box_size_request;*/ + wclass->key_pressed = gnt_check_box_key_pressed; + + signals[SIG_TOGGLED] = + g_signal_new("toggled", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(GntCheckBoxClass, toggled), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + DEBUG; +} + +static void +gnt_check_box_init(GTypeInstance *instance, gpointer class) +{ + GNT_WIDGET_SET_FLAGS(GNT_WIDGET(instance), GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); + DEBUG; +} + +/****************************************************************************** + * GntCheckBox API + *****************************************************************************/ +GType +gnt_check_box_get_gtype(void) +{ + static GType type = 0; + + if(type == 0) + { + static const GTypeInfo info = { + sizeof(GntCheckBoxClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc)gnt_check_box_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GntCheckBox), + 0, /* n_preallocs */ + gnt_check_box_init, /* instance_init */ + }; + + type = g_type_register_static(GNT_TYPE_BUTTON, + "GntCheckBox", + &info, 0); + } + + return type; +} + +GntWidget *gnt_check_box_new(const char *text) +{ + GntWidget *widget = g_object_new(GNT_TYPE_CHECK_BOX, NULL); + + GNT_BUTTON(widget)->priv->text = g_strdup(text); + gnt_widget_set_take_focus(widget, TRUE); + + return widget; +} + +void gnt_check_box_set_checked(GntCheckBox *box, gboolean set) +{ + if (set != box->checked) + { + box->checked = set; + g_signal_emit(box, signals[SIG_TOGGLED], 0); + } +} + +gboolean gnt_check_box_get_checked(GntCheckBox *box) +{ + return box->checked; +} + + + Property changes on: trunk/console/libgnt/gntcheckbox.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: trunk/console/libgnt/gntcheckbox.h =================================================================== --- trunk/console/libgnt/gntcheckbox.h (rev 0) +++ trunk/console/libgnt/gntcheckbox.h 2006-07-23 01:10:06 UTC (rev 16540) @@ -0,0 +1,54 @@ +#ifndef GNT_CHECK_BOX_H +#define GNT_CHECK_BOX_H + +#include "gntbutton.h" +#include "gnt.h" +#include "gntcolors.h" +#include "gntkeys.h" + +#define GNT_TYPE_CHECK_BOX (gnt_check_box_get_gtype()) +#define GNT_CHECK_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_CHECK_BOX, GntCheckBox)) +#define GNT_CHECK_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_CHECK_BOX, GntCheckBoxClass)) +#define GNT_IS_CHECK_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_CHECK_BOX)) +#define GNT_IS_CHECK_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_CHECK_BOX)) +#define GNT_CHECK_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_CHECK_BOX, GntCheckBoxClass)) + +#define GNT_CHECK_BOX_FLAGS(obj) (GNT_CHECK_BOX(obj)->priv.flags) +#define GNT_CHECK_BOX_SET_FLAGS(obj, flags) (GNT_CHECK_BOX_FLAGS(obj) |= flags) +#define GNT_CHECK_BOX_UNSET_FLAGS(obj, flags) (GNT_CHECK_BOX_FLAGS(obj) &= ~(flags)) + +typedef struct _GnCheckBox GntCheckBox; +typedef struct _GnCheckBoxPriv GntCheckBoxPriv; +typedef struct _GnCheckBoxClass GntCheckBoxClass; + +struct _GnCheckBox +{ + GntButton parent; + gboolean checked; +}; + +struct _GnCheckBoxClass +{ + GntButtonClass parent; + + void (*toggled)(void); + + void (*gnt_reserved1)(void); + void (*gnt_reserved2)(void); + void (*gnt_reserved3)(void); + void (*gnt_reserved4)(void); +}; + +G_BEGIN_DECLS + +GType gnt_check_box_get_gtype(void); + +GntWidget *gnt_check_box_new(const char *text); + +void gnt_check_box_set_checked(GntCheckBox *box, gboolean set); + +gboolean gnt_check_box_get_checked(GntCheckBox *box); + +G_END_DECLS + +#endif /* GNT_CHECK_BOX_H */ Property changes on: trunk/console/libgnt/gntcheckbox.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Modified: trunk/console/libgnt/gntcombobox.c =================================================================== --- trunk/console/libgnt/gntcombobox.c 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/libgnt/gntcombobox.c 2006-07-23 01:10:06 UTC (rev 16540) @@ -20,10 +20,14 @@ { if (box->selected != key) { + /* XXX: make sure the key actually does exist */ gpointer old = box->selected; box->selected = key; g_signal_emit(box, signals[SIG_SELECTION_CHANGED], 0, old, key); - gnt_widget_draw(GNT_WIDGET(box)); + if (GNT_WIDGET(box)->window) + gnt_widget_draw(GNT_WIDGET(box)); + if (box->dropdown) + gnt_tree_set_selected(GNT_TREE(box->dropdown), key); } } @@ -246,3 +250,8 @@ return box->selected; } +void gnt_combo_box_set_selected(GntComboBox *box, gpointer key) +{ + set_selection(box, key); +} + Modified: trunk/console/libgnt/gntcombobox.h =================================================================== --- trunk/console/libgnt/gntcombobox.h 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/libgnt/gntcombobox.h 2006-07-23 01:10:06 UTC (rev 16540) @@ -50,6 +50,8 @@ gpointer gnt_combo_box_get_selected_data(GntComboBox *box); +void gnt_combo_box_set_selected(GntComboBox *box, gpointer key); + G_END_DECLS #endif /* GNT_COMBO_BOX_H */ Modified: trunk/console/libgnt/gntentry.c =================================================================== --- trunk/console/libgnt/gntentry.c 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/libgnt/gntentry.c 2006-07-23 01:10:06 UTC (rev 16540) @@ -21,8 +21,15 @@ wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TEXT_NORMAL)); else wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D)); - mvwprintw(widget->window, 0, 0, entry->scroll); + if (entry->masked) + { + mvwhline(widget->window, 0, 0, gnt_ascii_only() ? '*' : ACS_BULLET, + entry->end - entry->scroll); + } + else + mvwprintw(widget->window, 0, 0, entry->scroll); + stop = entry->end - entry->scroll; if (stop < widget->priv.width) mvwhline(widget->window, 0, stop, ENTRY_CHAR, widget->priv.width - stop); @@ -283,4 +290,8 @@ entry_redraw(GNT_WIDGET(entry)); } +void gnt_entry_set_masked(GntEntry *entry, gboolean set) +{ + entry->masked = set; +} Modified: trunk/console/libgnt/gntentry.h =================================================================== --- trunk/console/libgnt/gntentry.h 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/libgnt/gntentry.h 2006-07-23 01:10:06 UTC (rev 16540) @@ -49,6 +49,7 @@ size_t buffer; /* Size of the buffer */ int max; /* 0 means infinite */ + gboolean masked; }; struct _GnEntryClass @@ -78,6 +79,8 @@ void gnt_entry_clear(GntEntry *entry); +void gnt_entry_set_masked(GntEntry *entry, gboolean set); + G_END_DECLS #endif /* GNT_ENTRY_H */ Modified: trunk/console/libgnt/gnttree.c =================================================================== --- trunk/console/libgnt/gnttree.c 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/libgnt/gnttree.c 2006-07-23 01:10:06 UTC (rev 16540) @@ -278,7 +278,11 @@ x += tree->columns[i].width; } if (pos) + { tree_mark_columns(tree, pos, 0, ACS_TTEE | COLOR_PAIR(GNT_COLOR_NORMAL)); + tree_mark_columns(tree, pos, widget->priv.height - pos, + ACS_BTEE | COLOR_PAIR(GNT_COLOR_NORMAL)); + } tree_mark_columns(tree, pos, pos + 1, ACS_PLUS | COLOR_PAIR(GNT_COLOR_NORMAL)); tree_mark_columns(tree, pos, pos, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL)); start = 2; @@ -691,10 +695,28 @@ char *gnt_tree_get_selection_text(GntTree *tree) { if (tree->current) - update_row_text(tree, tree->current); + return update_row_text(tree, tree->current); return NULL; } +GList *gnt_tree_get_selection_text_list(GntTree *tree) +{ + GList *list = NULL, *iter; + int i; + + if (!tree->current) + return NULL; + + for (i = 0, iter = tree->current->columns; i < tree->ncol && iter; + i++, iter = iter->next) + { + GntTreeCol *col = iter->data; + list = g_list_append(list, g_strdup(col->text)); + } + + return list; +} + /* XXX: Should this also remove all the children of the row being removed? */ void gnt_tree_remove(GntTree *tree, gpointer key) { @@ -859,24 +881,41 @@ return widget; } -GntTreeRow *gnt_tree_create_row(GntTree *tree, ...) +GntTreeRow *gnt_tree_create_row_from_list(GntTree *tree, GList *list) { + GList *iter; + int i; GntTreeRow *row = g_new0(GntTreeRow, 1); - int i; - va_list args; - va_start(args, tree); - - for (i = 0; i < tree->ncol; i++) + for (i = 0, iter = list; i < tree->ncol && iter; iter = iter->next, i++) { GntTreeCol *col = g_new0(GntTreeCol, 1); col->span = 1; - col->text = g_strdup(va_arg(args, const char *)); + col->text = g_strdup(iter->data); row->columns = g_list_append(row->columns, col); } + + return row; +} + +GntTreeRow *gnt_tree_create_row(GntTree *tree, ...) +{ + int i; + va_list args; + GList *list = NULL; + GntTreeRow *row; + + va_start(args, tree); + for (i = 0; i < tree->ncol; i++) + { + list = g_list_append(list, va_arg(args, const char *)); + } va_end(args); + row = gnt_tree_create_row_from_list(tree, list); + g_list_free(list); + return row; } Modified: trunk/console/libgnt/gnttree.h =================================================================== --- trunk/console/libgnt/gnttree.h 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/libgnt/gnttree.h 2006-07-23 01:10:06 UTC (rev 16540) @@ -80,6 +80,8 @@ char *gnt_tree_get_selection_text(GntTree *tree); +GList *gnt_tree_get_selection_text_list(GntTree *tree); + void gnt_tree_remove(GntTree *tree, gpointer key); /* Returns the visible line number of the selected row */ @@ -99,6 +101,8 @@ GntTreeRow *gnt_tree_create_row(GntTree *tree, ...); +GntTreeRow *gnt_tree_create_row_from_list(GntTree *tree, GList *list); + void gnt_tree_set_col_width(GntTree *tree, int col, int width); void gnt_tree_set_column_titles(GntTree *tree, ...); Modified: trunk/console/libgnt/gntwidget.c =================================================================== --- trunk/console/libgnt/gntwidget.c 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/libgnt/gntwidget.c 2006-07-23 01:10:06 UTC (rev 16540) @@ -489,6 +489,8 @@ void gnt_widget_queue_update(GntWidget *widget) { + if (widget->window == NULL) + return; while (widget->parent) widget = widget->parent; Modified: trunk/console/libgnt/test/combo.c =================================================================== --- trunk/console/libgnt/test/combo.c 2006-07-22 21:16:10 UTC (rev 16539) +++ trunk/console/libgnt/test/combo.c 2006-07-23 01:10:06 UTC (rev 16540) @@ -1,6 +1,7 @@ #include <gnt.h> #include <gntbox.h> #include <gntbutton.h> +#include <gntcheckbox.h> #include <gntcombobox.h> #include <gntlabel.h> @@ -61,6 +62,8 @@ gnt_box_add_widget(GNT_BOX(box), hbox); + gnt_box_add_widget(GNT_BOX(box), gnt_check_box_new("check box")); + gnt_widget_show(box); #ifdef STANDALONE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2006-07-22 21:16:21
|
Revision: 16539 Author: roast Date: 2006-07-22 14:16:10 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16539&view=rev Log Message: ----------- xml logger writes the UTF-8 BOM, and xml parser/reader clobbers it Modified Paths: -------------- branches/soc-2006-file-loggers/src/log.c branches/soc-2006-file-loggers/src/util.c Modified: branches/soc-2006-file-loggers/src/log.c =================================================================== --- branches/soc-2006-file-loggers/src/log.c 2006-07-22 18:14:40 UTC (rev 16538) +++ branches/soc-2006-file-loggers/src/log.c 2006-07-22 21:16:10 UTC (rev 16539) @@ -1035,9 +1035,11 @@ if (!data->channel) return 0; g_string_printf(writebuf, + "%c%c%c" "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" "<chat service=\"%s\" account=\"%s\" version=\"0.3.1-04\"%s>\n" "\t<event time=\"%s\" type=\"logStart\" />\n", + 0xEF, 0xBB, 0xBF, prpl, gaim_account_get_username(log->account), log->type == GAIM_LOG_SYSTEM ? "gaim:logtype=\"system\"" : "", date); Modified: branches/soc-2006-file-loggers/src/util.c =================================================================== --- branches/soc-2006-file-loggers/src/util.c 2006-07-22 18:14:40 UTC (rev 16538) +++ branches/soc-2006-file-loggers/src/util.c 2006-07-22 21:16:10 UTC (rev 16539) @@ -1522,6 +1522,15 @@ GString *loggedby = NULL; gboolean bad_formatting = FALSE; + const char bom_utf8[] = {0xEF, 0xBB, 0xBF, 0}; + + // clobber the UTF-8 BOM + if (c && *c) { + if(!g_ascii_strncasecmp(c, bom_utf8, 3)) { + c+=3; + } + } + while(!bad_formatting && c && *c) { if(*c == '<') { if (*(c+1) == '/') { /* list all expected closing tags */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-07-22 18:14:42
|
Revision: 16538 Author: thekingant Date: 2006-07-22 11:14:40 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16538&view=rev Log Message: ----------- Backport SVN revision #16537 from HEAD to v2_0_0 Original commit message: Hopefully prevent an assertion failure when you lose your connection to MSN. ViewCVS Links: ------------- http://svn.sourceforge.net/gaim/?rev=16537&view=rev Modified Paths: -------------- branches/v2_0_0/src/protocols/msn/servconn.c Modified: branches/v2_0_0/src/protocols/msn/servconn.c =================================================================== --- branches/v2_0_0/src/protocols/msn/servconn.c 2006-07-22 18:11:34 UTC (rev 16537) +++ branches/v2_0_0/src/protocols/msn/servconn.c 2006-07-22 18:14:40 UTC (rev 16538) @@ -125,6 +125,8 @@ const char *names[] = { "Notification", "Switchboard" }; const char *name; + msn_servconn_disconnect(servconn); + name = names[servconn->type]; switch (error) @@ -156,8 +158,6 @@ swboard->error = MSN_SB_ERROR_CONNECTION; } - msn_servconn_disconnect(servconn); - g_free(tmp); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-07-22 18:11:38
|
Revision: 16537 Author: thekingant Date: 2006-07-22 11:11:34 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16537&view=rev Log Message: ----------- Hopefully prevent an assertion failure when you lose your connection to MSN. Modified Paths: -------------- trunk/src/protocols/msn/servconn.c Modified: trunk/src/protocols/msn/servconn.c =================================================================== --- trunk/src/protocols/msn/servconn.c 2006-07-22 11:44:46 UTC (rev 16536) +++ trunk/src/protocols/msn/servconn.c 2006-07-22 18:11:34 UTC (rev 16537) @@ -125,6 +125,8 @@ const char *names[] = { "Notification", "Switchboard" }; const char *name; + msn_servconn_disconnect(servconn); + name = names[servconn->type]; switch (error) @@ -156,8 +158,6 @@ swboard->error = MSN_SB_ERROR_CONNECTION; } - msn_servconn_disconnect(servconn); - g_free(tmp); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-07-22 11:44:51
|
Revision: 16536 Author: markhuetsch Date: 2006-07-22 04:44:46 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16536&view=rev Log Message: ----------- Eliminated some nested function declarations. Modified Paths: -------------- trunk/src/protocols/qq/crypt.c Modified: trunk/src/protocols/qq/crypt.c =================================================================== --- trunk/src/protocols/qq/crypt.c 2006-07-21 03:34:03 UTC (rev 16535) +++ trunk/src/protocols/qq/crypt.c 2006-07-22 11:44:46 UTC (rev 16536) @@ -40,92 +40,82 @@ 0x61C88647 is what we can track on the ASM codes.!! */ -#ifndef _WIN32 #include <arpa/inet.h> -#else -#include "win32dep.h" -#endif #include <string.h> #include "crypt.h" -#include "debug.h" // gaim_debug, by gfhuang +#include "debug.h" // gaim_debug -/*****************************************************************************/ +/******************************************************************** + * encryption + *******************************************************************/ + static void qq_encipher(unsigned long *const v, const unsigned long *const k, unsigned long *const w) { - register unsigned long y = ntohl(v[0]), z = ntohl(v[1]), a = ntohl(k[0]), b = ntohl(k[1]), c = ntohl(k[2]), d = ntohl(k[3]), n = 0x10, sum = 0, delta = 0x9E3779B9; /* 0x9E3779B9 - 0x100000000 = -0x61C88647 */ + register unsigned long y = ntohl(v[0]), + z = ntohl(v[1]), + a = ntohl(k[0]), + b = ntohl(k[1]), + c = ntohl(k[2]), + d = ntohl(k[3]), + n = 0x10, + sum = 0, + delta = 0x9E3779B9; /* 0x9E3779B9 - 0x100000000 = -0x61C88647 */ while (n-- > 0) { sum += delta; y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); - } // while + } w[0] = htonl(y); w[1] = htonl(z); -} // qq_enciper +} -/*****************************************************************************/ -static void qq_decipher(unsigned long *const v, const unsigned long *const k, unsigned long *const w) +static int rand(void) { // it can be the real random seed function + return 0xdead; +} // override with number, convenient for debug + +// we encrypt every eight byte chunk +static void encrypt_every_8_byte(unsigned char *plain, unsigned char *plain_pre_8, unsigned char **crypted, + unsigned char **crypted_pre_8, unsigned char *key, int *count, int *pos_in_byte, int *is_header) { - register unsigned long y = ntohl(v[0]), z = ntohl(v[1]), a = ntohl(k[0]), b = ntohl(k[1]), c = ntohl(k[2]), d = ntohl(k[3]), n = 0x10, sum = 0xE3779B90, // why this ? must be related with n value - delta = 0x9E3779B9; + // prepare plain text + for (*pos_in_byte = 0; *pos_in_byte < 8; (*pos_in_byte)++) { + if (*is_header) { + plain[*pos_in_byte] ^= plain_pre_8[*pos_in_byte]; + } else { + plain[*pos_in_byte] ^= (*crypted_pre_8)[*pos_in_byte]; + } + } + qq_encipher((unsigned long *) plain, (unsigned long *) key, (unsigned long *) *crypted); // encrypt it - /* sum = delta<<5, in general sum = delta * n */ - while (n-- > 0) { - z -= ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); - y -= ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); - sum -= delta; + for (*pos_in_byte = 0; *pos_in_byte < 8; (*pos_in_byte)++) { + (*crypted)[*pos_in_byte] ^= plain_pre_8[*pos_in_byte]; } + memcpy(plain_pre_8, plain, 8); // prepare next - w[0] = htonl(y); - w[1] = htonl(z); -} // qq_decipher + *crypted_pre_8 = *crypted; // store position of previous 8 byte + *crypted += 8; // prepare next output + *count += 8; // outstrlen increase by 8 + *pos_in_byte = 0; // back to start + *is_header = 0; // and exit header +} // encrypt_every_8_byte -/******************************************************************** - * encrypt part - *******************************************************************/ static void qq_encrypt(unsigned char *instr, int instrlen, unsigned char *key, unsigned char *outstr, int *outstrlen_prt) { - unsigned char plain[8], // plain text buffer - plain_pre_8[8], // plain text buffer, previous 8 bytes - *crypted, // crypted text - *crypted_pre_8, // crypted test, previous 8 bytes - *inp; // current position in instr - int pos_in_byte = 1, // loop in the byte - is_header = 1, // header is one byte - count = 0, // number of bytes being crypted - padding = 0; // number of padding stuff + unsigned char plain[8], // plain text buffer + plain_pre_8[8], // plain text buffer, previous 8 bytes + *crypted, // crypted text + *crypted_pre_8, // crypted test, previous 8 bytes + *inp; // current position in instr + int pos_in_byte = 1, // loop in the byte + is_header = 1, // header is one byte + count = 0, // number of bytes being crypted + padding = 0; // number of padding stuff - int rand(void) { // it can be the real random seed function - return 0xdead; - } // override with number, convenient for debug - - /*** we encrypt every eight byte ***/ - void encrypt_every_8_byte(void) { - for (pos_in_byte = 0; pos_in_byte < 8; pos_in_byte++) { - if (is_header) { - plain[pos_in_byte] ^= plain_pre_8[pos_in_byte]; - } else { - plain[pos_in_byte] ^= crypted_pre_8[pos_in_byte]; - } - } // prepare plain text - qq_encipher((unsigned long *) plain, (unsigned long *) key, (unsigned long *) crypted); // encrypt it - - for (pos_in_byte = 0; pos_in_byte < 8; pos_in_byte++) { - crypted[pos_in_byte] ^= plain_pre_8[pos_in_byte]; - } - memcpy(plain_pre_8, plain, 8); // prepare next - - crypted_pre_8 = crypted; // store position of previous 8 byte - crypted += 8; // prepare next output - count += 8; // outstrlen increase by 8 - pos_in_byte = 0; // back to start - is_header = 0; // and exit header - } // encrypt_every_8_byte - pos_in_byte = (instrlen + 0x0a) % 8; // header padding decided by instrlen if (pos_in_byte) { pos_in_byte = 8 - pos_in_byte; @@ -138,13 +128,13 @@ crypted = crypted_pre_8 = outstr; padding = 1; // pad some stuff in header - while (padding <= 2) { // at most two byte + while (padding <= 2) { // at most two bytes if (pos_in_byte < 8) { plain[pos_in_byte++] = rand() & 0xff; padding++; } if (pos_in_byte == 8) { - encrypt_every_8_byte(); + encrypt_every_8_byte(plain, plain_pre_8, &crypted, &crypted_pre_8, key, &count, &pos_in_byte, &is_header); } } @@ -155,62 +145,88 @@ instrlen--; } if (pos_in_byte == 8) { - encrypt_every_8_byte(); + encrypt_every_8_byte(plain, plain_pre_8, &crypted, &crypted_pre_8, key, &count, &pos_in_byte, &is_header); } } - padding = 1; // pad some stuff in tailer - while (padding <= 7) { // at most sever byte + padding = 1; // pad some stuff in tail + while (padding <= 7) { // at most seven bytes if (pos_in_byte < 8) { plain[pos_in_byte++] = 0x00; padding++; } if (pos_in_byte == 8) { - encrypt_every_8_byte(); + encrypt_every_8_byte(plain, plain_pre_8, &crypted, &crypted_pre_8, key, &count, &pos_in_byte, &is_header); } } *outstrlen_prt = count; -} // qq_encrypt +} /******************************************************************** - * [decrypt part] - * return 0 if failed, otherwise return 1 + * decryption ********************************************************************/ +static void qq_decipher(unsigned long *const v, const unsigned long *const k, unsigned long *const w) +{ + register unsigned long y = ntohl(v[0]), + z = ntohl(v[1]), + a = ntohl(k[0]), + b = ntohl(k[1]), + c = ntohl(k[2]), + d = ntohl(k[3]), + n = 0x10, + sum = 0xE3779B90, // why this ? must be related with n value + delta = 0x9E3779B9; + + /* sum = delta<<5, in general sum = delta * n */ + while (n-- > 0) { + z -= ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); + y -= ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); + sum -= delta; + } + + w[0] = htonl(y); + w[1] = htonl(z); +} + +static int decrypt_every_8_byte(unsigned char **crypt_buff, const int instrlen, const unsigned char * const key, + int *context_start, unsigned char *decrypted, int *pos_in_byte) +{ + for (*pos_in_byte = 0; *pos_in_byte < 8; (*pos_in_byte)++) { + if (*context_start + *pos_in_byte >= instrlen) + return 1; + decrypted[*pos_in_byte] ^= (*crypt_buff)[*pos_in_byte]; + } + qq_decipher((unsigned long *) decrypted, (unsigned long *) key, (unsigned long *) decrypted); + + *context_start += 8; + *crypt_buff += 8; + *pos_in_byte = 0; + + return 1; +} + +// return 0 if failed, 1 otherwise static int qq_decrypt(unsigned char *instr, int instrlen, unsigned char *key, unsigned char *outstr, int *outstrlen_ptr) { unsigned char decrypted[8], m[8], *crypt_buff, *crypt_buff_pre_8, *outp; int count, context_start, pos_in_byte, padding; - int decrypt_every_8_byte(void) { - for (pos_in_byte = 0; pos_in_byte < 8; pos_in_byte++) { - if (context_start + pos_in_byte >= instrlen) - return 1; - decrypted[pos_in_byte] ^= crypt_buff[pos_in_byte]; - } - qq_decipher((unsigned long *) decrypted, (unsigned long *) key, (unsigned long *) decrypted); - - context_start += 8; - crypt_buff += 8; - pos_in_byte = 0; - return 1; - } // decrypt_every_8_byte - // at least 16 bytes and %8 == 0 if ((instrlen % 8) || (instrlen < 16)) { - //debug info by gfhuang - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Packet len is not times of 8 bytes, read %d bytes\n", instrlen); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "Packet len is either too short or not a multiple of 8 bytes, read %d bytes\n", instrlen); return 0; } // get information from header qq_decipher((unsigned long *) instr, (unsigned long *) key, (unsigned long *) decrypted); pos_in_byte = decrypted[0] & 0x7; count = instrlen - pos_in_byte - 10; // this is the plaintext length - // return if outstr buffer is not large enought or error plaintext length + // return if outstr buffer is not large enough or error plaintext length if (*outstrlen_ptr < count || count < 0) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Buffer len %d is less than real len %d", *outstrlen_ptr, count); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Buffer len %d is less than real len %d", *outstrlen_ptr, count); return 0; } @@ -219,23 +235,23 @@ *outstrlen_ptr = count; // everything is ok! set return string length crypt_buff = instr + 8; // address of real data start - context_start = 8; // context is at the second 8 byte + context_start = 8; // context is at the second chunk of 8 bytes pos_in_byte++; // start of paddng stuff padding = 1; // at least one in header while (padding <= 2) { // there are 2 byte padding stuff in header - if (pos_in_byte < 8) { // bypass the padding stuff, none sense data + if (pos_in_byte < 8) { // bypass the padding stuff, it's nonsense data pos_in_byte++; padding++; } if (pos_in_byte == 8) { crypt_buff_pre_8 = instr; - if (!decrypt_every_8_byte()) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "decrypt every 8 bytes error A"); + if (!decrypt_every_8_byte(&crypt_buff, instrlen, key, &context_start, decrypted, &pos_in_byte)) { + gaim_debug(GAIM_DEBUG_ERROR, "QQ", "decrypt every 8 bytes error A"); return 0; } } - } // while + } outp = outstr; while (count != 0) { @@ -247,12 +263,12 @@ } if (pos_in_byte == 8) { crypt_buff_pre_8 = crypt_buff - 8; - if (!decrypt_every_8_byte()) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "decrypt every 8 bytes error B"); + if (!decrypt_every_8_byte(&crypt_buff, instrlen, key, &context_start, decrypted, &pos_in_byte)) { + gaim_debug(GAIM_DEBUG_ERROR, "QQ", "decrypt every 8 bytes error B"); return 0; } } - } // while + } for (padding = 1; padding < 8; padding++) { if (pos_in_byte < 8) { @@ -262,14 +278,14 @@ } if (pos_in_byte == 8) { crypt_buff_pre_8 = crypt_buff; - if (!decrypt_every_8_byte()) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "decrypt every 8 bytes error C"); + if (!decrypt_every_8_byte(&crypt_buff, instrlen, key, &context_start, decrypted, &pos_in_byte)) { + gaim_debug(GAIM_DEBUG_ERROR, "QQ", "decrypt every 8 bytes error C"); return 0; } } - } // for + } return 1; -} // qq_decrypt +} /*****************************************************************************/ /* This is the Public Function */ @@ -283,7 +299,7 @@ qq_encrypt(instr, instrlen, key, outstr, outstrlen_ptr); return 1; // flag must be DECRYPT or ENCRYPT -} // qq_crypt +} /*****************************************************************************/ // END OF FILE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2006-07-21 03:35:18
|
Revision: 16535 Author: roast Date: 2006-07-20 20:34:03 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16535&view=rev Log Message: ----------- merged with svn trunk. 16498:16534. Modified Paths: -------------- branches/soc-2006-file-loggers/console/Makefile branches/soc-2006-file-loggers/console/gntaccount.c branches/soc-2006-file-loggers/console/gntblist.c branches/soc-2006-file-loggers/console/gntconv.c branches/soc-2006-file-loggers/console/gntgaim.c branches/soc-2006-file-loggers/console/gntgaim.h branches/soc-2006-file-loggers/console/gntui.c branches/soc-2006-file-loggers/console/libgnt/gntbox.c branches/soc-2006-file-loggers/console/libgnt/gntbox.h branches/soc-2006-file-loggers/console/libgnt/gntcolors.c branches/soc-2006-file-loggers/console/libgnt/gntcolors.h branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c branches/soc-2006-file-loggers/console/libgnt/gntlabel.c branches/soc-2006-file-loggers/console/libgnt/gntlabel.h branches/soc-2006-file-loggers/console/libgnt/gntline.h branches/soc-2006-file-loggers/console/libgnt/gntmain.c branches/soc-2006-file-loggers/console/libgnt/gnttextview.c branches/soc-2006-file-loggers/console/libgnt/gnttextview.h branches/soc-2006-file-loggers/console/libgnt/gnttree.c branches/soc-2006-file-loggers/console/libgnt/gnttree.h branches/soc-2006-file-loggers/console/libgnt/test/Makefile branches/soc-2006-file-loggers/console/libgnt/test/combo.c branches/soc-2006-file-loggers/console/libgnt/test/focus.c branches/soc-2006-file-loggers/console/libgnt/test/multiwin.c branches/soc-2006-file-loggers/console/libgnt/test/tv.c branches/soc-2006-file-loggers/plugins/dbus-example.c branches/soc-2006-file-loggers/plugins/musicmessaging/musicmessaging.c branches/soc-2006-file-loggers/plugins/tcl/tcl.c branches/soc-2006-file-loggers/src/buddyicon.h branches/soc-2006-file-loggers/src/connection.c branches/soc-2006-file-loggers/src/connection.h branches/soc-2006-file-loggers/src/conversation.c branches/soc-2006-file-loggers/src/conversation.h branches/soc-2006-file-loggers/src/core.c branches/soc-2006-file-loggers/src/dbus-server.c branches/soc-2006-file-loggers/src/dbus-server.h branches/soc-2006-file-loggers/src/gtkblist.c branches/soc-2006-file-loggers/src/gtkconv.c branches/soc-2006-file-loggers/src/gtkconv.h branches/soc-2006-file-loggers/src/gtknotify.c branches/soc-2006-file-loggers/src/log.c branches/soc-2006-file-loggers/src/notify.c branches/soc-2006-file-loggers/src/plugin.c branches/soc-2006-file-loggers/src/protocols/jabber/jabber.c branches/soc-2006-file-loggers/src/protocols/jabber/presence.c branches/soc-2006-file-loggers/src/protocols/jabber/roster.c branches/soc-2006-file-loggers/src/protocols/msn/dialog.c branches/soc-2006-file-loggers/src/protocols/msn/slp.c branches/soc-2006-file-loggers/src/protocols/msn/slplink.c branches/soc-2006-file-loggers/src/protocols/msn/switchboard.c branches/soc-2006-file-loggers/src/protocols/msn/switchboard.h branches/soc-2006-file-loggers/src/protocols/msn/user.c branches/soc-2006-file-loggers/src/protocols/msn/userlist.c branches/soc-2006-file-loggers/src/protocols/oscar/family_icbm.c branches/soc-2006-file-loggers/src/protocols/oscar/oscar.c branches/soc-2006-file-loggers/src/protocols/oscar/peer.c branches/soc-2006-file-loggers/src/protocols/oscar/peer_proxy.c branches/soc-2006-file-loggers/src/protocols/sametime/sametime.c branches/soc-2006-file-loggers/src/protocols/silc/silc.c branches/soc-2006-file-loggers/src/protocols/yahoo/yahoo.c branches/soc-2006-file-loggers/src/protocols/yahoo/yahoo_picture.c branches/soc-2006-file-loggers/src/protocols/yahoo/yahoo_picture.h branches/soc-2006-file-loggers/src/protocols/yahoo/yahoochat.c branches/soc-2006-file-loggers/src/proxy.c branches/soc-2006-file-loggers/src/signals.c branches/soc-2006-file-loggers/src/util.h Added Paths: ----------- branches/soc-2006-file-loggers/console/gntconn.c branches/soc-2006-file-loggers/console/gntconn.h branches/soc-2006-file-loggers/console/gntnotify.c branches/soc-2006-file-loggers/console/gntnotify.h branches/soc-2006-file-loggers/console/libgnt/test/wm.c Modified: branches/soc-2006-file-loggers/console/Makefile =================================================================== --- branches/soc-2006-file-loggers/console/Makefile 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/Makefile 2006-07-21 03:34:03 UTC (rev 16535) @@ -1,24 +1,30 @@ VERSION=gntgaim-0.0.0dev CC=gcc -CFLAGS=`pkg-config --cflags gaim gobject-2.0 gnt` -g -Wall -DVERSION=\"$(VERSION)\" +CFLAGS=`pkg-config --cflags gaim gobject-2.0 gnt` -g -Wall -DVERSION=\"$(VERSION)\" -DSTANDALONE LDFLAGS=`pkg-config --libs gaim gobject-2.0 libxml-2.0 gnt` -pg GG_SOURCES = \ gntaccount.c \ gntblist.c \ + gntconn.c \ gntconv.c \ + gntnotify.c \ gntui.c GG_HEADERS = \ gntaccount.h \ gntblist.h \ + gntconn.h \ gntconv.h \ + gntnotify.h \ gntui.h GG_OBJECTS = \ gntaccount.o \ gntblist.o \ + gntconn.o \ gntconv.o \ + gntnotify.o \ gntui.o all: gntgaim @@ -29,6 +35,7 @@ gntblist.o: gntblist.c $(GG_HEADERS) gntconv.o: gntconv.c $(GG_HEADERS) gntgaim.o: gntgaim.c gntgaim.h $(GG_HEADERS) +gntnotify.o: gntnotify.c $(GG_HEADERS) gntui.o: gntui.c $(GG_HEADERS) clean: Modified: branches/soc-2006-file-loggers/console/gntaccount.c =================================================================== --- branches/soc-2006-file-loggers/console/gntaccount.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/gntaccount.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -210,25 +210,26 @@ gnt_box_add_widget(GNT_BOX(accounts.window), gnt_line_new(FALSE)); - accounts.tree = gnt_tree_new(); + accounts.tree = gnt_tree_new_with_columns(2); GNT_WIDGET_SET_FLAGS(accounts.tree, GNT_WIDGET_NO_BORDER); for (iter = gaim_accounts_get_all(); iter; iter = iter->next) { GaimAccount *account = iter->data; - char *str = g_strdup_printf("%s (%s)", - gaim_account_get_username(account), gaim_account_get_protocol_id(account)); gnt_tree_add_choice(GNT_TREE(accounts.tree), account, - str, NULL, NULL); + gnt_tree_create_row(GNT_TREE(accounts.tree), + gaim_account_get_username(account), + gaim_account_get_protocol_name(account)), + NULL, NULL); gnt_tree_set_choice(GNT_TREE(accounts.tree), account, gaim_account_get_enabled(account, GAIM_GNT_UI)); - g_free(str); } g_signal_connect(G_OBJECT(accounts.tree), "toggled", G_CALLBACK(account_toggled), NULL); - gnt_widget_set_size(accounts.tree, 40, 10); + gnt_tree_set_col_width(GNT_TREE(accounts.tree), 0, 40); + gnt_tree_set_col_width(GNT_TREE(accounts.tree), 1, 10); gnt_box_add_widget(GNT_BOX(accounts.window), accounts.tree); gnt_box_add_widget(GNT_BOX(accounts.window), gnt_line_new(FALSE)); Modified: branches/soc-2006-file-loggers/console/gntblist.c =================================================================== --- branches/soc-2006-file-loggers/console/gntblist.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/gntblist.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -1,5 +1,6 @@ #include <account.h> #include <blist.h> +#include <request.h> #include <server.h> #include <signal.h> #include <util.h> @@ -19,6 +20,9 @@ GntWidget *tooltip; GaimBlistNode *tnode; /* Who is the tooltip being displayed for? */ + + GntWidget *context; + GaimBlistNode *cnode; } GGBlist; GGBlist *ggblist; @@ -28,6 +32,7 @@ static void add_chat(GaimChat *chat, GGBlist *ggblist); static void add_node(GaimBlistNode *node, GGBlist *ggblist); static void draw_tooltip(GGBlist *ggblist); +static void remove_peripherals(GGBlist *ggblist); static void new_node(GaimBlistNode *node) @@ -124,8 +129,9 @@ GaimBlistNode *node = (GaimBlistNode *)group; if (node->ui_data) return; + gnt_tree_remove(GNT_TREE(ggblist->tree), group); node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, - group->name, NULL, NULL); + gnt_tree_create_row(GNT_TREE(ggblist->tree), group->name), NULL, NULL); } static const char * @@ -186,8 +192,10 @@ group = gaim_chat_get_group(chat); add_node((GaimBlistNode*)group, ggblist); + gnt_tree_remove(GNT_TREE(ggblist->tree), chat); node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat, - get_display_name(node), group, NULL); + gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), + group, NULL); } static void @@ -201,8 +209,10 @@ group = gaim_buddy_get_group(buddy); add_node((GaimBlistNode*)group, ggblist); + gnt_tree_remove(GNT_TREE(ggblist->tree), buddy); node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, - get_display_name(node), group, NULL); + gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), + group, NULL); if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM); else @@ -252,6 +262,233 @@ } static void +remove_context_menu(GGBlist *ggblist) +{ + if (ggblist->context) + gnt_widget_destroy(ggblist->context->parent); + ggblist->context = NULL; + ggblist->cnode = NULL; +} + +static void +gnt_append_menu_action(GntTree *tree, GaimMenuAction *action, gpointer parent) +{ + GList *list; + + gnt_tree_add_row_after(tree, action, + gnt_tree_create_row(tree, action->label), parent, NULL); + for (list = action->children; list; list = list->next) + gnt_append_menu_action(tree, list->data, action); +} + +static void +append_proto_menu(GntTree *tree, GaimConnection *gc, GaimBlistNode *node) +{ + GList *list; + GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); + + if(!prpl_info || !prpl_info->blist_node_menu) + return; + + for(list = prpl_info->blist_node_menu(node); list; + list = g_list_delete_link(list, list)) + { + GaimMenuAction *act = (GaimMenuAction *) list->data; + gnt_append_menu_action(tree, act, NULL); + } +} + +static void +add_custom_action(GntTree *tree, const char *label, GaimCallback callback, + gpointer data) +{ + GaimMenuAction *action = gaim_menu_action_new(label, callback, data, NULL); + gnt_append_menu_action(tree, action, NULL); + g_signal_connect_swapped(G_OBJECT(tree), "destroy", + G_CALLBACK(gaim_menu_action_free), action); +} + +static void +create_chat_menu(GntTree *tree, GaimChat *chat) +{ +} + +static void +create_group_menu(GntTree *tree, GaimGroup *group) +{ +} + +static void +gg_blist_get_buddy_info_cb(GaimBuddy *buddy, GaimBlistNode *null) +{ + serv_get_info(buddy->account->gc, gaim_buddy_get_name(buddy)); +} + +static void +create_buddy_menu(GntTree *tree, GaimBuddy *buddy) +{ + GaimPluginProtocolInfo *prpl_info; + + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(buddy->account->gc->prpl); + if (prpl_info && prpl_info->get_info) + { + add_custom_action(tree, _("Get Info"), + GAIM_CALLBACK(gg_blist_get_buddy_info_cb), buddy); + } + +#if 0 + add_custom_action(tree, _("Add Buddy Pounce"), + GAIM_CALLBACK(gg_blist_add_buddy_pounce_cb)), buddy); + + if (prpl_info && prpl_info->send_file) + { + if (!prpl_info->can_receive_file || + prpl_info->can_receive_file(buddy->account->gc, buddy->name)) + add_custom_action(tree, _("Send File"), + GAIM_CALLBACK(gg_blist_show_file_cb)), buddy); + } + + add_custom_action(tree, _("View Log"), + GAIM_CALLBACK(gg_blist_view_log_cb)), buddy); +#endif + + /* Protocol actions */ + append_proto_menu(tree, + gaim_account_get_connection(gaim_buddy_get_account(buddy)), + (GaimBlistNode*)buddy); +} + +static void +append_extended_menu(GntTree *tree, GaimBlistNode *node) +{ + GList *iter; + + for (iter = gaim_blist_node_get_extended_menu(node); + iter; iter = g_list_delete_link(iter, iter)) + { + gnt_append_menu_action(tree, iter->data, NULL); + } +} + +static void +context_menu_callback(GntTree *tree, GGBlist *ggblist) +{ + GaimMenuAction *action = gnt_tree_get_selection_data(tree); + GaimBlistNode *node = ggblist->cnode; + + if (action) + { + void (*callback)(GaimBlistNode *, gpointer); + callback = (void (*)(GaimBlistNode *, gpointer))action->callback; + callback(node, action->data); + } + + remove_context_menu(ggblist); +} + +static void +gg_blist_rename_node_cb(GaimBlistNode *node, GaimBlistNode *null) +{ +} + +/* XXX: This still doesn't do anything, because request doesn't have a ui yet */ +static void +gg_blist_remove_node_cb(GaimBlistNode *node, GaimBlistNode *null) +{ + void (*callback)(gpointer); + + if (GAIM_BLIST_NODE_IS_BUDDY(node)) + callback = (void(*)(gpointer))gaim_blist_remove_buddy; + else if (GAIM_BLIST_NODE_IS_CHAT(node)) + callback = (void(*)(gpointer))gaim_blist_remove_chat; + else if (GAIM_BLIST_NODE_IS_GROUP(node)) + callback = (void(*)(gpointer))gaim_blist_remove_group; + + /* XXX: anything to do with the returned ui-handle? */ + gaim_request_action(node, _("Confirm Remove"), + _("Are you sure you want to remove ..."), NULL, /* XXX: tidy up */ + 1, node, 2, + _("Remove"), callback, + _("No"), NULL); + +} + +static void +draw_context_menu(GGBlist *ggblist) +{ + GaimBlistNode *node = NULL; + GntWidget *context = NULL, *window = NULL; + GntTree *tree = NULL; + int x, y, top, width; + char *title = NULL; + + tree = GNT_TREE(ggblist->tree); + + if (ggblist->context) + { + remove_context_menu(ggblist); + } + + node = gnt_tree_get_selection_data(tree); + + if (node == NULL) + return; + if (ggblist->tooltip) + remove_tooltip(ggblist); + + ggblist->cnode = node; + ggblist->context = context = gnt_tree_new(); + GNT_WIDGET_SET_FLAGS(context, GNT_WIDGET_NO_BORDER); + gnt_widget_set_name(context, "context menu"); + g_signal_connect(G_OBJECT(context), "activate", G_CALLBACK(context_menu_callback), ggblist); + + if (GAIM_BLIST_NODE_IS_BUDDY(node)) + { + GaimBuddy *buddy = (GaimBuddy *)node; + create_buddy_menu(GNT_TREE(context), buddy); + title = g_strdup(gaim_buddy_get_name(buddy)); + } + else if (GAIM_BLIST_NODE_IS_CHAT(node)) + { + GaimChat *chat = (GaimChat*)node; + create_chat_menu(GNT_TREE(context), chat); + title = g_strdup(gaim_chat_get_name(chat)); + } + else if (GAIM_BLIST_NODE_IS_GROUP(node)) + { + GaimGroup *group = (GaimGroup *)node; + create_group_menu(GNT_TREE(context), group); + title = g_strdup(group->name); + } + + append_extended_menu(GNT_TREE(context), node); + + /* These are common for everything */ + add_custom_action(GNT_TREE(context), _("Rename"), + GAIM_CALLBACK(gg_blist_rename_node_cb), node); + add_custom_action(GNT_TREE(context), _("Remove"), + GAIM_CALLBACK(gg_blist_remove_node_cb), node); + + window = gnt_vbox_new(FALSE); + gnt_box_set_toplevel(GNT_BOX(window), TRUE); + gnt_box_set_title(GNT_BOX(window), title); + + gnt_box_add_widget(GNT_BOX(window), context); + + /* Set the position for the popup */ + gnt_widget_get_position(GNT_WIDGET(tree), &x, &y); + gnt_widget_get_size(GNT_WIDGET(tree), &width, NULL); + top = gnt_tree_get_selection_visible_line(tree); + + x += width; + y += top - 1; + + gnt_widget_set_position(window, x, y); + gnt_widget_draw(window); + g_free(title); +} + +static void draw_tooltip(GGBlist *ggblist) { GaimBlistNode *node; @@ -270,6 +507,9 @@ if (!gnt_widget_has_focus(ggblist->tree)) return; + if (ggblist->context) + return; + if (ggblist->tooltip) { /* XXX: Once we can properly redraw on expose events, this can be removed at the end @@ -288,7 +528,9 @@ GaimBuddy *buddy = (GaimBuddy *)node; account = gaim_buddy_get_account(buddy); - g_string_append_printf(str, _("Account: %s"), gaim_account_get_username(account)); + g_string_append_printf(str, _("Account: %s (%s)"), + gaim_account_get_username(account), + gaim_account_get_protocol_name(account)); prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); @@ -323,7 +565,9 @@ GaimChat *chat = (GaimChat *)node; GaimAccount *account = chat->account; - g_string_append_printf(str, _("Account: %s"), gaim_account_get_username(account)); + g_string_append_printf(str, _("Account: %s (%s)"), + gaim_account_get_username(account), + gaim_account_get_protocol_name(account)); title = g_strdup(gaim_chat_get_name(chat)); } @@ -368,24 +612,41 @@ static gboolean key_pressed(GntWidget *widget, const char *text, GGBlist *ggblist) { + gboolean stop = FALSE, ret = FALSE; if (text[0] == 27 && text[1] == 0) { /* Escape was pressed */ - if (ggblist->tooltip) + remove_peripherals(ggblist); + stop = TRUE; + ret = TRUE; + } + + if (ggblist->context) + { + ret = gnt_widget_key_pressed(ggblist->context, text); + stop = TRUE; + } + + if (text[0] == 27) + { + if (strcmp(text + 1, GNT_KEY_POPUP) == 0) { - gnt_widget_destroy(ggblist->tooltip); - ggblist->tooltip = NULL; - return TRUE; + draw_context_menu(ggblist); + stop = TRUE; + ret = TRUE; } } - return FALSE; + if (stop) + g_signal_stop_emission_by_name(G_OBJECT(widget), "key_pressed"); + + return ret; } static void update_buddy_display(GaimBuddy *buddy, GGBlist *ggblist) { - gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, get_display_name((GaimBlistNode*)buddy)); + gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, 0, get_display_name((GaimBlistNode*)buddy)); if (ggblist->tnode == (GaimBlistNode*)buddy) draw_tooltip(ggblist); @@ -407,6 +668,15 @@ update_buddy_display(buddy, ggblist); } +static void +remove_peripherals(GGBlist *ggblist) +{ + if (ggblist->tooltip) + remove_tooltip(ggblist); + else if (ggblist->context) + remove_context_menu(ggblist); +} + void gg_blist_init() { ggblist = g_new0(GGBlist, 1); @@ -421,7 +691,8 @@ ggblist->tree = gnt_tree_new(); GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER); - gnt_widget_set_size(ggblist->tree, 25, getmaxy(stdscr) - 4); + gnt_tree_set_col_width(GNT_TREE(ggblist->tree), 0, 25); + gnt_widget_set_size(ggblist->tree, 0, getmaxy(stdscr) - 4); gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree); gnt_widget_show(ggblist->window); @@ -452,7 +723,7 @@ g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist); g_signal_connect_data(G_OBJECT(ggblist->tree), "gained-focus", G_CALLBACK(draw_tooltip), ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); - g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_tooltip), + g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_peripherals), ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); } Copied: branches/soc-2006-file-loggers/console/gntconn.c (from rev 16534, trunk/console/gntconn.c) =================================================================== --- branches/soc-2006-file-loggers/console/gntconn.c (rev 0) +++ branches/soc-2006-file-loggers/console/gntconn.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -0,0 +1,45 @@ +#include "notify.h" + +#include "gntconn.h" +#include "gntgaim.h" + +static void +gg_connection_report_disconnect(GaimConnection *gc, const char *text) +{ + char *act, *primary, *secondary; + GaimAccount *account = gaim_connection_get_account(gc); + + act = g_strdup_printf(_("%s (%s)"), gaim_account_get_username(account), + gaim_account_get_protocol_name(account)); + + primary = g_strdup_printf(_("%s disconnected."), act); + secondary = g_strdup_printf(_("%s was disconnected due to the following error:\n%s"), + act, text); + + gaim_notify_error(account, _("Connection Error"), primary, secondary); + + g_free(act); + g_free(primary); + g_free(secondary); +} + +static GaimConnectionUiOps ops = +{ + .connect_progress = NULL, + .connected = NULL, + .disconnected = NULL, + .notice = NULL, + .report_disconnect = gg_connection_report_disconnect +}; + +GaimConnectionUiOps *gg_connections_get_ui_ops() +{ + return &ops; +} + +void gg_connections_init() +{} + +void gg_connections_uninit() +{} + Copied: branches/soc-2006-file-loggers/console/gntconn.h (from rev 16534, trunk/console/gntconn.h) =================================================================== --- branches/soc-2006-file-loggers/console/gntconn.h (rev 0) +++ branches/soc-2006-file-loggers/console/gntconn.h 2006-07-21 03:34:03 UTC (rev 16535) @@ -0,0 +1,8 @@ +#include "connection.h" + +GaimConnectionUiOps *gg_connections_get_ui_ops(); + +void gg_connections_init(); + +void gg_connections_uninit(); + Modified: branches/soc-2006-file-loggers/console/gntconv.c =================================================================== --- branches/soc-2006-file-loggers/console/gntconv.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/gntconv.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -1,4 +1,6 @@ #include <string.h> + +#include <cmds.h> #include <util.h> #include "gntgaim.h" @@ -49,12 +51,53 @@ const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); if (*text == '/') { - /* XXX: Need to check for /-commands here */ + GaimConversation *conv = ggconv->conv; + GaimCmdStatus status; + const char *cmdline = text + 1; + char *error = NULL, *escape; + + escape = g_markup_escape_text(cmdline, -1); + status = gaim_cmd_do_command(conv, cmdline, escape, &error); + g_free(escape); + + switch (status) + { + case GAIM_CMD_STATUS_OK: + break; + case GAIM_CMD_STATUS_NOT_FOUND: + gaim_conversation_write(conv, "", _("No such command."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_WRONG_ARGS: + gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " + "to that command."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_FAILED: + gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_WRONG_TYPE: + if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) + gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + else + gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_WRONG_PRPL: + gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + } + g_free(error); +#if 0 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), _("Commands are not supported yet. Message was NOT sent."), GNT_TEXT_FLAG_DIM | GNT_TEXT_FLAG_UNDERLINE); gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv)); gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); +#endif } else { @@ -202,11 +245,12 @@ { if (flags & GAIM_MESSAGE_SEND) { - who = gaim_connection_get_display_name(conv->account->gc); + GaimAccount *account = gaim_conversation_get_account(conv); + who = gaim_connection_get_display_name(gaim_account_get_connection(account)); if (!who) - who = gaim_account_get_alias(conv->account); + who = gaim_account_get_alias(account); if (!who) - who = gaim_account_get_username(conv->account); + who = gaim_account_get_username(account); } else if (flags & GAIM_MESSAGE_RECV) who = gaim_conversation_get_name(conv); @@ -230,20 +274,48 @@ } static void -gg_chat_add_users(GaimConversation *conv, GList *users, GList *flags, GList *aliases, gboolean new_arrivals) -{} +gg_chat_add_users(GaimConversation *conv, GList *users, gboolean new_arrivals) +{ + if (!new_arrivals) + { + /* Print the list of users in the room */ + GString *string = g_string_new(_("List of users:\n")); + GList *iter; + for (iter = users; iter; iter = iter->next) + { + GaimConvChatBuddy *cbuddy = iter->data; + char *str; + + if ((str = cbuddy->alias) == NULL) + str = cbuddy->name; + g_string_append_printf(string, "[ %s ]", str); + } + + gaim_conversation_write(conv, NULL, string->str, + GAIM_MESSAGE_SYSTEM, time(NULL)); + g_string_free(string, TRUE); + } + /* XXX: Add the names for string completion */ +} + static void gg_chat_rename_user(GaimConversation *conv, const char *old, const char *new_n, const char *new_a) -{} +{ + /* XXX: Update the name for string completion */ +} static void gg_chat_remove_user(GaimConversation *conv, GList *list) -{} +{ + /* XXX: Remove the name from string completion */ +} static void gg_chat_update_user(GaimConversation *conv, const char *user) -{} +{ + /* XXX: This probably will not require updating the string completion */ +} static GaimConversationUiOps conv_ui_ops = { @@ -266,9 +338,9 @@ static void destroy_ggconv(gpointer data) { - GGConv *conv = data; - gnt_widget_destroy(conv->window); - g_free(conv); + GGConv *ggconv = data; + gnt_widget_destroy(ggconv->window); + g_free(ggconv); } GaimConversationUiOps *gg_conv_get_ui_ops() @@ -276,10 +348,132 @@ return &conv_ui_ops; } +/* Xerox */ +static GaimCmdRet +say_command_cb(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) + gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); + else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) + gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); + return GAIM_CMD_RET_OK; +} + +/* Xerox */ +static GaimCmdRet +me_command_cb(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + char *tmp; + + tmp = g_strdup_printf("/me %s", args[0]); + + if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) + gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); + else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) + gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); + + g_free(tmp); + return GAIM_CMD_RET_OK; +} + +/* Xerox */ +static GaimCmdRet +debug_command_cb(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + char *tmp, *markup; + GaimCmdStatus status; + + if (!g_ascii_strcasecmp(args[0], "version")) { + tmp = g_strdup_printf("me is using %s.", VERSION); + markup = g_markup_escape_text(tmp, -1); + + status = gaim_cmd_do_command(conv, tmp, markup, error); + + g_free(tmp); + g_free(markup); + return status; + } else { + gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), + GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); + return GAIM_CMD_STATUS_OK; + } +} + +/* Xerox */ +static GaimCmdRet +clear_command_cb(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + GGConv *ggconv = conv->ui_data; + gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv)); + return GAIM_CMD_STATUS_OK; +} + +/* Xerox */ +static GaimCmdRet +help_command_cb(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + GList *l, *text; + GString *s; + + if (args[0] != NULL) { + s = g_string_new(""); + text = gaim_cmd_help(conv, args[0]); + + if (text) { + for (l = text; l; l = l->next) + if (l->next) + g_string_append_printf(s, "%s\n", (char *)l->data); + else + g_string_append_printf(s, "%s", (char *)l->data); + } else { + g_string_append(s, _("No such command (in this context).")); + } + } else { + s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" + "The following commands are available in this context:\n")); + + text = gaim_cmd_list(conv); + for (l = text; l; l = l->next) + if (l->next) + g_string_append_printf(s, "%s, ", (char *)l->data); + else + g_string_append_printf(s, "%s.", (char *)l->data); + g_list_free(text); + } + + gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); + g_string_free(s, TRUE); + + return GAIM_CMD_STATUS_OK; +} + + void gg_conversation_init() { ggconvs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_ggconv); + + /* Xerox */ + gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, + say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); + gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, + me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); + gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, + debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); + gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, + clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); + gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, + help_command_cb, _("help <command>: Help on a specific command."), NULL); } void gg_conversation_uninit() Modified: branches/soc-2006-file-loggers/console/gntgaim.c =================================================================== --- branches/soc-2006-file-loggers/console/gntgaim.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/gntgaim.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -299,8 +299,9 @@ /* Initialize and run the UI */ init_gnt_ui(); - +#ifdef STANDALONE gaim_core_quit(); +#endif return 0; } Modified: branches/soc-2006-file-loggers/console/gntgaim.h =================================================================== --- branches/soc-2006-file-loggers/console/gntgaim.h 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/gntgaim.h 2006-07-21 03:34:03 UTC (rev 16535) @@ -1,4 +1,5 @@ #include <glib.h> +#include <libintl.h> #define GAIM_GNT_UI "gnt-gaim" Copied: branches/soc-2006-file-loggers/console/gntnotify.c (from rev 16534, trunk/console/gntnotify.c) =================================================================== --- branches/soc-2006-file-loggers/console/gntnotify.c (rev 0) +++ branches/soc-2006-file-loggers/console/gntnotify.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -0,0 +1,211 @@ +#include <gnt.h> +#include <gntbox.h> +#include <gntbutton.h> +#include <gntlabel.h> +#include <gnttree.h> + +#include <util.h> + +#include "gntnotify.h" +#include "gntgaim.h" + +static struct +{ + GntWidget *window; + GntWidget *tree; +} emaildialog; + +static void * +gg_notify_message(GaimNotifyMsgType type, const char *title, + const char *primary, const char *secondary) +{ + GntWidget *window, *button; + GntTextFormatFlags pf = 0, sf = 0; + + switch (type) + { + case GAIM_NOTIFY_MSG_ERROR: + sf |= GNT_TEXT_FLAG_BOLD; + case GAIM_NOTIFY_MSG_WARNING: + pf |= GNT_TEXT_FLAG_UNDERLINE; + case GAIM_NOTIFY_MSG_INFO: + pf |= GNT_TEXT_FLAG_BOLD; + break; + } + + window = gnt_box_new(FALSE, TRUE); + gnt_box_set_toplevel(GNT_BOX(window), TRUE); + gnt_box_set_title(GNT_BOX(window), title); + gnt_box_set_fill(GNT_BOX(window), FALSE); + gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); + + if (primary) + gnt_box_add_widget(GNT_BOX(window), + gnt_label_new_with_format(primary, pf)); + if (secondary) + gnt_box_add_widget(GNT_BOX(window), + gnt_label_new_with_format(secondary, sf)); + + button = gnt_button_new(_("OK")); + gnt_box_add_widget(GNT_BOX(window), button); + g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window); + + gnt_widget_show(window); + return window; +} + +/* handle is, in all/most occasions, a GntWidget * */ +static void gg_close_notify(GaimNotifyType type, void *handle) +{ + gnt_widget_destroy(GNT_WIDGET(handle)); +} + +static void *gg_notify_formatted(const char *title, const char *primary, + const char *secondary, const char *text) +{ + /* XXX: For now, simply strip the html and use _notify_message. For future use, + * there should be some way of parsing the makrups from GntTextView */ + char *unformat = gaim_markup_strip_html(text); + char *t = g_strdup_printf("%s%s%s", + secondary ? secondary : "", + secondary ? "\n" : "", + unformat ? unformat : ""); + + void *ret = gg_notify_message(GAIM_NOTIFY_MSG_INFO, title, primary, t); + + g_free(t); + g_free(unformat); + + return ret; +} + +static void +reset_email_dialog() +{ + emaildialog.window = NULL; + emaildialog.tree = NULL; +} + +static void +setup_email_dialog() +{ + GntWidget *box, *tree, *button; + if (emaildialog.window) + return; + + emaildialog.window = box = gnt_vbox_new(FALSE); + gnt_box_set_toplevel(GNT_BOX(box), TRUE); + gnt_box_set_title(GNT_BOX(box), _("Emails")); + gnt_box_set_fill(GNT_BOX(box), FALSE); + gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID); + gnt_box_set_pad(GNT_BOX(box), 0); + + gnt_box_add_widget(GNT_BOX(box), + gnt_label_new_with_format(_("You have mail!"), GNT_TEXT_FLAG_BOLD)); + + emaildialog.tree = tree = gnt_tree_new_with_columns(3); + gnt_tree_set_column_titles(GNT_TREE(tree), _("Account"), _("From"), _("Subject")); + gnt_tree_set_show_title(GNT_TREE(tree), TRUE); + gnt_tree_set_col_width(GNT_TREE(tree), 0, 15); + gnt_tree_set_col_width(GNT_TREE(tree), 1, 25); + gnt_tree_set_col_width(GNT_TREE(tree), 2, 25); + + gnt_box_add_widget(GNT_BOX(box), tree); + + button = gnt_button_new(_("Close")); + gnt_box_add_widget(GNT_BOX(box), button); + + g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), box); + g_signal_connect(G_OBJECT(box), "destroy", G_CALLBACK(reset_email_dialog), NULL); +} + +static void * +gg_notify_emails(GaimConnection *gc, size_t count, gboolean detailed, + const char **subjects, const char **froms, const char **tos, + const char **urls) +{ + GaimAccount *account = gaim_connection_get_account(gc); + GString *message = g_string_new(NULL); + void *ret; + + if (!detailed) + { + g_string_append_printf(message, + ngettext("%s (%s) has %d new message.", + "%s (%s) has %d new messages.", + (int)count), + tos ? *tos : gaim_account_get_username(account), + gaim_account_get_protocol_name(account), (int)count); + } + else + { + setup_email_dialog(); + + gnt_tree_add_row_after(GNT_TREE(emaildialog.tree), GINT_TO_POINTER(time(NULL)), + gnt_tree_create_row(GNT_TREE(emaildialog.tree), + tos ? *tos : gaim_account_get_username(account), /* XXX: Perhaps add the prpl-name */ + froms ? *froms : "[Unknown sender]", + *subjects), + NULL, NULL); + gnt_widget_show(emaildialog.window); + return NULL; + } + + ret = gg_notify_message(GAIM_NOTIFY_MSG_INFO, _("New Mail"), _("You have mail!"), message->str); + g_string_free(message, TRUE); + return ret; +} + +static void * +gg_notify_email(GaimConnection *gc, const char *subject, const char *from, + const char *to, const char *url) +{ + return gg_notify_emails(gc, 1, subject != NULL, + subject ? &subject : NULL, + from ? &from : NULL, + to ? &to : NULL, + url ? &url : NULL); +} + +static void * +gg_notify_userinfo(GaimConnection *gc, const char *who, const char *text) +{ + /* Xeroxed from gtknotify.c */ + char *primary; + void *ui_handle; + + primary = g_strdup_printf(_("Info for %s"), who); + ui_handle = gg_notify_formatted(_("Buddy Information"), primary, NULL, text); + g_free(primary); + return ui_handle; +} + +static GaimNotifyUiOps ops = +{ + .notify_message = gg_notify_message, + .close_notify = gg_close_notify, /* The rest of the notify-uiops return a GntWidget. + These widgets should be destroyed from here. */ + .notify_formatted = gg_notify_formatted, + .notify_email = gg_notify_email, + .notify_emails = gg_notify_emails, + .notify_userinfo = gg_notify_userinfo, + + .notify_searchresults = NULL, /* We are going to need multi-column GntTree's for this */ + .notify_searchresults_new_rows = NULL, + .notify_uri = NULL /* This is of low-priority to me */ +}; + +GaimNotifyUiOps *gg_notify_get_ui_ops() +{ + return &ops; +} + +void gg_notify_init() +{ +} + +void gg_notify_uninit() +{ +} + + Copied: branches/soc-2006-file-loggers/console/gntnotify.h (from rev 16534, trunk/console/gntnotify.h) =================================================================== --- branches/soc-2006-file-loggers/console/gntnotify.h (rev 0) +++ branches/soc-2006-file-loggers/console/gntnotify.h 2006-07-21 03:34:03 UTC (rev 16535) @@ -0,0 +1,8 @@ +#include "notify.h" + +GaimNotifyUiOps *gg_notify_get_ui_ops(); + +void gg_notify_init(); + +void gg_notify_uninit(); + Modified: branches/soc-2006-file-loggers/console/gntui.c =================================================================== --- branches/soc-2006-file-loggers/console/gntui.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/gntui.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -2,16 +2,23 @@ #include "gntaccount.h" #include "gntblist.h" +#include "gntconn.h" #include "gntconv.h" +#include "gntnotify.h" void init_gnt_ui() { +#ifdef STANDALONE gnt_init(); - +#endif /* Accounts */ gg_accounts_init(); gaim_accounts_set_ui_ops(gg_accounts_get_ui_ops()); + /* Connections */ + gg_connections_init(); + gaim_connections_set_ui_ops(gg_connections_get_ui_ops()); + /* Initialize the buddy list */ gg_blist_init(); gaim_blist_set_ui_ops(gg_blist_get_ui_ops()); @@ -20,17 +27,29 @@ gg_conversation_init(); gaim_conversations_set_ui_ops(gg_conv_get_ui_ops()); + /* Notify */ + gg_notify_init(); + gaim_notify_set_ui_ops(gg_notify_get_ui_ops()); + +#ifdef STANDALONE gnt_main(); gaim_accounts_set_ui_ops(NULL); gg_accounts_uninit(); + gaim_connections_set_ui_ops(NULL); + gg_connections_uninit(); + gaim_blist_set_ui_ops(NULL); gg_blist_uninit(); gaim_conversations_set_ui_ops(NULL); gg_conversation_uninit(); + gaim_notify_set_ui_ops(NULL); + gg_notify_uninit(); + gnt_quit(); +#endif } Modified: branches/soc-2006-file-loggers/console/libgnt/gntbox.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntbox.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gntbox.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -173,31 +173,30 @@ if (maxw < w) maxw = w; } - - if (box->homogeneous) + + for (iter = box->list; iter; iter = iter->next) { - for (iter = box->list; iter; iter = iter->next) + int w, h; + GntWidget *wid = GNT_WIDGET(iter->data); + + gnt_widget_get_size(wid, &w, &h); + + if (box->homogeneous) { - gnt_widget_set_size(GNT_WIDGET(iter->data), maxw, maxh); + if (box->vertical) + h = maxh; + else + w = maxw; } - } - else - { - for (iter = box->list; iter; iter = iter->next) + if (box->fill) { if (box->vertical) - { - int h; - gnt_widget_get_size(GNT_WIDGET(iter->data), NULL, &h); - gnt_widget_set_size(GNT_WIDGET(iter->data), maxw, h); - } + w = maxw; else - { - int w; - gnt_widget_get_size(GNT_WIDGET(iter->data), &w, NULL); - gnt_widget_set_size(GNT_WIDGET(iter->data), w, maxh); - } + h = maxh; } + + gnt_widget_set_size(wid, w, h); } reposition_children(widget); @@ -495,6 +494,7 @@ box->homogeneous = homo; box->vertical = vert; box->pad = 1; + box->fill = TRUE; gnt_widget_set_take_focus(widget, TRUE); GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); if (vert) @@ -669,3 +669,8 @@ } } +void gnt_box_set_fill(GntBox *box, gboolean fill) +{ + box->fill = fill; +} + Modified: branches/soc-2006-file-loggers/console/libgnt/gntbox.h =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntbox.h 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gntbox.h 2006-07-21 03:34:03 UTC (rev 16535) @@ -33,6 +33,7 @@ gboolean vertical; gboolean homogeneous; + gboolean fill; GList *list; /* List of widgets */ GntWidget *active; @@ -85,6 +86,8 @@ void gnt_box_readjust(GntBox *box); +void gnt_box_set_fill(GntBox *box, gboolean fill); + G_END_DECLS #endif /* GNT_BOX_H */ Modified: branches/soc-2006-file-loggers/console/libgnt/gntcolors.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntcolors.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gntcolors.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -1,10 +1,40 @@ #include <ncursesw/ncurses.h> #include "gntcolors.h" +static struct +{ + short r, g, b; +} colors[GNT_TOTAL_COLORS]; + +static void +backup_colors() +{ + short i; + for (i = 0; i < GNT_TOTAL_COLORS; i++) + { + color_content(i, &colors[i].r, + &colors[i].g, &colors[i].b); + } +} + +static void +restore_colors() +{ + short i; + for (i = 0; i < GNT_TOTAL_COLORS; i++) + { + init_color(i, colors[i].r, + colors[i].g, colors[i].b); + } +} + void gnt_init_colors() { + start_color(); if (can_change_color()) { + backup_colors(); + /* XXX: Do some init_color()s */ init_color(GNT_COLOR_BLACK, 0, 0, 0); init_color(GNT_COLOR_RED, 1000, 0, 0); @@ -39,3 +69,9 @@ } } +void +gnt_uninit_colors() +{ + restore_colors(); +} + Modified: branches/soc-2006-file-loggers/console/libgnt/gntcolors.h =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntcolors.h 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gntcolors.h 2006-07-21 03:34:03 UTC (rev 16535) @@ -32,4 +32,6 @@ /* populate some default colors */ void gnt_init_colors(); +void gnt_uninit_colors(); + #endif Modified: branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -235,7 +235,8 @@ void gnt_combo_box_add_data(GntComboBox *box, gpointer key, const char *text) { - gnt_tree_add_row_after(GNT_TREE(box->dropdown), key, text, NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(box->dropdown), key, + gnt_tree_create_row(GNT_TREE(box->dropdown), text), NULL, NULL); if (box->selected == NULL) set_selection(box, key); } Modified: branches/soc-2006-file-loggers/console/libgnt/gntlabel.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntlabel.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gntlabel.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -21,8 +21,9 @@ gnt_label_draw(GntWidget *widget) { GntLabel *label = GNT_LABEL(widget); + chtype flag = gnt_text_format_flag_to_chtype(label->flags); - wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); + wbkgdset(widget->window, '\0' | flag); mvwprintw(widget->window, 0, 0, label->text); DEBUG; @@ -109,13 +110,32 @@ GntWidget *gnt_label_new(const char *text) { + return gnt_label_new_with_format(text, 0); +} + +GntWidget *gnt_label_new_with_format(const char *text, GntTextFormatFlags flags) +{ GntWidget *widget = g_object_new(GNT_TYPE_LABEL, NULL); GntLabel *label = GNT_LABEL(widget); label->text = g_strdup(text); + label->flags = flags; gnt_widget_set_take_focus(widget, FALSE); GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); return widget; } +void gnt_label_set_text(GntLabel *label, const char *text) +{ + g_free(label->text); + label->text = g_strdup(text); + + if (GNT_WIDGET(label)->window) + { + gnt_widget_hide(GNT_WIDGET(label)); + gnt_label_size_request(GNT_WIDGET(label)); + gnt_widget_draw(GNT_WIDGET(label)); + } +} + Modified: branches/soc-2006-file-loggers/console/libgnt/gntlabel.h =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntlabel.h 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gntlabel.h 2006-07-21 03:34:03 UTC (rev 16535) @@ -3,6 +3,7 @@ #include "gnt.h" #include "gntwidget.h" +#include "gnttextview.h" #define GNT_TYPE_LABEL (gnt_label_get_gtype()) #define GNT_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_LABEL, GntLabel)) @@ -19,6 +20,7 @@ GntWidget parent; char *text; + GntTextFormatFlags flags; void (*gnt_reserved1)(void); void (*gnt_reserved2)(void); @@ -42,6 +44,10 @@ GntWidget *gnt_label_new(const char *text); +GntWidget *gnt_label_new_with_format(const char *text, GntTextFormatFlags flags); + +void gnt_label_set_text(GntLabel *label, const char *text); + G_END_DECLS #endif /* GNT_LABEL_H */ Modified: branches/soc-2006-file-loggers/console/libgnt/gntline.h =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntline.h 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gntline.h 2006-07-21 03:34:03 UTC (rev 16535) @@ -42,6 +42,9 @@ GType gnt_line_get_gtype(void); +#define gnt_hline_new() gnt_line_new(FALSE) +#define gnt_vline_new() gnt_line_new(TRUE) + GntWidget *gnt_line_new(gboolean vertical); G_END_DECLS Modified: branches/soc-2006-file-loggers/console/libgnt/gntmain.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntmain.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gntmain.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -258,13 +258,16 @@ { GntBox *box = GNT_BOX(iter->data); - gnt_tree_add_row_after(GNT_TREE(tree), box, box->title, NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), box, + gnt_tree_create_row(GNT_TREE(tree), box->title), NULL, NULL); update_window_in_list(GNT_WIDGET(box)); } + gnt_tree_set_selected(GNT_TREE(tree), focus_list->data); gnt_box_add_widget(GNT_BOX(win), tree); - gnt_widget_set_size(tree, getmaxx(stdscr) / 3, getmaxy(stdscr) / 2); + gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3); + gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2); gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4); lock_focus_list = 1; @@ -274,6 +277,34 @@ g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), NULL); } +static void +shift_window(GntWidget *widget, int dir) +{ + GList *all = g_list_first(focus_list); + GList *list = g_list_find(all, widget); + int length, pos; + if (!list) + return; + + length = g_list_length(all); + pos = g_list_position(all, list); + + pos += dir; + if (dir > 0) + pos++; + + if (pos < 0) + pos = length; + else if (pos > length) + pos = 0; + + all = g_list_insert(all, widget, pos); + all = g_list_delete_link(all, list); + if (focus_list == list) + focus_list = g_list_find(all, widget); + draw_taskbar(); +} + static gboolean io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) { @@ -350,6 +381,15 @@ /* Resize window */ mode = GNT_KP_MODE_RESIZE; } + else if (strcmp(buffer + 1, ",") == 0 && focus_list) + { + /* Re-order the list of windows */ + shift_window(focus_list->data, -1); + } + else if (strcmp(buffer + 1, ".") == 0 && focus_list) + { + shift_window(focus_list->data, 1); + } } } } @@ -501,7 +541,6 @@ ascii_only = TRUE; initscr(); - start_color(); gnt_init_colors(); X_MIN = 0; @@ -564,7 +603,8 @@ && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) { gnt_tree_add_row_after(GNT_TREE(window_list.tree), widget, - GNT_BOX(widget)->title, NULL, NULL); + gnt_tree_create_row(GNT_TREE(window_list.tree), GNT_BOX(widget)->title), + NULL, NULL); update_window_in_list(widget); } } @@ -654,6 +694,7 @@ void gnt_quit() { + gnt_uninit_colors(); endwin(); } Modified: branches/soc-2006-file-loggers/console/libgnt/gnttextview.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gnttextview.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gnttextview.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -178,20 +178,8 @@ if (text == NULL || *text == '\0') return; - if (flags & GNT_TEXT_FLAG_BOLD) - fl |= A_BOLD; - if (flags & GNT_TEXT_FLAG_UNDERLINE) - fl |= A_UNDERLINE; - if (flags & GNT_TEXT_FLAG_BLINK) - fl |= A_BLINK; + fl = gnt_text_format_flag_to_chtype(flags); - if (flags & GNT_TEXT_FLAG_DIM) - fl |= (A_DIM | COLOR_PAIR(GNT_COLOR_DISABLED)); - else if (flags & GNT_TEXT_FLAG_HIGHLIGHT) - fl |= (A_DIM | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); - else - fl |= COLOR_PAIR(GNT_COLOR_NORMAL); - view->list = g_list_first(view->list); split = g_strsplit(text, "\n", 0); @@ -262,3 +250,39 @@ gnt_widget_draw(GNT_WIDGET(view)); } +chtype gnt_text_format_flag_to_chtype(GntTextFormatFlags flags) +{ + chtype fl = 0; + + if (flags & GNT_TEXT_FLAG_BOLD) + fl |= A_BOLD; + if (flags & GNT_TEXT_FLAG_UNDERLINE) + fl |= A_UNDERLINE; + if (flags & GNT_TEXT_FLAG_BLINK) + fl |= A_BLINK; + + if (flags & GNT_TEXT_FLAG_DIM) + fl |= (A_DIM | COLOR_PAIR(GNT_COLOR_DISABLED)); + else if (flags & GNT_TEXT_FLAG_HIGHLIGHT) + fl |= (A_DIM | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); + else + fl |= COLOR_PAIR(GNT_COLOR_NORMAL); + + return fl; +} + +void gnt_text_view_clear(GntTextView *view) +{ + GntTextLine *line; + + g_list_foreach(view->list, free_text_line, NULL); + g_list_free(view->list); + view->list = NULL; + + line = g_new0(GntTextLine, 1); + view->list = g_list_append(view->list, line); + + if (GNT_WIDGET(view)->window) + gnt_widget_draw(GNT_WIDGET(view)); +} + Modified: branches/soc-2006-file-loggers/console/libgnt/gnttextview.h =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gnttextview.h 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gnttextview.h 2006-07-21 03:34:03 UTC (rev 16535) @@ -30,6 +30,7 @@ typedef enum { + GNT_TEXT_FLAG_NORMAL = 0, GNT_TEXT_FLAG_BOLD = 1 << 0, GNT_TEXT_FLAG_UNDERLINE = 1 << 1, GNT_TEXT_FLAG_BLINK = 1 << 2, @@ -64,6 +65,10 @@ * It first completes the current line with the current text-attributes. */ void gnt_text_view_next_line(GntTextView *view); +chtype gnt_text_format_flag_to_chtype(GntTextFormatFlags flags); + +void gnt_text_view_clear(GntTextView *view); + G_END_DECLS #endif /* GNT_TEXT_VIEW_H */ Modified: branches/soc-2006-file-loggers/console/libgnt/gnttree.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gnttree.c 2006-07-20 21:43:15 UTC (rev 16534) +++ branches/soc-2006-file-loggers/console/libgnt/gnttree.c 2006-07-21 03:34:03 UTC (rev 16535) @@ -18,7 +18,6 @@ struct _GnTreeRow { void *key; - char *text; void *data; /* XXX: unused */ gboolean collapsed; @@ -31,8 +30,16 @@ GntTreeRow *child; GntTreeRow *next; GntTreeRow *prev; + + GList *columns; }; +struct _GnTreeCol +{ + char *text; + int span; /* How many columns does it span? */ +}; + static GntWidgetClass *parent_class = NULL; static guint signals[SIGS] = { 0 }; @@ -151,14 +158,98 @@ return (hb - ha); } +static int +find_depth(GntTreeRow *row) +{ + int dep = -1; + + while (row) + { + dep++; + row = row->parent; + } + + return dep; +} + +static char * +update_row_text(GntTree *tree, GntTreeRow *row) +{ + GString *string = g_string_new(NULL); + GList *iter; + int i; + + for (i = 0, iter = row->columns; i < tree->ncol && iter; i++, iter = iter->next) + { + GntTreeCol *col = iter->data; + char *text; + int len = g_utf8_strlen(col->text, -1); + int fl = 0; + + if (i == 0) + { + if (row->choice) + { + g_string_append_printf(string, "[%c] ", + row->isselected ? 'X' : ' '); + fl = 4; + } + else if (row->parent == NULL && row->child) + { + if (row->collapsed) + { + string = g_string_append(string, "+ "); + } + else + { + string = g_string_append(string, "- "); + } + fl = 2; + } + else + { + fl = TAB_SIZE * find_depth(row); + g_string_append_printf(string, "%*s", fl, ""); + } + len += fl; + } + else + g_string_append_c(string, '|'); + + if (len > tree->columns[i].width) + { + len = tree->columns[i].width; + } + + text = g_utf8_offset_to_pointer(col->text, len - fl); + string = g_string_append_len(string, col->text, text - col->text); + if (len < tree->columns[i].width) + g_string_append_printf(string, "%*s", tree->columns[i].width - len, ""); + } + return g_string_free(string, FALSE); +} + static void +tree_mark_columns(GntTree *tree, int pos, int y, chtype type) +{ + GntWidget *widget = GNT_WIDGET(tree); + int i; + int x = pos; + + for (i = 0; i < tree->ncol - 1; i++) + { + x += tree->columns[i].width; + mvwaddch(widget->window, y, x + i, type); + } +} + +static void redraw_tree(GntTree *tree) { int start; GntWidget *widget = GNT_WIDGET(tree); GntTreeRow *row; int pos; - gboolean deep; if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) pos = 0; @@ -172,37 +263,39 @@ wbkgd(widget->window, COLOR_PAIR(GNT_COLOR_NORMAL)); - deep = TRUE; + start = 0; + if (tree->show_title) + { + int i; + int x = pos; + + mvwhline(widget->window, pos + 1, pos, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), + widget->priv.width - pos - 1); + + for (i = 0; i < tree->ncol; i++) + { + mvwprintw(widget->window, pos, x + i, tree->columns[i].title); + x += tree->columns[i].width; + } + if (pos) + tree_mark_columns(tree, pos, 0, ACS_TTEE | COLOR_PAIR(GNT_COLOR_NORMAL)); + tree_mark_columns(tree, pos, pos + 1, ACS_PLUS | COLOR_PAIR(GNT_COLOR_NORMAL)); + tree_mark_columns(tree, pos, pos, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL)); + start = 2; + } + row = tree->top; - for (start = pos; row && start < widget->priv.height - pos; + for (start = start + pos; row && start < widget->priv.height - pos; start++, row = get_next(row)) { - char str[2048]; + char *str; int wr; - char format[16] = ""; GntTextFormatFlags flags = row->flags; int attr = 0; - deep = TRUE; + str = update_row_text(tree, row); - if (row->parent == NULL && row->child) - { - if (row->collapsed) - { - strcpy(format, "+ "); - deep = FALSE; - } - else - strcpy(format, "- "); - } - else if (row->choice) - { - g_snprintf(format, sizeof(format) - 1, "[%c] ", row->isselected ? 'X' : ' '); - } - - g_snprintf(str, sizeof(str) - 1, "%s%s", format, row->text); - if ((wr = g_utf8_strlen(str, -1)) >= widget->priv.width - 1 - pos) { /* XXX: ellipsize */ @@ -238,6 +331,8 @@ mvwprintw(widget->window, start, pos, str); whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1)); tree->bottom = row; + g_free(str); + tree_mark_columns(tree, pos, start, ACS_VLINE | attr); } wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); @@ -245,6 +340,7 @@ { mvwhline(widget->window, start, pos, ' ', widget->priv.width - pos * 2); + tree_mark_columns(tree, pos, start, ACS_VLINE); start++; } @@ -267,7 +363,13 @@ if (widget->priv.height == 0) widget->priv.height = 10; /* XXX: Why?! */ if (widget->priv.width == 0) - widget->priv.width = 20; /* YYY: 'cuz ... */ + { + GntTree *tree = GNT_TREE(widget); + int i, width = 0; + for (i = 0; i < tree->ncol; i++) + width += tree->columns[i].width; + widget->priv.width = width + i; + } } static void @@ -353,9 +455,16 @@ gnt_tree_destroy(GntWidget *widget) { GntTree *tree = GNT_TREE(widget); + int i; g_hash_table_destroy(tree->hash); g_list_free(tree->list); + + for (i = 0; i < tree->ncol; i++) + { + g_free(tree->columns[i].title); + } + g_free(tree->columns); } static void @@ -437,6 +546,15 @@ } static void +free_tree_col(gpointer data) +{ + GntTreeCol *col = data; + + g_free(col->text); + g_free(col); +} + +static void free_tree_row(gpointer data) { GntTreeRow *row = data; @@ -444,20 +562,14 @@ if (!row) return; - g_free(row->text); + g_list_foreach(row->columns, (GFunc)free_tree_col, NULL); + g_list_free(row->columns); g_free(row); } GntWidget *gnt_tree_new() { - GntWidget *widget = g_object_new(GNT_TYPE_TREE, NULL); - GntTree *tree = GNT_TREE(widget); - - tree->hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_tree_row); - GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_SHADOW); - gnt_widget_set_take_focus(widget, TRUE); - - return widget; + return gnt_tree_new_with_columns(1); } void gnt_tree_set_visible_rows(GntTree *tree, int rows) @@ -500,24 +612,10 @@ g_signal_emit(tree, signals[SIG_SCROLLED], 0, count); } -static int -find_depth(GntTreeRow *row) +GntTreeRow *gnt_tree_add_row_after(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro) { - int dep = -1; + GntTreeRow *pr = NULL; - while (row) - { - dep++; - row = row->parent; - } - - return dep; -} - -GntTreeRow *gnt_tree_add_row_after(GntTree *tree, void *key, const char *text, void *parent, void *bigbro) -{ - GntTreeRow *row = g_new0(GntTreeRow, 1), *pr = NULL; - g_hash_table_replace(tree->hash, key, row); if (tree->root == NULL) @@ -575,7 +673,6 @@ } row->key = key; - row->text = g_strdup_printf("%*s%s", TAB_SIZE * find_depth(row), "", text); row->data = NULL; if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED)) @@ -591,10 +688,10 @@ return NULL; } -const char *gnt_tree_get_selection_text(GntTree *tree) +char *gnt_tree_get_selection_text(GntTree *tree) { if (tree->current) - return tree->current->text; + update_row_text(tree, tree->current); return NULL; } @@ -657,27 +754,32 @@ !!(GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER)); } -void gnt_tree_change_text(GntTree *tree, gpointer key, const char *text) +void gnt_tree_change_text(GntTree *tree, gpointer key, int colno, const char *text) { - GntTreeRow *row = g_hash_table_lookup(tree->hash, key); + GntTreeRow *row; + GntTreeCol *col; + + g_return_if_fail(colno < tree->ncol); + + row = g_hash_table_lookup(tree->hash, key); if (row) { - g_free(row->text); - row->text = g_strdup_printf("%*s%s", TAB_SIZE * find_depth(row), "", text); + col = g_list_nth_data(row->columns, colno); + g_free(col->text); + col->text = g_strdup(text); if (get_distance(tree->top, row) >= 0 && get_distance(row, tree->bottom) > 0) redraw_tree(tree); } } -GntTreeRow *gnt_tree_add_choice(GntTree *tree, void *key, const char *text, void *parent, void *bigbro) +GntTreeRow *gnt_tree_add_choice(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro) { - GntTreeRow *row; - - row = g_hash_table_lookup(tree->hash, key); - g_return_val_if_fail(!row || !row->choice, NULL); + GntTreeRow *r; + r = g_hash_table_lookup(tree->hash, key); + g_return_val_if_fail(!r || !r->choice, NULL); - row = gnt_tree_add_row_after(tree, key, text, parent, bigbro); + row = gnt_tree_add_row_after(tree, key, row, parent, bigbro); row->choice = TRUE; return row; @@ -716,3 +818,91 @@ redraw_tree(tree); /* XXX: It shouldn't be necessary to redraw the whole darned tree */ } +void gnt_tree_set_selected(GntTree *tree , void *key) +{ + int dist; + GntTreeRow *row = g_hash_table_lookup(tree->hash, key); + if (!row) + return; + + if (tree->top == NULL) + tree->top = row; + if (tree->bottom == NULL) + tree->bottom = row; + + tree->current = row; + if ((dist = get_distance(tree->current, tree->bottom)) < 0) + gnt_tree_scroll(tree, -dist); + else if ((dist = get_distance(tree->current, tree->top)) > 0) + gnt_tree_scroll(tree, -dist); + else + redraw_tree(tree); +} + +GntWidget *gnt_tree_new_with_columns(int col) +{ + GntWidget *widget = g_object_new(GNT_TYPE_TR... [truncated message content] |
From: <sa...@us...> - 2006-07-20 21:43:25
|
Revision: 16534 Author: sadrul Date: 2006-07-20 14:43:15 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16534&view=rev Log Message: ----------- Some more memleaks. Modified Paths: -------------- trunk/src/gtknotify.c trunk/src/notify.c Modified: trunk/src/gtknotify.c =================================================================== --- trunk/src/gtknotify.c 2006-07-20 19:51:34 UTC (rev 16533) +++ trunk/src/gtknotify.c 2006-07-20 21:43:15 UTC (rev 16534) @@ -53,6 +53,7 @@ GtkWidget *treeview; GtkWidget *window; gpointer user_data; + GaimNotifySearchResults *results; } GaimNotifySearchResultsData; @@ -684,6 +685,7 @@ data = g_malloc(sizeof(GaimNotifySearchResultsData)); data->user_data = user_data; + data->results = results; /* Create the window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -812,6 +814,7 @@ g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(searchresults_callback_wrapper_cb), bd); + g_signal_connect_swapped(G_OBJECT(button), "destroy", G_CALLBACK(g_free), bd); } } @@ -864,6 +867,7 @@ GaimNotifySearchResultsData *data = (GaimNotifySearchResultsData *)ui_handle; gtk_widget_destroy(data->window); + gaim_notify_searchresults_free(data->results); g_free(data); } Modified: trunk/src/notify.c =================================================================== --- trunk/src/notify.c 2006-07-20 19:51:34 UTC (rev 16533) +++ trunk/src/notify.c 2006-07-20 21:43:15 UTC (rev 16534) @@ -200,6 +200,7 @@ for (l = results->buttons; l; l = g_list_delete_link(l, l)) { GaimNotifySearchButton *button = l->data; + g_free(button->label); g_free(button); } results->buttons = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-07-20 19:51:39
|
Revision: 16533 Author: sadrul Date: 2006-07-20 12:51:34 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16533&view=rev Log Message: ----------- More memleak. Modified Paths: -------------- trunk/src/gtknotify.c Modified: trunk/src/gtknotify.c =================================================================== --- trunk/src/gtknotify.c 2006-07-20 18:54:26 UTC (rev 16532) +++ trunk/src/gtknotify.c 2006-07-20 19:51:34 UTC (rev 16533) @@ -191,6 +191,8 @@ button = bd->button; button->callback(gaim_account_get_connection(data->account), row, data->user_data); + g_list_foreach(row, (GFunc)g_free, NULL); + g_list_free(row); } static void * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2006-07-20 18:54:37
|
Revision: 16532 Author: evands Date: 2006-07-20 11:54:26 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16532&view=rev Log Message: ----------- On my system and in all the documentation I can find, the tm_zone field of the tm struct, if present, is a (char *), not a (const char *). This fixes two (harmless) compilation warnings resulting from the cast to (const char *). Modified Paths: -------------- trunk/src/log.c Modified: trunk/src/log.c =================================================================== --- trunk/src/log.c 2006-07-20 18:32:09 UTC (rev 16531) +++ trunk/src/log.c 2006-07-20 18:54:26 UTC (rev 16532) @@ -107,10 +107,10 @@ { char *tmp = g_locale_from_utf8(log->tm->tm_zone, -1, NULL, NULL, NULL); if (tmp != NULL) - log->tm->tm_zone = (const char *)tmp; + log->tm->tm_zone = tmp; else /* Just shove the UTF-8 bytes in and hope... */ - log->tm->tm_zone = (const char *)g_strdup(log->tm->tm_zone); + log->tm->tm_zone = (char *)g_strdup(log->tm->tm_zone); } #endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2006-07-20 18:32:16
|
Revision: 16531 Author: evands Date: 2006-07-20 11:32:09 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16531&view=rev Log Message: ----------- I see a lot of crashes from callbacks (mostly originating in proxy.c code) that end up crashing in gaim_connection_error() because the connection is invalid. Added a g_return_if_fail() on the connection being valid to protect against that condition as well as log it. Modified Paths: -------------- trunk/src/connection.c Modified: trunk/src/connection.c =================================================================== --- trunk/src/connection.c 2006-07-20 17:54:08 UTC (rev 16530) +++ trunk/src/connection.c 2006-07-20 18:32:09 UTC (rev 16531) @@ -423,6 +423,7 @@ GaimConnectionUiOps *ops; g_return_if_fail(gc != NULL); + g_return_if_fail(GAIM_CONNECTION_IS_VALID(gc)); g_return_if_fail(text != NULL); /* If we've already got one error, we don't need any more */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-07-20 17:54:21
|
Revision: 16530 Author: sadrul Date: 2006-07-20 10:54:08 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16530&view=rev Log Message: ----------- Memleak. Modified Paths: -------------- trunk/src/gtkconv.c Modified: trunk/src/gtkconv.c =================================================================== --- trunk/src/gtkconv.c 2006-07-20 17:38:09 UTC (rev 16529) +++ trunk/src/gtkconv.c 2006-07-20 17:54:08 UTC (rev 16530) @@ -417,6 +417,7 @@ g_string_append_printf(s, "%s, ", (char *)l->data); else g_string_append_printf(s, "%s.", (char *)l->data); + g_list_free(text); } gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-07-20 17:38:22
|
Revision: 16529 Author: sadrul Date: 2006-07-20 10:38:09 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16529&view=rev Log Message: ----------- Make multi-column trees look nice. Show the list of users in a chat-room after you join. Add some commands (eg. /me, /help etc., all Xeroxed from gtkconv.c) Modified Paths: -------------- trunk/console/gntconv.c trunk/console/gntnotify.c trunk/console/libgnt/gnttextview.c trunk/console/libgnt/gnttextview.h trunk/console/libgnt/gnttree.c trunk/console/libgnt/gnttree.h trunk/console/libgnt/test/multiwin.c Modified: trunk/console/gntconv.c =================================================================== --- trunk/console/gntconv.c 2006-07-20 13:04:35 UTC (rev 16528) +++ trunk/console/gntconv.c 2006-07-20 17:38:09 UTC (rev 16529) @@ -245,11 +245,12 @@ { if (flags & GAIM_MESSAGE_SEND) { - who = gaim_connection_get_display_name(conv->account->gc); + GaimAccount *account = gaim_conversation_get_account(conv); + who = gaim_connection_get_display_name(gaim_account_get_connection(account)); if (!who) - who = gaim_account_get_alias(conv->account); + who = gaim_account_get_alias(account); if (!who) - who = gaim_account_get_username(conv->account); + who = gaim_account_get_username(account); } else if (flags & GAIM_MESSAGE_RECV) who = gaim_conversation_get_name(conv); @@ -273,20 +274,48 @@ } static void -gg_chat_add_users(GaimConversation *conv, GList *users, GList *flags, GList *aliases, gboolean new_arrivals) -{} +gg_chat_add_users(GaimConversation *conv, GList *users, gboolean new_arrivals) +{ + if (!new_arrivals) + { + /* Print the list of users in the room */ + GString *string = g_string_new(_("List of users:\n")); + GList *iter; + for (iter = users; iter; iter = iter->next) + { + GaimConvChatBuddy *cbuddy = iter->data; + char *str; + + if ((str = cbuddy->alias) == NULL) + str = cbuddy->name; + g_string_append_printf(string, "[ %s ]", str); + } + + gaim_conversation_write(conv, NULL, string->str, + GAIM_MESSAGE_SYSTEM, time(NULL)); + g_string_free(string, TRUE); + } + /* XXX: Add the names for string completion */ +} + static void gg_chat_rename_user(GaimConversation *conv, const char *old, const char *new_n, const char *new_a) -{} +{ + /* XXX: Update the name for string completion */ +} static void gg_chat_remove_user(GaimConversation *conv, GList *list) -{} +{ + /* XXX: Remove the name from string completion */ +} static void gg_chat_update_user(GaimConversation *conv, const char *user) -{} +{ + /* XXX: This probably will not require updating the string completion */ +} static GaimConversationUiOps conv_ui_ops = { @@ -309,9 +338,9 @@ static void destroy_ggconv(gpointer data) { - GGConv *conv = data; - gnt_widget_destroy(conv->window); - g_free(conv); + GGConv *ggconv = data; + gnt_widget_destroy(ggconv->window); + g_free(ggconv); } GaimConversationUiOps *gg_conv_get_ui_ops() @@ -319,10 +348,132 @@ return &conv_ui_ops; } +/* Xerox */ +static GaimCmdRet +say_command_cb(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) + gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); + else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) + gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); + return GAIM_CMD_RET_OK; +} + +/* Xerox */ +static GaimCmdRet +me_command_cb(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + char *tmp; + + tmp = g_strdup_printf("/me %s", args[0]); + + if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) + gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); + else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) + gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); + + g_free(tmp); + return GAIM_CMD_RET_OK; +} + +/* Xerox */ +static GaimCmdRet +debug_command_cb(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + char *tmp, *markup; + GaimCmdStatus status; + + if (!g_ascii_strcasecmp(args[0], "version")) { + tmp = g_strdup_printf("me is using %s.", VERSION); + markup = g_markup_escape_text(tmp, -1); + + status = gaim_cmd_do_command(conv, tmp, markup, error); + + g_free(tmp); + g_free(markup); + return status; + } else { + gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), + GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); + return GAIM_CMD_STATUS_OK; + } +} + +/* Xerox */ +static GaimCmdRet +clear_command_cb(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + GGConv *ggconv = conv->ui_data; + gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv)); + return GAIM_CMD_STATUS_OK; +} + +/* Xerox */ +static GaimCmdRet +help_command_cb(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + GList *l, *text; + GString *s; + + if (args[0] != NULL) { + s = g_string_new(""); + text = gaim_cmd_help(conv, args[0]); + + if (text) { + for (l = text; l; l = l->next) + if (l->next) + g_string_append_printf(s, "%s\n", (char *)l->data); + else + g_string_append_printf(s, "%s", (char *)l->data); + } else { + g_string_append(s, _("No such command (in this context).")); + } + } else { + s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" + "The following commands are available in this context:\n")); + + text = gaim_cmd_list(conv); + for (l = text; l; l = l->next) + if (l->next) + g_string_append_printf(s, "%s, ", (char *)l->data); + else + g_string_append_printf(s, "%s.", (char *)l->data); + g_list_free(text); + } + + gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); + g_string_free(s, TRUE); + + return GAIM_CMD_STATUS_OK; +} + + void gg_conversation_init() { ggconvs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_ggconv); + + /* Xerox */ + gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, + say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); + gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, + me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); + gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, + debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); + gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, + clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); + gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, + help_command_cb, _("help <command>: Help on a specific command."), NULL); } void gg_conversation_uninit() Modified: trunk/console/gntnotify.c =================================================================== --- trunk/console/gntnotify.c 2006-07-20 13:04:35 UTC (rev 16528) +++ trunk/console/gntnotify.c 2006-07-20 17:38:09 UTC (rev 16529) @@ -104,6 +104,8 @@ gnt_label_new_with_format(_("You have mail!"), GNT_TEXT_FLAG_BOLD)); emaildialog.tree = tree = gnt_tree_new_with_columns(3); + gnt_tree_set_column_titles(GNT_TREE(tree), _("Account"), _("From"), _("Subject")); + gnt_tree_set_show_title(GNT_TREE(tree), TRUE); gnt_tree_set_col_width(GNT_TREE(tree), 0, 15); gnt_tree_set_col_width(GNT_TREE(tree), 1, 25); gnt_tree_set_col_width(GNT_TREE(tree), 2, 25); @@ -141,7 +143,7 @@ gnt_tree_add_row_after(GNT_TREE(emaildialog.tree), GINT_TO_POINTER(time(NULL)), gnt_tree_create_row(GNT_TREE(emaildialog.tree), - tos ? *tos : gaim_account_get_username(account), + tos ? *tos : gaim_account_get_username(account), /* XXX: Perhaps add the prpl-name */ froms ? *froms : "[Unknown sender]", *subjects), NULL, NULL); Modified: trunk/console/libgnt/gnttextview.c =================================================================== --- trunk/console/libgnt/gnttextview.c 2006-07-20 13:04:35 UTC (rev 16528) +++ trunk/console/libgnt/gnttextview.c 2006-07-20 17:38:09 UTC (rev 16529) @@ -271,3 +271,18 @@ return fl; } +void gnt_text_view_clear(GntTextView *view) +{ + GntTextLine *line; + + g_list_foreach(view->list, free_text_line, NULL); + g_list_free(view->list); + view->list = NULL; + + line = g_new0(GntTextLine, 1); + view->list = g_list_append(view->list, line); + + if (GNT_WIDGET(view)->window) + gnt_widget_draw(GNT_WIDGET(view)); +} + Modified: trunk/console/libgnt/gnttextview.h =================================================================== --- trunk/console/libgnt/gnttextview.h 2006-07-20 13:04:35 UTC (rev 16528) +++ trunk/console/libgnt/gnttextview.h 2006-07-20 17:38:09 UTC (rev 16529) @@ -67,6 +67,8 @@ chtype gnt_text_format_flag_to_chtype(GntTextFormatFlags flags); +void gnt_text_view_clear(GntTextView *view); + G_END_DECLS #endif /* GNT_TEXT_VIEW_H */ Modified: trunk/console/libgnt/gnttree.c =================================================================== --- trunk/console/libgnt/gnttree.c 2006-07-20 13:04:35 UTC (rev 16528) +++ trunk/console/libgnt/gnttree.c 2006-07-20 17:38:09 UTC (rev 16529) @@ -185,7 +185,6 @@ char *text; int len = g_utf8_strlen(col->text, -1); int fl = 0; - gboolean ell = FALSE; if (i == 0) { @@ -220,22 +219,31 @@ if (len > tree->columns[i].width) { len = tree->columns[i].width; - ell = TRUE; } - text = g_utf8_offset_to_pointer(col->text, len - fl - ell); + text = g_utf8_offset_to_pointer(col->text, len - fl); string = g_string_append_len(string, col->text, text - col->text); if (len < tree->columns[i].width) g_string_append_printf(string, "%*s", tree->columns[i].width - len, ""); - else if (ell) - { - g_string_append_unichar(string, (gunichar)2026); - } } return g_string_free(string, FALSE); } static void +tree_mark_columns(GntTree *tree, int pos, int y, chtype type) +{ + GntWidget *widget = GNT_WIDGET(tree); + int i; + int x = pos; + + for (i = 0; i < tree->ncol - 1; i++) + { + x += tree->columns[i].width; + mvwaddch(widget->window, y, x + i, type); + } +} + +static void redraw_tree(GntTree *tree) { int start; @@ -255,8 +263,29 @@ wbkgd(widget->window, COLOR_PAIR(GNT_COLOR_NORMAL)); + start = 0; + if (tree->show_title) + { + int i; + int x = pos; + + mvwhline(widget->window, pos + 1, pos, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), + widget->priv.width - pos - 1); + + for (i = 0; i < tree->ncol; i++) + { + mvwprintw(widget->window, pos, x + i, tree->columns[i].title); + x += tree->columns[i].width; + } + if (pos) + tree_mark_columns(tree, pos, 0, ACS_TTEE | COLOR_PAIR(GNT_COLOR_NORMAL)); + tree_mark_columns(tree, pos, pos + 1, ACS_PLUS | COLOR_PAIR(GNT_COLOR_NORMAL)); + tree_mark_columns(tree, pos, pos, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL)); + start = 2; + } + row = tree->top; - for (start = pos; row && start < widget->priv.height - pos; + for (start = start + pos; row && start < widget->priv.height - pos; start++, row = get_next(row)) { char *str; @@ -303,6 +332,7 @@ whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1)); tree->bottom = row; g_free(str); + tree_mark_columns(tree, pos, start, ACS_VLINE | attr); } wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); @@ -310,6 +340,7 @@ { mvwhline(widget->window, start, pos, ' ', widget->priv.width - pos * 2); + tree_mark_columns(tree, pos, start, ACS_VLINE); start++; } @@ -424,9 +455,16 @@ gnt_tree_destroy(GntWidget *widget) { GntTree *tree = GNT_TREE(widget); + int i; g_hash_table_destroy(tree->hash); g_list_free(tree->list); + + for (i = 0; i < tree->ncol; i++) + { + g_free(tree->columns[i].title); + } + g_free(tree->columns); } static void @@ -813,6 +851,7 @@ { tree->columns[col].width = 15; } + tree->show_title = FALSE; GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_SHADOW); gnt_widget_set_take_focus(widget, TRUE); @@ -836,6 +875,7 @@ row->columns = g_list_append(row->columns, col); } + va_end(args); return row; } @@ -847,3 +887,22 @@ tree->columns[col].width = width; } +void gnt_tree_set_column_titles(GntTree *tree, ...) +{ + int i; + va_list args; + + va_start(args, tree); + for (i = 0; i < tree->ncol; i++) + { + const char *title = va_arg(args, const char *); + tree->columns[i].title = g_strdup(title); + } + va_end(args); +} + +void gnt_tree_set_show_title(GntTree *tree, gboolean set) +{ + tree->show_title = set; +} + Modified: trunk/console/libgnt/gnttree.h =================================================================== --- trunk/console/libgnt/gnttree.h 2006-07-20 13:04:35 UTC (rev 16528) +++ trunk/console/libgnt/gnttree.h 2006-07-20 17:38:09 UTC (rev 16529) @@ -37,14 +37,15 @@ GntTreeRow *root; /* The root of all evil */ GList *list; /* List of GntTreeRow s */ - GHashTable *hash; /* XXX: We may need this for quickly referencing the rows */ + GHashTable *hash; /* We need this for quickly referencing the rows */ int ncol; /* No. of columns */ struct _GntTreeColInfo { int width; - int *name; + char *title; } *columns; /* Would a GList be better? */ + gboolean show_title; }; struct _GnTreeClass @@ -100,6 +101,10 @@ void gnt_tree_set_col_width(GntTree *tree, int col, int width); +void gnt_tree_set_column_titles(GntTree *tree, ...); + +void gnt_tree_set_show_title(GntTree *tree, gboolean set); + G_END_DECLS #endif /* GNT_TREE_H */ Modified: trunk/console/libgnt/test/multiwin.c =================================================================== --- trunk/console/libgnt/test/multiwin.c 2006-07-20 13:04:35 UTC (rev 16528) +++ trunk/console/libgnt/test/multiwin.c 2006-07-20 17:38:09 UTC (rev 16529) @@ -26,7 +26,9 @@ gnt_widget_set_name(hbox, "hbox"); gnt_widget_set_name(box2, "box2"); - tree = gnt_tree_new(); + tree = gnt_tree_new_with_columns(3); + gnt_tree_set_column_titles(GNT_TREE(tree), "12345678901234567890", "column 2", "column3"); + gnt_tree_set_show_title(GNT_TREE(tree), TRUE); gnt_widget_set_name(tree, "tree"); gnt_box_add_widget(GNT_BOX(hbox), tree); @@ -43,19 +45,21 @@ gnt_widget_set_position(box2, 35, 15); gnt_widget_show(box2); - gnt_tree_add_row_after(GNT_TREE(tree), "a", gnt_tree_create_row(GNT_TREE(tree), "a"), NULL, NULL); - gnt_tree_add_row_after(GNT_TREE(tree), "c", gnt_tree_create_row(GNT_TREE(tree), "c"), NULL, NULL); - gnt_tree_add_row_after(GNT_TREE(tree), "d", gnt_tree_create_row(GNT_TREE(tree), "d"), NULL, NULL); - gnt_tree_add_row_after(GNT_TREE(tree), "e", gnt_tree_create_row(GNT_TREE(tree), "e"), "a", NULL); - gnt_tree_add_row_after(GNT_TREE(tree), "b", gnt_tree_create_row(GNT_TREE(tree), "b"), "d", NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "a", + gnt_tree_create_row(GNT_TREE(tree), "alaskdjfkashfashfah kfalkdhflsiafhlasf", " long text", "a2"), NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "c", + gnt_tree_create_row(GNT_TREE(tree), "casdgertqhyeqgasfeytwfga fg arf agfwa ", " long text", "a2"), NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "d", gnt_tree_create_row(GNT_TREE(tree), "d", " long text", "a2"), NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "e", gnt_tree_create_row(GNT_TREE(tree), "e", " long text", "a2"), "a", NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "b", gnt_tree_create_row(GNT_TREE(tree), "b", "this is", "a2"), "d", NULL); - gnt_tree_add_choice(GNT_TREE(tree), "1", gnt_tree_create_row(GNT_TREE(tree), "1"), NULL, NULL); - gnt_tree_add_row_after(GNT_TREE(tree), "2", gnt_tree_create_row(GNT_TREE(tree), "2"), NULL, NULL); - gnt_tree_add_row_after(GNT_TREE(tree), "3", gnt_tree_create_row(GNT_TREE(tree), "3"), NULL, NULL); - gnt_tree_add_row_after(GNT_TREE(tree), "4", gnt_tree_create_row(GNT_TREE(tree), "4"), "a", NULL); - gnt_tree_add_row_after(GNT_TREE(tree), "5", gnt_tree_create_row(GNT_TREE(tree), "5"), "d", NULL); + gnt_tree_add_choice(GNT_TREE(tree), "1", gnt_tree_create_row(GNT_TREE(tree), "1", " long text", "a2"), NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "2", gnt_tree_create_row(GNT_TREE(tree), "2", " long text", "a2"), NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "3", gnt_tree_create_row(GNT_TREE(tree), "3", " long text", "a2"), NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "4", gnt_tree_create_row(GNT_TREE(tree), "4", " long text", "a2"), "a", NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "5", gnt_tree_create_row(GNT_TREE(tree), "5", " long text", "a2"), "d", NULL); - gnt_tree_add_row_after(GNT_TREE(tree), "6", gnt_tree_create_row(GNT_TREE(tree), "6"), "4", NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "6", gnt_tree_create_row(GNT_TREE(tree), "6", " long text", "a2"), "4", NULL); gnt_tree_set_row_flags(GNT_TREE(tree), "e", GNT_TEXT_FLAG_DIM); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2006-07-20 13:04:42
|
Revision: 16528 Author: evands Date: 2006-07-20 06:04:35 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16528&view=rev Log Message: ----------- Fixed sametime prpl when using static compilation. Modified Paths: -------------- trunk/src/protocols/sametime/sametime.c Modified: trunk/src/protocols/sametime/sametime.c =================================================================== --- trunk/src/protocols/sametime/sametime.c 2006-07-20 12:53:46 UTC (rev 16527) +++ trunk/src/protocols/sametime/sametime.c 2006-07-20 13:04:35 UTC (rev 16528) @@ -75,7 +75,7 @@ I don't know why I even bother providing these. Oh valiant reader, I do it all for you. */ /* scratch that, I just added it to the prpl options panel */ -#define PLUGIN_ID "prpl-meanwhile" +#define PLUGIN_ID "prpl-sametime" #define PLUGIN_NAME "Sametime" #define PLUGIN_SUMMARY "Sametime Protocol Plugin" #define PLUGIN_DESC "Open implementation of a Lotus Sametime client" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-07-20 12:53:57
|
Revision: 16527 Author: aaronsheldon Date: 2006-07-20 05:53:46 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16527&view=rev Log Message: ----------- Sadrul sent me this patch to look over and then commit. It fixes a PRPL leak in Yahoo's chat and fixes a few other memory leaks that were mostly my fault. Modified Paths: -------------- trunk/src/conversation.c trunk/src/gtkconv.c trunk/src/protocols/yahoo/yahoochat.c Modified: trunk/src/conversation.c =================================================================== --- trunk/src/conversation.c 2006-07-20 08:12:17 UTC (rev 16526) +++ trunk/src/conversation.c 2006-07-20 12:53:46 UTC (rev 16527) @@ -1485,7 +1485,7 @@ { GaimConversation *conv; GaimConversationUiOps *ops; - GaimConvChatBuddy *cb; + GaimConvChatBuddy *cbuddy; GaimConnection *gc; GaimPluginProtocolInfo *prpl_info; GList *ul, *fl; @@ -1508,12 +1508,9 @@ const char *user = (const char *)ul->data; const char *alias = user; gboolean quiet; - GaimConvChatBuddy *cbuddy; - GaimConvChatBuddyFlags flags = GPOINTER_TO_INT(fl->data); + GaimConvChatBuddyFlags flag = GPOINTER_TO_INT(fl->data); const char *extra_msg = (extra_msgs ? extra_msgs->data : NULL); - cbuddy = gaim_conv_chat_cb_new(user, NULL, GPOINTER_TO_INT(fl->data)); - if (!strcmp(chat->nick, gaim_normalize(conv->account, user))) { const char *alias2 = gaim_account_get_alias(conv->account); if (alias2 != NULL) @@ -1531,17 +1528,14 @@ } quiet = GPOINTER_TO_INT(gaim_signal_emit_return_1(gaim_conversations_get_handle(), - "chat-buddy-joining", conv, user, flags)) | + "chat-buddy-joining", conv, user, flag)) | gaim_conv_chat_is_user_ignored(chat, user); - cb = gaim_conv_chat_cb_new(user, NULL, flags); + cbuddy = gaim_conv_chat_cb_new(user, alias, flag); /* This seems dumb. Why should we set users thousands of times? */ gaim_conv_chat_set_users(chat, - g_list_prepend(gaim_conv_chat_get_users(chat), cb)); + g_list_prepend(gaim_conv_chat_get_users(chat), cbuddy)); - cbuddy->alias = strdup(alias); /* Should I be doing a strdup? */ - cbuddy->alias_key = g_utf8_collate_key(alias, strlen(alias)); - cbuddy->buddy = (gaim_find_buddy(conv->account, cbuddy->name) != NULL); cbuddies = g_list_prepend(cbuddies, cbuddy); if (!quiet && new_arrivals) { @@ -1563,7 +1557,7 @@ } gaim_signal_emit(gaim_conversations_get_handle(), - "chat-buddy-joined", conv, user, flags, new_arrivals); + "chat-buddy-joined", conv, user, flag, new_arrivals); ul = ul->next; fl = fl->next; if (extra_msgs != NULL) @@ -1575,6 +1569,7 @@ if (ops != NULL && ops->chat_add_users != NULL) ops->chat_add_users(conv, cbuddies, new_arrivals); + g_list_free(cbuddies); } void Modified: trunk/src/gtkconv.c =================================================================== --- trunk/src/gtkconv.c 2006-07-20 08:12:17 UTC (rev 16526) +++ trunk/src/gtkconv.c 2006-07-20 12:53:46 UTC (rev 16527) @@ -3398,6 +3398,7 @@ if (pixbuf) g_object_unref(pixbuf); + g_free(alias_key); } static void @@ -3707,7 +3708,7 @@ if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { const char *alias = name; - char *alias_key = g_utf8_collate_key(alias, strlen(alias)); + char *alias_key = NULL; GaimBuddy *buddy2; if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { @@ -3715,13 +3716,15 @@ if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) { alias = gaim_buddy_get_contact_alias(buddy2); - alias_key = g_utf8_collate_key(alias, strlen(alias)); } + alias_key = g_utf8_collate_key(alias, strlen(alias)); + gtk_list_store_set(GTK_LIST_STORE(model), &iter, CHAT_USERS_ALIAS_COLUMN, alias, CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, -1); + g_free(alias_key); } g_free(name); break; Modified: trunk/src/protocols/yahoo/yahoochat.c =================================================================== --- trunk/src/protocols/yahoo/yahoochat.c 2006-07-20 08:12:17 UTC (rev 16526) +++ trunk/src/protocols/yahoo/yahoochat.c 2006-07-20 12:53:46 UTC (rev 16527) @@ -460,6 +460,7 @@ yd->chat_name = g_strdup(room); gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE); } + g_list_free(flags); } else if (c) { yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-07-20 08:12:23
|
Revision: 16526 Author: thekingant Date: 2006-07-20 01:12:17 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16526&view=rev Log Message: ----------- Backport SVN revision #16525 from HEAD to v2_0_0 Original commit message: A bunch of little things * Use GAIM_CONNECTION_IS_VALID(gc) in a lot of places where we were doing g_list_find(gaim_connections_get_all(), gc) * Get rid of a lot of places where we were doing g_list_find(gaim_connections_get_all(), gc). The handle used by the request API ensures that the ok and cancel callback functions won't be called if the gc is destroyed. However, GAIM_CONNECTION_IS_VALID(gc) is still very important for callback functions where we can't cancel the request. For example, gaim_proxy_connect() callback functions. * "Added" a function to Yahoo! that should help us notice when our buddies change their buddy icon/display picture * Some comments in a few places * Changed GAIM_CONNECTION_IS_VALID(gc) to only look through the list of "all" connections and not the list of "connecting" connections. Some time ago we changed how this was done so that the list of "all" connections now includes the "connection" connections. ViewCVS Links: ------------- http://svn.sourceforge.net/gaim/?rev=16525&view=rev Modified Paths: -------------- branches/v2_0_0/src/buddyicon.h branches/v2_0_0/src/connection.h branches/v2_0_0/src/gtkblist.c branches/v2_0_0/src/protocols/jabber/jabber.c branches/v2_0_0/src/protocols/jabber/presence.c branches/v2_0_0/src/protocols/jabber/roster.c branches/v2_0_0/src/protocols/msn/dialog.c branches/v2_0_0/src/protocols/msn/userlist.c branches/v2_0_0/src/protocols/oscar/family_icbm.c branches/v2_0_0/src/protocols/oscar/oscar.c branches/v2_0_0/src/protocols/oscar/peer.c branches/v2_0_0/src/protocols/oscar/peer_proxy.c branches/v2_0_0/src/protocols/silc/silc.c branches/v2_0_0/src/protocols/yahoo/yahoo.c branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c branches/v2_0_0/src/protocols/yahoo/yahoo_picture.h branches/v2_0_0/src/proxy.c branches/v2_0_0/src/util.h Modified: branches/v2_0_0/src/buddyicon.h =================================================================== --- branches/v2_0_0/src/buddyicon.h 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/buddyicon.h 2006-07-20 08:12:17 UTC (rev 16526) @@ -42,6 +42,10 @@ int ref_count; /**< The buddy icon reference count. */ }; +#ifdef __cplusplus +extern "C" { +#endif + /**************************************************************************/ /** @name Buddy Icon API */ /**************************************************************************/ @@ -281,4 +285,8 @@ /*@}*/ +#ifdef __cplusplus +} +#endif + #endif /* _GAIM_BUDDYICON_H_ */ Modified: branches/v2_0_0/src/connection.h =================================================================== --- branches/v2_0_0/src/connection.h 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/connection.h 2006-07-20 08:12:17 UTC (rev 16526) @@ -271,7 +271,7 @@ * * @return @c TRUE if gc is valid. */ -#define GAIM_CONNECTION_IS_VALID(gc) (g_list_find(gaim_connections_get_all(), (gc)) || g_list_find(gaim_connections_get_connecting(), (gc))) +#define GAIM_CONNECTION_IS_VALID(gc) (g_list_find(gaim_connections_get_all(), (gc))) /*@}*/ Modified: branches/v2_0_0/src/gtkblist.c =================================================================== --- branches/v2_0_0/src/gtkblist.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/gtkblist.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -3419,6 +3419,13 @@ PangoLogAttr *log_attrs; gchar *word; + if (strcasecmp(key, "Global Thermonuclear War") == 0) + { + gaim_notify_info(NULL, "WOPR", + "Wouldn't you prefer a nice game of chess?", NULL); + return FALSE; + } + gtk_tree_model_get(model, iter, column, &withmarkup, -1); tmp = g_utf8_normalize(key, -1, G_NORMALIZE_DEFAULT); Modified: branches/v2_0_0/src/protocols/jabber/jabber.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/jabber.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/jabber/jabber.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -344,7 +344,8 @@ int len; static char buf[4096]; - if(!g_list_find(gaim_connections_get_all(), gc)) { + /* TODO: It should be possible to make this check unnecessary */ + if(!GAIM_CONNECTION_IS_VALID(gc)) { gaim_ssl_close(gsc); return; } Modified: branches/v2_0_0/src/protocols/jabber/presence.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/presence.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/jabber/presence.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -182,32 +182,30 @@ static void authorize_add_cb(struct _jabber_add_permit *jap) { - if(g_list_find(gaim_connections_get_all(), jap->gc)) { - GaimBuddy *buddy = NULL; + GaimBuddy *buddy = NULL; - jabber_presence_subscription_set(jap->gc->proto_data, jap->who, - "subscribed"); + jabber_presence_subscription_set(jap->gc->proto_data, jap->who, + "subscribed"); - buddy = gaim_find_buddy(jap->gc->account, jap->who); + buddy = gaim_find_buddy(jap->gc->account, jap->who); - if (buddy) { - JabberBuddy *jb = NULL; + if (buddy) { + JabberBuddy *jb = NULL; - jb = jabber_buddy_find(jap->js, jap->who, TRUE); + jb = jabber_buddy_find(jap->js, jap->who, TRUE); - if ((jb->subscription & JABBER_SUB_TO) == 0) { - gaim_account_request_add(jap->gc->account, + if ((jb->subscription & JABBER_SUB_TO) == 0) { + gaim_account_request_add(jap->gc->account, jap->who, NULL, - NULL, NULL); - } else { - gaim_account_notify_added(jap->gc->account, - jap->who, NULL, - NULL, NULL); - } + NULL, NULL); } else { - gaim_account_request_add(jap->gc->account, jap->who, - NULL, NULL, NULL); + gaim_account_notify_added(jap->gc->account, + jap->who, NULL, + NULL, NULL); } + } else { + gaim_account_request_add(jap->gc->account, jap->who, + NULL, NULL, NULL); } g_free(jap->who); @@ -216,10 +214,8 @@ static void deny_add_cb(struct _jabber_add_permit *jap) { - if(g_list_find(gaim_connections_get_all(), jap->gc)) { - jabber_presence_subscription_set(jap->gc->proto_data, jap->who, - "unsubscribed"); - } + jabber_presence_subscription_set(jap->gc->proto_data, jap->who, + "unsubscribed"); g_free(jap->who); g_free(jap); Modified: branches/v2_0_0/src/protocols/jabber/roster.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/roster.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/jabber/roster.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -104,7 +104,6 @@ gaim_blist_add_buddy(b, NULL, g, NULL); gaim_blist_alias_buddy(b, alias); - /* If we just learned about ourself, then fake our status, * because we won't be receiving a normal presence message * about ourself. */ @@ -117,8 +116,6 @@ jabber_presence_fake_to_self(js, status); } - - g_free(g2->data); g2 = g_slist_delete_link(g2, g2); } Modified: branches/v2_0_0/src/protocols/msn/dialog.c =================================================================== --- branches/v2_0_0/src/protocols/msn/dialog.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/msn/dialog.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -37,16 +37,12 @@ static void msn_add_cb(MsnAddRemData *data) { - if (g_list_find(gaim_connections_get_all(), data->gc) != NULL) - { - MsnSession *session = data->gc->proto_data; - MsnUserList *userlist = session->userlist; + MsnSession *session = data->gc->proto_data; + MsnUserList *userlist = session->userlist; - msn_userlist_add_buddy(userlist, data->who, MSN_LIST_FL, data->group); - } + msn_userlist_add_buddy(userlist, data->who, MSN_LIST_FL, data->group); - if (data->group != NULL) - g_free(data->group); + g_free(data->group); g_free(data->who); g_free(data); @@ -55,16 +51,12 @@ static void msn_rem_cb(MsnAddRemData *data) { - if (g_list_find(gaim_connections_get_all(), data->gc) != NULL) - { - MsnSession *session = data->gc->proto_data; - MsnUserList *userlist = session->userlist; + MsnSession *session = data->gc->proto_data; + MsnUserList *userlist = session->userlist; - msn_userlist_rem_buddy(userlist, data->who, MSN_LIST_FL, data->group); - } + msn_userlist_rem_buddy(userlist, data->who, MSN_LIST_FL, data->group); - if (data->group != NULL) - g_free(data->group); + g_free(data->group); g_free(data->who); g_free(data); Modified: branches/v2_0_0/src/protocols/msn/userlist.c =================================================================== --- branches/v2_0_0/src/protocols/msn/userlist.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/msn/userlist.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -40,23 +40,20 @@ static void msn_accept_add_cb(MsnPermitAdd *pa) { - if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL) - { - MsnSession *session = pa->gc->proto_data; - MsnUserList *userlist = session->userlist; - GaimBuddy *buddy; + MsnSession *session = pa->gc->proto_data; + MsnUserList *userlist = session->userlist; + GaimBuddy *buddy; - msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_AL, NULL); + msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_AL, NULL); - buddy = gaim_find_buddy(pa->gc->account, pa->who); + buddy = gaim_find_buddy(pa->gc->account, pa->who); - if (buddy != NULL) - gaim_account_notify_added(pa->gc->account, pa->who, - NULL, pa->friendly, NULL); - else - gaim_account_request_add(pa->gc->account, pa->who, - NULL, pa->friendly, NULL); - } + if (buddy != NULL) + gaim_account_notify_added(pa->gc->account, pa->who, + NULL, pa->friendly, NULL); + else + gaim_account_request_add(pa->gc->account, pa->who, + NULL, pa->friendly, NULL); g_free(pa->who); g_free(pa->friendly); @@ -66,13 +63,10 @@ static void msn_cancel_add_cb(MsnPermitAdd *pa) { - if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL) - { - MsnSession *session = pa->gc->proto_data; - MsnUserList *userlist = session->userlist; + MsnSession *session = pa->gc->proto_data; + MsnUserList *userlist = session->userlist; - msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_BL, NULL); - } + msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_BL, NULL); g_free(pa->who); g_free(pa->friendly); Modified: branches/v2_0_0/src/protocols/oscar/family_icbm.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/family_icbm.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/oscar/family_icbm.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -1718,9 +1718,9 @@ return ret; } -static void incomingim_ch2_buddylist(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) +static void +incomingim_ch2_buddylist(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) { - /* * This goes like this... * @@ -1740,7 +1740,8 @@ * ... * ... */ - while (servdata && byte_stream_empty(servdata)) { + while (byte_stream_empty(servdata)) + { guint16 gnlen, numb; int i; char *gn; @@ -1767,51 +1768,49 @@ return; } -static void incomingim_ch2_buddyicon_free(OscarData *od, IcbmArgsCh2 *args) +static void +incomingim_ch2_buddyicon_free(OscarData *od, IcbmArgsCh2 *args) { - free(args->info.icon.icon); return; } -static void incomingim_ch2_buddyicon(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) +static void +incomingim_ch2_buddyicon(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) { + args->info.icon.checksum = byte_stream_get32(servdata); + args->info.icon.length = byte_stream_get32(servdata); + args->info.icon.timestamp = byte_stream_get32(servdata); + args->info.icon.icon = byte_stream_getraw(servdata, args->info.icon.length); - if (servdata) { - args->info.icon.checksum = byte_stream_get32(servdata); - args->info.icon.length = byte_stream_get32(servdata); - args->info.icon.timestamp = byte_stream_get32(servdata); - args->info.icon.icon = byte_stream_getraw(servdata, args->info.icon.length); - } - args->destructor = (void *)incomingim_ch2_buddyicon_free; return; } -static void incomingim_ch2_chat_free(OscarData *od, IcbmArgsCh2 *args) +static void +incomingim_ch2_chat_free(OscarData *od, IcbmArgsCh2 *args) { - /* XXX - aim_chat_roominfo_free() */ free(args->info.chat.roominfo.name); return; } -static void incomingim_ch2_chat(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) +static void +incomingim_ch2_chat(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) { - /* * Chat room info. */ - if (servdata) - aim_chat_readroominfo(servdata, &args->info.chat.roominfo); + aim_chat_readroominfo(servdata, &args->info.chat.roominfo); args->destructor = (void *)incomingim_ch2_chat_free; } -static void incomingim_ch2_icqserverrelay_free(OscarData *od, IcbmArgsCh2 *args) +static void +incomingim_ch2_icqserverrelay_free(OscarData *od, IcbmArgsCh2 *args) { free((char *)args->info.rtfmsg.rtfmsg); } @@ -1824,12 +1823,13 @@ * Note that this is all little-endian. Cringe. * */ -static void incomingim_ch2_icqserverrelay(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) +static void +incomingim_ch2_icqserverrelay(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) { guint16 hdrlen, anslen, msglen; - if (servdata == NULL) - /* Odd... Oh well. */ + if (byte_stream_empty(servdata) < 24) + /* Someone sent us a short server relay ICBM. Weird. (Maybe?) */ return; hdrlen = byte_stream_getle16(servdata); @@ -1855,48 +1855,47 @@ args->destructor = (void *)incomingim_ch2_icqserverrelay_free; } -static void incomingim_ch2_sendfile_free(OscarData *od, IcbmArgsCh2 *args) +static void +incomingim_ch2_sendfile_free(OscarData *od, IcbmArgsCh2 *args) { free(args->info.sendfile.filename); } -static void incomingim_ch2_sendfile(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) +/* Someone is sending us a file */ +static void +incomingim_ch2_sendfile(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) { + int flen; args->destructor = (void *)incomingim_ch2_sendfile_free; /* Maybe there is a better way to tell what kind of sendfile * this is? Maybe TLV t(000a)? */ - if (servdata) { /* Someone is sending us a file */ - int flen; - /* subtype is one of AIM_OFT_SUBTYPE_* */ - args->info.sendfile.subtype = byte_stream_get16(servdata); - args->info.sendfile.totfiles = byte_stream_get16(servdata); - args->info.sendfile.totsize = byte_stream_get32(servdata); + /* subtype is one of AIM_OFT_SUBTYPE_* */ + args->info.sendfile.subtype = byte_stream_get16(servdata); + args->info.sendfile.totfiles = byte_stream_get16(servdata); + args->info.sendfile.totsize = byte_stream_get32(servdata); - /* - * I hope to God I'm right when I guess that there is a - * 32 char max filename length for single files. I think - * OFT tends to do that. Gotta love inconsistency. I saw - * a 26 byte filename? - */ - /* AAA - create an byte_stream_getnullstr function (don't anymore)(maybe) */ - /* Use an inelegant way of getting the null-terminated filename, - * since there's no easy bstream routine. */ - for (flen = 0; byte_stream_get8(servdata); flen++); - byte_stream_advance(servdata, -flen -1); - args->info.sendfile.filename = byte_stream_getstr(servdata, flen); + /* + * I hope to God I'm right when I guess that there is a + * 32 char max filename length for single files. I think + * OFT tends to do that. Gotta love inconsistency. I saw + * a 26 byte filename? + */ + /* AAA - create an byte_stream_getnullstr function (don't anymore)(maybe) */ + /* Use an inelegant way of getting the null-terminated filename, + * since there's no easy bstream routine. */ + for (flen = 0; byte_stream_get8(servdata); flen++); + byte_stream_advance(servdata, -flen -1); + args->info.sendfile.filename = byte_stream_getstr(servdata, flen); - /* There is sometimes more after the null-terminated filename, - * but I'm unsure of its format. */ - /* I don't believe him. */ - /* There is sometimes a null byte inside a unicode filename, - * but as far as I can tell the filename is the last - * piece of data that will be in this message. --Jonathan */ - } - - return; + /* There is sometimes more after the null-terminated filename, + * but I'm unsure of its format. */ + /* I don't believe him. */ + /* There is sometimes a null byte inside a unicode filename, + * but as far as I can tell the filename is the last + * piece of data that will be in this message. --Jonathan */ } typedef void (*ch2_args_destructor_t)(OscarData *od, IcbmArgsCh2 *args); @@ -2071,24 +2070,24 @@ byte_stream_init(&sdbs, servdatatlv->value, servdatatlv->length); sdbsptr = &sdbs; + + /* + * The rest of the handling depends on what type it is. + * + * Not all of them have special handling (yet). + */ + if (args.type & OSCAR_CAPABILITY_BUDDYICON) + incomingim_ch2_buddyicon(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); + else if (args.type & OSCAR_CAPABILITY_SENDBUDDYLIST) + incomingim_ch2_buddylist(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); + else if (args.type & OSCAR_CAPABILITY_CHAT) + incomingim_ch2_chat(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); + else if (args.type & OSCAR_CAPABILITY_ICQSERVERRELAY) + incomingim_ch2_icqserverrelay(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); + else if (args.type & OSCAR_CAPABILITY_SENDFILE) + incomingim_ch2_sendfile(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); } - /* - * The rest of the handling depends on what type it is. - * - * Not all of them have special handling (yet). - */ - if (args.type & OSCAR_CAPABILITY_BUDDYICON) - incomingim_ch2_buddyicon(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); - else if (args.type & OSCAR_CAPABILITY_SENDBUDDYLIST) - incomingim_ch2_buddylist(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); - else if (args.type & OSCAR_CAPABILITY_CHAT) - incomingim_ch2_chat(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); - else if (args.type & OSCAR_CAPABILITY_ICQSERVERRELAY) - incomingim_ch2_icqserverrelay(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); - else if (args.type & OSCAR_CAPABILITY_SENDFILE) - incomingim_ch2_sendfile(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); - if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) ret = userfunc(od, conn, frame, channel, userinfo, &args); Modified: branches/v2_0_0/src/protocols/oscar/oscar.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/oscar.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/oscar/oscar.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -954,7 +954,7 @@ new_conn_data = data; gc = new_conn_data->gc; - if (!g_list_find(gaim_connections_get_all(), gc)) + if (!GAIM_CONNECTION_IS_VALID(gc)) { if (source >= 0) close(source); @@ -2181,12 +2181,10 @@ gaim_auth_dontrequest(struct name_data *data) { GaimConnection *gc = data->gc; + GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); - if (g_list_find(gaim_connections_get_all(), gc)) { - /* Remove from local list */ - GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); - gaim_blist_remove_buddy(b); - } + /* Remove from local list */ + gaim_blist_remove_buddy(b); oscar_free_name_data(data); } @@ -2239,11 +2237,9 @@ gaim_auth_grant(struct name_data *data) { GaimConnection *gc = data->gc; + OscarData *od = gc->proto_data; - if (g_list_find(gaim_connections_get_all(), gc)) { - OscarData *od = gc->proto_data; - aim_ssi_sendauthreply(od, data->name, 0x01, NULL); - } + aim_ssi_sendauthreply(od, data->name, 0x01, NULL); oscar_free_name_data(data); } @@ -2253,11 +2249,9 @@ gaim_auth_dontgrant(struct name_data *data, char *msg) { GaimConnection *gc = data->gc; + OscarData *od = gc->proto_data; - if (g_list_find(gaim_connections_get_all(), gc)) { - OscarData *od = gc->proto_data; - aim_ssi_sendauthreply(od, data->name, 0x00, msg ? msg : _("No reason given.")); - } + aim_ssi_sendauthreply(od, data->name, 0x00, msg ? msg : _("No reason given.")); } static void @@ -2276,9 +2270,7 @@ { GaimConnection *gc = data->gc; - if (g_list_find(gaim_connections_get_all(), gc)) { - gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); - } + gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); oscar_free_name_data(data); } @@ -2779,7 +2771,11 @@ } break; default: { - gaim_debug_error("oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2); + /* + * It looks like iChat sometimes sends typing notification + * with type1=0x0001 and type2=0x000f. Not sure why. + */ + gaim_debug_info("oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2); } break; } Modified: branches/v2_0_0/src/protocols/oscar/peer.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/oscar/peer.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -481,7 +481,7 @@ conn = new_conn_data->conn; g_free(new_conn_data); - if (!g_list_find(gaim_connections_get_all(), gc)) + if (!GAIM_CONNECTION_IS_VALID(gc)) { if (source >= 0) close(source); @@ -573,7 +573,7 @@ conn = new_conn_data->conn; g_free(new_conn_data); - if (!g_list_find(gaim_connections_get_all(), gc)) + if (!GAIM_CONNECTION_IS_VALID(gc)) { if (listenerfd != -1) close(listenerfd); Modified: branches/v2_0_0/src/protocols/oscar/peer_proxy.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer_proxy.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/oscar/peer_proxy.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -337,7 +337,7 @@ conn = new_conn_data->conn; g_free(new_conn_data); - if (!g_list_find(gaim_connections_get_all(), gc)) + if (!GAIM_CONNECTION_IS_VALID(gc)) { if (source >= 0) close(source); Modified: branches/v2_0_0/src/protocols/silc/silc.c =================================================================== --- branches/v2_0_0/src/protocols/silc/silc.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/silc/silc.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -152,28 +152,24 @@ const char *dfile; g_return_if_fail(gc != NULL); - sg = gc->proto_data; + if (!GAIM_CONNECTION_IS_VALID(gc)) { + close(source); + return; + } + if (source < 0) { gaim_connection_error(gc, _("Connection failed")); return; } + sg = gc->proto_data; if (sg == NULL) return; client = sg->client; account = sg->account; - if (!g_list_find(gaim_connections_get_all(), gc)) { - close(source); - g_source_remove(sg->scheduler); - silc_client_stop(sg->client); - silc_client_free(sg->client); - silc_free(sg); - return; - } - /* Get session detachment data, if available */ memset(¶ms, 0, sizeof(params)); dfile = silcgaim_session_file(gaim_account_get_username(sg->account)); Modified: branches/v2_0_0/src/protocols/yahoo/yahoo.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -810,6 +810,7 @@ if (!msg || !g_utf8_validate(msg, -1, NULL)) return; + /* TODO: Does this really need to be escaped? It seems like it doesn't. */ escmsg = g_markup_escape_text(msg, -1); prim = g_strdup_printf(_("Yahoo! system message for %s:"), @@ -2132,6 +2133,9 @@ case YAHOO_SERVICE_PICTURE_UPLOAD: yahoo_process_picture_upload(gc, pkt); break; + case YAHOO_SERVICE_AVATAR_UPDATE: + yahoo_process_avatar_update(gc, pkt); + break; case YAHOO_SERVICE_AUDIBLE: yahoo_process_audible(gc, pkt); break; @@ -2234,7 +2238,7 @@ struct yahoo_data *yd; struct yahoo_packet *pkt; - if (!g_list_find(gaim_connections_get_all(), gc)) { + if (!GAIM_CONNECTION_IS_VALID(gc)) { close(source); return; } @@ -2261,7 +2265,7 @@ struct yahoo_data *yd; struct yahoo_packet *pkt; - if (!g_list_find(gaim_connections_get_all(), gc)) { + if (!GAIM_CONNECTION_IS_VALID(gc)) { close(source); return; } Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -225,6 +225,50 @@ } } +void yahoo_process_avatar_update(GaimConnection *gc, struct yahoo_packet *pkt) +{ + GSList *l = pkt->hash; + char *who = NULL; + int avatar = 0; + + while (l) { + struct yahoo_pair *pair = l->data; + + switch (pair->key) { + case 4: + who = pair->value; + break; + case 5: + /* us */ + break; + case 206: + /* + * 0 - No icon or avatar + * 1 - Using an avatar + * 2 - Using an icon + */ + avatar = strtol(pair->value, NULL, 10); + break; + } + l = l->next; + } + + if (who) { + if (avatar == 2) + yahoo_send_picture_request(gc, who); + else if ((avatar == 0) || (avatar == 1)) { + GaimBuddy *b = gaim_find_buddy(gc->account, who); + YahooFriend *f; + gaim_buddy_icons_set_for_user(gc->account, who, NULL, 0); + if (b) + gaim_blist_node_remove_setting((GaimBlistNode *)b, YAHOO_ICON_CHECKSUM_KEY); + if ((f = yahoo_friend_find(gc, who))) + yahoo_friend_set_buddy_icon_need_request(f, TRUE); + gaim_debug_misc("yahoo", "Setting user %s's icon to NULL.\n", who); + } + } +} + void yahoo_send_picture_info(GaimConnection *gc, const char *who) { struct yahoo_data *yd = gc->proto_data; Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_picture.h =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_picture.h 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_picture.h 2006-07-20 08:12:17 UTC (rev 16526) @@ -35,6 +35,8 @@ void yahoo_process_picture_checksum(GaimConnection *gc, struct yahoo_packet *pkt); void yahoo_process_picture_upload(GaimConnection *gc, struct yahoo_packet *pkt); +void yahoo_process_avatar_update(GaimConnection *gc, struct yahoo_packet *pkt); + void yahoo_set_buddy_icon(GaimConnection *gc, const char *iconfile); void yahoo_buddy_icon_upload(GaimConnection *gc, struct yahoo_buddy_icon_upload_data *d); void yahoo_buddy_icon_upload_data_free(struct yahoo_buddy_icon_upload_data *d); Modified: branches/v2_0_0/src/proxy.c =================================================================== --- branches/v2_0_0/src/proxy.c 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/proxy.c 2006-07-20 08:12:17 UTC (rev 16526) @@ -86,9 +86,9 @@ { g_return_if_fail(info != NULL); - if (info->host != NULL) g_free(info->host); - if (info->username != NULL) g_free(info->username); - if (info->password != NULL) g_free(info->password); + g_free(info->host); + g_free(info->username); + g_free(info->password); g_free(info); } @@ -106,8 +106,7 @@ { g_return_if_fail(info != NULL); - if (info->host != NULL) - g_free(info->host); + g_free(info->host); info->host = (host == NULL ? NULL : g_strdup(host)); } @@ -125,8 +124,7 @@ { g_return_if_fail(info != NULL); - if (info->username != NULL) - g_free(info->username); + g_free(info->username); info->username = (username == NULL ? NULL : g_strdup(username)); } @@ -136,8 +134,7 @@ { g_return_if_fail(info != NULL); - if (info->password != NULL) - g_free(info->password); + g_free(info->password); info->password = (password == NULL ? NULL : g_strdup(password)); } @@ -303,7 +300,7 @@ trap_gdb_bug() { const char *message = - "Gaim's DNS child got a SIGTRAP signal. \n" + "Gaim's DNS child got a SIGTRAP signal.\n" "This can be caused by trying to run gaim inside gdb.\n" "There is a known gdb bug which prevents this. Supposedly gaim\n" "should have detected you were using gdb and used an ugly hack,\n" @@ -2318,6 +2315,12 @@ return gpi; } +/* + * TODO: It would be really good if this returned some sort of handle + * that we could use to cancel the connection. As it is now, + * each callback has to check to make sure gc is still valid. + * And that is ugly. + */ int gaim_proxy_connect(GaimAccount *account, const char *host, int port, GaimInputFunction func, gpointer data) Modified: branches/v2_0_0/src/util.h =================================================================== --- branches/v2_0_0/src/util.h 2006-07-20 08:11:54 UTC (rev 16525) +++ branches/v2_0_0/src/util.h 2006-07-20 08:12:17 UTC (rev 16526) @@ -343,11 +343,12 @@ * in a GData hash table. The names of the attributes are lower-cased * in the hash table, and the name of the tag is case insensitive. * - * @param needle the name of the tag - * @param haystack the null-delimited string to search in - * @param start a pointer to the start of the tag if found - * @param end a pointer to the end of the tag if found - * @param attributes the attributes, if the tag was found + * @param needle The name of the tag + * @param haystack The null-delimited string to search in + * @param start A pointer to the start of the tag if found + * @param end A pointer to the end of the tag if found + * @param attributes The attributes, if the tag was found. This should + * be freed with g_datalist_clear(). * @return TRUE if the tag was found */ gboolean gaim_markup_find_tag(const char *needle, const char *haystack, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-07-20 08:12:01
|
Revision: 16525 Author: thekingant Date: 2006-07-20 01:11:54 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16525&view=rev Log Message: ----------- A bunch of little things * Use GAIM_CONNECTION_IS_VALID(gc) in a lot of places where we were doing g_list_find(gaim_connections_get_all(), gc) * Get rid of a lot of places where we were doing g_list_find(gaim_connections_get_all(), gc). The handle used by the request API ensures that the ok and cancel callback functions won't be called if the gc is destroyed. However, GAIM_CONNECTION_IS_VALID(gc) is still very important for callback functions where we can't cancel the request. For example, gaim_proxy_connect() callback functions. * "Added" a function to Yahoo! that should help us notice when our buddies change their buddy icon/display picture * Some comments in a few places * Changed GAIM_CONNECTION_IS_VALID(gc) to only look through the list of "all" connections and not the list of "connecting" connections. Some time ago we changed how this was done so that the list of "all" connections now includes the "connection" connections. Modified Paths: -------------- trunk/src/buddyicon.h trunk/src/connection.h trunk/src/gtkblist.c trunk/src/protocols/jabber/jabber.c trunk/src/protocols/jabber/presence.c trunk/src/protocols/jabber/roster.c trunk/src/protocols/msn/dialog.c trunk/src/protocols/msn/userlist.c trunk/src/protocols/oscar/family_icbm.c trunk/src/protocols/oscar/oscar.c trunk/src/protocols/oscar/peer.c trunk/src/protocols/oscar/peer_proxy.c trunk/src/protocols/silc/silc.c trunk/src/protocols/yahoo/yahoo.c trunk/src/protocols/yahoo/yahoo_picture.c trunk/src/protocols/yahoo/yahoo_picture.h trunk/src/proxy.c trunk/src/util.h Modified: trunk/src/buddyicon.h =================================================================== --- trunk/src/buddyicon.h 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/buddyicon.h 2006-07-20 08:11:54 UTC (rev 16525) @@ -42,6 +42,10 @@ int ref_count; /**< The buddy icon reference count. */ }; +#ifdef __cplusplus +extern "C" { +#endif + /**************************************************************************/ /** @name Buddy Icon API */ /**************************************************************************/ @@ -281,4 +285,8 @@ /*@}*/ +#ifdef __cplusplus +} +#endif + #endif /* _GAIM_BUDDYICON_H_ */ Modified: trunk/src/connection.h =================================================================== --- trunk/src/connection.h 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/connection.h 2006-07-20 08:11:54 UTC (rev 16525) @@ -271,7 +271,7 @@ * * @return @c TRUE if gc is valid. */ -#define GAIM_CONNECTION_IS_VALID(gc) (g_list_find(gaim_connections_get_all(), (gc)) || g_list_find(gaim_connections_get_connecting(), (gc))) +#define GAIM_CONNECTION_IS_VALID(gc) (g_list_find(gaim_connections_get_all(), (gc))) /*@}*/ Modified: trunk/src/gtkblist.c =================================================================== --- trunk/src/gtkblist.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/gtkblist.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -3435,6 +3435,13 @@ PangoLogAttr *log_attrs; gchar *word; + if (strcasecmp(key, "Global Thermonuclear War") == 0) + { + gaim_notify_info(NULL, "WOPR", + "Wouldn't you prefer a nice game of chess?", NULL); + return FALSE; + } + gtk_tree_model_get(model, iter, column, &withmarkup, -1); tmp = g_utf8_normalize(key, -1, G_NORMALIZE_DEFAULT); Modified: trunk/src/protocols/jabber/jabber.c =================================================================== --- trunk/src/protocols/jabber/jabber.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/jabber/jabber.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -344,7 +344,8 @@ int len; static char buf[4096]; - if(!g_list_find(gaim_connections_get_all(), gc)) { + /* TODO: It should be possible to make this check unnecessary */ + if(!GAIM_CONNECTION_IS_VALID(gc)) { gaim_ssl_close(gsc); return; } Modified: trunk/src/protocols/jabber/presence.c =================================================================== --- trunk/src/protocols/jabber/presence.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/jabber/presence.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -182,32 +182,30 @@ static void authorize_add_cb(struct _jabber_add_permit *jap) { - if(g_list_find(gaim_connections_get_all(), jap->gc)) { - GaimBuddy *buddy = NULL; + GaimBuddy *buddy = NULL; - jabber_presence_subscription_set(jap->gc->proto_data, jap->who, - "subscribed"); + jabber_presence_subscription_set(jap->gc->proto_data, jap->who, + "subscribed"); - buddy = gaim_find_buddy(jap->gc->account, jap->who); + buddy = gaim_find_buddy(jap->gc->account, jap->who); - if (buddy) { - JabberBuddy *jb = NULL; + if (buddy) { + JabberBuddy *jb = NULL; - jb = jabber_buddy_find(jap->js, jap->who, TRUE); + jb = jabber_buddy_find(jap->js, jap->who, TRUE); - if ((jb->subscription & JABBER_SUB_TO) == 0) { - gaim_account_request_add(jap->gc->account, + if ((jb->subscription & JABBER_SUB_TO) == 0) { + gaim_account_request_add(jap->gc->account, jap->who, NULL, - NULL, NULL); - } else { - gaim_account_notify_added(jap->gc->account, - jap->who, NULL, - NULL, NULL); - } + NULL, NULL); } else { - gaim_account_request_add(jap->gc->account, jap->who, - NULL, NULL, NULL); + gaim_account_notify_added(jap->gc->account, + jap->who, NULL, + NULL, NULL); } + } else { + gaim_account_request_add(jap->gc->account, jap->who, + NULL, NULL, NULL); } g_free(jap->who); @@ -216,10 +214,8 @@ static void deny_add_cb(struct _jabber_add_permit *jap) { - if(g_list_find(gaim_connections_get_all(), jap->gc)) { - jabber_presence_subscription_set(jap->gc->proto_data, jap->who, - "unsubscribed"); - } + jabber_presence_subscription_set(jap->gc->proto_data, jap->who, + "unsubscribed"); g_free(jap->who); g_free(jap); Modified: trunk/src/protocols/jabber/roster.c =================================================================== --- trunk/src/protocols/jabber/roster.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/jabber/roster.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -104,7 +104,6 @@ gaim_blist_add_buddy(b, NULL, g, NULL); gaim_blist_alias_buddy(b, alias); - /* If we just learned about ourself, then fake our status, * because we won't be receiving a normal presence message * about ourself. */ @@ -117,8 +116,6 @@ jabber_presence_fake_to_self(js, status); } - - g_free(g2->data); g2 = g_slist_delete_link(g2, g2); } Modified: trunk/src/protocols/msn/dialog.c =================================================================== --- trunk/src/protocols/msn/dialog.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/msn/dialog.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -57,19 +57,17 @@ static void msn_add_cb(MsnAddRemData *data) { + MsnSession *session; + MsnUserList *userlist; + msn_complete_sync_issue(data); - if (g_list_find(gaim_connections_get_all(), data->gc) != NULL) - { - MsnSession *session = data->gc->proto_data; - MsnUserList *userlist = session->userlist; + session = data->gc->proto_data; + userlist = session->userlist; - msn_userlist_add_buddy(userlist, data->who, MSN_LIST_FL, data->group); - } + msn_userlist_add_buddy(userlist, data->who, MSN_LIST_FL, data->group); - if (data->group != NULL) - g_free(data->group); - + g_free(data->group); g_free(data->who); g_free(data); } @@ -77,19 +75,17 @@ static void msn_rem_cb(MsnAddRemData *data) { + MsnSession *session; + MsnUserList *userlist; + msn_complete_sync_issue(data); - if (g_list_find(gaim_connections_get_all(), data->gc) != NULL) - { - MsnSession *session = data->gc->proto_data; - MsnUserList *userlist = session->userlist; + session = data->gc->proto_data; + userlist = session->userlist; - msn_userlist_rem_buddy(userlist, data->who, MSN_LIST_FL, data->group); - } + msn_userlist_rem_buddy(userlist, data->who, MSN_LIST_FL, data->group); - if (data->group != NULL) - g_free(data->group); - + g_free(data->group); g_free(data->who); g_free(data); } Modified: trunk/src/protocols/msn/userlist.c =================================================================== --- trunk/src/protocols/msn/userlist.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/msn/userlist.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -40,23 +40,20 @@ static void msn_accept_add_cb(MsnPermitAdd *pa) { - if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL) - { - MsnSession *session = pa->gc->proto_data; - MsnUserList *userlist = session->userlist; - GaimBuddy *buddy; + MsnSession *session = pa->gc->proto_data; + MsnUserList *userlist = session->userlist; + GaimBuddy *buddy; - msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_AL, NULL); + msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_AL, NULL); - buddy = gaim_find_buddy(pa->gc->account, pa->who); + buddy = gaim_find_buddy(pa->gc->account, pa->who); - if (buddy != NULL) - gaim_account_notify_added(pa->gc->account, pa->who, - NULL, pa->friendly, NULL); - else - gaim_account_request_add(pa->gc->account, pa->who, - NULL, pa->friendly, NULL); - } + if (buddy != NULL) + gaim_account_notify_added(pa->gc->account, pa->who, + NULL, pa->friendly, NULL); + else + gaim_account_request_add(pa->gc->account, pa->who, + NULL, pa->friendly, NULL); g_free(pa->who); g_free(pa->friendly); @@ -66,13 +63,10 @@ static void msn_cancel_add_cb(MsnPermitAdd *pa) { - if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL) - { - MsnSession *session = pa->gc->proto_data; - MsnUserList *userlist = session->userlist; + MsnSession *session = pa->gc->proto_data; + MsnUserList *userlist = session->userlist; - msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_BL, NULL); - } + msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_BL, NULL); g_free(pa->who); g_free(pa->friendly); Modified: trunk/src/protocols/oscar/family_icbm.c =================================================================== --- trunk/src/protocols/oscar/family_icbm.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/oscar/family_icbm.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -1718,9 +1718,9 @@ return ret; } -static void incomingim_ch2_buddylist(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) +static void +incomingim_ch2_buddylist(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) { - /* * This goes like this... * @@ -1740,7 +1740,8 @@ * ... * ... */ - while (servdata && byte_stream_empty(servdata)) { + while (byte_stream_empty(servdata)) + { guint16 gnlen, numb; int i; char *gn; @@ -1767,51 +1768,49 @@ return; } -static void incomingim_ch2_buddyicon_free(OscarData *od, IcbmArgsCh2 *args) +static void +incomingim_ch2_buddyicon_free(OscarData *od, IcbmArgsCh2 *args) { - free(args->info.icon.icon); return; } -static void incomingim_ch2_buddyicon(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) +static void +incomingim_ch2_buddyicon(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) { + args->info.icon.checksum = byte_stream_get32(servdata); + args->info.icon.length = byte_stream_get32(servdata); + args->info.icon.timestamp = byte_stream_get32(servdata); + args->info.icon.icon = byte_stream_getraw(servdata, args->info.icon.length); - if (servdata) { - args->info.icon.checksum = byte_stream_get32(servdata); - args->info.icon.length = byte_stream_get32(servdata); - args->info.icon.timestamp = byte_stream_get32(servdata); - args->info.icon.icon = byte_stream_getraw(servdata, args->info.icon.length); - } - args->destructor = (void *)incomingim_ch2_buddyicon_free; return; } -static void incomingim_ch2_chat_free(OscarData *od, IcbmArgsCh2 *args) +static void +incomingim_ch2_chat_free(OscarData *od, IcbmArgsCh2 *args) { - /* XXX - aim_chat_roominfo_free() */ free(args->info.chat.roominfo.name); return; } -static void incomingim_ch2_chat(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) +static void +incomingim_ch2_chat(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) { - /* * Chat room info. */ - if (servdata) - aim_chat_readroominfo(servdata, &args->info.chat.roominfo); + aim_chat_readroominfo(servdata, &args->info.chat.roominfo); args->destructor = (void *)incomingim_ch2_chat_free; } -static void incomingim_ch2_icqserverrelay_free(OscarData *od, IcbmArgsCh2 *args) +static void +incomingim_ch2_icqserverrelay_free(OscarData *od, IcbmArgsCh2 *args) { free((char *)args->info.rtfmsg.rtfmsg); } @@ -1824,12 +1823,13 @@ * Note that this is all little-endian. Cringe. * */ -static void incomingim_ch2_icqserverrelay(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) +static void +incomingim_ch2_icqserverrelay(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) { guint16 hdrlen, anslen, msglen; - if (servdata == NULL) - /* Odd... Oh well. */ + if (byte_stream_empty(servdata) < 24) + /* Someone sent us a short server relay ICBM. Weird. (Maybe?) */ return; hdrlen = byte_stream_getle16(servdata); @@ -1855,48 +1855,47 @@ args->destructor = (void *)incomingim_ch2_icqserverrelay_free; } -static void incomingim_ch2_sendfile_free(OscarData *od, IcbmArgsCh2 *args) +static void +incomingim_ch2_sendfile_free(OscarData *od, IcbmArgsCh2 *args) { free(args->info.sendfile.filename); } -static void incomingim_ch2_sendfile(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) +/* Someone is sending us a file */ +static void +incomingim_ch2_sendfile(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata) { + int flen; args->destructor = (void *)incomingim_ch2_sendfile_free; /* Maybe there is a better way to tell what kind of sendfile * this is? Maybe TLV t(000a)? */ - if (servdata) { /* Someone is sending us a file */ - int flen; - /* subtype is one of AIM_OFT_SUBTYPE_* */ - args->info.sendfile.subtype = byte_stream_get16(servdata); - args->info.sendfile.totfiles = byte_stream_get16(servdata); - args->info.sendfile.totsize = byte_stream_get32(servdata); + /* subtype is one of AIM_OFT_SUBTYPE_* */ + args->info.sendfile.subtype = byte_stream_get16(servdata); + args->info.sendfile.totfiles = byte_stream_get16(servdata); + args->info.sendfile.totsize = byte_stream_get32(servdata); - /* - * I hope to God I'm right when I guess that there is a - * 32 char max filename length for single files. I think - * OFT tends to do that. Gotta love inconsistency. I saw - * a 26 byte filename? - */ - /* AAA - create an byte_stream_getnullstr function (don't anymore)(maybe) */ - /* Use an inelegant way of getting the null-terminated filename, - * since there's no easy bstream routine. */ - for (flen = 0; byte_stream_get8(servdata); flen++); - byte_stream_advance(servdata, -flen -1); - args->info.sendfile.filename = byte_stream_getstr(servdata, flen); + /* + * I hope to God I'm right when I guess that there is a + * 32 char max filename length for single files. I think + * OFT tends to do that. Gotta love inconsistency. I saw + * a 26 byte filename? + */ + /* AAA - create an byte_stream_getnullstr function (don't anymore)(maybe) */ + /* Use an inelegant way of getting the null-terminated filename, + * since there's no easy bstream routine. */ + for (flen = 0; byte_stream_get8(servdata); flen++); + byte_stream_advance(servdata, -flen -1); + args->info.sendfile.filename = byte_stream_getstr(servdata, flen); - /* There is sometimes more after the null-terminated filename, - * but I'm unsure of its format. */ - /* I don't believe him. */ - /* There is sometimes a null byte inside a unicode filename, - * but as far as I can tell the filename is the last - * piece of data that will be in this message. --Jonathan */ - } - - return; + /* There is sometimes more after the null-terminated filename, + * but I'm unsure of its format. */ + /* I don't believe him. */ + /* There is sometimes a null byte inside a unicode filename, + * but as far as I can tell the filename is the last + * piece of data that will be in this message. --Jonathan */ } typedef void (*ch2_args_destructor_t)(OscarData *od, IcbmArgsCh2 *args); @@ -2071,24 +2070,24 @@ byte_stream_init(&sdbs, servdatatlv->value, servdatatlv->length); sdbsptr = &sdbs; + + /* + * The rest of the handling depends on what type it is. + * + * Not all of them have special handling (yet). + */ + if (args.type & OSCAR_CAPABILITY_BUDDYICON) + incomingim_ch2_buddyicon(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); + else if (args.type & OSCAR_CAPABILITY_SENDBUDDYLIST) + incomingim_ch2_buddylist(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); + else if (args.type & OSCAR_CAPABILITY_CHAT) + incomingim_ch2_chat(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); + else if (args.type & OSCAR_CAPABILITY_ICQSERVERRELAY) + incomingim_ch2_icqserverrelay(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); + else if (args.type & OSCAR_CAPABILITY_SENDFILE) + incomingim_ch2_sendfile(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); } - /* - * The rest of the handling depends on what type it is. - * - * Not all of them have special handling (yet). - */ - if (args.type & OSCAR_CAPABILITY_BUDDYICON) - incomingim_ch2_buddyicon(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); - else if (args.type & OSCAR_CAPABILITY_SENDBUDDYLIST) - incomingim_ch2_buddylist(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); - else if (args.type & OSCAR_CAPABILITY_CHAT) - incomingim_ch2_chat(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); - else if (args.type & OSCAR_CAPABILITY_ICQSERVERRELAY) - incomingim_ch2_icqserverrelay(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); - else if (args.type & OSCAR_CAPABILITY_SENDFILE) - incomingim_ch2_sendfile(od, conn, mod, frame, snac, userinfo, &args, sdbsptr); - if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) ret = userfunc(od, conn, frame, channel, userinfo, &args); Modified: trunk/src/protocols/oscar/oscar.c =================================================================== --- trunk/src/protocols/oscar/oscar.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/oscar/oscar.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -954,7 +954,7 @@ new_conn_data = data; gc = new_conn_data->gc; - if (!g_list_find(gaim_connections_get_all(), gc)) + if (!GAIM_CONNECTION_IS_VALID(gc)) { if (source >= 0) close(source); @@ -2182,12 +2182,10 @@ gaim_auth_dontrequest(struct name_data *data) { GaimConnection *gc = data->gc; + GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); - if (g_list_find(gaim_connections_get_all(), gc)) { - /* Remove from local list */ - GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); - gaim_blist_remove_buddy(b); - } + /* Remove from local list */ + gaim_blist_remove_buddy(b); oscar_free_name_data(data); } @@ -2240,11 +2238,9 @@ gaim_auth_grant(struct name_data *data) { GaimConnection *gc = data->gc; + OscarData *od = gc->proto_data; - if (g_list_find(gaim_connections_get_all(), gc)) { - OscarData *od = gc->proto_data; - aim_ssi_sendauthreply(od, data->name, 0x01, NULL); - } + aim_ssi_sendauthreply(od, data->name, 0x01, NULL); oscar_free_name_data(data); } @@ -2254,11 +2250,9 @@ gaim_auth_dontgrant(struct name_data *data, char *msg) { GaimConnection *gc = data->gc; + OscarData *od = gc->proto_data; - if (g_list_find(gaim_connections_get_all(), gc)) { - OscarData *od = gc->proto_data; - aim_ssi_sendauthreply(od, data->name, 0x00, msg ? msg : _("No reason given.")); - } + aim_ssi_sendauthreply(od, data->name, 0x00, msg ? msg : _("No reason given.")); } static void @@ -2277,9 +2271,7 @@ { GaimConnection *gc = data->gc; - if (g_list_find(gaim_connections_get_all(), gc)) { - gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); - } + gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); oscar_free_name_data(data); } @@ -2780,7 +2772,11 @@ } break; default: { - gaim_debug_error("oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2); + /* + * It looks like iChat sometimes sends typing notification + * with type1=0x0001 and type2=0x000f. Not sure why. + */ + gaim_debug_info("oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2); } break; } Modified: trunk/src/protocols/oscar/peer.c =================================================================== --- trunk/src/protocols/oscar/peer.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/oscar/peer.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -481,7 +481,7 @@ conn = new_conn_data->conn; g_free(new_conn_data); - if (!g_list_find(gaim_connections_get_all(), gc)) + if (!GAIM_CONNECTION_IS_VALID(gc)) { if (source >= 0) close(source); @@ -573,7 +573,7 @@ conn = new_conn_data->conn; g_free(new_conn_data); - if (!g_list_find(gaim_connections_get_all(), gc)) + if (!GAIM_CONNECTION_IS_VALID(gc)) { if (listenerfd != -1) close(listenerfd); Modified: trunk/src/protocols/oscar/peer_proxy.c =================================================================== --- trunk/src/protocols/oscar/peer_proxy.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/oscar/peer_proxy.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -337,7 +337,7 @@ conn = new_conn_data->conn; g_free(new_conn_data); - if (!g_list_find(gaim_connections_get_all(), gc)) + if (!GAIM_CONNECTION_IS_VALID(gc)) { if (source >= 0) close(source); Modified: trunk/src/protocols/silc/silc.c =================================================================== --- trunk/src/protocols/silc/silc.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/silc/silc.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -152,28 +152,24 @@ const char *dfile; g_return_if_fail(gc != NULL); - sg = gc->proto_data; + if (!GAIM_CONNECTION_IS_VALID(gc)) { + close(source); + return; + } + if (source < 0) { gaim_connection_error(gc, _("Connection failed")); return; } + sg = gc->proto_data; if (sg == NULL) return; client = sg->client; account = sg->account; - if (!g_list_find(gaim_connections_get_all(), gc)) { - close(source); - g_source_remove(sg->scheduler); - silc_client_stop(sg->client); - silc_client_free(sg->client); - silc_free(sg); - return; - } - /* Get session detachment data, if available */ memset(¶ms, 0, sizeof(params)); dfile = silcgaim_session_file(gaim_account_get_username(sg->account)); Modified: trunk/src/protocols/yahoo/yahoo.c =================================================================== --- trunk/src/protocols/yahoo/yahoo.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/yahoo/yahoo.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -810,6 +810,7 @@ if (!msg || !g_utf8_validate(msg, -1, NULL)) return; + /* TODO: Does this really need to be escaped? It seems like it doesn't. */ escmsg = g_markup_escape_text(msg, -1); prim = g_strdup_printf(_("Yahoo! system message for %s:"), @@ -2132,6 +2133,9 @@ case YAHOO_SERVICE_PICTURE_UPLOAD: yahoo_process_picture_upload(gc, pkt); break; + case YAHOO_SERVICE_AVATAR_UPDATE: + yahoo_process_avatar_update(gc, pkt); + break; case YAHOO_SERVICE_AUDIBLE: yahoo_process_audible(gc, pkt); break; @@ -2234,7 +2238,7 @@ struct yahoo_data *yd; struct yahoo_packet *pkt; - if (!g_list_find(gaim_connections_get_all(), gc)) { + if (!GAIM_CONNECTION_IS_VALID(gc)) { close(source); return; } @@ -2261,7 +2265,7 @@ struct yahoo_data *yd; struct yahoo_packet *pkt; - if (!g_list_find(gaim_connections_get_all(), gc)) { + if (!GAIM_CONNECTION_IS_VALID(gc)) { close(source); return; } Modified: trunk/src/protocols/yahoo/yahoo_picture.c =================================================================== --- trunk/src/protocols/yahoo/yahoo_picture.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/yahoo/yahoo_picture.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -225,6 +225,50 @@ } } +void yahoo_process_avatar_update(GaimConnection *gc, struct yahoo_packet *pkt) +{ + GSList *l = pkt->hash; + char *who = NULL; + int avatar = 0; + + while (l) { + struct yahoo_pair *pair = l->data; + + switch (pair->key) { + case 4: + who = pair->value; + break; + case 5: + /* us */ + break; + case 206: + /* + * 0 - No icon or avatar + * 1 - Using an avatar + * 2 - Using an icon + */ + avatar = strtol(pair->value, NULL, 10); + break; + } + l = l->next; + } + + if (who) { + if (avatar == 2) + yahoo_send_picture_request(gc, who); + else if ((avatar == 0) || (avatar == 1)) { + GaimBuddy *b = gaim_find_buddy(gc->account, who); + YahooFriend *f; + gaim_buddy_icons_set_for_user(gc->account, who, NULL, 0); + if (b) + gaim_blist_node_remove_setting((GaimBlistNode *)b, YAHOO_ICON_CHECKSUM_KEY); + if ((f = yahoo_friend_find(gc, who))) + yahoo_friend_set_buddy_icon_need_request(f, TRUE); + gaim_debug_misc("yahoo", "Setting user %s's icon to NULL.\n", who); + } + } +} + void yahoo_send_picture_info(GaimConnection *gc, const char *who) { struct yahoo_data *yd = gc->proto_data; Modified: trunk/src/protocols/yahoo/yahoo_picture.h =================================================================== --- trunk/src/protocols/yahoo/yahoo_picture.h 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/protocols/yahoo/yahoo_picture.h 2006-07-20 08:11:54 UTC (rev 16525) @@ -35,6 +35,8 @@ void yahoo_process_picture_checksum(GaimConnection *gc, struct yahoo_packet *pkt); void yahoo_process_picture_upload(GaimConnection *gc, struct yahoo_packet *pkt); +void yahoo_process_avatar_update(GaimConnection *gc, struct yahoo_packet *pkt); + void yahoo_set_buddy_icon(GaimConnection *gc, const char *iconfile); void yahoo_buddy_icon_upload(GaimConnection *gc, struct yahoo_buddy_icon_upload_data *d); void yahoo_buddy_icon_upload_data_free(struct yahoo_buddy_icon_upload_data *d); Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/proxy.c 2006-07-20 08:11:54 UTC (rev 16525) @@ -86,9 +86,9 @@ { g_return_if_fail(info != NULL); - if (info->host != NULL) g_free(info->host); - if (info->username != NULL) g_free(info->username); - if (info->password != NULL) g_free(info->password); + g_free(info->host); + g_free(info->username); + g_free(info->password); g_free(info); } @@ -106,8 +106,7 @@ { g_return_if_fail(info != NULL); - if (info->host != NULL) - g_free(info->host); + g_free(info->host); info->host = (host == NULL ? NULL : g_strdup(host)); } @@ -125,8 +124,7 @@ { g_return_if_fail(info != NULL); - if (info->username != NULL) - g_free(info->username); + g_free(info->username); info->username = (username == NULL ? NULL : g_strdup(username)); } @@ -136,8 +134,7 @@ { g_return_if_fail(info != NULL); - if (info->password != NULL) - g_free(info->password); + g_free(info->password); info->password = (password == NULL ? NULL : g_strdup(password)); } @@ -303,7 +300,7 @@ trap_gdb_bug() { const char *message = - "Gaim's DNS child got a SIGTRAP signal. \n" + "Gaim's DNS child got a SIGTRAP signal.\n" "This can be caused by trying to run gaim inside gdb.\n" "There is a known gdb bug which prevents this. Supposedly gaim\n" "should have detected you were using gdb and used an ugly hack,\n" @@ -2319,6 +2316,12 @@ return gpi; } +/* + * TODO: It would be really good if this returned some sort of handle + * that we could use to cancel the connection. As it is now, + * each callback has to check to make sure gc is still valid. + * And that is ugly. + */ int gaim_proxy_connect(GaimAccount *account, const char *host, int port, GaimInputFunction func, gpointer data) Modified: trunk/src/util.h =================================================================== --- trunk/src/util.h 2006-07-20 07:31:37 UTC (rev 16524) +++ trunk/src/util.h 2006-07-20 08:11:54 UTC (rev 16525) @@ -343,11 +343,12 @@ * in a GData hash table. The names of the attributes are lower-cased * in the hash table, and the name of the tag is case insensitive. * - * @param needle the name of the tag - * @param haystack the null-delimited string to search in - * @param start a pointer to the start of the tag if found - * @param end a pointer to the end of the tag if found - * @param attributes the attributes, if the tag was found + * @param needle The name of the tag + * @param haystack The null-delimited string to search in + * @param start A pointer to the start of the tag if found + * @param end A pointer to the end of the tag if found + * @param attributes The attributes, if the tag was found. This should + * be freed with g_datalist_clear(). * @return TRUE if the tag was found */ gboolean gaim_markup_find_tag(const char *needle, const char *haystack, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-07-20 07:31:39
|
Revision: 16524 Author: thekingant Date: 2006-07-20 00:31:37 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16524&view=rev Log Message: ----------- Backport SVN revision #16523 from HEAD to v2_0_0 Original commit message: Fix a crazy MSN crash. Basically it's possible to have more than one slplink associated with a given switchboard, but our code did not allow for that. I think it happens when you're in a multi-user chat and you do stuff with multiple users that involves slplinks. Like maybe file transfer and buddy icon related stuff. Tracking this down took an ungodly amount of time, but thanks to Meebo for letting me do it :-) ViewCVS Links: ------------- http://svn.sourceforge.net/gaim/?rev=16523&view=rev Modified Paths: -------------- branches/v2_0_0/src/protocols/msn/slp.c branches/v2_0_0/src/protocols/msn/slplink.c branches/v2_0_0/src/protocols/msn/switchboard.c branches/v2_0_0/src/protocols/msn/switchboard.h Modified: branches/v2_0_0/src/protocols/msn/slp.c =================================================================== --- branches/v2_0_0/src/protocols/msn/slp.c 2006-07-20 07:31:15 UTC (rev 16523) +++ branches/v2_0_0/src/protocols/msn/slp.c 2006-07-20 07:31:37 UTC (rev 16524) @@ -748,7 +748,7 @@ * reporting bugs. Hopefully this doesn't cause more crashes. Stu. */ if (slplink->swboard != NULL) - slplink->swboard->slplink = slplink; + slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink); else gaim_debug_error("msn", "msn_p2p_msg, swboard is NULL, ouch!\n"); } Modified: branches/v2_0_0/src/protocols/msn/slplink.c =================================================================== --- branches/v2_0_0/src/protocols/msn/slplink.c 2006-07-20 07:31:15 UTC (rev 16523) +++ branches/v2_0_0/src/protocols/msn/slplink.c 2006-07-20 07:31:37 UTC (rev 16524) @@ -102,7 +102,7 @@ g_return_if_fail(slplink != NULL); if (slplink->swboard != NULL) - slplink->swboard->slplink = NULL; + slplink->swboard->slplinks = g_list_remove(slplink->swboard->slplinks, slplink); session = slplink->session; @@ -256,7 +256,7 @@ return; /* If swboard is destroyed we will be too */ - slplink->swboard->slplink = slplink; + slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink); } msn_switchboard_send_msg(slplink->swboard, msg, TRUE); Modified: branches/v2_0_0/src/protocols/msn/switchboard.c =================================================================== --- branches/v2_0_0/src/protocols/msn/switchboard.c 2006-07-20 07:31:15 UTC (rev 16523) +++ branches/v2_0_0/src/protocols/msn/switchboard.c 2006-07-20 07:31:37 UTC (rev 16524) @@ -82,8 +82,8 @@ swboard->destroying = TRUE; /* If it linked us is because its looking for trouble */ - if (swboard->slplink != NULL) - msn_slplink_destroy(swboard->slplink); + while (swboard->slplinks != NULL) + msn_slplink_destroy(swboard->slplinks->data); /* Destroy the message queue */ while ((msg = g_queue_pop_head(swboard->msg_queue)) != NULL) Modified: branches/v2_0_0/src/protocols/msn/switchboard.h =================================================================== --- branches/v2_0_0/src/protocols/msn/switchboard.h 2006-07-20 07:31:15 UTC (rev 16523) +++ branches/v2_0_0/src/protocols/msn/switchboard.h 2006-07-20 07:31:37 UTC (rev 16524) @@ -102,7 +102,7 @@ MsnSBErrorType error; /**< The error that occurred in this switchboard (if applicable). */ - MsnSlpLink *slplink; /**< The slplink that is using this switchboard. */ + GList *slplinks; /**< The list of slplinks that are using this switchboard. */ }; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-07-20 07:31:21
|
Revision: 16523 Author: thekingant Date: 2006-07-20 00:31:15 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16523&view=rev Log Message: ----------- Fix a crazy MSN crash. Basically it's possible to have more than one slplink associated with a given switchboard, but our code did not allow for that. I think it happens when you're in a multi-user chat and you do stuff with multiple users that involves slplinks. Like maybe file transfer and buddy icon related stuff. Tracking this down took an ungodly amount of time, but thanks to Meebo for letting me do it :-) Modified Paths: -------------- trunk/src/protocols/msn/slp.c trunk/src/protocols/msn/slplink.c trunk/src/protocols/msn/switchboard.c trunk/src/protocols/msn/switchboard.h Modified: trunk/src/protocols/msn/slp.c =================================================================== --- trunk/src/protocols/msn/slp.c 2006-07-19 23:52:01 UTC (rev 16522) +++ trunk/src/protocols/msn/slp.c 2006-07-20 07:31:15 UTC (rev 16523) @@ -748,7 +748,7 @@ * reporting bugs. Hopefully this doesn't cause more crashes. Stu. */ if (slplink->swboard != NULL) - slplink->swboard->slplink = slplink; + slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink); else gaim_debug_error("msn", "msn_p2p_msg, swboard is NULL, ouch!\n"); } Modified: trunk/src/protocols/msn/slplink.c =================================================================== --- trunk/src/protocols/msn/slplink.c 2006-07-19 23:52:01 UTC (rev 16522) +++ trunk/src/protocols/msn/slplink.c 2006-07-20 07:31:15 UTC (rev 16523) @@ -102,7 +102,7 @@ g_return_if_fail(slplink != NULL); if (slplink->swboard != NULL) - slplink->swboard->slplink = NULL; + slplink->swboard->slplinks = g_list_remove(slplink->swboard->slplinks, slplink); session = slplink->session; @@ -256,7 +256,7 @@ return; /* If swboard is destroyed we will be too */ - slplink->swboard->slplink = slplink; + slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink); } msn_switchboard_send_msg(slplink->swboard, msg, TRUE); Modified: trunk/src/protocols/msn/switchboard.c =================================================================== --- trunk/src/protocols/msn/switchboard.c 2006-07-19 23:52:01 UTC (rev 16522) +++ trunk/src/protocols/msn/switchboard.c 2006-07-20 07:31:15 UTC (rev 16523) @@ -82,8 +82,8 @@ swboard->destroying = TRUE; /* If it linked us is because its looking for trouble */ - if (swboard->slplink != NULL) - msn_slplink_destroy(swboard->slplink); + while (swboard->slplinks != NULL) + msn_slplink_destroy(swboard->slplinks->data); /* Destroy the message queue */ while ((msg = g_queue_pop_head(swboard->msg_queue)) != NULL) Modified: trunk/src/protocols/msn/switchboard.h =================================================================== --- trunk/src/protocols/msn/switchboard.h 2006-07-19 23:52:01 UTC (rev 16522) +++ trunk/src/protocols/msn/switchboard.h 2006-07-20 07:31:15 UTC (rev 16523) @@ -102,7 +102,7 @@ MsnSBErrorType error; /**< The error that occurred in this switchboard (if applicable). */ - MsnSlpLink *slplink; /**< The slplink that is using this switchboard. */ + GList *slplinks; /**< The list of slplinks that are using this switchboard. */ }; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-07-19 23:52:07
|
Revision: 16522 Author: sadrul Date: 2006-07-19 16:52:01 -0700 (Wed, 19 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16522&view=rev Log Message: ----------- Enable the commands (prefixed with /) in conversations. Modified Paths: -------------- trunk/console/Makefile trunk/console/gntconv.c trunk/console/gntgaim.c trunk/console/gntui.c Modified: trunk/console/Makefile =================================================================== --- trunk/console/Makefile 2006-07-19 20:14:58 UTC (rev 16521) +++ trunk/console/Makefile 2006-07-19 23:52:01 UTC (rev 16522) @@ -1,6 +1,6 @@ VERSION=gntgaim-0.0.0dev CC=gcc -CFLAGS=`pkg-config --cflags gaim gobject-2.0 gnt` -g -Wall -DVERSION=\"$(VERSION)\" +CFLAGS=`pkg-config --cflags gaim gobject-2.0 gnt` -g -Wall -DVERSION=\"$(VERSION)\" -DSTANDALONE LDFLAGS=`pkg-config --libs gaim gobject-2.0 libxml-2.0 gnt` -pg GG_SOURCES = \ Modified: trunk/console/gntconv.c =================================================================== --- trunk/console/gntconv.c 2006-07-19 20:14:58 UTC (rev 16521) +++ trunk/console/gntconv.c 2006-07-19 23:52:01 UTC (rev 16522) @@ -1,4 +1,6 @@ #include <string.h> + +#include <cmds.h> #include <util.h> #include "gntgaim.h" @@ -49,12 +51,53 @@ const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); if (*text == '/') { - /* XXX: Need to check for /-commands here */ + GaimConversation *conv = ggconv->conv; + GaimCmdStatus status; + const char *cmdline = text + 1; + char *error = NULL, *escape; + + escape = g_markup_escape_text(cmdline, -1); + status = gaim_cmd_do_command(conv, cmdline, escape, &error); + g_free(escape); + + switch (status) + { + case GAIM_CMD_STATUS_OK: + break; + case GAIM_CMD_STATUS_NOT_FOUND: + gaim_conversation_write(conv, "", _("No such command."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_WRONG_ARGS: + gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " + "to that command."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_FAILED: + gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_WRONG_TYPE: + if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) + gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + else + gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_WRONG_PRPL: + gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + } + g_free(error); +#if 0 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), _("Commands are not supported yet. Message was NOT sent."), GNT_TEXT_FLAG_DIM | GNT_TEXT_FLAG_UNDERLINE); gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv)); gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); +#endif } else { Modified: trunk/console/gntgaim.c =================================================================== --- trunk/console/gntgaim.c 2006-07-19 20:14:58 UTC (rev 16521) +++ trunk/console/gntgaim.c 2006-07-19 23:52:01 UTC (rev 16522) @@ -299,8 +299,9 @@ /* Initialize and run the UI */ init_gnt_ui(); - +#ifdef STANDALONE gaim_core_quit(); +#endif return 0; } Modified: trunk/console/gntui.c =================================================================== --- trunk/console/gntui.c 2006-07-19 20:14:58 UTC (rev 16521) +++ trunk/console/gntui.c 2006-07-19 23:52:01 UTC (rev 16522) @@ -8,8 +8,9 @@ void init_gnt_ui() { +#ifdef STANDALONE gnt_init(); - +#endif /* Accounts */ gg_accounts_init(); gaim_accounts_set_ui_ops(gg_accounts_get_ui_ops()); @@ -30,6 +31,7 @@ gg_notify_init(); gaim_notify_set_ui_ops(gg_notify_get_ui_ops()); +#ifdef STANDALONE gnt_main(); gaim_accounts_set_ui_ops(NULL); @@ -48,5 +50,6 @@ gg_notify_uninit(); gnt_quit(); +#endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-07-19 20:15:05
|
Revision: 16521 Author: aaronsheldon Date: 2006-07-19 13:14:58 -0700 (Wed, 19 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16521&view=rev Log Message: ----------- Merges soc-2006-chat-speed into trunk. (r16371:r16435) Joining large chat rooms, like IRC rooms, is much quicker. Additional improvment should be seen when using >=GTK+-2.6. Modified Paths: -------------- trunk/src/conversation.c trunk/src/conversation.h trunk/src/gtkconv.c trunk/src/gtkconv.h Modified: trunk/src/conversation.c =================================================================== --- trunk/src/conversation.c 2006-07-19 07:12:59 UTC (rev 16520) +++ trunk/src/conversation.c 2006-07-19 20:14:58 UTC (rev 16521) @@ -38,7 +38,6 @@ static GList *chats = NULL; static GaimConversationUiOps *default_ops = NULL; - void gaim_conversations_set_ui_ops(GaimConversationUiOps *ops) { @@ -1441,6 +1440,45 @@ g_list_free(flags2); } +int +gaim_conv_chat_cb_compare(GaimConvChatBuddy *a, GaimConvChatBuddy *b) +{ + GaimConvChatBuddyFlags f1 = 0, f2 = 0; + char *user1 = NULL, *user2 = NULL; + gint ret = 0; + + + if (a) { + f1 = a->flags; + if (a->alias_key) + user1 = a->alias_key; + else if (a->name) + user1 = a->name; + } + + if (b) { + f2 = b->flags; + if (b->alias_key) + user2 = b->alias_key; + else if (b->name) + user2 = b->name; + } + + if (user1 == NULL || user2 == NULL) { + if (!(user1 == NULL && user2 == NULL)) + ret = (user1 == NULL) ? -1: 1; + } else if (f1 != f2) { + /* sort more important users first */ + ret = (f1 > f2) ? -1 : 1; + } else if (a->buddy != b->buddy) { + ret = a->buddy ? -1 : 1; + } else { + ret = strcasecmp(user1, user2); + } + + return ret; +} + void gaim_conv_chat_add_users(GaimConvChat *chat, GList *users, GList *extra_msgs, GList *flags, gboolean new_arrivals) @@ -1451,7 +1489,7 @@ GaimConnection *gc; GaimPluginProtocolInfo *prpl_info; GList *ul, *fl; - GList *aliases = NULL; + GList *cbuddies = NULL; g_return_if_fail(chat != NULL); g_return_if_fail(users != NULL); @@ -1470,9 +1508,12 @@ const char *user = (const char *)ul->data; const char *alias = user; gboolean quiet; + GaimConvChatBuddy *cbuddy; GaimConvChatBuddyFlags flags = GPOINTER_TO_INT(fl->data); const char *extra_msg = (extra_msgs ? extra_msgs->data : NULL); + cbuddy = gaim_conv_chat_cb_new(user, NULL, GPOINTER_TO_INT(fl->data)); + if (!strcmp(chat->nick, gaim_normalize(conv->account, user))) { const char *alias2 = gaim_account_get_alias(conv->account); if (alias2 != NULL) @@ -1493,12 +1534,16 @@ "chat-buddy-joining", conv, user, flags)) | gaim_conv_chat_is_user_ignored(chat, user); - cb = gaim_conv_chat_cb_new(user, flags); + cb = gaim_conv_chat_cb_new(user, NULL, flags); + /* This seems dumb. Why should we set users thousands of times? */ gaim_conv_chat_set_users(chat, g_list_prepend(gaim_conv_chat_get_users(chat), cb)); - /* We reverse this later to keep it in the same order as users. */ - aliases = g_list_prepend(aliases, (char *)alias); + cbuddy->alias = strdup(alias); /* Should I be doing a strdup? */ + cbuddy->alias_key = g_utf8_collate_key(alias, strlen(alias)); + cbuddy->buddy = (gaim_find_buddy(conv->account, cbuddy->name) != NULL); + cbuddies = g_list_prepend(cbuddies, cbuddy); + if (!quiet && new_arrivals) { char *escaped = g_markup_escape_text(alias, -1); char *tmp; @@ -1525,14 +1570,11 @@ extra_msgs = extra_msgs->next; } - /* This needs to be in the same order as users, but it's faster - * to prepend, so we do that above. */ - aliases = g_list_reverse(aliases); - + cbuddies = g_list_sort(cbuddies, (GCompareFunc)gaim_conv_chat_cb_compare); + if (ops != NULL && ops->chat_add_users != NULL) - ops->chat_add_users(conv, users, flags, aliases, new_arrivals); + ops->chat_add_users(conv, cbuddies, new_arrivals); - g_list_free(aliases); } void @@ -1562,7 +1604,7 @@ g_return_if_fail(prpl_info != NULL); flags = gaim_conv_chat_user_get_flags(chat, old_user); - cb = gaim_conv_chat_cb_new(new_user, flags); + cb = gaim_conv_chat_cb_new(new_user, NULL, flags); gaim_conv_chat_set_users(chat, g_list_prepend(gaim_conv_chat_get_users(chat), cb)); @@ -1873,9 +1915,8 @@ return chat->left; } - GaimConvChatBuddy * -gaim_conv_chat_cb_new(const char *name, GaimConvChatBuddyFlags flags) +gaim_conv_chat_cb_new(const char *name, const char *alias, GaimConvChatBuddyFlags flags) { GaimConvChatBuddy *cb; @@ -1884,6 +1925,10 @@ cb = g_new0(GaimConvChatBuddy, 1); cb->name = g_strdup(name); cb->flags = flags; + if (alias) + cb->alias = g_strdup(alias); + else + cb->alias = NULL; GAIM_DBUS_REGISTER_POINTER(cb, GaimConvChatBuddy); return cb; Modified: trunk/src/conversation.h =================================================================== --- trunk/src/conversation.h 2006-07-19 07:12:59 UTC (rev 16520) +++ trunk/src/conversation.h 2006-07-19 20:14:58 UTC (rev 16521) @@ -158,8 +158,8 @@ const char *message, GaimMessageFlags flags, time_t mtime); - void (*chat_add_users)(GaimConversation *conv, GList *users, - GList *flags, GList *aliases, gboolean new_arrivals); + void (*chat_add_users)(GaimConversation *conv, GList *cbuddies, gboolean new_arrivals); + void (*chat_rename_user)(GaimConversation *conv, const char *old_name, const char *new_name, const char *new_alias); void (*chat_remove_users)(GaimConversation *conv, GList *users); @@ -214,6 +214,9 @@ struct _GaimConvChatBuddy { char *name; /**< The name */ + char *alias; /**< The alias */ + char *alias_key; /**< The alias key */ + gboolean buddy; /**< ChatBuddy is on the blist */ GaimConvChatBuddyFlags flags; /**< Flags (ops, voice etc.) */ }; @@ -1133,11 +1136,12 @@ * Creates a new chat buddy * * @param name The name. + * @param alias The alias. * @param flags The flags. * * @return The new chat buddy */ -GaimConvChatBuddy *gaim_conv_chat_cb_new(const char *name, +GaimConvChatBuddy *gaim_conv_chat_cb_new(const char *name, const char *alias, GaimConvChatBuddyFlags flags); /** Modified: trunk/src/gtkconv.c =================================================================== --- trunk/src/gtkconv.c 2006-07-19 07:12:59 UTC (rev 16520) +++ trunk/src/gtkconv.c 2006-07-19 20:14:58 UTC (rev 16521) @@ -154,8 +154,7 @@ static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); static void gray_stuff_out(GaimGtkConversation *gtkconv); static GList *generate_invite_user_names(GaimConnection *gc); -static void add_chat_buddy_common(GaimConversation *conv, const char *name, - GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); +static void add_chat_buddy_common(GaimConversation *conv, GaimConvChatBuddy *cb, const char *old_name); static gboolean tab_complete(GaimConversation *conv); static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); @@ -1394,6 +1393,7 @@ { GaimConversation *conv = gtkconv->active_conv; GaimGtkChatPane *gtkchat; + GaimConvChatBuddy *cbuddy; GaimConvChat *chat; GaimConvChatBuddyFlags flags; GtkTreeIter iter; @@ -1424,7 +1424,9 @@ else gaim_conv_chat_ignore(chat, name); - add_chat_buddy_common(conv, name, flags, alias, NULL); + cbuddy = gaim_conv_chat_cb_new(name, alias, flags); + + add_chat_buddy_common(conv, cbuddy, NULL); g_free(name); g_free(alias); } @@ -3288,7 +3290,7 @@ } static void -add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) +add_chat_buddy_common(GaimConversation *conv, GaimConvChatBuddy *cb, const char *old_name) { GaimGtkConversation *gtkconv; GaimGtkChatPane *gtkchat; @@ -3300,6 +3302,12 @@ GtkTreeIter iter; gboolean is_me = FALSE; gboolean is_buddy; + gchar *alias_key, *name, *alias; + int flags; + + alias = cb->alias; + name = cb->name; + flags = GPOINTER_TO_INT(cb->flags); chat = GAIM_CONV_CHAT(conv); gtkconv = GAIM_GTK_CONVERSATION(conv); @@ -3318,32 +3326,74 @@ is_buddy = (gaim_find_buddy(conv->account, name) != NULL); - gtk_list_store_append(ls, &iter); + alias_key = g_utf8_collate_key(alias, strlen(alias)); if (is_me) { GdkColor send_color; gdk_color_parse(SEND_COLOR, &send_color); - + +#if GTK_CHECK_VERSION(2,6,0) + gtk_list_store_insert_with_values + (ls, + &iter, +/* + * The GTK docs are mute about the effects of the "row" value for performance. + * X-Chat hardcodes their value to 0 (prepend) and -1 (append), so we will too. + * It *might* be faster to search the gtk_list_store and set row accurately, + * but no one in #gtk+ seems to know anything about it either. + * Inserting in the "wrong" location has no visible ill effects. - F.P. + */ + -1, /* "row" */ + CHAT_USERS_ICON_COLUMN, pixbuf, + CHAT_USERS_ALIAS_COLUMN, alias, + CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, + CHAT_USERS_NAME_COLUMN, name, + CHAT_USERS_FLAGS_COLUMN, flags, + CHAT_USERS_COLOR_COLUMN, &send_color, + CHAT_USERS_BUDDY_COLUMN, is_buddy, + -1); + } + else { + gtk_list_store_insert_with_values + (ls, + &iter, + -1, /* "row" */ + CHAT_USERS_ICON_COLUMN, pixbuf, + CHAT_USERS_ALIAS_COLUMN, alias, + CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, + CHAT_USERS_NAME_COLUMN, name, + CHAT_USERS_FLAGS_COLUMN, flags, + CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), + CHAT_USERS_BUDDY_COLUMN, is_buddy, + -1); + +#else + gtk_list_store_append(ls, &iter); gtk_list_store_set(ls, &iter, CHAT_USERS_ICON_COLUMN, pixbuf, CHAT_USERS_ALIAS_COLUMN, alias, + CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, CHAT_USERS_NAME_COLUMN, name, CHAT_USERS_FLAGS_COLUMN, flags, CHAT_USERS_COLOR_COLUMN, &send_color, CHAT_USERS_BUDDY_COLUMN, is_buddy, -1); } - else - { + + else { + + gtk_list_store_append(ls, &iter); gtk_list_store_set(ls, &iter, CHAT_USERS_ICON_COLUMN, pixbuf, CHAT_USERS_ALIAS_COLUMN, alias, + CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, CHAT_USERS_NAME_COLUMN, name, CHAT_USERS_FLAGS_COLUMN, flags, CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), CHAT_USERS_BUDDY_COLUMN, is_buddy, -1); +#endif } if (pixbuf) @@ -3601,12 +3651,12 @@ gint ret = 0; gtk_tree_model_get(model, a, - CHAT_USERS_ALIAS_COLUMN, &user1, + CHAT_USERS_ALIAS_KEY_COLUMN, &user1, CHAT_USERS_FLAGS_COLUMN, &f1, CHAT_USERS_BUDDY_COLUMN, &buddy1, -1); gtk_tree_model_get(model, b, - CHAT_USERS_ALIAS_COLUMN, &user2, + CHAT_USERS_ALIAS_KEY_COLUMN, &user2, CHAT_USERS_FLAGS_COLUMN, &f2, CHAT_USERS_BUDDY_COLUMN, &buddy2, -1); @@ -3620,7 +3670,7 @@ } else if (buddy1 != buddy2) { ret = buddy1 ? -1 : 1; } else { - ret = gaim_utf8_strcasecmp(user1, user2); + ret = strcasecmp(user1, user2); } g_free(user1); @@ -3657,17 +3707,21 @@ if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { const char *alias = name; + char *alias_key = g_utf8_collate_key(alias, strlen(alias)); GaimBuddy *buddy2; if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { /* This user is not me, so look into updating the alias. */ - if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) + if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) { alias = gaim_buddy_get_contact_alias(buddy2); + alias_key = g_utf8_collate_key(alias, strlen(alias)); + } gtk_list_store_set(GTK_LIST_STORE(model), &iter, - CHAT_USERS_ALIAS_COLUMN, alias, - -1); + CHAT_USERS_ALIAS_COLUMN, alias, + CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, + -1); } g_free(name); break; @@ -3908,11 +3962,10 @@ gtk_widget_show(sw); ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_COLOR, G_TYPE_BOOLEAN); - gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, + GDK_TYPE_COLOR, G_TYPE_BOOLEAN); + gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, sort_chat_users, NULL, NULL); - gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, - GTK_SORT_ASCENDING); list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); @@ -4970,16 +5023,15 @@ account, name, message, conv, flags); g_free(displaying); } - static void -gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *flags, GList *aliases, gboolean new_arrivals) +gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *cbuddies, gboolean new_arrivals) { GaimConvChat *chat; GaimGtkConversation *gtkconv; GaimGtkChatPane *gtkchat; + GtkListStore *ls; GList *l; - GList *ll; - GList *lll; + char tmp[BUF_LONG]; int num_users; @@ -4996,15 +5048,22 @@ gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); - l = users; - ll = flags; - lll = aliases; - while (l != NULL && ll != NULL && lll != NULL) { - add_chat_buddy_common(conv, (const char *)l->data, GPOINTER_TO_INT(ll->data), (const char *)lll->data, NULL); + ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); + + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, + GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID); + + l = cbuddies; + while (l != NULL) { + add_chat_buddy_common(conv, (GaimConvChatBuddy *)l->data, NULL); l = l->next; - ll = ll->next; - lll = lll->next; } + + /* Currently GTK+ maintains our sorted list after it's in the tree. + * This may change if it turns out we can manage it faster ourselves. + */ + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, + GTK_SORT_ASCENDING); } static void @@ -5015,6 +5074,7 @@ GaimGtkConversation *gtkconv; GaimGtkChatPane *gtkchat; GaimConvChatBuddyFlags flags; + GaimConvChatBuddy *cbuddy; GtkTreeIter iter; GtkTreeModel *model; int f = 1; @@ -5049,7 +5109,9 @@ g_return_if_fail(new_alias != NULL); - add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); + cbuddy = gaim_conv_chat_cb_new(new_name, new_alias, flags); + + add_chat_buddy_common(conv, cbuddy, old_name); } static void @@ -5110,6 +5172,7 @@ { GaimConvChat *chat; GaimConvChatBuddyFlags flags; + GaimConvChatBuddy *cbuddy; GaimGtkConversation *gtkconv; GaimGtkChatPane *gtkchat; GtkTreeIter iter; @@ -5153,7 +5216,9 @@ flags = gaim_conv_chat_user_get_flags(chat, user); - add_chat_buddy_common(conv, user, flags, alias, NULL); + cbuddy = gaim_conv_chat_cb_new(user, alias, flags); + + add_chat_buddy_common(conv, cbuddy, NULL); g_free(alias); } Modified: trunk/src/gtkconv.h =================================================================== --- trunk/src/gtkconv.h 2006-07-19 07:12:59 UTC (rev 16520) +++ trunk/src/gtkconv.h 2006-07-19 20:14:58 UTC (rev 16521) @@ -44,6 +44,7 @@ enum { CHAT_USERS_ICON_COLUMN, CHAT_USERS_ALIAS_COLUMN, + CHAT_USERS_ALIAS_KEY_COLUMN, CHAT_USERS_NAME_COLUMN, CHAT_USERS_FLAGS_COLUMN, CHAT_USERS_COLOR_COLUMN, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |