2 * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
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.
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.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "tcp_connect.h"
28 rploop (GIOChannel *src, GIOCondition cond, gpointer xmpp)
30 hc_xmpp_read_and_parse (xmpp);
38 extern void hc_xmpp_chat_open (hc_xmpp_t *);
41 connect_clicked (GtkWidget *button, gpointer data)
48 server = (char *) gtk_entry_get_text (GTK_ENTRY (entry1));
49 user = (char *) gtk_entry_get_text (GTK_ENTRY (entry2));
50 password = (char *) gtk_entry_get_text (GTK_ENTRY (entry3));
51 xmpp = hc_xmpp_new (hc_xmpp_hook, server, user, password);
52 hc_xmpp_send_stream (xmpp);
53 channel = g_io_channel_unix_new (hc_xmpp_fd (xmpp));
54 g_io_add_watch (channel, G_IO_IN, rploop, xmpp);
55 hc_xmpp_chat_open (xmpp);
64 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
65 vbox = gtk_vbox_new (TRUE, 5);
66 entry1 = gtk_entry_new ();
67 entry2 = gtk_entry_new ();
68 entry3 = gtk_entry_new ();
69 gtk_entry_set_visibility (GTK_ENTRY (entry3), FALSE);
70 button = gtk_button_new_with_label ("Connect");
71 g_signal_connect (G_OBJECT (button), "clicked",
72 G_CALLBACK (connect_clicked), NULL);
73 gtk_container_add (GTK_CONTAINER (window), vbox);
74 gtk_container_add (GTK_CONTAINER (vbox), entry1);
75 gtk_container_add (GTK_CONTAINER (vbox), entry2);
76 gtk_container_add (GTK_CONTAINER (vbox), entry3);
77 gtk_container_add (GTK_CONTAINER (vbox), button);
78 gtk_widget_show_all (window);
82 main (int argc, char **argv)
85 gtk_init (&argc, &argv);
87 loop = g_main_loop_new (g_main_context_default (), TRUE);
89 g_main_loop_run (loop);