aboutsummaryrefslogtreecommitdiff
path: root/src/familiar-players-db.c
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2010-11-18 11:13:31 -0500
committerKen VanDine <ken.vandine@canonical.com>2010-11-18 11:13:31 -0500
commit13bc64e0a3c144740c30e2469fdb5f605d58ee39 (patch)
tree21b2af1f4d2d796bdbf2af16761de5be769e87fa /src/familiar-players-db.c
parent908222c0681fba3c6e1265d0f85a0b667927c169 (diff)
parent0d5c60e9161f4b1b4315bbfac7862ef662f577ee (diff)
downloadayatana-indicator-sound-13bc64e0a3c144740c30e2469fdb5f605d58ee39.tar.gz
ayatana-indicator-sound-13bc64e0a3c144740c30e2469fdb5f605d58ee39.tar.bz2
ayatana-indicator-sound-13bc64e0a3c144740c30e2469fdb5f605d58ee39.zip
Import upstream version 0.5.2
Diffstat (limited to 'src/familiar-players-db.c')
-rw-r--r--src/familiar-players-db.c530
1 files changed, 305 insertions, 225 deletions
diff --git a/src/familiar-players-db.c b/src/familiar-players-db.c
index 4adf129..7b082a2 100644
--- a/src/familiar-players-db.c
+++ b/src/familiar-players-db.c
@@ -1,4 +1,4 @@
-/* familiar-players-db.c generated by valac 0.10.0, the Vala compiler
+/* familiar-players-db.c generated by valac 0.11.2, the Vala compiler
* generated from familiar-players-db.vala, do not modify */
/*
@@ -54,8 +54,8 @@ struct _FamiliarPlayersDBClass {
struct _FamiliarPlayersDBPrivate {
GeeHashMap* players_DB;
- char* file_name;
- char* dir_name;
+ gchar* file_name;
+ gchar* dir_name;
GKeyFile* key_file;
guint write_id;
};
@@ -77,49 +77,72 @@ static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self);
static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self);
static gboolean familiar_players_db_check_for_keys (FamiliarPlayersDB* self);
static gboolean familiar_players_db_load_data_from_key_file (FamiliarPlayersDB* self);
-static void _vala_array_add1 (char*** array, int* length, int* size, char* value);
-void familiar_players_db_insert (FamiliarPlayersDB* self, const char* desktop);
-gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const char* desktop);
+static void _vala_array_add1 (gchar*** array, int* length, int* size, gchar* value);
+void familiar_players_db_insert (FamiliarPlayersDB* self, const gchar* desktop);
+gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const gchar* desktop);
static gboolean _familiar_players_db_write_db_gsource_func (gpointer self);
GeeSet* familiar_players_db_records (FamiliarPlayersDB* self);
-char* familiar_players_db_fetch_icon_name (const char* desktop_path);
+gchar* familiar_players_db_fetch_icon_name (const gchar* desktop_path);
static void familiar_players_db_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
-
FamiliarPlayersDB* familiar_players_db_construct (GType object_type) {
- FamiliarPlayersDB * self;
- GeeHashMap* _tmp0_;
- char* _tmp1_;
- char* _tmp2_;
- gboolean _tmp3_ = FALSE;
- gboolean _tmp4_ = FALSE;
+ FamiliarPlayersDB * self = NULL;
+ GeeHashMap* _tmp0_ = NULL;
+ GeeHashMap* _tmp1_;
+ gboolean _tmp2_;
+ const gchar* _tmp3_ = NULL;
+ gchar* _tmp4_ = NULL;
+ gchar* _tmp5_;
+ gchar* _tmp6_ = NULL;
+ gchar* _tmp7_;
+ gboolean _tmp8_ = FALSE;
+ gboolean _tmp9_ = FALSE;
+ gboolean _tmp10_;
self = (FamiliarPlayersDB*) g_object_new (object_type, NULL);
self->priv->write_id = (guint) 0;
- self->priv->players_DB = (_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_BOOLEAN, NULL, NULL, NULL, NULL, NULL), _g_object_unref0 (self->priv->players_DB), _tmp0_);
- if (!familiar_players_db_create_key_file (self)) {
+ _tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_BOOLEAN, NULL, NULL, NULL, NULL, NULL);
+ _tmp1_ = _tmp0_;
+ _g_object_unref0 (self->priv->players_DB);
+ self->priv->players_DB = _tmp1_;
+ _tmp2_ = familiar_players_db_create_key_file (self);
+ if (!_tmp2_) {
gee_abstract_map_set ((GeeAbstractMap*) self->priv->players_DB, FAMILIAR_PLAYERS_DB_DEFAULT_APP_DESKTOP, GINT_TO_POINTER (TRUE));
familiar_players_db_write_db (self);
}
- self->priv->dir_name = (_tmp1_ = g_build_filename (g_get_user_cache_dir (), "indicators", "sound", NULL), _g_free0 (self->priv->dir_name), _tmp1_);
- self->priv->file_name = (_tmp2_ = g_build_filename (self->priv->dir_name, "familiar-players-db.keyfile", NULL), _g_free0 (self->priv->file_name), _tmp2_);
- if (familiar_players_db_create_key_file (self)) {
- _tmp4_ = familiar_players_db_check_for_keys (self);
+ _tmp3_ = g_get_user_cache_dir ();
+ _tmp4_ = g_build_filename (_tmp3_, "indicators", "sound", NULL);
+ _tmp5_ = _tmp4_;
+ _g_free0 (self->priv->dir_name);
+ self->priv->dir_name = _tmp5_;
+ _tmp6_ = g_build_filename (self->priv->dir_name, "familiar-players-db.keyfile", NULL);
+ _tmp7_ = _tmp6_;
+ _g_free0 (self->priv->file_name);
+ self->priv->file_name = _tmp7_;
+ _tmp10_ = familiar_players_db_create_key_file (self);
+ if (_tmp10_) {
+ gboolean _tmp11_;
+ _tmp11_ = familiar_players_db_check_for_keys (self);
+ _tmp9_ = _tmp11_;
} else {
- _tmp4_ = FALSE;
+ _tmp9_ = FALSE;
}
- if (_tmp4_) {
- _tmp3_ = familiar_players_db_load_data_from_key_file (self);
+ if (_tmp9_) {
+ gboolean _tmp12_;
+ _tmp12_ = familiar_players_db_load_data_from_key_file (self);
+ _tmp8_ = _tmp12_;
} else {
- _tmp3_ = FALSE;
+ _tmp8_ = FALSE;
}
- if (_tmp3_) {
+ if (_tmp8_) {
g_debug ("familiar-players-db.vala:51: keyfiles in place and ready for action");
} else {
- GKeyFile* _tmp5_;
- self->priv->key_file = (_tmp5_ = NULL, _g_key_file_free0 (self->priv->key_file), _tmp5_);
+ GKeyFile* _tmp13_;
+ _tmp13_ = NULL;
+ _g_key_file_free0 (self->priv->key_file);
+ self->priv->key_file = _tmp13_;
g_warning ("familiar-players-db.vala:55: FamiliarPlayersDB:: problems loading key " \
"file - can't go any further");
}
@@ -135,39 +158,43 @@ FamiliarPlayersDB* familiar_players_db_new (void) {
static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self) {
gboolean result = FALSE;
gboolean _result_;
+ gboolean _tmp0_;
GError * _inner_error_ = NULL;
g_return_val_if_fail (self != NULL, FALSE);
_result_ = FALSE;
- if (g_file_test (self->priv->file_name, G_FILE_TEST_EXISTS)) {
- GKeyFile* _tmp0_;
- self->priv->key_file = (_tmp0_ = g_key_file_new (), _g_key_file_free0 (self->priv->key_file), _tmp0_);
- {
- gboolean _tmp1_;
- _tmp1_ = g_key_file_load_from_file (self->priv->key_file, self->priv->file_name, G_KEY_FILE_NONE, &_inner_error_);
- if (_inner_error_ != NULL) {
- if (_inner_error_->domain == G_KEY_FILE_ERROR) {
- goto __catch6_g_key_file_error;
- }
- if (_inner_error_->domain == G_FILE_ERROR) {
- goto __catch6_g_file_error;
- }
- g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return FALSE;
+ _tmp0_ = g_file_test (self->priv->file_name, G_FILE_TEST_EXISTS);
+ if (_tmp0_) {
+ GKeyFile* _tmp1_ = NULL;
+ GKeyFile* _tmp2_;
+ gboolean _tmp3_;
+ gboolean _tmp4_;
+ _tmp1_ = g_key_file_new ();
+ _tmp2_ = _tmp1_;
+ _g_key_file_free0 (self->priv->key_file);
+ self->priv->key_file = _tmp2_;
+ _tmp3_ = g_key_file_load_from_file (self->priv->key_file, self->priv->file_name, G_KEY_FILE_NONE, &_inner_error_);
+ _tmp4_ = _tmp3_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_KEY_FILE_ERROR) {
+ goto __catch6_g_key_file_error;
+ }
+ if (_inner_error_->domain == G_FILE_ERROR) {
+ goto __catch6_g_file_error;
}
- _result_ = _tmp1_;
+ g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return FALSE;
}
+ _result_ = _tmp4_;
goto __finally6;
__catch6_g_key_file_error:
{
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
- {
- g_warning ("familiar-players-db.vala:67: FamiliarPlayersDB::create_key_file() - Ke" \
+ g_warning ("familiar-players-db.vala:67: FamiliarPlayersDB::create_key_file() - Ke" \
"yFileError");
- _g_error_free0 (e);
- }
+ _g_error_free0 (e);
}
goto __finally6;
__catch6_g_file_error:
@@ -175,11 +202,9 @@ static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self) {
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
- {
- g_warning ("familiar-players-db.vala:70: FamiliarPlayersDB::create_key_file() - Fi" \
+ g_warning ("familiar-players-db.vala:70: FamiliarPlayersDB::create_key_file() - Fi" \
"leError");
- _g_error_free0 (e);
- }
+ _g_error_free0 (e);
}
__finally6:
if (_inner_error_ != NULL) {
@@ -195,23 +220,23 @@ static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self) {
static gboolean familiar_players_db_check_for_keys (FamiliarPlayersDB* self) {
gboolean result = FALSE;
+ gboolean _tmp0_;
+ gboolean _tmp1_;
GError * _inner_error_ = NULL;
g_return_val_if_fail (self != NULL, FALSE);
- {
- gboolean _tmp0_;
- _tmp0_ = g_key_file_has_key (self->priv->key_file, FAMILIAR_PLAYERS_DB_GROUP_NAME, FAMILIAR_PLAYERS_DB_KEY_NAME, &_inner_error_);
- if (_inner_error_ != NULL) {
- if (_inner_error_->domain == G_KEY_FILE_ERROR) {
- goto __catch7_g_key_file_error;
- }
- g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return FALSE;
- }
- if (_tmp0_ == TRUE) {
- result = TRUE;
- return result;
+ _tmp0_ = g_key_file_has_key (self->priv->key_file, FAMILIAR_PLAYERS_DB_GROUP_NAME, FAMILIAR_PLAYERS_DB_KEY_NAME, &_inner_error_);
+ _tmp1_ = _tmp0_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_KEY_FILE_ERROR) {
+ goto __catch7_g_key_file_error;
}
+ g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return FALSE;
+ }
+ if (_tmp1_ == TRUE) {
+ result = TRUE;
+ return result;
}
goto __finally7;
__catch7_g_key_file_error:
@@ -219,11 +244,9 @@ static gboolean familiar_players_db_check_for_keys (FamiliarPlayersDB* self) {
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
- {
- result = FALSE;
- _g_error_free0 (e);
- return result;
- }
+ result = FALSE;
+ _g_error_free0 (e);
+ return result;
}
__finally7:
if (_inner_error_ != NULL) {
@@ -240,68 +263,70 @@ static gboolean familiar_players_db_check_for_keys (FamiliarPlayersDB* self) {
static gboolean familiar_players_db_load_data_from_key_file (FamiliarPlayersDB* self) {
gboolean result = FALSE;
+ gsize _tmp0_;
+ gchar** _tmp1_ = NULL;
+ gint desktops_length1;
+ gint _desktops_size_;
+ gchar** _tmp2_;
+ gchar** desktops;
GError * _inner_error_ = NULL;
g_return_val_if_fail (self != NULL, FALSE);
- {
- gint desktops_length1;
- gint _desktops_size_;
- char** _tmp1_;
- gsize _tmp0_;
- char** desktops;
- desktops = (_tmp1_ = g_key_file_get_string_list (self->priv->key_file, FAMILIAR_PLAYERS_DB_GROUP_NAME, FAMILIAR_PLAYERS_DB_KEY_NAME, &_tmp0_, &_inner_error_), desktops_length1 = _tmp0_, _desktops_size_ = desktops_length1, _tmp1_);
- if (_inner_error_ != NULL) {
- if (_inner_error_->domain == G_KEY_FILE_ERROR) {
- goto __catch8_g_key_file_error;
- }
- g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return FALSE;
+ _tmp1_ = g_key_file_get_string_list (self->priv->key_file, FAMILIAR_PLAYERS_DB_GROUP_NAME, FAMILIAR_PLAYERS_DB_KEY_NAME, &_tmp0_, &_inner_error_);
+ _tmp2_ = _tmp1_;
+ desktops_length1 = _tmp0_;
+ _desktops_size_ = desktops_length1;
+ desktops = _tmp2_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_KEY_FILE_ERROR) {
+ goto __catch8_g_key_file_error;
}
- {
- char** s_collection;
- int s_collection_length1;
- int s_it;
- s_collection = desktops;
- s_collection_length1 = desktops_length1;
- for (s_it = 0; s_it < desktops_length1; s_it = s_it + 1) {
- char* s;
- s = g_strdup (s_collection[s_it]);
- {
- gee_abstract_map_set ((GeeAbstractMap*) self->priv->players_DB, s, GINT_TO_POINTER (TRUE));
- _g_free0 (s);
- }
+ g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return FALSE;
+ }
+ {
+ gchar** s_collection;
+ int s_collection_length1;
+ int s_it;
+ s_collection = desktops;
+ s_collection_length1 = desktops_length1;
+ for (s_it = 0; s_it < desktops_length1; s_it = s_it + 1) {
+ gchar* _tmp3_;
+ gchar* s;
+ _tmp3_ = g_strdup (s_collection[s_it]);
+ s = _tmp3_;
+ {
+ gee_abstract_map_set ((GeeAbstractMap*) self->priv->players_DB, s, GINT_TO_POINTER (TRUE));
+ _g_free0 (s);
}
}
- result = TRUE;
- desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
- return result;
}
+ result = TRUE;
+ desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
+ return result;
+ desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
goto __finally8;
__catch8_g_key_file_error:
{
GError * _error_;
_error_ = _inner_error_;
_inner_error_ = NULL;
- {
- g_warning ("familiar-players-db.vala:99: Error loading the Desktop string list");
- result = FALSE;
- _g_error_free0 (_error_);
- return result;
- }
+ g_warning ("familiar-players-db.vala:99: Error loading the Desktop string list");
+ result = FALSE;
+ _g_error_free0 (_error_);
+ return result;
}
__finally8:
- {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return FALSE;
- }
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return FALSE;
}
-static void _vala_array_add1 (char*** array, int* length, int* size, char* value) {
+static void _vala_array_add1 (gchar*** array, int* length, int* size, gchar* value) {
if ((*length) == (*size)) {
*size = (*size) ? (2 * (*size)) : 4;
- *array = g_renew (char*, *array, (*size) + 1);
+ *array = g_renew (gchar*, *array, (*size) + 1);
}
(*array)[(*length)++] = value;
(*array)[*length] = NULL;
@@ -310,55 +335,77 @@ static void _vala_array_add1 (char*** array, int* length, int* size, char* value
static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
gboolean result = FALSE;
+ GKeyFile* _tmp0_ = NULL;
GKeyFile* keyfile;
+ gchar** _tmp1_ = NULL;
gint desktops_length1;
gint _desktops_size_;
- char** _tmp1_;
- char** _tmp0_ = NULL;
- char** desktops;
+ gchar** _tmp2_;
+ gchar** desktops;
gsize data_length = 0UL;
- char* data;
+ gchar* data;
+ gsize _tmp10_;
+ gchar* _tmp11_ = NULL;
+ gchar* _tmp12_;
+ gint _tmp13_;
+ gboolean _tmp14_;
+ gboolean _tmp15_;
GError * _inner_error_ = NULL;
g_return_val_if_fail (self != NULL, FALSE);
- keyfile = g_key_file_new ();
- desktops = (_tmp1_ = (_tmp0_ = g_new0 (char*, 0 + 1), _tmp0_), desktops_length1 = 0, _desktops_size_ = desktops_length1, _tmp1_);
+ _tmp0_ = g_key_file_new ();
+ keyfile = _tmp0_;
+ _tmp1_ = g_new0 (gchar*, 0 + 1);
+ _tmp2_ = _tmp1_;
+ desktops_length1 = 0;
+ _desktops_size_ = desktops_length1;
+ desktops = _tmp2_;
{
- GeeSet* _tmp2_;
- GeeIterator* _tmp3_;
+ GeeSet* _tmp3_ = NULL;
+ GeeSet* _tmp4_;
+ GeeIterator* _tmp5_ = NULL;
+ GeeIterator* _tmp6_;
GeeIterator* _key_it;
- _key_it = (_tmp3_ = gee_iterable_iterator ((GeeIterable*) (_tmp2_ = gee_map_get_keys ((GeeMap*) self->priv->players_DB))), _g_object_unref0 (_tmp2_), _tmp3_);
+ _tmp3_ = gee_map_get_keys ((GeeMap*) self->priv->players_DB);
+ _tmp4_ = _tmp3_;
+ _tmp5_ = gee_iterable_iterator ((GeeIterable*) _tmp4_);
+ _key_it = (_tmp6_ = _tmp5_, _g_object_unref0 (_tmp4_), _tmp6_);
while (TRUE) {
- char* key;
- if (!gee_iterator_next (_key_it)) {
+ gboolean _tmp7_;
+ gpointer _tmp8_ = NULL;
+ gchar* key;
+ gchar* _tmp9_;
+ _tmp7_ = gee_iterator_next (_key_it);
+ if (!_tmp7_) {
break;
}
- key = (char*) gee_iterator_get (_key_it);
- _vala_array_add1 (&desktops, &desktops_length1, &_desktops_size_, g_strdup (key));
+ _tmp8_ = gee_iterator_get (_key_it);
+ key = (gchar*) _tmp8_;
+ _tmp9_ = g_strdup (key);
+ _vala_array_add1 (&desktops, &desktops_length1, &_desktops_size_, _tmp9_);
_g_free0 (key);
}
_g_object_unref0 (_key_it);
}
g_key_file_set_string_list (keyfile, FAMILIAR_PLAYERS_DB_GROUP_NAME, FAMILIAR_PLAYERS_DB_KEY_NAME, (const gchar* const*) desktops, desktops_length1);
data = NULL;
- {
- char* _tmp4_;
- data = (_tmp4_ = g_key_file_to_data (keyfile, &data_length, NULL), _g_free0 (data), _tmp4_);
- }
+ _tmp11_ = g_key_file_to_data (keyfile, &_tmp10_, NULL);
+ data_length = _tmp10_;
+ _tmp12_ = _tmp11_;
+ _g_free0 (data);
+ data = _tmp12_;
goto __finally9;
__catch9_g_key_file_error:
{
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
- {
- g_warning ("familiar-players-db.vala:120: Problems dumping keyfile to a string");
- result = FALSE;
- _g_error_free0 (e);
- _g_free0 (data);
- desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
- _g_key_file_free0 (keyfile);
- return result;
- }
+ g_warning ("familiar-players-db.vala:120: Problems dumping keyfile to a string");
+ result = FALSE;
+ _g_error_free0 (e);
+ _g_free0 (data);
+ desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
+ _g_key_file_free0 (keyfile);
+ return result;
}
__finally9:
if (_inner_error_ != NULL) {
@@ -369,7 +416,8 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
g_clear_error (&_inner_error_);
return FALSE;
}
- if (g_mkdir_with_parents (self->priv->dir_name, 0700) != 0) {
+ _tmp13_ = g_mkdir_with_parents (self->priv->dir_name, 0700);
+ if (_tmp13_ != 0) {
g_warning ("familiar-players-db.vala:125: Unable to make directory: %s", self->priv->dir_name);
result = FALSE;
_g_free0 (data);
@@ -377,23 +425,21 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
_g_key_file_free0 (keyfile);
return result;
}
- {
- gboolean _tmp5_;
- _tmp5_ = g_file_set_contents (self->priv->file_name, data, (gssize) data_length, &_inner_error_);
- if (_inner_error_ != NULL) {
- if (_inner_error_->domain == G_FILE_ERROR) {
- goto __catch10_g_file_error;
- }
- _g_free0 (data);
- desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
- _g_key_file_free0 (keyfile);
- g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return FALSE;
- }
- if (_tmp5_ == FALSE) {
- g_warning ("familiar-players-db.vala:131: Unable to write out file '%s'", self->priv->file_name);
+ _tmp14_ = g_file_set_contents (self->priv->file_name, data, (gssize) data_length, &_inner_error_);
+ _tmp15_ = _tmp14_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_FILE_ERROR) {
+ goto __catch10_g_file_error;
}
+ _g_free0 (data);
+ desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
+ _g_key_file_free0 (keyfile);
+ g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return FALSE;
+ }
+ if (_tmp15_ == FALSE) {
+ g_warning ("familiar-players-db.vala:131: Unable to write out file '%s'", self->priv->file_name);
}
goto __finally10;
__catch10_g_file_error:
@@ -401,10 +447,8 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
GError * err;
err = _inner_error_;
_inner_error_ = NULL;
- {
- g_warning ("familiar-players-db.vala:135: Unable to write out file '%s'", self->priv->file_name);
- _g_error_free0 (err);
- }
+ g_warning ("familiar-players-db.vala:135: Unable to write out file '%s'", self->priv->file_name);
+ _g_error_free0 (err);
}
__finally10:
if (_inner_error_ != NULL) {
@@ -430,72 +474,106 @@ static gboolean _familiar_players_db_write_db_gsource_func (gpointer self) {
}
-void familiar_players_db_insert (FamiliarPlayersDB* self, const char* desktop) {
+void familiar_players_db_insert (FamiliarPlayersDB* self, const gchar* desktop) {
+ gboolean _tmp0_;
g_return_if_fail (self != NULL);
g_return_if_fail (desktop != NULL);
- if (familiar_players_db_already_familiar (self, desktop) == FALSE) {
- char* _tmp0_;
+ _tmp0_ = familiar_players_db_already_familiar (self, desktop);
+ if (_tmp0_ == FALSE) {
+ guint _tmp1_;
+ gchar* _tmp2_ = NULL;
+ gchar* _tmp3_;
if (self->priv->write_id != 0) {
g_source_remove (self->priv->write_id);
self->priv->write_id = (guint) 0;
}
- self->priv->write_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 60, _familiar_players_db_write_db_gsource_func, g_object_ref (self), g_object_unref);
- gee_abstract_map_set ((GeeAbstractMap*) self->priv->players_DB, _tmp0_ = g_strdup (desktop), GINT_TO_POINTER (TRUE));
- _g_free0 (_tmp0_);
+ _tmp1_ = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 60, _familiar_players_db_write_db_gsource_func, g_object_ref (self), g_object_unref);
+ self->priv->write_id = _tmp1_;
+ _tmp2_ = g_strdup (desktop);
+ _tmp3_ = _tmp2_;
+ gee_abstract_map_set ((GeeAbstractMap*) self->priv->players_DB, _tmp3_, GINT_TO_POINTER (TRUE));
+ _g_free0 (_tmp3_);
}
}
-static char* bool_to_string (gboolean self) {
- char* result = NULL;
+static gchar* bool_to_string (gboolean self) {
+ gchar* result = NULL;
if (self) {
- result = g_strdup ("true");
+ gchar* _tmp0_;
+ _tmp0_ = g_strdup ("true");
+ result = _tmp0_;
return result;
} else {
- result = g_strdup ("false");
+ gchar* _tmp1_;
+ _tmp1_ = g_strdup ("false");
+ result = _tmp1_;
return result;
}
}
-gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const char* desktop) {
+gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const gchar* desktop) {
gboolean result = FALSE;
- GeeSet* _tmp0_;
- char* _tmp1_;
- GeeSet* _tmp2_;
- gboolean _tmp3_;
+ GeeSet* _tmp0_ = NULL;
+ GeeSet* _tmp1_;
+ gboolean _tmp2_;
+ gchar* _tmp3_ = NULL;
+ gchar* _tmp4_;
+ GeeSet* _tmp5_ = NULL;
+ GeeSet* _tmp6_;
+ gboolean _tmp7_;
+ gboolean _tmp8_;
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (desktop != NULL, FALSE);
- g_debug ("familiar-players-db.vala:154: playerDB->already_familiar - result %s", _tmp1_ = bool_to_string (gee_collection_contains ((GeeCollection*) (_tmp0_ = gee_map_get_keys ((GeeMap*) self->priv->players_DB)), desktop)));
- _g_free0 (_tmp1_);
- _g_object_unref0 (_tmp0_);
- result = (_tmp3_ = gee_collection_contains ((GeeCollection*) (_tmp2_ = gee_map_get_keys ((GeeMap*) self->priv->players_DB)), desktop), _g_object_unref0 (_tmp2_), _tmp3_);
+ _tmp0_ = gee_map_get_keys ((GeeMap*) self->priv->players_DB);
+ _tmp1_ = _tmp0_;
+ _tmp2_ = gee_collection_contains ((GeeCollection*) _tmp1_, desktop);
+ _tmp3_ = bool_to_string (_tmp2_);
+ _tmp4_ = _tmp3_;
+ g_debug ("familiar-players-db.vala:154: playerDB->already_familiar - result %s", _tmp4_);
+ _g_free0 (_tmp4_);
+ _g_object_unref0 (_tmp1_);
+ _tmp5_ = gee_map_get_keys ((GeeMap*) self->priv->players_DB);
+ _tmp6_ = _tmp5_;
+ _tmp7_ = gee_collection_contains ((GeeCollection*) _tmp6_, desktop);
+ result = (_tmp8_ = _tmp7_, _g_object_unref0 (_tmp6_), _tmp8_);
return result;
}
GeeSet* familiar_players_db_records (FamiliarPlayersDB* self) {
GeeSet* result = NULL;
+ GeeSet* _tmp0_ = NULL;
g_return_val_if_fail (self != NULL, NULL);
- result = gee_map_get_keys ((GeeMap*) self->priv->players_DB);
+ _tmp0_ = gee_map_get_keys ((GeeMap*) self->priv->players_DB);
+ result = _tmp0_;
return result;
}
-char* familiar_players_db_fetch_icon_name (const char* desktop_path) {
- char* result = NULL;
+gchar* familiar_players_db_fetch_icon_name (const gchar* desktop_path) {
+ gchar* result = NULL;
+ GKeyFile* _tmp0_ = NULL;
GKeyFile* desktop_keyfile;
+ gchar* _tmp1_ = NULL;
+ gchar* _tmp2_;
GError * _inner_error_ = NULL;
g_return_val_if_fail (desktop_path != NULL, NULL);
- desktop_keyfile = g_key_file_new ();
- {
- g_key_file_load_from_file (desktop_keyfile, desktop_path, G_KEY_FILE_NONE, &_inner_error_);
- if (_inner_error_ != NULL) {
- if (_inner_error_->domain == G_FILE_ERROR) {
- goto __catch11_g_file_error;
- }
- goto __finally11;
+ _tmp0_ = g_key_file_new ();
+ desktop_keyfile = _tmp0_;
+ g_key_file_load_from_file (desktop_keyfile, desktop_path, G_KEY_FILE_NONE, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_FILE_ERROR) {
+ goto __catch11_g_file_error;
}
+ if (_inner_error_->domain == G_KEY_FILE_ERROR) {
+ goto __catch11_g_key_file_error;
+ }
+ _g_key_file_free0 (desktop_keyfile);
+ g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return NULL;
}
goto __finally11;
__catch11_g_file_error:
@@ -503,13 +581,23 @@ char* familiar_players_db_fetch_icon_name (const char* desktop_path) {
GError * _error_;
_error_ = _inner_error_;
_inner_error_ = NULL;
- {
- g_warning ("familiar-players-db.vala:170: Error loading keyfile");
- result = NULL;
- _g_error_free0 (_error_);
- _g_key_file_free0 (desktop_keyfile);
- return result;
- }
+ g_warning ("familiar-players-db.vala:170: Error loading keyfile - FileError");
+ result = NULL;
+ _g_error_free0 (_error_);
+ _g_key_file_free0 (desktop_keyfile);
+ return result;
+ }
+ goto __finally11;
+ __catch11_g_key_file_error:
+ {
+ GError * _error_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ g_warning ("familiar-players-db.vala:174: Error loading keyfile - KeyFileError");
+ result = NULL;
+ _g_error_free0 (_error_);
+ _g_key_file_free0 (desktop_keyfile);
+ return result;
}
__finally11:
if (_inner_error_ != NULL) {
@@ -518,45 +606,38 @@ char* familiar_players_db_fetch_icon_name (const char* desktop_path) {
g_clear_error (&_inner_error_);
return NULL;
}
- {
- char* _tmp0_;
- _tmp0_ = g_key_file_get_string (desktop_keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, &_inner_error_);
- if (_inner_error_ != NULL) {
- if (_inner_error_->domain == G_KEY_FILE_ERROR) {
- goto __catch12_g_key_file_error;
- }
- _g_key_file_free0 (desktop_keyfile);
- g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return NULL;
+ _tmp1_ = g_key_file_get_string (desktop_keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, &_inner_error_);
+ _tmp2_ = _tmp1_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_KEY_FILE_ERROR) {
+ goto __catch12_g_key_file_error;
}
- result = _tmp0_;
_g_key_file_free0 (desktop_keyfile);
- return result;
+ g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return NULL;
}
+ result = _tmp2_;
+ _g_key_file_free0 (desktop_keyfile);
+ return result;
goto __finally12;
__catch12_g_key_file_error:
{
GError * _error_;
_error_ = _inner_error_;
_inner_error_ = NULL;
- {
- g_warning ("familiar-players-db.vala:178: Error trying to fetch the icon name from" \
+ g_warning ("familiar-players-db.vala:183: Error trying to fetch the icon name from" \
" the keyfile");
- result = NULL;
- _g_error_free0 (_error_);
- _g_key_file_free0 (desktop_keyfile);
- return result;
- }
- }
- __finally12:
- {
+ result = NULL;
+ _g_error_free0 (_error_);
_g_key_file_free0 (desktop_keyfile);
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return NULL;
+ return result;
}
+ __finally12:
_g_key_file_free0 (desktop_keyfile);
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return NULL;
}
@@ -614,4 +695,3 @@ static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify
-