LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 887|回复: 5

OpenQ过滤自定义表情补丁。。。[己更新]

[复制链接]
发表于 2004-9-20 23:54:09 | 显示全部楼层 |阅读模式
OpenQ过滤自定义表情补丁。。。
效果图:

是针对这个版做的补丁。。。
http://sunmoon.512j.com/OpenQ-0.3.0.p3.tar.gz
补丁下载:
http://sunmoon.512j.com/OpenQ-0.3.0.p3-userdefined-smiley.patch
还有gaim-1.0.0的补丁。。
http://sunmoon.512j.com/OpenQ-0.3.0.p3-gaim-1.0.0.patch
发表于 2004-9-21 04:38:56 | 显示全部楼层
怎么用呀?你的ebuild里边更新了吗?
 楼主| 发表于 2004-9-21 16:29:30 | 显示全部楼层
补丁己更新,现在已经比较稳定了。。。不会发生段错误了。。。
如果已经使用了这个补丁,请重新编译。。。
 楼主| 发表于 2004-9-21 16:34:35 | 显示全部楼层
这里是主要的过滤代码,,
大家帮我查一下。。
[php]const gchar *QQ_SPT_IMG_EXT[] =  {".BMP", ".GIF", ".JPEG", ".JPG", NULL};
#define QQ_USERDEFINED_SMILEY_FLAGS  "\025"
#define MSG_FILTER_PROM   "[MSG FILTERED]"
#define MSG_FILTER_PROM_SIZE  (sizeof(MSG_FILTER_PROM) - 1) //donnot include the terminal char
#define QQ_SMILEY_SHOTCUT_MAX  6

gchar *qq_im_filter_userdefined_smiley(const gchar *text, gboolean maintain_shotcut) {
  GString *converted;
  gchar *begin, *end, *cnt, **smiley_ex_flags, *result;
  static gchar shotcuts[26][QQ_SMILEY_SHOTCUT_MAX + 1]; //define as static to speedup
  gint  last_shotcut = -1;
  
  if (!g_strstr_len(text, -1, QQ_USERDEFINED_SMILEY_FLAGS))
   return NULL;

  converted = g_string_new(text);
  
  if (!converted)
      return NULL;

  begin = cnt = converted->str;

  
  while (cnt && *cnt) {
        cnt = g_strstr_len(cnt, -1, QQ_USERDEFINED_SMILEY_FLAGS);
        if (!cnt || !(*(cnt +1))) {
           break;
        }
        if (!isdigit(cnt[1])) {
            cnt ++;
            continue;
        }
        end = NULL;
       
        if ( cnt[1] == '3') {
                gchar *end1;
               
                //find the best match
                for (smiley_ex_flags = (gchar **)QQ_SPT_IMG_EXT; smiley_ex_flags != NULL, *smiley_ex_flags != '\0'; smiley_ex_flags++) {
                        end1 = g_strstr_len(cnt, -1, *smiley_ex_flags);
                        if ( !end && end1)
                                end = end1 + strlen(*smiley_ex_flags);
                        else if (end1 && end1 + strlen(*smiley_ex_flags) < end) {
                                end = end1 + strlen(*smiley_ex_flags);
                        }
                }
               
                if (end) {
                        if (*end ) {
                                //         extension name of smiley --> ____
                                //\x1532FE05FF7FDBE0CF68CB2A108F7B8D5B48.GIFDabc
                                //            shotcut length('D'-'A' = 3)-> ^--- <-shotcut of smiley
                                if (maintain_shotcut == FALSE && (*end >= 'A') && (end[0] - 'A' <= QQ_SMILEY_SHOTCUT_MAX)
                                    && (end + (end[0] - 'A')  <= begin + converted->len)) {
                                        if((!end[end[0] - 'A'] && end + end[0] - 'A' - cnt - 1 >= MSG_FILTER_PROM_SIZE) ||
                                           ( end[end[0] - 'A'] && end + end[0] - 'A' - cnt >= MSG_FILTER_PROM_SIZE)) {        
                                                strncpy(cnt,  MSG_FILTER_PROM, MSG_FILTER_PROM_SIZE);//tell user we filter some msg.
                                                cnt += MSG_FILTER_PROM_SIZE;
                                        }
                                       
                                        //store the shotcut
                                        if ( last_shotcut < 25) {
                                        //        strncpy(shotcuts[++last_shotcut], end + 1 , end[0] - 'A');
                                        //        shotcuts[last_shotcut][end[0] - 'A'] = '\0';
                                                ++last_shotcut;
                                        }
                                       
                                        end += (end[0] - 'A') + 1;       
                                }
                                else        { //maintain the shotcut
                                        //store the shotcut
                                        if ( last_shotcut < 25 && (*end >= 'A') && end[0] - 'A' <= QQ_SMILEY_SHOTCUT_MAX) {
                                                strncpy(shotcuts[++last_shotcut], end + 1 , end[0] - 'A');
                                                shotcuts[last_shotcut][end[0] - 'A'] = '\0';
                                        }
                                        end ++;
                                }
                        }
                         
                        if (end > begin + converted->len) //the end must be in the bound of `converted' string
                                end = begin + converted->len;
                       
                        g_string_erase(converted, (cnt - begin), (end - cnt));
                       
                        if (maintain_shotcut == FALSE)
                                continue;
                }
                else {
                        //\x153...
                        // ^-> ^
                        //skip...
                        cnt += 2;
                        continue;
                }
        }
        else if (cnt[1] == '4' ) {
                if (maintain_shotcut == FALSE) {
                        if (cnt[2] >= 'A' && cnt[2] <= 'Z' && cnt[2] - 'A' <= last_shotcut) {//\x154[A-Z]
                                g_string_erase(converted, (cnt - begin), 3); //just erase 3 chars
                                continue;
                        }
                       
                }
                else {
                        if (cnt[2] >= 'A' && cnt[2] <= 'Z' && last_shotcut >= 0) { //\x154[A-Z]
                                gint shotcut_len = strlen(shotcuts[cnt[2] - 'A']);

                                if (shotcut_len > 0 && shotcut_len <= 3 && cnt[2] - 'A' <= last_shotcut) {
                                        strncpy(cnt, shotcuts[cnt[2] - 'A'], shotcut_len);
                                        cnt += shotcut_len;
                                        if (shotcut_len < 3) {
      g_string_erase(converted, (cnt - begin), 3 - shotcut_len);
     }
     continue;
    }
    else {
     g_string_erase(converted, (cnt - begin), 3);
    }
   }
  }
}
cnt ++;
  }

  result = converted->str;
  g_string_free(converted, FALSE);

  if (last_shotcut >= 0 && maintain_shotcut == TRUE) //clear the buffer
   memset(&shotcuts[0][0], sizeof(shotcuts), 0);
  
  return result;
}//qq_im_filter_userdefined_smiley
[/php]
发表于 2004-9-21 20:24:18 | 显示全部楼层
emerge gaim升级到1.0
打了linuxfans上的两个补丁
编译通过,但找不到插件~!
./configure --prefix=/usr
make
make install
发表于 2004-9-21 20:34:55 | 显示全部楼层

而且打补丁的时候出现下面提示

smile OpenQ-0.3.0.p3 # patch -p1 < OpenQ-0.3.0.p3-
OpenQ-0.3.0.p3-gaim-1.0.0.patch          OpenQ-0.3.0.p3-userdefined-smiley.patch
smile OpenQ-0.3.0.p3 # patch -p1 < OpenQ-0.3.0.p3-gaim-1.0.0.patch
patching file src/qq.c
smile OpenQ-0.3.0.p3 # patch -p1 < OpenQ-0.3.0.p3-userdefined-smiley.patch
patching file src/qq.c
patching file src/qq_char_conv.c
patching file src/qq_char_conv.h
patching file src/qq_group_im.c
Hunk #1 FAILED at 205.
1 out of 3 hunks FAILED -- saving rejects to file src/qq_group_im.c.rej
patching file src/qq_im.c
Hunk #10 FAILED at 371.
1 out of 13 hunks FAILED -- saving rejects to file src/qq_im.c.rej
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表