aboutsummaryrefslogtreecommitdiff
path: root/irc/bitlbee-otr
diff options
context:
space:
mode:
authorSergey A. Osokin <osa@FreeBSD.org>2006-12-20 16:26:55 +0000
committerSergey A. Osokin <osa@FreeBSD.org>2006-12-20 16:26:55 +0000
commit98d4925ebd72cf1d6a0c7ac23377ab8100d91b19 (patch)
tree038f57111edd335d92d9ce012ff6d7dc625700c1 /irc/bitlbee-otr
parent7c3cc28125bc60f240d46f75e8108dcf5a4f5104 (diff)
downloadports-98d4925ebd72cf1d6a0c7ac23377ab8100d91b19.tar.gz
ports-98d4925ebd72cf1d6a0c7ac23377ab8100d91b19.zip
Notes
Diffstat (limited to 'irc/bitlbee-otr')
-rw-r--r--irc/bitlbee-otr/Makefile10
-rw-r--r--irc/bitlbee-otr/files/oscar-recode-patch196
2 files changed, 205 insertions, 1 deletions
diff --git a/irc/bitlbee-otr/Makefile b/irc/bitlbee-otr/Makefile
index 347859d60109..c3d2d18f3319 100644
--- a/irc/bitlbee-otr/Makefile
+++ b/irc/bitlbee-otr/Makefile
@@ -7,6 +7,7 @@
PORTNAME= bitlbee
PORTVERSION= 1.0.3
+PORTREVISION= 1
CATEGORIES= irc
MASTER_SITES= http://get.bitlbee.org/src/
@@ -26,7 +27,8 @@ USE_GETOPT_LONG=yes
PKGMESSAGE= ${WRKDIR}/pkg-message
OPTIONS= MSN "Enable MSN protocol support" On \
- LDAP "Enable LDAP authentication support" Off
+ LDAP "Enable LDAP authentication support" Off \
+ RECODE "Enable oscar_recode_charset" Off
CONFIGURE_ARGS= --mandir=${PREFIX}/man --config=${PREFIX}/etc/bitlbee
@@ -48,6 +50,12 @@ USE_OPENLDAP= yes
CONFIGURE_ARGS+=--ldap=${LOCALBASE}
.endif
+.if defined(WITH_RECODE)
+post-patch::
+ @cd ${WRKDIR} && \
+ ${PATCH} ${PATCH_ARGS} < ${FILESDIR}/oscar-recode-patch
+.endif
+
pre-install:
@${MKDIR} -m 700 ${PREFIX}/etc/bitlbee
diff --git a/irc/bitlbee-otr/files/oscar-recode-patch b/irc/bitlbee-otr/files/oscar-recode-patch
new file mode 100644
index 000000000000..7a235b969d3d
--- /dev/null
+++ b/irc/bitlbee-otr/files/oscar-recode-patch
@@ -0,0 +1,196 @@
+--- irc.c.orig 2006-06-24 17:00:43.000000000 +0300
++++ irc.c 2006-11-15 13:56:12.000000000 +0200
+@@ -116,6 +116,7 @@
+ set_add( irc, "buddy_sendbuffer", "false", set_eval_bool );
+ set_add( irc, "buddy_sendbuffer_delay", "200", set_eval_int );
+ set_add( irc, "charset", "iso8859-1", set_eval_charset );
++ set_add( irc, "oscar_recode_charset", "iso8859-1", set_eval_oscar_recode_charset );
+ set_add( irc, "debug", "false", set_eval_bool );
+ set_add( irc, "default_target", "root", NULL );
+ set_add( irc, "display_namechanges", "false", set_eval_bool );
+--- protocols/oscar/oscar.c.orig 2006-06-24 17:00:44.000000000 +0300
++++ protocols/oscar/oscar.c 2006-11-16 13:47:10.000000000 +0200
+@@ -1029,7 +1029,10 @@
+ return 1;
+ }
+
++extern GSList *irc_connection_list;
++
+ static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) {
++ char *src="";
+ char *tmp = g_malloc(BUF_LONG + 1);
+ struct gaim_connection *gc = sess->aux_data;
+ int flags = 0;
+@@ -1038,15 +1041,22 @@
+ flags |= IM_FLAG_AWAY;
+
+ if ((args->icbmflags & AIM_IMFLAGS_UNICODE) || (args->icbmflags & AIM_IMFLAGS_ISO_8859_1)) {
+- char *src;
+
+ if (args->icbmflags & AIM_IMFLAGS_UNICODE)
+ src = "UNICODEBIG";
+ else
+- src = "ISO8859-1";
++ {
++ char *cs;
++ irc_t *irc = (irc_t*)irc_connection_list->data;
++ if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )
++ src = cs;
++ else
++ src = "iso88590-1";
++ }
+
+ /* Try to use iconv first to convert the message to UTF8 - which is what BitlBee expects */
+ if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) >= 0) {
++ //fprintf (stderr, "bitlbee: converted from %s to utf8!\n", src);
+ // Successfully converted!
+ } else if (args->icbmflags & AIM_IMFLAGS_UNICODE) {
+ int i;
+@@ -1062,12 +1072,32 @@
+ g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "&#%04x;", uni);
+ }
+ }
++ //fprintf (stderr, "bitlbee: AIM_IMFLAGS_UNICODE, got %s!\n", tmp);
+ } else {
+- g_snprintf(tmp, BUF_LONG, "%s", args->msg);
++ char *cs;
++ irc_t *irc = (irc_t*)irc_connection_list->data;
++ if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )
++ src = cs;
++ else
++ src = "iso88590-1";
++ if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) < 0) {
++ g_snprintf(tmp, BUF_LONG, "[1%s]%s", src, args->msg);
++ }
++ //fprintf (stderr, "bitlbee: not utf8, nor unicode, got %s!\n", tmp);
+ }
+- } else
+- g_snprintf(tmp, BUF_LONG, "%s", args->msg);
+-
++ } else {
++ char *cs;
++ irc_t *irc = (irc_t*)irc_connection_list->data;
++ if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )
++ src = cs;
++ else
++ src = "iso88590-1";
++ if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) < 0) {
++ g_snprintf(tmp, BUF_LONG, "[2%s]%s", src, args->msg);
++ }
++ //fprintf (stderr, "bitlbee: unknown charset, got %s!\n", tmp);
++ }
++
+ strip_linefeed(tmp);
+ serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL), -1);
+ g_free(tmp);
+@@ -1163,12 +1193,23 @@
+ switch (args->type) {
+ case 0x0001: { /* An almost-normal instant message. Mac ICQ sends this. It's peculiar. */
+ char *uin, *message;
++ char *src = "";
++ char *cs;
++ char *tmp = g_malloc(BUF_LONG + 1);
++ irc_t *irc = (irc_t*)irc_connection_list->data;
++ if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )
++ src = cs;
++ else
++ src = "iso88590-1";
+ uin = g_strdup_printf("%u", args->uin);
+ message = g_strdup(args->msg);
+ strip_linefeed(message);
+- serv_got_im(gc, uin, message, 0, time(NULL), -1);
++ if (do_iconv(src, "UTF-8", message, tmp, strlen (message), BUF_LONG) < 0)
++ tmp = message;
++ serv_got_im(gc, uin, tmp, 0, time(NULL), -1);
+ g_free(uin);
+ g_free(message);
++ g_free (tmp);
+ } break;
+
+ case 0x0004: { /* Someone sent you a URL */
+@@ -1768,9 +1809,22 @@
+ char sender[32];
+ char *dialog_msg = g_strdup(msg->msg);
+ time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
++ char *tmp = g_malloc(BUF_LONG + 1);
++ char *src = "";
++ char *cs;
++ irc_t *irc = (irc_t*)irc_connection_list->data;
++ if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )
++ src = cs;
++ else
++ src = "iso88590-1";
+ g_snprintf(sender, sizeof(sender), "%u", msg->sender);
+ strip_linefeed(dialog_msg);
+- serv_got_im(gc, sender, dialog_msg, 0, t, -1);
++ if (do_iconv(src, "UTF-8", dialog_msg, tmp, strlen (msg->msg), BUF_LONG) < 0)
++ tmp = dialog_msg;
++ fprintf (stderr, "bitlbee: offlinemsg, got %s\n", tmp);
++ serv_got_im(gc, sender, tmp, 0, t, -1);
++ if (dialog_msg != tmp)
++ g_free (tmp);
+ g_free(dialog_msg);
+ } break;
+
+@@ -1838,6 +1892,14 @@
+ } else {
+ struct aim_sendimext_args args;
+ char *s;
++ char *cs;
++ char *src="";
++ irc_t *irc = (irc_t*)irc_connection_list->data;
++ if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )
++ src = cs;
++ else
++ src = "iso88590-1";
++
+
+ args.flags = AIM_IMFLAGS_ACK;
+ if (odata->icq)
+@@ -1851,7 +1913,7 @@
+ s = g_malloc(BUF_LONG);
+ /* Try if we can put it in an ISO8859-1 string first.
+ If we can't, fall back to UTF16. */
+- if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) {
++ if ((ret = do_iconv("UTF-8", src, message, s, len, BUF_LONG)) >= 0) {
+ args.flags |= AIM_IMFLAGS_ISO_8859_1;
+ len = ret;
+ } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) {
+@@ -1863,6 +1925,7 @@
+ s = message;
+ }
+ } else {
++ fprintf (stderr, "outgoing message is ascii!\n");
+ s = message;
+ }
+
+--- util.c.orig 2006-06-24 17:01:00.000000000 +0300
++++ util.c 2006-11-15 13:56:12.000000000 +0200
+@@ -453,3 +453,18 @@
+ iconv_close( cd );
+ return( value );
+ }
++
++char *set_eval_oscar_recode_charset( irc_t *irc, set_t *set, char *value )
++{
++ iconv_t cd;
++
++ if ( g_strncasecmp( value, "none", 4 ) == 0 )
++ return( value );
++
++ cd = iconv_open( "UTF-8", value );
++ if( cd == (iconv_t) -1 )
++ return( NULL );
++
++ iconv_close( cd );
++ return( value );
++}
+--- util.h.orig 2006-06-24 17:01:00.000000000 +0300
++++ util.h 2006-11-15 13:56:12.000000000 +0200
+@@ -46,5 +46,6 @@
+
+ G_MODULE_EXPORT signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf );
+ char *set_eval_charset( irc_t *irc, set_t *set, char *value );
++char *set_eval_oscar_recode_charset( irc_t *irc, set_t *set, char *value );
+
+ #endif