2
/* GnomeMeeting -- A Video-Conferencing application
3
* Copyright (C) 2000-2006 Damien Sandras
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* GnomeMeeting is licensed under the GPL license and as a special exception,
21
* you have permission to link or otherwise combine this program with the
22
* programs OpenH323 and Pwlib, and distribute the combination, without
23
* applying the requirements of the GNU GPL to the OpenH323 program, as long
24
* as you do follow the requirements of the GNU GPL for all the rest of the
25
* software thus combined.
30
* accounts.cpp - description
31
* ----------------------------
32
* begin : Sun Feb 13 2005
33
* copyright : (C) 2000-2006 by Damien Sandras
34
* description : This file contains all the functions needed to
35
* manipulate H323/SIP/... provider accounts.
39
#include "../../config.h"
42
#include "callbacks.h"
45
#include "preferences.h"
57
typedef struct GmAccountsEditWindow_ {
59
GtkWidget *account_entry;
60
GtkWidget *protocol_option_menu;
61
GtkWidget *host_label;
62
GtkWidget *host_entry;
63
GtkWidget *username_entry;
64
GtkWidget *auth_username_label;
65
GtkWidget *auth_username_entry;
66
GtkWidget *password_entry;
67
GtkWidget *domain_label;
68
GtkWidget *domain_entry;
69
GtkWidget *timeout_entry;
71
} GmAccountsEditWindow;
73
#define GM_ACCOUNTS_EDIT_WINDOW(x) (GmAccountsEditWindow *) (x)
75
typedef struct GmAccountsWindow_ {
77
GtkWidget *accounts_list;
78
GtkWidget *delete_button;
79
GtkWidget *edit_button;
80
GtkWidget *default_button;
84
#define GM_ACCOUNTS_WINDOW(x) (GmAccountsWindow *) (x)
90
* BEHAVIOR : Returns a GmAccount from its string representation.
93
static GmAccount *gm_aw_from_string_to_account (gchar *);
97
* BEHAVIOR : Returns a string representing a GmAccount.
100
static gchar *gm_aw_from_account_to_string (GmAccount *);
106
* BEHAVIOR : Frees a GmAccountsWindow and its content.
107
* PRE : A non-NULL pointer to a GmAccountsWindow structure.
109
static void gm_aw_destroy (gpointer);
113
* BEHAVIOR : Returns a pointer to the private GmAccountsWindow structure
114
* used by the preferences window GMObject.
115
* PRE : The given GtkWidget pointer must be a preferences window
118
static GmAccountsWindow *gm_aw_get_aw (GtkWidget *);
122
* BEHAVIOR : Creates and run a dialog where the user can edit a new
123
* or an already selected account. It also checks if all
124
* required parameters are present, and once a valid choice
125
* has been entered and validated, it is added/modified in
126
* the accounts database.
127
* PRE : The GmAccount is a valid pointer to a valid GmAccount
128
* that we are editing. If it is NULL, it means we
129
* are creating a new account.
131
static void gm_aw_edit_account_dialog_run (GtkWidget *accounts_window,
133
GtkWidget *parent_window);
137
* BEHAVIOR : Creates and run a dialog asking to the user if he wants
138
* to delete the given account.
139
* PRE : The GmAccount is a valid pointer to a valid GmAccount
140
* that we are editing. If can not be NULL.
142
static void gm_aw_delete_account_dialog_run (GtkWidget *accounts_window,
144
GtkWidget *parent_window);
148
* BEHAVIOR : Returns the currently selected account in the main window.
152
static GmAccount *gm_aw_get_selected_account (GtkWidget *accounts_window);
157
/* DESCRIPTION : This callback is called when the user clicks
158
* on an account in the accounts window or when
159
* there is an event_after.
160
* BEHAVIOR : It updates the accounts window buttons sensitivity.
161
* PRE : data is a valid pointer to the GmAccountsWindow.
163
static gint account_clicked_cb (GtkWidget *w,
168
/* DESCRIPTION : This callback is called when the user clicks
169
* on an account to enable it in the accounts window.
170
* BEHAVIOR : It updates the accounts list configuration to enable/disable
171
* the account. It also calls the Register operation from
172
* the GMManager to refresh the status of that account.
175
static void account_toggled_cb (GtkCellRendererToggle *cell,
180
/* DESCRIPTION : This callback is called when the user chooses to add
182
* BEHAVIOR : It runs the edit account dialog until the user validates
183
* it with correct data.
186
static void add_account_cb (GtkWidget *button,
190
/* DESCRIPTION : This callback is called when the user chooses to edit
192
* BEHAVIOR : It runs the edit account dialog until the user validates
193
* it with correct data.
196
static void edit_account_cb (GtkWidget *button,
200
/* DESCRIPTION : This callback is called when the user chooses to set
201
* an account as default.
202
* BEHAVIOR : It sets it as default, only one default at a time.
205
static void set_account_as_default_cb (GtkWidget *button,
209
/* DESCRIPTION : This callback is called when the user chooses to delete
211
* BEHAVIOR : It runs the delete account dialog until the user validates
215
static void delete_account_cb (GtkWidget *button,
219
/* DESCRIPTION : This callback is called when the user changes the protocol
220
* in the account dialog.
221
* BEHAVIOR : Updates the content and labels.
222
* PRE : data is a valid pointer to a valid GmAccountWindow.
224
static void account_dialog_protocol_changed_cb (GtkWidget *menu,
228
/* Columns for the VoIP accounts */
231
COLUMN_ACCOUNT_WEIGHT,
232
COLUMN_ACCOUNT_ENABLED,
233
COLUMN_ACCOUNT_DEFAULT,
235
COLUMN_ACCOUNT_ACCOUNT_NAME,
236
COLUMN_ACCOUNT_PROTOCOL_NAME,
238
COLUMN_ACCOUNT_DOMAIN,
239
COLUMN_ACCOUNT_USERNAME,
240
COLUMN_ACCOUNT_AUTH_USERNAME,
241
COLUMN_ACCOUNT_PASSWORD,
242
COLUMN_ACCOUNT_STATE,
243
COLUMN_ACCOUNT_TIMEOUT,
244
COLUMN_ACCOUNT_METHOD,
245
COLUMN_ACCOUNT_VOICEMAILS,
246
COLUMN_ACCOUNT_ERROR_MESSAGE,
247
COLUMN_ACCOUNT_ACTIVATABLE,
248
COLUMN_ACCOUNT_NUMBER
254
gm_aw_from_string_to_account (gchar *str)
256
GmAccount *account = NULL;
258
gchar **couple = NULL;
262
g_return_val_if_fail (str != NULL, NULL);
264
couple = g_strsplit (str, "|", 0);
268
while (couple [size])
272
account = gm_account_new ();
274
if (size >= 1 && couple [0])
275
account->enabled = atoi (couple [0]);
276
if (size >= 2 && couple [1])
277
account->default_account = atoi (couple [1]);
278
if (size >= 3 && couple [2])
279
account->aid = g_strdup (couple [2]);
280
if (size >= 4 && couple [3])
281
account->account_name = g_strdup (couple [3]);
282
if (size >= 5 && couple [4])
283
account->protocol_name = g_strdup (couple [4]);
284
if (size >= 6 && couple [5])
285
account->host = g_strdup (couple [5]);
286
if (size >= 7 && couple [6])
287
account->domain = g_strdup (couple [6]);
288
if (size >= 8 && couple [7])
289
account->username = g_strdup (couple [7]);
290
if (size >= 9 && couple [8])
291
account->auth_username = g_strdup (couple [8]);
292
if (size >= 10 && couple [9])
293
account->password = g_strdup (couple [9]);
294
if (size >= 11 && couple [10])
295
account->timeout = atoi (couple [10]);
296
if (size >= 12 && couple [11])
297
account->method = atoi (couple [11]);
307
gm_aw_from_account_to_string (GmAccount *account)
309
g_return_val_if_fail (account != NULL, NULL);
311
return g_strdup_printf ("%d|%d|%s|%s|%s|%s|%s|%s|%s|%s|%d|%d",
313
account->default_account,
315
account->account_name,
316
account->protocol_name,
320
account->auth_username,
329
gm_aw_destroy (gpointer aw)
331
g_return_if_fail (aw != NULL);
333
delete ((GmAccountsWindow *) aw);
337
static GmAccountsWindow *
338
gm_aw_get_aw (GtkWidget *accounts_window)
340
g_return_val_if_fail (accounts_window != NULL, NULL);
342
return GM_ACCOUNTS_WINDOW (g_object_get_data (G_OBJECT (accounts_window), "GMObject"));
347
gm_aw_edit_account_dialog_run (GtkWidget *accounts_window,
349
GtkWidget *parent_window)
351
GtkWidget *dialog = NULL;
353
GtkWidget *expander = NULL;
355
GtkSizeGroup *size_group_label = NULL;
356
GtkSizeGroup *size_group_entry = NULL;
358
GtkWidget *table = NULL;
359
GtkWidget *label = NULL;
361
PRegularExpression regex ("^[a-z0-9][-._a-z0-9 ]*$",
362
PRegularExpression::IgnoreCase);
365
PString auth_username;
369
PString account_name;
372
gchar *timeout_string = NULL;
376
gboolean valid = FALSE;
377
gboolean is_editing = FALSE;
379
GmAccountsEditWindow *aew = NULL;
381
is_editing = (account != NULL);
384
aew = new GmAccountsEditWindow ();
386
gtk_dialog_new_with_buttons (_("Edit the Account Information"),
389
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
390
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
392
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
393
GTK_RESPONSE_ACCEPT);
394
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
395
gtk_window_set_transient_for (GTK_WINDOW (dialog),
396
GTK_WINDOW (parent_window));
398
size_group_entry = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
399
size_group_label = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
401
table = gtk_table_new (7, 2, FALSE);
402
gtk_table_set_row_spacings (GTK_TABLE (table), 3);
403
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
404
gtk_container_set_border_width (GTK_CONTAINER (table), 12);
405
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), table);
409
label = gtk_label_new (_("Account Name:"));
410
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
411
aew->account_entry = gtk_entry_new ();
412
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);
413
gtk_table_attach_defaults (GTK_TABLE (table), aew->account_entry, 1, 2, 0, 1);
414
gtk_entry_set_activates_default (GTK_ENTRY (aew->account_entry), TRUE);
415
if (account && account->account_name)
416
gtk_entry_set_text (GTK_ENTRY (aew->account_entry), account->account_name);
421
label = gtk_label_new (_("Protocol:"));
422
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
423
gtk_label_set_mnemonic_widget (GTK_LABEL (label), aew->protocol_option_menu);
425
aew->protocol_option_menu = gtk_combo_box_new_text ();
426
gtk_combo_box_append_text (GTK_COMBO_BOX (aew->protocol_option_menu), "SIP");
427
gtk_combo_box_append_text (GTK_COMBO_BOX (aew->protocol_option_menu), "H323");
428
gtk_combo_box_set_active (GTK_COMBO_BOX (aew->protocol_option_menu), 0);
430
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
431
gtk_table_attach_defaults (GTK_TABLE (table), aew->protocol_option_menu,
434
g_signal_connect (GTK_COMBO_BOX (aew->protocol_option_menu),
436
G_CALLBACK (account_dialog_protocol_changed_cb),
441
if (!account || !strcmp (account->protocol_name, "SIP"))
442
aew->host_label = gtk_label_new (_("Registrar:"));
444
aew->host_label = gtk_label_new (_("Gatekeeper:"));
445
gtk_misc_set_alignment (GTK_MISC (aew->host_label), 0.0, 0.5);
446
aew->host_entry = gtk_entry_new ();
447
gtk_size_group_add_widget (size_group_label, aew->host_label);
448
gtk_size_group_add_widget (size_group_entry, aew->host_entry);
449
gtk_table_attach_defaults (GTK_TABLE (table), aew->host_label, 0, 1, 2, 3);
450
gtk_table_attach_defaults (GTK_TABLE (table), aew->host_entry, 1, 2, 2, 3);
451
gtk_entry_set_activates_default (GTK_ENTRY (aew->host_entry), TRUE);
452
if (account && account->host)
453
gtk_entry_set_text (GTK_ENTRY (aew->host_entry), account->host);
456
label = gtk_label_new (_("User Name:"));
457
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
458
aew->username_entry = gtk_entry_new ();
459
gtk_size_group_add_widget (size_group_label, label);
460
gtk_size_group_add_widget (size_group_entry, aew->username_entry);
461
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5);
462
gtk_table_attach_defaults (GTK_TABLE (table), aew->username_entry,
464
gtk_entry_set_activates_default (GTK_ENTRY (aew->username_entry), TRUE);
465
if (account && account->username)
466
gtk_entry_set_text (GTK_ENTRY (aew->username_entry), account->username);
469
label = gtk_label_new (_("Password:"));
470
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
471
aew->password_entry = gtk_entry_new ();
472
gtk_size_group_add_widget (size_group_label, label);
473
gtk_size_group_add_widget (size_group_entry, aew->password_entry);
474
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 5, 6);
475
gtk_table_attach_defaults (GTK_TABLE (table), aew->password_entry,
477
gtk_entry_set_activates_default (GTK_ENTRY (aew->password_entry), TRUE);
478
gtk_entry_set_visibility (GTK_ENTRY (aew->password_entry), FALSE);
479
if (account && account->password)
480
gtk_entry_set_text (GTK_ENTRY (aew->password_entry), account->password);
483
/* Advanced Options */
484
expander = gtk_expander_new_with_mnemonic (_("More _Options"));
485
gtk_table_attach_defaults (GTK_TABLE (table), expander, 0, 2, 6, 7);
487
table = gtk_table_new (3, 2, FALSE);
488
gtk_table_set_row_spacings (GTK_TABLE (table), 3);
489
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
490
gtk_container_set_border_width (GTK_CONTAINER (table), 0);
491
gtk_container_add (GTK_CONTAINER (expander), table);
494
if (!account || !strcmp (account->protocol_name, "SIP")) {
496
aew->auth_username_label = gtk_label_new (_("Authentication Login:"));
497
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
498
aew->auth_username_entry = gtk_entry_new ();
499
gtk_size_group_add_widget (size_group_label, aew->auth_username_label);
500
gtk_size_group_add_widget (size_group_entry, aew->auth_username_entry);
501
gtk_table_attach_defaults (GTK_TABLE (table), aew->auth_username_label,
503
gtk_table_attach_defaults (GTK_TABLE (table), aew->auth_username_entry,
505
gtk_entry_set_activates_default (GTK_ENTRY (aew->auth_username_entry),
507
if (account && account->auth_username)
508
gtk_entry_set_text (GTK_ENTRY (aew->auth_username_entry),
509
account->auth_username);
513
if (!account || !strcmp (account->protocol_name, "SIP"))
514
aew->domain_label = gtk_label_new (_("Realm/Domain:"));
516
aew->domain_label = gtk_label_new (_("Gatekeeper ID:"));
517
gtk_misc_set_alignment (GTK_MISC (aew->domain_label), 0.0, 0.5);
518
aew->domain_entry = gtk_entry_new ();
519
gtk_size_group_add_widget (size_group_label, aew->domain_label);
520
gtk_size_group_add_widget (size_group_entry, aew->domain_entry);
521
gtk_table_attach_defaults (GTK_TABLE (table), aew->domain_label, 0, 1, 1, 2);
522
gtk_table_attach_defaults (GTK_TABLE (table), aew->domain_entry, 1, 2, 1, 2);
523
gtk_entry_set_activates_default (GTK_ENTRY (aew->domain_entry), TRUE);
524
if (account && account->domain)
525
gtk_entry_set_text (GTK_ENTRY (aew->domain_entry), account->domain);
528
label = gtk_label_new (_("Registration Timeout:"));
529
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
530
aew->timeout_entry = gtk_entry_new ();
531
gtk_size_group_add_widget (size_group_label, label);
532
gtk_size_group_add_widget (size_group_entry, aew->timeout_entry);
533
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
534
gtk_table_attach_defaults (GTK_TABLE (table), aew->timeout_entry,
536
gtk_entry_set_activates_default (GTK_ENTRY (aew->timeout_entry), TRUE);
538
timeout_string = g_strdup_printf ("%d", account->timeout);
540
timeout_string = g_strdup ("3600");
541
gtk_entry_set_text (GTK_ENTRY (aew->timeout_entry), timeout_string);
542
g_free (timeout_string);
545
gtk_widget_show_all (dialog);
548
switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
550
case GTK_RESPONSE_ACCEPT:
552
username = gtk_entry_get_text (GTK_ENTRY (aew->username_entry));
553
if (aew->auth_username_entry)
554
auth_username = gtk_entry_get_text (GTK_ENTRY (aew->auth_username_entry));
555
account_name = gtk_entry_get_text (GTK_ENTRY (aew->account_entry));
556
host = gtk_entry_get_text (GTK_ENTRY (aew->host_entry));
557
password = gtk_entry_get_text (GTK_ENTRY (aew->password_entry));
558
domain = gtk_entry_get_text (GTK_ENTRY (aew->domain_entry));
559
timeout = gtk_entry_get_text (GTK_ENTRY (aew->timeout_entry));
562
protocol = // take it from the menu
563
gtk_combo_box_get_active (GTK_COMBO_BOX (aew->protocol_option_menu));
564
else // take it from the existing account field
565
protocol = (account->protocol_name
566
&& !strcmp (account->protocol_name, "SIP") ? 0 : 1);
568
/* Check at least an account name, registrar,
569
* and username are provided */
570
if (protocol == 0) // SIP
571
valid = (username.FindRegEx (regex) != P_MAX_INDEX
572
&& account_name.FindRegEx (regex) != P_MAX_INDEX);
574
valid = (account_name.FindRegEx (regex) != P_MAX_INDEX);
579
account = gm_account_new ();
581
g_free (account->username);
582
g_free (account->auth_username);
583
g_free (account->account_name);
584
g_free (account->host);
585
g_free (account->password);
586
g_free (account->domain);
588
g_free (account->protocol_name);
590
account->account_name = g_strdup (account_name);
591
account->host = g_strdup (host);
592
account->username = g_strdup (username);
594
if (!strcmp (domain, ""))
595
if (protocol == 0) // SIP
596
account->domain = g_strdup (host);
598
account->domain = g_strdup ("");
600
account->domain = g_strdup (domain);
602
if (!strcmp (auth_username, ""))
603
account->auth_username = g_strdup (username);
605
account->auth_username = g_strdup (auth_username);
607
account->password = g_strdup (password);
608
if (atoi (timeout) == 0)
609
account->timeout = 3600;
611
account->timeout = PMAX (atoi (timeout), 25);
614
account->protocol_name = g_strdup ((protocol == 0) ? "SIP" : "H323");
616
/* The GUI will be updated through the GmConf notifiers */
618
gnomemeeting_account_modify (account);
620
gnomemeeting_account_add (account);
623
if (protocol == 0) // SIP
624
gnomemeeting_error_dialog (GTK_WINDOW (dialog), _("Missing information"), _("Please make sure to provide a valid account name, host name, and user name."));
626
gnomemeeting_error_dialog (GTK_WINDOW (dialog), _("Missing information"), _("Please make sure to provide a valid account name, host name and registration timeout."));
630
case GTK_RESPONSE_REJECT:
636
delete ((GmAccountsEditWindow *) aew);
637
gtk_widget_destroy (dialog);
642
gm_aw_delete_account_dialog_run (GtkWidget *accounts_window,
644
GtkWidget *parent_window)
646
GtkWidget *dialog = NULL;
648
gchar *confirm_msg = NULL;
650
g_return_if_fail (accounts_window != NULL);
651
g_return_if_fail (account != NULL);
653
/* Create the dialog to delete the account */
655
g_strdup_printf (_("Are you sure you want to delete account %s?"),
656
account->account_name);
658
gtk_message_dialog_new (GTK_WINDOW (accounts_window),
659
GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
660
GTK_BUTTONS_YES_NO, confirm_msg);
661
g_free (confirm_msg);
663
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
666
gtk_widget_show_all (dialog);
669
/* Now run the dialg */
670
switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
672
case GTK_RESPONSE_YES:
674
/* The GUI will be updated throught the GmConf notifiers */
675
gnomemeeting_account_delete (account);
679
gtk_widget_destroy (dialog);
684
gm_aw_get_selected_account (GtkWidget *accounts_window)
686
GmAccountsWindow *aw = NULL;
688
GtkTreeModel *model = NULL;
689
GtkTreeSelection *selection = NULL;
692
GmAccount *account = NULL;
694
g_return_val_if_fail (accounts_window != NULL, NULL);
696
/* Get the required data */
697
aw = gm_aw_get_aw (accounts_window);
699
g_return_val_if_fail (aw != NULL, NULL);
701
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->accounts_list));
702
model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->accounts_list));
704
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
706
account = gm_account_new ();
708
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
709
COLUMN_ACCOUNT_ENABLED, &account->enabled,
710
COLUMN_ACCOUNT_DEFAULT, &account->default_account,
711
COLUMN_ACCOUNT_AID, &account->aid,
712
COLUMN_ACCOUNT_ACCOUNT_NAME, &account->account_name,
713
COLUMN_ACCOUNT_PROTOCOL_NAME, &account->protocol_name,
714
COLUMN_ACCOUNT_HOST, &account->host,
715
COLUMN_ACCOUNT_DOMAIN, &account->domain,
716
COLUMN_ACCOUNT_USERNAME, &account->username,
717
COLUMN_ACCOUNT_AUTH_USERNAME, &account->auth_username,
718
COLUMN_ACCOUNT_PASSWORD, &account->password,
719
COLUMN_ACCOUNT_TIMEOUT, &account->timeout,
720
COLUMN_ACCOUNT_METHOD, &account->method,
723
if (account->timeout == 0)
724
account->timeout = 3600;
733
account_clicked_cb (GtkWidget *w,
737
GmAccount *account = NULL;
738
GmAccountsWindow *aw = NULL;
740
g_return_val_if_fail (data != NULL, FALSE);
742
aw = gm_aw_get_aw (GTK_WIDGET (data));
743
g_return_val_if_fail (aw != NULL, FALSE);
745
account = gm_aw_get_selected_account (GTK_WIDGET (data));
749
gtk_widget_set_sensitive (aw->delete_button, TRUE);
750
gtk_widget_set_sensitive (aw->edit_button, TRUE);
751
if (!account->default_account)
752
gtk_widget_set_sensitive (aw->default_button, TRUE);
754
gtk_widget_set_sensitive (aw->default_button, FALSE);
756
gm_account_delete (account);
760
gtk_widget_set_sensitive (aw->delete_button, FALSE);
761
gtk_widget_set_sensitive (aw->edit_button, FALSE);
762
gtk_widget_set_sensitive (aw->default_button, FALSE);
770
account_toggled_cb (GtkCellRendererToggle *cell,
774
GMManager *ep = NULL;
776
GmAccountsWindow *aw = NULL;
777
GmAccount *account = NULL;
779
GtkTreePath *path = NULL;
780
GtkTreeSelection *selection = NULL;
782
GtkWidget *accounts_window = NULL;
784
accounts_window = GnomeMeeting::Process ()->GetAccountsWindow ();
785
ep = GnomeMeeting::Process ()->GetManager ();
787
aw = gm_aw_get_aw (accounts_window);
790
/* Make sure the toggled row is selected */
791
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->accounts_list));
792
path = gtk_tree_path_new_from_string (path_str);
793
gtk_tree_selection_select_path (selection, path);
794
gtk_tree_path_free (path);
796
/* Update the config */
797
account = gm_aw_get_selected_account (accounts_window);
798
gnomemeeting_account_toggle_active (account);
800
/* Update the account */
801
gdk_threads_leave ();
802
ep->Register (account);
803
gdk_threads_enter ();
805
gm_account_delete (account);
810
add_account_cb (GtkWidget *button,
813
GtkWidget *accounts_window = NULL;
815
accounts_window = GnomeMeeting::Process ()->GetAccountsWindow ();
817
gm_aw_edit_account_dialog_run (GTK_WIDGET (accounts_window),
819
GTK_WIDGET (accounts_window));
824
edit_account_cb (GtkWidget *button,
827
GmAccount *account = NULL;
828
GtkWidget *accounts_window = NULL;
830
accounts_window = GnomeMeeting::Process ()->GetAccountsWindow ();
832
account = gm_aw_get_selected_account (accounts_window);
833
gm_aw_edit_account_dialog_run (GTK_WIDGET (accounts_window),
835
GTK_WIDGET (accounts_window));
836
gm_account_delete (account);
841
set_account_as_default_cb (GtkWidget *button,
844
GmAccount *account = NULL;
845
GtkWidget *accounts_window = NULL;
847
accounts_window = GnomeMeeting::Process ()->GetAccountsWindow ();
849
account = gm_aw_get_selected_account (accounts_window);
850
gnomemeeting_account_set_default (account, TRUE);
851
gm_account_delete (account);
856
delete_account_cb (GtkWidget *button,
859
GmAccount *account = NULL;
860
GtkWidget *accounts_window = NULL;
862
accounts_window = GnomeMeeting::Process ()->GetAccountsWindow ();
864
account = gm_aw_get_selected_account (accounts_window);
866
gm_aw_delete_account_dialog_run (GTK_WIDGET (accounts_window),
868
GTK_WIDGET (accounts_window));
869
gm_account_delete (account);
874
account_dialog_protocol_changed_cb (GtkWidget *menu,
877
GmAccountsEditWindow *aew = NULL;
879
g_return_if_fail (data != NULL);
881
aew = GM_ACCOUNTS_EDIT_WINDOW (data);
883
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (aew->protocol_option_menu)))
886
gtk_label_set_text (GTK_LABEL (aew->host_label), _("Registrar:"));
887
gtk_label_set_text (GTK_LABEL (aew->domain_label), _("Realm/Domain:"));
888
gtk_widget_show (aew->auth_username_label);
889
gtk_widget_show (aew->auth_username_entry);
893
gtk_label_set_text (GTK_LABEL (aew->host_label), _("Gatekeeper:"));
894
gtk_label_set_text (GTK_LABEL (aew->domain_label), _("Gatekeeper ID:"));
895
gtk_widget_hide (aew->auth_username_label);
896
gtk_widget_hide (aew->auth_username_entry);
902
/* Implementation of public functions */
906
GmAccount *account = NULL;
908
account = g_new (GmAccount, 1);
910
account->aid = g_strdup (OpalGloballyUniqueID ().AsString ());
911
account->account_name = NULL;
912
account->protocol_name = NULL;
913
account->host = NULL;
914
account->domain = NULL;
915
account->username = NULL;
916
account->auth_username = NULL;
917
account->password = NULL;
918
account->enabled = FALSE;
919
account->default_account = FALSE;
920
account->timeout = 3600;
928
gm_account_delete (GmAccount *account)
933
g_free (account->aid);
934
g_free (account->account_name);
935
g_free (account->protocol_name);
936
g_free (account->domain);
937
g_free (account->auth_username);
938
g_free (account->username);
939
g_free (account->password);
940
g_free (account->host);
947
gm_account_copy (GmAccount *a)
949
GmAccount *account = NULL;
954
account = g_new (GmAccount, 1);
956
account->aid = g_strdup (a->aid);
957
account->account_name = g_strdup (a->account_name);
958
account->protocol_name = g_strdup (a->protocol_name);
959
account->host = g_strdup (a->host);
960
account->domain = g_strdup (a->domain);
961
account->username = g_strdup (a->username);
962
account->auth_username = g_strdup (a->auth_username);
963
account->password = g_strdup (a->password);
964
account->enabled = a->enabled;
965
account->default_account = a->default_account;
966
account->timeout = a->timeout;
967
account->method = a->method;
974
gnomemeeting_account_add (GmAccount *account)
983
gm_conf_get_string_list (PROTOCOLS_KEY "accounts_list");
986
account->default_account = TRUE;
988
entry = gm_aw_from_account_to_string (account);
990
list = g_slist_append (list, (gpointer) entry);
991
gm_conf_set_string_list (PROTOCOLS_KEY "accounts_list",
994
g_slist_foreach (list, (GFunc) g_free, NULL);
1002
gnomemeeting_account_delete (GmAccount *account)
1004
GSList *list = NULL;
1006
GSList *l_default_delete = NULL;
1007
GSList *l_delete = NULL;
1009
GmAccount *current_account = NULL;
1011
gchar *entry = NULL;
1013
gboolean found = FALSE;
1014
gboolean new_default = FALSE;
1016
if (account == NULL)
1020
gm_conf_get_string_list (PROTOCOLS_KEY "accounts_list");
1023
while (l && (!found || !new_default)) {
1027
current_account = gm_aw_from_string_to_account ((char *) l->data);
1028
if (current_account->aid && account->aid
1029
&& !strcmp (current_account->aid, account->aid)) {
1034
else if (account->default_account) { /* It was the default account */
1036
if (current_account->protocol_name && account->protocol_name
1037
&& !strcmp (current_account->protocol_name,
1038
account->protocol_name)) {
1040
l_default_delete = l;
1041
current_account->default_account = TRUE;
1042
entry = gm_aw_from_account_to_string (current_account);
1047
gm_account_delete (current_account);
1050
l = g_slist_next (l);
1055
list = g_slist_remove_link (list, l_delete);
1057
g_free (l_delete->data);
1058
g_slist_free_1 (l_delete);
1063
list = g_slist_insert_before (list, l_default_delete, (gpointer) entry);
1064
list = g_slist_remove_link (list, l_default_delete);
1066
g_free (l_default_delete->data);
1067
g_slist_free_1 (l_default_delete);
1070
gm_conf_set_string_list (PROTOCOLS_KEY "accounts_list",
1073
g_slist_foreach (list, (GFunc) g_free, NULL);
1074
g_slist_free (list);
1081
gnomemeeting_account_modify (GmAccount *account)
1083
GSList *list = NULL;
1086
gchar *entry = NULL;
1087
gchar **couple = NULL;
1089
gboolean found = FALSE;
1091
if (account == NULL)
1095
gm_conf_get_string_list (PROTOCOLS_KEY "accounts_list");
1097
entry = gm_aw_from_account_to_string (account);
1100
while (l && !found) {
1104
couple = g_strsplit ((const char *) l->data, "|", 0);
1105
if (couple && couple [2] && !strcmp (couple [2], account->aid)) {
1112
l = g_slist_next (l);
1117
list = g_slist_insert_before (list, l, (gpointer) entry);
1118
list = g_slist_remove_link (list, l);
1123
gm_conf_set_string_list (PROTOCOLS_KEY "accounts_list",
1127
g_slist_foreach (list, (GFunc) g_free, NULL);
1128
g_slist_free (list);
1135
gnomemeeting_get_accounts_list ()
1137
GSList *result = NULL;
1139
GSList *accounts_data_iter = NULL;
1140
GSList *accounts_data = NULL;
1142
GmAccount *account = NULL;
1145
gm_conf_get_string_list (PROTOCOLS_KEY "accounts_list");
1147
accounts_data_iter = accounts_data;
1148
while (accounts_data_iter) {
1150
account = gm_aw_from_string_to_account ((gchar *) accounts_data_iter->data);
1152
if (account != NULL)
1153
result = g_slist_append (result, (void *) account);
1155
accounts_data_iter = g_slist_next (accounts_data_iter);
1158
g_slist_foreach (accounts_data, (GFunc) g_free, NULL);
1159
g_slist_free (accounts_data);
1166
gnomemeeting_get_account (const char *domain)
1168
GmAccount *current_account = NULL;
1170
GSList *list = NULL;
1173
gboolean found = FALSE;
1175
g_return_val_if_fail (domain != NULL, NULL);
1178
gm_conf_get_string_list (PROTOCOLS_KEY "accounts_list");
1181
while (l && !found) {
1185
current_account = gm_aw_from_string_to_account ((gchar *) l->data);
1186
if ((current_account->domain
1187
&& !g_ascii_strcasecmp (current_account->domain, domain))
1188
|| (current_account->host
1189
&& !g_ascii_strcasecmp (current_account->host, domain))) {
1195
gm_account_delete (current_account);
1196
current_account = NULL;
1199
l = g_slist_next (l);
1202
g_slist_foreach (list, (GFunc) g_free, NULL);
1203
g_slist_free (list);
1205
return current_account;
1210
gnomemeeting_get_default_account (gchar *protocol)
1212
GmAccount *current_account = NULL;
1214
GSList *list = NULL;
1217
gboolean found = FALSE;
1219
g_return_val_if_fail (protocol != NULL, NULL);
1222
gm_conf_get_string_list (PROTOCOLS_KEY "accounts_list");
1225
while (l && !found) {
1229
current_account = gm_aw_from_string_to_account ((gchar *) l->data);
1230
if (current_account->protocol_name
1231
&& current_account->default_account
1232
&& !g_ascii_strcasecmp (current_account->protocol_name, protocol)) {
1238
gm_account_delete (current_account);
1239
current_account = NULL;
1242
l = g_slist_next (l);
1245
g_slist_foreach (list, (GFunc) g_free, NULL);
1246
g_slist_free (list);
1248
return current_account;
1253
gnomemeeting_account_toggle_active (GmAccount *account)
1255
GmAccount *current_account = NULL;
1257
GSList *accounts = NULL;
1258
GSList *accounts_iter = NULL;
1260
gchar *entry = NULL;
1265
accounts = gm_conf_get_string_list (PROTOCOLS_KEY "accounts_list");
1267
accounts_iter = accounts;
1268
while (accounts_iter) {
1271
gm_aw_from_string_to_account ((gchar *) accounts_iter->data);
1273
if (!strcmp (account->protocol_name, "H323")
1274
&& !strcmp (current_account->protocol_name, "H323")
1275
&& !account->enabled)
1276
current_account->enabled = FALSE;
1278
if (!strcmp (current_account->aid, account->aid)) {
1280
current_account->enabled = !account->enabled;
1281
account->enabled = current_account->enabled;
1284
entry = gm_aw_from_account_to_string (current_account);
1285
g_free (accounts_iter->data);
1286
accounts_iter->data = entry;
1288
accounts_iter = g_slist_next (accounts_iter);
1291
gm_conf_set_string_list (PROTOCOLS_KEY "accounts_list", accounts);
1293
g_slist_foreach (accounts, (GFunc) g_free, NULL);
1294
g_slist_free (accounts);
1301
gnomemeeting_account_set_default (GmAccount *account,
1302
gboolean default_account)
1304
GmAccount *current_account = NULL;
1306
GSList *accounts = NULL;
1307
GSList *accounts_iter = NULL;
1309
gchar *entry = NULL;
1311
gboolean found = FALSE;
1313
if (!account || !account->protocol_name)
1316
accounts = gm_conf_get_string_list (PROTOCOLS_KEY "accounts_list");
1318
/* Only one account for each protocol as default at a time */
1319
accounts_iter = accounts;
1320
while (accounts_iter) {
1323
gm_aw_from_string_to_account ((gchar *) accounts_iter->data);
1324
if (!strcmp (current_account->protocol_name, account->protocol_name)) {
1326
/* Same protocol, other account */
1327
if (strcmp (current_account->aid, account->aid)) {
1329
current_account->default_account = !default_account;
1331
/* Same protocol, same account */
1334
current_account->default_account = default_account;
1335
account->default_account = default_account;
1339
entry = gm_aw_from_account_to_string (current_account);
1340
g_free (accounts_iter->data);
1341
accounts_iter->data = entry;
1344
accounts_iter = g_slist_next (accounts_iter);
1347
gm_conf_set_string_list (PROTOCOLS_KEY "accounts_list", accounts);
1349
g_slist_foreach (accounts, (GFunc) g_free, NULL);
1350
g_slist_free (accounts);
1357
gm_accounts_window_new ()
1359
GmAccountsWindow *aw = NULL;
1361
GtkWidget *window = NULL;
1363
GtkWidget *event_box = NULL;
1364
GtkWidget *scroll_window = NULL;
1366
GtkWidget *frame = NULL;
1367
GtkWidget *hbox = NULL;
1369
GtkWidget *button = NULL;
1370
GtkWidget *buttons_vbox = NULL;
1371
GtkWidget *alignment = NULL;
1373
GtkCellRenderer *renderer = NULL;
1374
GtkListStore *list_store = NULL;
1375
GtkTreeViewColumn *column = NULL;
1377
gchar *column_names [] = {
1399
window = gtk_dialog_new ();
1400
gtk_dialog_add_button (GTK_DIALOG (window), GTK_STOCK_CLOSE, 0);
1402
g_object_set_data_full (G_OBJECT (window), "window_name",
1403
g_strdup ("accounts_window"), g_free);
1405
gtk_window_set_title (GTK_WINDOW (window), _("Accounts"));
1406
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
1408
aw = new GmAccountsWindow ();
1409
g_object_set_data_full (G_OBJECT (window), "GMObject",
1413
/* The accounts list store */
1414
list_store = gtk_list_store_new (COLUMN_ACCOUNT_NUMBER,
1416
G_TYPE_BOOLEAN, /* Enabled? */
1417
G_TYPE_BOOLEAN, /* Default? */
1418
G_TYPE_STRING, /* AID */
1419
G_TYPE_STRING, /* Account Name */
1420
G_TYPE_STRING, /* Protocol Name */
1421
G_TYPE_STRING, /* Host */
1422
G_TYPE_STRING, /* Domain */
1423
G_TYPE_STRING, /* Username */
1424
G_TYPE_STRING, /* Auth Username */
1425
G_TYPE_STRING, /* Password */
1426
G_TYPE_INT, /* State */
1427
G_TYPE_INT, /* Timeout */
1428
G_TYPE_INT, /* Method */
1429
G_TYPE_STRING, /* VoiceMails */
1430
G_TYPE_STRING, /* Error Message */
1431
G_TYPE_INT); /* Activatable */
1434
gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
1435
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (aw->accounts_list), TRUE);
1436
gtk_tree_view_set_reorderable (GTK_TREE_VIEW (aw->accounts_list), TRUE);
1438
renderer = gtk_cell_renderer_toggle_new ();
1439
column = gtk_tree_view_column_new_with_attributes (_("A"),
1442
COLUMN_ACCOUNT_ENABLED,
1444
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 25);
1445
gtk_tree_view_append_column (GTK_TREE_VIEW (aw->accounts_list), column);
1446
gtk_tree_view_column_add_attribute (column, renderer,
1448
COLUMN_ACCOUNT_ACTIVATABLE);
1449
g_signal_connect (G_OBJECT (renderer), "toggled",
1450
G_CALLBACK (account_toggled_cb),
1451
(gpointer) aw->accounts_list);
1454
/* Add all text renderers, ie all except the
1455
* "ACCOUNT_ENABLED/DEFAULT" columns */
1456
for (int i = COLUMN_ACCOUNT_AID ; i < COLUMN_ACCOUNT_NUMBER - 1 ; i++) {
1458
renderer = gtk_cell_renderer_text_new ();
1459
column = gtk_tree_view_column_new_with_attributes (column_names [i],
1464
COLUMN_ACCOUNT_WEIGHT,
1466
gtk_tree_view_append_column (GTK_TREE_VIEW (aw->accounts_list), column);
1467
gtk_tree_view_column_set_resizable (GTK_TREE_VIEW_COLUMN (column), TRUE);
1468
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
1469
GTK_TREE_VIEW_COLUMN_AUTOSIZE);
1470
if (i == COLUMN_ACCOUNT_ACCOUNT_NAME)
1471
gtk_tree_view_column_set_sort_column_id (column,
1472
COLUMN_ACCOUNT_ACCOUNT_NAME);
1474
if (i == COLUMN_ACCOUNT_AID
1475
|| i == COLUMN_ACCOUNT_HOST
1476
|| i == COLUMN_ACCOUNT_TIMEOUT
1477
|| i == COLUMN_ACCOUNT_METHOD
1478
|| i == COLUMN_ACCOUNT_DOMAIN
1479
|| i == COLUMN_ACCOUNT_USERNAME
1480
|| i == COLUMN_ACCOUNT_AUTH_USERNAME
1481
|| i == COLUMN_ACCOUNT_PASSWORD
1482
|| i == COLUMN_ACCOUNT_STATE)
1483
g_object_set (G_OBJECT (column), "visible", false, NULL);
1486
g_signal_connect (G_OBJECT (aw->accounts_list), "event_after",
1487
G_CALLBACK (account_clicked_cb), window);
1490
/* The scrolled window with the accounts list store */
1491
scroll_window = gtk_scrolled_window_new (FALSE, FALSE);
1492
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_window),
1493
GTK_POLICY_AUTOMATIC,
1494
GTK_POLICY_AUTOMATIC);
1496
event_box = gtk_event_box_new ();
1497
hbox = gtk_hbox_new (FALSE, 4);
1498
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
1499
gtk_container_add (GTK_CONTAINER (event_box), hbox);
1501
frame = gtk_frame_new (NULL);
1502
gtk_widget_set_size_request (GTK_WIDGET (frame), 250, 150);
1503
gtk_container_set_border_width (GTK_CONTAINER (frame),
1504
2 * GNOMEMEETING_PAD_SMALL);
1505
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
1506
gtk_container_add (GTK_CONTAINER (frame), scroll_window);
1507
gtk_container_add (GTK_CONTAINER (scroll_window), aw->accounts_list);
1508
gtk_container_set_border_width (GTK_CONTAINER (aw->accounts_list), 0);
1509
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
1513
alignment = gtk_alignment_new (1, 0.5, 0, 0);
1514
buttons_vbox = gtk_vbutton_box_new ();
1516
gtk_box_set_spacing (GTK_BOX (buttons_vbox), 2 * GNOMEMEETING_PAD_SMALL);
1518
gtk_container_add (GTK_CONTAINER (alignment), buttons_vbox);
1519
gtk_box_pack_start (GTK_BOX (hbox), alignment,
1520
FALSE, FALSE, 2 * GNOMEMEETING_PAD_SMALL);
1522
button = gtk_button_new_from_stock (GTK_STOCK_ADD);
1523
gtk_box_pack_start (GTK_BOX (buttons_vbox), button, TRUE, TRUE, 0);
1524
g_signal_connect (G_OBJECT (button), "clicked",
1525
GTK_SIGNAL_FUNC (add_account_cb), NULL);
1527
aw->delete_button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
1528
gtk_widget_set_sensitive (aw->delete_button, FALSE);
1529
gtk_box_pack_start (GTK_BOX (buttons_vbox), aw->delete_button, TRUE, TRUE, 0);
1530
g_signal_connect (G_OBJECT (aw->delete_button), "clicked",
1531
GTK_SIGNAL_FUNC (delete_account_cb), NULL);
1533
aw->edit_button = gtk_button_new_from_stock (GTK_STOCK_PROPERTIES);
1534
gtk_widget_set_sensitive (aw->edit_button, FALSE);
1535
gtk_box_pack_start (GTK_BOX (buttons_vbox), aw->edit_button, TRUE, TRUE, 0);
1536
g_signal_connect (G_OBJECT (aw->edit_button), "clicked",
1537
GTK_SIGNAL_FUNC (edit_account_cb), NULL);
1539
aw->default_button = gtk_button_new_with_mnemonic (_("_Default"));
1540
gtk_widget_set_sensitive (aw->default_button, FALSE);
1541
gtk_box_pack_start (GTK_BOX (buttons_vbox),
1542
aw->default_button, TRUE, TRUE, 0);
1543
g_signal_connect (G_OBJECT (aw->default_button), "clicked",
1544
GTK_SIGNAL_FUNC (set_account_as_default_cb), NULL);
1546
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox),
1547
event_box, TRUE, TRUE, 0);
1550
/* Generic signals */
1551
g_signal_connect_swapped (GTK_OBJECT (window),
1553
G_CALLBACK (gnomemeeting_window_hide),
1556
g_signal_connect (GTK_OBJECT (window), "delete-event",
1557
G_CALLBACK (delete_window_cb), NULL);
1559
gtk_widget_show_all (GTK_WIDGET (GTK_DIALOG (window)->vbox));
1562
/* We update it the accounts list to make sure the cursor is updated */
1563
gm_accounts_window_update_accounts_list (window);
1571
gm_accounts_window_update_account_state (GtkWidget *accounts_window,
1572
gboolean refreshing,
1573
const gchar *domain,
1575
const gchar *status,
1576
const gchar *voicemails)
1578
OpalTransportAddress addr1;
1579
OpalTransportAddress addr2;
1581
GtkTreeModel *model = NULL;
1586
gchar *realm = NULL;
1587
gchar *username = NULL;
1589
gboolean active = FALSE;
1591
GmAccountsWindow *aw = NULL;
1593
g_return_if_fail (accounts_window != NULL);
1594
g_return_if_fail (user != NULL);
1595
g_return_if_fail (domain != NULL);
1597
aw = gm_aw_get_aw (accounts_window);
1599
model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->accounts_list));
1601
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)){
1605
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
1606
COLUMN_ACCOUNT_ENABLED, &active,
1607
COLUMN_ACCOUNT_HOST, &host,
1608
COLUMN_ACCOUNT_DOMAIN, &realm,
1609
COLUMN_ACCOUNT_USERNAME, &username,
1612
if (((host && domain && !strcmp (host, domain))
1613
|| (realm && domain && !strcmp (realm, domain)))
1614
&& (username && user && !strcmp (username, user))) {
1616
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1617
COLUMN_ACCOUNT_STATE, refreshing, -1);
1619
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1620
COLUMN_ACCOUNT_ERROR_MESSAGE, status, -1);
1622
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1623
COLUMN_ACCOUNT_VOICEMAILS, voicemails, -1);
1626
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1627
COLUMN_ACCOUNT_ERROR_MESSAGE, "", -1);
1633
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
1637
/* We update it the accounts list to make sure the cursor is updated */
1638
gm_accounts_window_update_accounts_list (accounts_window);
1643
gm_accounts_window_update_accounts_list (GtkWidget *accounts_window)
1645
GmAccountsWindow *aw = NULL;
1647
GdkCursor *cursor = NULL;
1649
GtkTreeSelection *selection = NULL;
1650
GtkTreeModel *model = NULL;
1653
gchar *selected_aid = NULL;
1656
GmAccount *account = NULL;
1658
GSList *accounts_data = NULL;
1659
GSList *accounts_data_iter = NULL;
1661
gboolean found = FALSE;
1662
gboolean enabled = FALSE;
1663
gboolean refreshing = FALSE;
1664
gboolean busy = FALSE;
1665
gboolean valid_iter = TRUE;
1667
g_return_if_fail (accounts_window != NULL);
1669
aw = gm_aw_get_aw (accounts_window);
1672
/* Get the data and the selected codec */
1673
model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->accounts_list));
1675
gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->accounts_list));
1677
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
1679
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
1680
COLUMN_ACCOUNT_AID, &selected_aid, -1);
1684
/* Loop through all accounts in the configuration.
1685
* Then find that account in the GUI and updates it.
1686
* If we do not find the account in the GUI, append the new account
1689
accounts_data = gnomemeeting_get_accounts_list ();
1690
accounts_data_iter = accounts_data;
1691
while (accounts_data_iter && accounts_data_iter->data) {
1693
account = GM_ACCOUNT (accounts_data_iter->data);
1696
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) {
1700
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
1701
COLUMN_ACCOUNT_ENABLED, &enabled,
1702
COLUMN_ACCOUNT_STATE, &refreshing,
1703
COLUMN_ACCOUNT_AID, &aid, -1);
1704
if (aid && account->aid && !strcmp (account->aid, aid)) {
1706
busy = busy || refreshing;
1712
gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
1714
if (!found) /* No existing entry for that account */
1715
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
1717
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1718
COLUMN_ACCOUNT_WEIGHT,
1719
account->default_account?
1720
PANGO_WEIGHT_BOLD:PANGO_WEIGHT_NORMAL,
1721
COLUMN_ACCOUNT_ENABLED, account->enabled,
1722
COLUMN_ACCOUNT_DEFAULT, account->default_account,
1723
COLUMN_ACCOUNT_AID, account->aid,
1724
COLUMN_ACCOUNT_ACCOUNT_NAME, account->account_name,
1725
COLUMN_ACCOUNT_PROTOCOL_NAME, account->protocol_name,
1726
COLUMN_ACCOUNT_HOST, account->host,
1727
COLUMN_ACCOUNT_DOMAIN, account->domain,
1728
COLUMN_ACCOUNT_USERNAME, account->username,
1729
COLUMN_ACCOUNT_AUTH_USERNAME, account->auth_username,
1730
COLUMN_ACCOUNT_PASSWORD, account->password,
1731
COLUMN_ACCOUNT_TIMEOUT, account->timeout,
1732
COLUMN_ACCOUNT_METHOD, account->method,
1735
if (selected_aid && account->aid
1736
&& !strcmp (selected_aid, account->aid))
1737
gtk_tree_selection_select_iter (selection, &iter);
1739
accounts_data_iter = g_slist_next (accounts_data_iter);
1743
/* Loop through the accounts in the window, and check
1744
* if they are in the configuration. If not, remove them from the GUI.
1746
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) {
1753
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
1754
COLUMN_ACCOUNT_AID, &aid, -1);
1756
accounts_data_iter = accounts_data;
1757
while (accounts_data_iter && accounts_data_iter->data && !found) {
1759
account = GM_ACCOUNT (accounts_data_iter->data);
1761
if (account->aid && aid && !strcmp (account->aid, aid))
1764
accounts_data_iter = g_slist_next (accounts_data_iter);
1768
valid_iter = gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
1772
} while (valid_iter &&
1773
gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
1778
g_slist_foreach (accounts_data, (GFunc) gm_account_delete, NULL);
1779
g_slist_free (accounts_data);
1782
/* Update the cursor and the activatable state of all accounts
1783
* following we are refreshing or not */
1784
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) {
1788
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1789
COLUMN_ACCOUNT_ACTIVATABLE, !busy, -1);
1790
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
1793
gtk_widget_realize (GTK_WIDGET (accounts_window));
1797
cursor = gdk_cursor_new (GDK_WATCH);
1798
gdk_window_set_cursor (GTK_WIDGET (accounts_window)->window, cursor);
1799
gdk_cursor_unref (cursor);
1802
gdk_window_set_cursor (GTK_WIDGET (accounts_window)->window, NULL);