Mercurial > hg
annotate mcabber/libjabber/jabber.h @ 430:d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
If possible, we display the child element corresponding to the stanza
error conditions defined in RFC3920. Error code and error text will
be displayed if available.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 11 Sep 2005 22:01:57 +0200 |
parents | c3ae9251c197 |
children | 98de2d166a11 |
rev | line source |
---|---|
25 | 1 /* |
2 * This program is free software; you can redistribute it and/or modify | |
3 * it under the terms of the GNU General Public License as published by | |
4 * the Free Software Foundation; either version 2 of the License, or | |
5 * (at your option) any later version. | |
6 * | |
7 * This program is distributed in the hope that it will be useful, | |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 * GNU General Public License for more details. | |
11 * | |
12 * You should have received a copy of the GNU General Public License | |
13 * along with this program; if not, write to the Free Software | |
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
15 * | |
16 * Jabber | |
17 * Copyright (C) 1998-1999 The Jabber Team http://jabber.org/ | |
18 */ | |
19 | |
20 #include <string.h> | |
21 #include <stdlib.h> | |
22 #include <sys/types.h> | |
23 #include <stdio.h> | |
24 #include <setjmp.h> | |
25 #include <sys/stat.h> | |
26 #include <fcntl.h> | |
27 #include <errno.h> | |
28 #include <signal.h> | |
29 #include <stdarg.h> | |
30 #include <syslog.h> | |
31 #include <strings.h> | |
32 #include <unistd.h> | |
33 #include <sys/socket.h> | |
34 #include <netinet/in.h> | |
35 #include <netdb.h> | |
36 #include <arpa/inet.h> | |
37 #include <ctype.h> | |
38 #include <time.h> | |
39 | |
40 #include "libxode.h" | |
56 | 41 #include "../connwrap/connwrap.h" |
25 | 42 |
43 #ifndef INCL_JABBER_H | |
44 #define INCL_JABBER_H | |
45 | |
46 #ifdef __cplusplus | |
47 extern "C" { | |
48 #endif | |
49 | |
50 /* --------------------------------------------------------- */ | |
51 /* */ | |
52 /* JID structures & constants */ | |
53 /* */ | |
54 /* --------------------------------------------------------- */ | |
55 #define JID_RESOURCE 1 | |
56 #define JID_USER 2 | |
57 #define JID_SERVER 4 | |
58 | |
59 typedef struct jid_struct | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
60 { |
25 | 61 pool p; |
62 char* resource; | |
63 char* user; | |
64 char* server; | |
65 char* full; | |
66 struct jid_struct *next; /* for lists of jids */ | |
67 } *jid; | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
68 |
25 | 69 jid jid_new(pool p, char *idstr); /* Creates a jabber id from the idstr */ |
70 | |
71 void jid_set(jid id, char *str, int item); /* Individually sets jid components */ | |
72 char* jid_full(jid id); /* Builds a string type=user/resource@server from the jid data */ | |
73 int jid_cmp(jid a, jid b); /* Compares two jid's, returns 0 for perfect match */ | |
74 int jid_cmpx(jid a, jid b, int parts); /* Compares just the parts specified as JID_|JID_ */ | |
75 jid jid_append(jid a, jid b); /* Appending b to a (list), no dups */ | |
76 xmlnode jid_xres(jid id); /* Returns xmlnode representation of the resource?query=string */ | |
77 xmlnode jid_nodescan(jid id, xmlnode x); /* Scans the children of the node for a matching jid attribute */ | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
78 jid jid_user(jid a); /* returns the same jid but just of the user@host part */ |
25 | 79 |
80 | |
81 /* --------------------------------------------------------- */ | |
82 /* */ | |
83 /* JPacket structures & constants */ | |
84 /* */ | |
85 /* --------------------------------------------------------- */ | |
86 #define JPACKET_UNKNOWN 0x00 | |
87 #define JPACKET_MESSAGE 0x01 | |
88 #define JPACKET_PRESENCE 0x02 | |
89 #define JPACKET_IQ 0x04 | |
90 #define JPACKET_S10N 0x08 | |
91 | |
92 #define JPACKET__UNKNOWN 0 | |
93 #define JPACKET__NONE 1 | |
94 #define JPACKET__ERROR 2 | |
95 #define JPACKET__CHAT 3 | |
96 #define JPACKET__GROUPCHAT 4 | |
97 #define JPACKET__GET 5 | |
98 #define JPACKET__SET 6 | |
99 #define JPACKET__RESULT 7 | |
100 #define JPACKET__SUBSCRIBE 8 | |
101 #define JPACKET__SUBSCRIBED 9 | |
102 #define JPACKET__UNSUBSCRIBE 10 | |
103 #define JPACKET__UNSUBSCRIBED 11 | |
104 #define JPACKET__AVAILABLE 12 | |
105 #define JPACKET__UNAVAILABLE 13 | |
106 #define JPACKET__PROBE 14 | |
107 #define JPACKET__HEADLINE 15 | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
108 #define JPACKET__INVISIBLE 16 |
25 | 109 |
110 typedef struct jpacket_struct | |
111 { | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
112 unsigned char type; /**< stanza type (JPACKET_*) */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
113 int subtype; /**< subtype of a stanza */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
114 int flag; /**< used by the session manager to flag messages, that are read from offline storage */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
115 void* aux1; /**< pointer to data passed around with a jpacket, multiple use inside jsm */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
116 xmlnode x; /**< xmlnode containing the stanza inside the jpacket */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
117 jid to; /**< destination of the stanza */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
118 jid from; /**< source address for the stanza */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
119 char* iqns; /**< pointer to the namespace inside an IQ stanza */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
120 xmlnode iq; /**< "content" of an iq stanza, pointer to the element in its own namespace */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
121 pool p; /**< memory pool used for this stanza */ |
25 | 122 } *jpacket, _jpacket; |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
123 |
25 | 124 jpacket jpacket_new(xmlnode x); /* Creates a jabber packet from the xmlnode */ |
125 jpacket jpacket_reset(jpacket p); /* Resets the jpacket values based on the xmlnode */ | |
126 int jpacket_subtype(jpacket p); /* Returns the subtype value (looks at xmlnode for it) */ | |
127 | |
128 | |
129 /* --------------------------------------------------------- */ | |
130 /* */ | |
131 /* Presence Proxy DB structures & constants */ | |
132 /* */ | |
133 /* --------------------------------------------------------- */ | |
134 typedef struct ppdb_struct | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
135 { |
25 | 136 jid id; /* entry data */ |
137 int pri; | |
138 xmlnode x; | |
139 struct ppdb_struct* user; /* linked list for user@server */ | |
140 pool p; /* db-level data */ | |
141 struct ppdb_struct* next; | |
142 } _ppdb, *ppdb; | |
143 | |
144 ppdb ppdb_insert(ppdb db, jid id, xmlnode x); /* Inserts presence into the proxy */ | |
145 xmlnode ppdb_primary(ppdb db, jid id); /* Fetches the matching primary presence for the id */ | |
146 void ppdb_free(ppdb db); /* Frees the db and all entries */ | |
147 xmlnode ppdb_get(ppdb db, jid id); /* Called successively to return each presence xmlnode */ | |
148 /* for the id and children, returns NULL at the end */ | |
149 | |
150 | |
151 /* --------------------------------------------------------- */ | |
152 /* */ | |
153 /* Simple Jabber Rate limit functions */ | |
154 /* */ | |
155 /* --------------------------------------------------------- */ | |
156 typedef struct jlimit_struct | |
157 { | |
158 char *key; | |
159 int start; | |
160 int points; | |
161 int maxt, maxp; | |
162 pool p; | |
163 } *jlimit, _jlimit; | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
164 |
25 | 165 jlimit jlimit_new(int maxt, int maxp); |
166 void jlimit_free(jlimit r); | |
167 int jlimit_check(jlimit r, char *key, int points); | |
168 | |
169 | |
170 /* --------------------------------------------------------- */ | |
171 /* */ | |
172 /* Error structures & constants */ | |
173 /* */ | |
174 /* --------------------------------------------------------- */ | |
175 typedef struct terror_struct | |
176 { | |
177 int code; | |
178 char msg[64]; | |
179 } terror; | |
180 | |
181 #define TERROR_BAD (terror){400,"Bad Request"} | |
182 #define TERROR_AUTH (terror){401,"Unauthorized"} | |
183 #define TERROR_PAY (terror){402,"Payment Required"} | |
184 #define TERROR_FORBIDDEN (terror){403,"Forbidden"} | |
185 #define TERROR_NOTFOUND (terror){404,"Not Found"} | |
186 #define TERROR_NOTALLOWED (terror){405,"Not Allowed"} | |
187 #define TERROR_NOTACCEPTABLE (terror){406,"Not Acceptable"} | |
188 #define TERROR_REGISTER (terror){407,"Registration Required"} | |
189 #define TERROR_REQTIMEOUT (terror){408,"Request Timeout"} | |
190 #define TERROR_CONFLICT (terror){409,"Conflict"} | |
191 | |
192 #define TERROR_INTERNAL (terror){500,"Internal Server Error"} | |
193 #define TERROR_NOTIMPL (terror){501,"Not Implemented"} | |
194 #define TERROR_EXTERNAL (terror){502,"Remote Server Error"} | |
195 #define TERROR_UNAVAIL (terror){503,"Service Unavailable"} | |
196 #define TERROR_EXTTIMEOUT (terror){504,"Remote Server Timeout"} | |
197 #define TERROR_DISCONNECTED (terror){510,"Disconnected"} | |
198 | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
199 /* we define this to signal that we support xterror */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
200 #define HAS_XTERROR |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
201 |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
202 typedef struct xterror_struct |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
203 { |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
204 int code; |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
205 char msg[256]; |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
206 char type[9]; |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
207 char condition[64]; |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
208 } xterror; |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
209 |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
210 #define XTERROR_BAD (xterror){400,"Bad Request","modify","bad-request"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
211 #define XTERROR_CONFLICT (xterror){409,"Conflict","cancel","conflict"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
212 #define XTERROR_NOTIMPL (xterror){501,"Not Implemented","cancel","feature-not-implemented"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
213 #define XTERROR_FORBIDDEN (xterror){403,"Forbidden","auth","forbidden"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
214 #define XTERROR_GONE (xterror){302,"Gone","modify","gone"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
215 #define XTERROR_INTERNAL (xterror){500,"Internal Server Error","wait","internal-server-error"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
216 #define XTERROR_NOTFOUND (xterror){404,"Not Found","cancel","item-not-found"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
217 #define XTERROR_JIDMALFORMED (xterror){400,"Bad Request","modify","jid-malformed"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
218 #define XTERROR_NOTACCEPTABLE (xterror){406,"Not Acceptable","modify","not-acceptable"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
219 #define XTERROR_NOTALLOWED (xterror){405,"Not Allowed","cancel","not-allowed"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
220 #define XTERROR_AUTH (xterror){401,"Unauthorized","auth","not-authorized"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
221 #define XTERROR_PAY (xterror){402,"Payment Required","auth","payment-required"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
222 #define XTERROR_RECIPIENTUNAVAIL (xterror){404,"Receipient Is Unavailable","wait","recipient-unavailable"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
223 #define XTERROR_REDIRECT (xterror){302,"Redirect","modify","redirect"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
224 #define XTERROR_REGISTER (xterror){407,"Registration Required","auth","registration-required"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
225 #define XTERROR_REMOTENOTFOUND (xterror){404,"Remote Server Not Found","cancel","remote-server-not-found"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
226 #define XTERROR_REMOTETIMEOUT (xterror){504,"Remote Server Timeout","wait","remote-server-timeout"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
227 #define XTERROR_RESCONSTRAINT (xterror){500,"Resource Constraint","wait","resource-constraint"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
228 #define XTERROR_UNAVAIL (xterror){503,"Service Unavailable","cancel","service-unavailable"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
229 #define XTERROR_SUBSCRIPTIONREQ (xterror){407,"Subscription Required","auth","subscription-required"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
230 #define XTERROR_UNDEF_CANCEL (xterror){500,NULL,"cancel","undefined-condition"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
231 #define XTERROR_UNDEF_CONTINUE (xterror){500,NULL,"continue","undefined-condition"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
232 #define XTERROR_UNDEF_MODIFY (xterror){500,NULL,"modify","undefined-condition"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
233 #define XTERROR_UNDEF_AUTH (xterror){500,NULL,"auth","undefined-condition"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
234 #define XTERROR_UNDEF_WAIT (xterror){500,NULL,"wait","undefined-condition"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
235 #define XTERROR_UNEXPECTED (xterror){400,"Unexpected Request","wait","unexpected-request"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
236 |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
237 #define XTERROR_REQTIMEOUT (xterror){408,"Request Timeout","wait","remote-server-timeout"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
238 #define XTERROR_EXTERNAL (xterror){502,"Remote Server Error","wait","service-unavailable"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
239 #define XTERROR_EXTTIMEOUT (xterror){504,"Remote Server Timeout","wait","remote-server-timeout"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
240 #define XTERROR_DISCONNECTED (xterror){510,"Disconnected","cancel","service-unavailable"} |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
241 |
25 | 242 /* --------------------------------------------------------- */ |
243 /* */ | |
244 /* Namespace constants */ | |
245 /* */ | |
246 /* --------------------------------------------------------- */ | |
247 #define NSCHECK(x,n) (j_strcmp(xmlnode_get_attrib(x,"xmlns"),n) == 0) | |
248 | |
249 #define NS_CLIENT "jabber:client" | |
250 #define NS_SERVER "jabber:server" | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
251 #define NS_DIALBACK "jabber:server:dialback" |
25 | 252 #define NS_AUTH "jabber:iq:auth" |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
253 #define NS_AUTH_CRYPT "jabber:iq:auth:crypt" |
25 | 254 #define NS_REGISTER "jabber:iq:register" |
255 #define NS_ROSTER "jabber:iq:roster" | |
256 #define NS_OFFLINE "jabber:x:offline" | |
257 #define NS_AGENT "jabber:iq:agent" | |
258 #define NS_AGENTS "jabber:iq:agents" | |
259 #define NS_DELAY "jabber:x:delay" | |
260 #define NS_VERSION "jabber:iq:version" | |
261 #define NS_TIME "jabber:iq:time" | |
262 #define NS_VCARD "vcard-temp" | |
263 #define NS_PRIVATE "jabber:iq:private" | |
264 #define NS_SEARCH "jabber:iq:search" | |
265 #define NS_OOB "jabber:iq:oob" | |
266 #define NS_XOOB "jabber:x:oob" | |
267 #define NS_ADMIN "jabber:iq:admin" | |
268 #define NS_FILTER "jabber:iq:filter" | |
269 #define NS_AUTH_0K "jabber:iq:auth:0k" | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
270 #define NS_BROWSE "jabber:iq:browse" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
271 #define NS_EVENT "jabber:x:event" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
272 #define NS_CONFERENCE "jabber:iq:conference" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
273 #define NS_SIGNED "jabber:x:signed" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
274 #define NS_ENCRYPTED "jabber:x:encrypted" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
275 #define NS_GATEWAY "jabber:iq:gateway" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
276 #define NS_LAST "jabber:iq:last" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
277 #define NS_ENVELOPE "jabber:x:envelope" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
278 #define NS_EXPIRE "jabber:x:expire" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
279 #define NS_XHTML "http://www.w3.org/1999/xhtml" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
280 #define NS_DISCO_INFO "http://jabber.org/protocol/disco#info" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
281 #define NS_DISCO_ITEMS "http://jabber.org/protocol/disco#items" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
282 #define NS_IQ_AUTH "http://jabber.org/features/iq-auth" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
283 #define NS_REGISTER_FEATURE "http://jabber.org/features/iq-register" |
25 | 284 |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
285 #define NS_XDBGINSERT "jabber:xdb:ginsert" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
286 #define NS_XDBNSLIST "jabber:xdb:nslist" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
287 |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
288 #define NS_XMPP_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
289 #define NS_XMPP_TLS "urn:ietf:params:xml:ns:xmpp-tls" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
290 #define NS_XMPP_STREAMS "urn:ietf:params:xml:ns:xmpp-streams" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
291 |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
292 #define NS_JABBERD_STOREDPRESENCE "http://jabberd.org/ns/storedpresence" |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
403
diff
changeset
|
293 #define NS_JABBERD_HISTORY "http://jabberd.org/ns/history" |
25 | 294 |
295 /* --------------------------------------------------------- */ | |
296 /* */ | |
297 /* Message Types */ | |
298 /* */ | |
299 /* --------------------------------------------------------- */ | |
300 #define TMSG_NORMAL "normal" | |
301 #define TMSG_ERROR "error" | |
302 #define TMSG_CHAT "chat" | |
303 #define TMSG_GROUPCHAT "groupchat" | |
304 #define TMSG_HEADLINE "headline" | |
305 | |
306 | |
307 /* --------------------------------------------------------- */ | |
308 /* */ | |
309 /* JUtil functions */ | |
310 /* */ | |
311 /* --------------------------------------------------------- */ | |
312 xmlnode jutil_presnew(int type, char *to, char *status); /* Create a skeleton presence packet */ | |
313 xmlnode jutil_iqnew(int type, char *ns); /* Create a skeleton iq packet */ | |
314 xmlnode jutil_msgnew(char *type, char *to, char *subj, char *body); | |
315 /* Create a skeleton message packet */ | |
316 xmlnode jutil_header(char* xmlns, char* server); /* Create a skeleton stream packet */ | |
317 int jutil_priority(xmlnode x); /* Determine priority of this packet */ | |
318 void jutil_tofrom(xmlnode x); /* Swaps to/from fields on a packet */ | |
319 xmlnode jutil_iqresult(xmlnode x); /* Generate a skeleton iq/result, given a iq/query */ | |
320 char* jutil_timestamp(void); /* Get stringified timestamp */ | |
321 void jutil_error(xmlnode x, terror E); /* Append an <error> node to x */ | |
322 void jutil_delay(xmlnode msg, char *reason); /* Append a delay packet to msg */ | |
323 char* jutil_regkey(char *key, char *seed); /* pass a seed to generate a key, pass the key again to validate (returns it) */ | |
324 | |
325 | |
326 /* --------------------------------------------------------- */ | |
327 /* */ | |
328 /* JConn structures & functions */ | |
329 /* */ | |
330 /* --------------------------------------------------------- */ | |
331 #define JCONN_STATE_OFF 0 | |
332 #define JCONN_STATE_CONNECTED 1 | |
333 #define JCONN_STATE_ON 2 | |
334 #define JCONN_STATE_AUTH 3 | |
335 #define JCONN_STATE_CONNECTING 4 | |
336 | |
337 typedef struct jconn_struct | |
338 { | |
339 /* Core structure */ | |
56 | 340 pool p; /* Memory allocation pool */ |
341 int state; /* Connection state flag */ | |
342 int cw_state; /* Low level connection state flag */ | |
343 int fd; /* Connection file descriptor */ | |
403
17aa60c6dc63
Allow a different server name than the jid domain name
Mikael Berthe <mikael@lilotux.net>
parents:
56
diff
changeset
|
344 char *server; /* The server we'll connect too */ |
25 | 345 int port; |
346 int ssl; | |
56 | 347 jid user; /* User info */ |
348 char *pass; /* User passwd */ | |
25 | 349 |
350 /* Stream stuff */ | |
56 | 351 int id; /* id counter for jab_getid() function */ |
352 char idbuf[9]; /* temporary storage for jab_getid() */ | |
353 char *sid; /* stream id from server, for digest auth */ | |
354 XML_Parser parser; /* Parser instance */ | |
355 xmlnode current; /* Current node in parsing instance.. */ | |
25 | 356 |
357 /* Event callback ptrs */ | |
358 void (*on_state)(struct jconn_struct *j, int state); | |
359 void (*on_packet)(struct jconn_struct *j, jpacket p); | |
360 void (*logger)(struct jconn_struct *j, int inout, const char *p); | |
361 | |
362 } *jconn, jconn_struct; | |
363 | |
364 typedef void (*jconn_state_h)(jconn j, int state); | |
365 typedef void (*jconn_packet_h)(jconn j, jpacket p); | |
366 typedef void (*jconn_logger)(jconn j, int inout, const char *p); | |
367 | |
403
17aa60c6dc63
Allow a different server name than the jid domain name
Mikael Berthe <mikael@lilotux.net>
parents:
56
diff
changeset
|
368 jconn jab_new(char *user, char *pass, char *server, int port, int ssl); |
25 | 369 void jab_delete(jconn j); |
370 void jab_state_handler(jconn j, jconn_state_h h); | |
371 void jab_packet_handler(jconn j, jconn_packet_h h); | |
372 void jab_logger(jconn j, jconn_logger h); | |
373 void jab_start(jconn j); | |
374 void jab_stop(jconn j); | |
375 | |
376 int jab_getfd(jconn j); | |
377 jid jab_getjid(jconn j); | |
378 char *jab_getsid(jconn j); | |
379 char *jab_getid(jconn j); | |
380 | |
381 void jab_send(jconn j, xmlnode x); | |
382 void jab_send_raw(jconn j, const char *str); | |
383 void jab_recv(jconn j); | |
384 void jab_poll(jconn j, int timeout); | |
385 | |
386 char *jab_auth(jconn j); | |
387 char *jab_reg(jconn j); | |
388 | |
389 #ifdef __cplusplus | |
390 } | |
391 #endif | |
392 | |
393 #endif /* INCL_JABBER_H */ |