~ubuntu-branches/ubuntu/precise/evolution/precise

« back to all changes in this revision

Viewing changes to modules/addressbook/addressbook-config.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2011-09-08 09:38:57 UTC
  • mfrom: (1.1.84 upstream)
  • Revision ID: package-import@ubuntu.com-20110908093857-6lfl04ke2ns3kx2o
Tags: 3.1.91-0ubuntu1
* New upstream release. (LP: #843769)
* debian/control: bump e-d-s Build-Depends to 3.1.91. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
215
215
}
216
216
 
217
217
static gboolean
218
 
source_to_uri_parts (ESource *source, gchar **host, gchar **rootdn, AddressbookLDAPScopeType *scope, gchar **search_filter, gint *port)
 
218
source_to_uri_parts (ESource *source,
 
219
                     gchar **host,
 
220
                     gchar **rootdn,
 
221
                     AddressbookLDAPScopeType *scope,
 
222
                     gchar **search_filter,
 
223
                     gint *port)
219
224
{
220
225
        gchar       *uri;
221
226
        LDAPURLDesc *lud;
256
261
 
257
262
/* ldap api foo */
258
263
static LDAP *
259
 
addressbook_ldap_init (GtkWidget *window, ESource *source)
 
264
addressbook_ldap_init (GtkWidget *window,
 
265
                       ESource *source)
260
266
{
261
267
        LDAP  *ldap;
262
268
        gchar *host;
284
290
}
285
291
 
286
292
static gint
287
 
addressbook_ldap_auth (GtkWidget *window, LDAP *ldap)
 
293
addressbook_ldap_auth (GtkWidget *window,
 
294
                       LDAP *ldap)
288
295
{
289
296
        gint ldap_error;
290
297
 
297
304
}
298
305
 
299
306
static gint
300
 
addressbook_root_dse_query (AddressbookSourceDialog *dialog, LDAP *ldap,
301
 
                            const gchar **attrs, LDAPMessage **resp)
 
307
addressbook_root_dse_query (AddressbookSourceDialog *dialog,
 
308
                            LDAP *ldap,
 
309
                            const gchar **attrs,
 
310
                            LDAPMessage **resp)
302
311
{
303
312
        GtkAdjustment *adjustment;
304
313
        GtkRange *range;
322
331
}
323
332
 
324
333
static gboolean
325
 
do_ldap_root_dse_query (AddressbookSourceDialog *sdialog, GtkListStore *model, ESource *source)
 
334
do_ldap_root_dse_query (AddressbookSourceDialog *sdialog,
 
335
                        GtkListStore *model,
 
336
                        ESource *source)
326
337
{
327
338
        LDAP *ldap;
328
339
        const gchar *attrs[2];
369
380
}
370
381
 
371
382
static void
372
 
search_base_selection_model_changed (GtkTreeSelection *selection, GtkWidget *dialog)
 
383
search_base_selection_model_changed (GtkTreeSelection *selection,
 
384
                                     GtkWidget *dialog)
373
385
{
374
386
        gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
375
387
                                           GTK_RESPONSE_OK,
377
389
}
378
390
 
379
391
static void
380
 
query_for_supported_bases (GtkWidget *button, AddressbookSourceDialog *sdialog)
 
392
query_for_supported_bases (GtkWidget *button,
 
393
                           AddressbookSourceDialog *sdialog)
381
394
{
382
395
        GtkTreeSelection *selection;
383
396
        GtkTreeModel *model;
427
440
 
428
441
#endif /* HAVE_LDAP */
429
442
 
430
 
GtkWidget*
 
443
GtkWidget *
431
444
addressbook_config_create_new_source (GtkWidget *parent)
432
445
{
433
446
        return addressbook_config_edit_source (parent, NULL);
436
449
/* ********************************************************************** */
437
450
 
438
451
static void
439
 
eabc_type_changed (GtkComboBox *dropdown, AddressbookSourceDialog *sdialog)
 
452
eabc_type_changed (GtkComboBox *dropdown,
 
453
                   AddressbookSourceDialog *sdialog)
440
454
{
441
455
        gint id = gtk_combo_box_get_active (dropdown);
442
456
        GtkTreeModel *model;
454
468
        e_source_set_group (sdialog->source, sdialog->source_group);
455
469
 
456
470
        /* BIG HACK: We load the defaults for each type here.
457
 
           I guess plugins will have to use the do it in their factory callbacks */
 
471
         * I guess plugins will have to use the do it in their factory callbacks */
458
472
        if (!strncmp(e_source_group_peek_base_uri(sdialog->source_group), "groupwise:", 10)) {
459
473
                GSList *l;
460
474
                ESource *source;
520
534
        cell = gtk_cell_renderer_text_new ();
521
535
        store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
522
536
        i = 0;
523
 
        for (l=sdialog->menu_source_groups;l;l=g_slist_next (l)) {
 
537
        for (l = sdialog->menu_source_groups; l; l = g_slist_next (l)) {
524
538
                ESourceGroup *group = l->data;
525
539
 
526
540
                gtk_list_store_append (store, &iter);
535
549
        gtk_combo_box_set_model (dropdown, (GtkTreeModel *) store);
536
550
        gtk_combo_box_set_active (dropdown, -1);
537
551
        gtk_combo_box_set_active (dropdown, row);
538
 
        g_signal_connect(dropdown, "changed", G_CALLBACK(eabc_type_changed), sdialog);
 
552
        g_signal_connect (dropdown, "changed", G_CALLBACK(eabc_type_changed), sdialog);
539
553
        gtk_widget_show ((GtkWidget *) dropdown);
540
554
        gtk_box_pack_start ((GtkBox *) w, (GtkWidget *) dropdown, TRUE, TRUE, 0);
541
555
        gtk_label_set_mnemonic_widget ((GtkLabel *) label, (GtkWidget *) dropdown);
548
562
}
549
563
 
550
564
static void
551
 
name_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
 
565
name_changed_cb (GtkWidget *w,
 
566
                 AddressbookSourceDialog *sdialog)
552
567
{
553
568
        const gchar *text;
554
569
        gchar *stripped_name;
583
598
        gtk_box_pack_start ((GtkBox *) parent, w, FALSE, FALSE, 0);
584
599
 
585
600
        sdialog->display_name = e_builder_get_widget (builder, "account-editor-display-name-entry");
586
 
        g_signal_connect(sdialog->display_name, "changed", G_CALLBACK(name_changed_cb), sdialog);
 
601
        g_signal_connect (sdialog->display_name, "changed", G_CALLBACK(name_changed_cb), sdialog);
587
602
        gtk_entry_set_text ((GtkEntry *) sdialog->display_name, e_source_peek_name (sdialog->source));
588
603
 
589
604
        /* Hardcoded: groupwise can't edit the name (or anything else) */
601
616
 
602
617
/* TODO: This should be moved to plugins if B&A calendar setup is moved there */
603
618
static void
604
 
use_in_cal_changed_cb (GtkWidget *widget, AddressbookSourceDialog *sdialog)
 
619
use_in_cal_changed_cb (GtkWidget *widget,
 
620
                       AddressbookSourceDialog *sdialog)
605
621
{
606
622
        e_source_set_property (sdialog->source, "use-in-contacts-calendar", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? "1" : "0");
607
623
}
640
656
}
641
657
 
642
658
static void
643
 
offline_status_changed_cb (GtkWidget *widget, AddressbookSourceDialog *sdialog)
 
659
offline_status_changed_cb (GtkWidget *widget,
 
660
                           AddressbookSourceDialog *sdialog)
644
661
{
645
662
        e_source_set_property (sdialog->source, "offline_sync", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? "1" : "0");
646
663
}
684
701
        const gchar *search_filter = gtk_entry_get_text ((GtkEntry *) w);
685
702
 
686
703
        /* this function can be used to format the search filter entered */
687
 
        if ((strlen (search_filter) !=0) && *search_filter != '(' && *(search_filter + (strlen (search_filter-1))) != ')')
 
704
        if ((strlen (search_filter) !=0) && *search_filter != '(' && *(search_filter + (strlen (search_filter - 1))) != ')')
688
705
                filter = g_strdup_printf ("(%s)", search_filter);
689
706
        else
690
707
                filter = g_strdup_printf ("%s", search_filter);
710
727
}
711
728
 
712
729
static void
713
 
host_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
 
730
host_changed_cb (GtkWidget *w,
 
731
                 AddressbookSourceDialog *sdialog)
714
732
{
715
733
        url_changed (sdialog);
716
734
}
717
735
 
718
736
static void
719
 
port_entry_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
 
737
port_entry_changed_cb (GtkWidget *w,
 
738
                       AddressbookSourceDialog *sdialog)
720
739
{
721
740
        const gchar *port = gtk_entry_get_text ((GtkEntry *) w);
722
741
 
732
751
}
733
752
 
734
753
static void
735
 
ssl_combobox_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
 
754
ssl_combobox_changed_cb (GtkWidget *w,
 
755
                         AddressbookSourceDialog *sdialog)
736
756
{
737
757
        sdialog->ssl = gtk_combo_box_get_active (GTK_COMBO_BOX (w));
738
758
        e_source_set_property (sdialog->source, "ssl", ldap_unparse_ssl (sdialog->ssl));
798
818
}
799
819
 
800
820
static void
801
 
auth_entry_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
 
821
auth_entry_changed_cb (GtkWidget *w,
 
822
                       AddressbookSourceDialog *sdialog)
802
823
{
803
824
        const gchar *principal = gtk_entry_get_text ((GtkEntry *) w);
804
825
 
821
842
}
822
843
 
823
844
static void
824
 
auth_combobox_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
 
845
auth_combobox_changed_cb (GtkWidget *w,
 
846
                          AddressbookSourceDialog *sdialog)
825
847
{
826
848
        sdialog->auth = gtk_combo_box_get_active (GTK_COMBO_BOX (w));
827
849
        e_source_set_property (sdialog->source, "auth", ldap_unparse_auth (sdialog->auth));
882
904
}
883
905
 
884
906
static void
885
 
rootdn_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
886
 
{
887
 
        url_changed (sdialog);
888
 
}
889
 
 
890
 
static void
891
 
search_filter_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
892
 
{
893
 
        url_changed (sdialog);
894
 
}
895
 
 
896
 
static void
897
 
scope_combobox_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
 
907
rootdn_changed_cb (GtkWidget *w,
 
908
                   AddressbookSourceDialog *sdialog)
 
909
{
 
910
        url_changed (sdialog);
 
911
}
 
912
 
 
913
static void
 
914
search_filter_changed_cb (GtkWidget *w,
 
915
                          AddressbookSourceDialog *sdialog)
 
916
{
 
917
        url_changed (sdialog);
 
918
}
 
919
 
 
920
static void
 
921
scope_combobox_changed_cb (GtkWidget *w,
 
922
                           AddressbookSourceDialog *sdialog)
898
923
{
899
924
        sdialog->scope = gtk_combo_box_get_active (GTK_COMBO_BOX (w));
900
925
        url_changed (sdialog);
968
993
}
969
994
 
970
995
static void
971
 
timeout_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
 
996
timeout_changed_cb (GtkWidget *w,
 
997
                    AddressbookSourceDialog *sdialog)
972
998
{
973
999
        GtkAdjustment *adjustment;
974
1000
        GtkRange *range;
982
1008
}
983
1009
 
984
1010
static void
985
 
limit_changed_cb (GtkWidget *w, AddressbookSourceDialog *sdialog)
 
1011
limit_changed_cb (GtkWidget *w,
 
1012
                  AddressbookSourceDialog *sdialog)
986
1013
{
987
1014
        gchar limit[16];
988
1015
 
991
1018
}
992
1019
 
993
1020
static void
994
 
canbrowse_toggled_cb (GtkWidget *toggle_button, ESource *source)
 
1021
canbrowse_toggled_cb (GtkWidget *toggle_button,
 
1022
                      ESource *source)
995
1023
{
996
1024
        if (!source || !toggle_button)
997
1025
                return;
1027
1055
        range = GTK_RANGE (sdialog->timeout_scale);
1028
1056
        adjustment = gtk_range_get_adjustment (range);
1029
1057
        tmp = e_source_get_property(sdialog->source, "timeout");
1030
 
        gtk_adjustment_set_value (adjustment, tmp?g_strtod (tmp, NULL):3.0);
 
1058
        gtk_adjustment_set_value (adjustment, tmp ? g_strtod (tmp, NULL) : 3.0);
1031
1059
        g_signal_connect (
1032
1060
                adjustment, "value_changed",
1033
1061
                G_CALLBACK (timeout_changed_cb), sdialog);
1034
1062
 
1035
1063
        sdialog->limit_spinbutton = e_builder_get_widget (builder, "download-limit-spinbutton");
1036
1064
        tmp = e_source_get_property(sdialog->source, "limit");
1037
 
        gtk_spin_button_set_value ((GtkSpinButton *) sdialog->limit_spinbutton, tmp?g_strtod (tmp, NULL):100.0);
 
1065
        gtk_spin_button_set_value ((GtkSpinButton *) sdialog->limit_spinbutton, tmp ? g_strtod (tmp, NULL) : 100.0);
1038
1066
        g_signal_connect (sdialog->limit_spinbutton, "value_changed", G_CALLBACK (limit_changed_cb), sdialog);
1039
1067
 
1040
1068
        sdialog->canbrowsecheck = e_builder_get_widget (builder, "canbrowsecheck");
1110
1138
}
1111
1139
 
1112
1140
static void
1113
 
eabc_free (EConfig *ec, GSList *items, gpointer data)
 
1141
eabc_free (EConfig *ec,
 
1142
           GSList *items,
 
1143
           gpointer data)
1114
1144
{
1115
1145
        AddressbookSourceDialog *sdialog = data;
1116
1146
 
1129
1159
}
1130
1160
 
1131
1161
static gboolean
1132
 
eabc_check_complete (EConfig *ec, const gchar *pageid, gpointer data)
 
1162
eabc_check_complete (EConfig *ec,
 
1163
                     const gchar *pageid,
 
1164
                     gpointer data)
1133
1165
{
1134
1166
        AddressbookSourceDialog *sdialog = data;
1135
1167
        gint valid = TRUE;
1187
1219
/* debug only: */
1188
1220
#if d(!)0
1189
1221
static void
1190
 
source_changed (ESource *source, AddressbookSourceDialog *sdialog)
 
1222
source_changed (ESource *source,
 
1223
                AddressbookSourceDialog *sdialog)
1191
1224
{
1192
1225
        gchar *xml;
1193
1226
 
1197
1230
}
1198
1231
#endif
1199
1232
 
1200
 
GtkWidget*
1201
 
addressbook_config_edit_source (GtkWidget *parent, ESource *source)
 
1233
GtkWidget *
 
1234
addressbook_config_edit_source (GtkWidget *parent,
 
1235
                                ESource *source)
1202
1236
{
1203
1237
        AddressbookSourceDialog *sdialog = g_new0 (AddressbookSourceDialog, 1);
1204
1238
        EABConfig *ec;
1234
1268
 
1235
1269
                sdialog->menu_source_groups = g_slist_copy (l);
1236
1270
#ifndef HAVE_LDAP
1237
 
                for (;l;l = g_slist_next (l))
 
1271
                for (; l; l = g_slist_next (l))
1238
1272
                        if (!strncmp("ldap:", e_source_group_peek_base_uri(l->data), 5))
1239
1273
                                sdialog->menu_source_groups = g_slist_remove (sdialog->menu_source_groups, l->data);
1240
1274
#endif
1241
1275
                sdialog->source_group = (ESourceGroup *) sdialog->menu_source_groups->data;
1242
 
                for (i=0;eabc_new_items[i].path;i++)
 
1276
                for (i = 0; eabc_new_items[i].path; i++)
1243
1277
                        items = g_slist_prepend (items, &eabc_new_items[i]);
1244
1278
                g_object_unref (gconf);
1245
1279
        }
1251
1285
        xml = e_source_to_standalone_xml (sdialog->source);
1252
1286
        printf("but working standalone xml: %s\n", xml);
1253
1287
        g_free (xml);
1254
 
        g_signal_connect(sdialog->source, "changed", source_changed, sdialog);
 
1288
        g_signal_connect (sdialog->source, "changed", source_changed, sdialog);
1255
1289
#endif
1256
1290
 
1257
1291
        sdialog->config = ec = eab_config_new(E_CONFIG_BOOK, "com.novell.evolution.addressbook.config.accountEditor");
1258
1292
 
1259
 
        for (i=0;eabc_items[i].path;i++) {
 
1293
        for (i = 0; eabc_items[i].path; i++) {
1260
1294
                if (eabc_items[i].label)
1261
1295
                        eabc_items[i].label = gettext (eabc_items[i].label);
1262
1296
                items = g_slist_prepend (items, &eabc_items[i]);