首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在使用pidgin-sipe时,使用pidgin中传入消息的无用换行符

在使用pidgin-sipe时,使用pidgin中传入消息的无用换行符
EN

Ask Ubuntu用户
提问于 2017-02-07 09:26:12
回答 1查看 224关注 0票数 2

当使用pidgin-sipe和pidgin时,传入的消息在实际消息周围有大量的空白。启用/禁用传入消息的格式设置没有任何区别。见这里:

浅绿色是我(没有空格),深绿色是我的朋友使用Skype为商业客户。在他看来一切都很正常。为什么传入的消息周围有这么多空白(空行)?怎么解决这个问题呢?

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2018-04-18 13:47:44

我通过黑客攻击我自己搞定了这个。这可能是不好的代码,但是我对C不在行。它所做的只是删除消息中出现的<BR>。下面是补丁,以防其他人遇到同样的问题:

代码语言:javascript
复制
*** purple-im.c     2016-12-18 18:19:07.000000000 +0100
--- /tmp/purple-im.c        2018-04-18 15:49:48.915516011 +0200
***************
*** 43,60 ****
  #include "sipe-core.h"
  #include "sipe-nls.h"

  void sipe_backend_im_message(struct sipe_core_public *sipe_public,
                         const gchar *from,
                         const gchar *html)
  {
    struct sipe_backend_private *purple_private = sipe_public->backend_private;
    purple_serv_got_im(purple_private->gc,
                from,
!               html,
                0,
                time(NULL));
  }

  void sipe_backend_im_topic(struct sipe_core_public *sipe_public,
                       const gchar *with,
                       const gchar *topic)
--- 43,102 ----
  #include "sipe-core.h"
  #include "sipe-nls.h"

+ static void str_replace(gchar *target, const gchar *needle, const gchar *replacement)
+ {
+
+     gchar buffer[1024] = { 0 };
+     gchar *insert_point = &buffer[0];
+     const gchar *tmp = target;
+     size_t needle_len = strlen(needle);
+     size_t repl_len = strlen(replacement);
+
+     while (1) {
+         const gchar *p = strstr(tmp, needle);
+
+         // walked past last occurrence of needle; copy remaining part
+         if (p == NULL) {
+             strcpy(insert_point, tmp);
+             break;
+         }
+
+         // copy part before needle
+         memcpy(insert_point, tmp, p - tmp);
+         insert_point += p - tmp;
+
+         // copy replacement string
+         memcpy(insert_point, replacement, repl_len);
+         insert_point += repl_len;
+
+         // adjust pointers, move on
+         tmp = p + needle_len;
+     }
+
+     // write altered string back to target
+     strcpy(target, buffer);
+ }
+
  void sipe_backend_im_message(struct sipe_core_public *sipe_public,
                         const gchar *from,
                         const gchar *html)
  {
    struct sipe_backend_private *purple_private = sipe_public->backend_private;
+
+     const size_t target_size = strlen(html) + 1;
+     gchar copy_of_html[target_size];
+     strncpy(copy_of_html, html, target_size);
+
+     str_replace(copy_of_html, "<BR>", "");
+
    purple_serv_got_im(purple_private->gc,
                from,
!               copy_of_html,
                0,
                time(NULL));
  }

+
  void sipe_backend_im_topic(struct sipe_core_public *sipe_public,
                       const gchar *with,
                       const gchar *topic)
票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/880725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档