Mercurial > pidgin
annotate libpurple/protocols/myspace/message.c @ 17264:ddcf9ef2ccec
Add MsimMessage implementation (sending only).
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Thu, 31 May 2007 02:29:50 +0000 |
parents | |
children | 793301c04e3a |
rev | line source |
---|---|
17264
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 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
5 * Copyright (C) 2007, Jeff Connelly <jeff2@homing.pidgin.im> |
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 #include "myspace.h" |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
23 #include "message.h" |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
24 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
25 static void msim_msg_free_element(gpointer data, gpointer user_data); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
26 static void msim_msg_debug_string_element(gpointer data, gpointer user_data); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
27 static gchar *msim_msg_pack_using(MsimMessage *msg, GFunc gf, gchar *sep, gchar *begin, gchar *end); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
28 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
29 MsimMessage *msim_msg_new(void) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
30 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
31 /* Just an empty list. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
32 return NULL; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
33 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
34 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
35 /** Free an individual message element. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
36 static void msim_msg_free_element(gpointer data, gpointer user_data) |
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 MsimMessageElement *elem; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
39 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
40 elem = (MsimMessageElement *)data; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
41 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
42 switch (elem->type) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
43 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
44 case MSIM_TYPE_BOOLEAN: /* Fall through */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
45 case MSIM_TYPE_INTEGER: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
46 /* Integer value stored in gpointer - no need to free(). */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
47 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
48 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
49 case MSIM_TYPE_STRING: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
50 /* Always free strings - caller should have g_strdup()'d if |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
51 * string was static or temporary and not to be freed. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
52 g_free(elem->data); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
53 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
54 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
55 case MSIM_TYPE_BINARY: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
56 /* Free the GString itself and the binary data. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
57 g_string_free((GString *)elem->data, TRUE); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
58 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
59 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
60 case MSIM_TYPE_DICTIONARY: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
61 /* TODO: free dictionary */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
62 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
63 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
64 case MSIM_TYPE_LIST: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
65 /* TODO: free list */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
66 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
67 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
68 default: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
69 purple_debug_info("msim", "msim_msg_free_element: not freeing unknown type %d\n", |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
70 elem->type); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
71 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
72 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
73 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
74 g_free(elem); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
75 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
76 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
77 /** Free a complete message. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
78 void msim_msg_free(MsimMessage *msg) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
79 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
80 if (!msg) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
81 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
82 /* already free as can be */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
83 return; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
84 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
85 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
86 g_list_foreach(msg, msim_msg_free_element, NULL); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
87 g_list_free(msg); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
88 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
89 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
90 /** Send an existing MsimMessage. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
91 gboolean msim_msg_send(MsimSession *session, MsimMessage *msg) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
92 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
93 gchar *raw; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
94 gboolean success; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
95 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
96 raw = msim_msg_pack(msg); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
97 success = msim_send_raw(session, raw); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
98 g_free(raw); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
99 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
100 return success; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
101 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
102 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
103 /** |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
104 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
105 * Send a message to the server, whose contents is specified using |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
106 * variable arguments. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
107 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
108 * @param session |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
109 * @param ... A sequence of gchar* key/type/value triplets, terminated with NULL. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
110 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
111 * This function exists for coding convenience: it allows a message to be created |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
112 * and sent in one line of code. Internally it calls msim_msg_send(). |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
113 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
114 * IMPORTANT: See msim_msg_append() documentation for details on element types. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
115 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
116 */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
117 gboolean msim_send(MsimSession *session, ...) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
118 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
119 va_list argp; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
120 gchar *key, *value; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
121 MsimMessageType type; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
122 gboolean success; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
123 MsimMessage *msg; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
124 GString *gs; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
125 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
126 msg = msim_msg_new(); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
127 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
128 /* Read key, type, value triplets until NULL. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
129 va_start(argp, session); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
130 do |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
131 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
132 key = va_arg(argp, gchar *); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
133 if (!key) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
134 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
135 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
136 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
137 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
138 type = va_arg(argp, int); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
139 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
140 switch (type) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
141 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
142 case MSIM_TYPE_INTEGER: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
143 msg = msim_msg_append(msg, key, type, GUINT_TO_POINTER(va_arg(argp, int))); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
144 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
145 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
146 case MSIM_TYPE_STRING: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
147 value = va_arg(argp, char *); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
148 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
149 g_return_val_if_fail(value != NULL, FALSE); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
150 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
151 msg = msim_msg_append(msg, key, type, value); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
152 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
153 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
154 case MSIM_TYPE_BINARY: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
155 gs = va_arg(argp, GString *); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
156 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
157 g_return_val_if_fail(gs != NULL, FALSE); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
158 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
159 /* msim_msg_free() will free this GString the caller created. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
160 msg = msim_msg_append(msg, key, type, gs); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
161 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
162 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
163 default: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
164 purple_debug_info("msim", "msim_send: unknown type %d\n", type); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
165 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
166 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
167 } while(key); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
168 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
169 /* Actually send the message. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
170 success = msim_msg_send(session, msg); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
171 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
172 /* Cleanup. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
173 va_end(argp); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
174 msim_msg_free(msg); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
175 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
176 return success; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
177 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
178 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
179 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
180 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
181 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
182 /** Append a new element to a message. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
183 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
184 * @param name Textual name of element (static string, neither copied nor freed). |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
185 * @param type An MSIM_TYPE_* code. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
186 * @param data Pointer to data, see below. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
187 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
188 * @return The new message - must be assigned to as with GList*. For example: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
189 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
190 * msg = msim_msg_append(msg, ...) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
191 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
192 * The data parameter depends on the type given: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
193 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
194 * * MSIM_TYPE_INTEGER: Use GUINT_TO_POINTER(x). |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
195 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
196 * * MSIM_TYPE_BINARY: Same as integer, non-zero is TRUE and zero is FALSE. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
197 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
198 * * MSIM_TYPE_STRING: gchar *. The data WILL BE FREED - use g_strdup() if needed. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
199 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
200 * * MSIM_TYPE_BINARY: g_string_new_len(data, length). The data and GString will be freed. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
201 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
202 * * MSIM_TYPE_DICTIONARY: TODO |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
203 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
204 * * MSIM_TYPE_LIST: TODO |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
205 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
206 * */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
207 MsimMessage *msim_msg_append(MsimMessage *msg, gchar *name, MsimMessageType type, gpointer data) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
208 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
209 MsimMessageElement *elem; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
210 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
211 elem = g_new0(MsimMessageElement, 1); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
212 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
213 elem->name = name; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
214 elem->type = type; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
215 elem->data = data; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
216 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
217 return g_list_append(msg, elem); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
218 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
219 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
220 /** Pack a string using the given GFunc and seperator. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
221 * Used by msim_msg_debug_string() and msim_msg_pack(). |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
222 */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
223 static gchar *msim_msg_pack_using(MsimMessage *msg, GFunc gf, gchar *sep, gchar *begin, gchar *end) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
224 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
225 gchar **strings; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
226 gchar **strings_tmp; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
227 gchar *joined; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
228 gchar *final; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
229 int i; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
230 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
231 g_return_val_if_fail(msg != NULL, NULL); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
232 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
233 /* Add one for NULL terminator for g_strjoinv(). */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
234 strings = (gchar **)g_new0(gchar *, g_list_length(msg) + 1); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
235 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
236 strings_tmp = strings; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
237 g_list_foreach(msg, gf, &strings_tmp); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
238 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
239 joined = g_strjoinv(sep, strings); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
240 final = g_strconcat(begin, joined, end, NULL); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
241 g_free(joined); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
242 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
243 /* Clean up. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
244 for (i = 0; i < g_list_length(msg); ++i) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
245 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
246 g_free(strings[i]); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
247 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
248 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
249 g_free(strings); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
250 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
251 return final; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
252 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
253 /** Store a human-readable string describing the element. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
254 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
255 * @param data Pointer to an MsimMessageElement. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
256 * @param user_data |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
257 */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
258 static void msim_msg_debug_string_element(gpointer data, gpointer user_data) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
259 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
260 MsimMessageElement *elem; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
261 gchar *string; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
262 GString *gs; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
263 gchar *binary; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
264 gchar ***items; /* wow, a pointer to a pointer to a pointer */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
265 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
266 elem = (MsimMessageElement *)data; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
267 items = user_data; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
268 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
269 switch (elem->type) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
270 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
271 case MSIM_TYPE_INTEGER: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
272 string = g_strdup_printf("%s(integer): %d", elem->name, GPOINTER_TO_UINT(elem->data)); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
273 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
274 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
275 case MSIM_TYPE_STRING: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
276 string = g_strdup_printf("%s(string): %s", elem->name, (gchar *)elem->data); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
277 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
278 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
279 case MSIM_TYPE_BINARY: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
280 gs = (GString *)elem->data; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
281 binary = purple_base64_encode((guchar*)gs->str, gs->len); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
282 string = g_strdup_printf("%s(binary, %d bytes): %s", elem->name, (int)gs->len, binary); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
283 g_free(binary); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
284 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
285 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
286 case MSIM_TYPE_BOOLEAN: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
287 string = g_strdup_printf("%s(boolean): %s", elem->name, |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
288 GPOINTER_TO_UINT(elem->data) ? "TRUE" : "FALSE"); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
289 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
290 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
291 case MSIM_TYPE_DICTIONARY: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
292 /* TODO: provide human-readable output of dictionary. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
293 string = g_strdup_printf("%s(dict): TODO", elem->name); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
294 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
295 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
296 case MSIM_TYPE_LIST: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
297 /* TODO: provide human-readable output of list. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
298 string = g_strdup_printf("%s(list): TODO", elem->name); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
299 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
300 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
301 default: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
302 string = g_strdup_printf("%s(unknown type %d)", elem->name, elem->type); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
303 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
304 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
305 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
306 **items = string; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
307 ++(*items); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
308 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
309 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
310 /** Return a human-readable string of the message. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
311 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
312 * @return A string. Caller must g_free(). |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
313 */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
314 gchar *msim_msg_debug_string(MsimMessage *msg) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
315 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
316 if (!msg) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
317 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
318 return g_strdup("<MsimMessage: empty>"); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
319 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
320 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
321 return msim_msg_pack_using(msg, msim_msg_debug_string_element, "\n", "<MsimMessage: \n", ">"); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
322 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
323 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
324 /** Pack an element into its protocol representation. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
325 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
326 * @param data Pointer to an MsimMessageElement. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
327 * @param user_data |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
328 */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
329 static void msim_msg_pack_element(gpointer data, gpointer user_data) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
330 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
331 MsimMessageElement *elem; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
332 gchar *string; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
333 gchar ***items; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
334 gchar *binary; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
335 gchar *escaped; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
336 GString *gs; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
337 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
338 elem = (MsimMessageElement *)data; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
339 items = user_data; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
340 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
341 switch (elem->type) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
342 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
343 case MSIM_TYPE_INTEGER: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
344 string = g_strdup_printf("%s\\%d", elem->name, GPOINTER_TO_UINT(elem->data)); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
345 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
346 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
347 case MSIM_TYPE_STRING: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
348 /* Strings get escaped. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
349 escaped = msim_escape((gchar *)elem->data); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
350 string = g_strdup_printf("%s\\%s", elem->name, escaped); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
351 g_free(escaped); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
352 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
353 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
354 case MSIM_TYPE_BINARY: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
355 gs = (GString *)elem->data; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
356 binary = purple_base64_encode((guchar*)gs->str, gs->len); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
357 /* Do not escape! */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
358 string = g_strdup_printf("%s\\%s", elem->name, binary); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
359 g_free(binary); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
360 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
361 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
362 case MSIM_TYPE_BOOLEAN: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
363 if (GPOINTER_TO_UINT(elem->data)) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
364 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
365 string = g_strdup_printf("%s\\\\", elem->name); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
366 } else { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
367 /* False - leave out. */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
368 string = g_strdup(""); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
369 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
370 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
371 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
372 case MSIM_TYPE_DICTIONARY: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
373 /* TODO: pack using k=v\034k2=v2\034... */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
374 string = g_strdup_printf("%s\\TODO", elem->name); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
375 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
376 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
377 case MSIM_TYPE_LIST: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
378 /* TODO: pack using a|b|c|d|... */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
379 string = g_strdup_printf("%s\\TODO", elem->name); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
380 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
381 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
382 default: |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
383 g_return_if_fail(FALSE); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
384 break; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
385 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
386 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
387 **items = string; |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
388 ++(*items); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
389 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
390 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
391 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
392 /** Return a packed string suitable for sending over the wire. |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
393 * |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
394 * @return A string. Caller must g_free(). |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
395 */ |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
396 gchar *msim_msg_pack(MsimMessage *msg) |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
397 { |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
398 g_return_val_if_fail(msg != NULL, NULL); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
399 |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
400 return msim_msg_pack_using(msg, msim_msg_pack_element, "\\", "\\", "\\final\\"); |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
401 } |
ddcf9ef2ccec
Add MsimMessage implementation (sending only).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
402 |