static void default_source_changed (GtkWidget *check_box, ESource *source) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_box))) e_source_set_property (source, "default", "true"); else e_source_set_property (source, "default", NULL); }
static void on_ssl_cb_toggled (GtkToggleButton *tb, gpointer user_data) { ESource *source = user_data; if (gtk_toggle_button_get_active (tb)) { e_source_set_property (source, "use-ssl", "true"); } else { e_source_set_property (source, "use-ssl", "false"); } }
static void on_remote_db_changed (GtkEditable *entry, gpointer user_data) { UIData *ui = (UIData *) user_data; e_source_set_property (ui->source, "couchdb_remote_server", gtk_entry_get_text (GTK_ENTRY (entry))); }
static void create_ldap_source (EAccount * account, ESourceGroup * group) { ESource *source; EUri *euri; char *uri; char *uid; xmlNodePtr node; euri = e_uri_new (account->source->url); uri = g_strdup_printf ("ldap://%s:389/o=Scalix?sub", euri->host); uid = g_strdup_printf ("system-ldap@%s", account->uid); node = xmlNewNode (NULL, "source"); xmlSetProp (node, "uid", uid); xmlSetProp (node, "name", _("System")); xmlSetProp (node, "uri", uri); source = e_source_new_from_xml_node (node); xmlFreeNode (node); e_source_set_property (source, "completion", "TRUE"); if (!e_source_group_add_source (group, source, 1)) { g_print ("Could not add ldap source\n"); } g_free (uri); g_free (uid); e_uri_free (euri); }
static void on_remote_db_toggled (GtkToggleButton *button, gpointer *user_data) { UIData *ui = (UIData *) user_data; if (gtk_toggle_button_get_active (button)) { e_source_set_property (ui->source, "couchdb_instance", "remote"); gtk_widget_set_sensitive (ui->remote_db_entry, TRUE); } }
static void add_account (const char *conf_key, const char *hostname, const char *username, const char *password) { ESourceList *source_list; ESourceGroup *group; ESource *source; char *group_name; source_list = e_source_list_new_for_gconf (conf_client, conf_key); group_name = g_strdup_printf ("%s@%s:7181/soap", username, hostname); group = e_source_group_new ("Groupwise", "groupwise://"); e_source_list_add_group (source_list, group, -1); if (password && *password) { g_free (group_name); group_name = g_strdup_printf ("%s:%s@%s/soap/", username, password, hostname); } source = e_source_new ("Frequent Contacts", group_name); e_source_set_property (source, "auth", "ldap/simple-binddn"); e_source_set_property(source, "binddn", "user1"); e_source_group_add_source (group, source, -1); /* source = e_source_new ("Test User1", group_name); e_source_set_property (source, "auth", "ldap/simple-binddn"); e_source_set_property(source, "binddn", "user1"); e_source_group_add_source (group, source, -1); source = e_source_new ("mybook1", group_name); e_source_set_property (source, "auth", "ldap/simple-binddn"); e_source_set_property(source, "binddn", "user1"); e_source_group_add_source (group, source, -1);*/ e_source_list_sync (source_list, NULL); g_free (group_name); g_object_unref (source); g_object_unref (group); g_object_unref (source_list); }
static void on_username_entry_changed (GtkEntry *entry, gpointer user_data) { ESource *source = user_data; const gchar *text; gchar *username; text = gtk_entry_get_text (entry); if (!text || !*text) { username = NULL; } else if (strstr (text, "@")) { username = g_strdup (text); } else { username = g_strdup_printf ("*****@*****.**", text); } e_source_set_relative_uri (source, username); e_source_set_property (source, "username", username); e_source_set_property (source, "auth", "plain/password"); g_free (username); }
static void add_return_value (EGwSendOptionsReturnNotify track, ESource *source, const gchar *notify) { gchar *value; switch (track) { case E_GW_RETURN_NOTIFY_MAIL: value = g_strdup ("mail"); break; default: value = g_strdup ("none"); } e_source_set_property (source, notify, value); g_free (value), value = NULL; }
static void on_interval_combo_changed (GtkComboBox *combo, gpointer user_data) { ESource *source = user_data; gdouble time; guint seconds; gchar *value_string; GtkWidget *sb; IntervalType type; sb = g_object_get_data (G_OBJECT (combo), "interval-sb"); type = gtk_combo_box_get_active (combo); time = gtk_spin_button_get_value (GTK_SPIN_BUTTON (sb)); seconds = interval_to_seconds (type, time); value_string = g_strdup_printf ("%u", seconds); e_source_set_property (source, "refresh-interval", value_string); g_free (value_string); }
static void on_interval_sb_value_changed (GtkSpinButton *sb, gpointer user_data) { ESource *source = user_data; gdouble time; guint seconds; gchar *value_string; GtkWidget *interval_combo; IntervalType type; interval_combo = g_object_get_data (G_OBJECT (sb), "interval-combo"); type = gtk_combo_box_get_active (GTK_COMBO_BOX (interval_combo)); time = gtk_spin_button_get_value (sb); seconds = interval_to_seconds (type, time); value_string = g_strdup_printf ("%u", seconds); e_source_set_property (source, "refresh-interval", value_string); g_free (value_string); }
static void put_options_in_source (ESource *source, EGwSendOptionsGeneral *gopts, EGwSendOptionsStatusTracking *sopts) { gchar *value; const gchar *val; icaltimetype tt; if (gopts) { /* priority */ switch (gopts->priority) { case E_GW_PRIORITY_HIGH: value = g_strdup ("high"); break; case E_GW_PRIORITY_STANDARD: value = g_strdup ("standard"); break; case E_GW_PRIORITY_LOW: value = g_strdup ("low"); break; default: value = g_strdup ("undefined"); } e_source_set_property (source, "priority", value); g_free (value), value = NULL; /* Reply Requested */ /*TODO Fill the value if it is not "convinient" */ if (gopts->reply_enabled) { if (gopts->reply_convenient) value = g_strdup ("convinient"); else value = g_strdup_printf ("%d",gopts->reply_within); } else value = g_strdup ("none"); e_source_set_property (source, "reply-requested", value); g_free (value), value = NULL; /* Delay delivery */ if (gopts->delay_enabled) { tt = icaltime_today (); icaltime_adjust (&tt, gopts->delay_until, 0, 0, 0); val = icaltime_as_ical_string_r (tt); } else val = "none"; e_source_set_property (source, "delay-delivery", val); /* Expiration date */ if (gopts->expiration_enabled) value = g_strdup_printf ("%d", gopts->expire_after); else value = g_strdup ("none"); e_source_set_property (source, "expiration", value); g_free (value), value = NULL; } if (sopts) { /* status tracking */ if (sopts->tracking_enabled) { switch (sopts->track_when) { case E_GW_DELIVERED : value = g_strdup ("delivered"); break; case E_GW_DELIVERED_OPENED: value = g_strdup ("delivered-opened"); break; default: value = g_strdup ("all"); } } else value = g_strdup ("none"); e_source_set_property (source, "status-tracking", value); g_free (value), value = NULL; add_return_value (sopts->opened, source, "return-open"); add_return_value (sopts->accepted, source, "return-accept"); add_return_value (sopts->declined, source, "return-decline"); add_return_value (sopts->completed, source, "return-complete"); } }
GtkWidget * plugin_couchdb_contacts (EPlugin *epl, EConfigHookItemFactoryData *data) { ESource *source; ESourceGroup *group; const gchar *base_uri; GtkWidget *parent; GtkWidget *table, *label, *parent_vbox; UIData *ui; const gchar *property; EABConfigTargetSource *t = (EABConfigTargetSource *) data->target; source = t->source; group = e_source_peek_group (source); base_uri = e_source_group_peek_base_uri (group); g_object_set_data (G_OBJECT (epl), "cwidget", NULL); if (strcmp (base_uri, COUCHDB_BASE_URI) != 0) return NULL; /* Build up the UI */ ui = g_new0 (UIData, 1); ui->source = t->source; parent = data->parent; parent_vbox = gtk_widget_get_ancestor (gtk_widget_get_parent (parent), GTK_TYPE_VBOX); ui->vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (parent_vbox), ui->vbox, FALSE, FALSE, 0); label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), _("<b>Server</b>")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (ui->vbox), label, FALSE, FALSE, 0); table = gtk_table_new (3, 3, FALSE); gtk_box_pack_start (GTK_BOX (ui->vbox), table, TRUE, TRUE, 0); label = gtk_label_new (" "); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); ui->user_db_button = gtk_radio_button_new_with_label (NULL, _("Desktop CouchDB")); gtk_table_attach (GTK_TABLE (table), ui->user_db_button, 1, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 3, 3); ui->system_db_button = gtk_radio_button_new_with_label ( gtk_radio_button_get_group (GTK_RADIO_BUTTON (ui->user_db_button)), _("System-wide CouchDB")); gtk_table_attach (GTK_TABLE (table), ui->system_db_button, 1, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 3, 3); ui->remote_db_button = gtk_radio_button_new_with_label ( gtk_radio_button_get_group (GTK_RADIO_BUTTON (ui->user_db_button)), _("Remote CouchDB server")); gtk_table_attach (GTK_TABLE (table), ui->remote_db_button, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 3, 3); ui->remote_db_entry = gtk_entry_new (); gtk_table_attach (GTK_TABLE (table), ui->remote_db_entry, 2, 3, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 3, 3); gtk_widget_show_all (ui->vbox); /* Set values from the source */ property = e_source_get_property (ui->source, "couchdb_instance"); if (g_strcmp0 (property, "system") == 0) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ui->system_db_button), TRUE); gtk_widget_set_sensitive (ui->remote_db_entry, FALSE); } else if (g_strcmp0 (property, "remote") == 0) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ui->remote_db_button), TRUE); gtk_widget_set_sensitive (ui->remote_db_entry, TRUE); gtk_entry_set_text (GTK_ENTRY (ui->remote_db_entry), e_source_get_property (ui->source, "couchdb_remote_server")); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ui->user_db_button), TRUE); if (!property) e_source_set_property (ui->source, "couchdb_instance", "user"); gtk_widget_set_sensitive (ui->remote_db_entry, FALSE); } g_object_set_data_full (G_OBJECT (epl), "cwidget", ui, destroy_ui_data); g_signal_connect (ui->vbox, "destroy", G_CALLBACK (gtk_widget_destroyed), &ui->vbox); /* Signals */ g_signal_connect (G_OBJECT (ui->user_db_button), "toggled", G_CALLBACK (on_user_db_toggled), ui); g_signal_connect (G_OBJECT (ui->system_db_button), "toggled", G_CALLBACK (on_system_db_toggled), ui); g_signal_connect (G_OBJECT (ui->remote_db_button), "toggled", G_CALLBACK (on_remote_db_toggled), ui); g_signal_connect (G_OBJECT (ui->remote_db_entry), "changed", G_CALLBACK (on_remote_db_changed), ui); return NULL; }
static void sync_source_group (EAccount * account, ESourceGroup * group, int folder_type, CamelFolderInfo * ftree) { GSList *fi_list; GSList *def; GSList *iter; fi_list = folder_tree_flatten (ftree, folder_type, &def); for (iter = fi_list; iter != NULL; iter = g_slist_next (iter)) { ESource *source; CamelURL *url; CamelFolderInfo *info; const char *fuid; const char *pssl; char *uid; xmlNodePtr node; info = (CamelFolderInfo *) iter->data; url = camel_url_new (info->uri, NULL); g_print ("FOLDER_URI: %s\n", info->uri); if (url == NULL) { camel_url_free (url); continue; } /* the uid part */ fuid = camel_url_get_param (url, "uid"); if (fuid == NULL) { g_warning ("No Folder UID\n"); camel_url_free (url); continue; } uid = g_strdup_printf ("%s@%s", fuid, account->uid); /* there is no such thing as e_source_set_uid * so we have to cheat here a bit */ node = xmlNewNode (NULL, "source"); xmlSetProp (node, "uid", uid); xmlSetProp (node, "name", info->name); xmlSetProp (node, "relative_uri", info->full_name); source = e_source_new_from_xml_node (node); xmlFreeNode (node); g_free (uid); if (source == NULL) { g_warning ("Invalid source, skipping"); camel_url_free (url); /* FIXME free resources */ continue; } pssl = camel_url_get_param (url, "use_ssl"); if (pssl != NULL) { e_source_set_property (source, "use_ssl", pssl); } if (info->flags & CAMEL_FOLDER_IS_DEFAULT) { e_source_set_property (source, "default", "TRUE"); if (folder_type == CAMEL_SCALIX_FOLDER_CONTACT) { e_source_set_property (source, "completion", "TRUE"); } } camel_url_free (url); e_source_group_add_source (group, source, -1); } }
static gint on_idle_do_stuff (gpointer unused_data) { GConfClient *client = gconf_client_get_default (); ESourceGroup *new_group = NULL; ESource *new_source = NULL; list = e_source_list_new_for_gconf (client, key_arg); g_object_unref (client); if (add_group_arg != NULL) { if (group_arg != NULL) { fprintf (stderr, "--add-group and --group cannot be used at the same time.\n"); exit (1); } if (set_base_uri_arg == NULL) { fprintf (stderr, "When using --add-group, you need to specify a base URI using --set-base-uri.\n"); exit (1); } new_group = e_source_group_new (add_group_arg, set_base_uri_arg); e_source_list_add_group (list, new_group, -1); g_object_unref (new_group); e_source_list_sync (list, NULL); } if (remove_group_arg != NULL) { ESourceGroup *group; group = e_source_list_peek_group_by_uid (list, remove_group_arg); if (group == NULL) { fprintf (stderr, "No such group \"%s\".\n", remove_group_arg); exit (1); } e_source_list_remove_group (list, group); e_source_list_sync (list, NULL); } if (add_source_arg != NULL) { ESourceGroup *group; if (group_arg == NULL && new_group == NULL) { fprintf (stderr, "When using --add-source, you need to specify a group using either --group\n" "or --add-group.\n"); exit (1); } if (set_relative_uri_arg == NULL) { fprintf (stderr, "When using --add-source, you need to specify a relative URI using\n" "--set-relative-uri.\n"); exit (1); } if (group_arg == NULL) { group = new_group; } else { group = e_source_list_peek_group_by_uid (list, group_arg); if (group == NULL) { fprintf (stderr, "No such group \"%s\".\n", group_arg == NULL ? add_group_arg : group_arg); exit (1); } } new_source = e_source_new (add_source_arg, set_relative_uri_arg); e_source_group_add_source (group, new_source, -1); e_source_list_sync (list, NULL); } if (remove_source_arg != NULL) { ESource *source; source = e_source_list_peek_source_by_uid (list, remove_source_arg); if (source == NULL) { fprintf (stderr, "No such source \"%s\".\n", remove_source_arg); exit (1); } e_source_list_remove_source_by_uid (list, remove_source_arg); e_source_list_sync (list, NULL); } if (set_name_arg != NULL) { if (group_arg == NULL && source_arg == NULL) { fprintf (stderr, "When using --set-name, you need to specify a source (using --source" "alone) or a group (using --group alone).\n"); exit (1); } if (source_arg != NULL) { ESource *source = e_source_list_peek_source_by_uid (list, source_arg); if (source != NULL) { e_source_set_name (source, set_name_arg); } else { fprintf (stderr, "No such source \"%s\".\n", source_arg); exit (1); } } else { ESourceGroup *group = e_source_list_peek_group_by_uid (list, group_arg); if (group != NULL) { e_source_group_set_name (group, set_name_arg); } else { fprintf (stderr, "No such group \"%s\".\n", group_arg); exit (1); } } e_source_list_sync (list, NULL); } if (set_relative_uri_arg != NULL && add_source_arg == NULL) { ESource *source; if (source_arg == NULL) { fprintf (stderr, "When using --set-relative-uri, you need to specify a source using " "--source.\n"); exit (1); } source = e_source_list_peek_source_by_uid (list, source_arg); e_source_set_relative_uri (source, set_relative_uri_arg); e_source_list_sync (list, NULL); } if (set_color_arg != NULL) { ESource *source; if (add_source_arg == NULL && source_arg == NULL) { fprintf (stderr, "When using --set-color, you need to specify a source using --source\n"); exit (1); } if (add_source_arg != NULL) source = new_source; else source = e_source_list_peek_source_by_uid (list, source_arg); e_source_set_color_spec (source, set_color_arg); e_source_list_sync (list, NULL); } if (unset_color) { ESource *source; if (add_source_arg == NULL && source_arg == NULL) { fprintf (stderr, "When using --unset-color, you need to specify a source using --source\n"); exit (1); } if (add_source_arg != NULL) source = new_source; else source = e_source_list_peek_source_by_uid (list, source_arg); e_source_set_color_spec (source, NULL); e_source_list_sync (list, NULL); } if (set_base_uri_arg != NULL && add_group_arg == NULL) { ESourceGroup *group; if (group_arg == NULL) { fprintf (stderr, "When using --set-base-uri, you need to specify a group using --group.\n"); exit (1); } group = e_source_list_peek_group_by_uid (list, group_arg); e_source_group_set_base_uri (group, set_base_uri_arg); e_source_list_sync (list, NULL); } if (set_value_arg != NULL) { ESource *source; if (add_source_arg == NULL && source_arg == NULL) { fprintf (stderr, "When using --set-value, you need to specify a source using --source\n"); exit (1); } if (property_arg == NULL) { fprintf (stderr, "When using --set-value, you need to specify a property using --property\n"); exit (1); } if (add_source_arg != NULL) source = new_source; else source = e_source_list_peek_source_by_uid (list, source_arg); e_source_set_property (source, property_arg, set_value_arg); e_source_list_sync (list, NULL); } if (unset_value) { ESource *source; if (add_source_arg == NULL && source_arg == NULL) { fprintf (stderr, "When using --unset-value, you need to specify a source using --source\n"); exit (1); } if (property_arg == NULL) { fprintf (stderr, "When using --unset-value, you need to specify a property using --property\n"); exit (1); } if (add_source_arg != NULL) source = new_source; else source = e_source_list_peek_source_by_uid (list, source_arg); e_source_set_property (source, property_arg, NULL); e_source_list_sync (list, NULL); } connect_list (); if (dump) dump_list (); if (!listen) g_main_loop_quit (main_loop); return FALSE; }