Mercurial > pidgin.yaz
changeset 23116:d53f72735830
propagate from branch 'im.pidgin.pidgin' (head ba6112dabbb907fd5e93c30e0f5228e557949d69)
to branch 'im.pidgin.pidgin.next.minor' (head f42c9025190a57ae55424302fd21d2b615a721a9)
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Mon, 12 May 2008 02:19:06 +0000 |
parents | 67148f43fd2f (current diff) f714a7fa01f4 (diff) |
children | d11c993700e6 dea8b856466e |
files | ChangeLog.API configure.ac libpurple/prpl.h |
diffstat | 27 files changed, 222 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog.API Mon May 12 02:03:13 2008 +0000 +++ b/ChangeLog.API Mon May 12 02:19:06 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.
--- a/configure.ac Mon May 12 02:03:13 2008 +0000 +++ b/configure.ac Mon May 12 02:19:06 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])
--- a/doc/conversation-signals.dox Mon May 12 02:03:13 2008 +0000 +++ b/doc/conversation-signals.dox Mon May 12 02:19:06 2008 +0000 @@ -27,6 +27,7 @@ @signal chat-invited-user @signal chat-invited @signal chat-joined + @signal chat-join-failed @signal chat-left @signal chat-topic-changed @signal conversation-extended-menu @@ -302,6 +303,18 @@ @param new_arrival If the buddy is a new arrival. @endsignaldef + @signaldef chat-join-failed + @signalproto +void (*chat_join_failed)(PurpleConnection *gc, GHashTable *components); + @endsignalproto + @signaldesc + Emitted when an account fails to join a chat room + @param gc The PurpleConnection of the account which failed to join the chat. + @param data The components passed to serv_join_chat() originally. + The hash function should be g_str_hash() and the equal + function should be g_str_equal(). + @endsignaldef + @signaldef chat-buddy-flags @signalproto void (*chat_buddy_flags)(PurpleConversation *conv, const char *name,
--- a/libpurple/conversation.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/conversation.c Mon May 12 02:19:06 2008 +0000 @@ -2381,6 +2381,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_POINTER)); + purple_signal_register(handle, "chat-left", purple_marshal_VOID__POINTER, NULL, 1, purple_value_new(PURPLE_TYPE_SUBTYPE,
--- a/libpurple/protocols/bonjour/bonjour.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/bonjour/bonjour.c Mon May 12 02:19:06 2008 +0000 @@ -487,6 +487,7 @@ NULL, NULL, NULL, + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/gg/gg.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/gg/gg.c Mon May 12 02:19:06 2008 +0000 @@ -2152,6 +2152,7 @@ NULL, NULL, NULL, + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL }; /* }}} */
--- a/libpurple/protocols/irc/irc.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/irc/irc.c Mon May 12 02:19:06 2008 +0000 @@ -905,6 +905,7 @@ NULL, NULL, NULL, + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/jabber/chat.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/jabber/chat.c Mon May 12 02:19:06 2008 +0000 @@ -198,6 +198,12 @@ return chat_name; } +static void insert_in_hash_table(gpointer key, gpointer value, gpointer user_data) +{ + GHashTable *hash_table = (GHashTable *)user_data; + g_hash_table_insert(hash_table, g_strdup(key), g_strdup(value)); +} + void jabber_chat_join(PurpleConnection *gc, GHashTable *data) { JabberChat *chat; @@ -226,18 +232,21 @@ 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, data); 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, data); 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, data); g_free(buf); return; } @@ -256,6 +265,11 @@ chat->server = g_strdup(server); chat->handle = g_strdup(handle); + /* Copy the data hash table to chat->components */ + chat->components = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_free); + g_hash_table_foreach(data, insert_in_hash_table, chat->components); + chat->members = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)jabber_chat_member_free); @@ -316,6 +330,7 @@ g_free(chat->server); g_free(chat->handle); g_hash_table_destroy(chat->members); + g_hash_table_destroy(chat->components); g_free(chat); }
--- a/libpurple/protocols/jabber/chat.h Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/jabber/chat.h Mon May 12 02:19:06 2008 +0000 @@ -41,6 +41,7 @@ char *room; char *server; char *handle; + GHashTable *components; int id; PurpleConversation *conv; gboolean muc;
--- a/libpurple/protocols/jabber/libxmpp.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/jabber/libxmpp.c Mon May 12 02:19:06 2008 +0000 @@ -116,7 +116,7 @@ jabber_send_attention, /* send_attention */ jabber_attention_types, /* attention_types */ - /* padding */ + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/jabber/presence.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/jabber/presence.c Mon May 12 02:19:06 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, chat->components); } purple_notify_error(js->gc, title, title, msg); g_free(title);
--- a/libpurple/protocols/msn/msn.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/msn/msn.c Mon May 12 02:19:06 2008 +0000 @@ -132,6 +132,17 @@ return list; } +static GHashTable * +msn_get_account_text_table(PurpleAccount *unused) +{ + 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) @@ -2307,8 +2318,8 @@ msn_send_attention, /* send_attention */ msn_attention_types, /* attention_types */ - /* padding */ - NULL + sizeof(PurplePluginProtocolInfo), /* struct_size */ + msn_get_account_text_table, /* get_account_text_table */ }; static PurplePluginInfo info =
--- a/libpurple/protocols/msnp9/msn.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/msnp9/msn.c Mon May 12 02:19:06 2008 +0000 @@ -133,6 +133,17 @@ return list; } +static GHashTable * +msn_get_account_text_table(PurpleAccount *unused) +{ + 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) @@ -2148,8 +2159,8 @@ msn_send_attention, /* send_attention */ msn_attention_types, /* attention_types */ - /* padding */ - NULL + sizeof(PurplePluginProtocolInfo), /* struct_size */ + msn_get_account_text_table, /* get_account_text_table */ }; static PurplePluginInfo info =
--- a/libpurple/protocols/myspace/myspace.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/myspace/myspace.c Mon May 12 02:19:06 2008 +0000 @@ -2449,6 +2449,18 @@ return normalized; } +static GHashTable * +msim_get_account_text_table(PurpleAccount *unused) +{ + 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,14 +3143,16 @@ NULL, /* unregister_user */ msim_send_attention, /* send_attention */ msim_attention_types, /* attention_types */ - NULL /* _purple_reserved4 */ + + sizeof(PurplePluginProtocolInfo), /* struct_size */ + msim_get_account_text_table, /* get_account_text_table */ }; /** Based on MSN's plugin info comments. */ static PurplePluginInfo info = { - PURPLE_PLUGIN_MAGIC, + PURPLE_PLUGIN_MAGIC, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_PLUGIN_PROTOCOL, /**< type */
--- a/libpurple/protocols/novell/novell.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/novell/novell.c Mon May 12 02:19:06 2008 +0000 @@ -3517,6 +3517,7 @@ NULL, NULL, NULL, + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/oscar/libaim.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/oscar/libaim.c Mon May 12 02:19:06 2008 +0000 @@ -96,7 +96,7 @@ NULL, /* send_attention */ NULL, /* get_attention_types */ - /* padding */ + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/oscar/libicq.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/oscar/libicq.c Mon May 12 02:19:06 2008 +0000 @@ -96,7 +96,7 @@ NULL, /* send_attention */ NULL, /* get_attention_types */ - /* padding */ + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/qq/qq.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/qq/qq.c Mon May 12 02:19:06 2008 +0000 @@ -706,6 +706,7 @@ NULL, NULL, NULL, + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/silc/silc.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/silc/silc.c Mon May 12 02:19:06 2008 +0000 @@ -2071,6 +2071,7 @@ NULL, NULL, NULL, + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/silc10/silc.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/silc10/silc.c Mon May 12 02:19:06 2008 +0000 @@ -1800,10 +1800,10 @@ NULL, /* send_raw */ NULL, /* roomlist_room_serialize */ - /* padding */ NULL, NULL, NULL, + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/simple/simple.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/simple/simple.c Mon May 12 02:19:06 2008 +0000 @@ -2052,6 +2052,7 @@ NULL, NULL, NULL, + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/yahoo/yahoo.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/yahoo/yahoo.c Mon May 12 02:19:06 2008 +0000 @@ -4383,7 +4383,7 @@ yahoo_send_attention, yahoo_attention_types, - /* padding */ + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/protocols/zephyr/zephyr.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/protocols/zephyr/zephyr.c Mon May 12 02:19:06 2008 +0000 @@ -2907,10 +2907,10 @@ NULL, /* send_raw */ NULL, /* roomlist_room_serialize */ - /* padding */ NULL, NULL, NULL, + sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL };
--- a/libpurple/prpl.h Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/prpl.h Mon May 12 02:19:06 2008 +0000 @@ -399,9 +399,45 @@ gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type); GList *(*get_attention_types)(PurpleAccount *acct); - void (*_purple_reserved4)(void); + /** + * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo). + * This allows adding more functions to this struct without requiring a major version bump. + */ + unsigned long struct_size; + + /* NOTE: + * If more functions are added, they should accessed using the following syntax: + * + * if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function)) + * prpl->new_function(...); + * + * instead of + * + * if (prpl->new_function != NULL) + * prpl->new_function(...); + * + * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member + * functions (e.g. login, send_im etc.) too. + */ + + /** 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. The hash table should be + * destroyed by the caller when it's no longer needed. + */ + GHashTable *(*get_account_text_table)(PurpleAccount *account); }; +#define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \ + (((G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < G_STRUCT_OFFSET(PurplePluginProtocolInfo, struct_size)) \ + || (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size)) && \ + prpl->member != NULL) + + #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \ ((plugin)->info->type == PURPLE_PLUGIN_PROTOCOL)
--- a/libpurple/server.c Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/server.c Mon May 12 02:19:06 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, GHashTable *data) +{ + purple_signal_emit(purple_conversations_get_handle(), "chat-join-failed", + gc, data); +} + void serv_got_chat_in(PurpleConnection *g, int id, const char *who, PurpleMessageFlags flags, const char *message, time_t mtime) {
--- a/libpurple/server.h Mon May 12 02:03:13 2008 +0000 +++ b/libpurple/server.h Mon May 12 02:19:06 2008 +0000 @@ -166,6 +166,17 @@ 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 data The components passed to serv_join_chat() originally. + * The hash function should be g_str_hash() and the equal + * function should be g_str_equal(). + */ +void purple_serv_got_join_chat_failed(PurpleConnection *gc, GHashTable *data); + 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);
--- a/pidgin/gtkaccount.c Mon May 12 02:03:13 2008 +0000 +++ b/pidgin/gtkaccount.c Mon May 12 02:19:06 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_destroy(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_destroy(table); + + return FALSE; +} + static void icon_filesel_choose_cb(const char *filename, gpointer data) { @@ -410,6 +455,25 @@ add_pref_box(dialog, vbox, _("_Username:"), dialog->screenname_entry); + if (dialog->account != NULL) + username = g_strdup(purple_account_get_username(dialog->account)); + + if (!username && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(dialog->prpl_info, get_account_text_table)) { + 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"); + + 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_destroy(table); + } + g_signal_connect(G_OBJECT(dialog->screenname_entry), "changed", G_CALLBACK(screenname_changed_cb), dialog); @@ -419,9 +483,6 @@ else user_splits = dialog->prpl_info->user_splits; - if (dialog->account != NULL) - username = g_strdup(purple_account_get_username(dialog->account)); - if (dialog->user_split_entries != NULL) { g_list_free(dialog->user_split_entries); dialog->user_split_entries = NULL; @@ -1513,6 +1574,8 @@ /* Show the window. */ gtk_widget_show(win); + if (!account) + gtk_widget_grab_focus(dialog->protocol_menu); } /**************************************************************************