Mercurial > pidgin.yaz
view console/gntnotify.c @ 14357:4e14503b9bac
[gaim-migrate @ 17063]
Fix an assertion that fails for me about half the time
when I try to sign onto MSN.
Here's a backtrace, in case someone wants to look at this
more in depth:
#4 0x00002aaab203d857 in msn_object_new_from_string (str=0x2aaaac4f0860 "0")
at object.c:79
obj = (MsnObject *) 0x7fff2bc6efe0
tag = 0x2aaaac4f0861 ""
c = 0x100000001 <Address 0x100000001 out of bounds>
__PRETTY_FUNCTION__ = "msn_object_new_from_string"
#5 0x00002aaab203bf37 in nln_cmd (cmdproc=0xd84f30, cmd=0xcb1e10)
at notification.c:687
session = (MsnSession *) 0xd72e70
account = (GaimAccount *) 0x63c020
gc = (GaimConnection *) 0xd5d9b0
user = (MsnUser *) 0xcb1d90
msnobj = (MsnObject *) 0x2aaaacc127d9
clientid = 32767
state = 0xc97820 "NLN"
passport = 0xd65310 "lbdash@yahoo.com"
friendly = 0x2aaaac4f0860 "0"
#6 0x00002aaab202ff18 in msn_cmdproc_process_cmd (cmdproc=0xd84f30,
cmd=0xcb1e10) at cmdproc.c:313
cb = 0x2aaab203be63 <nln_cmd>
trans = (MsnTransaction *) 0x0
#7 0x00002aaab202ffbe in msn_cmdproc_process_cmd_text (cmdproc=0xd84f30,
command=0xe082b0 "NLN NLN lbdash@yahoo.com lbdash@yahoo.com 1073741856 0")
at cmdproc.c:335
No locals.
#8 0x00002aaab2032c06 in read_cb (data=0xd4e600, source=7,
cond=GAIM_INPUT_READ) at httpconn.c:380
httpconn = (MsnHttpConn *) 0xd4e600
servconn = (MsnServConn *) 0xd65360
session = (MsnSession *) 0xd72e70
buf = "HTTP/1.1 200 OK\r\nDate: Sun, 27 Aug 2006 21:29:58 GMT\r\nServer:
Microsoft-IIS/6.0\r\nX-Powered-By: ASP.N ET\r\nX-MSN-Messenger:
SessionID=26246177.8760; GW-IP=207.46.7.4\r\nContent-Length: 56\r\nContent-type:
ap"...
cur = 0xe082b0 "NLN NLN lbdash@yahoo.com lbdash@yahoo.com 1073741856 0"
end = 0xe082e8 ""
old_rx_buf = 0xe082b0 "NLN NLN lbdash@yahoo.com lbdash@yahoo.com
1073741856 0"
len = 285
cur_len = 56
result_msg = 0xe082b0 "NLN NLN lbdash@yahoo.com lbdash@yahoo.com
1073741856 0"
result_len = 56
error = 0
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 27 Aug 2006 21:36:52 +0000 |
parents | a8a0b10be4fb |
children | 81650a27f253 |
line wrap: on
line source
#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 notify_msg_window_destroy_cb(GntWidget *window, GaimNotifyMsgType type) { gaim_notify_close(type, window); } 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); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); gnt_widget_show(window); return window; } /* handle is, in all/most occasions, a GntWidget * */ static void gg_close_notify(GaimNotifyType type, void *handle) { GntWidget *widget = handle; if (!widget) return; while (widget->parent) widget = widget->parent; if (type == GAIM_NOTIFY_SEARCHRESULTS) gaim_notify_searchresults_free(g_object_get_data(handle, "notify-results")); #if 1 /* This did not seem to be necessary */ g_signal_handlers_disconnect_by_func(G_OBJECT(widget), G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); #endif gnt_widget_destroy(widget); } 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_FORMATTED, 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 { char *to; setup_email_dialog(); to = g_strdup_printf("%s (%s)", tos ? *tos : gaim_account_get_username(account), gaim_account_get_protocol_name(account)); gnt_tree_add_row_after(GNT_TREE(emaildialog.tree), GINT_TO_POINTER(time(NULL)), gnt_tree_create_row(GNT_TREE(emaildialog.tree), to, froms ? *froms : "[Unknown sender]", *subjects), NULL, NULL); g_free(to); gnt_widget_show(emaildialog.window); return NULL; } ret = gg_notify_message(GAIM_NOTIFY_EMAIL, _("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 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; default: text = _("(none)"); } 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, .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 = gg_notify_searchresults, .notify_searchresults_new_rows = gg_notify_sr_new_rows, .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() { }