1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/***************************************************************************\
* *
* BitlBee - An IRC to IM gateway *
* Jabber module - Main file *
* *
* Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
\***************************************************************************/
#ifndef _JABBER_H
#define _JABBER_H
#include <glib.h>
#include "xmltree.h"
#include "bitlbee.h"
typedef enum
{
JFLAG_STREAM_STARTED = 1, /* Set when we detected the beginning of the stream
and want to do auth. */
JFLAG_AUTHENTICATED = 2, /* Set when we're successfully authenticatd. */
JFLAG_STREAM_RESTART = 4, /* Set when we want to restart the stream (after
SASL or TLS). */
JFLAG_WAIT_SESSION = 8, /* Set if we sent a <session> tag and need a reply
before we continue. */
JFLAG_WAIT_BIND = 16, /* ... for <bind> tag. */
JFLAG_WANT_TYPING = 32, /* Set if we ever sent a typing notification, this
activates all XEP-85 related code. */
} jabber_flags_t;
typedef enum
{
JBFLAG_PROBED_XEP85 = 1, /* Set this when we sent our probe packet to make
sure it gets sent only once. */
JBFLAG_DOES_XEP85 = 2, /* Set this when the resource seems to support
XEP85 (typing notification shite). */
} jabber_buddy_flag_t;
struct jabber_data
{
struct gaim_connection *gc;
int fd;
void *ssl;
char *txq;
int tx_len;
int r_inpa, w_inpa;
struct xt_parser *xt;
jabber_flags_t flags;
char *username; /* USERNAME@server */
char *server; /* username@SERVER -=> server/domain, not hostname */
/* After changing one of these two (or the priority setting), call
presence_send_update() to inform the server about the changes. */
struct jabber_away_state *away_state;
char *away_message;
GHashTable *node_cache;
GHashTable *buddies;
};
struct jabber_away_state
{
char code[5];
char *full_name;
};
typedef xt_status (*jabber_cache_event) ( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
struct jabber_cache_entry
{
struct xt_node *node;
jabber_cache_event func;
};
struct jabber_buddy
{
char *handle;
char *full_jid;
char *resource;
int priority;
struct jabber_away_state *away_state;
char *away_message;
time_t last_act;
int flags;
struct jabber_buddy *next;
};
/* iq.c */
xt_status jabber_pkt_iq( struct xt_node *node, gpointer data );
int jabber_init_iq_auth( struct gaim_connection *gc );
xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
int jabber_get_roster( struct gaim_connection *gc );
int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name );
int jabber_remove_from_roster( struct gaim_connection *gc, char *handle );
/* message.c */
xt_status jabber_pkt_message( struct xt_node *node, gpointer data );
/* presence.c */
xt_status jabber_pkt_presence( struct xt_node *node, gpointer data );
int presence_send_update( struct gaim_connection *gc );
int presence_send_request( struct gaim_connection *gc, char *handle, char *request );
/* jabber_util.c */
char *set_eval_priority( set_t *set, char *value );
char *set_eval_tls( set_t *set, char *value );
struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_node *children );
struct xt_node *jabber_make_error_packet( struct xt_node *orig, char *err_cond, char *err_type );
void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func );
struct xt_node *jabber_cache_get( struct gaim_connection *gc, char *id );
void jabber_cache_entry_free( gpointer entry );
void jabber_cache_clean( struct gaim_connection *gc );
const struct jabber_away_state *jabber_away_state_by_code( char *code );
const struct jabber_away_state *jabber_away_state_by_name( char *name );
void jabber_buddy_ask( struct gaim_connection *gc, char *handle );
struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_jid );
struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid );
int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid );
int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid );
extern const struct jabber_away_state jabber_away_state_list[];
/* io.c */
int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node );
int jabber_write( struct gaim_connection *gc, char *buf, int len );
gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond );
gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond );
gboolean jabber_start_stream( struct gaim_connection *gc );
void jabber_end_stream( struct gaim_connection *gc );
/* sasl.c */
xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data );
xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data );
xt_status sasl_pkt_result( struct xt_node *node, gpointer data );
gboolean sasl_supported( struct gaim_connection *gc );
#endif
|