source: protocols/jabber/jabber.c @ f06894d

Last change on this file since f06894d was f06894d, checked in by Wilmer van der Gaast <wilmer@…>, at 2006-09-20T10:18:56Z

Added some pretty empty files.

  • Property mode set to 100644
File size: 5.0 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#include <glib.h>
25#include <string.h>
26#include <unistd.h>
27#include <ctype.h>
28#include <stdio.h>
29
30#include "xmltree.h"
31#include "bitlbee.h"
32#include "jabber.h"
33
34static void jabber_acc_init( account_t *acc )
35{
36        set_t *s;
37       
38        s = set_add( &acc->set, "port", "5222", set_eval_int, acc );
39        s->flags |= ACC_SET_OFFLINE_ONLY;
40       
41        s = set_add( &acc->set, "priority", "0", set_eval_resprio, acc );
42       
43        s = set_add( &acc->set, "resource", "BitlBee", set_eval_resprio, acc );
44       
45        s = set_add( &acc->set, "server", NULL, set_eval_account, acc );
46        s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY;
47       
48        s = set_add( &acc->set, "ssl", "false", set_eval_bool, acc );
49        s->flags |= ACC_SET_OFFLINE_ONLY;
50       
51        s = set_add( &acc->set, "tls", "try", set_eval_tls, acc );
52        s->flags |= ACC_SET_OFFLINE_ONLY;
53}
54
55static void jabber_login( account_t *acc )
56{
57}
58
59static void jabber_close( struct gaim_connection *gc )
60{
61}
62
63static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )
64{
65}
66
67void jabber_init()
68{
69        struct prpl *ret = g_new0(struct prpl, 1);
70       
71        ret->name = "jabber";
72        ret->login = jabber_login;
73        ret->acc_init = jabber_acc_init;
74        ret->close = jabber_close;
75        ret->send_im = jabber_send_im;
76//      ret->away_states = jabber_away_states;
77//      ret->get_status_string = jabber_get_status_string;
78//      ret->set_away = jabber_set_away;
79//      ret->set_info = jabber_set_info;
80//      ret->get_info = jabber_get_info;
81//      ret->add_buddy = jabber_add_buddy;
82//      ret->remove_buddy = jabber_remove_buddy;
83//      ret->chat_send = jabber_chat_send;
84//      ret->chat_invite = jabber_chat_invite;
85//      ret->chat_leave = jabber_chat_leave;
86//      ret->chat_open = jabber_chat_open;
87//      ret->keepalive = jabber_keepalive;
88//      ret->add_permit = jabber_add_permit;
89//      ret->rem_permit = jabber_rem_permit;
90//      ret->add_deny = jabber_add_deny;
91//      ret->rem_deny = jabber_rem_deny;
92//      ret->send_typing = jabber_send_typing;
93        ret->handle_cmp = g_strcasecmp;
94
95        register_protocol(ret);
96}
97
98static xt_status jabber_end_of_stream( struct xt_node *node, gpointer data )
99{
100        return XT_ABORT;
101}
102
103static xt_status jabber_pkt_misc( struct xt_node *node, gpointer data )
104{
105        printf( "Received unknown packet:\n" );
106        xt_print( node );
107       
108        return XT_HANDLED;
109}
110
111static const struct xt_handler_entry jabber_handlers[] = {
112        { "stream:stream",      "<root>",               jabber_end_of_stream },
113        { "iq",                 "stream:stream",        jabber_pkt_iq },
114        { "message",            "stream:stream",        jabber_pkt_message },
115        { "presence",           "stream:stream",        jabber_pkt_presence },
116        { NULL,                 "stream:stream",        jabber_pkt_misc },
117        { NULL,                 NULL,                   NULL }
118};
119
120#if 0
121int main( int argc, char *argv[] )
122{
123        struct xt_parser *xt = xt_new( NULL );
124        struct xt_node *msg;
125        int i;
126        char buf[512];
127       
128        msg = xt_new_node( "message", NULL, xt_new_node( "body", "blaataap-test", NULL ) );
129        xt_add_child( msg, xt_new_node( "html", NULL, xt_new_node( "body", "<b>blaataap in html</b>", NULL ) ) );
130        xt_add_attr( msg, "xmlns", "jabber:client" );
131        xt_add_attr( xt_find_node( msg->children, "html" ), "xmlns", "html rotte zooi" );
132        printf( "%s\n", xt_to_string( msg ) );
133       
134        while( ( i = read( 0, buf, 512 ) ) > 0 )
135        {
136                if( xt_feed( xt, buf, i ) < 1 )
137                        break;
138        }
139        xt->handlers = jabber_handlers;
140        xt_handle( xt, NULL );
141       
142        xt_cleanup( xt, NULL );
143        printf( "%d\n", xt->root );
144       
145        xt_free( xt );
146}
147#endif
Note: See TracBrowser for help on using the repository browser.