本文整理汇总了C++中g_key_file_set_string函数的典型用法代码示例。如果您正苦于以下问题:C++ g_key_file_set_string函数的具体用法?C++ g_key_file_set_string怎么用?C++ g_key_file_set_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了g_key_file_set_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_wcs_data
static int handle_wcs_data(const uint8_t *tlv_msg, int length)
{
struct wifi_sc *wsc = NULL;
GKeyFile *keyfile = NULL;
int ret = -EINVAL;
wsc = decode_from_tlv(tlv_msg, length);
if (!wsc)
return -EINVAL;
if (!wsc->ssid)
goto out;
keyfile = g_key_file_new();
if (!keyfile) {
ret = -ENOMEM;
goto out;
}
g_key_file_set_string(keyfile, NEARD_SERVICE_GROUP,
SERVICE_KEY_TYPE, "wifi");
g_key_file_set_string(keyfile, NEARD_SERVICE_GROUP,
SERVICE_KEY_SSID, wsc->ssid);
g_key_file_set_boolean(keyfile, NEARD_SERVICE_GROUP,
SERVICE_KEY_HIDDEN, TRUE);
if (wsc->passphrase)
g_key_file_set_string(keyfile, NEARD_SERVICE_GROUP,
SERVICE_KEY_PASSPHRASE, wsc->passphrase);
ret = connman_config_provision_mutable_service(keyfile);
out:
g_key_file_unref(keyfile);
free_wifi_sc(wsc);
return ret;
}
示例2: sat_pref_layout_ok
/** User pressed OK. Any changes should be stored in config. */
void sat_pref_layout_ok(GKeyFile * cfg)
{
if (dirty)
{
/* we have new settings */
if (cfg != NULL)
{
g_key_file_set_string(cfg,
MOD_CFG_GLOBAL_SECTION,
MOD_CFG_GRID,
gtk_entry_get_text(GTK_ENTRY(gridstr)));
}
else
{
sat_cfg_set_str(SAT_CFG_STR_MODULE_GRID,
gtk_entry_get_text(GTK_ENTRY(gridstr)));
sat_cfg_set_bool(SAT_CFG_BOOL_MAIN_WIN_POS,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(mwin)));
sat_cfg_set_bool(SAT_CFG_BOOL_MOD_WIN_POS,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(mod)));
sat_cfg_set_bool(SAT_CFG_BOOL_MOD_STATE,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(state)));
}
}
else if (reset)
{
/* we have to reset the values to global or default settings */
if (cfg == NULL)
{
/* layout */
sat_cfg_reset_str(SAT_CFG_STR_MODULE_GRID);
/* window placement */
sat_cfg_reset_bool(SAT_CFG_BOOL_MAIN_WIN_POS);
sat_cfg_reset_bool(SAT_CFG_BOOL_MOD_WIN_POS);
sat_cfg_reset_bool(SAT_CFG_BOOL_MOD_STATE);
}
else
{
g_key_file_remove_key((GKeyFile *) (cfg),
MOD_CFG_GLOBAL_SECTION, MOD_CFG_GRID, NULL);
}
}
dirty = FALSE;
reset = FALSE;
}
示例3: save_state
static gboolean
save_state (time_t mtime,
gchar **converted)
{
gchar *filename;
GKeyFile *keyfile;
gchar *str;
GError *error;
gboolean result;
/* Make sure the state directory exists */
if (g_mkdir_with_parents (g_get_user_data_dir (), 0755))
{
g_printerr ("Failed to create directory %s: %s\n",
g_get_user_data_dir (), g_strerror (errno));
return FALSE;
}
filename = g_build_filename (g_get_user_data_dir (), "mateconf-gsettings-data-convert", NULL);
keyfile = g_key_file_new ();
str = g_strdup_printf ("%ld", mtime);
g_key_file_set_string (keyfile,
"State", "timestamp", str);
g_free (str);
g_key_file_set_string_list (keyfile,
"State", "converted",
(const gchar * const *)converted, g_strv_length (converted));
str = g_key_file_to_data (keyfile, NULL, NULL);
g_key_file_free (keyfile);
error = NULL;
if (!g_file_set_contents (filename, str, -1, &error))
{
g_printerr ("%s\n", error->message);
g_error_free (error);
result = FALSE;
}
else
result = TRUE;
g_free (filename);
g_free (str);
return result;
}
示例4: gnc_save_all_state
/** 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("");
}
示例5: hlfs_get_inode_info_setup
static void
hlfs_get_inode_info_setup(Fixture *fixture, const void *data) {
const char *test_dir = (const char *)data;
g_print("test env dir is %s\n", test_dir);
char *fs_dir = g_build_filename(test_dir, "testfs", NULL);
// g_assert(g_mkdir(fs_dir, 0700) == 0);
char *uri = g_malloc0(128);
g_assert(uri != NULL);
snprintf(uri, 128, "%s%s", "local://", fs_dir);
// char *uri = g_build_path(tmp, fs_dir, NULL);
g_print("uri is %s\n", uri);
pid_t status;
const char cmd[256];
memset((char *) cmd, 0, 256);
sprintf((char *) cmd, "%s %s %s %s %d %s %d %s %d", "../mkfs.hlfs",
"-u", uri,
"-b", 8192,
"-s", 67108864,
"-m", 1024);
g_message("cmd is [%s]", cmd);
status = system(cmd);
#if 0
GKeyFile *sb_keyfile = g_key_file_new();
g_key_file_set_string(sb_keyfile, "METADATA", "uri", uri);
g_key_file_set_integer(sb_keyfile, "METADATA", "block_size", 8196);
g_key_file_set_integer(sb_keyfile, "METADATA", "segment_size", 67108864);
g_key_file_set_integer(sb_keyfile, "METADATA", "max_fs_size", 671088640);
gchar *content = g_key_file_to_data(sb_keyfile, NULL, NULL);
char *sb_file_path = g_build_filename(fs_dir, "superblock", NULL);
g_print("sb file path is %s\n", sb_file_path);
GError *error = NULL;
if (TRUE != g_file_set_contents(sb_file_path, content, strlen(content) + 1, &error)) {
g_print("error msg is %s", error->message);
error = NULL;
}
#endif
fixture->uri = uri;
g_print("fixture->uri is %s\n", fixture->uri);
fixture->ctrl = init_hlfs(fixture->uri);
g_assert(fixture->ctrl != NULL);
int ret = hlfs_open(fixture->ctrl, 1);
g_assert(ret == 0);
take_snapshot(fixture, data);
test_hlfs_find_inode_before_time(fixture, data);
// g_key_file_free(sb_keyfile);
// g_free(sb_file_path);
g_free(fs_dir);
return ;
}
示例6: goa_utils_keyfile_set_string
void
goa_utils_keyfile_set_string (GoaAccount *account, const gchar *key, const gchar *value)
{
GError *error;
GKeyFile *key_file;
gchar *contents;
gchar *group;
gchar *path;
gsize length;
contents = NULL;
path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ());
group = g_strdup_printf ("Account %s", goa_account_get_id (account));
key_file = g_key_file_new ();
error = NULL;
if (!g_key_file_load_from_file (key_file,
path,
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
&error))
{
g_warning ("Error loading keyfile %s: %s (%s, %d)",
path,
error->message,
g_quark_to_string (error->domain),
error->code);
g_error_free (error);
goto out;
}
g_key_file_set_string (key_file, group, key, value);
contents = g_key_file_to_data (key_file, &length, NULL);
error = NULL;
if (!g_file_set_contents (path, contents, length, &error))
{
g_prefix_error (&error, "Error writing key-value-file %s: ", path);
g_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code);
g_error_free (error);
goto out;
}
out:
g_free (contents);
g_key_file_free (key_file);
g_free (group);
g_free (path);
}
示例7: mc_config_set_string
void
mc_config_set_string (const mc_config_t * mc_config, const gchar * group,
const gchar * param, const gchar * value)
{
gchar *buffer;
if (!mc_config || !group || !param || !value)
return;
buffer = mc_config_normalize_before_save (value);
g_key_file_set_string (mc_config->handle, group, param, buffer);
g_free (buffer);
}
示例8: on_save_preferences
static void
on_save_preferences (Viewer *viewer, GKeyFile *keyfile, void *user_data)
{
RendererCamThumb *self = user_data;
GPtrArray *keys = gu_hash_table_get_keys(self->cam_handlers);
for (int k = 0; k < g_ptr_array_size(keys); k++) {
char *key = g_ptr_array_index(keys, k);
cam_renderer_t *cr = g_hash_table_lookup(self->cam_handlers, key);
char str[80];
sprintf (str, "%d %d", cr->render_place, cr->expanded);
g_key_file_set_string (keyfile, RENDERER_NAME, key, str);
}
}
示例9: add_remote_to_keyfile
static gboolean
add_remote_to_keyfile (GKeyFile *new_keyfile,
const char *key,
const char *url,
GPtrArray *branches,
GError **error)
{
gboolean ret = FALSE;
char **iter;
g_key_file_set_string (new_keyfile, key, "url", url);
for (iter = opt_set; iter && *iter; iter++)
{
const char *keyvalue = *iter;
gs_free char *subkey = NULL;
gs_free char *subvalue = NULL;
if (!parse_keyvalue (keyvalue, &subkey, &subvalue, error))
goto out;
g_key_file_set_string (new_keyfile, key, subkey, subvalue);
}
if (branches->len > 0)
g_key_file_set_string_list (new_keyfile, key, "branches",
(const char *const *)branches->pdata,
branches->len);
if (opt_no_gpg_verify)
g_key_file_set_boolean (new_keyfile, key, "gpg-verify", FALSE);
ret = TRUE;
out:
return ret;
}
示例10: keystore_store_key
/**
* Sets a key in the key store file.
*/
bool keystore_store_key(const char *nick, const char *key) {
const char *password;
char *encrypted;
char *wrapped;
bool ok = false;
GKeyFile *keyfile = getConfigFile();
// Remove old key
delete_nick(keyfile, nick);
// Add new key
password = get_keystore_password();
if (password) {
// Encrypt the password
encrypted = fish_encrypt(password, strlen(password), key);
if (!encrypted) goto end;
// Prepend "+OK "
wrapped = g_strconcat("+OK ", encrypted, NULL);
g_free(encrypted);
// Store encrypted in file
g_key_file_set_string(keyfile, nick, "key", wrapped);
free(wrapped);
} else {
// Store unencrypted in file
g_key_file_set_string(keyfile, nick, "key", key);
}
// Save key store file
ok = save_keystore(keyfile);
end:
g_key_file_free(keyfile);
return ok;
}
示例11: create_conf_file
/* create basic conffile with sensible defaults */
static void create_conf_file(void)
{
GKeyFile *settingsfile;
gchar *keyfile;
mkdir(CONFIG_FILE_DIR, 0755);
settingsfile = g_key_file_new();
g_key_file_set_string(settingsfile, MODE_SETTING_ENTRY, MODE_SETTING_KEY, MODE_DEVELOPER );
keyfile = g_key_file_to_data (settingsfile, NULL, NULL);
if(g_file_set_contents(FS_MOUNT_CONFIG_FILE, keyfile, -1, NULL) == 0)
log_debug("Conffile creation failed. Continuing without configuration!\n");
g_key_file_free(settingsfile);
}
示例12: policy_allowed_bearers
static void policy_allowed_bearers(const char *allowed_bearers)
{
struct passwd *pwd;
uid_t uid;
char *pathname;
GKeyFile *keyfile;
LOG("update to '%s'", allowed_bearers);
uid = getuid();
pwd = getpwuid(uid);
g_assert(pwd);
keyfile = g_key_file_new();
g_key_file_set_string(keyfile, "policy_foo", "uid", pwd->pw_name);
g_key_file_set_string(keyfile, "policy_foo", "AllowedBearers",
allowed_bearers);
pathname = g_strdup_printf("%s/foo.policy", POLICYDIR);
policy_save(keyfile, pathname);
g_free(pathname);
g_key_file_unref(keyfile);
}
示例13: cairo_dock_add_remove_element_to_key
void cairo_dock_add_remove_element_to_key (const gchar *cConfFilePath, const gchar *cGroupName, const gchar *cKeyName, gchar *cElementName, gboolean bAdd)
{
GKeyFile *pKeyFile = cairo_dock_open_key_file (cConfFilePath);
if (pKeyFile == NULL)
return ;
gchar *cElementList = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL), *cNewElementList = NULL;
if (cElementList != NULL && *cElementList == '\0')
{
g_free (cElementList);
cElementList= NULL;
}
if (bAdd)
{
//g_print ("on rajoute %s\n", cElementName);
if (cElementList != NULL)
cNewElementList = g_strdup_printf ("%s;%s", cElementList, cElementName);
else
cNewElementList = g_strdup (cElementName);
}
else
{
//g_print ("on enleve %s\n", cElementName);
gchar *str = g_strstr_len (cElementList, strlen (cElementList), cElementName);
g_return_if_fail (str != NULL);
if (str == cElementList)
{
if (str[strlen (cElementName)] == '\0')
cNewElementList = g_strdup ("");
else
cNewElementList = g_strdup (str + strlen (cElementName) + 1);
}
else
{
*(str-1) = '\0';
if (str[strlen (cElementName)] == '\0')
cNewElementList = g_strdup (cElementList);
else
cNewElementList = g_strdup_printf ("%s;%s", cElementList, str + strlen (cElementName) + 1);
}
}
g_key_file_set_string (pKeyFile, cGroupName, cKeyName, cNewElementList);
cairo_dock_write_keys_to_file (pKeyFile, cConfFilePath);
g_free (cElementList);
g_free (cNewElementList);
g_key_file_free (pKeyFile);
}
示例14: anjuta_session_set_string
/**
* anjuta_session_set_string:
* @session: an #AnjutaSession object
* @section: Section.
* @key: Key name.
* @value: Key value
*
* Set a string @value to @key in given @section.
*/
void
anjuta_session_set_string (AnjutaSession *session, const gchar *section,
const gchar *key, const gchar *value)
{
g_return_if_fail (ANJUTA_IS_SESSION (session));
g_return_if_fail (section != NULL);
g_return_if_fail (key != NULL);
if (!value)
{
g_key_file_remove_key (session->priv->key_file, section, key, NULL);
return;
}
g_key_file_set_string (session->priv->key_file, section, key, value);
}
示例15: gather_unlock_options
/**
* builder: the gtk builder object
* dialog: The dialog to extract the data from
*
* Gets the unlocking settings and stores them in output_data
*
**/
static void
gather_unlock_options (GtkBuilder *builder, GtkDialog *dialog)
{
GcrUnlockOptionsWidget *unlock;
const gchar *choice;
unlock = g_object_get_data (G_OBJECT (dialog), "unlock-options-widget");
choice = gcr_unlock_options_widget_get_choice (unlock);
if (choice) {
g_key_file_set_integer (output_data, "unlock-options", "ttl",
gcr_unlock_options_widget_get_ttl (unlock));
g_key_file_set_string (output_data, "unlock-options", "choice", choice);
}
}