Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/xmpp_helper.c @ 1604:351427ef0b4b
Remove #include's of C files
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 11 Oct 2009 15:59:53 +0200 |
parents | f4a2c6f767d1 |
children | 14690e624e9d |
comparison
equal
deleted
inserted
replaced
1603:54029aba9452 | 1604:351427ef0b4b |
---|---|
20 * along with this program; if not, write to the Free Software | 20 * along with this program; if not, write to the Free Software |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
22 * USA | 22 * USA |
23 */ | 23 */ |
24 | 24 |
25 #include <string.h> | |
26 #include <stdlib.h> | |
27 | |
25 #include "xmpp_helper.h" | 28 #include "xmpp_helper.h" |
29 #include "settings.h" | |
30 #include "utils.h" | |
31 #include "caps.h" | |
32 #include "logprint.h" | |
26 | 33 |
27 time_t iqlast; // last message/status change time | 34 time_t iqlast; // last message/status change time |
35 | |
36 extern char *imstatus_showmap[]; | |
37 | |
38 struct xmpp_error xmpp_errors[] = { | |
39 {XMPP_ERROR_REDIRECT, "302", | |
40 "Redirect", "redirect", "modify"}, | |
41 {XMPP_ERROR_BAD_REQUEST, "400", | |
42 "Bad Request", "bad-request", "modify"}, | |
43 {XMPP_ERROR_NOT_AUTHORIZED, "401", | |
44 "Not Authorized", "not-authorized", "auth"}, | |
45 {XMPP_ERROR_PAYMENT_REQUIRED, "402", | |
46 "Payment Required", "payment-required", "auth"}, | |
47 {XMPP_ERROR_FORBIDDEN, "403", | |
48 "Forbidden", "forbidden", "auth"}, | |
49 {XMPP_ERROR_NOT_FOUND, "404", | |
50 "Not Found", "item-not-found", "cancel"}, | |
51 {XMPP_ERROR_NOT_ALLOWED, "405", | |
52 "Not Allowed", "not-allowed", "cancel"}, | |
53 {XMPP_ERROR_NOT_ACCEPTABLE, "406", | |
54 "Not Acceptable", "not-acceptable", "modify"}, | |
55 {XMPP_ERROR_REGISTRATION_REQUIRED, "407", | |
56 "Registration required", "registration-required", "auth"}, | |
57 {XMPP_ERROR_REQUEST_TIMEOUT, "408", | |
58 "Request Timeout", "remote-server-timeout", "wait"}, | |
59 {XMPP_ERROR_CONFLICT, "409", | |
60 "Conflict", "conflict", "cancel"}, | |
61 {XMPP_ERROR_INTERNAL_SERVER_ERROR, "500", | |
62 "Internal Server Error", "internal-server-error", "wait"}, | |
63 {XMPP_ERROR_NOT_IMPLEMENTED, "501", | |
64 "Not Implemented", "feature-not-implemented", "cancel"}, | |
65 {XMPP_ERROR_REMOTE_SERVER_ERROR, "502", | |
66 "Remote Server Error", "service-unavailable", "wait"}, | |
67 {XMPP_ERROR_SERVICE_UNAVAILABLE, "503", | |
68 "Service Unavailable", "service-unavailable", "cancel"}, | |
69 {XMPP_ERROR_REMOTE_SERVER_TIMEOUT, "504", | |
70 "Remote Server Timeout", "remote-server-timeout", "wait"}, | |
71 {XMPP_ERROR_DISCONNECTED, "510", | |
72 "Disconnected", "service-unavailable", "cancel"}, | |
73 {0, NULL, NULL, NULL, NULL} | |
74 }; | |
75 | |
28 | 76 |
29 const gchar* lm_message_node_get_child_value(LmMessageNode *node, | 77 const gchar* lm_message_node_get_child_value(LmMessageNode *node, |
30 const gchar *child) | 78 const gchar *child) |
31 { | 79 { |
32 LmMessageNode *tmp; | 80 LmMessageNode *tmp; |
108 const gchar* lm_message_get_id(LmMessage *m) | 156 const gchar* lm_message_get_id(LmMessage *m) |
109 { | 157 { |
110 return lm_message_node_get_attribute(m->node, "id"); | 158 return lm_message_node_get_attribute(m->node, "id"); |
111 } | 159 } |
112 | 160 |
113 static LmMessage *lm_message_new_iq_from_query(LmMessage *m, | 161 LmMessage *lm_message_new_iq_from_query(LmMessage *m, |
114 LmMessageSubType type) | 162 LmMessageSubType type) |
115 { | 163 { |
116 LmMessage *new; | 164 LmMessage *new; |
117 const char *from = lm_message_node_get_attribute(m->node, "from"); | 165 const char *from = lm_message_node_get_attribute(m->node, "from"); |
118 const char *id = lm_message_node_get_attribute(m->node, "id"); | 166 const char *id = lm_message_node_get_attribute(m->node, "id"); |
119 | 167 |
164 | 212 |
165 ver = caps_generate(); | 213 ver = caps_generate(); |
166 return ver; | 214 return ver; |
167 } | 215 } |
168 | 216 |
169 inline static LmMessageNode *lm_message_node_find_xmlns(LmMessageNode *node, | 217 LmMessageNode *lm_message_node_find_xmlns(LmMessageNode *node, |
170 const char *xmlns) | 218 const char *xmlns) |
171 { | 219 { |
172 LmMessageNode *x; | 220 LmMessageNode *x; |
173 const char *p; | 221 const char *p; |
174 | 222 |
175 for (x = node->children ; x; x = x->next) { | 223 for (x = node->children ; x; x = x->next) { |
177 break; | 225 break; |
178 } | 226 } |
179 return x; | 227 return x; |
180 } | 228 } |
181 | 229 |
182 static time_t lm_message_node_get_timestamp(LmMessageNode *node) | 230 time_t lm_message_node_get_timestamp(LmMessageNode *node) |
183 { | 231 { |
184 LmMessageNode *x; | 232 LmMessageNode *x; |
185 const char *p; | 233 const char *p; |
186 | 234 |
187 x = lm_message_node_find_xmlns(node, NS_XMPP_DELAY); | 235 x = lm_message_node_find_xmlns(node, NS_XMPP_DELAY); |
195 } | 243 } |
196 | 244 |
197 // lm_message_new_presence(status, recipient, message) | 245 // lm_message_new_presence(status, recipient, message) |
198 // Create an xmlnode with default presence attributes | 246 // Create an xmlnode with default presence attributes |
199 // Note: the caller must free the node after use | 247 // Note: the caller must free the node after use |
200 static LmMessage *lm_message_new_presence(enum imstatus st, | 248 LmMessage *lm_message_new_presence(enum imstatus st, |
201 const char *recipient, | 249 const char *recipient, |
202 const char *msg) | 250 const char *msg) |
203 { | 251 { |
204 unsigned int prio; | 252 unsigned int prio; |
205 LmMessage *x = lm_message_new(recipient, LM_MESSAGE_TYPE_PRESENCE); | 253 LmMessage *x = lm_message_new(recipient, LM_MESSAGE_TYPE_PRESENCE); |
206 | 254 |
207 switch(st) { | 255 switch(st) { |
241 return x; | 289 return x; |
242 } | 290 } |
243 | 291 |
244 static const char *defaulterrormsg(guint code) | 292 static const char *defaulterrormsg(guint code) |
245 { | 293 { |
246 int i = 0; | 294 int i; |
247 | 295 |
248 for (i = 0; xmpp_errors[i].code; ++i) { | 296 for (i = 0; xmpp_errors[i].code; ++i) { |
249 if (xmpp_errors[i].code == code) | 297 if (xmpp_errors[i].code == code) |
250 return xmpp_errors[i].meaning; | 298 return xmpp_errors[i].meaning; |
251 } | 299 } |