gboolean purple_smiley_set_shortcut(PurpleSmiley *smiley, const char *shortcut) { g_return_val_if_fail(smiley != NULL, FALSE); g_return_val_if_fail(shortcut != NULL, FALSE); /* Check out whether the new shortcut is already being used. */ if (g_hash_table_lookup(smiley_shortcut_index, shortcut)) return FALSE; /* Remove the old shortcut. */ if (smiley->shortcut) g_hash_table_remove(smiley_shortcut_index, smiley->shortcut); /* Insert the new shortcut. */ g_hash_table_insert(smiley_shortcut_index, g_strdup(shortcut), smiley); g_free(smiley->shortcut); smiley->shortcut = g_strdup(shortcut); g_object_notify(G_OBJECT(smiley), PROP_SHORTCUT_S); purple_smileys_save(); return TRUE; }
gboolean purple_smiley_set_shortcut(PurpleSmiley *smiley, const char *shortcut) { PurpleSmileyPrivate *priv = NULL; g_return_val_if_fail(smiley != NULL, FALSE); g_return_val_if_fail(shortcut != NULL, FALSE); /* Check out whether the new shortcut is already being used. */ if (g_hash_table_lookup(smiley_shortcut_index, shortcut)) return FALSE; priv = PURPLE_SMILEY_GET_PRIVATE(smiley); /* Remove the old shortcut. */ if (priv->shortcut) g_hash_table_remove(smiley_shortcut_index, priv->shortcut); /* Insert the new shortcut. */ g_hash_table_insert(smiley_shortcut_index, g_strdup(shortcut), smiley); g_free(priv->shortcut); priv->shortcut = g_strdup(shortcut); g_object_notify_by_pspec(G_OBJECT(smiley), properties[PROP_SHORTCUT]); purple_smileys_save(); return TRUE; }
void purple_smiley_set_data(PurpleSmiley *smiley, guchar *smiley_data, size_t smiley_data_len) { g_return_if_fail(smiley != NULL); g_return_if_fail(smiley_data != NULL); g_return_if_fail(smiley_data_len > 0); /* Remove the previous entry */ g_hash_table_remove(smiley_checksum_index, smiley->checksum); /* Update the file data. This also updates the checksum. */ purple_smiley_set_data_impl(smiley, smiley_data, smiley_data_len); /* Reinsert the index item. */ g_hash_table_insert(smiley_checksum_index, g_strdup(smiley->checksum), smiley); purple_smileys_save(); }
static void purple_smiley_finalize(GObject *obj) { PurpleSmiley *smiley = PURPLE_SMILEY(obj); if (g_hash_table_lookup(smiley_shortcut_index, smiley->shortcut)) { g_hash_table_remove(smiley_shortcut_index, smiley->shortcut); g_hash_table_remove(smiley_checksum_index, smiley->checksum); } g_free(smiley->shortcut); g_free(smiley->checksum); if (smiley->img) purple_smiley_data_unstore(purple_imgstore_get_filename(smiley->img)); purple_imgstore_unref(smiley->img); PURPLE_DBUS_UNREGISTER_POINTER(smiley); purple_smileys_save(); }