b4fe6c339b177d5fc84e4725c58fff096597fb8f
[cascardo/rnetproxy.git] / jabber_server.c
1 /*
2 ** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
3 **  
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2 of the License, or
7 ** (at your option) any later version.
8 **  
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ** GNU General Public License for more details.
13 **  
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 **  
18 */
19
20 #include <gnet.h>
21 #include <glib.h>
22 #include <iksemel.h>
23 #include "jabber.h"
24
25 static void jabber_server_connect (net_hook_t* hook)
26 {
27   g_message ("Connected to jabber server.");
28 }
29
30 static void jabber_server_close (net_hook_t* hook)
31 {
32   g_message ("Server disconnected.");
33 }
34
35 static void jabber_server_write (net_hook_t* hook)
36 {
37   g_message ("Have written bytes to server.");
38 }
39
40 static void jabber_server_read (net_hook_t* hook, gchar* buffer, size_t len)
41 {
42   g_message ("Received response from server.");
43   gnet_conn_write (hook->peer, buffer, len);
44 }
45
46 net_hook_t* jabber_server_hook_new (net_hook_t* client_hook, char* server)
47 {
48   net_hook_t* hook;
49   hook = g_slice_new (net_hook_t);
50   hook->conn = gnet_conn_new (server, 5222, nethook_event, hook);
51   hook->peer = client_hook->conn;
52   hook->server = TRUE;
53   hook->connect = jabber_server_connect;
54   hook->close = jabber_server_close;
55   hook->write = jabber_server_write;
56   hook->read = jabber_server_read;
57   hook->data = NULL; /*iks_stream_new ("jabber:client", hook, jabber_server_parser);*/
58   return hook;
59 }