1 /* 2 ** Jabby (a C library for Jabber protocol) 3 ** Copyright (c) 2002 Hubert Soko�owski <who_ami@tlen.pl> 4 ** 5 ** This code is free software; you can redistribute it and/or 6 ** modify it under the terms of the GNU General Public License. 7 ** 8 */ 9 10 #ifndef _JABBY_H_ 11 #define _JABBY_H_ 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #include "../iksemel/iksemel.h" 18 #include <glib.h> 19 20 21 enum netstates 22 { 23 JABBY_NET_OFF, 24 JABBY_NET_CONNECT, 25 JABBY_NET_STREAM, 26 JABBY_NET_REG, 27 JABBY_NET_AUTH, 28 JABBY_NET_ON 29 }; 30 31 typedef struct 32 { 33 iksid *id; 34 gchar *pass; 35 iksparser *parser; 36 enum netstates state; 37 gboolean debug; 38 } jabby_session; 39 40 typedef struct 41 { 42 gchar *jid; 43 gchar *name; 44 gchar *subscription; 45 gchar *group; 46 gchar *ask; 47 } jabby_roster; 48 49 enum jabby_event_type{ 50 JABBY_EVENT_UNKNOWN = 0, 51 JABBY_EVENT_NONE, 52 JABBY_EVENT_ERROR, 53 JABBY_EVENT_MESSAGE, 54 JABBY_EVENT_PRESENCE, 55 JABBY_EVENT_SUBSCRIBE, 56 JABBY_EVENT_SUBSCRIBED, 57 JABBY_EVENT_UNSUBSCRIBE, 58 JABBY_EVENT_UNSUBSCRIBED, 59 JABBY_EVENT_ROSTER_ITEM, 60 JABBY_EVENT_ROSTER_END, 61 JABBY_EVENT_UNAUTHORIZED, 62 JABBY_EVENT_CONNECTION_FAILED, 63 JABBY_EVENT_SEARCH_ITEM, 64 JABBY_EVENT_SEARCH_END, 65 JABBY_EVENT_AGENT, 66 JABBY_EVENT_AGENTS_END, 67 JABBY_EVENT_REGISTERED 68 }; 69 70 enum jabby_presence_type{ 71 JABBY_PRESENCE_UNAVAILABLE = 0, 72 JABBY_PRESENCE_AVAILABLE, 73 JABBY_PRESENCE_CHAT, 74 JABBY_PRESENCE_AWAY, 75 JABBY_PRESENCE_XA, 76 JABBY_PRESENCE_DND, 77 JABBY_PRESENCE_INVISIBLE 78 }; 79 80 enum jabby_message_type{ 81 JABBY_MESSAGE_NORMAL, 82 JABBY_MESSAGE_CHAT, 83 JABBY_MESSAGE_ERROR 84 }; 85 86 typedef struct 87 { 88 gchar *to; 89 } jabby_event_registered; 90 91 typedef struct 92 { 93 gchar *jid; 94 gchar *name; 95 gchar *service; 96 gchar *transport; 97 } jabby_event_agent; 98 99 typedef struct 100 { 101 gchar *message; 102 } jabby_event_error; 103 104 typedef struct 105 { 106 gchar *from; 107 gchar *id; 108 enum jabby_message_type type; 109 gchar *body; 110 gchar *subject; 111 gchar *thread; 112 gchar *error; 113 gchar *delay; 114 } jabby_event_message; 115 116 typedef struct 117 { 118 gchar *from; 119 gchar *status; 120 } jabby_event_subscribe; 121 122 typedef struct 123 { 124 gchar *from; 125 gchar *status; 126 } jabby_event_unsubscribe; 127 128 typedef struct 129 { 130 gchar *from; 131 } jabby_event_subscribed; 132 133 typedef struct 134 { 135 gchar *from; 136 gchar *status; 137 } jabby_event_unsubscribed; 138 139 typedef struct 140 { 141 gchar *from; 142 enum jabby_presence_type type; 143 gchar *message; 144 } jabby_event_presence; 145 146 typedef struct 147 { 148 gchar *id; 149 gchar *first; 150 gchar *last; 151 gchar *nick; 152 gint age; 153 gchar *city; 154 gint population; 155 gint province; 156 gint sex; 157 gint occupation; 158 gint online; 159 } jabby_search_res; 160 161 typedef struct 162 { 163 enum jabby_event_type type; 164 union{ 165 jabby_event_error *error; 166 jabby_event_message *message; 167 jabby_event_subscribe *subscribe; 168 jabby_event_unsubscribe *unsubscribe; 169 jabby_event_subscribed *subscribed; 170 jabby_event_unsubscribed *unsubscribed; 171 jabby_roster *roster; 172 jabby_event_presence *presence; 173 jabby_search_res *search; 174 jabby_event_agent *agent; 175 jabby_event_registered *registered; 176 } event; 177 } jabby_event; 178 179 180 #define JABBY_SEARCH_SEX_NONE 0 181 #define JABBY_SEARCH_SEX_MALE 1 182 #define JABBY_SEARCH_SEX_FEMALE 2 183 #define JABBY_SEARCH_OCCUPATION_NONE 0 184 #define JABBY_SEARCH_OCCUPATION_J1 1 185 #define JABBY_SEARCH_OCCUPATION_J2 2 186 #define JABBY_SEARCH_OCCUPATION_J3 3 187 #define JABBY_SEARCH_OCCUPATION_J4 4 188 #define JABBY_SEARCH_OCCUPATION_J5 5 189 #define JABBY_SEARCH_OCCUPATION_J6 6 190 #define JABBY_SEARCH_OCCUPATION_J7 7 191 #define JABBY_SEARCH_OCCUPATION_J8 8 192 #define JABBY_SEARCH_OCCUPATION_J9 9 193 #define JABBY_SEARCH_OCCUPATION_J10 10 194 #define JABBY_SEARCH_OCCUPATION_J11 11 195 #define JABBY_SEARCH_STATUS_NONE 0 196 #define JABBY_SEARCH_STATUS_YES 1 197 #define JABBY_SEARCH_POPULATION_NONE 0 198 #define JABBY_SEARCH_POPULATION_S1 1 199 #define JABBY_SEARCH_POPULATION_S2 2 200 #define JABBY_SEARCH_POPULATION_S3 3 201 #define JABBY_SEARCH_POPULATION_S4 4 202 #define JABBY_SEARCH_POPULATION_S5 5 203 #define JABBY_SEARCH_PROVINCE_NONE 0 204 #define JABBY_SEARCH_PROVINCE_R1 1 205 #define JABBY_SEARCH_PROVINCE_R2 2 206 #define JABBY_SEARCH_PROVINCE_R3 3 207 #define JABBY_SEARCH_PROVINCE_R4 4 208 #define JABBY_SEARCH_PROVINCE_R5 5 209 #define JABBY_SEARCH_PROVINCE_R6 6 210 #define JABBY_SEARCH_PROVINCE_R7 7 211 #define JABBY_SEARCH_PROVINCE_R8 8 212 #define JABBY_SEARCH_PROVINCE_R9 9 213 #define JABBY_SEARCH_PROVINCE_R10 10 214 #define JABBY_SEARCH_PROVINCE_R11 11 215 #define JABBY_SEARCH_PROVINCE_R12 12 216 #define JABBY_SEARCH_PROVINCE_R13 13 217 #define JABBY_SEARCH_PROVINCE_R14 14 218 #define JABBY_SEARCH_PROVINCE_R15 15 219 #define JABBY_SEARCH_PROVINCE_R16 16 220 221 typedef struct 222 { 223 gchar *id; 224 gchar *first; 225 gchar *last; 226 gint age_min; 227 gint age_max; 228 gchar *city; 229 gint population; 230 gint province; 231 gint sex; 232 gint occupation; 233 gint online; 234 } jabby_search_set; 235 236 /* 237 * 238 * prototypes 239 * 240 */ 241 242 jabby_session *jabby_session_new(gchar *id, gchar *pass); 243 gint jabby_connect(jabby_session *ses); 244 jabby_event *jabby_event_next(jabby_session *ses); 245 void jabby_disconnect(jabby_session *ses); 246 void jabby_get_roster(jabby_session *ses); 247 void jabby_event_free(jabby_event *event); 248 gint jabby_presence(jabby_session *ses, enum jabby_presence_type type, 249 gchar *message, gchar *to); 250 gint jabby_contact_add(jabby_session *ses, gchar *name, gchar *jid, 251 gchar *group); 252 gint jabby_contact_remove(jabby_session *ses, gchar *jid); 253 gint jabby_subscribe_ask(jabby_session *ses, gchar *jid, gchar *status); 254 gint jabby_subscribe_accept(jabby_session *ses, gchar *jid); 255 gint jabby_subscribe_deny(jabby_session *ses, gchar *jid); 256 gint jabby_unsubscribe(jabby_session *ses, gchar *jid); 257 gint jabby_message(jabby_session *ses, gchar *to, gchar *id, gchar *message, 258 gchar *subject, enum jabby_message_type type); 259 void jabby_session_free(jabby_session *ses); 260 void jabby_get_agents(jabby_session *ses); 261 void jabby_register_to(jabby_session *ses, gchar *to, gchar *username, 262 gchar *password); 263 264 /* pubdir search*/ 265 jabby_search_set *jabby_search_set_new(); 266 void jabby_search_set_free(jabby_search_set *search); 267 void jabby_search_wp(jabby_session *ses, jabby_search_set *search); 268 269 /* 270 * 271 * others 272 * 273 */ 274 275 276 #ifdef __cplusplus 277 } 278 #endif 279 280 #endif 281