Mercurial > pidgin.yaz
annotate libpurple/protocols/myspace/message.h @ 17967:c9acdf96e74e
Update login process to more closely match official client.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sun, 22 Jul 2007 06:53:48 +0000 |
parents | 6d1d86ab6a59 |
children | a2298513db8b |
rev | line source |
---|---|
17321
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
1 /** MySpaceIM protocol messages |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
2 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
3 * \author Jeff Connelly |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
4 * |
17923
d87916bd1d73
Fix email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17383
diff
changeset
|
5 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
17321
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
6 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
7 * This program is free software; you can redistribute it and/or modify |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
8 * it under the terms of the GNU General Public License as published by |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
9 * the Free Software Foundation; either version 2 of the License, or |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
10 * (at your option) any later version. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
11 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
15 * GNU General Public License for more details. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
16 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
18 * along with this program; if not, write to the Free Software |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
20 */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
21 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
22 #ifndef _MYSPACE_MESSAGE_H |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
23 #define _MYSPACE_MESSAGE_H |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
24 |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17321
diff
changeset
|
25 #include <glib.h> |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17321
diff
changeset
|
26 |
17321
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
27 /* Types */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
28 #define MsimMessage GList /* #define instead of typedef to avoid casting */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
29 typedef struct _MsimMessageElement |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
30 { |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17359
diff
changeset
|
31 const gchar *name; /**< Textual name of element. */ |
17321
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
32 guint type; /**< MSIM_TYPE_* code. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
33 gpointer data; /**< Pointer to data, or GUINT_TO_POINTER for int/bool. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
34 } MsimMessageElement; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
35 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
36 typedef gchar MsimMessageType; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
37 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
38 /* Protocol field types */ |
17341
37499e926a42
Add new MsimMessage element type, MSIM_TYPE_RAW, for fields in incoming
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17338
diff
changeset
|
39 #define MSIM_TYPE_RAW '-' |
17321
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
40 #define MSIM_TYPE_INTEGER 'i' |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
41 #define MSIM_TYPE_STRING 's' |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
42 #define MSIM_TYPE_BINARY 'b' |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
43 #define MSIM_TYPE_BOOLEAN 'f' |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
44 #define MSIM_TYPE_DICTIONARY 'd' |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
45 #define MSIM_TYPE_LIST 'l' |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
46 |
17359
d69bcd74c240
Enhance msim_msg_new() to accept a variadic arguments, like msim_send(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17358
diff
changeset
|
47 MsimMessage *msim_msg_new(gboolean not_empty, ...); |
d69bcd74c240
Enhance msim_msg_new() to accept a variadic arguments, like msim_send(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17358
diff
changeset
|
48 /* No sentinel attribute, because can leave off varargs if not_empty is FALSE. */ |
d69bcd74c240
Enhance msim_msg_new() to accept a variadic arguments, like msim_send(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17358
diff
changeset
|
49 |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17341
diff
changeset
|
50 MsimMessage *msim_msg_clone(MsimMessage *old); |
17321
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
51 void msim_msg_free(MsimMessage *msg); |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17359
diff
changeset
|
52 MsimMessage *msim_msg_append(MsimMessage *msg, const gchar *name, MsimMessageType type, gpointer data); |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17359
diff
changeset
|
53 MsimMessage *msim_msg_insert_before(MsimMessage *msg, const gchar *name_before, const gchar *name, MsimMessageType type, gpointer data); |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17359
diff
changeset
|
54 void msim_msg_dump(const char *fmt_string, MsimMessage *msg); |
17321
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
55 gchar *msim_msg_pack(MsimMessage *msg); |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17321
diff
changeset
|
56 |
17964
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
57 GList *msim_msg_list_copy(GList *old); |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
58 void msim_msg_list_free(GList *l); |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
59 GList *msim_msg_list_parse(const gchar *raw); |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
60 |
17326
57bde8784308
(Plugin loads, but cannot do anything useful)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
61 /* Defined in myspace.h */ |
57bde8784308
(Plugin loads, but cannot do anything useful)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
62 struct _MsimSession; |
57bde8784308
(Plugin loads, but cannot do anything useful)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
63 |
17964
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
64 /* Based on http://permalink.gmane.org/gmane.comp.parsers.sparse/695 |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
65 * Define macros for useful gcc attributes. */ |
17352
86b4862b7a02
Add GCC sentinal attribute to msim_send().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
66 #ifdef __GNUC__ |
17964
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
67 #define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
68 #define FORMAT_ATTR(pos) __attribute__ ((__format__ (__printf__, pos, pos+1))) |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
69 #define NORETURN_ATTR __attribute__ ((__noreturn__)) |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
70 /* __sentinel__ attribute was introduced in gcc 3.5 */ |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
71 #if (GCC_VERSION >= 3005) |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
72 #define SENTINEL_ATTR __attribute__ ((__sentinel__(0))) |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
73 #else |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
74 #define SENTINEL_ATTR |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
75 #endif /* gcc >= 3.5 */ |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
76 #else |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
77 #define FORMAT_ATTR(pos) |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
78 #define NORETURN_ATTR |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
79 #define SENTINEL_ATTR |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
80 #endif |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
81 |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
82 /* Cause gcc to emit "a missing sentinel in function call" if forgot |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
83 * to write NULL as last, terminating parameter. */ |
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
84 gboolean msim_send(struct _MsimSession *session, ...) SENTINEL_ATTR; |
17352
86b4862b7a02
Add GCC sentinal attribute to msim_send().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
85 |
17326
57bde8784308
(Plugin loads, but cannot do anything useful)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
86 gboolean msim_msg_send(struct _MsimSession *session, MsimMessage *msg); |
17321
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
87 |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17321
diff
changeset
|
88 MsimMessage *msim_parse(gchar *raw); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17321
diff
changeset
|
89 GHashTable *msim_parse_body(const gchar *body_str); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17321
diff
changeset
|
90 |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17359
diff
changeset
|
91 MsimMessageElement *msim_msg_get(MsimMessage *msg, const gchar *name); |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17359
diff
changeset
|
92 gchar *msim_msg_get_string(MsimMessage *msg, const gchar *name); |
17964
6d1d86ab6a59
In MsimMessage, add support for MSIM_TYPE_LIST - pipe-separated lists.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17923
diff
changeset
|
93 GList *msim_msg_get_list(MsimMessage *msg, const gchar *name); |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17359
diff
changeset
|
94 guint msim_msg_get_integer(MsimMessage *msg, const gchar *name); |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17359
diff
changeset
|
95 gboolean msim_msg_get_binary(MsimMessage *msg, const gchar *name, gchar **binary_data, gsize *binary_length); |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17321
diff
changeset
|
96 |
17321
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
97 #endif /* _MYSPACE_MESSAGE_H */ |