annotate mcabber/libjabber/jabber.h @ 1283:2faf179166f3

Implement XEP-0202 (Entity Time) Mcabber now answers urn:xmpp:time IQ requests.
author Mikael Berthe <mikael@lilotux.net>
date Sat, 25 Aug 2007 22:48:59 +0200
parents d438b56990cd
children
rev   line source
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
1 /*
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
2 * This program is free software; you can redistribute it and/or modify
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
3 * it under the terms of the GNU General Public License as published by
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
4 * the Free Software Foundation; either version 2 of the License, or
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
5 * (at your option) any later version.
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
6 *
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
7 * This program is distributed in the hope that it will be useful,
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
10 * GNU General Public License for more details.
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
11 *
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
12 * You should have received a copy of the GNU General Public License
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
13 * along with this program; if not, write to the Free Software
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
15 *
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
16 * Jabber
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
17 * Copyright (C) 1998-1999 The Jabber Team http://jabber.org/
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
18 */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
19
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
20 #include <string.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
21 #include <stdlib.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
22 #include <sys/types.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
23 #include <stdio.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
24 #include <setjmp.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
25 #include <sys/stat.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
26 #include <fcntl.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
27 #include <errno.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
28 #include <signal.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
29 #include <stdarg.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
30 #include <syslog.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
31 #include <strings.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
32 #include <unistd.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
33 #include <sys/socket.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
34 #include <netinet/in.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
35 #include <netdb.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
36 #include <arpa/inet.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
37 #include <ctype.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
38 #include <time.h>
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
39
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
40 #include "libxode.h"
56
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
41 #include "../connwrap/connwrap.h"
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
42
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
43 #ifndef INCL_JABBER_H
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
44 #define INCL_JABBER_H
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
45
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
46 #ifdef __cplusplus
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
47 extern "C" {
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
48 #endif
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
49
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
50 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
51 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
52 /* JID structures & constants */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
53 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
54 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
55 #define JID_RESOURCE 1
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
56 #define JID_USER 2
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
57 #define JID_SERVER 4
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
58
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
59 typedef struct jid_struct
417
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
60 {
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
61 pool p;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
62 char* resource;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
63 char* user;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
64 char* server;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
65 char* full;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
66 struct jid_struct *next; /* for lists of jids */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
67 } *jid;
417
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
68
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
69 jid jid_new(pool p, char *idstr); /* Creates a jabber id from the idstr */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
70
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
71 void jid_set(jid id, char *str, int item); /* Individually sets jid components */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
72 char* jid_full(jid id); /* Builds a string type=user/resource@server from the jid data */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
73 int jid_cmp(jid a, jid b); /* Compares two jid's, returns 0 for perfect match */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
74 int jid_cmpx(jid a, jid b, int parts); /* Compares just the parts specified as JID_|JID_ */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
75 jid jid_append(jid a, jid b); /* Appending b to a (list), no dups */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
76 xmlnode jid_xres(jid id); /* Returns xmlnode representation of the resource?query=string */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
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
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
79
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
80
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
81 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
82 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
83 /* JPacket structures & constants */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
84 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
85 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
86 #define JPACKET_UNKNOWN 0x00
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
87 #define JPACKET_MESSAGE 0x01
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
88 #define JPACKET_PRESENCE 0x02
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
89 #define JPACKET_IQ 0x04
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
90 #define JPACKET_S10N 0x08
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
91
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
92 #define JPACKET__UNKNOWN 0
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
93 #define JPACKET__NONE 1
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
94 #define JPACKET__ERROR 2
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
95 #define JPACKET__CHAT 3
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
96 #define JPACKET__GROUPCHAT 4
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
97 #define JPACKET__GET 5
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
98 #define JPACKET__SET 6
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
99 #define JPACKET__RESULT 7
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
100 #define JPACKET__SUBSCRIBE 8
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
101 #define JPACKET__SUBSCRIBED 9
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
102 #define JPACKET__UNSUBSCRIBE 10
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
103 #define JPACKET__UNSUBSCRIBED 11
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
104 #define JPACKET__AVAILABLE 12
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
105 #define JPACKET__UNAVAILABLE 13
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
106 #define JPACKET__PROBE 14
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
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
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
109
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
110 typedef struct jpacket_struct
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
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
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
122 } *jpacket, _jpacket;
417
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
123
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
124 jpacket jpacket_new(xmlnode x); /* Creates a jabber packet from the xmlnode */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
125 jpacket jpacket_reset(jpacket p); /* Resets the jpacket values based on the xmlnode */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
126 int jpacket_subtype(jpacket p); /* Returns the subtype value (looks at xmlnode for it) */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
127
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
128
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
129 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
130 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
131 /* Presence Proxy DB structures & constants */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
132 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
133 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
134 typedef struct ppdb_struct
417
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
135 {
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
136 jid id; /* entry data */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
137 int pri;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
138 xmlnode x;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
139 struct ppdb_struct* user; /* linked list for user@server */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
140 pool p; /* db-level data */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
141 struct ppdb_struct* next;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
142 } _ppdb, *ppdb;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
143
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
144 ppdb ppdb_insert(ppdb db, jid id, xmlnode x); /* Inserts presence into the proxy */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
145 xmlnode ppdb_primary(ppdb db, jid id); /* Fetches the matching primary presence for the id */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
146 void ppdb_free(ppdb db); /* Frees the db and all entries */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
147 xmlnode ppdb_get(ppdb db, jid id); /* Called successively to return each presence xmlnode */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
148 /* for the id and children, returns NULL at the end */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
149
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
150
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
151 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
152 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
153 /* Simple Jabber Rate limit functions */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
154 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
155 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
156 typedef struct jlimit_struct
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
157 {
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
158 char *key;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
159 int start;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
160 int points;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
161 int maxt, maxp;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
162 pool p;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
163 } *jlimit, _jlimit;
417
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
164
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
165 jlimit jlimit_new(int maxt, int maxp);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
166 void jlimit_free(jlimit r);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
167 int jlimit_check(jlimit r, char *key, int points);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
168
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
169
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
170 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
171 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
172 /* Error structures & constants */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
173 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
174 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
175 typedef struct terror_struct
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
176 {
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
177 int code;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
178 char msg[64];
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
179 } terror;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
180
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
181 #define TERROR_BAD (terror){400,"Bad Request"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
182 #define TERROR_AUTH (terror){401,"Unauthorized"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
183 #define TERROR_PAY (terror){402,"Payment Required"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
184 #define TERROR_FORBIDDEN (terror){403,"Forbidden"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
185 #define TERROR_NOTFOUND (terror){404,"Not Found"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
186 #define TERROR_NOTALLOWED (terror){405,"Not Allowed"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
187 #define TERROR_NOTACCEPTABLE (terror){406,"Not Acceptable"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
188 #define TERROR_REGISTER (terror){407,"Registration Required"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
189 #define TERROR_REQTIMEOUT (terror){408,"Request Timeout"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
190 #define TERROR_CONFLICT (terror){409,"Conflict"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
191
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
192 #define TERROR_INTERNAL (terror){500,"Internal Server Error"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
193 #define TERROR_NOTIMPL (terror){501,"Not Implemented"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
194 #define TERROR_EXTERNAL (terror){502,"Remote Server Error"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
195 #define TERROR_UNAVAIL (terror){503,"Service Unavailable"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
196 #define TERROR_EXTTIMEOUT (terror){504,"Remote Server Timeout"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
197 #define TERROR_DISCONNECTED (terror){510,"Disconnected"}
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
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
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
242 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
243 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
244 /* Namespace constants */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
245 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
246 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
247 #define NSCHECK(x,n) (j_strcmp(xmlnode_get_attrib(x,"xmlns"),n) == 0)
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
248
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
249 #define NS_CLIENT "jabber:client"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
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
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
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
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
254 #define NS_REGISTER "jabber:iq:register"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
255 #define NS_ROSTER "jabber:iq:roster"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
256 #define NS_OFFLINE "jabber:x:offline"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
257 #define NS_AGENT "jabber:iq:agent"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
258 #define NS_AGENTS "jabber:iq:agents"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
259 #define NS_DELAY "jabber:x:delay"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
260 #define NS_VERSION "jabber:iq:version"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
261 #define NS_TIME "jabber:iq:time"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
262 #define NS_VCARD "vcard-temp"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
263 #define NS_PRIVATE "jabber:iq:private"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
264 #define NS_SEARCH "jabber:iq:search"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
265 #define NS_OOB "jabber:iq:oob"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
266 #define NS_XOOB "jabber:x:oob"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
267 #define NS_ADMIN "jabber:iq:admin"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
268 #define NS_FILTER "jabber:iq:filter"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
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"
1215
80c095886fb5 Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents: 1158
diff changeset
284
80c095886fb5 Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents: 1158
diff changeset
285 #define NS_CAPS "http://jabber.org/protocol/caps"
987
f47e312560af Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents: 686
diff changeset
286 #define NS_CHATSTATES "http://jabber.org/protocol/chatstates"
1158
c30c315dc447 XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents: 1134
diff changeset
287 #define NS_COMMANDS "http://jabber.org/protocol/commands"
1215
80c095886fb5 Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents: 1158
diff changeset
288 #define NS_MUC "http://jabber.org/protocol/muc"
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
289
417
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
290 #define NS_XDBGINSERT "jabber:xdb:ginsert"
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
291 #define NS_XDBNSLIST "jabber:xdb:nslist"
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
292
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
293 #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
294 #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
295 #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
296
1283
2faf179166f3 Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents: 1282
diff changeset
297 #define NS_XMPP_DELAY "urn:xmpp:delay"
2faf179166f3 Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents: 1282
diff changeset
298 #define NS_XMPP_TIME "urn:xmpp:time"
2faf179166f3 Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents: 1282
diff changeset
299 #define NS_PING "urn:xmpp:ping"
1134
995dde656033 Response to XMPP Ping (XEP-0199)
misc@mandriva.org
parents: 995
diff changeset
300
417
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
301 #define NS_JABBERD_STOREDPRESENCE "http://jabberd.org/ns/storedpresence"
c3ae9251c197 Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents: 403
diff changeset
302 #define NS_JABBERD_HISTORY "http://jabberd.org/ns/history"
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
303
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
304 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
305 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
306 /* Message Types */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
307 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
308 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
309 #define TMSG_NORMAL "normal"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
310 #define TMSG_ERROR "error"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
311 #define TMSG_CHAT "chat"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
312 #define TMSG_GROUPCHAT "groupchat"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
313 #define TMSG_HEADLINE "headline"
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
314
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
315
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
316 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
317 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
318 /* JUtil functions */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
319 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
320 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
321 xmlnode jutil_presnew(int type, char *to, char *status); /* Create a skeleton presence packet */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
322 xmlnode jutil_iqnew(int type, char *ns); /* Create a skeleton iq packet */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
323 xmlnode jutil_msgnew(char *type, char *to, char *subj, char *body);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
324 /* Create a skeleton message packet */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
325 xmlnode jutil_header(char* xmlns, char* server); /* Create a skeleton stream packet */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
326 int jutil_priority(xmlnode x); /* Determine priority of this packet */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
327 void jutil_tofrom(xmlnode x); /* Swaps to/from fields on a packet */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
328 xmlnode jutil_iqresult(xmlnode x); /* Generate a skeleton iq/result, given a iq/query */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
329 char* jutil_timestamp(void); /* Get stringified timestamp */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
330 void jutil_error(xmlnode x, terror E); /* Append an <error> node to x */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
331 void jutil_delay(xmlnode msg, char *reason); /* Append a delay packet to msg */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
332 char* jutil_regkey(char *key, char *seed); /* pass a seed to generate a key, pass the key again to validate (returns it) */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
333
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
334
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
335 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
336 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
337 /* JConn structures & functions */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
338 /* */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
339 /* --------------------------------------------------------- */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
340 #define JCONN_STATE_OFF 0
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
341 #define JCONN_STATE_CONNECTED 1
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
342 #define JCONN_STATE_ON 2
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
343 #define JCONN_STATE_AUTH 3
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
344 #define JCONN_STATE_CONNECTING 4
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
345
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
346 typedef struct jconn_struct
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
347 {
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
348 /* Core structure */
56
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
349 pool p; /* Memory allocation pool */
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
350 int state; /* Connection state flag */
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
351 int cw_state; /* Low level connection state flag */
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
352 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
353 char *server; /* The server we'll connect too */
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
354 int port;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
355 int ssl;
56
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
356 jid user; /* User info */
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
357 char *pass; /* User passwd */
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
358
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
359 /* Stream stuff */
56
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
360 int id; /* id counter for jab_getid() function */
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
361 char idbuf[9]; /* temporary storage for jab_getid() */
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
362 char *sid; /* stream id from server, for digest auth */
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
363 XML_Parser parser; /* Parser instance */
1fa1185346be [/trunk] Changeset 71 by mikael
mikael
parents: 25
diff changeset
364 xmlnode current; /* Current node in parsing instance.. */
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
365
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
366 /* Event callback ptrs */
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
367 void (*on_state)(struct jconn_struct *j, int state);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
368 void (*on_packet)(struct jconn_struct *j, jpacket p);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
369 void (*logger)(struct jconn_struct *j, int inout, const char *p);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
370
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
371 } *jconn, jconn_struct;
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
372
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
373 typedef void (*jconn_state_h)(jconn j, int state);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
374 typedef void (*jconn_packet_h)(jconn j, jpacket p);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
375 typedef void (*jconn_logger)(jconn j, int inout, const char *p);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
376
403
17aa60c6dc63 Allow a different server name than the jid domain name
Mikael Berthe <mikael@lilotux.net>
parents: 56
diff changeset
377 jconn jab_new(char *user, char *pass, char *server, int port, int ssl);
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
378 void jab_delete(jconn j);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
379 void jab_state_handler(jconn j, jconn_state_h h);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
380 void jab_packet_handler(jconn j, jconn_packet_h h);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
381 void jab_logger(jconn j, jconn_logger h);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
382 void jab_start(jconn j);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
383 void jab_stop(jconn j);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
384
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
385 int jab_getfd(jconn j);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
386 jid jab_getjid(jconn j);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
387 char *jab_getsid(jconn j);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
388 char *jab_getid(jconn j);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
389
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
390 void jab_send(jconn j, xmlnode x);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
391 void jab_send_raw(jconn j, const char *str);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
392 void jab_recv(jconn j);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
393 void jab_poll(jconn j, int timeout);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
394
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
395 char *jab_auth(jconn j);
686
98de2d166a11 Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents: 417
diff changeset
396 int jab_auth_mcabber(jconn j, xmlnode x);
25
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
397 char *jab_reg(jconn j);
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
398
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
399 #ifdef __cplusplus
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
400 }
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
401 #endif
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
402
bf3d6e241714 [/trunk] Changeset 41 by mikael
mikael
parents:
diff changeset
403 #endif /* INCL_JABBER_H */