Esempio n. 1
0
gint plugin_init(gchar **error)
{
    gchar *rcpath;

    /* Version check */
    if(!check_plugin_version(MAKE_NUMERIC_VERSION(3,13,2,39),
                             VERSION_NUMERIC, _("GData"), error))
        return -1;

    hook_address_completion = hooks_register_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST,
                              my_address_completion_build_list_hook, NULL);
    if(hook_address_completion == (guint) -1) {
        *error = g_strdup(_("Failed to register address completion hook in the GData plugin"));
        return -1;
    }

    hook_offline_switch = hooks_register_hook(OFFLINE_SWITCH_HOOKLIST, my_offline_switch_hook, NULL);
    if(hook_offline_switch == (guint) -1) {
        hooks_unregister_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, hook_address_completion);
        *error = g_strdup(_("Failed to register offline switch hook in the GData plugin"));
        return -1;
    }

    /* Configuration */
    prefs_set_default(cm_gdata_param);
    rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
    prefs_read_config(cm_gdata_param, "GDataPlugin", rcpath, NULL);
    g_free(rcpath);

    /* If the refresh token is still stored in config, save it to
     * password store. */
    if(cm_gdata_config.oauth2_refresh_token != NULL) {
        passwd_store_set(PWS_PLUGIN, "GData", GDATA_TOKEN_PWD_STRING,
                         cm_gdata_config.oauth2_refresh_token, TRUE);
        passwd_store_write_config();
    }

    cm_gdata_prefs_init();

    debug_print("GData plugin loaded\n");

    /* contacts cache */
    cm_gdata_load_contacts_cache_from_file();
    cm_gdata_update_contacts_update_timer();
    cm_gdata_update_contacts_cache();

    return 0;
}
Esempio n. 2
0
void vcal_prefs_init(void)
{
    static gchar *path[3];
    gchar *rcpath;
    gboolean passwords_migrated = FALSE;

    path[0] = _("Plugins");
    path[1] = _("vCalendar");
    path[2] = NULL;

    prefs_set_default(param);
    rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
    prefs_read_config(param, PREFS_BLOCK_NAME, rcpath, NULL);
    g_free(rcpath);

    /* Move passwords that are still in main config to password store. */
    if (vcalprefs.export_pass != NULL &&
            strlen(vcalprefs.export_pass) > 0) {
        passwd_store_set(PWS_PLUGIN, "vCalendar", "export",
                         vcalprefs.export_pass, TRUE);
        passwords_migrated = TRUE;
        memset(vcalprefs.export_pass, 0, strlen(vcalprefs.export_pass));
        g_free(vcalprefs.export_pass);
    }
    if (vcalprefs.export_freebusy_pass != NULL &&
            strlen(vcalprefs.export_freebusy_pass) > 0) {
        passwd_store_set(PWS_PLUGIN, "vCalendar", "export",
                         vcalprefs.export_freebusy_pass, TRUE);
        passwords_migrated = TRUE;
        memset(vcalprefs.export_freebusy_pass, 0, strlen(vcalprefs.export_freebusy_pass));
        g_free(vcalprefs.export_freebusy_pass);
    }

    if (passwords_migrated)
        passwd_store_write_config();

    vcal_prefs_page.page.path = path;
    vcal_prefs_page.page.create_widget = vcal_prefs_create_widget_func;
    vcal_prefs_page.page.destroy_widget = vcal_prefs_destroy_widget_func;
    vcal_prefs_page.page.save_page = vcal_prefs_save_func;

    prefs_gtk_register_page((PrefsPage *) &vcal_prefs_page);
}
Esempio n. 3
0
static void vcal_prefs_save_func(PrefsPage * _page)
{
    struct VcalendarPage *page = (struct VcalendarPage *) _page;
    gchar *pass;

    /* alert */
    vcalprefs.alert_enable =
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
                                     (page->alert_enable_btn));
    vcalprefs.alert_delay =
        60 * gtk_spin_button_get_value_as_int (
            GTK_SPIN_BUTTON(page->alert_delay_h_spinbtn))
        + gtk_spin_button_get_value_as_int (
            GTK_SPIN_BUTTON(page->alert_delay_m_spinbtn));

    /* calendar export */
    vcalprefs.export_enable =
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
                                     (page->export_enable_btn));

    vcalprefs.export_subs =
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
                                     (page->export_subs_btn));

    g_free(vcalprefs.export_path);
    vcalprefs.export_path =
        gtk_editable_get_chars(GTK_EDITABLE(page->export_path_entry), 0, -1);

    g_free(vcalprefs.export_command);
    vcalprefs.export_command =
        gtk_editable_get_chars(GTK_EDITABLE(page->export_command_entry), 0, -1);

    g_free(vcalprefs.export_user);
    vcalprefs.export_user =
        gtk_editable_get_chars(GTK_EDITABLE(page->export_user_entry), 0, -1);
    pass = gtk_editable_get_chars(GTK_EDITABLE(page->export_pass_entry), 0, -1);

    vcal_passwd_set("export", pass);
    memset(pass, 0, strlen(pass));
    g_free(pass);

    /* free/busy export */
    vcalprefs.export_freebusy_enable =
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
                                     (page->export_freebusy_enable_btn));

    g_free(vcalprefs.export_freebusy_path);
    vcalprefs.export_freebusy_path =
        gtk_editable_get_chars(GTK_EDITABLE(page->export_freebusy_path_entry), 0, -1);

    g_free(vcalprefs.export_freebusy_command);
    vcalprefs.export_freebusy_command =
        gtk_editable_get_chars(GTK_EDITABLE(page->export_freebusy_command_entry), 0, -1);

    g_free(vcalprefs.export_freebusy_user);
    vcalprefs.export_freebusy_user =
        gtk_editable_get_chars(GTK_EDITABLE(page->export_freebusy_user_entry), 0, -1);
    pass = gtk_editable_get_chars(GTK_EDITABLE(page->export_freebusy_pass_entry), 0, -1);

    vcal_passwd_set("export_freebusy", pass);
    memset(pass, 0, strlen(pass));
    g_free(pass);

    /* free/busy import */
    g_free(vcalprefs.freebusy_get_url);
    vcalprefs.freebusy_get_url =
        gtk_editable_get_chars(GTK_EDITABLE(page->freebusy_get_url_entry), 0, -1);

    /* SSL */
    vcalprefs.ssl_verify_peer =
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
                                     (page->ssl_verify_peer_checkbtn));

    vcal_prefs_save();
    passwd_store_write_config();
    vcal_folder_export(NULL);
}