annotate libpurple/protocols/myspace/myspace.h @ 16732:435918bfed0f

Add field type codes.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sun, 20 May 2007 19:08:26 +0000
parents a2e9890a57e0
children 3f53f8f502b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16405
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
1 /* MySpaceIM Protocol Plugin, headr file
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
2 *
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
3 * \author Jeff Connelly
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
4 *
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
5 * Copyright (C) 2007, Jeff Connelly <jeff2@homing.pidgin.im>
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
6 *
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
10 * (at your option) any later version.
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
11 *
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
15 * GNU General Public License for more details.
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
16 *
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
20 */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
21
16725
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
22 /* Conditional compilation options */
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
23
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
24 /* Debugging options */
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
25 #define MSIM_DEBUG_MSG
16407
bb649c52fc19 Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16405
diff changeset
26 /* Low-level and rarely needed */
16725
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
27 /*#define MSIM_DEBUG_PARSE */
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
28 /*#define MSIM_DEBUG_LOGIN_CHALLENGE */
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
29 /*#define MSIM_DEBUG_RXBUF */
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
30
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
31 /* RC4 didn't make it into Libpurple 2.0.0's cipher suite, so we have
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
32 * to use our own RC4 code (from Samba) by not defining this. */
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
33 /*#define MSIM_USE_PURPLE_RC4 */
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
34
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
35 /* TODO: when RC4 makes it into libpurple, use the PURPLE_VERSION_CHECK
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
36 * macro to conditionally compile. And then later, get rid of our own
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
37 * RC4 code and only support libpurple with RC4. */
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
38
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
39 /* Constants */
16407
bb649c52fc19 Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16405
diff changeset
40
16732
435918bfed0f Add field type codes.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16730
diff changeset
41 /* Protocol field types */
435918bfed0f Add field type codes.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16730
diff changeset
42 #define MSIM_TYPE_INTEGER 0
435918bfed0f Add field type codes.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16730
diff changeset
43 #define MSIM_TYPE_STRING 1
435918bfed0f Add field type codes.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16730
diff changeset
44 #define MSIM_TYPE_BINARY 2
435918bfed0f Add field type codes.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16730
diff changeset
45 #define MSIM_TYPE_BOOLEAN 3
435918bfed0f Add field type codes.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16730
diff changeset
46 #define MSIM_TYPE_DICTIONARY 4
435918bfed0f Add field type codes.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16730
diff changeset
47 #define MSIM_TYPE_LIST 5
435918bfed0f Add field type codes.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16730
diff changeset
48
435918bfed0f Add field type codes.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16730
diff changeset
49
16405
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
50 /* Statuses */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
51 #define MSIM_STATUS_ONLINE "online"
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
52 #define MSIM_STATUS_AWAY "away"
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
53 #define MSIM_STATUS_OFFLINE "offline"
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
54 #define MSIM_STATUS_INVISIBLE "invisible"
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
55
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
56 /* Build version of MySpaceIM to report to servers (1.0.xxx.0) */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
57 #define MSIM_CLIENT_VERSION 673
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
58
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
59 /* Server */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
60 #define MSIM_SERVER "im.myspace.akadns.net"
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
61 //#define MSIM_SERVER "localhost"
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
62 #define MSIM_PORT 1863 /* TODO: alternate ports and automatic */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
63
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
64 /* Constants */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
65 #define HASH_SIZE 0x14 /**< Size of SHA-1 hash for login */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
66 #define NONCE_SIZE 0x20 /**< Half of decoded 'nc' field */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
67 #define MSIM_READ_BUF_SIZE 5*1024 /**< Receive buffer size */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
68 #define MSIM_FINAL_STRING "\\final\\" /**< Message end marker */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
69
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
70 /* Messages */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
71 #define MSIM_BM_INSTANT 1
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
72 #define MSIM_BM_STATUS 100
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
73 #define MSIM_BM_ACTION 121
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
74 /*#define MSIM_BM_UNKNOWN1 122*/
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
75
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
76 /* Random number in every MsimSession, to ensure it is valid. */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
77 #define MSIM_SESSION_STRUCT_MAGIC 0xe4a6752b
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
78
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
79 /* Everything needed to keep track of a session. */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
80 typedef struct _MsimSession
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
81 {
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
82 guint magic; /**< MSIM_SESSION_STRUCT_MAGIC */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
83 PurpleAccount *account;
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
84 PurpleConnection *gc;
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
85 gchar *sesskey; /**< Session key text string from server */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
86 gchar *userid; /**< This user's numeric user ID */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
87 gint fd; /**< File descriptor to/from server */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
88
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
89 GHashTable *user_lookup_cb; /**< Username -> userid lookup callback */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
90 GHashTable *user_lookup_cb_data; /**< Username -> userid lookup callback data */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
91 GHashTable *user_lookup_cache; /**< Cached information on users */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
92
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
93 gchar *rxbuf; /**< Receive buffer */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
94 guint rxoff; /**< Receive buffer offset */
16407
bb649c52fc19 Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16405
diff changeset
95 guint next_rid; /**< Next request/response ID */
16405
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
96 } MsimSession;
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
97
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
98 /* Check if an MsimSession is valid */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
99 #define MSIM_SESSION_VALID(s) (session != NULL && \
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
100 session->magic == MSIM_SESSION_STRUCT_MAGIC)
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
101
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
102 /* Callback function pointer type for when a user's information is received,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
103 * initiated from a user lookup. */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
104 typedef void (*MSIM_USER_LOOKUP_CB)(MsimSession *session, GHashTable *userinfo,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
105 gpointer data);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
106
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
107 /* Passed to MSIM_USER_LOOKUP_CB for msim_send_im_cb - called when
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
108 * user information is available, ready to send a message. */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
109 typedef struct _send_im_cb_struct
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
110 {
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
111 gchar *who;
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
112 gchar *message;
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
113 PurpleMessageFlags flags;
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
114 } send_im_cb_struct;
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
115
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
116
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
117 /* Functions */
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
118 static void init_plugin(PurplePlugin *plugin);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
119 static GList *msim_status_types(PurpleAccount *acct);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
120 static const gchar *msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
121
16409
1aa62f7368ca Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16407
diff changeset
122 static gchar *msim_unescape(const gchar *msg);
1aa62f7368ca Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16407
diff changeset
123 static gchar *msim_escape(const gchar *msg);
1aa62f7368ca Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16407
diff changeset
124 static gchar *str_replace(const gchar* str, const gchar *old, const gchar *new);
16730
a2e9890a57e0 Implement msim_pack(), msim_sendh(), msim_send().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16725
diff changeset
125 static GHashTable *msim_parse(gchar* msg);
a2e9890a57e0 Implement msim_pack(), msim_sendh(), msim_send().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16725
diff changeset
126 static GHashTable* msim_parse_body(const gchar *body_str);
16405
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
127
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
128 static void print_hash_item(gpointer key, gpointer value, gpointer user_data);
16723
3b5037a93807 Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16409
diff changeset
129 static gboolean msim_send_raw(MsimSession *session, const gchar *msg);
16730
a2e9890a57e0 Implement msim_pack(), msim_sendh(), msim_send().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16725
diff changeset
130 static gchar *msim_pack(GHashTable *table);
a2e9890a57e0 Implement msim_pack(), msim_sendh(), msim_send().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16725
diff changeset
131 static gboolean msim_sendh(MsimSession *session, GHashTable *table);
16723
3b5037a93807 Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16409
diff changeset
132 static gboolean msim_send(MsimSession *session, ...);
16405
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
133
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
134 static void msim_login(PurpleAccount *acct);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
135 static int msim_login_challenge(MsimSession *session, GHashTable *table);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
136 static gchar* msim_compute_login_response(guchar nonce[2*NONCE_SIZE],
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
137 gchar* email, gchar* password);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
138
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
139 static int msim_send_im(PurpleConnection *gc, const char *who,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
140 const char *message, PurpleMessageFlags flags);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
141 static int msim_send_im_by_userid(MsimSession *session, const gchar *userid,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
142 const gchar *message, PurpleMessageFlags flags);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
143 static void msim_send_im_by_userid_cb(MsimSession *session,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
144 GHashTable *userinfo, gpointer data);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
145 static void msim_incoming_im_cb(MsimSession *session, GHashTable *userinfo,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
146 gpointer data);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
147 static int msim_incoming_im(MsimSession *session, GHashTable *table);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
148
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
149 static int msim_process_reply(MsimSession *session, GHashTable *table);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
150 static int msim_process(PurpleConnection *gc, GHashTable *table);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
151
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
152 static int msim_error(MsimSession *session, GHashTable *table);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
153 static void msim_status_cb(MsimSession *session, GHashTable *userinfo,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
154 gpointer data);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
155 static int msim_status(MsimSession *session, GHashTable *table);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
156 static void msim_input_cb(gpointer gc_uncasted, gint source,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
157 PurpleInputCondition cond);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
158 static void msim_connect_cb(gpointer data, gint source,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
159 const gchar *error_message);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
160
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
161 static MsimSession *msim_session_new(PurpleAccount *acct);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
162 static void msim_session_destroy(MsimSession *session);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
163
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
164 static void msim_close(PurpleConnection *gc);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
165
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
166 static inline gboolean msim_is_userid(const gchar *user);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
167 static inline gboolean msim_is_email(const gchar *user);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
168
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
169 static void msim_lookup_user(MsimSession *session, const gchar *user,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
170 MSIM_USER_LOOKUP_CB cb, gpointer data);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
171
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
172 static char *msim_status_text(PurpleBuddy *buddy);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
173 static void msim_tooltip_text(PurpleBuddy *buddy,
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
174 PurpleNotifyUserInfo *user_info, gboolean full);
8063f163f411 Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff changeset
175
16725
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
176 #ifndef MSIM_USE_PURPLE_RC4
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
177 /*
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
178 Unix SMB/CIFS implementation.
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
179
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
180 a partial implementation of RC4 designed for use in the
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
181 SMB authentication protocol
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
182
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
183 Copyright (C) Andrew Tridgell 1998
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
184
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
185 $Id: crypt-rc4.h 12116 2004-09-27 23:29:22Z guy $
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
186
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
187 This program is free software; you can redistribute it and/or modify
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
188 it under the terms of the GNU General Public License as published by
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
189 the Free Software Foundation; either version 2 of the License, or
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
190 (at your option) any later version.
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
191
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
192 This program is distributed in the hope that it will be useful,
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
193 but WITHOUT ANY WARRANTY; without even the implied warranty of
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
194 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
195 GNU General Public License for more details.
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
196
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
197 You should have received a copy of the GNU General Public License
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
198 along with this program; if not, write to the Free Software
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
199 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
200 */
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
201
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
202 typedef struct _rc4_state_struct {
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
203 unsigned char s_box[256];
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
204 unsigned char index_i;
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
205 unsigned char index_j;
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
206 } rc4_state_struct;
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
207
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
208 void crypt_rc4_init(rc4_state_struct *rc4_state,
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
209 const unsigned char *key, int key_len);
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
210
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
211 void crypt_rc4(rc4_state_struct *rc4_state, unsigned char *data, int data_len);
58cd11fcd84f Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 16723
diff changeset
212 #endif /* !MSIM_USE_PURPLE_RC4 */