pidgin: f1f69617: Add support for XMPP URIs on Windows. Cl...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Sat Aug 8 20:25:51 EDT 2009
-----------------------------------------------------------------
Revision: f1f696174da801e709c7ee17dd9a6423b54dba3f
Ancestor: edd569c9522df52af33d6132a9d4955bd842f9bb
Author: darkrain42 at pidgin.im
Date: 2009-08-09T00:15:14
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/f1f696174da801e709c7ee17dd9a6423b54dba3f
Modified files:
ChangeLog.win32 libpurple/protocols/jabber/libxmpp.c
libpurple/util.c pidgin/win32/nsis/pidgin-installer.nsi
ChangeLog:
Add support for XMPP URIs on Windows. Closes #2326.
-------------- next part --------------
============================================================
--- ChangeLog.win32 fedc45be91a07838713706360ba3f355e2dc0049
+++ ChangeLog.win32 4e6d3598412197feb7b068578744bd154b677d9e
@@ -1,4 +1,5 @@ version 2.6.0 (??/??/2009):
version 2.6.0 (??/??/2009):
+ * Added XMPP URI support.
version 2.5.8 (06/27/2009):
* No changes
============================================================
--- libpurple/protocols/jabber/libxmpp.c 54af098c2be2089acb3145ed4e1bda05a903e19d
+++ libpurple/protocols/jabber/libxmpp.c ceb592bbac49dc7fdf128f9bbf4bc27a4b6971f4
@@ -28,6 +28,7 @@
#include "internal.h"
#include "accountopt.h"
+#include "core.h"
#include "debug.h"
#include "version.h"
@@ -47,6 +48,8 @@
#include "data.h"
#include "ibb.h"
+static PurplePlugin *my_protocol = NULL;
+
static PurplePluginProtocolInfo prpl_info =
{
OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_MAIL_CHECK |
@@ -266,6 +269,70 @@ static PurplePluginInfo info =
NULL
};
+static PurpleAccount *find_acct(const char *prpl, const char *acct_id)
+{
+ PurpleAccount *acct = NULL;
+
+ /* If we have a specific acct, use it */
+ if (acct_id) {
+ acct = purple_accounts_find(acct_id, prpl);
+ if (acct && !purple_account_is_connected(acct))
+ acct = NULL;
+ } else { /* Otherwise find an active account for the protocol */
+ GList *l = purple_accounts_get_all();
+ while (l) {
+ if (!strcmp(prpl, purple_account_get_protocol_id(l->data))
+ && purple_account_is_connected(l->data)) {
+ acct = l->data;
+ break;
+ }
+ l = l->next;
+ }
+ }
+
+ return acct;
+}
+
+static gboolean xmpp_uri_handler(const char *proto, const char *user, GHashTable *params)
+{
+ char *acct_id = g_hash_table_lookup(params, "account");
+ PurpleAccount *acct;
+
+ if (g_ascii_strcasecmp(proto, "xmpp"))
+ return FALSE;
+
+ acct = find_acct(purple_plugin_get_id(my_protocol), acct_id);
+
+ if (!acct)
+ return FALSE;
+
+ /* xmpp:romeo at montague.net?message;subject=Test%20Message;body=Here%27s%20a%20test%20message */
+ if (g_hash_table_lookup_extended(params, "message", NULL, NULL)) {
+ char *body = g_hash_table_lookup(params, "body");
+ if (user && *user) {
+ PurpleConversation *conv =
+ purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, user);
+ purple_conversation_present(conv);
+ if (body && *body)
+ purple_conv_send_confirm(conv, body);
+ }
+ } else if (g_hash_table_lookup_extended(params, "roster", NULL, NULL)) {
+ char *name = g_hash_table_lookup(params, "name");
+ if (user && *user)
+ purple_blist_request_add_buddy(acct, user, NULL, name);
+ } else if (g_hash_table_lookup_extended(params, "join", NULL, NULL)) {
+ PurpleConnection *gc = purple_account_get_connection(acct);
+ if (user && *user) {
+ GHashTable *params = jabber_chat_info_defaults(gc, user);
+ jabber_chat_join(gc, params);
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
static void
init_plugin(PurplePlugin *plugin)
{
@@ -331,6 +398,7 @@ init_plugin(PurplePlugin *plugin)
prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
option);
+ my_protocol = plugin;
jabber_init_plugin(plugin);
purple_prefs_remove("/plugins/prpl/jabber");
@@ -366,6 +434,9 @@ init_plugin(PurplePlugin *plugin)
jabber_ibb_init();
jabber_si_init();
+
+ purple_signal_connect(purple_get_core(), "uri-handler", plugin,
+ PURPLE_CALLBACK(xmpp_uri_handler), NULL);
}
============================================================
--- libpurple/util.c 785d467dcac110839da5a11c1017f56b10e7144b
+++ libpurple/util.c a42b048d94b6975d4b6b5e84903f901021a99644
@@ -3519,6 +3519,7 @@ void purple_got_protocol_handler_uri(con
void purple_got_protocol_handler_uri(const char *uri)
{
char proto[11];
+ char delimiter;
const char *tmp, *param_string;
char *cmd;
GHashTable *params = NULL;
@@ -3534,8 +3535,14 @@ void purple_got_protocol_handler_uri(con
proto[len] = '\0';
tmp++;
- purple_debug_info("util", "Processing message '%s' for protocol '%s'.\n", tmp, proto);
+ if (g_str_equal(proto, "xmpp"))
+ delimiter = ';';
+ else
+ delimiter = '&';
+
+ purple_debug_info("util", "Processing message '%s' for protocol '%s' using delimiter '%c'.\n", tmp, proto, delimiter);
+
if ((param_string = strchr(tmp, '?'))) {
const char *keyend = NULL, *pairstart;
char *key, *value = NULL;
@@ -3547,7 +3554,7 @@ void purple_got_protocol_handler_uri(con
pairstart = tmp = param_string;
while (*tmp || *pairstart) {
- if (*tmp == '&' || !(*tmp)) {
+ if (*tmp == delimiter || !(*tmp)) {
/* If there is no explicit value */
if (keyend == NULL)
keyend = tmp;
============================================================
--- pidgin/win32/nsis/pidgin-installer.nsi 6f18513383c265a3a80bea3341e329826a4ab1a2
+++ pidgin/win32/nsis/pidgin-installer.nsi 0e3dfb77c656cd2d40e5de3ac6490bba85a2cf5e
@@ -567,6 +567,7 @@ SectionGroup /e $(URI_HANDLERS_SECTION_T
!insertmacro URI_SECTION "msnim"
!insertmacro URI_SECTION "myim"
!insertmacro URI_SECTION "ymsgr"
+ !insertmacro URI_SECTION "xmpp"
SectionGroupEnd
;--------------------------------
@@ -708,6 +709,8 @@ Section Uninstall
Call un.UnregisterURIHandler
Push "ymsgr"
Call un.UnregisterURIHandler
+ Push "xmpp"
+ Call un.UnregisterURIHandler
Delete "$INSTDIR\ca-certs\America_Online_Root_Certification_Authority_1.pem"
Delete "$INSTDIR\ca-certs\AOL_Member_CA.pem"
More information about the Commits
mailing list