void MetadataManager::cleanupMetadata() { XOJ_CHECK_TYPE(MetadataManager); GList* data = NULL; gsize lenght = 0; gchar** groups = g_key_file_get_groups(this->config, &lenght); for (gsize i = 0; i < lenght; i++) { char* group = groups[i]; GFile* file = g_file_new_for_uri(group); bool exists = g_file_query_exists(file, NULL); g_object_unref(file); if (!exists) { g_key_file_remove_group(this->config, group, NULL); continue; } GError* error = NULL; // TODO LOW PRIO: newer GTK Version use _int64 instead of integer int time = g_key_file_get_integer(this->config, group, "atime", &error); if (error) { g_error_free(error); continue; } GroupTimeEntry* e = g_new(GroupTimeEntry, 1); e->group = group; e->time = time; data = g_list_insert_sorted(data, e, (GCompareFunc) timeCompareFunc); } int count = g_list_length(data); GList* d = data; if (count > METADATA_MAX_ITEMS) { for (int i = count - METADATA_MAX_ITEMS; i > 0 && d; i--) { GroupTimeEntry* e = (GroupTimeEntry*) d->data; g_key_file_remove_group(this->config, e->group, NULL); d = d->next; } } g_list_foreach(data, (GFunc) g_free, NULL); g_list_free(data); g_strfreev(groups); }
/* http://bugzilla.gnome.org/show_bug.cgi?id=165887 */ void test_group_remove (void) { gchar **names; gsize len; GError *error = NULL; const gchar *data = "[group1]\n" "[group2]\n" "key1=bla\n" "key2=bla\n" "[group3]\n" "key1=bla\n" "key2=bla\n"; cut_assert (g_key_file_load_from_data (keyfile, data, -1, 0, NULL)); names = g_key_file_get_groups (keyfile, &len); cut_assert (names); check_length ("groups", g_strv_length (names), len, 3); check_name ("group name", names[0], "group1", 0); check_name ("group name", names[1], "group2", 1); check_name ("group name", names[2], "group3", 2); g_key_file_remove_group (keyfile, "group1", &error); check_no_error (error); g_strfreev (names); names = g_key_file_get_groups (keyfile, &len); cut_assert (names); check_length ("groups", g_strv_length (names), len, 2); check_name ("group name", names[0], "group2", 0); check_name ("group name", names[1], "group3", 1); g_key_file_remove_group (keyfile, "group2", &error); check_no_error (error); g_strfreev (names); names = g_key_file_get_groups (keyfile, &len); cut_assert (names); check_length ("groups", g_strv_length (names), len, 1); check_name ("group name", names[0], "group3", 0); g_key_file_remove_group (keyfile, "no such group", &error); check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND); g_strfreev (names); }
gboolean mc_config_del_group (mc_config_t * mc_config, const char *group) { if (!mc_config || !group) return FALSE; #if GLIB_CHECK_VERSION (2, 15, 0) return g_key_file_remove_group (mc_config->handle, group, NULL); #else g_key_file_remove_group (mc_config->handle, group, NULL); return TRUE; #endif }
static gboolean password_provider_keyfile_forget (TrackerPasswordProvider *provider, const gchar *service, GError **error) { TrackerPasswordProviderKeyfilePrivate *priv; GError *local_error = NULL; priv = TRACKER_PASSWORD_PROVIDER_KEYFILE_GET_PRIVATE (provider); if (!g_key_file_remove_group (priv->password_file, service, &local_error)) { g_warning ("Could not remove GKeyFile group '%s' from password file, %s", service, local_error->message); g_error_free (local_error); g_set_error_literal (error, TRACKER_PASSWORD_PROVIDER_ERROR, TRACKER_PASSWORD_PROVIDER_ERROR_NOTFOUND, "Could not find service for GKeyFile password"); return FALSE; } return TRUE; }
static void write_proximity_config(struct btd_device *device, const char *alert, const char *level) { char *filename; GKeyFile *key_file; char *data; gsize length = 0; filename = btd_device_get_storage_path(device, "proximity"); key_file = g_key_file_new(); g_key_file_load_from_file(key_file, filename, 0, NULL); if (level) g_key_file_set_string(key_file, alert, "Level", level); else g_key_file_remove_group(key_file, alert, NULL); data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } g_free(data); g_free(filename); g_key_file_free(key_file); }
static void ep_clear_passwords_keyfile (EPassMsg *msg) { gchar *group; GError *error = NULL; if (!check_key_file (G_STRFUNC)) return; group = ep_key_file_get_group (msg->component); if (g_key_file_remove_group (key_file, group, &error)) ep_key_file_save (); /* Not finding the requested group is acceptable, but we still * want to leave an informational message on the terminal. */ else if (g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { g_message ("%s", error->message); g_error_free (error); } else if (error != NULL) g_propagate_error (&msg->error, error); g_free (group); }
void CsvImportSettings::remove_common (void) { auto keyfile = gnc_state_get_current (); auto group = csv_group_prefix + m_settings_type + " - " + m_name; g_key_file_remove_group (keyfile, group.c_str(), nullptr); }
/* delete a group from the keyfile */ static gboolean gst_preset_default_delete_preset (GstPreset * preset, const gchar * name) { GKeyFile *presets; /* get the presets from the type */ if (!(presets = preset_get_keyfile (preset))) goto no_presets; /* get the group */ if (!g_key_file_has_group (presets, name)) goto no_group; /* remove the group */ g_key_file_remove_group (presets, name, NULL); /* save updated version */ return gst_preset_default_save_presets_file (preset); /* ERRORS */ no_presets: { GST_WARNING_OBJECT (preset, "no presets"); return FALSE; } no_group: { GST_WARNING_OBJECT (preset, "no preset named %s", name); return FALSE; } }
gboolean accounts_rename(const char * const account_name, const char * const new_name) { if (g_key_file_has_group(accounts, new_name)) { return FALSE; } if (!g_key_file_has_group(accounts, account_name)) { return FALSE; } // treat all properties as strings for copy gchar *string_keys[] = { "enabled", "jid", "server", "port", "resource", "password", "eval_password", "presence.last", "presence.laststatus", "presence.login", "priority.online", "priority.chat", "priority.away", "priority.xa", "priority.dnd", "muc.service", "muc.nick", "otr.policy", "otr.manual", "otr.opportunistic", "otr.always", "pgp.keyid", "last.activity" }; int i; for (i = 0; i < ARRAY_SIZE(string_keys); i++) { char *value = g_key_file_get_string(accounts, account_name, string_keys[i], NULL); if (value) { g_key_file_set_string(accounts, new_name, string_keys[i], value); g_free(value); } } g_key_file_remove_group(accounts, account_name, NULL); _save_accounts(); autocomplete_remove(all_ac, account_name); autocomplete_add(all_ac, new_name); if (g_key_file_get_boolean(accounts, new_name, "enabled", NULL)) { autocomplete_remove(enabled_ac, account_name); autocomplete_add(enabled_ac, new_name); } return TRUE; }
void libbalsa_conf_remove_group_(const char *group, gboolean priv) { lbc_lock(); g_key_file_remove_group(LBC_KEY_FILE(priv), group, NULL); LBC_CHANGED(priv); lbc_unlock(); }
int accounts_remove(const char *account_name) { int r = g_key_file_remove_group(accounts, account_name, NULL); _save_accounts(); autocomplete_remove(all_ac, account_name); autocomplete_remove(enabled_ac, account_name); return r; }
static void remove_from_saved_permissions (const char *path, mode_t remove_mask) { GKeyFile *key_file; char *key_file_path; if (remove_mask == 0) return; key_file = g_key_file_new (); key_file_path = get_key_file_path (); if (g_key_file_load_from_file (key_file, key_file_path, 0, NULL)) { mode_t need_mask; mode_t remove_from_current_mask; char *str; need_mask = 0; /* NULL GError */ str = g_key_file_get_string (key_file, path, "need_mask", NULL); if (str) { guint i; if (sscanf (str, "%o", &i) == 1) /* octal */ need_mask = i; g_free (str); } remove_from_current_mask = need_mask & remove_mask; remove_permissions (path, remove_from_current_mask); need_mask &= ~remove_mask; if (need_mask == 0) { /* NULL GError */ g_key_file_remove_group (key_file, path, NULL); } else { char buf[50]; g_snprintf (buf, sizeof (buf), "%o", (guint) need_mask); /* octal */ g_key_file_set_string (key_file, path, "need_mask", buf); } save_key_file (key_file_path, key_file); } g_key_file_free (key_file); g_free (key_file_path); }
/** * anjuta_session_clear_section: * @session: an #AnjutaSession object. * @section: Section to clear. * * Clears the given section in session object. */ void anjuta_session_clear_section (AnjutaSession *session, const gchar *section) { g_return_if_fail (ANJUTA_IS_SESSION (session)); g_return_if_fail (section != NULL); g_key_file_remove_group (session->priv->key_file, section, NULL); }
void gpc_queue_purge_request(GPilotRequest **req) { gchar *section = NULL; int num; GKeyFile *kfile; LOG (("gpc_queue_purge_request()")); g_return_if_fail (req != NULL); g_return_if_fail (*req != NULL); kfile = get_queue_kfile (); set_section ((*req)->pilot_id, (*req)->type, §ion); num = g_key_file_get_integer (kfile, section, NUMREQ, NULL); num--; g_key_file_set_integer (kfile, section, NUMREQ, num); g_key_file_remove_group (kfile, (*req)->queue_data.section_name, NULL); switch((*req)->type) { case GREQ_INSTALL: unlink((*req)->parameters.install.filename); g_free((*req)->parameters.install.filename); g_free((*req)->parameters.install.description); break; case GREQ_RESTORE: g_free((*req)->parameters.restore.directory); break; case GREQ_CONDUIT: g_free((*req)->parameters.conduit.name); break; case GREQ_GET_USERINFO: break; case GREQ_GET_SYSINFO: break; case GREQ_NEW_USERINFO: case GREQ_SET_USERINFO: g_free((*req)->parameters.set_userinfo.user_id); g_free((*req)->parameters.set_userinfo.password); break; default: g_assert_not_reached(); break; } g_free((*req)->cradle); g_free((*req)->client_id); g_free((*req)->queue_data.section_name); g_free(*req); *req = NULL; g_free (section); save_queue_kfile (kfile); g_key_file_free (kfile); }
void CsvTransSettings::remove (void) { if (trans_preset_is_reserved_name (m_name)) return; auto keyfile = gnc_state_get_current (); auto group = csv_group_prefix + m_name; g_key_file_remove_group (keyfile, group.c_str(), nullptr); }
static void save_session_settings (RBAudioscrobblerAccount *account) { /* Save the current session */ const char *rb_data_dir; char *file_path; GKeyFile *key_file; char *service_name; char *data; gsize data_length; GFile *out_file; GError *error; rb_data_dir = rb_user_data_dir (); if (rb_data_dir == NULL) { rb_debug ("error saving session: could not find data dir"); return; } file_path = g_build_filename (rb_data_dir, "audioscrobbler", SESSION_SETTINGS_FILE, NULL); key_file = g_key_file_new (); /* load existing file contents. errors wont matter, just means file doesn't exist yet */ g_key_file_load_from_file (key_file, file_path, G_KEY_FILE_KEEP_COMMENTS, NULL); /* get the service name */ g_object_get (account->priv->service, "name", &service_name, NULL); /* set the new data */ if (account->priv->username != NULL && account->priv->session_key != NULL) { g_key_file_set_string (key_file, service_name, "username", account->priv->username); g_key_file_set_string (key_file, service_name, "session_key", account->priv->session_key); } else { g_key_file_remove_group (key_file, service_name, NULL); } g_free (service_name); data = g_key_file_to_data (key_file, &data_length, NULL); g_key_file_free (key_file); /* write data to the file */ out_file = g_file_new_for_path (file_path); g_free (file_path); error = NULL; g_file_replace_contents (out_file, data, data_length, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL, &error); if (error != NULL) { rb_debug ("error saving session: %s", error->message); g_error_free (error); } else { rb_debug ("successfully saved session"); } g_free (data); g_object_unref (out_file); }
/* copies all keys and comments from one group to another, deleting the old * group. */ static gboolean gst_preset_default_rename_preset (GstPreset * preset, const gchar * old_name, const gchar * new_name) { GKeyFile *presets; gchar *str; gchar **keys; gsize i, num_keys; /* get the presets from the type */ if (!(presets = preset_get_keyfile (preset))) goto no_presets; if (!g_key_file_has_group (presets, old_name)) goto no_group; /* copy group comment if there is any */ if ((str = g_key_file_get_comment (presets, old_name, NULL, NULL))) { g_key_file_set_comment (presets, new_name, NULL, str, NULL); g_free (str); } /* get all keys from the old group and copy them in the new group */ keys = g_key_file_get_keys (presets, old_name, &num_keys, NULL); for (i = 0; i < num_keys; i++) { /* copy key comment if there is any */ if ((str = g_key_file_get_comment (presets, old_name, keys[i], NULL))) { g_key_file_set_comment (presets, new_name, keys[i], str, NULL); g_free (str); } /* copy key value */ str = g_key_file_get_value (presets, old_name, keys[i], NULL); g_key_file_set_value (presets, new_name, keys[i], str); g_free (str); } g_strfreev (keys); /* remove old group */ g_key_file_remove_group (presets, old_name, NULL); /* save updated version */ return gst_preset_default_save_presets_file (preset); /* ERRORS */ no_presets: { GST_WARNING_OBJECT (preset, "no presets"); return FALSE; } no_group: { GST_WARNING_OBJECT (preset, "no preset named %s", old_name); return FALSE; } }
gboolean prefs_reset_room_notify(const char *const roomjid) { if (g_key_file_has_group(prefs, roomjid)) { g_key_file_remove_group(prefs, roomjid, NULL); _save_prefs(); return TRUE; } return FALSE; }
gboolean tlscerts_revoke(const char *const fingerprint) { gboolean result = g_key_file_remove_group(tlscerts, fingerprint, NULL); if (result) { autocomplete_remove(certs_ac, fingerprint); } _save_tlscerts(); return result; }
/** Save all persistent program state to disk. This function finds the * name of the "new" state file associated with a specific book guid. * It saves some top level data, then iterates through the list of * open windows calling a helper function to save each window. * * @note The name of the state file is based on the name of the data * file, not the path name of the data file. If there are multiple * data files with the same name, the state files will be suffixed * with a number. E.G. test_account, test_account_2, test_account_3, * etc. * * @param session The QofSession whose state should be saved. * * @param unused */ static void gnc_save_all_state (gpointer session, gpointer unused) { QofBook *book; gchar guid_string[GUID_ENCODING_LENGTH+1]; const GncGUID *guid; GKeyFile *keyfile = NULL; keyfile = gnc_state_get_current (); if (keyfile) { /* Remove existing Window and Page groups from the keyfile * They will be regenerated. */ gsize num_groups, curr; gchar **groups = g_key_file_get_groups (keyfile, &num_groups); for (curr=0; curr < num_groups; curr++) { if (g_str_has_prefix (groups[curr], "Window ") || g_str_has_prefix (groups[curr], "Page ")) { DEBUG ("Removing state group %s", groups[curr]); g_key_file_remove_group (keyfile, groups[curr], NULL); } } g_strfreev (groups); } /* Store the book's GncGUID in the top level group */ book = qof_session_get_book(session); guid = qof_entity_get_guid(QOF_INSTANCE(book)); guid_to_string_buff(guid, guid_string); g_key_file_set_string(keyfile, STATE_FILE_TOP, STATE_FILE_BOOK_GUID, guid_string); gnc_main_window_save_all_windows(keyfile); #ifdef DEBUG /* Debugging: dump a copy to the trace log */ { gchar *file_data; gsize file_length; file_data = g_key_file_to_data(keyfile, &file_length, NULL); DEBUG("=== File Data Written===\n%s\n=== File End ===\n", file_data); g_free(file_data); } #endif LEAVE(""); }
/** * Deletes a nick and the associated key in the key store file. */ static bool delete_nick(GKeyFile *keyfile, const char *nick) { gchar **group; gchar **groups = g_key_file_get_groups(keyfile, NULL); bool ok = false; for (group = groups; *group != NULL; group++) { if (!irc_nick_cmp(*group, nick)) { ok = g_key_file_remove_group(keyfile, *group, NULL); break; } } g_strfreev(groups); return ok; }
void config_clear_section (const char * section) { g_return_if_fail (defaults && keyfile); pthread_mutex_lock (& mutex); if (! section) section = DEFAULT_SECTION; if (g_key_file_has_group (keyfile, section)) { g_key_file_remove_group (keyfile, section, NULL); modified = TRUE; } pthread_mutex_unlock (& mutex); }
static gboolean _accounts_rename(const char * const account_name, const char * const new_name) { if (g_key_file_has_group(accounts, new_name)) { return FALSE; } if (!g_key_file_has_group(accounts, account_name)) { return FALSE; } g_key_file_set_boolean(accounts, new_name, "enabled", g_key_file_get_boolean(accounts, account_name, "enabled", NULL)); g_key_file_set_integer(accounts, new_name, "priority.online", g_key_file_get_integer(accounts, account_name, "priority.online", NULL)); g_key_file_set_integer(accounts, new_name, "priority.chat", g_key_file_get_integer(accounts, account_name, "priority.chat", NULL)); g_key_file_set_integer(accounts, new_name, "priority.away", g_key_file_get_integer(accounts, account_name, "priority.away", NULL)); g_key_file_set_integer(accounts, new_name, "priority.xa", g_key_file_get_integer(accounts, account_name, "priority.xa", NULL)); g_key_file_set_integer(accounts, new_name, "priority.dnd", g_key_file_get_integer(accounts, account_name, "priority.dnd", NULL)); // copy other string properties int i; for (i = 0; i < ARRAY_SIZE(string_keys); i++) { char *value = g_key_file_get_string(accounts, account_name, string_keys[i], NULL); if (value != NULL) { g_key_file_set_string(accounts, new_name, string_keys[i], value); g_free(value); } } g_key_file_remove_group(accounts, account_name, NULL); _save_accounts(); autocomplete_remove(all_ac, account_name); autocomplete_add(all_ac, new_name); if (g_key_file_get_boolean(accounts, new_name, "enabled", NULL)) { autocomplete_remove(enabled_ac, account_name); autocomplete_add(enabled_ac, new_name); } return TRUE; }
static void preset_merge (GKeyFile * system, GKeyFile * user) { gchar *str; gchar **groups, **keys; gsize i, j, num_groups, num_keys; /* copy file comment if there is any */ if ((str = g_key_file_get_comment (user, NULL, NULL, NULL))) { g_key_file_set_comment (system, NULL, NULL, str, NULL); g_free (str); } /* get groups in user and copy into system */ groups = g_key_file_get_groups (user, &num_groups); for (i = 0; i < num_groups; i++) { /* copy group comment if there is any */ if ((str = g_key_file_get_comment (user, groups[i], NULL, NULL))) { g_key_file_set_comment (system, groups[i], NULL, str, NULL); g_free (str); } /* ignore private groups */ if (groups[i][0] == '_') continue; /* if group already exists in system, remove and re-add keys from user */ if (g_key_file_has_group (system, groups[i])) { g_key_file_remove_group (system, groups[i], NULL); } keys = g_key_file_get_keys (user, groups[i], &num_keys, NULL); for (j = 0; j < num_keys; j++) { /* copy key comment if there is any */ if ((str = g_key_file_get_comment (user, groups[i], keys[j], NULL))) { g_key_file_set_comment (system, groups[i], keys[j], str, NULL); g_free (str); } str = g_key_file_get_value (user, groups[i], keys[j], NULL); g_key_file_set_value (system, groups[i], keys[j], str); g_free (str); } g_strfreev (keys); } g_strfreev (groups); }
static gboolean set_to_keyfile (GKeyfileSettingsBackend *kfsb, const gchar *key, GVariant *value) { gchar *group, *name; if (g_hash_table_contains (kfsb->system_locks, key)) return FALSE; if (convert_path (kfsb, key, &group, &name)) { if (value) { gchar *str = g_variant_print (value, FALSE); g_key_file_set_value (kfsb->keyfile, group, name, str); g_variant_unref (g_variant_ref_sink (value)); g_free (str); } else { if (*name == '\0') { gchar **groups; gint i; groups = g_key_file_get_groups (kfsb->keyfile, NULL); for (i = 0; groups[i]; i++) if (group_name_matches (groups[i], group)) g_key_file_remove_group (kfsb->keyfile, groups[i], NULL); g_strfreev (groups); } else g_key_file_remove_key (kfsb->keyfile, group, name, NULL); } g_free (group); g_free (name); return TRUE; } return FALSE; }
gint gnc_state_drop_sections_for (const gchar *partial_name) { gchar **groups; gint found_count = 0, dropped_count = 0; gsize i, num_groups; GError *error = NULL; if (!state_file) { PWARN ("No pre-existing state found, ignoring drop request"); return 0; } ENTER(""); groups = g_key_file_get_groups (state_file, &num_groups); for (i = 0; i < num_groups; i++) { if (g_strstr_len (groups[i], -1, partial_name)) { DEBUG ("Section \"%s\" matches \"%s\", removing", groups[i], partial_name); found_count++; if (!g_key_file_remove_group (state_file, groups[i], &error)) { PWARN ("Warning: unable to remove section %s.\n %s", groups[i], error->message); g_error_free (error); } else dropped_count++; } } g_strfreev (groups); LEAVE("Found %i sections matching \"%s\", successfully removed %i", found_count, partial_name, dropped_count); return dropped_count; }
/* * Remove a map provider from the list store. Returns a new row number (e.g., * to replace combobox selections) if the provider was removed, or -1 if it is a * built-in default provider. */ gint ph_config_remove_map_provider(GtkTreeIter *iter, guint row) { gchar *name; gchar *group; gboolean predefined; gint result = -1; g_return_val_if_fail(ph_config != NULL, FALSE); g_return_val_if_fail(iter != NULL, FALSE); if (ph_config->map_providers == NULL) (void) ph_config_get_map_providers(); g_return_val_if_fail(ph_config->map_providers != NULL, FALSE); gtk_tree_model_get(GTK_TREE_MODEL(ph_config->map_providers), iter, PH_MAP_PROVIDER_COLUMN_NAME, &name, PH_MAP_PROVIDER_COLUMN_PREDEFINED, &predefined, -1); if (!predefined) { gtk_list_store_remove(ph_config->map_providers, iter); group = ph_config_get_map_provider_group(name); (void) g_key_file_remove_group(ph_config->key_file, group, NULL); g_free(group); if (row >= (guint) gtk_tree_model_iter_n_children( GTK_TREE_MODEL(ph_config->map_providers), NULL)) result = row - 1; else result = row; } g_free(name); return result; }
gboolean dfu_key_file_rename_group (GKeyFile *keyfile, const char *oldgroup, const char *newgroup) { char **keys; char *value; unsigned int i; g_return_val_if_fail (keyfile != NULL, FALSE); if (!g_key_file_has_group (keyfile, oldgroup)) return TRUE; keys = g_key_file_get_keys (keyfile, oldgroup, NULL, NULL); for (i = 0; keys[i] != NULL; i++) { value = g_key_file_get_value (keyfile, oldgroup, keys[i], NULL); g_key_file_set_value (keyfile, newgroup, keys[i], value); g_free (value); value = g_key_file_get_comment (keyfile, oldgroup, keys[i], NULL); if (value) { g_key_file_set_comment (keyfile, newgroup, keys[i], value, NULL); g_free (value); } } g_strfreev (keys); value = g_key_file_get_comment (keyfile, oldgroup, NULL, NULL); if (value) { g_key_file_set_comment (keyfile, newgroup, NULL, value, NULL); g_free (value); } g_key_file_remove_group (keyfile, oldgroup, NULL); return TRUE; }
static void ep_forget_passwords_keyfile (EPassMsg *msg) { gchar **groups; gsize length = 0, ii; if (!check_key_file (G_STRFUNC)) return; groups = g_key_file_get_groups (key_file, &length); if (!groups) return; for (ii = 0; ii < length; ii++) { GError *error = NULL; if (!g_str_has_prefix (groups[ii], KEY_FILE_GROUP_PREFIX)) continue; g_key_file_remove_group (key_file, groups[ii], &error); /* Not finding the requested group is acceptable, but we still * want to leave an informational message on the terminal. */ if (g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { g_message ("%s", error->message); g_error_free (error); /* Issue a warning if anything else goes wrong. */ } else if (error != NULL) { g_warning ("%s", error->message); g_error_free (error); } } ep_key_file_save (); g_strfreev (groups); }
gboolean imgur_forget_record (const gchar *record_name) { gboolean result = TRUE; gchar *path = get_path (); gchar *filename = get_filename (path); GKeyFile *keyfile = get_keyfile (path); gchar *local_thumbnail = get_local_thumbnail (path, keyfile, record_name); gchar *temp; if (g_file_test (local_thumbnail, G_FILE_TEST_IS_REGULAR)) { g_unlink (local_thumbnail); } result = g_key_file_remove_group (keyfile, record_name, NULL); temp = g_key_file_to_data (keyfile, NULL, NULL); g_file_set_contents (filename, temp, -1, NULL); g_free (temp); g_free (filename); g_free (path); /* FIXME: free the keyfile? */ return result; }