pidgin/pidgin

Parents 2abcdcea1ee0
Children 82a21ea342d8
Remove all of the current smiley support as it currently isn't used and needs to be completely overhauled for the new emoji api when we write it.

Testing Done:
Ran the unit tests, `ninja pidgin-pot doc`, ran pidgin3, opened the preferences page, verified the `custom smileys menu was removed`, sent messages over xmpp with text smileys and verified that pidgin 2 still rendered them.

Reviewed at https://reviews.imfreedom.org/r/852/
--- a/ChangeLog.API Tue Aug 24 04:51:11 2021 -0500
+++ b/ChangeLog.API Tue Aug 24 04:52:14 2021 -0500
@@ -355,13 +355,20 @@
Use GLib's GHmac or GChecksum instead.
* PURPLE_CMD_FUNC
* purple_connection_error_reason
+ * PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY
* purple_connection_new
* purple_connection_new_unregister
* purple_connection_destroy
* purple_connection_set_account
* purple_contact_set_alias
* purple_conv_chat_set_users
+ * purple_conv_custom_smiley_add
+ * purple_conv_custom_smiley_close
+ * purple_conv_custom_smiley_write
* PurpleConversationType
+ * purple_conversation_add_smiley
+ * purple_conversation_get_remote_smileys
+ * purple_conversation_get_smiley
* purple_conversations_add. Use purple_conversation_manager_register
instead.
* purple_conversations_remove. Use
@@ -520,6 +527,24 @@
purple_roomlist_set_protocol_data
* PurpleSetPublicAliasFailureCallback
* PurpleSetPublicAliasSuccessCallback
+ * purple_smiley_get_type
+ * purple_smiley_new
+ * purple_smiley_new_from_file
+ * purple_smiley_delete
+ * purple_smiley_set_shortcut
+ * purple_smiley_set_data
+ * purple_smiley_get_shortcut
+ * purple_smiley_get_checksum
+ * purple_smiley_get_stored_image
+ * purple_smiley_get_data
+ * purple_smiley_get_extension
+ * purple_smiley_get_full_path
+ * purple_smileys_get_all
+ * purple_smileys_find_by_shortcut
+ * purple_smileys_find_by_checksum
+ * purple_smileys_get_storing_dir
+ * purple_smileys_init
+ * purple_smileys_uninit
* purple_socket_get_family
* purple_socket_speaks_ipv4
* PurpleSoundUiOps
@@ -692,9 +717,6 @@
removed the accel related parameters.
* pidgin_setup_screenname_autocomplete now takes a filter function and
its data as final two arguments
- * smiley_list renamed to PidginSmileyList
- * smiley_parse_markup renamed to pidgin_smiley_parse_markup
- * smiley_theme renamed to PidginSmileyTheme
* PidginWindow renamed to PidginConvWindow
Removed:
@@ -785,6 +807,17 @@
* pidgin_set_sensitive_if_input
* pidgin_set_urgent, use gtk_window_set_urgency_hint instead.
* pidgin_setup_screenname_autocomplete_with_filter
+ * PidginSmiley
+ * pidgin_smiley_add_to_list
+ * pidgin_smiley_del_from_list
+ * pidgin_smiley_manager_show
+ * pidgin_smiley_edit
+ * pidgin_smiley_editor_set_shortcut
+ * pidgin_smiley_editor_set_image
+ * pidgin_smiley_editor_set_data
+ * pidgin_smileys_init
+ * pidgin_smileys_uninit
+ * pidgin_smileys_get_all
* pidgin_sound_get_event_label
* pidgin_sound_get_event_option
* pidgin_sound_get_handle
@@ -797,6 +830,7 @@
* pidgin_status_box_set_buddy_icon
* pidgin_status_box_set_network_available
* pidgin_stock_id_from_presence
+ * PIDGIN_STOCK_TOOLBAR_SMILEY
* pidgin_text_combo_box_entry_set_text
* pidgin_theme_font_free
* pidgin_theme_font_get_color
@@ -826,6 +860,9 @@
* struct _GtkSmileyTree
* struct _PidginChatPane
* struct _PidginImPane
+ * smiley_list
+ * smiley_parse_markup
+ * smiley_theme
Finch:
Added:
--- a/doc/reference/libpurple/libpurple-docs.xml Tue Aug 24 04:51:11 2021 -0500
+++ b/doc/reference/libpurple/libpurple-docs.xml Tue Aug 24 04:52:14 2021 -0500
@@ -139,16 +139,6 @@
<xi:include href="xml/cmds.xml" />
</chapter>
- <chapter id="smiley">
- <title>Smiley APIs</title>
-
- <xi:include href="xml/smiley.xml" />
- <xi:include href="xml/smiley-custom.xml" />
- <xi:include href="xml/smiley-list.xml" />
- <xi:include href="xml/smiley-theme.xml" />
- <xi:include href="xml/smiley-parser.xml" />
- </chapter>
-
<chapter id="image">
<title>Graphics</title>
--- a/doc/reference/pidgin/pidgin-docs.xml Tue Aug 24 04:51:11 2021 -0500
+++ b/doc/reference/pidgin/pidgin-docs.xml Tue Aug 24 04:52:14 2021 -0500
@@ -36,8 +36,6 @@
<xi:include href="xml/gtkrequest.xml" />
<xi:include href="xml/gtkroomlist.xml" />
<xi:include href="xml/gtksavedstatuses.xml" />
- <xi:include href="xml/gtksmiley-manager.xml" />
- <xi:include href="xml/gtksmiley-theme.xml" />
<xi:include href="xml/gtkstatus-icon-theme.xml" />
<xi:include href="xml/gtkstatusbox.xml" />
<xi:include href="xml/gtkutils.xml" />
--- a/libpurple/connection.h Tue Aug 24 04:51:11 2021 -0500
+++ b/libpurple/connection.h Tue Aug 24 04:52:14 2021 -0500
@@ -81,8 +81,6 @@
* with links
* @PURPLE_CONNECTION_FLAG_NO_IMAGES: Connection does not support sending of
* images
- * @PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY: Connection supports sending
- * and receiving custom smileys
* @PURPLE_CONNECTION_FLAG_SUPPORT_MOODS: Connection supports setting moods
* @PURPLE_CONNECTION_FLAG_SUPPORT_MOOD_MESSAGES: Connection supports setting
* a message on moods
@@ -99,7 +97,6 @@
PURPLE_CONNECTION_FLAG_NO_FONTSIZE = 0x0020,
PURPLE_CONNECTION_FLAG_NO_URLDESC = 0x0040,
PURPLE_CONNECTION_FLAG_NO_IMAGES = 0x0080,
- PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY = 0x0100,
PURPLE_CONNECTION_FLAG_SUPPORT_MOODS = 0x0200,
PURPLE_CONNECTION_FLAG_SUPPORT_MOOD_MESSAGES = 0x0400
} PurpleConnectionFlags;
--- a/libpurple/core.c Tue Aug 24 04:51:11 2021 -0500
+++ b/libpurple/core.c Tue Aug 24 04:52:14 2021 -0500
@@ -40,9 +40,6 @@
#include "purpleprivate.h"
#include "savedstatuses.h"
#include "signals.h"
-#include "smiley-custom.h"
-#include "smiley-parser.h"
-#include "smiley-theme.h"
#include "status.h"
#include "stun.h"
#include "theme-manager.h"
@@ -180,8 +177,6 @@
purple_stun_init();
purple_xfers_init();
purple_idle_init();
- _purple_smiley_custom_init();
- _purple_smiley_parser_init();
/*
* Call this early on to try to auto-detect our IP address and
@@ -223,9 +218,6 @@
purple_connections_disconnect_all();
/* Save .xml files, remove signals, etc. */
- _purple_smiley_theme_uninit();
- _purple_smiley_custom_uninit();
- _purple_smiley_parser_uninit();
purple_idle_uninit();
purple_conversation_manager_shutdown();
purple_conversations_uninit();
@@ -371,14 +363,12 @@
xdg_dir_exists = g_file_test(purple_data_dir(), G_FILE_TEST_EXISTS);
if (!xdg_dir_exists) {
MIGRATE_TO_XDG_DIR(purple_data_dir(), "certificates");
- MIGRATE_TO_XDG_DIR(purple_data_dir(), "custom_smiley");
MIGRATE_TO_XDG_DIR(purple_data_dir(), "logs");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "accounts.xml");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "blist.xml");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "fs-codec.conf");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "fs-element.conf");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "prefs.xml");
- MIGRATE_TO_XDG_DIR(purple_config_dir(), "smileys.xml");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "status.xml");
}
--- a/libpurple/meson.build Tue Aug 24 04:51:11 2021 -0500
+++ b/libpurple/meson.build Tue Aug 24 04:52:14 2021 -0500
@@ -81,11 +81,6 @@
'savedstatuses.c',
'server.c',
'signals.c',
- 'smiley-custom.c',
- 'smiley-list.c',
- 'smiley-parser.c',
- 'smiley-theme.c',
- 'smiley.c',
'status.c',
'stun.c',
'theme.c',
@@ -178,11 +173,6 @@
'savedstatuses.h',
'server.h',
'signals.h',
- 'smiley-custom.h',
- 'smiley-list.h',
- 'smiley-parser.h',
- 'smiley-theme.h',
- 'smiley.h',
'status.h',
'stun.h',
'tests.h',
--- a/libpurple/protocols/jabber/jabber.c Tue Aug 24 04:51:11 2021 -0500
+++ b/libpurple/protocols/jabber/jabber.c Tue Aug 24 04:52:14 2021 -0500
@@ -1076,7 +1076,6 @@
PurpleImage *image;
purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_HTML |
- PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY |
PURPLE_CONNECTION_FLAG_NO_IMAGES);
js = jabber_stream_new(account);
if (js == NULL)
--- a/libpurple/protocols/jabber/message.c Tue Aug 24 04:51:11 2021 -0500
+++ b/libpurple/protocols/jabber/message.c Tue Aug 24 04:52:14 2021 -0500
@@ -34,11 +34,6 @@
#include <string.h>
-typedef struct {
- PurpleConversation *conv;
- gchar *shortcut;
-} JabberMessageRemoteSmileyAddData;
-
static GString *jm_body_with_oob(JabberMessage *jm) {
GList *etc;
GString *body = g_string_new("");
@@ -339,70 +334,6 @@
purple_protocol_got_attention(jm->js->gc, jm->from, 0);
}
-static void
-jabber_message_get_refs_from_xmlnode_internal(const PurpleXmlNode *message,
- GHashTable *table)
-{
- PurpleXmlNode *child;
-
- for (child = purple_xmlnode_get_child(message, "img") ; child ;
- child = purple_xmlnode_get_next_twin(child)) {
- const gchar *src = purple_xmlnode_get_attrib(child, "src");
-
- if (g_str_has_prefix(src, "cid:")) {
- const gchar *cid = src + 4;
-
- /* if we haven't "fetched" this yet... */
- if (!g_hash_table_lookup(table, cid)) {
- gchar *value;
- const gchar *alt = purple_xmlnode_get_attrib(child, "alt");
- /* if there is no "alt" string, use the cid...
- include the entire src, eg. "cid:.." to avoid linkification */
- if (alt && alt[0] != '\0') {
- /* workaround for when "alt" is set to the value of the
- CID (which Jabbim seems to do), to avoid it showing up
- as an mailto: link */
- if (purple_email_is_valid(alt)) {
- value = g_strdup_printf("smiley:%s", alt);
- } else {
- value = g_strdup(alt);
- }
- } else {
- value = g_strdup(src);
- }
- g_hash_table_insert(table, g_strdup(cid), value);
- }
- }
- }
-
- for (child = message->child ; child ; child = child->next) {
- jabber_message_get_refs_from_xmlnode_internal(child, table);
- }
-}
-
-static gboolean
-jabber_message_get_refs(gpointer key, gpointer value, gpointer user_data)
-{
- GList **refs = (GList **) user_data;
- PurpleKeyValuePair *ref = purple_key_value_pair_new_full(key, value, g_free);
-
- *refs = g_list_append(*refs, ref);
-
- return TRUE;
-}
-
-static GList *
-jabber_message_get_refs_from_xmlnode(const PurpleXmlNode *message)
-{
- GList *refs = NULL;
- GHashTable *unique_refs = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
-
- jabber_message_get_refs_from_xmlnode_internal(message, unique_refs);
- (void)g_hash_table_foreach_remove(unique_refs, jabber_message_get_refs, &refs);
- g_hash_table_destroy(unique_refs);
- return refs;
-}
-
static gchar *
jabber_message_xml_to_string_strip_img_smileys(PurpleXmlNode *xhtml)
{
@@ -474,101 +405,6 @@
return g_string_free(out, FALSE);
}
-static void
-jabber_message_add_remote_smileys(JabberStream *js, const gchar *who,
- const PurpleXmlNode *message)
-{
- PurpleXmlNode *data_tag;
- for (data_tag = purple_xmlnode_get_child_with_namespace(message, "data", NS_BOB) ;
- data_tag ;
- data_tag = purple_xmlnode_get_next_twin(data_tag)) {
- const gchar *cid = purple_xmlnode_get_attrib(data_tag, "cid");
- const JabberData *data = jabber_data_find_remote_by_cid(js, who, cid);
-
- if (!data && cid != NULL) {
- /* we haven't cached this already, let's add it */
- JabberData *new_data = jabber_data_create_from_xml(data_tag);
-
- if (new_data) {
- jabber_data_associate_remote(js, who, new_data);
- }
- }
- }
-}
-
-static void
-jabber_message_remote_smiley_got(JabberData *jdata, gchar *alt, gpointer d) {
- JabberMessageRemoteSmileyAddData *data = (JabberMessageRemoteSmileyAddData *)d;
-
- if (jdata) {
- PurpleSmiley *smiley = NULL;
-
- purple_debug_info("jabber",
- "smiley data retrieved successfully");
-
- smiley = purple_smiley_new_from_data(
- data->shortcut,
- jabber_data_get_data(jdata),
- jabber_data_get_size(jdata)
- );
-
- purple_conversation_add_smiley(data->conv, smiley);
-
- g_object_unref(G_OBJECT(smiley));
- } else {
- purple_debug_error("jabber", "failed retrieving smiley data");
- }
-
- g_object_unref(G_OBJECT(data->conv));
- g_free(data->shortcut);
- g_slice_free(JabberMessageRemoteSmileyAddData, data);
-}
-
-static void
-jabber_message_remote_smiley_add(JabberStream *js, PurpleConversation *conv,
- const gchar *from, const gchar *shortcut, const gchar *cid)
-{
- PurpleSmiley *smiley = NULL;
- const JabberData *jdata = NULL;
-
- purple_debug_misc("jabber", "about to add remote smiley %s to the conv",
- shortcut);
-
- smiley = purple_conversation_get_smiley(conv, shortcut);
- if(PURPLE_IS_SMILEY(smiley)) {
- purple_debug_misc("jabber", "smiley was already present");
- return;
- }
-
- /* TODO: cache lookup by "cid" */
- jdata = jabber_data_find_remote_by_cid(js, from, cid);
- if (jdata) {
- purple_debug_info("jabber", "smiley data is already known");
-
- smiley = purple_smiley_new_from_data(
- shortcut,
- jabber_data_get_data(jdata),
- jabber_data_get_size(jdata)
- );
-
- purple_conversation_add_smiley(conv, smiley);
-
- g_object_unref(G_OBJECT(smiley));
- } else {
- JabberMessageRemoteSmileyAddData *data = NULL;
-
- data = g_slice_new(JabberMessageRemoteSmileyAddData);
- data->conv = g_object_ref(conv);
- data->shortcut = g_strdup(shortcut);
-
- purple_debug_info("jabber", "smiley data is unknown, "
- "need to request it");
-
- jabber_data_request(js, cid, from, NULL, FALSE,
- jabber_message_remote_smiley_got, data);
- }
-}
-
void jabber_message_parse(JabberStream *js, PurpleXmlNode *packet)
{
JabberMessage *jm;
@@ -731,52 +567,8 @@
} else if(purple_strequal(child->name, "html") && purple_strequal(xmlns, NS_XHTML_IM)) {
if(!jm->xhtml && purple_xmlnode_get_child(child, "body")) {
char *c;
-
- PurpleConnection *gc = js->gc;
- PurpleAccount *account = purple_connection_get_account(gc);
- PurpleConversation *conv = NULL;
- GList *smiley_refs = NULL;
gchar *reformatted_xhtml;
- if (purple_account_get_bool(account, "custom_smileys", TRUE)) {
- /* find a list of smileys ("cid" and "alt" text pairs)
- occuring in the message */
- smiley_refs = jabber_message_get_refs_from_xmlnode(child);
- purple_debug_info("jabber", "found %d smileys\n",
- g_list_length(smiley_refs));
-
- if (smiley_refs) {
- if (jm->type == JABBER_MESSAGE_GROUPCHAT) {
- JabberID *jid = jabber_id_new(jm->from);
- JabberChat *chat = NULL;
-
- if (jid) {
- chat = jabber_chat_find(js, jid->node, jid->domain);
- if (chat)
- conv = PURPLE_CONVERSATION(chat->conv);
- jabber_id_free(jid);
- }
- } else if (jm->type == JABBER_MESSAGE_NORMAL ||
- jm->type == JABBER_MESSAGE_CHAT)
- {
- PurpleConversationManager *manager;
-
- manager = purple_conversation_manager_get_default();
- conv = purple_conversation_manager_find(manager,
- account,
- from);
- if (!conv) {
- /* we need to create the conversation here */
- conv = PURPLE_CONVERSATION(
- purple_im_conversation_new(account, from));
- }
- }
- }
-
- /* process any newly provided smileys */
- jabber_message_add_remote_smileys(js, to, packet);
- }
-
purple_xmlnode_strip_prefixes(child);
/* reformat xhtml so that img tags with a "cid:" src gets
@@ -788,20 +580,6 @@
jm->xhtml = reformatted_xhtml;
- /* add known custom emoticons to the conversation */
- /* note: if there were no smileys in the incoming message, or
- if receiving custom smileys is turned off, smiley_refs will
- be NULL */
- if (conv) {
- for (GList *it = smiley_refs; it; it = g_list_next(it)) {
- PurpleKeyValuePair *ref = it->data;
-
- jabber_message_remote_smiley_add(js,
- conv, from, ref->value, ref->key);
- }
- }
- g_list_free_full(smiley_refs, (GDestroyNotify)purple_key_value_pair_free);
-
/* Convert all newlines to whitespace. Technically, even regular, non-XML HTML is supposed to ignore newlines, but Pidgin has, as convention
* treated \n as a newline for compatibility with other protocols
*/
@@ -923,147 +701,6 @@
jabber_message_free(jm);
}
-static gboolean
-jabber_conv_support_custom_smileys(JabberStream *js,
- PurpleConversation *conv, const gchar *who)
-{
- JabberBuddy *jb;
- JabberChat *chat;
-
- if (PURPLE_IS_IM_CONVERSATION(conv)) {
- jb = jabber_buddy_find(js, who, FALSE);
- if (jb) {
- return jabber_buddy_has_capability(jb, NS_BOB);
- } else {
- return FALSE;
- }
- } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
- chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
- if (chat) {
- /* do not attempt to send custom smileys in a MUC with more than
- 10 people, to avoid getting too many BoB requests */
- return jabber_chat_get_num_participants(chat) <= 10 &&
- jabber_chat_all_participants_have_capability(chat,
- NS_BOB);
- } else {
- return FALSE;
- }
- } else {
- return FALSE;
- }
-}
-
-static gboolean
-jabber_message_smileyify_cb(GString *out, PurpleSmiley *smiley,
- PurpleConversation *_empty, gpointer _unused)
-{
- const gchar *shortcut;
- const JabberData *data;
- PurpleXmlNode *smiley_node;
- gchar *node_xml;
-
- shortcut = purple_smiley_get_shortcut(smiley);
- data = jabber_data_find_local_by_alt(shortcut);
-
- if (!data)
- return FALSE;
-
- smiley_node = jabber_data_get_xhtml_im(data, shortcut);
- node_xml = purple_xmlnode_to_str(smiley_node, NULL);
-
- g_string_append(out, node_xml);
-
- purple_xmlnode_free(smiley_node);
- g_free(node_xml);
-
- return TRUE;
-}
-
-static char *
-jabber_message_smileyfy_xhtml(JabberMessage *jm, const char *xhtml)
-{
- PurpleAccount *account = purple_connection_get_account(jm->js->gc);
- GList *found_smileys, *it, *it_next;
- PurpleConversation *conv;
- PurpleConversationManager *manager;
- gboolean has_too_large_smiley = FALSE;
- gchar *smileyfied_xhtml = NULL;
-
- manager = purple_conversation_manager_get_default();
- conv = purple_conversation_manager_find(manager, account, jm->to);
-
- if (!jabber_conv_support_custom_smileys(jm->js, conv, jm->to))
- return NULL;
-
- found_smileys = purple_smiley_parser_find(
- purple_smiley_custom_get_list(), xhtml, TRUE);
- if (!found_smileys)
- return NULL;
-
- for (it = found_smileys; it; it = it_next) {
- PurpleSmiley *smiley = it->data;
- gboolean valid = TRUE;
-
- it_next = g_list_next(it);
-
- if (purple_image_get_data_size(PURPLE_IMAGE(smiley)) > JABBER_DATA_MAX_SIZE) {
- has_too_large_smiley = TRUE;
- valid = FALSE;
- purple_debug_warning("jabber", "Refusing to send "
- "smiley %s (too large, max is %d)",
- purple_smiley_get_shortcut(smiley),
- JABBER_DATA_MAX_SIZE);
- }
-
- if (!valid)
- found_smileys = g_list_delete_link(found_smileys, it);
- }
-
- if (has_too_large_smiley) {
- purple_conversation_write_system_message(conv,
- _("A custom smiley in the message is too large to send."),
- PURPLE_MESSAGE_ERROR);
- }
-
- if (!found_smileys)
- return NULL;
-
- for (it = found_smileys; it; it = g_list_next(it)) {
- PurpleSmiley *smiley = it->data;
- const gchar *shortcut = purple_smiley_get_shortcut(smiley);
- const gchar *mimetype;
- JabberData *jdata;
-
- /* the object has been sent before */
- if (jabber_data_find_local_by_alt(shortcut))
- continue;
-
- mimetype = purple_image_get_mimetype(PURPLE_IMAGE(smiley));
- if (!mimetype) {
- purple_debug_error("jabber",
- "unknown mime type for image");
- continue;
- }
-
- jdata = jabber_data_create_from_data(
- purple_image_get_data(PURPLE_IMAGE(smiley)),
- purple_image_get_data_size(PURPLE_IMAGE(smiley)),
- mimetype, FALSE, jm->js);
-
- purple_debug_info("jabber", "cache local smiley alt=%s, cid=%s",
- shortcut, jabber_data_get_cid(jdata));
- jabber_data_associate_local(jdata, shortcut);
- }
-
- g_list_free(found_smileys);
-
- smileyfied_xhtml = purple_smiley_parser_replace(
- purple_smiley_custom_get_list(), xhtml,
- jabber_message_smileyify_cb, NULL);
-
- return smileyfied_xhtml;
-}
-
void jabber_message_send(JabberMessage *jm)
{
PurpleXmlNode *message, *child;
@@ -1237,12 +874,6 @@
purple_markup_html_to_xhtml(tmp, &xhtml, &jm->body);
g_free(tmp);
- tmp = jabber_message_smileyfy_xhtml(jm, xhtml);
- if (tmp) {
- g_free(xhtml);
- xhtml = tmp;
- }
-
/*
* For backward compatibility with user expectations or for those not on
* the user's roster, allow sending XHTML-IM markup.
@@ -1289,11 +920,6 @@
tmp = purple_utf8_strip_unprintables(purple_message_get_contents(msg));
purple_markup_html_to_xhtml(tmp, &xhtml, &jm->body);
g_free(tmp);
- tmp = jabber_message_smileyfy_xhtml(jm, xhtml);
- if (tmp) {
- g_free(xhtml);
- xhtml = tmp;
- }
if (chat->xhtml && !jabber_xhtml_plain_equal(xhtml, jm->body))
/* Wrap the message in <p/> for greater interoperability justice. */
@@ -1361,10 +987,3 @@
gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *namespace) {
return js->allowBuzz;
}
-
-gboolean jabber_custom_smileys_isenabled(JabberStream *js, const gchar *namespace)
-{
- PurpleAccount *account = purple_connection_get_account(js->gc);
-
- return purple_account_get_bool(account, "custom_smileys", TRUE);
-}
--- a/libpurple/protocols/jabber/message.h Tue Aug 24 04:51:11 2021 -0500
+++ b/libpurple/protocols/jabber/message.h Tue Aug 24 04:52:14 2021 -0500
@@ -79,6 +79,4 @@
gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *namespace);
-gboolean jabber_custom_smileys_isenabled(JabberStream *js, const gchar *namespace);
-
#endif /* PURPLE_JABBER_MESSAGE_H */
--- a/libpurple/protocols/jabber/xmpp.c Tue Aug 24 04:51:11 2021 -0500
+++ b/libpurple/protocols/jabber/xmpp.c Tue Aug 24 04:52:14 2021 -0500
@@ -74,13 +74,6 @@
option = purple_account_option_string_new(_("BOSH URL"), "bosh_url", NULL);
opts = g_list_append(opts, option);
- /* this should probably be part of global smiley theme settings
- * later on
- */
- option = purple_account_option_bool_new(_("Show Custom Smileys"),
- "custom_smileys", TRUE);
- opts = g_list_append(opts, option);
-
return opts;
}
--- a/libpurple/purpleconversation.c Tue Aug 24 04:51:11 2021 -0500
+++ b/libpurple/purpleconversation.c Tue Aug 24 04:52:14 2021 -0500
@@ -38,7 +38,6 @@
#include "purpleprotocolclient.h"
#include "request.h"
#include "signals.h"
-#include "smiley-list.h"
typedef struct {
PurpleAccount *account; /* The user using this conversation. */
@@ -54,11 +53,6 @@
PurpleConnectionFlags features; /* The supported features */
GList *message_history; /* Message history, as a GList of PurpleMessages */
-
- /* The list of remote smileys. This should be per-buddy (PurpleBuddy),
- * but we don't have any class for people not on our buddy
- * list (PurpleDude?). So, if we have one, we should switch to it. */
- PurpleSmileyList *remote_smileys;
} PurpleConversationPrivate;
enum {
@@ -979,60 +973,3 @@
return purple_protocol_client_get_max_message_size(PURPLE_PROTOCOL_CLIENT(protocol), conv);
}
-
-void
-purple_conversation_add_smiley(PurpleConversation *conv, PurpleSmiley *smiley) {
- PurpleConversationPrivate *priv = NULL;
-
- g_return_if_fail(PURPLE_IS_CONVERSATION(conv));
- g_return_if_fail(smiley);
-
- priv = purple_conversation_get_instance_private(conv);
-
- if(priv->remote_smileys == NULL) {
- priv->remote_smileys = purple_smiley_list_new();
- g_object_set(priv->remote_smileys, "drop-failed-remotes", TRUE, NULL);
- }
-
- if(purple_smiley_list_get_by_shortcut(
- priv->remote_smileys,
- purple_smiley_get_shortcut(smiley)))
- {
- /* smiley was already added */
- return;
- }
-
- if(!purple_smiley_list_add(priv->remote_smileys, smiley)) {
- purple_debug_error("conversation", "failed adding remote smiley to "
- "the list");
- }
-}
-
-PurpleSmiley *
-purple_conversation_get_smiley(PurpleConversation *conv,
- const gchar *shortcut)
-{
- PurpleConversationPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_CONVERSATION(conv), NULL);
- g_return_val_if_fail(shortcut, NULL);
-
- priv = purple_conversation_get_instance_private(conv);
-
- if(priv->remote_smileys == NULL) {
- return NULL;
- }
-
- return purple_smiley_list_get_by_shortcut(priv->remote_smileys, shortcut);
-}
-
-PurpleSmileyList *
-purple_conversation_get_remote_smileys(PurpleConversation *conv) {
- PurpleConversationPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_CONVERSATION(conv), NULL);
-
- priv = purple_conversation_get_instance_private(conv);
-
- return priv->remote_smileys;
-}
--- a/libpurple/purpleconversation.h Tue Aug 24 04:51:11 2021 -0500
+++ b/libpurple/purpleconversation.h Tue Aug 24 04:52:14 2021 -0500
@@ -140,7 +140,6 @@
#include "account.h"
#include "buddyicon.h"
#include "log.h"
-#include "smiley-list.h"
G_BEGIN_DECLS
@@ -446,36 +445,6 @@
gssize purple_conversation_get_max_message_size(PurpleConversation *conv);
/**
- * purple_conversation_add_smiley:
- * @conv: The conversation that receives new smiley.
- * @smiley: The smiley.
- *
- * Adds a smiley to the list of smileys that belong to this conversation.
- */
-void purple_conversation_add_smiley(PurpleConversation *conv, PurpleSmiley *smiley);
-
-/**
- * purple_conversation_get_smiley:
- * @conv: The conversation.
- * @shortcut: The shortcut.
- *
- * Lookups for the smiley previously added to this conversation.
- *
- * Returns: (transfer none): The smiley, or %NULL if it doesn't exists.
- */
-PurpleSmiley *purple_conversation_get_smiley(PurpleConversation *conv, const gchar *shortcut);
-
-/**
- * purple_conversation_get_remote_smileys:
- * @conv: The conversation.
- *
- * Get all remote smileys previously added to this conversation.
- *
- * Returns: (transfer none): The list of remote smileys.
- */
-PurpleSmileyList *purple_conversation_get_remote_smileys(PurpleConversation *conv);
-
-/**
* purple_conversation_present_error:
* @who: The user this error is about
* @account: The account this error is on
--- a/libpurple/smiley-custom.c Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,325 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#include "smiley-custom.h"
-
-#include "internal.h"
-#include "debug.h"
-#include "util.h"
-
-#include <glib/gstdio.h>
-#include <errno.h>
-
-#define SMILEYS_DEFAULT_FOLDER "custom_smiley"
-#define SMILEYS_INDEX_FILE "smileys.xml"
-
-static gchar *smileys_dir;
-static gchar *smileys_index;
-
-static PurpleSmileyList *smileys_list;
-static gboolean disable_write = FALSE;
-
-/*******************************************************************************
- * XML storage
- ******************************************************************************/
-
-static void
-purple_smiley_custom_load(void)
-{
- PurpleXmlNode *root_node, *profile_node, *smileyset_node, *smiley_node;
- gchar *basename;
- gchar *dirname;
- int got_smileys = 0;
-
- if (!g_file_test(smileys_index, G_FILE_TEST_EXISTS))
- return;
-
- basename = g_path_get_basename(smileys_index);
- dirname = g_path_get_dirname(smileys_index);
- root_node = purple_xmlnode_from_file(dirname, basename,
- "custom smileys index", "smiley-custom");
- g_free(dirname);
- g_free(basename);
-
- g_return_if_fail(root_node);
-
- profile_node = purple_xmlnode_get_child(root_node, "profile");
- if (!profile_node) {
- purple_xmlnode_free(root_node);
- g_return_if_fail(profile_node);
- }
-
- smileyset_node = purple_xmlnode_get_child(profile_node, "smiley_set");
- if (!smileyset_node) {
- purple_xmlnode_free(root_node);
- g_return_if_fail(smileyset_node);
- }
-
- smiley_node = purple_xmlnode_get_child(smileyset_node, "smiley");
- while (smiley_node) {
- const gchar *shortcut, *file_name;
-
- shortcut = purple_xmlnode_get_attrib(smiley_node, "shortcut");
- file_name = purple_xmlnode_get_attrib(smiley_node, "filename");
-
- if (shortcut && file_name) {
- PurpleSmiley *smiley;
- gchar *file_path = g_build_filename(
- smileys_dir, file_name, NULL);
-
- smiley = purple_smiley_new(shortcut, file_path);
- g_free(file_path);
-
- if (purple_smiley_list_add(smileys_list, smiley)) {
- got_smileys++;
- } else {
- purple_debug_warning("smiley-custom",
- "Couldn't add '%s' smiley", shortcut);
- }
- g_object_unref(smiley);
- }
-
- smiley_node = purple_xmlnode_get_next_twin(smiley_node);
- }
-
- purple_xmlnode_free(root_node);
-
- purple_debug_info("smiley-custom", "Loaded %d custom smiley(s)",
- got_smileys);
-}
-
-static PurpleXmlNode *
-smileys_to_xmlnode(void)
-{
- PurpleXmlNode *root_node, *profile_node, *smileyset_node;
- GList *smileys, *it;
- gchar *basename;
-
- root_node = purple_xmlnode_new("smileys");
- purple_xmlnode_set_attrib(root_node, "version", "1.0");
-
- profile_node = purple_xmlnode_new("profile");
- purple_xmlnode_insert_child(root_node, profile_node);
- purple_xmlnode_set_attrib(profile_node, "name", "Default");
-
- smileyset_node = purple_xmlnode_new("smiley_set");
- purple_xmlnode_insert_child(profile_node, smileyset_node);
-
- smileys = purple_smiley_list_get_all(smileys_list);
-
- for (it = smileys; it; it = g_list_next(it)) {
- PurpleSmiley *smiley = PURPLE_SMILEY(it->data);
- PurpleXmlNode *smiley_node;
-
- smiley_node = purple_xmlnode_new("smiley");
- purple_xmlnode_insert_child(smileyset_node, smiley_node);
- purple_xmlnode_set_attrib(smiley_node, "shortcut",
- purple_smiley_get_shortcut(smiley));
- basename = g_path_get_basename(purple_image_get_path(
- PURPLE_IMAGE(smiley)));
- purple_xmlnode_set_attrib(smiley_node, "filename", basename);
- g_free(basename);
- }
-
- return root_node;
-}
-
-static void
-purple_smiley_custom_save(void)
-{
- PurpleXmlNode *root_node;
- gchar *data;
- GError *error = NULL;
-
- if (disable_write)
- return;
-
- root_node = smileys_to_xmlnode();
- g_return_if_fail(root_node != NULL);
-
- data = purple_xmlnode_to_formatted_str(root_node, NULL);
- g_return_if_fail(data != NULL);
-
- g_file_set_contents(smileys_index, data, -1, &error);
-
- g_free(data);
- purple_xmlnode_free(root_node);
-
- if (error) {
- purple_debug_error("smiley-custom",
- "Error writting custom smileys xml file");
- }
-}
-
-static gchar *
-purple_smiley_custom_img_checksum(PurpleImage *img)
-{
- g_return_val_if_fail(PURPLE_IS_IMAGE(img), NULL);
-
- return g_compute_checksum_for_data(G_CHECKSUM_SHA1,
- purple_image_get_data(img),
- purple_image_get_data_size(img));
-}
-
-
-/*******************************************************************************
- * API implementation
- ******************************************************************************/
-
-PurpleSmiley *
-purple_smiley_custom_add(PurpleImage *img, const gchar *shortcut)
-{
- PurpleSmiley *existing_smiley, *smiley;
- gchar *checksum, *file_path;
- gchar file_name[256];
- const gchar *file_ext;
- gboolean succ;
-
- g_return_val_if_fail(PURPLE_IS_IMAGE(img), NULL);
-
- existing_smiley = purple_smiley_list_get_by_shortcut(
- smileys_list, shortcut);
-
- g_object_ref(img);
-
- if (existing_smiley) {
- disable_write = TRUE;
- purple_smiley_custom_remove(existing_smiley);
- disable_write = FALSE;
- }
-
- checksum = purple_smiley_custom_img_checksum(img);
- file_ext = purple_image_get_extension(img);
- if (file_ext == NULL || g_strcmp0("icon", file_ext) == 0) {
- purple_debug_warning("smiley-custom", "Invalid image type");
- return NULL;
- }
-
- g_snprintf(file_name, sizeof(file_name), "%s.%s", checksum, file_ext);
- g_free(checksum);
-
- file_path = g_build_filename(smileys_dir, file_name, NULL);
-
- if (!purple_image_save(img, file_path)) {
- purple_debug_error("smiley-custom", "Failed writing smiley "
- "file %s", file_path);
- g_free(file_path);
- g_object_unref(img);
- return NULL;
- }
- g_object_unref(img);
-
- smiley = purple_smiley_new(shortcut, file_path);
- g_free(file_path);
- succ = purple_smiley_list_add(smileys_list, smiley);
- g_object_unref(smiley);
-
- if (!succ)
- purple_debug_error("smiley-custom", "Failed adding a smiley");
-
- purple_smiley_custom_save();
-
- return smiley;
-}
-
-void
-purple_smiley_custom_remove(PurpleSmiley *smiley)
-{
- PurpleSmiley *existing_smiley;
- const gchar *smiley_shortcut, *path;
- GList *other_smileys, *it;
- gboolean is_unique;
-
- g_return_if_fail(PURPLE_IS_SMILEY(smiley));
-
- smiley_shortcut = purple_smiley_get_shortcut(smiley);
- existing_smiley = purple_smiley_list_get_by_shortcut(
- smileys_list, smiley_shortcut);
- if (existing_smiley == NULL)
- return;
- if (existing_smiley != smiley) {
- purple_debug_warning("smiley-custom", "Smiley is not in store");
- return;
- }
-
- g_object_ref(smiley);
- purple_smiley_list_remove(smileys_list, smiley);
-
- path = purple_image_get_path(PURPLE_IMAGE(smiley));
-
- other_smileys = purple_smiley_list_get_unique(smileys_list);
- is_unique = TRUE;
- for (it = other_smileys; it; it = g_list_next(it)) {
- PurpleSmiley *other = it->data;
- const gchar *other_path = purple_image_get_path(PURPLE_IMAGE(other));
- if (g_strcmp0(other_path, path) == 0) {
- is_unique = FALSE;
- break;
- }
- }
- g_list_free(other_smileys);
-
- if (is_unique)
- g_unlink(path);
-
- g_object_unref(smiley);
-
- purple_smiley_custom_save();
-}
-
-PurpleSmileyList *
-purple_smiley_custom_get_list(void)
-{
- return smileys_list;
-}
-
-
-/*******************************************************************************
- * Custom smiley subsystem
- ******************************************************************************/
-
-void
-_purple_smiley_custom_init(void)
-{
- gint ret;
-
- smileys_dir = g_build_filename(purple_data_dir(),
- SMILEYS_DEFAULT_FOLDER, NULL);
- smileys_index = g_build_filename(purple_config_dir(),
- SMILEYS_INDEX_FILE, NULL);
- smileys_list = purple_smiley_list_new();
-
- ret = g_mkdir(smileys_dir, S_IRUSR | S_IWUSR | S_IXUSR);
- if (ret != 0 && errno != EEXIST) {
- purple_debug_error("smiley-custom", "Failed creating custom "
- "smileys directory: %s (%d)", g_strerror(errno), errno);
- }
-
- purple_smiley_custom_load();
-}
-
-void
-_purple_smiley_custom_uninit(void)
-{
- g_free(smileys_dir);
- g_free(smileys_index);
- g_object_unref(smileys_list);
-}
--- a/libpurple/smiley-custom.h Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#endif
-
-#ifndef PURPLE_SMILEY_CUSTOM_H
-#define PURPLE_SMILEY_CUSTOM_H
-/**
- * SECTION:smiley-custom
- * @include:smiley-custom.h
- * @section_id: libpurple-smiley-custom
- * @short_description: a persistent storage for user-defined smileys
- * @title: Custom smileys storage
- *
- * A custom smiley is a non-standard (not defined by a particular protocol)
- * #PurpleSmiley, defined by user. Some protocols support sending such smileys
- * for other buddies, that do not have such image on their machine. Protocol
- * that supports this feature should set the flag
- * @PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY of #PurpleConnectionFlags.
- */
-
-#include "smiley.h"
-#include "smiley-list.h"
-
-/**
- * purple_smiley_custom_add:
- * @image: the smiley's image.
- * @shortcut: textual representation of a smiley.
- *
- * Adds a new smiley to the store. The @shortcut should be unique, but the
- * @image contents don't have to.
- *
- * Returns: (transfer none): A new #PurpleSmiley, or %NULL if error occurred.
- */
-PurpleSmiley *
-purple_smiley_custom_add(PurpleImage *image, const gchar *shortcut);
-
-/**
- * purple_smiley_custom_remove:
- * @smiley: the smiley to be removed.
- *
- * Removes a @smiley from the store. If the @smiley file is unique (not used by
- * other smileys) it will be removed from a disk.
- */
-void
-purple_smiley_custom_remove(PurpleSmiley *smiley);
-
-/**
- * purple_smiley_custom_get_list:
- *
- * Returns the whole list of user-configured custom smileys.
- *
- * Returns: (transfer none): A #PurpleSmileyList of custom smileys.
- */
-PurpleSmileyList *
-purple_smiley_custom_get_list(void);
-
-/**
- * _purple_smiley_custom_init: (skip)
- *
- * Initializes the custom smileys storage subsystem.
- * Stability: Private
- */
-void
-_purple_smiley_custom_init(void);
-
-/**
- * _purple_smiley_custom_uninit: (skip)
- *
- * Uninitializes the custom smileys storage subsystem.
- */
-void
-_purple_smiley_custom_uninit(void);
-
-#endif /* PURPLE_SMILEY_CUSTOM_H */
--- a/libpurple/smiley-list.c Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,391 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#include "smiley-list.h"
-
-#include "debug.h"
-#include "smiley-parser.h"
-#include "trie.h"
-
-#include <string.h>
-
-/**
- * PurpleSmileyList:
- *
- * A container for #PurpleSmiley's.
- */
-struct _PurpleSmileyList {
- GObject parent;
-};
-
-typedef struct {
- GList *smileys;
- GList *smileys_end;
- PurpleTrie *trie;
- GHashTable *path_map;
- GHashTable *shortcut_map;
-
- gboolean drop_failed_remotes;
-} PurpleSmileyListPrivate;
-
-enum
-{
- PROP_0,
- PROP_DROP_FAILED_REMOTES,
- PROP_LAST
-};
-
-static GParamSpec *properties[PROP_LAST];
-
-/*******************************************************************************
- * Object stuff
- ******************************************************************************/
-G_DEFINE_TYPE_WITH_PRIVATE(PurpleSmileyList, purple_smiley_list, G_TYPE_OBJECT);
-
-static void
-purple_smiley_list_init(PurpleSmileyList *list) {
- PurpleSmileyListPrivate *priv = purple_smiley_list_get_instance_private(list);
-
- priv->trie = purple_trie_new();
- priv->path_map = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, NULL);
- priv->shortcut_map = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, NULL);
-}
-
-static void
-purple_smiley_list_finalize(GObject *obj) {
- PurpleSmileyList *sl = PURPLE_SMILEY_LIST(obj);
- PurpleSmileyListPrivate *priv = purple_smiley_list_get_instance_private(sl);
- GList *it;
-
- g_object_unref(priv->trie);
- g_hash_table_destroy(priv->path_map);
- g_hash_table_destroy(priv->shortcut_map);
-
- for (it = priv->smileys; it; it = g_list_next(it)) {
- PurpleSmiley *smiley = it->data;
- g_object_set_data(G_OBJECT(smiley), "purple-smiley-list", NULL);
- g_object_set_data(G_OBJECT(smiley), "purple-smiley-list-elem", NULL);
- g_object_unref(smiley);
- }
- g_list_free(priv->smileys);
-
- G_OBJECT_CLASS(purple_smiley_list_parent_class)->finalize(obj);
-}
-
-static void
-purple_smiley_list_get_property(GObject *obj, guint param_id, GValue *value,
- GParamSpec *pspec)
-{
- PurpleSmileyList *sl = PURPLE_SMILEY_LIST(obj);
- PurpleSmileyListPrivate *priv = purple_smiley_list_get_instance_private(sl);
-
- switch (param_id) {
- case PROP_DROP_FAILED_REMOTES:
- g_value_set_boolean(value, priv->drop_failed_remotes);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
- break;
- }
-}
-
-static void
-purple_smiley_list_set_property(GObject *obj, guint param_id,
- const GValue *value, GParamSpec *pspec)
-{
- PurpleSmileyList *sl = PURPLE_SMILEY_LIST(obj);
- PurpleSmileyListPrivate *priv = purple_smiley_list_get_instance_private(sl);
-
- switch (param_id) {
- case PROP_DROP_FAILED_REMOTES:
- priv->drop_failed_remotes = g_value_get_boolean(value);
- /* XXX: we could scan for remote smiley's on our list
- * and change the setting, but we don't care that much.
- */
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
- break;
- }
-}
-
-static void
-purple_smiley_list_class_init(PurpleSmileyListClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
- obj_class->get_property = purple_smiley_list_get_property;
- obj_class->set_property = purple_smiley_list_set_property;
- obj_class->finalize = purple_smiley_list_finalize;
-
- properties[PROP_DROP_FAILED_REMOTES] = g_param_spec_boolean(
- "drop-failed-remotes", "Drop failed remote PurpleSmileys",
- "Watch added remote smileys and remove them from the list, "
- "if they change their state to failed", FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties(obj_class, PROP_LAST, properties);
-}
-
-/******************************************************************************
- * Helpers
- *****************************************************************************/
-static void
-_list_append2(GList **head_p, GList **tail_p, gpointer data)
-{
- GList *head = *head_p;
- GList *tail = *tail_p;
- GList *elem;
-
- g_return_if_fail((head == NULL) == (tail == NULL));
- g_return_if_fail((tail == NULL) || (tail->next == NULL));
-
- elem = g_list_alloc();
- elem->data = data;
- elem->prev = tail;
- elem->next = NULL;
-
- if (head) {
- tail->next = elem;
- *tail_p = elem;
- } else
- *head_p = *tail_p = elem;
-}
-
-static void
-_list_delete_link2(GList **head_p, GList **tail_p, GList *link)
-{
- GList *head = *head_p;
- GList *tail = *tail_p;
-
- g_return_if_fail(head != NULL);
- g_return_if_fail(tail != NULL);
-
- if (link == tail)
- *tail_p = tail->prev;
- *head_p = g_list_delete_link(head, link);
-}
-
-static const gchar *
-smiley_get_uniqid(PurpleSmiley *smiley)
-{
- return purple_image_get_path(PURPLE_IMAGE(smiley));
-}
-
-/*******************************************************************************
- * API implementation
- ******************************************************************************/
-PurpleSmileyList *
-purple_smiley_list_new(void) {
- return g_object_new(PURPLE_TYPE_SMILEY_LIST, NULL);
-}
-
-gboolean
-purple_smiley_list_add(PurpleSmileyList *list, PurpleSmiley *smiley) {
- PurpleSmileyListPrivate *priv = NULL;
- const gchar *smiley_path;
- gboolean succ;
- gchar *shortcut_escaped;
- const gchar *shortcut;
-
- g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), FALSE);
- g_return_val_if_fail(PURPLE_IS_SMILEY(smiley), FALSE);
-
- priv = purple_smiley_list_get_instance_private(list);
-
- if (g_object_get_data(G_OBJECT(smiley), "purple-smiley-list") != NULL) {
- purple_debug_warning("smiley-list",
- "smiley is already associated with some list");
- return FALSE;
- }
-
- shortcut = purple_smiley_get_shortcut(smiley);
-
- if (g_hash_table_lookup(priv->shortcut_map, shortcut) != NULL)
- return FALSE;
-
- shortcut_escaped = g_markup_escape_text(shortcut, -1);
- succ = purple_trie_add(priv->trie, shortcut_escaped, smiley);
-
- /* A special-case for WebKit, which unescapes apos entity.
- * Please, don't trust this hack - it may be removed in future releases.
- */
- if (succ && strstr(shortcut_escaped, "&apos;") != NULL) {
- gchar *tmp = shortcut_escaped;
- shortcut_escaped = purple_strreplace(shortcut_escaped,
- "&apos;", "'");
- g_free(tmp);
- succ = purple_trie_add(priv->trie, shortcut_escaped, smiley);
- }
-
- g_free(shortcut_escaped);
- if (!succ)
- return FALSE;
-
- g_object_ref(smiley);
- _list_append2(&priv->smileys, &priv->smileys_end, smiley);
- g_object_set_data(G_OBJECT(smiley), "purple-smiley-list", list);
- g_object_set_data(G_OBJECT(smiley), "purple-smiley-list-elem",
- priv->smileys_end);
-
- g_hash_table_insert(priv->shortcut_map, g_strdup(shortcut), smiley);
-
- smiley_path = smiley_get_uniqid(smiley);
-
- /* TODO: add to the table, when the smiley sets the path */
- if (!smiley_path)
- return TRUE;
-
- if (g_hash_table_lookup(priv->path_map, smiley_path) == NULL) {
- g_hash_table_insert(priv->path_map,
- g_strdup(smiley_path), smiley);
- }
-
- return TRUE;
-}
-
-void
-purple_smiley_list_remove(PurpleSmileyList *list, PurpleSmiley *smiley) {
- PurpleSmileyListPrivate *priv = NULL;
- GList *list_elem, *it;
- const gchar *shortcut, *path;
- gchar *shortcut_escaped;
-
- g_return_if_fail(PURPLE_IS_SMILEY_LIST(list));
- g_return_if_fail(PURPLE_IS_SMILEY(smiley));
-
- priv = purple_smiley_list_get_instance_private(list);
-
- if (g_object_get_data(G_OBJECT(smiley), "purple-smiley-list") != list) {
- purple_debug_warning("smiley-list", "remove: invalid list");
- return;
- }
-
- list_elem = g_object_get_data(G_OBJECT(smiley),
- "purple-smiley-list-elem");
-
- shortcut = purple_smiley_get_shortcut(smiley);
- path = smiley_get_uniqid(smiley);
-
- g_hash_table_remove(priv->shortcut_map, shortcut);
- if (path)
- g_hash_table_remove(priv->path_map, path);
-
- shortcut_escaped = g_markup_escape_text(shortcut, -1);
- purple_trie_remove(priv->trie, shortcut);
- g_free(shortcut_escaped);
-
- _list_delete_link2(&priv->smileys, &priv->smileys_end, list_elem);
-
- /* re-add entry to path_map if smiley was not unique */
- for (it = priv->smileys; it && path; it = g_list_next(it)) {
- PurpleSmiley *smiley = it->data;
-
- if (g_strcmp0(smiley_get_uniqid(smiley), path) == 0) {
- g_hash_table_insert(priv->path_map,
- g_strdup(path), smiley);
- break;
- }
- }
-
- g_object_set_data(G_OBJECT(smiley), "purple-smiley-list", NULL);
- g_object_set_data(G_OBJECT(smiley), "purple-smiley-list-elem", NULL);
- g_object_unref(smiley);
-}
-
-gboolean
-purple_smiley_list_is_empty(PurpleSmileyList *list)
-{
- PurpleSmileyListPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), TRUE);
-
- priv = purple_smiley_list_get_instance_private(list);
-
- return (priv->smileys == NULL);
-}
-
-PurpleSmiley *
-purple_smiley_list_get_by_shortcut(PurpleSmileyList *list,
- const gchar *shortcut)
-{
- PurpleSmileyListPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), NULL);
-
- priv = purple_smiley_list_get_instance_private(list);
-
- return g_hash_table_lookup(priv->shortcut_map, shortcut);
-}
-
-PurpleTrie *
-purple_smiley_list_get_trie(PurpleSmileyList *list) {
- PurpleSmileyListPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), NULL);
-
- priv = purple_smiley_list_get_instance_private(list);
-
- return priv->trie;
-}
-
-GList *
-purple_smiley_list_get_unique(PurpleSmileyList *list) {
- GList *unique = NULL, *it;
- GHashTable *unique_map;
- PurpleSmileyListPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), NULL);
-
- priv = purple_smiley_list_get_instance_private(list);
-
- /* We could just return g_hash_table_get_values(priv->path_map) here,
- * but it won't be in order. */
-
- unique_map = g_hash_table_new(g_str_hash, g_str_equal);
-
- for (it = priv->smileys; it; it = g_list_next(it)) {
- PurpleSmiley *smiley = it->data;
- const gchar *path = smiley_get_uniqid(smiley);
-
- if (g_hash_table_lookup(unique_map, path))
- continue;
-
- unique = g_list_prepend(unique, smiley);
- g_hash_table_insert(unique_map, (gpointer)path, smiley);
- }
-
- g_hash_table_destroy(unique_map);
-
- return g_list_reverse(unique);
-}
-
-GList *
-purple_smiley_list_get_all(PurpleSmileyList *list) {
- PurpleSmileyListPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), NULL);
-
- priv = purple_smiley_list_get_instance_private(list);
-
- return g_hash_table_get_values(priv->shortcut_map);
-}
--- a/libpurple/smiley-list.h Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,158 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#endif
-
-#ifndef PURPLE_SMILEY_LIST_H
-#define PURPLE_SMILEY_LIST_H
-
-/**
- * SECTION:smiley-list
- * @include:smiley-list.h
- * @section_id: libpurple-smiley-list
- * @short_description: a collection of smileys
- * @title: Smiley lists
- *
- * A #PurpleSmileyList is a handy storage for a set of #PurpleSmiley's.
- * It holds structures needed for parsing, accessing them by a shortcut, or
- * listing (either all, or by unique image).
- */
-
-#include <glib-object.h>
-
-#include "smiley.h"
-#include "trie.h"
-
-G_BEGIN_DECLS
-
-/**
- * PURPLE_TYPE_SMILEY_LIST:
- *
- * The standard _get_type macro for #PurpleSmileyList.
- */
-#define PURPLE_TYPE_SMILEY_LIST purple_smiley_list_get_type()
-
-/**
- * purple_smiley_list_get_type:
- *
- * Returns: the #GType for a smiley list.
- */
-G_DECLARE_FINAL_TYPE(PurpleSmileyList, purple_smiley_list, PURPLE,
- SMILEY_LIST, GObject)
-
-/**
- * purple_smiley_list_new:
- *
- * Creates new #PurpleSmileyList. You might prefer using existing lists, like
- * #purple_smiley_custom_get_list or #purple_conversation_get_remote_smileys
- * (the latter is read-only, accessed with
- * #purple_conversation_add_remote_smiley and
- * #purple_conversation_get_remote_smiley).
- *
- * Returns: newly created #PurpleSmileyList.
- */
-PurpleSmileyList *purple_smiley_list_new(void);
-
-/**
- * purple_smiley_list_add:
- * @list: the smiley list.
- * @smiley: the smiley to be added.
- *
- * Adds the @smiley to the @list. A particular @smiley can only be added to
- * a single @list. Also, a @list can not contain multiple @smiley's with
- * the same shortcut.
- *
- * It increases the reference count of @smiley, if needed.
- *
- * Returns: %TRUE if the @smiley was successfully added to the list.
- */
-gboolean purple_smiley_list_add(PurpleSmileyList *list, PurpleSmiley *smiley);
-
-/**
- * purple_smiley_list_remove:
- * @list: the smiley list.
- * @smiley: the smiley to be removed.
- *
- * Removes a @smiley from the @list. If @smiley's reference count drops to zero,
- * it's destroyed.
- */
-void purple_smiley_list_remove(PurpleSmileyList *list, PurpleSmiley *smiley);
-
-/**
- * purple_smiley_list_is_empty:
- * @list: the smiley list.
- *
- * Checks, if the smiley @list is empty.
- *
- * Returns: %TRUE if the @list is empty, %FALSE otherwise.
- */
-gboolean purple_smiley_list_is_empty(PurpleSmileyList *list);
-
-/**
- * purple_smiley_list_get_by_shortcut:
- * @list: the smiley list.
- * @shortcut: the textual representation of smiley to lookup.
- *
- * Retrieves a smiley with the specified @shortcut from the @list.
- *
- * Returns: (transfer none): A #PurpleSmiley if the smiley was found, %NULL
- * otherwise.
- */
-PurpleSmiley *purple_smiley_list_get_by_shortcut(PurpleSmileyList *list, const gchar *shortcut);
-
-/**
- * purple_smiley_list_get_trie:
- * @list: the smiley list.
- *
- * Returns the #PurpleTrie for searching of #PurpleSmiley's being kept
- * in the @list. It holds markup escaped shortcuts, so if you want to search
- * in plain message, you have to escape it first. If you don't do this, it won't
- * find smileys containing special characters.
- *
- * Returns: (transfer none): a #PurpleTrie for contained smileys.
- */
-PurpleTrie *purple_smiley_list_get_trie(PurpleSmileyList *list);
-
-/**
- * purple_smiley_list_get_unique:
- * @list_: the smiley list.
- *
- * Returns the list of smileys with unique image file paths.
- *
- * Returns: (element-type PurpleSmiley) (transfer container): the list of unique smileys.
- */
-GList *purple_smiley_list_get_unique(PurpleSmileyList *list_);
-
-/**
- * purple_smiley_list_get_all:
- * @list_: the smiley list.
- *
- * Returns the list of all smileys added to the @list_.
- *
- * Returns: (element-type PurpleSmiley) (transfer container): the list of smileys.
- */
-GList *purple_smiley_list_get_all(PurpleSmileyList *list_);
-
-G_END_DECLS
-
-#endif /* PURPLE_SMILEY_LIST_H */
--- a/libpurple/smiley-parser.c Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,262 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#include "smiley-parser.h"
-
-#include "smiley-custom.h"
-#include "smiley-theme.h"
-
-#define DISPLAY_OUR_CUSTOM_SMILEYS_FOR_INCOMING_MESSAGES 1
-
-typedef struct
-{
- union {
- struct {
- PurpleConversation *conv;
- PurpleSmileyParseCb cb;
- gpointer ui_data;
- } replace;
- struct {
- GHashTable *found_smileys;
- } find;
- } job;
-
- gboolean in_html_tag;
-} PurpleSmileyParseData;
-
-static PurpleTrie *html_sentry;
-
-static inline void
-purple_smiley_parse_check_html(const gchar *word,
- PurpleSmileyParseData *parse_data)
-{
- if (G_LIKELY(word[0] == '<'))
- parse_data->in_html_tag = TRUE;
- else if (G_LIKELY(word[0] == '>'))
- parse_data->in_html_tag = FALSE;
- else
- g_return_if_reached();
- g_warn_if_fail(word[1] == '\0');
-}
-
-static gboolean
-purple_smiley_parse_cb(GString *out, const gchar *word, gpointer _smiley,
- gpointer _parse_data)
-{
- PurpleSmileyParseData *parse_data = _parse_data;
- PurpleSmiley *smiley = _smiley;
-
- /* a special-case for html_sentry */
- if (smiley == NULL) {
- purple_smiley_parse_check_html(word, parse_data);
- return FALSE;
- }
-
- if (parse_data->in_html_tag)
- return FALSE;
-
- return parse_data->job.replace.cb(out, smiley,
- parse_data->job.replace.conv, parse_data->job.replace.ui_data);
-}
-
-/* XXX: this shouldn't be a conv for incoming messages - see
- * PurpleConversationPrivate.remote_smileys.
- * For outgoing messages, we could pass conv in ui_data (or something).
- * Or maybe we should use two distinct functions?
- * To be reconsidered when we had PurpleDude-like objects.
- */
-gchar *
-purple_smiley_parser_smileify(PurpleConversation *conv, const gchar *html_message,
- gboolean use_remote_smileys, PurpleSmileyParseCb cb, gpointer ui_data)
-{
- PurpleSmileyTheme *theme;
- PurpleSmileyList *theme_smileys = NULL, *remote_smileys = NULL;
- PurpleTrie *theme_trie = NULL, *custom_trie = NULL, *remote_trie = NULL;
- GSList *tries = NULL;
- GSList tries_sentry, tries_theme, tries_custom, tries_remote;
- PurpleSmileyParseData parse_data;
-
- if (html_message == NULL || html_message[0] == '\0')
- return g_strdup(html_message);
-
- /* get remote smileys */
- if (use_remote_smileys)
- remote_smileys = purple_conversation_get_remote_smileys(conv);
- if (remote_smileys)
- remote_trie = purple_smiley_list_get_trie(remote_smileys);
- if (remote_trie && purple_trie_get_size(remote_trie) == 0)
- remote_trie = NULL;
-
- /* get custom smileys */
- if (purple_conversation_get_features(conv) &
- PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY)
- {
- custom_trie = purple_smiley_list_get_trie(
- purple_smiley_custom_get_list());
-#if !DISPLAY_OUR_CUSTOM_SMILEYS_FOR_INCOMING_MESSAGES
- if (use_remote_smileys)
- custom_trie = NULL;
-#endif
- }
- if (custom_trie && purple_trie_get_size(custom_trie) == 0)
- custom_trie = NULL;
-
- /* get theme smileys */
- theme = purple_smiley_theme_get_current();
- if (theme != NULL)
- theme_smileys = purple_smiley_theme_get_smileys(theme, ui_data);
- if (theme_smileys != NULL)
- theme_trie = purple_smiley_list_get_trie(theme_smileys);
-
- /* we have absolutely no smileys */
- if (theme_trie == NULL && custom_trie == NULL && remote_trie == NULL)
- return g_strdup(html_message);
-
- /* Create a tries list on the stack. */
- tries_sentry.data = html_sentry;
- tries_theme.data = theme_trie;
- tries_custom.data = custom_trie;
- tries_remote.data = remote_trie;
- tries_sentry.next = NULL;
- tries_theme.next = tries_custom.next = tries_remote.next = NULL;
- tries = &tries_sentry;
- if (remote_trie != NULL)
- g_slist_last(tries)->next = &tries_remote;
- if (custom_trie != NULL)
- g_slist_last(tries)->next = &tries_custom;
- if (theme_trie != NULL)
- g_slist_last(tries)->next = &tries_theme;
-
- parse_data.job.replace.conv = conv;
- parse_data.job.replace.cb = cb;
- parse_data.job.replace.ui_data = ui_data;
- parse_data.in_html_tag = FALSE;
-
- /* TODO: parse greedily (as much as possible) when PurpleTrie
- * provides support for it. */
- return purple_trie_multi_replace(tries, html_message,
- purple_smiley_parse_cb, &parse_data);
-}
-
-gchar *
-purple_smiley_parser_replace(PurpleSmileyList *smileys,
- const gchar *html_message, PurpleSmileyParseCb cb, gpointer ui_data)
-{
- PurpleTrie *smileys_trie = NULL;
- GSList trie_1, trie_2;
- PurpleSmileyParseData parse_data;
-
- if (html_message == NULL || html_message[0] == '\0')
- return g_strdup(html_message);
-
- if (smileys == NULL || purple_smiley_list_is_empty(smileys))
- return g_strdup(html_message);
-
- smileys_trie = purple_smiley_list_get_trie(smileys);
- g_return_val_if_fail(smileys_trie != NULL, NULL);
-
- trie_1.data = html_sentry;
- trie_2.data = smileys_trie;
- trie_1.next = &trie_2;
- trie_2.next = NULL;
-
- parse_data.job.replace.conv = NULL;
- parse_data.job.replace.cb = cb;
- parse_data.job.replace.ui_data = ui_data;
- parse_data.in_html_tag = FALSE;
-
- return purple_trie_multi_replace(&trie_1, html_message,
- purple_smiley_parse_cb, &parse_data);
-}
-
-static gboolean
-smiley_find_cb(const gchar *word, gpointer _smiley, gpointer _parse_data)
-{
- PurpleSmiley *smiley = _smiley;
- PurpleSmileyParseData *parse_data = _parse_data;
-
- /* a special-case for html_sentry */
- if (smiley == NULL) {
- purple_smiley_parse_check_html(word, parse_data);
- return FALSE;
- }
-
- if (parse_data->in_html_tag)
- return FALSE;
-
- g_hash_table_insert(parse_data->job.find.found_smileys, smiley, smiley);
-
- return TRUE;
-}
-
-GList *
-purple_smiley_parser_find(PurpleSmileyList *smileys, const gchar *message,
- gboolean is_html)
-{
- PurpleTrie *smileys_trie;
- GList *found_list;
- gchar *escaped_message = NULL;
- PurpleSmileyParseData parse_data;
- GSList trie_1, trie_2;
-
- if (message == NULL || message[0] == '\0')
- return NULL;
-
- if (smileys == NULL || purple_smiley_list_is_empty(smileys))
- return NULL;
-
- smileys_trie = purple_smiley_list_get_trie(smileys);
- g_return_val_if_fail(smileys_trie != NULL, NULL);
-
- if (!is_html)
- message = escaped_message = g_markup_escape_text(message, -1);
-
- parse_data.job.find.found_smileys =
- g_hash_table_new(g_direct_hash, g_direct_equal);
- parse_data.in_html_tag = FALSE;
-
- trie_1.data = html_sentry;
- trie_2.data = smileys_trie;
- trie_1.next = &trie_2;
- trie_2.next = NULL;
- purple_trie_multi_find(&trie_1, message, smiley_find_cb, &parse_data);
-
- g_free(escaped_message);
-
- found_list = g_hash_table_get_values(parse_data.job.find.found_smileys);
- g_hash_table_destroy(parse_data.job.find.found_smileys);
-
- return found_list;
-}
-
-void
-_purple_smiley_parser_init(void)
-{
- html_sentry = purple_trie_new();
- purple_trie_add(html_sentry, "<", NULL);
- purple_trie_add(html_sentry, ">", NULL);
-}
-
-void
-_purple_smiley_parser_uninit(void)
-{
- g_object_unref(html_sentry);
-}
--- a/libpurple/smiley-parser.h Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#endif
-
-#ifndef PURPLE_SMILEY_PARSER_H
-#define PURPLE_SMILEY_PARSER_H
-
-/**
- * SECTION:smiley-parser
- * @include:smiley-parser.h
- * @section_id: libpurple-smiley-parser
- * @short_description: a efficient smiley processor
- * @title: Smiley parser
- *
- * This module is a fast and easy method for searching (and optionally replacing)
- * #PurpleSmiley's in a text. It may use all suitable smiley sets to smileyify
- * the message in one step. The priority if always the following: remote
- * smileys > local custom smileys > theme smileys.
- */
-
-#include <glib.h>
-
-#include <purpleconversation.h>
-#include "smiley.h"
-#include "smiley-list.h"
-
-/**
- * PurpleSmileyParseCb:
- * @out: the message buffer.
- * @smiley: found smiley.
- * @conv: the conversation of a message (or %NULL, if not passed).
- * @ui_data: the data being passed to #purple_smiley_parse.
- *
- * A replace callback for the found @smiley. It should append a HTML tag
- * representing the @smiley to the @out string. It must not modify the
- * @out string in other way than appending to its end.
- *
- * If callback decides not to replace a smiley, it must not modify
- * @out in any way.
- *
- * Returns: %TRUE if the smiley was inserted.
- */
-typedef gboolean (*PurpleSmileyParseCb)(GString *out, PurpleSmiley *smiley,
- PurpleConversation *conv, gpointer ui_data);
-
-/**
- * purple_smiley_parser_smileify:
- * @conv: the conversation of a message.
- * @html_message: the html message, or escaped plain message.
- * @use_remote_smileys: %TRUE if remote smileys of @conv should be parsed.
- * @cb: (scope call): The callback to replace smiley text with an image.
- * @ui_data: the user data to be passed to @cb and
- * #purple_smiley_theme_get_smileys.
- *
- * Replaces all textual smiley representations with proper smiley images
- * configured for libpurple.
- *
- * The @use_remote_smileys parameter should be %TRUE for incoming messages,
- * %FALSE for outgoing.
- *
- * This function is intended for replacing all smileys before displaying. For
- * replacing custom smileys before sending to the other party,
- * see #purple_smiley_parser_replace.
- *
- * Returns: (transfer full): the smileifed message. Should be #g_free'd when
- * done using it. Returns %NULL if and only if @html_message was %NULL.
- */
-gchar *
-purple_smiley_parser_smileify(PurpleConversation *conv, const gchar *html_message,
- gboolean use_remote_smileys, PurpleSmileyParseCb cb, gpointer ui_data);
-
-/**
- * purple_smiley_parser_replace:
- * @smileys: the list of smileys to replace.
- * @html_message: the html message, or escaped plain message.
- * @cb: (scope call): The callback to replace smiley text with an image.
- * @ui_data: (closure cb): The user data to be passed to the callback.
- *
- * Replaces all textual smiley representations from @smileys list with images.
- *
- * This function is intended for replacing custom smileys before sending to the
- * other party. For replacing all sets of smileys (custom, remote and theme) at
- * once (ie. before displaying), use #purple_smiley_parser_smileify.
- *
- * Returns: (transfer full): the smileifed message. Should be #g_free'd when
- * done using it. Returns %NULL if and only if @html_message was %NULL.
- */
-gchar *
-purple_smiley_parser_replace(PurpleSmileyList *smileys,
- const gchar *html_message, PurpleSmileyParseCb cb, gpointer ui_data);
-
-/**
- * purple_smiley_parser_find:
- * @smileys: the list of smileys to find.
- * @message: the message.
- * @is_html: %TRUE if the message is HTML, %FALSE if it's plain, unescaped.
- *
- * Searches for all smileys from the @smileys list present in @message.
- * Each smiley is returned only once, regardless how many times it appeared in
- * text. However, distinct smileys may share common image file (thus, their
- * paths will be the same).
- *
- * Returns: (element-type PurpleSmiley) (transfer container): the list of found smileys.
- */
-GList *
-purple_smiley_parser_find(PurpleSmileyList *smileys, const gchar *message,
- gboolean is_html);
-
-/**
- * _purple_smiley_parser_init: (skip)
- *
- * Initializes the smileys parser subsystem.
- */
-void
-_purple_smiley_parser_init(void);
-
-/**
- * _purple_smiley_parser_uninit: (skip)
- *
- * Uninitializes the smileys parser subsystem.
- */
-void
-_purple_smiley_parser_uninit(void);
-
-#endif /* PURPLE_SMILEY_PARSER_H */
--- a/libpurple/smiley-theme.c Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#include "smiley-theme.h"
-
-static PurpleSmileyTheme *current = NULL;
-
-/*******************************************************************************
- * API implementation
- ******************************************************************************/
-
-PurpleSmileyList *
-purple_smiley_theme_get_smileys(PurpleSmileyTheme *theme, gpointer ui_data)
-{
- PurpleSmileyThemeClass *klass;
-
- g_return_val_if_fail(PURPLE_IS_SMILEY_THEME(theme), NULL);
- klass = PURPLE_SMILEY_THEME_GET_CLASS(theme);
- g_return_val_if_fail(klass != NULL, NULL);
- g_return_val_if_fail(klass->get_smileys != NULL, NULL);
-
- return klass->get_smileys(theme, ui_data);
-}
-
-void
-purple_smiley_theme_set_current(PurpleSmileyTheme *theme)
-{
- PurpleSmileyThemeClass *klass;
-
- g_return_if_fail(theme == NULL || PURPLE_IS_SMILEY_THEME(theme));
-
- if (theme)
- g_object_ref(theme);
- if (current)
- g_object_unref(current);
- current = theme;
-
- if (!theme)
- return;
- klass = PURPLE_SMILEY_THEME_GET_CLASS(theme);
- g_return_if_fail(klass != NULL);
- if (klass->activate)
- klass->activate(theme);
-}
-
-PurpleSmileyTheme *
-purple_smiley_theme_get_current(void)
-{
- return current;
-}
-
-void
-_purple_smiley_theme_uninit(void)
-{
- purple_smiley_theme_set_current(NULL);
-}
-
-
-/*******************************************************************************
- * Object stuff
- ******************************************************************************/
-
-GType
-purple_smiley_theme_get_type(void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY(type == 0)) {
- static const GTypeInfo info = {
- .class_size = sizeof(PurpleSmileyThemeClass),
- .instance_size = sizeof(PurpleSmileyTheme),
- };
-
- type = g_type_register_static(G_TYPE_OBJECT,
- "PurpleSmileyTheme", &info, G_TYPE_FLAG_ABSTRACT);
- }
-
- return type;
-}
--- a/libpurple/smiley-theme.h Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#endif
-
-#ifndef PURPLE_SMILEY_THEME_H
-#define PURPLE_SMILEY_THEME_H
-/**
- * SECTION:smiley-theme
- * @include:smiley-theme.h
- * @section_id: libpurple-smiley-theme
- * @short_description: a categorized set of standard smileys
- * @title: Smiley themes
- *
- * A smiley theme is a set of standard smileys, that may be displayed in user's
- * message window instead of their textual representations. It may be
- * categorized depending on the selected protocol, but it's up to the UI to
- * choose behavior.
- */
-
-#include <glib-object.h>
-
-#include "smiley.h"
-#include "smiley-list.h"
-
-G_BEGIN_DECLS
-
-/**
- * PURPLE_TYPE_SMILEY_THEME:
- *
- * The standard _get_type macro for #PurpleSmileyTheme.
- */
-#define PURPLE_TYPE_SMILEY_THEME purple_smiley_theme_get_type()
-
-/**
- * purple_smiley_theme_get_type:
- *
- * Returns: the #GType for a smiley list.
- */
-G_DECLARE_DERIVABLE_TYPE(PurpleSmileyTheme, purple_smiley_theme, PURPLE,
- SMILEY_THEME, GObject)
-
-/**
- * PurpleSmileyThemeClass:
- * @get_smileys: a callback for getting smiley list based on choosen category.
- * The criteria for a category are being passed using the
- * @ui_data parameter.
- * @activate: a callback being fired after activating the @theme. It may be used
- * for loading its contents before using @get_smileys callback.
- *
- * Base class for #PurpleSmileyTheme objects.
- */
-struct _PurpleSmileyThemeClass
-{
- /*< private >*/
- GObjectClass parent_class;
-
- /*< public >*/
- PurpleSmileyList * (*get_smileys)(PurpleSmileyTheme *theme,
- gpointer ui_data);
- void (*activate)(PurpleSmileyTheme *theme);
-
- /*< private >*/
- void (*purple_reserved1)(void);
- void (*purple_reserved2)(void);
- void (*purple_reserved3)(void);
- void (*purple_reserved4)(void);
-};
-
-/**
- * purple_smiley_theme_get_smileys:
- * @theme: the smiley theme.
- * @ui_data: the UI-passed criteria to choose a smiley set.
- *
- * Retrieves a smiley category based on UI-provided criteria.
- *
- * You might want to use <link linkend="libpurple-smiley-parser">smiley
- * parser</link> instead. It's mostly for the UI, prpls shouldn't use it.
- *
- * Returns: (transfer none): a #PurpleSmileyList with standard smileys to use.
- */
-PurpleSmileyList *
-purple_smiley_theme_get_smileys(PurpleSmileyTheme *theme, gpointer ui_data);
-
-/**
- * purple_smiley_theme_set_current:
- * @theme: the smiley theme to be set as currently used. May be %NULL.
- *
- * Sets the new smiley theme to be used for displaying messages.
- */
-void
-purple_smiley_theme_set_current(PurpleSmileyTheme *theme);
-
-/**
- * purple_smiley_theme_get_current:
- *
- * Returns the currently used smiley theme.
- *
- * Returns: (transfer none): the #PurpleSmileyTheme or %NULL, if none is set.
- */
-PurpleSmileyTheme *
-purple_smiley_theme_get_current(void);
-
-/**
- * _purple_smiley_theme_uninit: (skip)
- *
- * Uninitializes the smileys theme subsystem.
- */
-void
-_purple_smiley_theme_uninit(void);
-
-G_END_DECLS
-
-#endif /* PURPLE_SMILEY_THEME_H */
--- a/libpurple/smiley.c Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,211 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#include "smiley.h"
-
-/**
- * PurpleSmiley:
- *
- * A generic smiley. It can either be a theme smiley, or a custom smiley.
- */
-struct _PurpleSmiley {
- /*< private >*/
- PurpleImage parent;
-};
-
-typedef struct {
- gchar *shortcut;
-} PurpleSmileyPrivate;
-
-enum
-{
- PROP_0,
- PROP_SHORTCUT,
- PROP_LAST
-};
-
-static GParamSpec *properties[PROP_LAST];
-
-G_DEFINE_TYPE_WITH_PRIVATE(PurpleSmiley, purple_smiley, PURPLE_TYPE_IMAGE);
-
-/*******************************************************************************
- * Helpers
- ******************************************************************************/
-static void
-_purple_smiley_set_shortcut(PurpleSmiley *smiley, const gchar *shortcut) {
- PurpleSmileyPrivate *priv = purple_smiley_get_instance_private(smiley);
-
- g_free(priv->shortcut);
-
- priv->shortcut = g_strdup(shortcut);
-
- g_object_notify(G_OBJECT(smiley), "shortcut");
-}
-
-/*******************************************************************************
- * Object stuff
- ******************************************************************************/
-
-static void
-purple_smiley_init(PurpleSmiley *smiley) {
-}
-
-static void
-purple_smiley_finalize(GObject *obj) {
- PurpleSmiley *smiley = PURPLE_SMILEY(obj);
- PurpleSmileyPrivate *priv = purple_smiley_get_instance_private(smiley);
-
- g_free(priv->shortcut);
-
- G_OBJECT_CLASS(purple_smiley_parent_class)->finalize(obj);
-}
-
-static void
-purple_smiley_get_property(GObject *obj, guint param_id, GValue *value,
- GParamSpec *pspec)
-{
- PurpleSmiley *smiley = PURPLE_SMILEY(obj);
-
- switch (param_id) {
- case PROP_SHORTCUT:
- g_value_set_string(value, purple_smiley_get_shortcut(smiley));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
- break;
- }
-}
-
-static void
-purple_smiley_set_property(GObject *obj, guint param_id, const GValue *value,
- GParamSpec *pspec)
-{
- PurpleSmiley *smiley = PURPLE_SMILEY(obj);
-
- switch (param_id) {
- case PROP_SHORTCUT:
- _purple_smiley_set_shortcut(smiley, g_value_get_string(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
- break;
- }
-}
-
-static void
-purple_smiley_class_init(PurpleSmileyClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
- obj_class->get_property = purple_smiley_get_property;
- obj_class->set_property = purple_smiley_set_property;
- obj_class->finalize = purple_smiley_finalize;
-
- properties[PROP_SHORTCUT] = g_param_spec_string(
- "shortcut",
- "Shortcut",
- "A non-escaped textual representation of a smiley.",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS
- );
-
- g_object_class_install_properties(obj_class, PROP_LAST, properties);
-}
-
-/*******************************************************************************
- * API
- ******************************************************************************/
-PurpleSmiley *
-purple_smiley_new(const gchar *shortcut, const gchar *path)
-{
- PurpleSmiley *smiley = NULL;
- GBytes *bytes = NULL;
- gchar *contents = NULL;
- gsize length = 0;
-
- g_return_val_if_fail(shortcut != NULL, NULL);
- g_return_val_if_fail(path != NULL, NULL);
-
- if(!g_file_get_contents(path, &contents, &length, NULL)) {
- return NULL;
- }
-
- bytes = g_bytes_new_take(contents, length);
-
- smiley = g_object_new(
- PURPLE_TYPE_SMILEY,
- "path", path,
- "contents", bytes,
- "shortcut", shortcut,
- NULL
- );
-
- g_bytes_unref(bytes);
-
- return smiley;
-}
-
-PurpleSmiley *
-purple_smiley_new_from_data(const gchar *shortcut,
- const guint8 *data,
- gsize length)
-{
- PurpleSmiley *smiley = NULL;
- GBytes *bytes = NULL;
-
- g_return_val_if_fail(shortcut != NULL, NULL);
-
- bytes = g_bytes_new(data, length);
-
- smiley = g_object_new(
- PURPLE_TYPE_SMILEY,
- "shortcut", shortcut,
- "contents", bytes,
- NULL
- );
-
- g_bytes_unref(bytes);
-
- return smiley;
-
-}
-
-PurpleSmiley *
-purple_smiley_new_remote(const gchar *shortcut) {
- g_return_val_if_fail(shortcut != NULL, NULL);
-
- return g_object_new(
- PURPLE_TYPE_SMILEY,
- "shortcut", shortcut,
- NULL
- );
-}
-
-const gchar *
-purple_smiley_get_shortcut(PurpleSmiley *smiley)
-{
- PurpleSmileyPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_SMILEY(smiley), NULL);
-
- priv = purple_smiley_get_instance_private(smiley);
-
- return priv->shortcut;
-}
--- a/libpurple/smiley.h Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#endif
-
-#ifndef PURPLE_SMILEY_H
-#define PURPLE_SMILEY_H
-
-/**
- * SECTION:smiley
- * @include:smiley.h
- * @section_id: libpurple-smiley
- * @short_description: a link between emoticon image and its textual representation
- * @title: Smileys
- *
- * A #PurpleSmiley is a base class for associating emoticon images and their
- * textual representation. It's intended for various smiley-related tasks:
- * parsing the text against them, displaying in the smiley selector, or handling
- * remote data.
- *
- * The #PurpleSmiley:shortcut is always unescaped, but <link linkend="libpurple-smiley-parser">smiley parser</link>
- * may deal with special characters.
- */
-
-#include "image.h"
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/**
- * PURPLE_TYPE_SMILEY:
- *
- * The standard _get_type macro for #PurpleSmiley.
- */
-#define PURPLE_TYPE_SMILEY purple_smiley_get_type()
-
-/**
- * purple_smiley_get_type:
- *
- * Returns: the #GType for a smiley.
- */
-G_DECLARE_FINAL_TYPE(PurpleSmiley, purple_smiley, PURPLE, SMILEY, PurpleImage)
-
-/**
- * purple_smiley_new:
- * @shortcut: the smiley shortcut (unescaped).
- * @path: the smiley image file path.
- *
- * Creates new smiley, which is ready to display (its file exists
- * and is a valid image).
- *
- * Returns: the new #PurpleSmiley.
- */
-PurpleSmiley *purple_smiley_new(const gchar *shortcut, const gchar *path);
-
-/**
- * purple_smiley_new_from_data:
- * @shortcut: The smiley shortcut (unescaped).
- * @data: The raw data of the image.
- * @length: The length of @data in bytes.
- *
- * Creates new smiley from @data.
- *
- * Returns: A new #PurpleSmiley.
- */
-PurpleSmiley *purple_smiley_new_from_data(const gchar *shortcut, const guint8 *data, gsize length);
-
-/**
- * purple_smiley_new_remote:
- * @shortcut: the smiley shortcut (unescaped).
- *
- * Creates new remote smiley. It's not bound to any conversation, so most
- * probably you might want to use
- * #purple_conversation_add_remote_smiley instead.
- *
- * Returns: the new remote #PurpleSmiley.
- */
-PurpleSmiley *purple_smiley_new_remote(const gchar *shortcut);
-
-/**
- * purple_smiley_get_shortcut:
- * @smiley: the smiley.
- *
- * Returns the @smiley's associated shortcut (e.g. <literal>(homer)</literal> or
- * <literal>:-)</literal>).
- *
- * Returns: the unescaped shortcut.
- */
-const gchar *purple_smiley_get_shortcut(PurpleSmiley *smiley);
-
-G_END_DECLS
-
-#endif /* PURPLE_SMILEY_H */
--- a/libpurple/tests/meson.build Tue Aug 24 04:51:11 2021 -0500
+++ b/libpurple/tests/meson.build Tue Aug 24 04:52:14 2021 -0500
@@ -11,8 +11,6 @@
'protocol_attention',
'protocol_xfer',
'queued_output_stream',
- 'smiley',
- 'smiley_list',
'trie',
'util',
'xmlnode'
--- a/libpurple/tests/test_smiley.c Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
- * Purple
- *
- * Purple is the legal property of its developers, whose names are too
- * numerous to list here. Please refer to the COPYRIGHT file distributed
- * with this source distribution
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#include <glib.h>
-#include <string.h>
-
-#include <purple.h>
-
-// generated via:
-// $ cat test-image.png | hexdump -v -e '1 1 "0x%02x," " "' | xargs -n 8 echo
-static const gsize test_image_data_len = 160;
-static const guint8 test_image_data[] = {
- 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
- 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02,
- 0x08, 0x02, 0x00, 0x00, 0x00, 0xfd, 0xd4, 0x9a,
- 0x73, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59,
- 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b,
- 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00,
- 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45, 0x07, 0xe0,
- 0x0a, 0x02, 0x16, 0x30, 0x22, 0x28, 0xa4, 0xc9,
- 0xdd, 0x00, 0x00, 0x00, 0x1d, 0x69, 0x54, 0x58,
- 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x72, 0x65,
- 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74,
- 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x64, 0x2e,
- 0x65, 0x07, 0x00, 0x00, 0x00, 0x16, 0x49, 0x44,
- 0x41, 0x54, 0x08, 0xd7, 0x63, 0xf8, 0xff, 0xff,
- 0x3f, 0x03, 0x03, 0x03, 0xe3, 0xb3, 0x4c, 0xb5,
- 0x9b, 0x4e, 0x0b, 0x00, 0x2f, 0xa9, 0x06, 0x2f,
- 0x8a, 0xd1, 0xc6, 0xb3, 0x00, 0x00, 0x00, 0x00,
- 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
-};
-
-/******************************************************************************
- * Helpers
- *****************************************************************************/
-static void
-_test_smiley(PurpleSmiley *smiley,
- const gchar *path,
- const guint8 *edata,
- gsize elen,
- const gchar *ext,
- const gchar *mimetype,
- const gchar *shortcut)
-{
- GBytes *bytes = NULL;
- const guint8 *adata = NULL;
- gsize alen;
-
- g_assert(PURPLE_IS_SMILEY(PURPLE_IMAGE(smiley)));
-
- bytes = purple_image_get_contents(PURPLE_IMAGE(smiley));
- adata = g_bytes_get_data(bytes, &alen);
- g_assert_cmpmem(adata, alen, edata, elen);
- g_bytes_unref(bytes);
-
- g_assert_cmpstr(
- purple_image_get_extension(PURPLE_IMAGE(smiley)),
- ==,
- ext
- );
- g_assert_cmpstr(
- purple_image_get_mimetype(PURPLE_IMAGE(smiley)),
- ==,
- mimetype
- );
- g_assert_cmpstr(purple_smiley_get_shortcut(smiley), ==, shortcut);
-
- if(path)
- g_assert_cmpstr(purple_image_get_path(PURPLE_IMAGE(smiley)), ==, path);
-
- g_object_unref(G_OBJECT(smiley));
-}
-
-/******************************************************************************
- * Tests
- *****************************************************************************/
-static void
-test_smiley_new_from_data(void) {
- PurpleSmiley *smiley = purple_smiley_new_from_data(
- ":-X",
- test_image_data,
- test_image_data_len
- );
-
- _test_smiley(
- smiley,
- NULL,
- test_image_data,
- test_image_data_len,
- "png",
- "image/png",
- ":-X"
- );
-}
-
-static void
-test_smiley_new_from_file(void) {
- PurpleSmiley *smiley = NULL;
- GError *error = NULL;
- gchar *path = NULL;
- gchar *edata = NULL;
- gsize elen;
-
- path = g_build_filename(TEST_DATA_DIR, "test-image.png", NULL);
- smiley = purple_smiley_new("^_^", path);
-
- g_file_get_contents(path, &edata, &elen, &error);
- g_assert_no_error(error);
-
- _test_smiley(
- smiley,
- path,
- (guint8 *)edata,
- elen,
- "png",
- "image/png",
- "^_^"
- );
-
- g_free(path);
-}
-
-/******************************************************************************
- * Main
- *****************************************************************************/
-gint
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
-
- g_test_set_nonfatal_assertions();
-
- g_test_add_func("/smiley/new-from-data", test_smiley_new_from_data);
- g_test_add_func("/smiley/new-from-file", test_smiley_new_from_file);
-
- return g_test_run();
-}
--- a/libpurple/tests/test_smiley_list.c Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * Purple
- *
- * Purple is the legal property of its developers, whose names are too
- * numerous to list here. Please refer to the COPYRIGHT file distributed
- * with this source distribution
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#include <glib.h>
-
-#include <purple.h>
-
-/******************************************************************************
- * Test
- *****************************************************************************/
-static void
-test_smiley_list_new(void) {
- PurpleSmileyList *list = NULL;
-
- list = purple_smiley_list_new();
-
- g_assert(purple_smiley_list_is_empty(list));
- g_assert(purple_smiley_list_get_unique(list) == NULL);
- g_assert(purple_smiley_list_get_all(list) == NULL);
-
- g_object_unref(G_OBJECT(list));
-}
-
-static void
-test_smiley_list_add_remove(void) {
- PurpleSmileyList *list = NULL;
- PurpleSmiley *smiley = NULL, *smiley2 = NULL;
- PurpleTrie *trie = NULL;
- gboolean added = FALSE;
-
- list = purple_smiley_list_new();
-
- g_assert(purple_smiley_list_is_empty(list));
-
- /* create a smiley */
- smiley = purple_smiley_new_from_data("testing", NULL, 0);
-
- /* add the smiley to the list */
- added = purple_smiley_list_add(list, smiley);
- g_assert(added);
- g_assert(!purple_smiley_list_is_empty(list));
-
- /* make sure we can get it back out */
- smiley2 = purple_smiley_list_get_by_shortcut(list, "testing");
- g_assert(smiley == smiley2);
-
- /* make sure it returns a valid trie */
- trie = purple_smiley_list_get_trie(list);
- g_assert(PURPLE_IS_TRIE(trie));
- /* don't free the trie, as it's ownership is not transfered to us */
-
- /* add it again (should fail) */
- added = purple_smiley_list_add(list, smiley);
- g_assert(!added);
-
- /* now remove it and make sure the list is empty */
- purple_smiley_list_remove(list, smiley);
- g_assert(purple_smiley_list_is_empty(list));
-
- g_object_unref(G_OBJECT(smiley));
- g_object_unref(G_OBJECT(list));
-}
-
-/******************************************************************************
- * Main
- *****************************************************************************/
-gint
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
-
- g_test_set_nonfatal_assertions();
-
- g_test_add_func("/smiley_list/new", test_smiley_list_new);
- g_test_add_func("/smiley_list/add-remove", test_smiley_list_add_remove);
-
- return g_test_run();
-}
--- a/pidgin/gtkconv.c Tue Aug 24 04:51:11 2021 -0500
+++ b/pidgin/gtkconv.c Tue Aug 24 04:52:14 2021 -0500
@@ -104,7 +104,6 @@
PIDGIN_CONV_MENU = 1 << 2,
PIDGIN_CONV_TAB_ICON = 1 << 3,
PIDGIN_CONV_TOPIC = 1 << 4,
- PIDGIN_CONV_SMILEY_THEME = 1 << 5,
PIDGIN_CONV_COLORIZE_TITLE = 1 << 6,
}PidginConvFields;
@@ -4750,9 +4749,6 @@
purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE);
purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike", FALSE);
purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE);
- /* TODO: it's about *remote* smileys, not local ones */
- purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/resize_custom_smileys", TRUE);
- purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/custom_smileys_size", 96);
purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines", 2);
purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", TRUE);
--- a/pidgin/gtksmiley-manager.c Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,791 +0,0 @@
-/*
- * pidgin
- *
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#include <glib/gi18n-lib.h>
-
-#include <purple.h>
-
-#include "gtksmiley-manager.h"
-#include "gtkutils.h"
-#include "pidginstock.h"
-
-#include <libsoup/soup.h>
-
-typedef struct
-{
- PurpleSmiley *smiley;
-
- gchar *filename;
- PurpleImage *new_image;
-
- GtkDialog *window;
- GtkImage *thumbnail;
- GtkEntry *shortcut;
-} SmileyEditDialog;
-
-typedef struct
-{
- GtkDialog *window;
- GtkListStore *model;
- GtkTreeView *tree;
-
- SoupSession *session;
-} SmileyManager;
-
-enum
-{
- SMILEY_LIST_MODEL_ICON,
- SMILEY_LIST_MODEL_SHORTCUT,
- SMILEY_LIST_MODEL_PURPLESMILEY,
- SMILEY_LIST_MODEL_N_COL
-};
-
-enum
-{
- PIDGIN_RESPONSE_MODIFY
-};
-
-static SmileyManager *smiley_manager = NULL;
-
-static void
-edit_dialog_update_buttons(SmileyEditDialog *edit_dialog);
-
-static void
-manager_list_fill(SmileyManager *manager);
-
-
-/*******************************************************************************
- * Custom smiley edit dialog image.
- ******************************************************************************/
-
-static void
-edit_dialog_image_update_thumb(SmileyEditDialog *edit_dialog)
-{
- GdkPixbuf *pixbuf = NULL;
-
- if (edit_dialog->new_image) {
- pixbuf = pidgin_pixbuf_from_image(edit_dialog->new_image);
- } else if (edit_dialog->filename) {
- pixbuf = pidgin_pixbuf_new_from_file(edit_dialog->filename);
- if (!pixbuf) {
- g_free(edit_dialog->filename);
- edit_dialog->filename = NULL;
- }
- }
-
- if (pixbuf) {
- pixbuf = pidgin_pixbuf_scale_down(pixbuf, 64, 64,
- GDK_INTERP_HYPER, TRUE);
- }
-
- if (!pixbuf) {
- GtkIconSize icon_size =
- gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL);
- pixbuf = gtk_widget_render_icon(GTK_WIDGET(edit_dialog->window),
- PIDGIN_STOCK_TOOLBAR_SELECT_AVATAR, icon_size,
- "PidginSmileyManager");
- }
- g_return_if_fail(pixbuf != NULL);
-
- gtk_image_set_from_pixbuf(GTK_IMAGE(edit_dialog->thumbnail), pixbuf);
-
- g_object_unref(G_OBJECT(pixbuf));
-}
-
-static gboolean
-edit_dialog_set_image(SmileyEditDialog *edit_dialog, PurpleImage *image)
-{
- GdkPixbuf *tmp = NULL;
-
- if (edit_dialog->new_image)
- g_object_unref(edit_dialog->new_image);
-
- if (edit_dialog->smiley) {
- g_object_set_data(G_OBJECT(edit_dialog->smiley),
- "pidgin-smiley-manager-list-thumb", NULL);
- }
-
- /* check, if image is valid */
- if (image)
- tmp = pidgin_pixbuf_from_image(image);
- if (tmp)
- g_object_unref(tmp);
- else {
- g_object_unref(image);
- image = NULL;
- }
-
- edit_dialog->new_image = image;
-
- edit_dialog_image_update_thumb(edit_dialog);
- edit_dialog_update_buttons(edit_dialog);
-
- return (image != NULL);
-}
-
-static void
-edit_dialog_set_shortcut(SmileyEditDialog *edit_dialog,
- const gchar *shortcut)
-{
- gtk_entry_set_text(edit_dialog->shortcut, shortcut ? shortcut : "");
-}
-
-static void
-edit_dialog_image_choosen(const char *filename, gpointer _edit_dialog)
-{
- PurpleImage *image;
- SmileyEditDialog *edit_dialog = _edit_dialog;
-
- if (!filename)
- return;
-
- image = purple_image_new_from_file(filename, NULL);
- if (!image)
- return;
-
- g_free(edit_dialog->filename);
- edit_dialog->filename = NULL;
-
- if (!edit_dialog_set_image(edit_dialog, image))
- return;
- edit_dialog->filename = g_strdup(filename);
-
- gtk_widget_grab_focus(GTK_WIDGET(edit_dialog->shortcut));
-}
-
-static void
-edit_dialog_image_choose(GtkWidget *widget, gpointer _edit_dialog)
-{
- GtkFileChooserNative *file_chooser;
- file_chooser = pidgin_buddy_icon_chooser_new(
- GTK_WINDOW(gtk_widget_get_toplevel(widget)),
- edit_dialog_image_choosen, _edit_dialog);
- gtk_window_set_title(GTK_WINDOW(file_chooser), _("Custom Smiley"));
- gtk_window_set_role(GTK_WINDOW(file_chooser),
- "file-selector-custom-smiley");
- gtk_native_dialog_run(GTK_NATIVE_DIALOG(file_chooser));
- g_object_unref(file_chooser);
-}
-
-
-/*******************************************************************************
- * Custom smiley edit dialog.
- ******************************************************************************/
-
-static void
-edit_dialog_destroy(GtkWidget *window, gpointer _edit_dialog)
-{
- SmileyEditDialog *edit_dialog = _edit_dialog;
-
- if (edit_dialog->smiley) {
- g_object_set_data(G_OBJECT(edit_dialog->smiley),
- "pidgin-smiley-manager-edit-dialog", NULL);
- g_object_unref(edit_dialog->smiley);
- }
-
- if (edit_dialog->new_image)
- g_object_unref(edit_dialog->new_image);
-
- g_free(edit_dialog->filename);
- g_free(edit_dialog);
-}
-
-static void
-edit_dialog_save(SmileyEditDialog *edit_dialog)
-{
- const gchar *shortcut;
- PurpleSmiley *existing_smiley;
- gboolean shortcut_changed, image_changed;
-
- shortcut = gtk_entry_get_text(edit_dialog->shortcut);
-
- existing_smiley = purple_smiley_list_get_by_shortcut(
- purple_smiley_custom_get_list(), shortcut);
-
- if (existing_smiley && existing_smiley != edit_dialog->smiley) {
- gchar *msg = g_strdup_printf(
- _("A custom smiley for '%s' already exists. "
- "Please use a different shortcut."), shortcut);
- purple_notify_error(edit_dialog, _("Custom Smiley"),
- _("Duplicate Shortcut"), msg, NULL);
- g_free(msg);
- return;
- }
-
- if (edit_dialog->smiley == NULL)
- shortcut_changed = image_changed = TRUE;
- else {
- shortcut_changed = purple_strequal(purple_smiley_get_shortcut(
- edit_dialog->smiley), shortcut);
- image_changed = (edit_dialog->new_image != NULL);
- }
-
- if (!shortcut_changed && !image_changed) {
- gtk_widget_destroy(GTK_WIDGET(edit_dialog->window));
- return;
- }
-
- if (edit_dialog->new_image == NULL) {
- edit_dialog->new_image = PURPLE_IMAGE(edit_dialog->smiley);
- g_return_if_fail(edit_dialog->new_image);
- }
-
- if (edit_dialog->smiley)
- purple_smiley_custom_remove(edit_dialog->smiley);
- purple_smiley_custom_add(edit_dialog->new_image, shortcut);
-
- if (smiley_manager)
- manager_list_fill(smiley_manager);
-
- gtk_widget_destroy(GTK_WIDGET(edit_dialog->window));
-}
-
-static void
-edit_dialog_update_buttons(SmileyEditDialog *edit_dialog)
-{
- gboolean shortcut_ok, image_ok;
-
- shortcut_ok = (gtk_entry_get_text_length(edit_dialog->shortcut) > 0);
- image_ok = (edit_dialog->filename || edit_dialog->new_image);
-
- gtk_dialog_set_response_sensitive(edit_dialog->window,
- GTK_RESPONSE_ACCEPT, shortcut_ok && image_ok);
-}
-
-static void
-edit_dialog_shortcut_changed(GtkEditable *shortcut, gpointer _edit_dialog)
-{
- SmileyEditDialog *edit_dialog = _edit_dialog;
-
- edit_dialog_update_buttons(edit_dialog);
-}
-
-static void
-edit_dialog_response(GtkDialog *window, gint response_id,
- gpointer _edit_dialog)
-{
- SmileyEditDialog *edit_dialog = _edit_dialog;
-
- switch (response_id) {
- case GTK_RESPONSE_ACCEPT:
- edit_dialog_save(edit_dialog);
- break;
- case GTK_RESPONSE_DELETE_EVENT:
- case GTK_RESPONSE_CANCEL:
- gtk_widget_destroy(GTK_WIDGET(edit_dialog->window));
- break;
- default:
- g_warn_if_reached();
- }
-}
-
-static SmileyEditDialog *
-edit_dialog_show(SmileyManager *manager, PurpleSmiley *smiley)
-{
- SmileyEditDialog *edit_dialog;
- GtkWidget *vbox, *hbox;
- GtkLabel *label;
- GtkButton *filech;
-
- if (smiley) {
- edit_dialog = g_object_get_data(G_OBJECT(smiley),
- "pidgin-smiley-manager-edit-dialog");
- if (edit_dialog) {
- gtk_window_present(GTK_WINDOW(edit_dialog->window));
- return edit_dialog;
- }
- }
-
- edit_dialog = g_new0(SmileyEditDialog, 1);
-
- edit_dialog->window = GTK_DIALOG(gtk_dialog_new_with_buttons(
- smiley ? _("Edit Smiley") : _("Add Smiley"),
- manager ? GTK_WINDOW(manager->window) : NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- _("Cancel"), GTK_RESPONSE_CANCEL,
- smiley ? _("Save") : _("Add"), GTK_RESPONSE_ACCEPT,
- NULL));
- gtk_dialog_set_default_response(
- edit_dialog->window, GTK_RESPONSE_ACCEPT);
-
- if (smiley) {
- edit_dialog->smiley = smiley;
- g_object_set_data(G_OBJECT(smiley),
- "pidgin-smiley-manager-edit-dialog", edit_dialog);
- g_object_ref(smiley);
- }
-
-
- /* The vbox */
- vbox = gtk_grid_new();
- gtk_grid_set_row_spacing(GTK_GRID(vbox), 12);
- gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(
- edit_dialog->window)), vbox);
- gtk_widget_show(vbox);
-
- /* The hbox */
- hbox = gtk_grid_new();
- gtk_grid_set_column_spacing(GTK_GRID(hbox), 12);
- gtk_grid_attach(GTK_GRID(vbox), hbox, 0, 0, 1, 1);
-
- label = GTK_LABEL(gtk_label_new_with_mnemonic(_("_Image:")));
- gtk_grid_attach(GTK_GRID(hbox), GTK_WIDGET(label), 0, 0, 1, 1);
- gtk_widget_show(GTK_WIDGET(label));
-
- filech = GTK_BUTTON(gtk_button_new());
- gtk_grid_attach_next_to(GTK_GRID(hbox), GTK_WIDGET(filech), NULL,
- GTK_POS_RIGHT, 1, 1);
- pidgin_set_accessible_label(GTK_WIDGET(filech), label);
-
- edit_dialog->thumbnail = GTK_IMAGE(gtk_image_new());
- gtk_container_add(GTK_CONTAINER(filech),
- GTK_WIDGET(edit_dialog->thumbnail));
-
- gtk_widget_show_all(hbox);
-
- /* info */
- hbox = gtk_grid_new();
- gtk_grid_set_column_spacing(GTK_GRID(hbox), 12);
-
- gtk_grid_attach_next_to(GTK_GRID(vbox), hbox, NULL,
- GTK_POS_BOTTOM, 1, 1);
-
- /* Shortcut text */
- label = GTK_LABEL(gtk_label_new_with_mnemonic(_("S_hortcut text:")));
- gtk_grid_attach(GTK_GRID(hbox), GTK_WIDGET(label), 0, 0, 1, 1);
- gtk_widget_show(GTK_WIDGET(label));
-
- edit_dialog->shortcut = GTK_ENTRY(gtk_entry_new());
- gtk_entry_set_activates_default(edit_dialog->shortcut, TRUE);
- pidgin_set_accessible_label(GTK_WIDGET(edit_dialog->shortcut), label);
-
- gtk_grid_attach_next_to(GTK_GRID(hbox),
- GTK_WIDGET(edit_dialog->shortcut), NULL, GTK_POS_RIGHT, 1, 1);
-
- gtk_widget_show(GTK_WIDGET(edit_dialog->shortcut));
- gtk_widget_show(hbox);
- gtk_widget_show(GTK_WIDGET(edit_dialog->window));
-
- if (smiley) {
- edit_dialog->filename = g_strdup(purple_image_get_path(
- PURPLE_IMAGE(smiley)));
- gtk_entry_set_text(edit_dialog->shortcut,
- purple_smiley_get_shortcut(smiley));
- }
-
- edit_dialog_image_update_thumb(edit_dialog);
- edit_dialog_update_buttons(edit_dialog);
-
- g_signal_connect(edit_dialog->window, "response",
- G_CALLBACK(edit_dialog_response), edit_dialog);
- g_signal_connect(filech, "clicked",
- G_CALLBACK(edit_dialog_image_choose), edit_dialog);
- g_signal_connect(edit_dialog->shortcut, "changed",
- G_CALLBACK(edit_dialog_shortcut_changed), edit_dialog);
-
- g_signal_connect(edit_dialog->window, "destroy",
- G_CALLBACK(edit_dialog_destroy), edit_dialog);
- g_signal_connect(edit_dialog->window, "destroy",
- G_CALLBACK(purple_notify_close_with_handle), edit_dialog);
-
- return edit_dialog;
-}
-
-void
-pidgin_smiley_manager_add(PurpleImage *image, const gchar *shortcut)
-{
- SmileyEditDialog *edit_dialog;
-
- g_return_if_fail(image != NULL);
-
- g_object_ref(image);
-
- edit_dialog = edit_dialog_show(NULL, NULL);
- edit_dialog_set_shortcut(edit_dialog, shortcut);
- if (!edit_dialog_set_image(edit_dialog, image))
- gtk_widget_destroy(GTK_WIDGET(edit_dialog->window));
-}
-
-
-/*******************************************************************************
- * Custom smiley list Drag-and-drop support.
- ******************************************************************************/
-
-static void
-smiley_list_dnd_url_got(G_GNUC_UNUSED SoupSession *session, SoupMessage *msg,
- gpointer _manager)
-{
- SmileyManager *manager = _manager;
- SmileyEditDialog *edit_dialog;
- PurpleImage *image;
-
- g_return_if_fail(manager == smiley_manager);
-
- if (!SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) {
- return;
- }
-
- image = purple_image_new_from_data((const guint8 *)msg->response_body->data,
- msg->response_body->length);
- if (!image)
- return;
-
- edit_dialog = edit_dialog_show(manager, NULL);
- if (!edit_dialog_set_image(edit_dialog, image))
- gtk_widget_destroy(GTK_WIDGET(edit_dialog->window));
-}
-
-static void
-smiley_list_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y,
- GtkSelectionData *sd, guint info, guint time, gpointer _manager)
-{
- SmileyManager *manager = _manager;
- gchar content[1024];
-
- /* We don't need anything, that is not 8-bit per element (char). */
- if (gtk_selection_data_get_format(sd) != 8) {
- gtk_drag_finish(dc, FALSE, FALSE, time);
- return;
- }
-
- if (gtk_selection_data_get_length(sd) <= 0) {
- gtk_drag_finish(dc, FALSE, FALSE, time);
- return;
- }
-
- memset(&content, 0, sizeof(content));
- memcpy(&content, gtk_selection_data_get_data(sd),
- MIN((guint)gtk_selection_data_get_length(sd), sizeof(content)));
- g_strstrip(content);
- if (content[0] == '\0') {
- gtk_drag_finish(dc, FALSE, FALSE, time);
- return;
- }
-
- /* Well, it looks like the drag event was cool.
- * Let's do something with it */
-
- if (purple_str_has_caseprefix(content, "file://")) {
- SmileyEditDialog *edit_dialog;
- PurpleImage *image;
- gchar *filename;
-
- filename = g_filename_from_uri(content, NULL, NULL);
- if (!filename || !g_file_test(filename, G_FILE_TEST_EXISTS)) {
- purple_debug_warning("gtksmiley-manager",
- "dropped file does not exists");
- gtk_drag_finish(dc, FALSE, FALSE, time);
- g_free(filename);
- return;
- }
-
- image = purple_image_new_from_file(filename, NULL);
- g_free(filename);
- if (!image) {
- purple_debug_warning("gtksmiley-manager",
- "dropped file is not a valid image");
- gtk_drag_finish(dc, FALSE, FALSE, time);
- return;
- }
- edit_dialog = edit_dialog_show(manager, NULL);
- if (!edit_dialog_set_image(edit_dialog, image)) {
- gtk_widget_destroy(GTK_WIDGET(edit_dialog->window));
- gtk_drag_finish(dc, FALSE, FALSE, time);
- return;
- }
-
- gtk_drag_finish(dc, TRUE, FALSE, time);
- return;
- }
-
- if (purple_str_has_caseprefix(content, "http://") ||
- purple_str_has_caseprefix(content, "https://"))
- {
- SoupMessage *msg;
-
- if (smiley_manager->session == NULL) {
- smiley_manager->session = soup_session_new();
- }
-
- soup_session_abort(smiley_manager->session);
- msg = soup_message_new("GET", content);
- soup_session_queue_message(smiley_manager->session, msg,
- smiley_list_dnd_url_got, manager);
-
- gtk_drag_finish(dc, TRUE, FALSE, time);
- return;
- }
-
- gtk_drag_finish(dc, FALSE, FALSE, time);
-}
-
-/*******************************************************************************
- * Custom smiley list.
- ******************************************************************************/
-
-static void
-smiley_list_selected(GtkTreeSelection *sel, gpointer _manager)
-{
- SmileyManager *manager = _manager;
- gboolean sens;
-
- sens = (gtk_tree_selection_count_selected_rows(sel) > 0);
-
- gtk_dialog_set_response_sensitive(manager->window,
- GTK_RESPONSE_NO, sens);
- gtk_dialog_set_response_sensitive(manager->window,
- PIDGIN_RESPONSE_MODIFY, sens);
-}
-
-static void
-smiley_list_activated(GtkTreeView *tree, GtkTreePath *path,
- GtkTreeViewColumn *col, gpointer _manager)
-{
- SmileyManager *manager = _manager;
- GtkTreeIter iter;
- PurpleSmiley *smiley = NULL;
-
- if (!gtk_tree_model_get_iter(
- GTK_TREE_MODEL(manager->model), &iter, path))
- {
- return;
- }
-
- gtk_tree_model_get(GTK_TREE_MODEL(manager->model), &iter,
- SMILEY_LIST_MODEL_PURPLESMILEY, &smiley, -1);
- g_return_if_fail(PURPLE_IS_SMILEY(smiley));
-
- edit_dialog_show(manager, smiley);
-}
-
-static void
-manager_list_add(SmileyManager *manager, PurpleSmiley *smiley)
-{
- GdkPixbuf *smiley_image;
- GtkTreeIter iter;
-
- smiley_image = g_object_get_data(G_OBJECT(smiley),
- "pidgin-smiley-manager-list-thumb");
- if (smiley_image == NULL) {
- smiley_image = pidgin_pixbuf_from_image(PURPLE_IMAGE(smiley));
- smiley_image = pidgin_pixbuf_scale_down(smiley_image,
- 22, 22, GDK_INTERP_BILINEAR, TRUE);
- g_object_set_data_full(G_OBJECT(smiley),
- "pidgin-smiley-manager-list-thumb",
- smiley_image, g_object_unref);
- }
-
- gtk_list_store_append(manager->model, &iter);
- gtk_list_store_set(manager->model, &iter,
- SMILEY_LIST_MODEL_ICON, smiley_image,
- SMILEY_LIST_MODEL_SHORTCUT, purple_smiley_get_shortcut(smiley),
- SMILEY_LIST_MODEL_PURPLESMILEY, smiley,
- -1);
-}
-
-static void
-manager_list_fill(SmileyManager *manager)
-{
- GList *custom_smileys, *it;
- gtk_list_store_clear(manager->model);
-
- custom_smileys = purple_smiley_list_get_all(
- purple_smiley_custom_get_list());
-
- for (it = custom_smileys; it; it = g_list_next(it)) {
- PurpleSmiley *smiley = it->data;
-
- manager_list_add(manager, smiley);
- }
- g_list_free(custom_smileys);
-}
-
-static GtkWidget *
-manager_list_create(SmileyManager *manager)
-{
- GtkTreeView *tree;
- GtkTreeSelection *sel;
- GtkCellRenderer *cellrend;
- GtkTreeViewColumn *column;
- GtkTargetEntry targets[3] = {
- {"text/plain", 0, 0},
- {"text/uri-list", 0, 1},
- {"STRING", 0, 2}
- };
-
- manager->model = gtk_list_store_new(SMILEY_LIST_MODEL_N_COL,
- GDK_TYPE_PIXBUF, /* icon */
- G_TYPE_STRING, /* shortcut */
- G_TYPE_OBJECT /* PurpleSmiley */
- );
-
- manager->tree = tree = GTK_TREE_VIEW(gtk_tree_view_new_with_model(
- GTK_TREE_MODEL(manager->model)));
-
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(manager->model),
- SMILEY_LIST_MODEL_SHORTCUT, GTK_SORT_ASCENDING);
-
- g_object_unref(manager->model);
-
- sel = gtk_tree_view_get_selection(tree);
- gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
-
- g_signal_connect(sel, "changed",
- G_CALLBACK(smiley_list_selected), manager);
- g_signal_connect(tree, "row-activated",
- G_CALLBACK(smiley_list_activated), manager);
-
- gtk_drag_dest_set(GTK_WIDGET(tree), GTK_DEST_DEFAULT_MOTION |
- GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
- targets, G_N_ELEMENTS(targets),
- GDK_ACTION_COPY | GDK_ACTION_MOVE);
- g_signal_connect(tree, "drag-data-received",
- G_CALLBACK(smiley_list_dnd_recv), manager);
-
- gtk_widget_show(GTK_WIDGET(tree));
-
- /* setting up columns */
-
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _("Smiley"));
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_append_column(tree, column);
- cellrend = gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_column_pack_start(column, cellrend, FALSE);
- gtk_tree_view_column_add_attribute(column, cellrend,
- "pixbuf", SMILEY_LIST_MODEL_ICON);
-
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _("Shortcut Text"));
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_append_column(tree, column);
- cellrend = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, cellrend, TRUE);
- gtk_tree_view_column_add_attribute(column, cellrend,
- "text", SMILEY_LIST_MODEL_SHORTCUT);
-
- manager_list_fill(manager);
-
- return pidgin_make_scrollable(GTK_WIDGET(tree), GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, -1);
-}
-
-/*******************************************************************************
- * Custom smiley manager window.
- ******************************************************************************/
-
-static void
-manager_select_cb(GtkWidget *widget, gint resp, SmileyManager *manager)
-{
- GtkTreeSelection *selection = NULL;
- GList *selected_rows, *selected_smileys = NULL, *it;
- GtkTreeModel *model = GTK_TREE_MODEL(manager->model);
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(manager->tree));
- selected_rows = gtk_tree_selection_get_selected_rows(selection, NULL);
- for (it = selected_rows; it; it = g_list_next(it)) {
- GtkTreePath *path = it->data;
- GtkTreeIter iter;
- PurpleSmiley *smiley = NULL;
-
- if (!gtk_tree_model_get_iter(model, &iter, path))
- continue;
-
- gtk_tree_model_get(model, &iter,
- SMILEY_LIST_MODEL_PURPLESMILEY, &smiley, -1);
- if (!smiley)
- continue;
-
- selected_smileys = g_list_prepend(selected_smileys, smiley);
- }
- g_list_free_full(selected_rows, (GDestroyNotify)gtk_tree_path_free);
-
- switch (resp) {
- case GTK_RESPONSE_YES:
- edit_dialog_show(manager, NULL);
- break;
- case GTK_RESPONSE_NO:
- for (it = selected_smileys; it; it = g_list_next(it))
- purple_smiley_custom_remove(it->data);
- manager_list_fill(manager);
- break;
- case GTK_RESPONSE_DELETE_EVENT:
- case GTK_RESPONSE_CLOSE:
- gtk_widget_destroy(GTK_WIDGET(manager->window));
- soup_session_abort(manager->session);
- g_clear_object(&manager->session);
- g_free(manager);
- smiley_manager = NULL;
- break;
- case PIDGIN_RESPONSE_MODIFY:
- for (it = selected_smileys; it; it = g_list_next(it))
- edit_dialog_show(manager, it->data);
- break;
- default:
- g_warn_if_reached();
- }
-
- g_list_free(selected_smileys);
-}
-
-void
-pidgin_smiley_manager_show(void)
-{
- SmileyManager *manager;
- GtkDialog *win;
- GtkWidget *sw, *vbox;
-
- if (smiley_manager) {
- gtk_window_present(GTK_WINDOW(smiley_manager->window));
- return;
- }
-
- manager = g_new0(SmileyManager, 1);
- smiley_manager = manager;
-
- manager->window = win = GTK_DIALOG(gtk_dialog_new_with_buttons(
- _("Custom Smiley Manager"), NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- PIDGIN_STOCK_ADD, GTK_RESPONSE_YES,
- PIDGIN_STOCK_MODIFY, PIDGIN_RESPONSE_MODIFY,
- _("Delete"), GTK_RESPONSE_NO,
- _("Close"), GTK_RESPONSE_CLOSE,
- NULL));
-
- gtk_window_set_default_size(GTK_WINDOW(win), 50, 400);
- gtk_window_set_role(GTK_WINDOW(win), "custom_smiley_manager");
- gtk_dialog_set_response_sensitive(win, GTK_RESPONSE_NO, FALSE);
- gtk_dialog_set_response_sensitive(win, PIDGIN_RESPONSE_MODIFY, FALSE);
-
- g_signal_connect(win, "response",
- G_CALLBACK(manager_select_cb), manager);
-
- /* The vbox */
- vbox = gtk_dialog_get_content_area(win);
-
- /* get the scrolled window with all stuff */
- sw = manager_list_create(manager);
- gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
- gtk_widget_show(sw);
-
- gtk_widget_show(GTK_WIDGET(win));
-}
--- a/pidgin/gtksmiley-manager.h Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/* pidgin
- *
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
-# error "only <pidgin.h> may be included directly"
-#endif
-
-#ifndef _PIDGIN_SMILEY_MANAGER_H_
-#define _PIDGIN_SMILEY_MANAGER_H_
-/**
- * SECTION:gtksmiley-manager
- * @include:gtksmiley-manager.h
- * @section_id: pidgin-smiley-manager
- * @short_description: a UI for user-defined smileys management
- * @title: Custom smileys manager
- *
- * This module provides a GTK+ UI that allows the user adding and removing
- * custom smileys. See libpurple-smiley-custom section (TODO: how to link this
- * to libpurple's docs?).
- */
-
-G_BEGIN_DECLS
-
-/**
- * pidgin_smiley_manager_show:
- *
- * Creates and shows the smiley manager window, or requests focus for it,
- * if it's already opened.
- */
-void
-pidgin_smiley_manager_show(void);
-
-/**
- * pidgin_smiley_manager_add:
- * @image: the image for a new smiley.
- * @shortcut: the textual representation, may be %NULL.
- *
- * Creates and shows the new dialog for adding a new custom smiley with
- * provided image.
- */
-void
-pidgin_smiley_manager_add(PurpleImage *image, const gchar *shortcut);
-
-G_END_DECLS
-
-#endif /* _PIDGIN_SMILEY_MANAGER_H_ */
--- a/pidgin/gtksmiley-theme.c Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,631 +0,0 @@
-/* pidgin
- *
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib/gstdio.h>
-
-#include <purple.h>
-
-#include "gtksmiley-theme.h"
-
-#include "gtkutils.h"
-#include "pidgincore.h"
-
-#define PIDGIN_SMILEY_THEME_MAX_LINES 1024
-#define PIDGIN_SMILEY_THEME_MAX_TOKENS 1024
-
-/**
- * PidginSmileyTheme:
- *
- * An implementation of a smiley theme.
- */
-struct _PidginSmileyTheme
-{
- PurpleSmileyTheme parent;
-};
-
-typedef struct
-{
- gchar *path;
-
- gchar *name;
- gchar *desc;
- gchar *icon;
- gchar *author;
-
- GdkPixbuf *icon_pixbuf;
-
- GHashTable *smiley_lists_map;
-} PidginSmileyThemePrivate;
-
-static gchar **probe_dirs;
-static GList *smiley_themes = NULL;
-
-typedef struct
-{
- gchar *name;
- gchar *desc;
- gchar *icon;
- gchar *author;
-
- GList *protocols;
-} PidginSmileyThemeIndex;
-
-typedef struct
-{
- gchar *name;
- GList *smileys;
-} PidginSmileyThemeIndexProtocol;
-
-typedef struct
-{
- gchar *file;
- gboolean hidden;
- GList *shortcuts;
-} PidginSmileyThemeIndexSmiley;
-
-G_DEFINE_TYPE_WITH_PRIVATE(PidginSmileyTheme, pidgin_smiley_theme,
- PURPLE_TYPE_SMILEY_THEME);
-
-/*******************************************************************************
- * Theme index parsing
- ******************************************************************************/
-
-static void
-pidgin_smiley_theme_index_smiley_free(PidginSmileyThemeIndexSmiley *smiley)
-{
- g_return_if_fail(smiley != NULL);
-
- g_free(smiley->file);
- g_list_free_full(smiley->shortcuts, g_free);
- g_free(smiley);
-}
-
-static void
-pidgin_smiley_theme_index_protocol_free(PidginSmileyThemeIndexProtocol *proto)
-{
- g_return_if_fail(proto != NULL);
-
- g_free(proto->name);
- g_list_free_full(proto->smileys, (GDestroyNotify)pidgin_smiley_theme_index_smiley_free);
- g_free(proto);
-}
-
-static void
-pidgin_smiley_theme_index_free(PidginSmileyThemeIndex *index)
-{
- g_return_if_fail(index != NULL);
-
- g_free(index->name);
- g_free(index->desc);
- g_free(index->icon);
- g_free(index->author);
- g_list_free_full(index->protocols, (GDestroyNotify)pidgin_smiley_theme_index_protocol_free);
- g_free(index);
-}
-
-static PidginSmileyThemeIndex *
-pidgin_smiley_theme_index_parse(const gchar *theme_path, gboolean load_contents)
-{
- PidginSmileyThemeIndex *index;
- PidginSmileyThemeIndexProtocol *proto = NULL;
- gchar *index_path;
- FILE *file;
- int line_no = 0;
- gboolean inv_frm = FALSE;
-
- index_path = g_build_filename(theme_path, "theme", NULL);
- file = g_fopen(index_path, "r");
- if (!file) {
- purple_debug_error("gtksmiley-theme",
- "Failed to open index file %s", index_path);
- g_free(index_path);
- return NULL;
- }
-
- index = g_new0(PidginSmileyThemeIndex, 1);
-
- while (!feof(file)) {
- PidginSmileyThemeIndexSmiley *smiley;
- gchar buff[1024];
- gchar *line, *eqchr;
- gchar **split;
- int i;
-
- if (++line_no > PIDGIN_SMILEY_THEME_MAX_LINES) {
- purple_debug_warning("gtksmiley-theme", "file too big");
- break;
- }
-
- if (!fgets(buff, sizeof(buff), file))
- break;
-
- /* strip comments */
- if (buff[0] == '#')
- continue;
-
- g_strstrip(buff);
- if (buff[0] == '\0')
- continue;
-
- if (!g_utf8_validate(buff, -1, NULL)) {
- purple_debug_error("gtksmiley-theme",
- "%s:%d is invalid UTF-8",
- index_path, line_no);
- continue;
- }
-
- line = buff;
-
- if (line[0] == '[') {
- gchar *end;
-
- if (!load_contents)
- break;
- line++;
- end = strchr(line, ']');
- if (!end) {
- inv_frm = TRUE;
- break;
- }
-
- if (proto)
- proto->smileys = g_list_reverse(proto->smileys);
-
- proto = g_new0(PidginSmileyThemeIndexProtocol, 1);
- proto->name = g_strndup(line, end - line);
-
- index->protocols =
- g_list_prepend(index->protocols, proto);
-
- continue;
- }
-
- if ((eqchr = strchr(line, '='))) {
- *eqchr = '\0';
- if (g_ascii_strcasecmp(line, "name") == 0) {
- g_free(index->name);
- index->name = g_strdup(eqchr + 1);
- g_strchug(index->name);
- continue;
- } else if (g_ascii_strcasecmp(line, "description") == 0) {
- g_free(index->desc);
- index->desc = g_strdup(eqchr + 1);
- g_strchug(index->desc);
- continue;
- } else if (g_ascii_strcasecmp(line, "icon") == 0) {
- g_free(index->icon);
- index->icon = g_strdup(eqchr + 1);
- g_strchug(index->icon);
- continue;
- } else if (g_ascii_strcasecmp(line, "author") == 0) {
- g_free(index->author);
- index->author = g_strdup(eqchr + 1);
- g_strchug(index->author);
- continue;
- }
- *eqchr = '=';
- }
-
- /* parsing section content */
-
- if (proto == NULL) {
- inv_frm = FALSE;
- break;
- }
-
- smiley = g_new0(PidginSmileyThemeIndexSmiley, 1);
- proto->smileys = g_list_prepend(proto->smileys, smiley);
-
- smiley->hidden = FALSE;
- if (line[0] == '!') {
- smiley->hidden = TRUE;
- line++;
- }
-
- split = g_strsplit_set(line, " \t",
- PIDGIN_SMILEY_THEME_MAX_TOKENS);
- for (i = 0; split[i]; i++) {
- gchar *token = split[i];
-
- if (token[0] == '\0')
- continue;
- if (i == PIDGIN_SMILEY_THEME_MAX_TOKENS - 1)
- break;
-
- if (!smiley->file) {
- smiley->file = g_strdup(token);
- continue;
- }
-
- smiley->shortcuts = g_list_prepend(smiley->shortcuts,
- g_strdup(token));
- }
- g_strfreev(split);
- smiley->shortcuts = g_list_reverse(smiley->shortcuts);
- }
-
- if (proto)
- proto->smileys = g_list_reverse(proto->smileys);
-
- fclose(file);
-
- if (inv_frm) {
- purple_debug_error("gtksmiley-theme", "%s:%d"
- " invalid format", index_path, line_no);
- pidgin_smiley_theme_index_free(index);
- index = NULL;
- }
-
- g_free(index_path);
- return index;
-}
-
-/*******************************************************************************
- * Theme loading
- ******************************************************************************/
-
-static void
-pidgin_smiley_theme_load(const gchar *theme_path)
-{
- PidginSmileyTheme *theme;
- PidginSmileyThemePrivate *priv;
- PidginSmileyThemeIndex *index;
- GList *it;
-
- /* it's not super-efficient, but we don't expect huge amount of
- * installed themes */
- for (it = smiley_themes; it; it = g_list_next(it)) {
- PidginSmileyThemePrivate *priv =
- pidgin_smiley_theme_get_instance_private(it->data);
-
- /* theme is already loaded */
- if (g_strcmp0(priv->path, theme_path) == 0)
- return;
- }
-
- theme = g_object_new(PIDGIN_TYPE_SMILEY_THEME, NULL);
- priv = pidgin_smiley_theme_get_instance_private(theme);
-
- priv->path = g_strdup(theme_path);
-
- index = pidgin_smiley_theme_index_parse(theme_path, FALSE);
-
- if (!index->name || index->name[0] == '\0') {
- purple_debug_warning("gtksmiley-theme",
- "incomplete theme %s", theme_path);
- pidgin_smiley_theme_index_free(index);
- g_object_unref(theme);
- return;
- }
-
- priv->name = g_strdup(index->name);
- if (index->desc && index->desc[0])
- priv->desc = g_strdup(index->desc);
- if (index->icon && index->icon[0])
- priv->icon = g_strdup(index->icon);
- if (index->author && index->author[0])
- priv->author = g_strdup(index->author);
-
- pidgin_smiley_theme_index_free(index);
-
- smiley_themes = g_list_append(smiley_themes, theme);
-}
-
-static void
-pidgin_smiley_theme_probe(void)
-{
- GList *it, *next;
- int i;
-
- /* remove non-existing themes */
- for (it = smiley_themes; it; it = next) {
- PidginSmileyTheme *theme = it->data;
- PidginSmileyThemePrivate *priv =
- pidgin_smiley_theme_get_instance_private(theme);
-
- next = g_list_next(it);
-
- if (g_file_test(priv->path, G_FILE_TEST_EXISTS))
- continue;
- smiley_themes = g_list_delete_link(smiley_themes, it);
- g_object_unref(theme);
- }
-
- /* scan for themes */
- for (i = 0; probe_dirs[i]; i++) {
- GDir *dir = g_dir_open(probe_dirs[i], 0, NULL);
- const gchar *theme_dir_name;
-
- if (!dir)
- continue;
-
- while ((theme_dir_name = g_dir_read_name(dir))) {
- gchar *theme_path;
-
- /* Ignore Pidgin 2.x.y "none" theme. */
- if (g_strcmp0(theme_dir_name, "none") == 0)
- continue;
-
- theme_path = g_build_filename(
- probe_dirs[i], theme_dir_name, NULL);
-
- if (g_file_test(theme_path, G_FILE_TEST_IS_DIR))
- pidgin_smiley_theme_load(theme_path);
-
- g_free(theme_path);
- }
-
- g_dir_close(dir);
- }
-}
-
-
-/*******************************************************************************
- * API implementation
- ******************************************************************************/
-
-const gchar *
-pidgin_smiley_theme_get_name(PidginSmileyTheme *theme)
-{
- PidginSmileyThemePrivate *priv = NULL;
-
- g_return_val_if_fail(PIDGIN_IS_SMILEY_THEME(theme), NULL);
-
- priv = pidgin_smiley_theme_get_instance_private(theme);
- return priv->name;
-}
-
-const gchar *
-pidgin_smiley_theme_get_description(PidginSmileyTheme *theme)
-{
- PidginSmileyThemePrivate *priv = NULL;
-
- g_return_val_if_fail(PIDGIN_IS_SMILEY_THEME(theme), NULL);
-
- priv = pidgin_smiley_theme_get_instance_private(theme);
- return priv->desc;
-}
-
-GdkPixbuf *
-pidgin_smiley_theme_get_icon(PidginSmileyTheme *theme)
-{
- PidginSmileyThemePrivate *priv = NULL;
-
- g_return_val_if_fail(PIDGIN_IS_SMILEY_THEME(theme), NULL);
- priv = pidgin_smiley_theme_get_instance_private(theme);
-
- if (priv->icon == NULL)
- return NULL;
-
- if (!priv->icon_pixbuf) {
- gchar *icon_path = g_build_filename(
- priv->path, priv->icon, NULL);
- priv->icon_pixbuf = pidgin_pixbuf_new_from_file(icon_path);
- g_free(icon_path);
- }
-
- return priv->icon_pixbuf;
-}
-
-const gchar *
-pidgin_smiley_theme_get_author(PidginSmileyTheme *theme)
-{
- PidginSmileyThemePrivate *priv = NULL;
-
- g_return_val_if_fail(PIDGIN_IS_SMILEY_THEME(theme), NULL);
-
- priv = pidgin_smiley_theme_get_instance_private(theme);
- return priv->author;
-}
-
-PurpleSmileyList *
-pidgin_smiley_theme_for_conv(PurpleConversation *conv)
-{
- PurpleAccount *acc = NULL;
- PurpleSmileyTheme *theme;
- const gchar *proto_name = NULL;
-
- theme = purple_smiley_theme_get_current();
- if (theme == NULL)
- return NULL;
-
- if (conv)
- acc = purple_conversation_get_account(conv);
- if (acc)
- proto_name = purple_account_get_protocol_name(acc);
-
- return purple_smiley_theme_get_smileys(theme, (gpointer)proto_name);
-}
-
-static void
-pidgin_smiley_theme_activate_impl(PurpleSmileyTheme *theme)
-{
- PidginSmileyThemePrivate *priv =
- pidgin_smiley_theme_get_instance_private(
- PIDGIN_SMILEY_THEME(theme));
- PidginSmileyThemeIndex *index;
- GHashTable *smap;
- GList *it, *it2, *it3;
-
- if (priv->smiley_lists_map)
- return;
-
- priv->smiley_lists_map = smap = g_hash_table_new_full(
- g_str_hash, g_str_equal, g_free, g_object_unref);
-
- index = pidgin_smiley_theme_index_parse(priv->path, TRUE);
-
- for (it = index->protocols; it; it = g_list_next(it)) {
- PidginSmileyThemeIndexProtocol *proto_idx = it->data;
- PurpleSmileyList *proto_smileys;
-
- proto_smileys = g_hash_table_lookup(smap, proto_idx->name);
- if (!proto_smileys) {
- proto_smileys = purple_smiley_list_new();
- g_hash_table_insert(smap,
- g_strdup(proto_idx->name), proto_smileys);
- }
-
- for (it2 = proto_idx->smileys; it2; it2 = g_list_next(it2)) {
- PidginSmileyThemeIndexSmiley *smiley_idx = it2->data;
- gchar *smiley_path;
-
- smiley_path = g_build_filename(
- priv->path, smiley_idx->file, NULL);
- if (!g_file_test(smiley_path, G_FILE_TEST_EXISTS)) {
- purple_debug_warning("gtksmiley-theme",
- "Smiley %s is missing", smiley_path);
- g_free(smiley_path);
- continue;
- }
-
- for (it3 = smiley_idx->shortcuts; it3;
- it3 = g_list_next(it3))
- {
- PurpleSmiley *smiley;
- gchar *shortcut = it3->data;
-
- smiley = purple_smiley_new(
- shortcut, smiley_path);
- g_object_set_data(G_OBJECT(smiley),
- "pidgin-smiley-hidden",
- GINT_TO_POINTER(smiley_idx->hidden));
- purple_smiley_list_add(proto_smileys, smiley);
- g_object_unref(smiley);
- }
-
- g_free(smiley_path);
- }
- }
-
- pidgin_smiley_theme_index_free(index);
-}
-
-static PurpleSmileyList *
-pidgin_smiley_theme_get_smileys_impl(PurpleSmileyTheme *theme, gpointer ui_data)
-{
- PidginSmileyThemePrivate *priv =
- pidgin_smiley_theme_get_instance_private(
- PIDGIN_SMILEY_THEME(theme));
- PurpleSmileyList *smileys = NULL;
-
- pidgin_smiley_theme_activate_impl(theme);
-
- if (ui_data)
- smileys = g_hash_table_lookup(priv->smiley_lists_map, ui_data);
- if (smileys != NULL)
- return smileys;
-
- return g_hash_table_lookup(priv->smiley_lists_map, "default");
-}
-
-GList *
-pidgin_smiley_theme_get_all(void)
-{
- pidgin_smiley_theme_probe();
-
- return smiley_themes;
-}
-
-void
-_pidgin_smiley_theme_init(void)
-{
- GList *it;
- const gchar *user_smileys_dir;
- const gchar *theme_name;
-
- probe_dirs = g_new0(gchar*, 3);
- probe_dirs[0] = g_build_filename(
- PURPLE_DATADIR, "pixmaps", "pidgin", "emotes", NULL);
- user_smileys_dir = probe_dirs[1] =
- g_build_filename(purple_data_dir(), "smileys", NULL);
-
- if (!g_file_test(user_smileys_dir, G_FILE_TEST_IS_DIR)) {
- if (g_mkdir(user_smileys_dir, S_IRUSR | S_IWUSR | S_IXUSR) == 0) {
- purple_debug_error("gtksmiley-theme",
- "Failed to create user smileys dir");
- }
- }
-
- /* setting theme by name (copy-paste from gtkprefs) */
- pidgin_smiley_theme_probe();
- theme_name = purple_prefs_get_string(
- PIDGIN_PREFS_ROOT "/smileys/theme");
- for (it = smiley_themes; it; it = g_list_next(it)) {
- PidginSmileyTheme *theme = it->data;
-
- if (g_strcmp0(pidgin_smiley_theme_get_name(theme), theme_name))
- continue;
-
- purple_smiley_theme_set_current(PURPLE_SMILEY_THEME(theme));
- }
-}
-
-void
-_pidgin_smiley_theme_uninit(void)
-{
- g_strfreev(probe_dirs);
-}
-
-/*******************************************************************************
- * Object stuff
- ******************************************************************************/
-
-static void
-pidgin_smiley_theme_finalize(GObject *obj)
-{
- PidginSmileyThemePrivate *priv =
- pidgin_smiley_theme_get_instance_private(
- PIDGIN_SMILEY_THEME(obj));
-
- g_free(priv->path);
- g_free(priv->name);
- g_free(priv->desc);
- g_free(priv->icon);
- g_free(priv->author);
- if (priv->icon_pixbuf)
- g_object_unref(priv->icon_pixbuf);
- if (priv->smiley_lists_map)
- g_hash_table_destroy(priv->smiley_lists_map);
-
- G_OBJECT_CLASS(pidgin_smiley_theme_parent_class)->finalize(obj);
-}
-
-static void
-pidgin_smiley_theme_class_init(PidginSmileyThemeClass *klass)
-{
- GObjectClass *gobj_class = G_OBJECT_CLASS(klass);
- PurpleSmileyThemeClass *pst_class = PURPLE_SMILEY_THEME_CLASS(klass);
-
- gobj_class->finalize = pidgin_smiley_theme_finalize;
-
- pst_class->get_smileys = pidgin_smiley_theme_get_smileys_impl;
- pst_class->activate = pidgin_smiley_theme_activate_impl;
-}
-
-static void
-pidgin_smiley_theme_init(PidginSmileyTheme *theme)
-{
-}
--- a/pidgin/gtksmiley-theme.h Tue Aug 24 04:51:11 2021 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/* pidgin
- *
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
-# error "only <pidgin.h> may be included directly"
-#endif
-
-#ifndef _PIDGIN_SMILEY_THEME_H_
-#define _PIDGIN_SMILEY_THEME_H_
-/**
- * SECTION:gtksmiley-theme
- * @include:gtksmiley-theme.h
- * @section_id: pidgin-smiley-theme
- * @short_description: a per-protocol categorized sets of standard smileys
- * @title: Pidgin's smiley themes
- *
- * This class implements a per-protocol based #PurpleSmileyTheme.
- */
-
-#include <glib-object.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-#include <purple.h>
-
-G_BEGIN_DECLS
-
-#define PIDGIN_TYPE_SMILEY_THEME pidgin_smiley_theme_get_type()
-
-/**
- * pidgin_smiley_theme_get_type:
- *
- * Returns: the #GType for a smiley list.
- */
-G_DECLARE_FINAL_TYPE(PidginSmileyTheme, pidgin_smiley_theme, PIDGIN,
- SMILEY_THEME, PurpleSmileyTheme)
-
-/**
- * pidgin_smiley_theme_get_name:
- * @theme: the smiley theme.
- *
- * Returns the name for a @theme. Valid themes always have the name set.
- *
- * Returns: (transfer none): the name string, or %NULL if error occured.
- */
-const gchar *
-pidgin_smiley_theme_get_name(PidginSmileyTheme *theme);
-
-/**
- * pidgin_smiley_theme_get_description:
- * @theme: the smiley theme.
- *
- * Returns the description for a @theme.
- *
- * Returns: (transfer none): the description string, or %NULL if it's not
- * set or error occured.
- */
-const gchar *
-pidgin_smiley_theme_get_description(PidginSmileyTheme *theme);
-
-/**
- * pidgin_smiley_theme_get_icon:
- * @theme: the smiley theme.
- *
- * Returns the @theme's icon image, possibly loading it from the disk (and
- * adding it to the cache).
- *
- * Returns: (transfer none): the @theme's icon image.
- */
-GdkPixbuf *
-pidgin_smiley_theme_get_icon(PidginSmileyTheme *theme);
-
-/**
- * pidgin_smiley_theme_get_author:
- * @theme: the smiley theme.
- *
- * Returns the autor of @theme.
- *
- * Returns: (transfer none): the author string, or %NULL if it's not
- * set or error occured.
- */
-const gchar *
-pidgin_smiley_theme_get_author(PidginSmileyTheme *theme);
-
-/**
- * pidgin_smiley_theme_for_conv:
- * @conv: the conversation.
- *
- * Gets the smiley list for a @conv based on current theme.
- *
- * Returns: (transfer none): the smiley list, or %NULL if there
- * is no smiley theme set.
- */
-PurpleSmileyList *
-pidgin_smiley_theme_for_conv(PurpleConversation *conv);
-
-/**
- * pidgin_smiley_theme_get_all:
- *
- * Returns the list of currently available smiley themes.
- *
- * Returns: (transfer none) (element-type PidginSmileyTheme): the #GList of #PidginSmileyTheme's.
- */
-GList *
-pidgin_smiley_theme_get_all(void);
-
-/**
- * _pidgin_smiley_theme_init: (skip)
- *
- * Initializes the Pidgin's smiley theme subsystem.
- */
-void
-_pidgin_smiley_theme_init(void);
-
-/**
- * _pidgin_smiley_theme_uninit: (skip)
- *
- * Unitializes the Pidgin's smiley theme subsystem.
- */
-void
-_pidgin_smiley_theme_uninit(void);
-
-G_END_DECLS
-
-#endif /* _PIDGIN_SMILEY_THEME_H_ */
--- a/pidgin/libpidgin.c Tue Aug 24 04:51:11 2021 -0500
+++ b/pidgin/libpidgin.c Tue Aug 24 04:52:14 2021 -0500
@@ -45,7 +45,6 @@
#include "gtkrequest.h"
#include "gtkroomlist.h"
#include "gtksavedstatuses.h"
-#include "gtksmiley-theme.h"
#include "gtkutils.h"
#include "gtkwhiteboard.h"
#include "pidginapplication.h"
@@ -197,7 +196,6 @@
pidgin_xfers_init();
pidgin_roomlist_init();
pidgin_log_init();
- _pidgin_smiley_theme_init();
pidgin_medias_init();
pidgin_notify_init();
}
@@ -209,7 +207,6 @@
PurpleDebugUi *ui;
pidgin_notify_uninit();
- _pidgin_smiley_theme_uninit();
pidgin_commands_uninit();
pidgin_conversations_uninit();
pidgin_status_uninit();
--- a/pidgin/meson.build Tue Aug 24 04:51:11 2021 -0500
+++ b/pidgin/meson.build Tue Aug 24 04:52:14 2021 -0500
@@ -16,8 +16,6 @@
'gtkrequest.c',
'gtkroomlist.c',
'gtksavedstatuses.c',
- 'gtksmiley-manager.c',
- 'gtksmiley-theme.c',
'gtkstatus-icon-theme.c',
'gtkstatusbox.c',
'gtkutils.c',
@@ -85,8 +83,6 @@
'gtkrequest.h',
'gtkroomlist.h',
'gtksavedstatuses.h',
- 'gtksmiley-manager.h',
- 'gtksmiley-theme.h',
'gtkstatus-icon-theme.h',
'gtkstatusbox.h',
'pidginstock.h',
--- a/pidgin/pidginapplication.c Tue Aug 24 04:51:11 2021 -0500
+++ b/pidgin/pidginapplication.c Tue Aug 24 04:52:14 2021 -0500
@@ -40,7 +40,6 @@
#include "gtkdialogs.h"
#include "gtkprivacy.h"
#include "gtkroomlist.h"
-#include "gtksmiley-manager.h"
#include "gtkxfer.h"
#include "pidginabout.h"
#include "pidgincore.h"
@@ -190,13 +189,6 @@
}
static void
-pidgin_application_custom_smiley(GSimpleAction *simple, GVariant *parameter,
- gpointer data)
-{
- pidgin_smiley_manager_show();
-}
-
-static void
pidgin_application_debug(GSimpleAction *simple, GVariant *parameter,
gpointer data)
{
@@ -316,9 +308,6 @@
.name = "add-group",
.activate = pidgin_application_add_group,
}, {
- .name = "custom-smiley",
- .activate = pidgin_application_custom_smiley,
- }, {
.name = "debug",
.activate = pidgin_application_debug,
}, {
--- a/pidgin/pidginstock.c Tue Aug 24 04:51:11 2021 -0500
+++ b/pidgin/pidginstock.c Tue Aug 24 04:52:14 2021 -0500
@@ -123,7 +123,6 @@
{ PIDGIN_STOCK_TOOLBAR_BGCOLOR, "actions", "change-bgcolor.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ PIDGIN_STOCK_TOOLBAR_BLOCK, "emblems", "emblem-blocked.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ PIDGIN_STOCK_TOOLBAR_FGCOLOR, "actions", "change-fgcolor.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
- { PIDGIN_STOCK_TOOLBAR_SMILEY, "actions", "emote-select.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ PIDGIN_STOCK_TOOLBAR_FONT_FACE, "actions", "font-face.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER, "actions", "font-size-down.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ PIDGIN_STOCK_TOOLBAR_TEXT_LARGER, "actions", "font-size-up.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
--- a/pidgin/pidginstock.h Tue Aug 24 04:51:11 2021 -0500
+++ b/pidgin/pidginstock.h Tue Aug 24 04:52:14 2021 -0500
@@ -98,7 +98,6 @@
#define PIDGIN_STOCK_TOOLBAR_BGCOLOR "pidgin-bgcolor"
#define PIDGIN_STOCK_TOOLBAR_BLOCK "pidgin-block"
#define PIDGIN_STOCK_TOOLBAR_FGCOLOR "pidgin-fgcolor"
-#define PIDGIN_STOCK_TOOLBAR_SMILEY "pidgin-smiley"
#define PIDGIN_STOCK_TOOLBAR_FONT_FACE "pidgin-font-face"
#define PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER "pidgin-text-smaller"
#define PIDGIN_STOCK_TOOLBAR_TEXT_LARGER "pidgin-text-larger"
--- a/pidgin/prefs/pidginprefs.c Tue Aug 24 04:51:11 2021 -0500
+++ b/pidgin/prefs/pidginprefs.c Tue Aug 24 04:52:14 2021 -0500
@@ -38,7 +38,6 @@
#include "gtkconv.h"
#include "gtkdialogs.h"
#include "gtksavedstatuses.h"
-#include "gtksmiley-theme.h"
#include "gtkstatus-icon-theme.h"
#include "gtkutils.h"
#include "pidgincore.h"
@@ -123,8 +122,6 @@
struct {
GtkWidget *blink_im;
} win32;
- GtkWidget *resize_custom_smileys;
- GtkWidget *custom_smileys_size;
GtkWidget *minimum_entry_lines;
GtkTextBuffer *format_buffer;
GtkWidget *format_view;
@@ -194,7 +191,6 @@
struct {
SoupSession *session;
GtkWidget *status;
- GtkWidget *smiley;
} theme;
#ifdef USE_VV
@@ -227,11 +223,9 @@
/* Themes page */
static GtkWidget *prefs_status_themes_combo_box;
-static GtkWidget *prefs_smiley_themes_combo_box;
/* These exist outside the lifetime of the prefs dialog */
static GtkListStore *prefs_status_icon_themes;
-static GtkListStore *prefs_smiley_themes;
/*
* PROTOTYPES
@@ -821,7 +815,6 @@
/* NULL-ify globals */
prefs_status_themes_combo_box = NULL;
- prefs_smiley_themes_combo_box = NULL;
g_free(prefs->proxy.gnome_program_path);
prefs = NULL;
@@ -838,39 +831,6 @@
description != NULL ? description : "");
}
-static void
-smileys_refresh_theme_list(void)
-{
- GList *it;
- GtkTreeIter iter;
- gchar *description;
-
- description = get_theme_markup(_("none"), FALSE, _("Penguin Pimps"),
- _("Selecting this disables graphical emoticons."));
- gtk_list_store_append(prefs_smiley_themes, &iter);
- gtk_list_store_set(prefs_smiley_themes, &iter,
- 0, NULL, 1, description, 2, "none", -1);
- g_free(description);
-
- for (it = pidgin_smiley_theme_get_all(); it; it = g_list_next(it)) {
- PidginSmileyTheme *theme = it->data;
-
- description = get_theme_markup(
- _(pidgin_smiley_theme_get_name(theme)), FALSE,
- _(pidgin_smiley_theme_get_author(theme)),
- _(pidgin_smiley_theme_get_description(theme)));
-
- gtk_list_store_append(prefs_smiley_themes, &iter);
- gtk_list_store_set(prefs_smiley_themes, &iter,
- 0, pidgin_smiley_theme_get_icon(theme),
- 1, description,
- 2, pidgin_smiley_theme_get_name(theme),
- -1);
-
- g_free(description);
- }
-}
-
/* adds the themes to the theme list from the manager so they can be displayed in prefs */
static void
prefs_themes_sort(PurpleTheme *theme)
@@ -957,15 +917,10 @@
if (pixbuf)
g_object_unref(G_OBJECT(pixbuf));
- /* smiley themes */
- gtk_list_store_clear(prefs_smiley_themes);
-
purple_theme_manager_for_each_theme(prefs_themes_sort);
- smileys_refresh_theme_list();
/* set active */
prefs_set_active_theme_combo(prefs_status_themes_combo_box, prefs_status_icon_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/status/icon-theme"));
- prefs_set_active_theme_combo(prefs_smiley_themes_combo_box, prefs_smiley_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/smileys/theme"));
}
/* init all the theme variables so that the themes can be sorted later and used by pref pages */
@@ -973,8 +928,6 @@
prefs_themes_init(void)
{
prefs_status_icon_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
-
- prefs_smiley_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
}
/*
@@ -1053,7 +1006,7 @@
{
gchar *destdir;
const char *tail;
- gboolean is_smiley_theme, is_archive;
+ gboolean is_archive;
PurpleTheme *theme = NULL;
if (info == NULL)
@@ -1072,10 +1025,7 @@
/* Just to be safe */
g_strchomp(path);
- if ((is_smiley_theme = purple_strequal(info->type, "smiley")))
- destdir = g_build_filename(purple_data_dir(), "smileys", NULL);
- else
- destdir = g_build_filename(purple_data_dir(), "themes", "temp", NULL);
+ destdir = g_build_filename(purple_data_dir(), "themes", "temp", NULL);
/* We'll check this just to make sure. This also lets us do something different on
* other platforms, if need be */
@@ -1112,11 +1062,7 @@
#endif
}
- if (is_smiley_theme) {
- /* just extract the folder to the smiley directory */
- prefs_themes_refresh();
-
- } else if (is_archive) {
+ if (is_archive) {
theme = prefs_theme_find_theme(destdir, info->type);
if (PURPLE_IS_THEME(theme)) {
@@ -1329,59 +1275,6 @@
g_signal_connect(G_OBJECT(combo_box), "drag_data_received", G_CALLBACK(theme_dnd_recv), (gpointer) type);
}
-/* sets the current smiley theme */
-static void
-prefs_set_smiley_theme_cb(GtkComboBox *combo_box, gpointer user_data)
-{
- gchar *new_theme;
- GtkTreeIter new_iter;
-
- if (gtk_combo_box_get_active_iter(combo_box, &new_iter)) {
-
- gtk_tree_model_get(GTK_TREE_MODEL(prefs_smiley_themes), &new_iter, 2, &new_theme, -1);
-
- purple_prefs_set_string(PIDGIN_PREFS_ROOT "/smileys/theme", new_theme);
-
- g_free(new_theme);
- }
-}
-
-
-/* Does same as normal sort, except "none" is sorted first */
-static gint pidgin_sort_smileys (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer userdata)
-{
- gint ret = 0;
- gchar *name1 = NULL, *name2 = NULL;
-
- gtk_tree_model_get(model, a, 2, &name1, -1);
- gtk_tree_model_get(model, b, 2, &name2, -1);
-
- if (name1 == NULL || name2 == NULL) {
- if (!(name1 == NULL && name2 == NULL))
- ret = (name1 == NULL) ? -1: 1;
- } else if (!g_ascii_strcasecmp(name1, "none")) {
- if (!g_utf8_collate(name1, name2))
- ret = 0;
- else
- /* Sort name1 first */
- ret = -1;
- } else if (!g_ascii_strcasecmp(name2, "none")) {
- /* Sort name2 first */
- ret = 1;
- } else {
- /* Neither string is "none", default to normal sort */
- ret = purple_utf8_strcasecmp(name1, name2);
- }
-
- g_free(name1);
- g_free(name2);
-
- return ret;
-}
-
/* sets the current icon theme */
static void
prefs_set_status_icon_theme_cb(GtkComboBox *combo_box, gpointer user_data)
@@ -1412,18 +1305,6 @@
PIDGIN_PREFS_ROOT "/status/icon-theme",
"icon");
prefs_status_themes_combo_box = win->theme.status;
-
- /* Smiley Themes */
- prefs_build_theme_combo_box(win->theme.smiley, prefs_smiley_themes,
- PIDGIN_PREFS_ROOT "/smileys/theme",
- "smiley");
- prefs_smiley_themes_combo_box = win->theme.smiley;
-
- /* Custom sort so "none" theme is at top of list */
- gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(prefs_smiley_themes),
- 2, pidgin_sort_smileys, NULL, NULL);
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(prefs_smiley_themes),
- 2, GTK_SORT_ASCENDING);
}
static void
@@ -1534,21 +1415,6 @@
gtk_widget_hide(win->conversations.win32.blink_im);
#endif
-#if 0
- /* TODO: it's not implemented */
- pidgin_prefs_bind_checkbox(
- PIDGIN_PREFS_ROOT "/conversations/resize_custom_smileys",
- win->conversations.resize_custom_smileys);
-
- pidgin_prefs_bind_spin_button(
- PIDGIN_PREFS_ROOT "/conversations/custom_smileys_size",
- win->conversations.custom_smileys_size);
-
- g_object_bind_property(win->conversations.resize_custom_smileys, "active",
- win->conversations.custom_smileys_size, "sensitive",
- G_BINDING_SYNC_CREATE);
-#endif
-
pidgin_prefs_bind_spin_button(
PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines",
win->conversations.minimum_entry_lines);
@@ -2508,12 +2374,6 @@
conversations.win32.blink_im);
gtk_widget_class_bind_template_child(
widget_class, PidginPrefsWindow,
- conversations.resize_custom_smileys);
- gtk_widget_class_bind_template_child(
- widget_class, PidginPrefsWindow,
- conversations.custom_smileys_size);
- gtk_widget_class_bind_template_child(
- widget_class, PidginPrefsWindow,
conversations.minimum_entry_lines);
gtk_widget_class_bind_template_child(
widget_class, PidginPrefsWindow,
@@ -2650,12 +2510,8 @@
/* Themes page */
gtk_widget_class_bind_template_child(
widget_class, PidginPrefsWindow, theme.status);
- gtk_widget_class_bind_template_child(
- widget_class, PidginPrefsWindow, theme.smiley);
gtk_widget_class_bind_template_callback(widget_class,
prefs_set_status_icon_theme_cb);
- gtk_widget_class_bind_template_callback(widget_class,
- prefs_set_smiley_theme_cb);
}
static void
@@ -2687,31 +2543,6 @@
gtk_window_present(GTK_WINDOW(prefs));
}
-static void
-smiley_theme_pref_cb(const char *name, PurplePrefType type,
- gconstpointer value, gpointer data)
-{
- const gchar *theme_name = value;
- GList *themes, *it;
-
- if (purple_strequal(theme_name, "none")) {
- purple_smiley_theme_set_current(NULL);
- return;
- }
-
- /* XXX: could be cached when initializing prefs view */
- themes = pidgin_smiley_theme_get_all();
-
- for (it = themes; it; it = g_list_next(it)) {
- PidginSmileyTheme *theme = it->data;
-
- if (!purple_strequal(pidgin_smiley_theme_get_name(theme), theme_name))
- continue;
-
- purple_smiley_theme_set_current(PURPLE_SMILEY_THEME(theme));
- }
-}
-
void
pidgin_prefs_init(void)
{
@@ -2731,14 +2562,6 @@
/* Themes */
prefs_themes_init();
- /* Smiley Themes */
- purple_prefs_add_none(PIDGIN_PREFS_ROOT "/smileys");
- purple_prefs_add_string(PIDGIN_PREFS_ROOT "/smileys/theme", "Default");
-
- /* Smiley Callbacks */
- purple_prefs_connect_callback(&prefs, PIDGIN_PREFS_ROOT "/smileys/theme",
- smiley_theme_pref_cb, NULL);
-
#ifdef USE_VV
/* Voice/Video */
purple_prefs_add_none(PIDGIN_PREFS_ROOT "/vvconfig");
@@ -2794,9 +2617,7 @@
purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/html_shortcuts");
purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/icons_on_tabs");
purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/send_formatting");
- purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/show_smileys");
purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/show_urls_as_links");
- purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/smiley_shortcuts");
purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_bgcolor");
purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_fgcolor");
purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_font");
--- a/pidgin/resources/BuddyList/window.ui Tue Aug 24 04:51:11 2021 -0500
+++ b/pidgin/resources/BuddyList/window.ui Tue Aug 24 04:52:14 2021 -0500
@@ -235,16 +235,6 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
- <object class="GtkMenuItem" id="custom_smileys">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="action-name">app.custom-smiley</property>
- <property name="label" translatable="yes">Custom Smile_ys</property>
- <property name="use-underline">True</property>
- <accelerator key="y" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- </object>
- </child>
- <child>
<object class="GtkMenuItem" id="preferences">
<property name="visible">True</property>
<property name="can-focus">False</property>
--- a/pidgin/resources/Prefs/prefs.ui Tue Aug 24 04:51:11 2021 -0500
+++ b/pidgin/resources/Prefs/prefs.ui Tue Aug 24 04:52:14 2021 -0500
@@ -20,8 +20,8 @@
-->
<interface>
+ <requires lib="gtk+" version="3.22"/>
<requires lib="Talkatu" version="0.0"/>
- <requires lib="gtk+" version="3.22"/>
<requires lib="pidgin" version="3.0"/>
<!-- interface-license-type gplv2 -->
<!-- interface-name Pidgin -->
@@ -78,13 +78,6 @@
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
- <object class="GtkAdjustment" id="conversations.custom_smiley_size.adjustment">
- <property name="lower">16</property>
- <property name="upper">512</property>
- <property name="value">16</property>
- <property name="step-increment">1</property>
- <property name="page-increment">10</property>
- </object>
<object class="TalkatuTagTable" id="conversations.format_tag_table"/>
<object class="TalkatuWholeBuffer" id="conversations.format_buffer">
<property name="tag-table">conversations.format_tag_table</property>
@@ -674,7 +667,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">5</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -688,7 +681,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">6</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -703,58 +696,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">7</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="can-focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkCheckButton" id="conversations.resize_custom_smileys">
- <property name="label" translatable="yes">Resize incoming custom smileys</property>
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="receives-default">False</property>
- <property name="draw-indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="label" translatable="yes">Maximum size:</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="conversations.custom_smileys_size">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="input-purpose">number</property>
- <property name="adjustment">conversations.custom_smiley_size.adjustment</property>
- <property name="numeric">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">8</property>
+ <property name="position">5</property>
</packing>
</child>
<child>
@@ -792,7 +734,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">9</property>
+ <property name="position">6</property>
</packing>
</child>
</object>
@@ -927,38 +869,46 @@
<property name="orientation">vertical</property>
<child>
<object class="TalkatuEditor">
- <property name="orientation">vertical</property>
<property name="visible">True</property>
+ <property name="can-focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <child internal-child="toolbar">
- <object class="TalkatuToolbar">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- </object>
- <packing>
- <property name="fill">False</property>
- </packing>
- </child>
- <child internal-child="input">
- <object class="TalkatuView" id="conversations.format_view">
- <property name="width_request">450</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="wrap_mode">word</property>
- <property name="buffer">conversations.format_buffer</property>
- </object>
- <packing>
- <property name="fill">False</property>
- </packing>
- </child>
+ <property name="orientation">vertical</property>
<child internal-child="send_button">
<object class="GtkButton">
<property name="can-focus">False</property>
<property name="receives-default">False</property>
</object>
<packing>
+ <property name="expand">False</property>
<property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="toolbar">
+ <object class="TalkatuToolbar">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="input">
+ <object class="TalkatuInput" id="conversations.format_view">
+ <property name="width-request">450</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="wrap-mode">word</property>
+ <property name="buffer">conversations.format_buffer</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
@@ -2285,7 +2235,7 @@
<packing>
<property name="name">away</property>
<property name="title" translatable="yes">Status / Idle</property>
- <property name="position">6</property>
+ <property name="position">5</property>
</packing>
</child>
<child>
@@ -2380,60 +2330,6 @@
<property name="position">2</property>
</packing>
</child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label18">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="label" translatable="yes">Smiley Theme:</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="theme.smiley">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <signal name="changed" handler="prefs_set_smiley_theme_cb" swapped="no"/>
- <child>
- <object class="GtkCellRendererPixbuf">
- <property name="width">32</property>
- <property name="height">32</property>
- </object>
- <attributes>
- <attribute name="pixbuf">0</attribute>
- </attributes>
- </child>
- <child>
- <object class="GtkCellRendererText">
- <property name="ellipsize">end</property>
- </object>
- <attributes>
- <attribute name="markup">1</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
</object>
</child>
</object>
@@ -2460,24 +2356,18 @@
<packing>
<property name="name">theme</property>
<property name="title" translatable="yes">Themes</property>
- <property name="position">7</property>
+ <property name="position">6</property>
</packing>
</child>
<child>
<object class="PidginCredentialsPage">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="name">credentials</property>
<property name="title" translatable="yes">Credentials</property>
- <property name="position">8</property>
+ <property name="position">7</property>
</packing>
</child>
</object>
@@ -2527,13 +2417,11 @@
<object class="GtkSizeGroup" id="theme.combo_sg">
<widgets>
<widget name="theme.status"/>
- <widget name="theme.smiley"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="theme.label_sg">
<widgets>
<widget name="label20"/>
- <widget name="label18"/>
</widgets>
</object>
</interface>
--- a/po/POTFILES.in Tue Aug 24 04:51:11 2021 -0500
+++ b/po/POTFILES.in Tue Aug 24 04:52:14 2021 -0500
@@ -276,11 +276,6 @@
libpurple/savedstatuses.c
libpurple/server.c
libpurple/signals.c
-libpurple/smiley.c
-libpurple/smiley-custom.c
-libpurple/smiley-list.c
-libpurple/smiley-parser.c
-libpurple/smiley-theme.c
libpurple/status.c
libpurple/stun.c
libpurple/tests/test_account_option.c
@@ -295,8 +290,6 @@
libpurple/tests/test_protocol_attention.c
libpurple/tests/test_protocol_xfer.c
libpurple/tests/test_queued_output_stream.c
-libpurple/tests/test_smiley.c
-libpurple/tests/test_smiley_list.c
libpurple/tests/test_trie.c
libpurple/tests/test_ui.c
libpurple/tests/test_util.c
@@ -328,8 +321,6 @@
pidgin/gtkrequest.c
pidgin/gtkroomlist.c
pidgin/gtksavedstatuses.c
-pidgin/gtksmiley-manager.c
-pidgin/gtksmiley-theme.c
pidgin/gtkstatusbox.c
pidgin/gtkstatus-icon-theme.c
pidgin/gtkutils.c