source: protocols/jabber/jabber.h @ 6a1128d

Last change on this file since 6a1128d was 6a1128d, checked in by Wilmer van der Gaast <wilmer@…>, at 2006-10-09T18:19:05Z

The module now keeps track of all resources available for a buddy. This
means the buddy won't show up offline when one resource goes down (while
there are still others available). It also remembers away state
information for every separate resource. Later this system will be used
to keep track of client capability information (Typing notices, yay...)
and who knows what else.

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