]> git.pld-linux.org Git - packages/libpurple-protocol-skypeweb.git/commitdiff
upstream patch for displaying video attachments; rel 5
authorJan Palus <atler@pld-linux.org>
Sun, 14 Feb 2021 11:37:53 +0000 (12:37 +0100)
committerJan Palus <atler@pld-linux.org>
Sun, 14 Feb 2021 11:38:49 +0000 (12:38 +0100)
libpurple-protocol-skypeweb.spec
video_attachemnt.patch [new file with mode: 0644]

index 4b882e1f05e70496e2e63f2772a2a3dc9e67eaa0..0290413963fa5208840cbfbd1f3b0319f070b625 100644 (file)
@@ -1,7 +1,7 @@
 Summary:       SkypeWeb API Plugin for Pidgin/libpurple/Adium
 Name:          libpurple-protocol-skypeweb
 Version:       1.7
-Release:       4
+Release:       5
 License:       GPL v3
 Group:         Applications/Communications
 Source0:       https://github.com/EionRobb/skype4pidgin/archive/%{version}.tar.gz
@@ -9,6 +9,7 @@ Source0:        https://github.com/EionRobb/skype4pidgin/archive/%{version}.tar.gz
 Patch0:                login.patch
 Patch1:                bitlbee_img_url.patch
 Patch2:                xhtml.patch
+Patch3:                video_attachemnt.patch
 URL:           https://github.com/EionRobb/skype4pidgin/tree/master/skypeweb
 BuildRequires: cmake >= 2.8
 BuildRequires: glib2-devel
@@ -27,6 +28,7 @@ and chat with all your Skype buddies from within Pidgin/Adium.
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
 
 %build
 cd skypeweb
diff --git a/video_attachemnt.patch b/video_attachemnt.patch
new file mode 100644 (file)
index 0000000..06e5643
--- /dev/null
@@ -0,0 +1,176 @@
+From b6766782ec838f3e4b7dc3e3d0181f6c0bdb7d91 Mon Sep 17 00:00:00 2001
+From: Jan Palus <jpalus@fastmail.com>
+Date: Tue, 26 Jan 2021 15:23:08 +0100
+Subject: [PATCH] Preliminary video attachment support
+
+Message looks almost the same as image attachment hence logic is almost
+the same. For now Pidgin displays thumbnail + link to full video while
+Bitlbee shows link.
+---
+ skypeweb/skypeweb_contacts.c | 28 ++++++++++++++++++++++++----
+ skypeweb/skypeweb_contacts.h |  3 ++-
+ skypeweb/skypeweb_messages.c | 33 +++++++++++++++++++++------------
+ skypeweb/skypeweb_messages.h |  7 +++++++
+ 4 files changed, 54 insertions(+), 17 deletions(-)
+
+diff --git a/skypeweb/skypeweb_contacts.c b/skypeweb/skypeweb_contacts.c
+index 35dddc9..aab23e4 100644
+--- a/skypeweb/skypeweb_contacts.c
++++ b/skypeweb/skypeweb_contacts.c
+@@ -180,16 +180,37 @@ skypeweb_got_imagemessage(PurpleHttpConnection *http_conn, PurpleHttpResponse *r
+       g_free(ctx_from);\r
+ }\r
\r
++static const char*\r
++skypeweb_uri_type_name(SkypeWebURIType uri_type) {\r
++      switch (uri_type) {\r
++              case SKYPEWEB_URI_TYPE_IMAGE:\r
++                      return "image";\r
++              case SKYPEWEB_URI_TYPE_VIDEO:\r
++                      return "video";\r
++              default:\r
++                      return "(unknown)";\r
++      }\r
++}\r
+ void\r
+-skypeweb_download_uri_to_conv(SkypeWebAccount *sa, const gchar *uri, PurpleConversation *conv, time_t ts, const gchar* from)\r
++skypeweb_download_uri_to_conv(SkypeWebAccount *sa, const gchar *uri, SkypeWebURIType uri_type, PurpleConversation *conv, time_t ts, const gchar* from)\r
+ {\r
+       gchar *url, *text;\r
+       PurpleHttpRequest *request;\r
+       \r
++      switch (uri_type) {\r
++              case SKYPEWEB_URI_TYPE_IMAGE:\r
++                      url = purple_strreplace(uri, "imgt1", "imgpsh_fullsize");\r
++                      break;\r
++              case SKYPEWEB_URI_TYPE_VIDEO:\r
++                      url = purple_strreplace(uri, "thumbnail", "video");\r
++                      break;\r
++              default:\r
++                      url = g_strdup(uri);\r
++                      break;\r
++      }\r
+       if (purple_strequal(purple_core_get_ui(), "BitlBee")) {\r
+               // Bitlbee doesn't support images, so just plop a url to the image instead\r
+               \r
+-              url = purple_strreplace(uri, "imgt1", "imgpsh_fullsize");\r
+               if (PURPLE_IS_IM_CONVERSATION(conv)) {\r
+                       purple_serv_got_im(sa->pc, from, url, PURPLE_MESSAGE_RECV, ts);\r
+               } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {\r
+@@ -212,8 +233,7 @@ skypeweb_download_uri_to_conv(SkypeWebAccount *sa, const gchar *uri, PurpleConve
+       purple_http_request(sa->pc, request, skypeweb_got_imagemessage, ctx);\r
+       purple_http_request_unref(request);\r
\r
+-      url = purple_strreplace(uri, "imgt1", "imgpsh_fullsize");\r
+-      text = g_strdup_printf("<a href=\"%s\">Click here to view full version</a>", url);\r
++      text = g_strdup_printf("<a href=\"%s\">Click here to view full %s</a>", url, skypeweb_uri_type_name(uri_type));\r
+       purple_conversation_write_img_message(conv, from, text, 0, ts);\r
+       \r
+       g_free(url);\r
+diff --git a/skypeweb/skypeweb_contacts.h b/skypeweb/skypeweb_contacts.h
+index 885f865..8eef9c7 100644
+--- a/skypeweb/skypeweb_contacts.h
++++ b/skypeweb/skypeweb_contacts.h
+@@ -20,9 +20,10 @@
+ #define SKYPEWEB_CONTACTS_H
+ #include "libskypeweb.h"
++#include "skypeweb_messages.h"
+ void skypeweb_get_icon(PurpleBuddy *buddy);
+-void skypeweb_download_uri_to_conv(SkypeWebAccount *sa, const gchar *uri, PurpleConversation *conv, time_t ts, const gchar* from);
++void skypeweb_download_uri_to_conv(SkypeWebAccount *sa, const gchar *uri, SkypeWebURIType uri_type, PurpleConversation *conv, time_t ts, const gchar* from);
+ void skypeweb_download_video_message(SkypeWebAccount *sa, const gchar *sid, PurpleConversation *conv);
+ void skypeweb_download_moji_to_conv(SkypeWebAccount *sa, const gchar *text, const gchar *url_thumbnail, PurpleConversation *conv, time_t ts, const gchar* from);
+ void skypeweb_present_uri_as_filetransfer(SkypeWebAccount *sa, const gchar *uri, const gchar *from);
+diff --git a/skypeweb/skypeweb_messages.c b/skypeweb/skypeweb_messages.c
+index 8e6ba79..bf9f472 100644
+--- a/skypeweb/skypeweb_messages.c
++++ b/skypeweb/skypeweb_messages.c
+@@ -116,6 +116,22 @@ process_userpresence_resource(SkypeWebAccount *sa, JsonObject *resource)
+       // return FALSE;\r
+ // }\r
\r
++static void\r
++skypeweb_process_uri_message(const gchar* messagetype, SkypeWebAccount *sa, PurpleConversation* conv, const gchar* uri_content, time_t composetimestamp, const gchar* from) {\r
++      PurpleXmlNode *blob = purple_xmlnode_from_str(uri_content, -1);\r
++      const gchar *uri = purple_xmlnode_get_attrib(blob, "url_thumbnail");\r
++      SkypeWebURIType uri_type;\r
++      \r
++      if (g_str_has_suffix(messagetype, "Media_Video")) {\r
++              uri_type = SKYPEWEB_URI_TYPE_VIDEO;\r
++      } else {\r
++              uri_type = SKYPEWEB_URI_TYPE_IMAGE;\r
++      }\r
++      \r
++      skypeweb_download_uri_to_conv(sa, uri, uri_type, conv, composetimestamp, from);\r
++      purple_xmlnode_free(blob);\r
++}\r
++\r
+ static void\r
+ process_message_resource(SkypeWebAccount *sa, JsonObject *resource)\r
+ {\r
+@@ -337,15 +353,11 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource)
+                       } \r
+                       \r
+                       purple_xmlnode_free(blob);\r
+-              } else if (g_str_equal(messagetype, "RichText/UriObject")) {\r
+-                      PurpleXmlNode *blob = purple_xmlnode_from_str(content, -1);\r
+-                      const gchar *uri = purple_xmlnode_get_attrib(blob, "url_thumbnail");\r
+-                      \r
++              } else if (g_str_equal(messagetype, "RichText/UriObject") || g_str_equal(messagetype, "RichText/Media_Video")) {\r
+                       from = skypeweb_contact_url_to_name(from);\r
+                       g_return_if_fail(from);\r
+                       \r
+-                      skypeweb_download_uri_to_conv(sa, uri, conv, composetimestamp, from);\r
+-                      purple_xmlnode_free(blob);\r
++                      skypeweb_process_uri_message(messagetype, sa, conv, content, composetimestamp, from);\r
+               } else {\r
+                       purple_debug_warning("skypeweb", "Unhandled thread message resource messagetype '%s'\n", messagetype);\r
+               }\r
+@@ -420,11 +432,9 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource)
+                               conv = PURPLE_CONVERSATION(imconv);\r
+                       }\r
+                       g_free(html);\r
+-              } else if (g_str_equal(messagetype, "RichText/UriObject")) {\r
+-                      PurpleXmlNode *blob = purple_xmlnode_from_str(content, -1);\r
+-                      const gchar *uri = purple_xmlnode_get_attrib(blob, "url_thumbnail");\r
++              } else if (g_str_equal(messagetype, "RichText/UriObject") || g_str_equal(messagetype, "RichText/Media_Video")) {\r
+                       PurpleIMConversation *imconv;\r
+-                      \r
++\r
+                       if (skypeweb_is_user_self(sa, from)) {\r
+                               from = convbuddyname;\r
+                       }\r
+@@ -436,9 +446,8 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource)
+                               }\r
+                               \r
+                               conv = PURPLE_CONVERSATION(imconv);\r
+-                              skypeweb_download_uri_to_conv(sa, uri, conv, composetimestamp, from);\r
++                              skypeweb_process_uri_message(messagetype, sa, conv, content, composetimestamp, from);\r
+                       }\r
+-                      purple_xmlnode_free(blob);\r
+               } else if (g_str_equal(messagetype, "RichText/Media_GenericFile")) {\r
+                       PurpleXmlNode *blob = purple_xmlnode_from_str(content, -1);\r
+                       const gchar *uri = purple_xmlnode_get_attrib(blob, "uri");\r
+diff --git a/skypeweb/skypeweb_messages.h b/skypeweb/skypeweb_messages.h
+index 5c03fa9..98fcb60 100644
+--- a/skypeweb/skypeweb_messages.h
++++ b/skypeweb/skypeweb_messages.h
+@@ -21,6 +21,13 @@
+ #include "libskypeweb.h"
++typedef enum
++{
++      SKYPEWEB_URI_TYPE_IMAGE,
++      SKYPEWEB_URI_TYPE_VIDEO,
++      SKYPEWEB_URI_TYPE_UNKNOWN
++} SkypeWebURIType;
++
+ gint skypeweb_send_im(PurpleConnection *pc, 
+ #if PURPLE_VERSION_CHECK(3, 0, 0)
+       PurpleMessage *msg
+-- 
+2.30.1
+
This page took 0.057384 seconds and 4 git commands to generate.