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); }
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; }