Novas linhas inúteis em mensagens recebidas no pidgin ao usar o pidgin-sipe

1

Ao usar o pidgin-sipe com o pidgin, as mensagens recebidas têm uma quantidade enorme de espaço em branco ao redor da mensagem real. Ativar / desativar a formatação nas mensagens recebidas não faz diferença. Veja aqui:

Luz verde sou eu (sem espaço em branco), verde escuro é meu amigo usando o cliente Skype for Business. No seu final tudo parece normal. Por que há tanto espaço em branco (linhas vazias) ao redor das mensagens recebidas? Como isso pode ser corrigido?

    
por Patrick 07.02.2017 / 10:26

1 resposta

0

Eu consertei isso hacking-me sip-se. É provavelmente um código ruim, mas ei, eu sou ruim em C. Tudo o que ele faz é remover ocorrências de <BR> nas mensagens. Aqui está o patch, caso alguém encontre o mesmo problema:

*** 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)
    
por Patrick 18.04.2018 / 15:47