# HG changeset patch # User John Bailey # Date 1209534649 0 # Node ID 424037c8a343b3b30c14c5402c2064657ae2d6fe # Parent 087c3ed328d3e1037d5ed6f31fbd15edc2f4f6ef# Parent 83c726877e09084e4618a2617bc19c99171bb985 propagate from branch 'im.pidgin.pidgin' (head 7a752818c2f9f500d9b707e9424bd75230b2a05d) to branch 'im.pidgin.pidgin.next.minor' (head 38c3a1050aefc66e1c541e3d91ae6f7fe6930559) diff -r 83c726877e09 -r 424037c8a343 ChangeLog.API --- a/ChangeLog.API Wed Apr 30 02:24:51 2008 +0000 +++ b/ChangeLog.API Wed Apr 30 05:50:49 2008 +0000 @@ -1,6 +1,10 @@ Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul -version 2.x.x: +version 2.5.0: + libpurple: + Added: + * purple_serv_got_join_chat_failed + * chat-join-failed signal (see conversation-signals.dox) perl: Added: * Purple::Prefs::get_children_names. diff -r 83c726877e09 -r 424037c8a343 configure.ac --- a/configure.ac Wed Apr 30 02:24:51 2008 +0000 +++ b/configure.ac Wed Apr 30 05:50:49 2008 +0000 @@ -43,19 +43,19 @@ # # Make sure to update finch/libgnt/configure.ac with libgnt version changes. # -m4_define([purple_lt_current], [4]) +m4_define([purple_lt_current], [5]) m4_define([purple_major_version], [2]) -m4_define([purple_minor_version], [4]) -m4_define([purple_micro_version], [2]) +m4_define([purple_minor_version], [5]) +m4_define([purple_micro_version], [0]) m4_define([purple_version_suffix], [devel]) m4_define([purple_version], [purple_major_version.purple_minor_version.purple_micro_version]) m4_define([purple_display_version], purple_version[]m4_ifdef([purple_version_suffix],[purple_version_suffix])) -m4_define([gnt_lt_current], [4]) +m4_define([gnt_lt_current], [5]) m4_define([gnt_major_version], [2]) -m4_define([gnt_minor_version], [4]) -m4_define([gnt_micro_version], [2]) +m4_define([gnt_minor_version], [5]) +m4_define([gnt_micro_version], [0]) m4_define([gnt_version_suffix], [devel]) m4_define([gnt_version], [gnt_major_version.gnt_minor_version.gnt_micro_version]) diff -r 83c726877e09 -r 424037c8a343 libpurple/conversation.c --- a/libpurple/conversation.c Wed Apr 30 02:24:51 2008 +0000 +++ b/libpurple/conversation.c Wed Apr 30 05:50:49 2008 +0000 @@ -2368,6 +2368,12 @@ purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONVERSATION)); + purple_signal_register(handle, "chat-join-failed", + purple_marshal_VOID__POINTER_POINTER, NULL, 2, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_CONNECTION), + purple_value_new(PURPLE_TYPE_STRING)); + purple_signal_register(handle, "chat-left", purple_marshal_VOID__POINTER, NULL, 1, purple_value_new(PURPLE_TYPE_SUBTYPE, diff -r 83c726877e09 -r 424037c8a343 libpurple/protocols/jabber/chat.c --- a/libpurple/protocols/jabber/chat.c Wed Apr 30 02:24:51 2008 +0000 +++ b/libpurple/protocols/jabber/chat.c Wed Apr 30 05:50:49 2008 +0000 @@ -222,33 +222,39 @@ if(!handle) handle = js->user->node; + tmp = g_strdup_printf("%s@%s", room, server); + room_jid = g_strdup(jabber_normalize(NULL, tmp)); + g_free(tmp); + if(!jabber_nodeprep_validate(room)) { char *buf = g_strdup_printf(_("%s is not a valid room name"), room); purple_notify_error(gc, _("Invalid Room Name"), _("Invalid Room Name"), buf); + purple_serv_got_join_chat_failed(gc, room_jid); + g_free(room_jid); g_free(buf); return; } else if(!jabber_nameprep_validate(server)) { char *buf = g_strdup_printf(_("%s is not a valid server name"), server); purple_notify_error(gc, _("Invalid Server Name"), _("Invalid Server Name"), buf); + purple_serv_got_join_chat_failed(gc, room_jid); + g_free(room_jid); g_free(buf); return; } else if(!jabber_resourceprep_validate(handle)) { char *buf = g_strdup_printf(_("%s is not a valid room handle"), handle); purple_notify_error(gc, _("Invalid Room Handle"), _("Invalid Room Handle"), buf); + purple_serv_got_join_chat_failed(gc, room_jid); g_free(buf); + g_free(room_jid); return; } if(jabber_chat_find(js, room, server)) return; - tmp = g_strdup_printf("%s@%s", room, server); - room_jid = g_strdup(jabber_normalize(NULL, tmp)); - g_free(tmp); - chat = g_new0(JabberChat, 1); chat->js = gc->proto_data; diff -r 83c726877e09 -r 424037c8a343 libpurple/protocols/jabber/presence.c --- a/libpurple/protocols/jabber/presence.c Wed Apr 30 02:24:51 2008 +0000 +++ b/libpurple/protocols/jabber/presence.c Wed Apr 30 05:50:49 2008 +0000 @@ -587,6 +587,7 @@ serv_got_chat_left(js->gc, chat->id); } else { title = g_strdup_printf(_("Error joining chat %s"), from); + purple_serv_got_join_chat_failed(js->gc, room_jid); } purple_notify_error(js->gc, title, title, msg); g_free(title); diff -r 83c726877e09 -r 424037c8a343 libpurple/protocols/msn/msn.c --- a/libpurple/protocols/msn/msn.c Wed Apr 30 02:24:51 2008 +0000 +++ b/libpurple/protocols/msn/msn.c Wed Apr 30 05:50:49 2008 +0000 @@ -132,6 +132,17 @@ return list; } +static GHashTable * +msn_get_account_text_table() +{ + GHashTable *table; + + table = g_hash_table_new(g_str_hash, g_str_equal); + + g_hash_table_insert(table, "login_label", (gpointer)_("E-mail Address...")); + + return table; +} static PurpleCmdRet msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) @@ -2306,9 +2317,7 @@ NULL, /* unregister_user */ msn_send_attention, /* send_attention */ msn_attention_types, /* attention_types */ - - /* padding */ - NULL + msn_get_account_text_table /* get_account_text_table */ }; static PurplePluginInfo info = diff -r 83c726877e09 -r 424037c8a343 libpurple/protocols/msnp9/msn.c --- a/libpurple/protocols/msnp9/msn.c Wed Apr 30 02:24:51 2008 +0000 +++ b/libpurple/protocols/msnp9/msn.c Wed Apr 30 05:50:49 2008 +0000 @@ -133,6 +133,17 @@ return list; } +static GHashTable * +msn_get_account_text_table() +{ + GHashTable *table; + + table = g_hash_table_new(g_str_hash, g_str_equal); + + g_hash_table_insert(table, "login_label", (gpointer)_("E-mail Address...")); + + return table; +} static PurpleCmdRet msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) @@ -2147,9 +2158,7 @@ NULL, /* unregister_user */ msn_send_attention, /* send_attention */ msn_attention_types, /* attention_types */ - - /* padding */ - NULL + msn_get_account_text_table /* get_account_text_table */ }; static PurplePluginInfo info = diff -r 83c726877e09 -r 424037c8a343 libpurple/protocols/myspace/myspace.c --- a/libpurple/protocols/myspace/myspace.c Wed Apr 30 02:24:51 2008 +0000 +++ b/libpurple/protocols/myspace/myspace.c Wed Apr 30 05:50:49 2008 +0000 @@ -2449,6 +2449,18 @@ return normalized; } +static GHashTable * +msim_get_account_text_table() +{ + GHashTable *table; + + table = g_hash_table_new(g_str_hash, g_str_equal); + + g_hash_table_insert(table, "login_label", (gpointer)_("E-mail Address...")); + + return table; +} + /** Return whether the buddy can be messaged while offline. * * The protocol supports offline messages in just the same way as online @@ -3131,7 +3143,7 @@ NULL, /* unregister_user */ msim_send_attention, /* send_attention */ msim_attention_types, /* attention_types */ - NULL /* _purple_reserved4 */ + msim_get_account_text_table /* get_account_text_table */ }; diff -r 83c726877e09 -r 424037c8a343 libpurple/prpl.h --- a/libpurple/prpl.h Wed Apr 30 02:24:51 2008 +0000 +++ b/libpurple/prpl.h Wed Apr 30 05:50:49 2008 +0000 @@ -398,7 +398,15 @@ gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type); GList *(*get_attention_types)(PurpleAccount *acct); - void (*_purple_reserved4)(void); + /** This allows protocols to specify additional strings to be used for + * various purposes. The idea is to stuff a bunch of strings in this hash + * table instead of expanding the struct for every addition. This hash + * table is allocated every call and MUST be unrefed by the caller. + * + * @param account The account to specify. This can be NULL. + * @return The protocol's string hash table. + */ + GHashTable *(*get_account_text_table)(PurpleAccount *account); }; #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \ diff -r 83c726877e09 -r 424037c8a343 libpurple/server.c --- a/libpurple/server.c Wed Apr 30 02:24:51 2008 +0000 +++ b/libpurple/server.c Wed Apr 30 05:50:49 2008 +0000 @@ -967,6 +967,12 @@ purple_signal_emit(purple_conversations_get_handle(), "chat-left", conv); } +void purple_serv_got_join_chat_failed(PurpleConnection *gc, const char *name) +{ + purple_signal_emit(purple_conversations_get_handle(), "chat-join-failed", + gc, name); +} + void serv_got_chat_in(PurpleConnection *g, int id, const char *who, PurpleMessageFlags flags, const char *message, time_t mtime) { diff -r 83c726877e09 -r 424037c8a343 libpurple/server.h --- a/libpurple/server.h Wed Apr 30 02:24:51 2008 +0000 +++ b/libpurple/server.h Wed Apr 30 05:50:49 2008 +0000 @@ -166,6 +166,15 @@ PurpleConversation *serv_got_joined_chat(PurpleConnection *gc, int id, const char *name); +/** + * Called by a prpl when an attempt to join a chat via serv_join_chat() + * fails. + * + * @param gc The connection on which chat joining failed + * @param name The name of the chat which we did not join + */ +void purple_serv_got_join_chat_failed(PurpleConnection *gc, const char *name); + void serv_got_chat_left(PurpleConnection *g, int id); void serv_got_chat_in(PurpleConnection *g, int id, const char *who, PurpleMessageFlags flags, const char *message, time_t mtime); diff -r 83c726877e09 -r 424037c8a343 pidgin/gtkaccount.c --- a/pidgin/gtkaccount.c Wed Apr 30 02:24:51 2008 +0000 +++ b/pidgin/gtkaccount.c Wed Apr 30 05:50:49 2008 +0000 @@ -255,6 +255,25 @@ } } +static gboolean +screenname_focus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog) +{ + GHashTable *table; + const char *label; + + table = dialog->prpl_info->get_account_text_table(NULL); + label = g_hash_table_lookup(table, "login_label"); + + if(!strcmp(gtk_entry_get_text(GTK_ENTRY(widget)), label)) { + gtk_entry_set_text(GTK_ENTRY(widget), ""); + gtk_widget_modify_text(widget, GTK_STATE_NORMAL,NULL); + } + + g_hash_table_unref(table); + + return FALSE; +} + static void screenname_changed_cb(GtkEntry *entry, AccountPrefsDialog *dialog) { @@ -270,6 +289,32 @@ } } +static gboolean +screenname_nofocus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog) +{ + GdkColor color = {0, 34952, 35466, 34181}; + GHashTable *table; + const char *label; + + table = dialog->prpl_info->get_account_text_table(NULL); + label = g_hash_table_lookup(table, "login_label"); + + if (*gtk_entry_get_text(GTK_ENTRY(widget)) == '\0') { + /* We have to avoid hitting the screenname_changed_cb function + * because it enables buttons we don't want enabled yet ;) + */ + g_signal_handlers_block_by_func(widget, G_CALLBACK(screenname_changed_cb), dialog); + gtk_entry_set_text(GTK_ENTRY(widget), label); + /* Make sure we can hit it again */ + g_signal_handlers_unblock_by_func(widget, G_CALLBACK(screenname_changed_cb), dialog); + gtk_widget_modify_text(widget, GTK_STATE_NORMAL, &color); + } + + g_hash_table_unref(table); + + return FALSE; +} + static void icon_filesel_choose_cb(const char *filename, gpointer data) { @@ -364,6 +409,9 @@ GList *user_splits; GList *l, *l2; char *username = NULL; + GdkColor color = {0, 34952, 35466, 34181}; + GHashTable *table; + const char *label; if (dialog->protocol_menu != NULL) { @@ -410,6 +458,20 @@ add_pref_box(dialog, vbox, _("Screen _name:"), dialog->screenname_entry); + if (dialog->prpl_info->get_account_text_table) { + table = dialog->prpl_info->get_account_text_table(NULL); + label = g_hash_table_lookup(table, "login_label"); + + gtk_entry_set_text(GTK_ENTRY(dialog->screenname_entry), label); + g_signal_connect(G_OBJECT(dialog->screenname_entry), "focus-in-event", + G_CALLBACK(screenname_focus_cb), dialog); + g_signal_connect(G_OBJECT(dialog->screenname_entry), "focus-out-event", + G_CALLBACK(screenname_nofocus_cb), dialog); + gtk_widget_modify_text(dialog->screenname_entry, GTK_STATE_NORMAL, &color); + + g_hash_table_unref(table); + } + g_signal_connect(G_OBJECT(dialog->screenname_entry), "changed", G_CALLBACK(screenname_changed_cb), dialog);