Mercurial > pidgin.yaz
comparison libpurple/protocols/myspace/myspace.h @ 16747:496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
object-oriented approach that simplifies sending of messages.
Support for:
- Several field types used in the protocol (integer, string, binary).
- Transparently escape strings and base64 binary data as necessary.
- Multiple values per key are supported (unlike GHashTable), required for
WebChallenge message.
- Order is preserved (unlike GHashTable). Also required for WebChallenge.
Note that currently MsimMessage is only used for sending messages.
-
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Wed, 23 May 2007 04:18:05 +0000 |
parents | 52357f6392a4 |
children | da7621e799b7 |
comparison
equal
deleted
inserted
replaced
16746:52357f6392a4 | 16747:496855295bd7 |
---|---|
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 */ | 20 */ |
21 | 21 |
22 #ifndef _MYSPACE_MYSPACE_H | 22 #ifndef _MYSPACE_MYSPACE_H |
23 #define _MYSPACE_MYSPACE_H | 23 #define _MYSPACE_MYSPACE_H |
24 | |
25 /* Other includes */ | |
26 #include <string.h> | |
27 #include <errno.h> /* for EAGAIN */ | |
28 #include <stdarg.h> | |
29 | |
30 #include <glib.h> | |
31 | |
32 #ifdef _WIN32 | |
33 #include "win32dep.h" | |
34 #else | |
35 /* For recv() and send(); needed to match Win32 */ | |
36 #include <sys/types.h> | |
37 #include <sys/socket.h> | |
38 #endif | |
39 | |
40 #include "internal.h" | |
41 | |
42 #include "notify.h" | |
43 #include "plugin.h" | |
44 #include "accountopt.h" | |
45 #include "version.h" | |
46 #include "cipher.h" /* for SHA-1 */ | |
47 #include "util.h" /* for base64 */ | |
48 #include "debug.h" /* for purple_debug_info */ | |
49 | |
24 | 50 |
25 /* Conditional compilation options */ | 51 /* Conditional compilation options */ |
26 | 52 |
27 /* Debugging options */ | 53 /* Debugging options */ |
28 #define MSIM_DEBUG_MSG | 54 #define MSIM_DEBUG_MSG |
110 PurpleMessageFlags flags; | 136 PurpleMessageFlags flags; |
111 } send_im_cb_struct; | 137 } send_im_cb_struct; |
112 | 138 |
113 | 139 |
114 /* Functions */ | 140 /* Functions */ |
115 static void init_plugin(PurplePlugin *plugin); | 141 gboolean msim_load(PurplePlugin *plugin); |
116 static GList *msim_status_types(PurpleAccount *acct); | 142 GList *msim_status_types(PurpleAccount *acct); |
117 static const gchar *msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy); | 143 const gchar *msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy); |
118 | 144 |
119 /* TODO: move these three functions to message.c/h */ | 145 /* TODO: move these three functions to message.c/h */ |
120 static gchar *msim_unescape(const gchar *msg); | 146 gchar *msim_unescape(const gchar *msg); |
121 static gchar *msim_escape(const gchar *msg); | 147 gchar *msim_escape(const gchar *msg); |
122 static gchar *str_replace(const gchar* str, const gchar *old, const gchar *new); | 148 gchar *str_replace(const gchar* str, const gchar *old, const gchar *new); |
123 | 149 |
124 static GHashTable *msim_parse(gchar* msg); | 150 GHashTable *msim_parse(gchar* msg); |
125 static GHashTable* msim_parse_body(const gchar *body_str); | 151 GHashTable* msim_parse_body(const gchar *body_str); |
126 | 152 |
127 static void print_hash_item(gpointer key, gpointer value, gpointer user_data); | 153 void print_hash_item(gpointer key, gpointer value, gpointer user_data); |
128 static gboolean msim_send_raw(MsimSession *session, const gchar *msg); | 154 gboolean msim_send_raw(MsimSession *session, const gchar *msg); |
129 static gchar *msim_pack(GHashTable *table); | 155 gchar *msim_pack(GHashTable *table); |
130 static gboolean msim_sendh(MsimSession *session, GHashTable *table); | 156 gboolean msim_sendh(MsimSession *session, GHashTable *table); |
131 static gboolean msim_send(MsimSession *session, ...); | 157 gboolean msim_send(MsimSession *session, ...); |
132 | 158 |
133 static void msim_login(PurpleAccount *acct); | 159 void msim_login(PurpleAccount *acct); |
134 static int msim_login_challenge(MsimSession *session, GHashTable *table); | 160 int msim_login_challenge(MsimSession *session, GHashTable *table); |
135 static gchar* msim_compute_login_response(guchar nonce[2*NONCE_SIZE], | 161 gchar* msim_compute_login_response(guchar nonce[2*NONCE_SIZE], |
136 gchar* email, gchar* password); | 162 gchar* email, gchar* password, guint *response_len); |
137 | 163 |
138 static int msim_send_im(PurpleConnection *gc, const char *who, | 164 int msim_send_im(PurpleConnection *gc, const char *who, |
139 const char *message, PurpleMessageFlags flags); | 165 const char *message, PurpleMessageFlags flags); |
140 static int msim_send_im_by_userid(MsimSession *session, const gchar *userid, | 166 int msim_send_im_by_userid(MsimSession *session, const gchar *userid, |
141 const gchar *message, PurpleMessageFlags flags); | 167 const gchar *message, PurpleMessageFlags flags); |
142 static void msim_send_im_by_userid_cb(MsimSession *session, | 168 void msim_send_im_by_userid_cb(MsimSession *session, |
143 GHashTable *userinfo, gpointer data); | 169 GHashTable *userinfo, gpointer data); |
144 static void msim_incoming_im_cb(MsimSession *session, GHashTable *userinfo, | 170 void msim_incoming_im_cb(MsimSession *session, GHashTable *userinfo, |
145 gpointer data); | 171 gpointer data); |
146 static int msim_incoming_im(MsimSession *session, GHashTable *table); | 172 int msim_incoming_im(MsimSession *session, GHashTable *table); |
147 | 173 |
148 static int msim_process_reply(MsimSession *session, GHashTable *table); | 174 int msim_process_reply(MsimSession *session, GHashTable *table); |
149 static int msim_process(PurpleConnection *gc, GHashTable *table); | 175 int msim_process(PurpleConnection *gc, GHashTable *table); |
150 | 176 |
151 static int msim_error(MsimSession *session, GHashTable *table); | 177 int msim_error(MsimSession *session, GHashTable *table); |
152 static void msim_status_cb(MsimSession *session, GHashTable *userinfo, | 178 void msim_status_cb(MsimSession *session, GHashTable *userinfo, |
153 gpointer data); | 179 gpointer data); |
154 static int msim_status(MsimSession *session, GHashTable *table); | 180 int msim_status(MsimSession *session, GHashTable *table); |
155 static void msim_input_cb(gpointer gc_uncasted, gint source, | 181 void msim_input_cb(gpointer gc_uncasted, gint source, |
156 PurpleInputCondition cond); | 182 PurpleInputCondition cond); |
157 static void msim_connect_cb(gpointer data, gint source, | 183 void msim_connect_cb(gpointer data, gint source, |
158 const gchar *error_message); | 184 const gchar *error_message); |
159 | 185 |
160 static MsimSession *msim_session_new(PurpleAccount *acct); | 186 MsimSession *msim_session_new(PurpleAccount *acct); |
161 static void msim_session_destroy(MsimSession *session); | 187 void msim_session_destroy(MsimSession *session); |
162 | 188 |
163 static void msim_close(PurpleConnection *gc); | 189 void msim_close(PurpleConnection *gc); |
164 | 190 |
165 static inline gboolean msim_is_userid(const gchar *user); | 191 gboolean msim_is_userid(const gchar *user); |
166 static inline gboolean msim_is_email(const gchar *user); | 192 gboolean msim_is_email(const gchar *user); |
167 | 193 |
168 static void msim_lookup_user(MsimSession *session, const gchar *user, | 194 void msim_lookup_user(MsimSession *session, const gchar *user, |
169 MSIM_USER_LOOKUP_CB cb, gpointer data); | 195 MSIM_USER_LOOKUP_CB cb, gpointer data); |
170 | 196 |
171 static char *msim_status_text(PurpleBuddy *buddy); | 197 char *msim_status_text(PurpleBuddy *buddy); |
172 static void msim_tooltip_text(PurpleBuddy *buddy, | 198 void msim_tooltip_text(PurpleBuddy *buddy, |
173 PurpleNotifyUserInfo *user_info, gboolean full); | 199 PurpleNotifyUserInfo *user_info, gboolean full); |
200 | |
201 void init_plugin(PurplePlugin *plugin); | |
174 | 202 |
175 #ifndef MSIM_USE_PURPLE_RC4 | 203 #ifndef MSIM_USE_PURPLE_RC4 |
176 /* | 204 /* |
177 Unix SMB/CIFS implementation. | 205 Unix SMB/CIFS implementation. |
178 | 206 |