# HG changeset patch # User Christian Hammond # Date 1052211298 0 # Node ID d5690ed7008513a43b6cc605c59649c8d848be65 # Parent b1c430fbf9d52068e52177ec8616e8239e74db3a [gaim-migrate @ 5688] Added experimental support for the text/x-clientinfo content-type being discussed on the forums at hypothetic.org. It may change, but for now, I just want to play with it, and I want us to be able to accept the messages. Ignore what it consists of right now. It'll change. committer: Tailor Script diff -r b1c430fbf9d5 -r d5690ed70085 src/protocols/msn/msn.h --- a/src/protocols/msn/msn.h Tue May 06 08:53:52 2003 +0000 +++ b/src/protocols/msn/msn.h Tue May 06 08:54:58 2003 +0000 @@ -71,4 +71,9 @@ #define MSN_FT_GUID "{5D3E02AB-6190-11d3-BBBB-00C04F795683}" +#define MSN_CLIENTINFO \ + "User-Agent: Gaim/" VERSION "\r\n" \ + "Buddy-Icons: 1\r\n" \ + "Logging: 1\r\n" + #endif /* _MSN_H_ */ diff -r b1c430fbf9d5 -r d5690ed70085 src/protocols/msn/switchboard.c --- a/src/protocols/msn/switchboard.c Tue May 06 08:53:52 2003 +0000 +++ b/src/protocols/msn/switchboard.c Tue May 06 08:54:58 2003 +0000 @@ -26,6 +26,32 @@ static GHashTable *switchboard_commands = NULL; static GHashTable *switchboard_msg_types = NULL; +/************************************************************************** + * Utility functions + **************************************************************************/ +static gboolean +__send_clientinfo(MsnSwitchBoard *swboard) +{ + MsnMessage *msg; + + msg = msn_message_new(); + msn_message_set_content_type(msg, "text/x-clientinfo"); + msn_message_set_charset(msg, NULL); + msn_message_set_attr(msg, "User-Agent", NULL); + msn_message_set_body(msg, MSN_CLIENTINFO); + + if (!msn_switchboard_send_msg(swboard, msg)) { + msn_switchboard_destroy(swboard); + + msn_message_destroy(msg); + + return FALSE; + } + + msn_message_destroy(msg); + + return TRUE; +} /************************************************************************** * Catch-all commands @@ -60,7 +86,7 @@ if (swboard->chat != NULL) gaim_chat_add_user(GAIM_CHAT(swboard->chat), gc->username, NULL); - return TRUE; + return __send_clientinfo(swboard); } static gboolean @@ -159,7 +185,7 @@ } } - return TRUE; + return __send_clientinfo(swboard); } static gboolean @@ -277,6 +303,20 @@ return TRUE; } +static gboolean +__clientinfo_msg(MsnServConn *servconn, const MsnMessage *msg) +{ + MsnSession *session = servconn->session; + MsnUser *user; + GHashTable *clientinfo; + + user = msn_user_new(session, servconn->msg_passport, NULL); + + clientinfo = msn_message_get_hashtable_from_body(msg); + + return TRUE; +} + /************************************************************************** * Connect stuff **************************************************************************/ @@ -364,6 +404,8 @@ msn_servconn_register_msg_type(servconn, "text/plain", __plain_msg); msn_servconn_register_msg_type(servconn, "text/x-msmsgscontrol", __control_msg); + msn_servconn_register_msg_type(servconn, "text/x-clientinfo", + __clientinfo_msg); /* Save these for future use. */ switchboard_commands = servconn->commands; diff -r b1c430fbf9d5 -r d5690ed70085 src/protocols/msn/user.c --- a/src/protocols/msn/user.c Tue May 06 08:53:52 2003 +0000 +++ b/src/protocols/msn/user.c Tue May 06 08:54:58 2003 +0000 @@ -69,6 +69,9 @@ if (user->session != NULL && user->session->users != NULL) msn_users_remove(user->session->users, user); + if (user->clientinfo != NULL) + g_hash_table_destroy(user->clientinfo); + if (user->passport != NULL) g_free(user->passport); @@ -161,6 +164,26 @@ return user->group_id; } +void +msn_user_set_client_info(MsnUser *user, GHashTable *info) +{ + g_return_if_fail(user != NULL); + g_return_if_fail(info != NULL); + + if (user->clientinfo != NULL) + g_hash_table_destroy(user->clientinfo); + + user->clientinfo = info; +} + +GHashTable * +msn_user_get_client_info(const MsnUser *user) +{ + g_return_val_if_fail(user != NULL, NULL); + + return user->clientinfo; +} + MsnUsers * msn_users_new(void) { diff -r b1c430fbf9d5 -r d5690ed70085 src/protocols/msn/user.h --- a/src/protocols/msn/user.h Tue May 06 08:53:52 2003 +0000 +++ b/src/protocols/msn/user.h Tue May 06 08:54:58 2003 +0000 @@ -32,14 +32,16 @@ */ struct _MsnUser { - MsnSession *session; /**< The MSN session. */ + MsnSession *session; /**< The MSN session. */ + + char *passport; /**< The passport account. */ + char *name; /**< The friendly name. */ - char *passport; /**< The passport account. */ - char *name; /**< The friendly name. */ + int group_id; /**< The group ID. */ - int group_id; /**< The group ID. */ + size_t ref_count; /**< The reference count. */ - size_t ref_count; /**< The reference count. */ + GHashTable *clientinfo; /**< The client information. */ }; /** @@ -141,6 +143,23 @@ int msn_user_get_group_id(const MsnUser *user); /** + * Sets the client information for a user. + * + * @param user The user. + * @param info The client information. + */ +void msn_user_set_client_info(MsnUser *user, GHashTable *info); + +/** + * Returns the client information for a user. + * + * @param user The user. + * + * @return The client information. + */ +GHashTable *msn_user_get_client_info(const MsnUser *user); + +/** * Creates a new MsnUsers structure. * * @return A new MsnUsers structure. @@ -170,7 +189,6 @@ */ void msn_users_remove(MsnUsers *users, MsnUser *user); - /** * Finds a user with the specified passport. *