pidgin: 08ae293b: Parse the invite message out of the pend...
qulogic at pidgin.im
qulogic at pidgin.im
Mon May 18 23:50:38 EDT 2009
-----------------------------------------------------------------
Revision: 08ae293b4c7796039d18538c66438b2da7954f4c
Ancestor: a1463341c3bf211c429282870babdb4785c7d817
Author: qulogic at pidgin.im
Date: 2009-05-19T03:16:45
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/08ae293b4c7796039d18538c66438b2da7954f4c
Modified files:
libpurple/protocols/msn/contact.c
libpurple/protocols/msn/user.c
libpurple/protocols/msn/user.h
libpurple/protocols/msn/userlist.c
ChangeLog:
Parse the invite message out of the pending membership list so that it can
be presented to the user when someone adds us to their buddy list.
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/contact.c 2f54e60a3a8b313a746b6e96a9c42ccdc27ff6fb
+++ libpurple/protocols/msn/contact.c 54e6b6b3ca50b0144b741d3a98bc238e88860071
@@ -357,29 +357,36 @@ msn_parse_each_member(MsnSession *sessio
MsnUser *user = msn_userlist_find_add_user(session->userlist, passport, NULL);
xmlnode *annotation;
guint nid = MSN_NETWORK_UNKNOWN;
+ char *invite = NULL;
- /* For EmailMembers, the network must be found in the annotations. */
- if (!strcmp(node, "PassportName")) {
- nid = MSN_NETWORK_PASSPORT;
- } else {
- for (annotation = xmlnode_get_child(member, "Annotations/Annotation");
- annotation;
- annotation = xmlnode_get_next_twin(annotation)) {
- char *name = xmlnode_get_data(xmlnode_get_child(annotation, "Name"));
- if (name && !strcmp(name, "MSN.IM.BuddyType")) {
- char *value = xmlnode_get_data(xmlnode_get_child(annotation, "Value"));
- if (value != NULL)
- nid = strtoul(value, NULL, 10);
- g_free(value);
+ for (annotation = xmlnode_get_child(member, "Annotations/Annotation");
+ annotation;
+ annotation = xmlnode_get_next_twin(annotation)) {
+ char *name = xmlnode_get_data(xmlnode_get_child(annotation, "Name"));
+ char *value = xmlnode_get_data(xmlnode_get_child(annotation, "Value"));
+ if (name && value) {
+ if (!strcmp(name, "MSN.IM.BuddyType")) {
+ nid = strtoul(value, NULL, 10);
}
- g_free(name);
+ else if (!strcmp(name, "MSN.IM.InviteMessage")) {
+ invite = value;
+ value = NULL;
+ }
}
+ g_free(name);
+ g_free(value);
}
+ /* For EmailMembers, the network must be found in the annotations, above.
+ Otherwise, PassportMembers are on the Passport network. */
+ if (!strcmp(node, "PassportName"))
+ nid = MSN_NETWORK_PASSPORT;
+
purple_debug_info("msn", "CL: %s name: %s, Type: %s, MembershipID: %s, NetworkID: %u\n",
node, passport, type, member_id == NULL ? "(null)" : member_id, nid);
msn_user_set_network(user, nid);
+ msn_user_set_invite_message(user, invite);
if (member_id) {
user->membership_id[list] = atoi(member_id);
@@ -390,6 +397,7 @@ msn_parse_each_member(MsnSession *sessio
g_free(passport);
g_free(type);
g_free(member_id);
+ g_free(invite);
}
static void
============================================================
--- libpurple/protocols/msn/user.c 92fd4f15df1e4a62e375c1b8f0ded35a75ece6ba
+++ libpurple/protocols/msn/user.c 53a3cb07cd6b852d9ffe81f8c46202d94e289c33
@@ -74,6 +74,7 @@ msn_user_destroy(MsnUser *user)
g_free(user->media.title);
g_free(user->media.album);
g_free(user->statusline);
+ g_free(user->invite_message);
g_free(user);
}
@@ -426,6 +427,15 @@ msn_user_set_client_caps(MsnUser *user,
user->clientcaps = info;
}
+void
+msn_user_set_invite_message(MsnUser *user, const char *message)
+{
+ g_return_if_fail(user != NULL);
+
+ g_free(user->invite_message);
+ user->invite_message = g_strdup(message);
+}
+
const char *
msn_user_get_passport(const MsnUser *user)
{
@@ -489,3 +499,12 @@ msn_user_get_client_caps(const MsnUser *
return user->clientcaps;
}
+
+const char *
+msn_user_get_invite_message(const MsnUser *user)
+{
+ g_return_val_if_fail(user != NULL, NULL);
+
+ return user->invite_message;
+}
+
============================================================
--- libpurple/protocols/msn/user.h 3d3e068b16c3857051c17873cfdd1a0e117ff88a
+++ libpurple/protocols/msn/user.h 9eeb35d1e130ada46705650bb6f4199d6f68ae17
@@ -105,6 +105,8 @@ struct _MsnUser
guint membership_id[5]; /**< The membershipId sent by the contacts server,
indexed by the list it belongs to */
+
+ char *invite_message; /**< Invite message of user request */
};
/**************************************************************************
@@ -290,7 +292,15 @@ void msn_user_set_client_caps(MsnUser *u
*/
void msn_user_set_client_caps(MsnUser *user, GHashTable *info);
+/**
+ * Sets the invite message for a user.
+ *
+ * @param user The user.
+ * @param message The invite message for a user.
+ */
+void msn_user_set_invite_message(MsnUser *user, const char *message);
+
/**
* Returns the passport account for a user.
*
@@ -373,6 +383,15 @@ GHashTable *msn_user_get_client_caps(con
GHashTable *msn_user_get_client_caps(const MsnUser *user);
/**
+ * Returns the invite message for a user.
+ *
+ * @param user The user.
+ *
+ * @return The user's invite message.
+ */
+const char *msn_user_get_invite_message(const MsnUser *user);
+
+/**
* check to see if user is online
*/
gboolean
============================================================
--- libpurple/protocols/msn/userlist.c 8ccf29acbe436fef36baf7025ff7139917b20c00
+++ libpurple/protocols/msn/userlist.c 64735bb8ff3632b106efab69f637b9977484ec8c
@@ -86,7 +86,7 @@ static void
}
static void
-got_new_entry(PurpleConnection *gc, const char *passport, const char *friendly)
+got_new_entry(PurpleConnection *gc, const char *passport, const char *friendly, const char *message)
{
PurpleAccount *acct;
MsnPermitAdd *pa;
@@ -97,7 +97,7 @@ got_new_entry(PurpleConnection *gc, cons
pa->gc = gc;
acct = purple_connection_get_account(gc);
- purple_account_request_authorization(acct, passport, NULL, friendly, NULL,
+ purple_account_request_authorization(acct, passport, NULL, friendly, message,
purple_find_buddy(acct, passport) != NULL,
msn_accept_add_cb, msn_cancel_add_cb, pa);
@@ -150,12 +150,14 @@ msn_got_lst_user(MsnSession *session, Ms
PurpleAccount *account;
const char *passport;
const char *store;
+ const char *message;
account = session->account;
gc = purple_account_get_connection(account);
passport = msn_user_get_passport(user);
store = msn_user_get_friendly_name(user);
+ message = msn_user_get_invite_message(user);
msn_user_set_op(user, list_op);
@@ -199,13 +201,13 @@ msn_got_lst_user(MsnSession *session, Ms
if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP)))
{
-/* got_new_entry(gc, passport, store); */
+/* got_new_entry(gc, passport, store, NULL); */
}
}
if (list_op & MSN_LIST_PL_OP)
{
- got_new_entry(gc, passport, store);
+ got_new_entry(gc, passport, store, message);
}
}
More information about the Commits
mailing list