comparison libpurple/protocols/myspace/myspace.h @ 17323:793301c04e3a

(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Thu, 31 May 2007 06:09:46 +0000
parents 0fa4a3e9b318
children 57bde8784308
comparison
equal deleted inserted replaced
17322:253155592cd5 17323:793301c04e3a
46 #include "cipher.h" /* for SHA-1 */ 46 #include "cipher.h" /* for SHA-1 */
47 #include "util.h" /* for base64 */ 47 #include "util.h" /* for base64 */
48 #include "debug.h" /* for purple_debug_info */ 48 #include "debug.h" /* for purple_debug_info */
49 49
50 50
51 /* MySpaceIM includes */
52 #include "session.h"
53 #include "message.h"
54
51 /* Conditional compilation options */ 55 /* Conditional compilation options */
52 56
53 /* Debugging options */ 57 /* Debugging options */
54 #define MSIM_DEBUG_MSG 58 #define MSIM_DEBUG_MSG
55 /* Low-level and rarely needed */ 59 /* Low-level and rarely needed */
66 * macro to conditionally compile. And then later, get rid of our own 70 * macro to conditionally compile. And then later, get rid of our own
67 * RC4 code and only support libpurple with RC4. */ 71 * RC4 code and only support libpurple with RC4. */
68 72
69 /* Constants */ 73 /* Constants */
70 74
71 /* Statuses */
72 #define MSIM_STATUS_ONLINE "online"
73 #define MSIM_STATUS_AWAY "away"
74 #define MSIM_STATUS_OFFLINE "offline"
75 #define MSIM_STATUS_INVISIBLE "invisible"
76
77 /* Build version of MySpaceIM to report to servers (1.0.xxx.0) */ 75 /* Build version of MySpaceIM to report to servers (1.0.xxx.0) */
78 #define MSIM_CLIENT_VERSION 673 76 #define MSIM_CLIENT_VERSION 673
79 77
80 /* Server */ 78 /* Server */
81 #define MSIM_SERVER "im.myspace.akadns.net" 79 #define MSIM_SERVER "im.myspace.akadns.net"
94 #define MSIM_BM_ACTION 121 92 #define MSIM_BM_ACTION 121
95 /* #define MSIM_BM_UNKNOWN1 122 */ 93 /* #define MSIM_BM_UNKNOWN1 122 */
96 94
97 /* Authentication algorithm for login2 */ 95 /* Authentication algorithm for login2 */
98 #define MSIM_AUTH_ALGORITHM 196610 96 #define MSIM_AUTH_ALGORITHM 196610
99
100 /* Random number in every MsimSession, to ensure it is valid. */
101 #define MSIM_SESSION_STRUCT_MAGIC 0xe4a6752b
102
103 /* Everything needed to keep track of a session. */
104 typedef struct _MsimSession
105 {
106 guint magic; /**< MSIM_SESSION_STRUCT_MAGIC */
107 PurpleAccount *account;
108 PurpleConnection *gc;
109 gchar *sesskey; /**< Session key text string from server */
110 gchar *userid; /**< This user's numeric user ID */
111 gint fd; /**< File descriptor to/from server */
112
113 GHashTable *user_lookup_cb; /**< Username -> userid lookup callback */
114 GHashTable *user_lookup_cb_data; /**< Username -> userid lookup callback data */
115 GHashTable *user_lookup_cache; /**< Cached information on users */
116
117 gchar *rxbuf; /**< Receive buffer */
118 guint rxoff; /**< Receive buffer offset */
119 guint next_rid; /**< Next request/response ID */
120 } MsimSession;
121
122 /* Check if an MsimSession is valid */
123 #define MSIM_SESSION_VALID(s) (session != NULL && \
124 session->magic == MSIM_SESSION_STRUCT_MAGIC)
125 97
126 /* Callback function pointer type for when a user's information is received, 98 /* Callback function pointer type for when a user's information is received,
127 * initiated from a user lookup. */ 99 * initiated from a user lookup. */
128 typedef void (*MSIM_USER_LOOKUP_CB)(MsimSession *session, GHashTable *userinfo, 100 typedef void (*MSIM_USER_LOOKUP_CB)(MsimSession *session, GHashTable *userinfo,
129 gpointer data); 101 gpointer data);
145 117
146 /* TODO: move these three functions to message.c/h */ 118 /* TODO: move these three functions to message.c/h */
147 gchar *msim_unescape(const gchar *msg); 119 gchar *msim_unescape(const gchar *msg);
148 gchar *msim_escape(const gchar *msg); 120 gchar *msim_escape(const gchar *msg);
149 gchar *str_replace(const gchar *str, const gchar *old, const gchar *new); 121 gchar *str_replace(const gchar *str, const gchar *old, const gchar *new);
150
151 GHashTable *msim_parse(gchar *msg);
152 GHashTable *msim_parse_body(const gchar *body_str);
153 122
154 void print_hash_item(gpointer key, gpointer value, gpointer user_data); 123 void print_hash_item(gpointer key, gpointer value, gpointer user_data);
155 gboolean msim_send_raw(MsimSession *session, const gchar *msg); 124 gboolean msim_send_raw(MsimSession *session, const gchar *msg);
156 gchar *msim_pack(GHashTable *table); 125 gchar *msim_pack(GHashTable *table);
157 gboolean msim_sendh(MsimSession *session, GHashTable *table); 126 gboolean msim_sendh(MsimSession *session, GHashTable *table);
171 void msim_incoming_im_cb(MsimSession *session, GHashTable *userinfo, 140 void msim_incoming_im_cb(MsimSession *session, GHashTable *userinfo,
172 gpointer data); 141 gpointer data);
173 int msim_incoming_im(MsimSession *session, GHashTable *table); 142 int msim_incoming_im(MsimSession *session, GHashTable *table);
174 143
175 int msim_process_reply(MsimSession *session, GHashTable *table); 144 int msim_process_reply(MsimSession *session, GHashTable *table);
176 int msim_process(PurpleConnection *gc, GHashTable *table); 145 int msim_process(PurpleConnection *gc, MsimMessage *msg);
177 146
178 int msim_error(MsimSession *session, GHashTable *table); 147 int msim_error(MsimSession *session, GHashTable *table);
179 void msim_status_cb(MsimSession *session, GHashTable *userinfo, 148 void msim_status_cb(MsimSession *session, GHashTable *userinfo,
180 gpointer data); 149 gpointer data);
181 int msim_status(MsimSession *session, GHashTable *table); 150 int msim_status(MsimSession *session, GHashTable *table);