From d510f3a4309cf0a42fc135bbf0905f476757a9c8 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 27 May 2022 10:39:49 +0200 Subject: [PATCH] Final touches for `/avatar set` --- configure.ac | 7 +++---- src/command/cmd_defs.c | 2 +- src/command/cmd_funcs.c | 2 +- src/xmpp/avatar.c | 5 +++-- tests/unittests/xmpp/stub_avatar.c | 2 -- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 5124f2ed..dad9cc28 100644 --- a/configure.ac +++ b/configure.ac @@ -66,7 +66,7 @@ AC_ARG_WITH([themes], AC_ARG_ENABLE([icons-and-clipboard], [AS_HELP_STRING([--enable-icons-and-clipboard], [enable GTK tray icons and clipboard paste support])]) AC_ARG_ENABLE([gdk-pixbuf], - [AS_HELP_STRING([--enable-gdk-pixbuf], [enable GDK Pixbuf support])]) + [AS_HELP_STRING([--enable-gdk-pixbuf], [enable GDK Pixbuf support to scale avatars before uploading])]) # Required dependencies @@ -308,15 +308,14 @@ if test "x$enable_otr" != xno; then AM_COND_IF([BUILD_OTR], [AC_DEFINE([HAVE_LIBOTR], [1], [Have libotr])]) fi -dnl feature: pixbuf +dnl feature: pixbuf / used for scaling avatars before uploading via `/avatar set` AS_IF([test "x$enable_pixbuf" != xno], [PKG_CHECK_MODULES([gdk_pixbuf], [gdk-pixbuf-2.0 >= 2.4], [AC_DEFINE([HAVE_PIXBUF], [1], [gdk-pixbuf module])], [AS_IF([test "x$enable_pixbuf" = xyes], - [AC_MSG_ERROR([gdk-pixbuf-2.0 >= 2.4 is required for GDK Pixbuf support])], + [AC_MSG_ERROR([gdk-pixbuf-2.0 >= 2.4 is required to scale avatars before uploading])], [AC_MSG_NOTICE([gdk-pixbuf-2.0 >= 2.4 not found, GDK Pixbuf support not enabled])])])]) - dnl feature: omemo AM_CONDITIONAL([BUILD_OMEMO], [false]) if test "x$enable_omemo" != xno; then diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index ffc4ec83..599262c1 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2452,7 +2452,7 @@ static struct cmd_t command_defs[] = { "If nothing happens after using this command the user either doesn't have an avatar set at all " "or doesn't use XEP-0084 to publish it.") CMD_ARGS( - { "set ", "Set avatar to the img at ." }, + { "set ", "Set avatar to the image at ." }, { "get ", "Download the avatar. barejid is the JID to download avatar from." }, { "open ", "Download avatar and open it with command." }) CMD_EXAMPLES( diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index dfe96971..2a8331d1 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -9201,7 +9201,7 @@ cmd_avatar(ProfWin* window, const char* const command, gchar** args) cons_show("Avatar updated successfully"); } #else - cons_show("This version of Profanity has not been built with GDK Pixbuf support enabled"); + cons_show("Profanity has not been built with GDK Pixbuf support enabled which is needed to scale the avatar when uploading."); #endif } else if (g_strcmp0(args[0], "get") == 0) { avatar_get_by_nick(args[1], false); diff --git a/src/xmpp/avatar.c b/src/xmpp/avatar.c index 15ec7f1a..9345ba3a 100644 --- a/src/xmpp/avatar.c +++ b/src/xmpp/avatar.c @@ -36,12 +36,13 @@ #include "config.h" #include +#ifdef HAVE_PIXBUF #include +#endif #include #include #include #include -#include #include #include "log.h" @@ -61,7 +62,7 @@ typedef struct avatar_metadata static GHashTable* looking_for = NULL; // contains nicks/barejids from who we want to get the avatar static GHashTable* shall_open = NULL; // contains a list of nicks that shall not just downloaded but also opened -const int MAX_PIXEL = 192; +const int MAX_PIXEL = 192; // max pixel width/height for an avatar static void _avatar_request_item_by_id(const char* jid, avatar_metadata* data); static int _avatar_metadata_handler(xmpp_stanza_t* const stanza, void* const userdata); diff --git a/tests/unittests/xmpp/stub_avatar.c b/tests/unittests/xmpp/stub_avatar.c index 9f07c334..fd63293e 100644 --- a/tests/unittests/xmpp/stub_avatar.c +++ b/tests/unittests/xmpp/stub_avatar.c @@ -9,10 +9,8 @@ avatar_get_by_nick(const char* nick) return TRUE; } -#ifdef HAVE_PIXBUF gboolean avatar_set(const char* path) { return TRUE; } -#endif