]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-account-widget-sip.c
Remove most SIP settings since they are impossible to understand.
[empathy.git] / libempathy-gtk / empathy-account-widget-sip.c
1 /*
2  * Copyright (C) 2007-2008 Guillaume Desmottes
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  * Authors: Guillaume Desmottes <gdesmott@gnome.org>
19  *          Frederic Peters <fpeters@0d.be>
20  */
21
22 #include "config.h"
23
24 #include <stdlib.h>
25 #include <string.h>
26 #include <sys/stat.h>
27
28 #include <glib/gi18n.h>
29 #include <gtk/gtk.h>
30 #include <glade/glade.h>
31
32 #include <libmissioncontrol/mc-account.h>
33 #include <libmissioncontrol/mc-protocol.h>
34
35 #include <libempathy/empathy-utils.h>
36 #include <libempathy/empathy-debug.h>
37
38 #include "empathy-account-widget.h"
39 #include "empathy-account-widget-sip.h"
40 #include "empathy-ui-utils.h"
41
42 #define DEBUG_DOMAIN "AccountWidgetSIP"
43
44 typedef struct {
45   McAccount *account;
46
47   GtkWidget *vbox_settings;
48
49   GtkWidget *entry_stun_server;
50   GtkWidget *spinbutton_stun_part;
51   GtkWidget *checkbutton_discover_stun;
52 } EmpathyAccountWidgetSip;
53
54 static void
55 account_widget_sip_destroy_cb (GtkWidget *widget,
56                                EmpathyAccountWidgetSip *settings)
57 {
58   g_object_unref (settings->account);
59   g_slice_free (EmpathyAccountWidgetSip, settings);
60 }
61
62 static void
63 account_widget_sip_discover_stun_toggled_cb (
64     GtkWidget *checkbox,
65     EmpathyAccountWidgetSip *settings)
66 {
67   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox))) {
68     gtk_widget_set_sensitive(settings->entry_stun_server, TRUE);
69     gtk_widget_set_sensitive(settings->spinbutton_stun_part, TRUE);
70   } else {
71     gtk_widget_set_sensitive(settings->entry_stun_server, FALSE);
72     gtk_widget_set_sensitive(settings->spinbutton_stun_part, FALSE);
73   }
74 }
75
76 /**
77  * empathy_account_widget_sip_new:
78  * @account: the #McAccount to configure
79  *
80  * Creates a new SIP account widget to configure a given #McAccount
81  *
82  * Returns: The toplevel container of the configuration widget
83  */
84 GtkWidget *
85 empathy_account_widget_sip_new (McAccount *account)
86 {
87   EmpathyAccountWidgetSip *settings;
88   GladeXML *glade;
89   gchar *filename;
90
91   settings = g_slice_new0 (EmpathyAccountWidgetSip);
92   settings->account = g_object_ref (account);
93
94   filename = empathy_file_lookup ("empathy-account-widget-sip.glade",
95       "libempathy-gtk");
96   glade = empathy_glade_get_file (filename,
97       "vbox_sip_settings",
98       NULL,
99       "vbox_sip_settings", &settings->vbox_settings,
100       "entry_stun-server", &settings->entry_stun_server,
101       "spinbutton_stun-port", &settings->spinbutton_stun_part,
102       "checkbutton_discover-stun", &settings->checkbutton_discover_stun,
103       NULL);
104   g_free (filename);
105
106   empathy_account_widget_handle_params (account, glade,
107       "entry_userid", "account",
108       "entry_password", "password",
109       "checkbutton_discover-stun", "discover-stun",
110       "entry_stun-server", "stun-server",
111       "spinbutton_stun-port", "stun-port",
112       NULL);
113
114   empathy_account_widget_add_forget_button (account, glade,
115                                             "button_forget",
116                                             "entry_password");
117
118   account_widget_sip_discover_stun_toggled_cb (settings->checkbutton_discover_stun,
119                                                settings);
120
121   empathy_glade_connect (glade, settings,
122       "vbox_sip_settings", "destroy", account_widget_sip_destroy_cb,
123       "checkbutton_discover-stun", "toggled", account_widget_sip_discover_stun_toggled_cb,
124       NULL);
125
126   g_object_unref (glade);
127
128   return settings->vbox_settings;
129 }