# HG changeset patch # User Hermitifier # Date 1318328888 -7200 # Node ID 76d7c57212108fabb457d7ec91cd97d7baed5a79 # Parent 1fe1e8d1d1ea3b6015a4bcf66197d01435967108 Remove dependency on newer glib. Caps.c comments, whitespace cleanup. diff -r 1fe1e8d1d1ea -r 76d7c5721210 mcabber/mcabber/caps.c --- a/mcabber/mcabber/caps.c Mon Oct 03 16:37:17 2011 +0200 +++ b/mcabber/mcabber/caps.c Tue Oct 11 12:28:08 2011 +0200 @@ -74,7 +74,8 @@ void field_destroy(gpointer data) { GList *v = data; - g_list_free_full(v, g_free); + g_list_foreach (v, (GFunc) g_free, NULL); + g_list_free (v); } void caps_init(void) @@ -110,6 +111,7 @@ g_hash_table_remove(caps_cache, hash); } +/* if hash is not verified, this will bind capabilities set only with bare jid */ void caps_move_to_local(char *hash, char *bjid) { char *orig_hash; @@ -127,6 +129,7 @@ } } +/*if bjid is NULL, it will check only verified hashes */ int caps_has_hash(const char *hash, const char *bjid) { caps *c = NULL; @@ -230,6 +233,9 @@ } } +/* If hash is verified, then bare jid is ignored. + * If there is no globally verified hash, and bare jid is not null, + * then local storage for that jid will be checked */ int caps_has_feature(const char *hash, char *feature, char *bjid) { caps *c = NULL; @@ -408,13 +414,14 @@ static gchar* caps_get_filename(const char* hash) { - gchar *hash_fs = g_strdup (hash); + gchar *hash_fs; gchar *dir = (gchar *) settings_opt_get ("caps_directory"); gchar *file = NULL; if (!dir) goto caps_filename_return; + hash_fs = g_strdup (hash); { const gchar *valid_fs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+="; @@ -424,12 +431,13 @@ dir = expand_filename (dir); file = g_strdup_printf ("%s/%s.ini", dir, hash_fs); g_free(dir); + g_free(hash_fs); caps_filename_return: - g_free(hash_fs); return file; } +/* Store capabilities set in GKeyFile. To be used with verified hashes only */ void caps_copy_to_persistent(const char* hash, char* xml) { gchar *file; @@ -453,6 +461,9 @@ goto caps_copy_exists; key_file = g_key_file_new (); + g_key_file_set_comment (key_file, NULL, NULL, + "This is autogenerated file. Please do not modify.", + NULL); langs = g_hash_table_get_keys (c->identities); { @@ -505,24 +516,24 @@ GList *values; for (field=fields; field; field=field->next) { values = g_hash_table_lookup (d->fields, field->data); - { - GList *value; - gchar **string_list; - gint i; - i = g_list_length (values); - string_list = g_new (gchar*, i + 1); - i = 0; - for (value=values; value; value=value->next) { - string_list[i] = g_strdup(value->data); - ++i; - } - string_list[i] = NULL; + { + GList *value; + gchar **string_list; + gint i; + i = g_list_length (values); + string_list = g_new (gchar*, i + 1); + i = 0; + for (value=values; value; value=value->next) { + string_list[i] = g_strdup(value->data); + ++i; + } + string_list[i] = NULL; - g_key_file_set_string_list (key_file, group, field->data, - (const gchar**)string_list, i); - - g_strfreev (string_list); - } + g_key_file_set_string_list (key_file, group, field->data, + (const gchar**)string_list, i); + + g_strfreev (string_list); + } } } g_list_free(fields); @@ -547,6 +558,7 @@ return; } +/* Restore capabilities from GKeyFile. Hash is not verified afterwards */ gboolean caps_restore_from_persistent (const char* hash) { gchar *file; @@ -597,11 +609,11 @@ for (field = fields; *field; ++field) { gchar **values, **value; values = g_key_file_get_string_list (key_file, *group, *field, - NULL, NULL); - for (value = values; *value; ++value) { - caps_add_dataform_field (hash, formtype, *field, *value); - } - g_strfreev (values); + NULL, NULL); + for (value = values; *value; ++value) { + caps_add_dataform_field (hash, formtype, *field, *value); + } + g_strfreev (values); } g_strfreev (fields); }