Mercurial > pidgin
changeset 26941:e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 23 May 2009 17:42:34 +0000 |
parents | e40a30c883cc |
children | 7957a5ed53bb |
files | libpurple/protocols/jabber/jutil.c libpurple/protocols/jabber/jutil.h |
diffstat | 2 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jutil.c Sat May 23 07:08:00 2009 +0000 +++ b/libpurple/protocols/jabber/jutil.c Sat May 23 17:42:34 2009 +0000 @@ -223,6 +223,50 @@ return buf; } +gboolean +jabber_is_own_server(JabberStream *js, const char *str) +{ + JabberID *jid; + gboolean equal; + + if (str == NULL) + return FALSE; + + g_return_val_if_fail(*str != '\0', FALSE); + + jid = jabber_id_new(str); + if (!jid) + return FALSE; + + equal = (jid->node == NULL && + g_str_equal(jid->domain, js->user->domain) && + jid->resource == NULL); + jabber_id_free(jid); + return equal; +} + +gboolean +jabber_is_own_account(JabberStream *js, const char *str) +{ + JabberID *jid; + gboolean equal; + + if (str == NULL) + return TRUE; + + g_return_val_if_fail(*str != '\0', FALSE); + + jid = jabber_id_new(str); + if (!jid) + return FALSE; + + equal = (g_str_equal(jid->node, js->user->node) && + g_str_equal(jid->domain, js->user->domain) && + jid->resource == NULL); + jabber_id_free(jid); + return equal; +} + PurpleConversation * jabber_find_unnormalized_conv(const char *name, PurpleAccount *account) {
--- a/libpurple/protocols/jabber/jutil.h Sat May 23 07:08:00 2009 +0000 +++ b/libpurple/protocols/jabber/jutil.h Sat May 23 17:42:34 2009 +0000 @@ -36,6 +36,12 @@ const char *jabber_normalize(const PurpleAccount *account, const char *in); +/* Returns true if JID is the bare JID of our server. */ +gboolean jabber_is_own_server(JabberStream *js, const char *jid); + +/* Returns true if JID is the bare JID of our account. */ +gboolean jabber_is_own_account(JabberStream *js, const char *jid); + gboolean jabber_nodeprep_validate(const char *); gboolean jabber_nameprep_validate(const char *); gboolean jabber_resourceprep_validate(const char *);