From svn w toxygen.net Mon Sep 1 11:15:59 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 11:15:59 +0200 (CEST) Subject: [ekg2-commit] r4569 - in trunk: ekg plugins/dbus plugins/gg plugins/icq plugins/irc plugins/jabber plugins/jogger plugins/xmsg: trunk/ekg/commands.c trunk/ekg/plugins.h trunk/plugins/dbus/dbus_iface_im.c trunk/plugins/gg/gg.c trunk/plugins/icq/icq.c trunk/plugins/irc/irc.c trunk/plugins/jabber/jabber.c trunk/plugins/jogger/jogger.c trunk/plugins/xmsg/xmsg.c Message-ID: <20080901091559.7EF7A17B1F@toxygen.net> Author: peres Date: 2008-09-01 11:15:58 +0200 (Mon, 01 Sep 2008) New Revision: 4569 Modified: trunk/ekg/commands.c trunk/ekg/plugins.h trunk/plugins/dbus/dbus_iface_im.c trunk/plugins/gg/gg.c trunk/plugins/icq/icq.c trunk/plugins/irc/irc.c trunk/plugins/jabber/jabber.c trunk/plugins/jogger/jogger.c trunk/plugins/xmsg/xmsg.c Log: Ok, no C standard permits anonymous unions. Modified: trunk/ekg/commands.c =================================================================== --- trunk/ekg/commands.c 2008-08-31 21:32:29 UTC (rev 4568) +++ trunk/ekg/commands.c 2008-09-01 09:15:58 UTC (rev 4569) @@ -2010,12 +2010,12 @@ printq("generic", buf); if (p->pclass == PLUGIN_PROTOCOL) { - char *pr = array_join((char**) p->protocol.protocols, ", "); + char *pr = array_join((char**) p->priv.protocol.protocols, ", "); char *st; char **_sts = NULL; const status_t *_st; - for (_st = p->protocol.statuses; *_st != EKG_STATUS_NULL; _st++) { + for (_st = p->priv.protocol.statuses; *_st != EKG_STATUS_NULL; _st++) { array_add(&_sts, (char*) ekg_status_string(*_st, 2)); } st = array_join(_sts, ", "); Modified: trunk/ekg/plugins.h =================================================================== --- trunk/ekg/plugins.h 2008-08-31 21:32:29 UTC (rev 4568) +++ trunk/ekg/plugins.h 2008-09-01 09:15:58 UTC (rev 4569) @@ -75,7 +75,7 @@ const char **protocols; /* NULL-terminated list of supported protocols, replacing GET_PLUGIN_PROTOCOLS */ const status_t *statuses; /* EKG_STATUS_NULL-terminated list of supported statuses */ } protocol; - }; + } priv; } plugin_t; /* Note about plugin_t.statuses: Modified: trunk/plugins/dbus/dbus_iface_im.c =================================================================== --- trunk/plugins/dbus/dbus_iface_im.c 2008-08-31 21:32:29 UTC (rev 4568) +++ trunk/plugins/dbus/dbus_iface_im.c 2008-09-01 09:15:58 UTC (rev 4569) @@ -30,7 +30,7 @@ if (p->pclass == PLUGIN_PROTOCOL) { const char **a; - for (a = p->protocol.protocols; *a; a++) + for (a = p->priv.protocol.protocols; *a; a++) EKG2_DBUS_ADD_STRING(a); } } @@ -109,7 +109,7 @@ if (p->pclass == PLUGIN_PROTOCOL) { const char **a; - for (a = p->protocol.protocols; *a; a++) { + for (a = p->priv.protocol.protocols; *a; a++) { if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, a)) { debug("ekg2_dbus_iface_im_getProtocols cannot allocate memory?\n"); ekg_oom_handler(); Modified: trunk/plugins/gg/gg.c =================================================================== --- trunk/plugins/gg/gg.c 2008-08-31 21:32:29 UTC (rev 4568) +++ trunk/plugins/gg/gg.c 2008-09-01 09:15:58 UTC (rev 4569) @@ -1644,8 +1644,8 @@ PLUGIN_CHECK_VER("gg"); gg_plugin.params = gg_plugin_vars; - gg_plugin.protocol.protocols = gg_protocols; - gg_plugin.protocol.statuses = gg_statuses; + gg_plugin.priv.protocol.protocols = gg_protocols; + gg_plugin.priv.protocol.statuses = gg_statuses; plugin_register(&gg_plugin, prio); gg_setvar_default(NULL, dummy); Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-08-31 21:32:29 UTC (rev 4568) +++ trunk/plugins/icq/icq.c 2008-09-01 09:15:58 UTC (rev 4569) @@ -1463,8 +1463,8 @@ icq_convert_string_init(); icq_plugin.params = icq_plugin_vars; - icq_plugin.protocol.protocols = icq_protocols; - icq_plugin.protocol.statuses = icq_statuses; + icq_plugin.priv.protocol.protocols = icq_protocols; + icq_plugin.priv.protocol.statuses = icq_statuses; plugin_register(&icq_plugin, prio); Modified: trunk/plugins/irc/irc.c =================================================================== --- trunk/plugins/irc/irc.c 2008-08-31 21:32:29 UTC (rev 4568) +++ trunk/plugins/irc/irc.c 2008-09-01 09:15:58 UTC (rev 4569) @@ -2381,8 +2381,8 @@ irc_plugin_vars[23].value = pwd_realname; irc_plugin.params = irc_plugin_vars; - irc_plugin.protocol.protocols = irc_protocols; - irc_plugin.protocol.statuses = irc_statuses; + irc_plugin.priv.protocol.protocols = irc_protocols; + irc_plugin.priv.protocol.statuses = irc_statuses; plugin_register(&irc_plugin, prio); Modified: trunk/plugins/jabber/jabber.c =================================================================== --- trunk/plugins/jabber/jabber.c 2008-08-31 21:32:29 UTC (rev 4568) +++ trunk/plugins/jabber/jabber.c 2008-09-01 09:15:58 UTC (rev 4569) @@ -1623,8 +1623,8 @@ PLUGIN_CHECK_VER("jabber"); jabber_plugin.params = jabber_plugin_vars; - jabber_plugin.protocol.protocols = jabber_protocols; - jabber_plugin.protocol.statuses = jabber_statuses; + jabber_plugin.priv.protocol.protocols = jabber_protocols; + jabber_plugin.priv.protocol.statuses = jabber_statuses; plugin_register(&jabber_plugin, prio); Modified: trunk/plugins/jogger/jogger.c =================================================================== --- trunk/plugins/jogger/jogger.c 2008-08-31 21:32:29 UTC (rev 4568) +++ trunk/plugins/jogger/jogger.c 2008-09-01 09:15:58 UTC (rev 4569) @@ -280,7 +280,7 @@ PLUGIN_CHECK_VER("jogger"); jogger_plugin.params = jogger_plugin_vars; - jogger_plugin.protocol.protocols = jogger_protocols; + jogger_plugin.priv.protocol.protocols = jogger_protocols; /* statuses are not supported, we're just copying jabber session status */ query_connect_id(&jogger_plugin, PLUGIN_PRINT_VERSION, jogger_print_version, NULL); Modified: trunk/plugins/xmsg/xmsg.c =================================================================== --- trunk/plugins/xmsg/xmsg.c 2008-08-31 21:32:29 UTC (rev 4568) +++ trunk/plugins/xmsg/xmsg.c 2008-09-01 09:15:58 UTC (rev 4569) @@ -710,7 +710,7 @@ xdebug("inotify fd = %d", in_fd); xmsg_plugin.params = xmsg_plugin_vars; - xmsg_plugin.protocol.protocols = xmsg_protocols; + xmsg_plugin.priv.protocol.protocols = xmsg_protocols; /* statuses not supported */ plugin_register(&xmsg_plugin, prio); From svn w toxygen.net Mon Sep 1 11:29:28 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 11:29:28 +0200 (CEST) Subject: [ekg2-commit] r4570 - trunk/scons.d: trunk/scons.d/standard Message-ID: <20080901092928.42FB817B1F@toxygen.net> Author: peres Date: 2008-09-01 11:29:27 +0200 (Mon, 01 Sep 2008) New Revision: 4570 Modified: trunk/scons.d/standard Log: Fix libresolv detection with -std=c99. Modified: trunk/scons.d/standard =================================================================== --- trunk/scons.d/standard 2008-09-01 09:15:58 UTC (rev 4569) +++ trunk/scons.d/standard 2008-09-01 09:29:27 UTC (rev 4570) @@ -103,11 +103,13 @@ defines['STDERR_DEBUG'] = True if env['RESOLV']: + old = SetFlags(env, ['-D_GNU_SOURCE']) have_resolv = conf.CheckLibWithHeader(None, ['netinet/in.h', 'resolv.h'], 'C', 'dn_expand(NULL, NULL, NULL, NULL, 0);', 0) if not have_resolv: have_resolv = conf.CheckLibWithHeader('resolv', ['netinet/in.h', 'resolv.h'], 'C', 'dn_expand(NULL, NULL, NULL, NULL, 0);', 0) if have_resolv: ekg_libs.append('resolv') + RestoreFlags(env, old) else: have_resolv = False From svn w toxygen.net Mon Sep 1 11:30:05 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 11:30:05 +0200 (CEST) Subject: [ekg2-commit] r4571 - in trunk/plugins: dbus icq jabber mail rivchat: trunk/plugins/dbus/dbus_iface_im_ekg.c trunk/plugins/icq/icq_snac_handlers.c trunk/plugins/jabber/jabber.c trunk/plugins/mail/main.c trunk/plugins/rivchat/rivchat.c Message-ID: <20080901093006.03A0817B1F@toxygen.net> Author: peres Date: 2008-09-01 11:30:05 +0200 (Mon, 01 Sep 2008) New Revision: 4571 Modified: trunk/plugins/dbus/dbus_iface_im_ekg.c trunk/plugins/icq/icq_snac_handlers.c trunk/plugins/jabber/jabber.c trunk/plugins/mail/main.c trunk/plugins/rivchat/rivchat.c Log: Fix few warnings. Modified: trunk/plugins/dbus/dbus_iface_im_ekg.c =================================================================== --- trunk/plugins/dbus/dbus_iface_im_ekg.c 2008-09-01 09:29:27 UTC (rev 4570) +++ trunk/plugins/dbus/dbus_iface_im_ekg.c 2008-09-01 09:30:05 UTC (rev 4571) @@ -17,24 +17,25 @@ { #define __FUNCTION__ "ekg2_dbus_iface_im_ekg2_getSessions" EKG2_DBUS_CALL_HANDLER_VARIABLES; - list_t l; + session_t *sl; char x[1] = "", *tmp_descr, *tmp; EKG2_DBUS_INIT_REPLY; - for (l = sessions; l; l = l->next) + for (sl = sessions; sl; sl = sl->next) { - session_t *s = l->data; + session_t *s = sl; EKG2_DBUS_ADD_STRING(&(s->uid)); #warning "XXX: Old API here, need updating." + /* mg: updated? */ #if 0 EKG2_DBUS_ADD(DBUS_TYPE_BOOLEAN, &(s->connected)); #endif tmp = (char *)session_get(s, "status"); EKG2_DBUS_ADD_STRING(&tmp); /* XXX convert to utf before sending, d-bus sux? XXX */ - tmp = session_descr_get(s); + tmp = (char *)session_descr_get(s); tmp = xstrdup(tmp?tmp:""); tmp_descr = ekg_convert_string (tmp, NULL, "utf-8"); EKG2_DBUS_ADD_STRING(tmp_descr ? &tmp_descr : &tmp); Modified: trunk/plugins/icq/icq_snac_handlers.c =================================================================== --- trunk/plugins/icq/icq_snac_handlers.c 2008-09-01 09:29:27 UTC (rev 4570) +++ trunk/plugins/icq/icq_snac_handlers.c 2008-09-01 09:30:05 UTC (rev 4571) @@ -26,6 +26,7 @@ #include #include #include +#include #include "icq.h" #include "misc.h" Modified: trunk/plugins/jabber/jabber.c =================================================================== --- trunk/plugins/jabber/jabber.c 2008-09-01 09:29:27 UTC (rev 4570) +++ trunk/plugins/jabber/jabber.c 2008-09-01 09:30:05 UTC (rev 4571) @@ -1613,7 +1613,7 @@ */ static const char *jabber_protocols[] = { "xmpp:", "tlen:", NULL }; -static const int jabber_statuses[] = { +static const status_t jabber_statuses[] = { EKG_STATUS_NA, EKG_STATUS_DND, EKG_STATUS_XA, EKG_STATUS_AWAY, EKG_STATUS_AVAIL, EKG_STATUS_FFC, EKG_STATUS_INVISIBLE, EKG_STATUS_ERROR, EKG_STATUS_UNKNOWN, EKG_STATUS_NULL }; Modified: trunk/plugins/mail/main.c =================================================================== --- trunk/plugins/mail/main.c 2008-09-01 09:29:27 UTC (rev 4570) +++ trunk/plugins/mail/main.c 2008-09-01 09:30:05 UTC (rev 4571) @@ -141,7 +141,7 @@ else if (config_check_mail & 2) check_mail_maildir(); - return; /* we already checked all of them, so just ignore rest */ + return 0; /* we already checked all of them, so just ignore rest */ } } Modified: trunk/plugins/rivchat/rivchat.c =================================================================== --- trunk/plugins/rivchat/rivchat.c 2008-09-01 09:29:27 UTC (rev 4570) +++ trunk/plugins/rivchat/rivchat.c 2008-09-01 09:30:05 UTC (rev 4571) @@ -16,6 +16,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define _BSD_SOURCE 1 /* gethostname() */ #include #include #include From svn w toxygen.net Mon Sep 1 11:34:31 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 11:34:31 +0200 (CEST) Subject: [ekg2-commit] r4572 - in trunk: plugins/sniff scons.d: trunk/plugins/sniff/sniff.c trunk/scons.d/pcap Message-ID: <20080901093431.D4BC417B34@toxygen.net> Author: peres Date: 2008-09-01 11:34:31 +0200 (Mon, 01 Sep 2008) New Revision: 4572 Modified: trunk/plugins/sniff/sniff.c trunk/scons.d/pcap Log: Fix pcap/sniff with -std=c99. Modified: trunk/plugins/sniff/sniff.c =================================================================== --- trunk/plugins/sniff/sniff.c 2008-09-01 09:30:05 UTC (rev 4571) +++ trunk/plugins/sniff/sniff.c 2008-09-01 09:34:31 UTC (rev 4572) @@ -20,6 +20,7 @@ #include "ekg2-config.h" +#define _GNU_SOURCE #include #include Modified: trunk/scons.d/pcap =================================================================== --- trunk/scons.d/pcap 2008-09-01 09:30:05 UTC (rev 4571) +++ trunk/scons.d/pcap 2008-09-01 09:34:31 UTC (rev 4572) @@ -3,9 +3,11 @@ Import('*') +old = SetFlags(env, ['-D_GNU_SOURCE']) out = conf.CheckLibWithHeader('pcap', ['pcap.h'], 'C', 'pcap_open_live(NULL, 0, 0, 0, NULL);', 0) if (out): libs.append('pcap') +RestoreFlags(env, old) Return('out') From svn w toxygen.net Mon Sep 1 12:31:45 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 12:31:45 +0200 (CEST) Subject: [ekg2-commit] r4573 - trunk/plugins/irc: trunk/plugins/irc/misc.c Message-ID: <20080901103145.7D7E617B1F@toxygen.net> Author: peres Date: 2008-09-01 12:31:45 +0200 (Mon, 01 Sep 2008) New Revision: 4573 Modified: trunk/plugins/irc/misc.c Log: Colorful debug from IRC. Modified: trunk/plugins/irc/misc.c =================================================================== --- trunk/plugins/irc/misc.c 2008-09-01 09:34:31 UTC (rev 4572) +++ trunk/plugins/irc/misc.c 2008-09-01 10:31:45 UTC (rev 4573) @@ -393,9 +393,10 @@ /* debug only nasty hack ;> */ #ifdef GDEBUG + /* mg: well, it's not the exact data sent, but color is needed indeed */ i=0; - while (q[i] != NULL) debug("[%s]",q[i++]); - debug("\n"); + while (q[i] != NULL) debug_iorecv("[%s]",q[i++]); + debug_iorecv("\n"); #endif if (xstrlen(q[1]) > 1) { From svn w toxygen.net Mon Sep 1 15:13:40 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 15:13:40 +0200 (CEST) Subject: [ekg2-commit] r4574 - trunk/ekg: trunk/ekg/sessions.c Message-ID: <20080901131340.4FFFB17B1F@toxygen.net> Author: peres Date: 2008-09-01 15:13:39 +0200 (Mon, 01 Sep 2008) New Revision: 4574 Modified: trunk/ekg/sessions.c Log: Arrayize session_is_var(). Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 10:31:45 UTC (rev 4573) +++ trunk/ekg/sessions.c 2008-09-01 13:13:39 UTC (rev 4574) @@ -615,21 +615,17 @@ */ int session_is_var(session_t *s, const char *key) { + const char *intvars[] = { "alias", "descr", "status", "password", NULL }; + const char **intvar; + if (!s) return -1; - if (!xstrcasecmp(key, "alias")) - return 1; + /* XXX: maybe move this above !s? */ + for (intvar = intvars; *intvar; intvar++) + if (!xstrcasecmp(key, *intvar)) + return 1; - if (!xstrcasecmp(key, "descr")) - return 1; - - if (!xstrcasecmp(key, "status")) - return 1; - - if (!xstrcasecmp(key, "password")) - return 1; - /* so maybe _global_ session variable? */ return (plugin_var_find(s->plugin, key) != 0); } From svn w toxygen.net Mon Sep 1 15:13:49 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 15:13:49 +0200 (CEST) Subject: [ekg2-commit] r4575 - trunk/plugins/jogger: trunk/plugins/jogger/jogger.c Message-ID: <20080901131349.79C5817B1F@toxygen.net> Author: peres Date: 2008-09-01 15:13:49 +0200 (Mon, 01 Sep 2008) New Revision: 4575 Modified: trunk/plugins/jogger/jogger.c Log: Enable autodetection by default. Modified: trunk/plugins/jogger/jogger.c =================================================================== --- trunk/plugins/jogger/jogger.c 2008-09-01 13:13:39 UTC (rev 4574) +++ trunk/plugins/jogger/jogger.c 2008-09-01 13:13:49 UTC (rev 4575) @@ -265,7 +265,7 @@ PLUGIN_VAR_ADD("log_formats", VAR_STR, "simple,sqlite", 0, NULL), PLUGIN_VAR_ADD("newentry_open_query", VAR_BOOL, "1", 0, NULL), PLUGIN_VAR_ADD("own_commentformat", VAR_STR, NULL, 0, NULL), - PLUGIN_VAR_ADD("own_commentformat_autodetect", VAR_BOOL, "0", 0, NULL), + PLUGIN_VAR_ADD("own_commentformat_autodetect", VAR_BOOL, "1", 0, NULL), PLUGIN_VAR_ADD("used_session", VAR_STR, NULL, 0, jogger_usedchanged), PLUGIN_VAR_ADD("used_uid", VAR_STR, NULL, 0, jogger_usedchanged), PLUGIN_VAR_ADD("userlist_keep", VAR_BOOL, "0", 0, NULL), From svn w toxygen.net Mon Sep 1 15:46:20 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 15:46:20 +0200 (CEST) Subject: [ekg2-commit] r4576 - trunk/ekg: trunk/ekg/sessions.c Message-ID: <20080901134620.EC07417B1F@toxygen.net> Author: peres Date: 2008-09-01 15:46:20 +0200 (Mon, 01 Sep 2008) New Revision: 4576 Modified: trunk/ekg/sessions.c Log: statusdescr prototype. Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 13:13:49 UTC (rev 4575) +++ trunk/ekg/sessions.c 2008-09-01 13:46:20 UTC (rev 4576) @@ -527,6 +527,23 @@ PROPERTY_STRING_GET(session, uid) +const int session_statusdescr_set(session_t *s, const char *statusdescr) { + const char *descr = xstrchr(statusdescr, ' '); + const char *status; + + if (descr) { + status = xstrndup(statusdescr, (descr - statusdescr)); + descr++; + } else + status = statusdescr; + + debug_function("session_statusdescr_set(), status = %s, descr = %s\n", status, descr); + + if (descr) + xfree(status); /* was duplicated */ + return 1; +} + /* * session_localvar_find() * @@ -573,6 +590,9 @@ if (!xstrcasecmp(key, "status")) return ekg_status_string(session_status_get(s), 2); + + if (!xstrcasecmp(key, "statusdescr")) + return NULL; /* XXX? */ if (!xstrcasecmp(key, "password")) return session_password_get(s); @@ -615,7 +635,7 @@ */ int session_is_var(session_t *s, const char *key) { - const char *intvars[] = { "alias", "descr", "status", "password", NULL }; + const char *intvars[] = { "alias", "descr", "status", "password", "statusdescr", NULL }; const char **intvar; if (!s) @@ -671,6 +691,11 @@ goto notify; } + if (!xstrcasecmp(key, "statusdescr")) { + ret = session_statusdescr_set(s, value); + goto notify; + } + if (!xstrcasecmp(key, "password")) { if (s->connected && !session_get(s, "__new_password")) print("session_password_changed", session_name(s)); @@ -1112,6 +1137,7 @@ else if (!xstrcasecmp(key, "alias")) var = session_alias_get(s); else if (!xstrcasecmp(key, "descr")) var = session_descr_get(s); else if (!xstrcasecmp(key, "status")) var = ekg_status_string(session_status_get(s), 2); + else if (!xstrcasecmp(key, "statusdescr")) var = NULL; /* XXX? */ else if (!xstrcasecmp(key, "password")) { var = s->password ? "(...)" : NULL; } else if ((paid = plugin_var_find(s->plugin, key))) { plugins_params_t *pa = PLUGIN_VAR_FIND_BYID(s->plugin, paid); From svn w toxygen.net Mon Sep 1 16:03:03 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 16:03:03 +0200 (CEST) Subject: [ekg2-commit] r4577 - trunk/ekg: trunk/ekg/sessions.c trunk/ekg/sessions.h Message-ID: <20080901140303.729B117B1F@toxygen.net> Author: peres Date: 2008-09-01 16:03:02 +0200 (Mon, 01 Sep 2008) New Revision: 4577 Modified: trunk/ekg/sessions.c trunk/ekg/sessions.h Log: Second prototype, now with splitting function. Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 13:46:20 UTC (rev 4576) +++ trunk/ekg/sessions.c 2008-09-01 14:03:02 UTC (rev 4577) @@ -527,23 +527,37 @@ PROPERTY_STRING_GET(session, uid) -const int session_statusdescr_set(session_t *s, const char *statusdescr) { - const char *descr = xstrchr(statusdescr, ' '); - const char *status; +/* Splits statusdescr into status and descr. + * Returns status as status_t, and sets *statusdescr to descr. + * Doesn't modify original *statusdescr */ +const status_t session_statusdescr_split(const char **statusdescr) { + const char *descr = xstrchr(*statusdescr, ' '); + char *status = NULL; + status_t nstatus; if (descr) { - status = xstrndup(statusdescr, (descr - statusdescr)); + status = xstrndup(*statusdescr, (descr - *statusdescr)); descr++; - } else - status = statusdescr; + } - debug_function("session_statusdescr_set(), status = %s, descr = %s\n", status, descr); + nstatus = ekg_status_int(status ? status : *statusdescr); + *statusdescr = descr; if (descr) xfree(status); /* was duplicated */ - return 1; + + return nstatus; } +static const int session_statusdescr_set(session_t *s, const char *statusdescr) { + const char *descr = statusdescr; + status_t status = session_statusdescr_split(&descr); + + debug_function("session_statusdescr_set(), status = %s [%d], descr = %s\n", ekg_status_string(status, 2), status, descr); + + return (status == EKG_STATUS_NULL); +} + /* * session_localvar_find() * Modified: trunk/ekg/sessions.h =================================================================== --- trunk/ekg/sessions.h 2008-09-01 13:46:20 UTC (rev 4576) +++ trunk/ekg/sessions.h 2008-09-01 14:03:02 UTC (rev 4577) @@ -176,6 +176,8 @@ int session_connected_get(session_t *s); int session_connected_set(session_t *s, int connected); +const status_t session_statusdescr_split(const char **statusdescr); + const char *session_get(session_t *s, const char *key); int session_int_get(session_t *s, const char *key); int session_set(session_t *s, const char *key, const char *value); From svn w toxygen.net Mon Sep 1 16:15:23 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 16:15:23 +0200 (CEST) Subject: [ekg2-commit] r4578 - trunk/ekg: trunk/ekg/sessions.c Message-ID: <20080901141523.7182017B1F@toxygen.net> Author: peres Date: 2008-09-01 16:15:23 +0200 (Mon, 01 Sep 2008) New Revision: 4578 Modified: trunk/ekg/sessions.c Log: Now /session statusdescr should do something. Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 14:03:02 UTC (rev 4577) +++ trunk/ekg/sessions.c 2008-09-01 14:15:23 UTC (rev 4578) @@ -549,13 +549,20 @@ return nstatus; } +/* Just simple setter for both status&descr + * The real magic should be done in plugin-defined notify handler */ static const int session_statusdescr_set(session_t *s, const char *statusdescr) { - const char *descr = statusdescr; - status_t status = session_statusdescr_split(&descr); + const char *descr = statusdescr; + status_t status = session_statusdescr_split(&descr); debug_function("session_statusdescr_set(), status = %s [%d], descr = %s\n", ekg_status_string(status, 2), status, descr); - return (status == EKG_STATUS_NULL); + if (status == EKG_STATUS_NULL) return 1; /* if incorrect status, don't do anything! */ + + session_status_set(s, status); + session_descr_set(s, descr); + + return 0; } /* @@ -707,6 +714,9 @@ if (!xstrcasecmp(key, "statusdescr")) { ret = session_statusdescr_set(s, value); + + if (ret != 0) /* temporary workaround, see XXX @ notify: */ + return ret; goto notify; } @@ -738,7 +748,7 @@ return 0; notify: - if (pa && pa->notify) + if (pa && pa->notify) /* XXX: notify only when ret == 0 ? */ pa->notify(s, key); return ret; From svn w toxygen.net Mon Sep 1 16:16:40 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 16:16:40 +0200 (CEST) Subject: [ekg2-commit] r4579 - trunk/plugins/jogger: trunk/plugins/jogger/jogger.c Message-ID: <20080901141640.5A16117B1F@toxygen.net> Author: peres Date: 2008-09-01 16:16:39 +0200 (Mon, 01 Sep 2008) New Revision: 4579 Modified: trunk/plugins/jogger/jogger.c Log: Remove ol' jid->xmpp hack. Modified: trunk/plugins/jogger/jogger.c =================================================================== --- trunk/plugins/jogger/jogger.c 2008-09-01 14:15:23 UTC (rev 4578) +++ trunk/plugins/jogger/jogger.c 2008-09-01 14:16:39 UTC (rev 4579) @@ -132,18 +132,6 @@ static void jogger_usedchanged(session_t *s, const char *varname) { const char *tmp, *tmpb; - /* temporary jid: -> xmpp: hack */ - if (!xstrncasecmp(session_get(s, "used_session"), "jid:", 4)) { - char *tmp = saprintf("xmpp:%s", session_get(s, "used_session") + 4); - session_set(s, "used_session", tmp); - xfree(tmp); - } - if (!xstrncasecmp(session_get(s, "used_uid"), "jid:", 4)) { - char *tmp = saprintf("xmpp:%s", session_get(s, "used_uid") + 4); - session_set(s, "used_uid", tmp); - xfree(tmp); - } - /* /hack */ /* first check if session is correct */ session_t *js = session_find((tmp = session_get(s, "used_session"))); From svn w toxygen.net Mon Sep 1 17:14:46 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 17:14:46 +0200 (CEST) Subject: [ekg2-commit] r4580 - in trunk: ekg plugins/jabber: trunk/ekg/sessions.c trunk/plugins/jabber/jabber.c Message-ID: <20080901151446.5F81017B1F@toxygen.net> Author: peres Date: 2008-09-01 17:14:45 +0200 (Mon, 01 Sep 2008) New Revision: 4580 Modified: trunk/ekg/sessions.c trunk/plugins/jabber/jabber.c Log: Simple, working statusdescr for jabber. Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 14:16:39 UTC (rev 4579) +++ trunk/ekg/sessions.c 2008-09-01 15:14:45 UTC (rev 4580) @@ -552,16 +552,27 @@ /* Just simple setter for both status&descr * The real magic should be done in plugin-defined notify handler */ static const int session_statusdescr_set(session_t *s, const char *statusdescr) { - const char *descr = statusdescr; - status_t status = session_statusdescr_split(&descr); + const char *descr = statusdescr; + status_t status = session_statusdescr_split(&descr); + const char *label = ekg_status_label(status, descr, NULL); - debug_function("session_statusdescr_set(), status = %s [%d], descr = %s\n", ekg_status_string(status, 2), status, descr); + debug_function("session_statusdescr_set(), status = %s [%d], descr = %s, label = %s\n", + ekg_status_string(status, 2), status, descr, label); if (status == EKG_STATUS_NULL) return 1; /* if incorrect status, don't do anything! */ session_status_set(s, status); session_descr_set(s, descr); + session_unidle(s); + ekg_update_status(s); + /* XXX: maybe change _descr formats to carry session name as %1? + * currently this sucks more than ever. */ + if (descr) + print(label, descr, "", session_name(s)); + else + print(label, session_name(s)); + return 0; } Modified: trunk/plugins/jabber/jabber.c =================================================================== --- trunk/plugins/jabber/jabber.c 2008-09-01 14:16:39 UTC (rev 4579) +++ trunk/plugins/jabber/jabber.c 2008-09-01 15:14:45 UTC (rev 4580) @@ -1425,6 +1425,19 @@ xfree(msg); } +static void jabber_statusdescr_handler(session_t *s, const char *name) { + const char *descr = session_descr_get(s); + const status_t status = session_status_get(s); + const char *format = ekg_status_string(status, 0); + + /* well, it should be equal to one in session_statusdescr_set() + * this is why we print it */ + debug_function("jabber_statusdescr_handler(), status = %s [%d], descr = %s\n", ekg_status_string(status, 2), status, descr); + + if (session_connected_get(s)) + jabber_write_status(s); +} + /** * jabber_pgp_postinit() * @@ -1588,6 +1601,7 @@ PLUGIN_VAR_ADD("resource", VAR_STR, 0, 0, NULL), PLUGIN_VAR_ADD("server", VAR_STR, 0, 0, NULL), PLUGIN_VAR_ADD("ssl_port", VAR_INT, "5223", 0, NULL), + PLUGIN_VAR_ADD("statusdescr", VAR_STR, 0, 0, jabber_statusdescr_handler), PLUGIN_VAR_ADD("use_compression", VAR_STR, 0, 0, NULL), /* for instance: zlib,lzw */ PLUGIN_VAR_ADD("use_ssl", VAR_BOOL, "0", 0, NULL), PLUGIN_VAR_ADD("use_tls", VAR_BOOL, "1", 0, NULL), From svn w toxygen.net Mon Sep 1 17:24:31 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 17:24:31 +0200 (CEST) Subject: [ekg2-commit] r4581 - trunk/ekg: trunk/ekg/sessions.c Message-ID: <20080901152431.8771C17B34@toxygen.net> Author: peres Date: 2008-09-01 17:24:31 +0200 (Mon, 01 Sep 2008) New Revision: 4581 Modified: trunk/ekg/sessions.c Log: Fix displaying status after /session statusdescr. Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 15:14:45 UTC (rev 4580) +++ trunk/ekg/sessions.c 2008-09-01 15:24:31 UTC (rev 4581) @@ -554,7 +554,7 @@ static const int session_statusdescr_set(session_t *s, const char *statusdescr) { const char *descr = statusdescr; status_t status = session_statusdescr_split(&descr); - const char *label = ekg_status_label(status, descr, NULL); + const char *label = ekg_status_string(status, 1); debug_function("session_statusdescr_set(), status = %s [%d], descr = %s, label = %s\n", ekg_status_string(status, 2), status, descr, label); @@ -566,11 +566,12 @@ session_unidle(s); ekg_update_status(s); - /* XXX: maybe change _descr formats to carry session name as %1? - * currently this sucks more than ever. */ - if (descr) - print(label, descr, "", session_name(s)); - else + /* ok, we suck even more. formats for statuschanges are command-based. */ + if (descr) { + char l[xstrlen(label)+7]; + sprintf(l, "%s_descr", label); + print(l, descr, "", session_name(s)); + } else print(label, session_name(s)); return 0; @@ -1172,7 +1173,7 @@ else if (!xstrcasecmp(key, "alias")) var = session_alias_get(s); else if (!xstrcasecmp(key, "descr")) var = session_descr_get(s); else if (!xstrcasecmp(key, "status")) var = ekg_status_string(session_status_get(s), 2); - else if (!xstrcasecmp(key, "statusdescr")) var = NULL; /* XXX? */ + else if (!xstrcasecmp(key, "statusdescr")) return 0; /* workaround to disable display, XXX? */ else if (!xstrcasecmp(key, "password")) { var = s->password ? "(...)" : NULL; } else if ((paid = plugin_var_find(s->plugin, key))) { plugins_params_t *pa = PLUGIN_VAR_FIND_BYID(s->plugin, paid); From svn w toxygen.net Mon Sep 1 17:46:38 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 17:46:38 +0200 (CEST) Subject: [ekg2-commit] r4583 - trunk/ekg: trunk/ekg/sessions.c Message-ID: <20080901154638.3CDC317B3A@toxygen.net> Author: peres Date: 2008-09-01 17:46:37 +0200 (Mon, 01 Sep 2008) New Revision: 4583 Modified: trunk/ekg/sessions.c Log: Find nearest status available for plugin. Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 15:46:08 UTC (rev 4582) +++ trunk/ekg/sessions.c 2008-09-01 15:46:37 UTC (rev 4583) @@ -549,17 +549,43 @@ return nstatus; } +static inline status_t session_status_nearest(session_t *s, status_t status) { + plugin_t *p = s->plugin; + const status_t *ast; + + if (p->pclass != PLUGIN_PROTOCOL) { + debug_wtf("session_status_nearest(), session '%s' on non-protocol plugin '%s'!\n", session_uid_get(s), p->name); + return EKG_STATUS_NULL; + } + + for (; status < EKG_STATUS_LAST; status++) { + if (status <= EKG_STATUS_NA) continue; + + for (ast = p->priv.protocol.statuses; ast && (*ast != EKG_STATUS_NULL); ast++) { + if (*ast == status) /* is supported? */ + return status; + } + } + + return EKG_STATUS_NULL; +} + /* Just simple setter for both status&descr * The real magic should be done in plugin-defined notify handler */ static const int session_statusdescr_set(session_t *s, const char *statusdescr) { const char *descr = statusdescr; status_t status = session_statusdescr_split(&descr); - const char *label = ekg_status_string(status, 1); + const char *label; debug_function("session_statusdescr_set(), status = %s [%d], descr = %s, label = %s\n", ekg_status_string(status, 2), status, descr, label); - if (status == EKG_STATUS_NULL) return 1; /* if incorrect status, don't do anything! */ + if (status == EKG_STATUS_NULL) return 1; /* if incorrect status, don't do anything! */ + status = session_status_nearest(s, status); /* check whether plugin supports this status, if not find nearest */ + if (status == EKG_STATUS_NULL) { + debug_function("session_statusdescr_set(), status setting on session '%s' not supported\n", session_uid_get(s)); + return 1; + } session_status_set(s, status); session_descr_set(s, descr); @@ -567,6 +593,7 @@ ekg_update_status(s); /* ok, we suck even more. formats for statuschanges are command-based. */ + label = ekg_status_string(status, 1); if (descr) { char l[xstrlen(label)+7]; sprintf(l, "%s_descr", label); From svn w toxygen.net Mon Sep 1 17:53:53 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 17:53:53 +0200 (CEST) Subject: [ekg2-commit] r4584 - trunk/ekg: trunk/ekg/sessions.c Message-ID: <20080901155353.46A9E17B3A@toxygen.net> Author: peres Date: 2008-09-01 17:53:52 +0200 (Mon, 01 Sep 2008) New Revision: 4584 Modified: trunk/ekg/sessions.c Log: Fix debug in e_sd_set(). Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 15:46:37 UTC (rev 4583) +++ trunk/ekg/sessions.c 2008-09-01 15:53:52 UTC (rev 4584) @@ -577,8 +577,8 @@ status_t status = session_statusdescr_split(&descr); const char *label; - debug_function("session_statusdescr_set(), status = %s [%d], descr = %s, label = %s\n", - ekg_status_string(status, 2), status, descr, label); + debug_function("session_statusdescr_set(), status = %s [%d], descr = %s\n", + ekg_status_string(status, 2), status, descr); if (status == EKG_STATUS_NULL) return 1; /* if incorrect status, don't do anything! */ status = session_status_nearest(s, status); /* check whether plugin supports this status, if not find nearest */ @@ -594,6 +594,9 @@ /* ok, we suck even more. formats for statuschanges are command-based. */ label = ekg_status_string(status, 1); + debug_function("session_statusdescr_set(), -> status = %s [%d], label = %s\n", + ekg_status_string(status, 2), status, label); + if (descr) { char l[xstrlen(label)+7]; sprintf(l, "%s_descr", label); From svn w toxygen.net Mon Sep 1 18:11:30 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 18:11:30 +0200 (CEST) Subject: [ekg2-commit] r4585 - trunk/ekg: trunk/ekg/stuff.c Message-ID: <20080901161130.2E90317B40@toxygen.net> Author: peres Date: 2008-09-01 18:11:29 +0200 (Mon, 01 Sep 2008) New Revision: 4585 Modified: trunk/ekg/stuff.c Log: Optimize status_find() when ekg_statuses[] are sorted with status_t. Modified: trunk/ekg/stuff.c =================================================================== --- trunk/ekg/stuff.c 2008-09-01 15:53:52 UTC (rev 4584) +++ trunk/ekg/stuff.c 2008-09-01 16:11:29 UTC (rev 4585) @@ -2455,6 +2455,7 @@ const char* command; /* command used to set status, if ==format, NULL */ }; +/* please, keep it sorted with status_t */ const struct ekg_status_info ekg_statuses[] = { { EKG_STATUS_ERROR, "error" }, { EKG_STATUS_BLOCKED, "blocking" }, @@ -2478,6 +2479,19 @@ static inline const struct ekg_status_info *status_find(const int status) { const struct ekg_status_info *s; + /* as long as ekg_statuses[] are sorted, this should be fast */ + if (status < EKG_STATUS_LAST) { + for (s = &(ekg_statuses[status-1]); s->status != EKG_STATUS_NULL; s++) { + if (s->status == status) + return s; + } + } + + debug_function("status_find(), going into fallback loop (statuses ain't sorted?)\n"); + + /* fallback if statuses aren't sorted, we've got unknown or special status, + * in second case we'll iterate part of list twice, but that's rather + * rare case, so I think optimization isn't needed here. */ for (s = ekg_statuses; s->status != EKG_STATUS_NULL; s++) { if (s->status == status) return s; From svn w toxygen.net Mon Sep 1 17:46:08 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 17:46:08 +0200 (CEST) Subject: [ekg2-commit] r4582 - trunk/ekg: trunk/ekg/plugins.h trunk/ekg/sessions.h Message-ID: <20080901154608.9797C17B1F@toxygen.net> Author: peres Date: 2008-09-01 17:46:08 +0200 (Mon, 01 Sep 2008) New Revision: 4582 Modified: trunk/ekg/plugins.h trunk/ekg/sessions.h Log: Remove 'codepoints' for statuses, add EKG_STATUS_LAST. Modified: trunk/ekg/plugins.h =================================================================== --- trunk/ekg/plugins.h 2008-09-01 15:24:31 UTC (rev 4581) +++ trunk/ekg/plugins.h 2008-09-01 15:46:08 UTC (rev 4582) @@ -26,7 +26,7 @@ #include "dynstuff.h" #include "sessions.h" -#define EKG_ABI_VER 4561 +#define EKG_ABI_VER 4582 #define EXPORT __attribute__ ((visibility("default"))) Modified: trunk/ekg/sessions.h =================================================================== --- trunk/ekg/sessions.h 2008-09-01 15:24:31 UTC (rev 4581) +++ trunk/ekg/sessions.h 2008-09-01 15:46:08 UTC (rev 4582) @@ -40,8 +40,8 @@ EKG_STATUS_BLOCKED, /* used in GG */ /* These statuses should be considered as 'not sure' */ - EKG_STATUS_UNKNOWN = 0x10, /* used in Jabber */ - EKG_STATUS_NA = 0x20, /* universal */ + EKG_STATUS_UNKNOWN, /* used in Jabber */ + EKG_STATUS_NA, /* universal */ /* These should be considered as 'probably available' */ EKG_STATUS_INVISIBLE, /* GG; hard to prioritize... */ @@ -51,9 +51,11 @@ EKG_STATUS_AWAY, /* universal */ /* These should be considered as 'sure available' */ - EKG_STATUS_AVAIL = 0x40, /* universal */ + EKG_STATUS_AVAIL, /* universal */ EKG_STATUS_FFC, /* Jabber */ + EKG_STATUS_LAST, + /* XXX: autostatuses are going to be rewritten and then below will be removed */ /* These are special statuses, which are to be used only with dedicated functions */ EKG_STATUS_AUTOAWAY = 0x80, /* putting in auto-away */ EKG_STATUS_AUTOXA, /* putting in auto-xa */ From svn w toxygen.net Mon Sep 1 20:07:05 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 20:07:05 +0200 (CEST) Subject: [ekg2-commit] r4586 - trunk/plugins/icq: trunk/plugins/icq/icq.c trunk/plugins/icq/icq.h trunk/plugins/icq/icq_snac_handlers_01service.inc trunk/plugins/icq/icq_snac_handlers_13userlist.inc Message-ID: <20080901180705.5C85C17B1F@toxygen.net> Author: wiechu Date: 2008-09-01 20:07:04 +0200 (Mon, 01 Sep 2008) New Revision: 4586 Modified: trunk/plugins/icq/icq.c trunk/plugins/icq/icq.h trunk/plugins/icq/icq_snac_handlers_01service.inc trunk/plugins/icq/icq_snac_handlers_13userlist.inc Log: add few new icq format Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-01 16:11:29 UTC (rev 4585) +++ trunk/plugins/icq/icq.c 2008-09-01 18:07:04 UTC (rev 4586) @@ -1410,6 +1410,8 @@ static int icq_theme_init() { #ifndef NO_DEFAULT_THEME format_add("icq_auth_subscribe", _("%> (%1) %T%2%n asks for authorisation. Use \"/auth -a %2\" to accept, \"/auth -d %2 [reason]\" to refuse. Reason: %T%3%n"), 1); + format_add("icq_auth_decline", _("%> (%1) %2 decline your authorization: %3\n"), 1); + format_add("icq_auth_grant", _("%> (%1) %2 grant your authorization: %3\n"), 1); format_add("icq_userinfo_start", "%g,+=%G----- %g%3%G info for: %Ticq:%2%n", 1); @@ -1428,7 +1430,7 @@ format_add("icq_rates_header", "%>%n # %K|%n Curr %K|%n Alrt %K|%n Limt %K|%n Clear %K|%n Dscn %K|%n Max %K|%nwin %K|%n\n", 1); format_add("icq_rates", "%>%n%[-2]1 %K|%n%[-5]7 %K|%n%[-5]4 %K|%n%[-5]5 %K|%n%[-6]3 %K|%n%[-5]6 %K|%n%[-5]8 %K|%n%[-3]2 %K|%n\n", 1); - format_add("icq_you_were_added", "%> %R%1 add you to contact list", 1); + format_add("icq_you_were_added", "%> (%1) %2 adds you to contact list\n", 1); #endif return 0; Modified: trunk/plugins/icq/icq.h =================================================================== --- trunk/plugins/icq/icq.h 2008-09-01 16:11:29 UTC (rev 4585) +++ trunk/plugins/icq/icq.h 2008-09-01 18:07:04 UTC (rev 4586) @@ -20,7 +20,7 @@ int curr_lvl; // Current level int max_lvl; // Max level int n_groups; - int *groups; + uint32_t *groups; } icq_rate_t; typedef struct icq_snac_reference_list_s { Modified: trunk/plugins/icq/icq_snac_handlers_01service.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_01service.inc 2008-09-01 16:11:29 UTC (rev 4585) +++ trunk/plugins/icq/icq_snac_handlers_01service.inc 2008-09-01 18:07:04 UTC (rev 4586) @@ -107,6 +107,10 @@ struct { uint16_t no; // Number of rate classes } pkt; + struct { + uint16_t cl; // Class + uint16_t no; // Number of rate groups + } pkt2; int i; if (!ICQ_UNPACK(&buf, "W", &pkt.no)) @@ -132,9 +136,20 @@ j->rates[id]->max_lvl = x6; // Max level } } - // XXX ?wo? handle rate groups -// icq_hexdump(DEBUG_ERROR, buf, len); + // store rate groups + while (len >= 4) { + (void) ICQ_UNPACK(&buf, "WW", &pkt2.cl, &pkt2.no); + if (pkt2.cl > j->n_rates) goto wrong; + if (len < pkt2.no*4) goto wrong; + pkt2.cl--; + j->rates[pkt2.cl]->groups = xcalloc(pkt2.no, sizeof(uint32_t)); + j->rates[pkt2.cl]->n_groups = pkt2.no; + for (i=0; irates[pkt2.cl]->groups[i]); + } + } + wrong: /* ack rate levels */ Modified: trunk/plugins/icq/icq_snac_handlers_13userlist.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_13userlist.inc 2008-09-01 16:11:29 UTC (rev 4585) +++ trunk/plugins/icq/icq_snac_handlers_13userlist.inc 2008-09-01 18:07:04 UTC (rev 4586) @@ -492,17 +492,16 @@ if (!ICQ_UNPACK(&buf, "U", &pkt.reason)) pkt.reason = ""; /* XXX, spammer */ - // XXX ?wo? add format & display in status window switch (pkt.flag) { case 0: - debug_error("%s - %s decline your authorization: %s", session_name(s), uid, pkt.reason); - break; case 1: { userlist_t *u = userlist_find(s, uid); - if (u) + if (u && pkt.flag) user_private_item_set_int(u, "auth", 0); - debug_error("%s - %s grant your authorization: %s", session_name(s), uid, pkt.reason); + + print_info(uid, s, pkt.flag ? "icq_auth_grant" : "icq_auth_decline", session_name(s), format_user(s, uid), pkt.reason); + break; } default: @@ -517,19 +516,22 @@ } SNAC_SUBHANDLER(icq_snac_userlist_you_were_added) { -int quiet=0; struct { char *uid; } pkt; char *uid; + userlist_t *u; if (!ICQ_UNPACK(&buf, "u", &pkt.uid)) return -1; - - // XXX ?wo? add format & display in status window + uid = icq_uid(pkt.uid); - debug_white("You were added %s %s\n", session_name(s), uid); - printq("icq_you_were_added", uid); + + print_info(uid, s, "icq_you_were_added", session_name(s), format_user(s, uid)); + + if ( config_auto_user_add && !(u = userlist_find(s, uid)) ) + u = userlist_add(s, uid, uid); + xfree(uid); return 0; From svn w toxygen.net Mon Sep 1 20:22:03 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 20:22:03 +0200 (CEST) Subject: [ekg2-commit] r4587 - in trunk: ekg plugins/irc plugins/jabber: trunk/ekg/sessions.c trunk/plugins/irc/irc.c trunk/plugins/jabber/jabber.c Message-ID: <20080901182203.53FBA17B1F@toxygen.net> Author: peres Date: 2008-09-01 20:22:02 +0200 (Mon, 01 Sep 2008) New Revision: 4587 Modified: trunk/ekg/sessions.c trunk/plugins/irc/irc.c trunk/plugins/jabber/jabber.c Log: Call statusdescr notify only when session is connected. Support statusdescr in IRC. XXX: don't write statuschange twice. Maybe p->priv.protocol.printstatus? Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 18:07:04 UTC (rev 4586) +++ trunk/ekg/sessions.c 2008-09-01 18:22:02 UTC (rev 4587) @@ -188,6 +188,10 @@ s->values[i] = xstrdup(value); + /* sorry, but to simplify plugin writing we've to assure handler + * is never called with nonconnected session */ + if (!xstrcasecmp(key, "statusdescr")) + continue; /* notify plugin, like session_set() do */ if (pl->params[i].notify) pl->params[i].notify(s, key); @@ -580,11 +584,11 @@ debug_function("session_statusdescr_set(), status = %s [%d], descr = %s\n", ekg_status_string(status, 2), status, descr); - if (status == EKG_STATUS_NULL) return 1; /* if incorrect status, don't do anything! */ + if (status == EKG_STATUS_NULL) return -1; /* if incorrect status, don't do anything! */ status = session_status_nearest(s, status); /* check whether plugin supports this status, if not find nearest */ if (status == EKG_STATUS_NULL) { debug_function("session_statusdescr_set(), status setting on session '%s' not supported\n", session_uid_get(s)); - return 1; + return -1; } session_status_set(s, status); @@ -757,7 +761,7 @@ if (!xstrcasecmp(key, "statusdescr")) { ret = session_statusdescr_set(s, value); - if (ret != 0) /* temporary workaround, see XXX @ notify: */ + if (ret != 0 || !session_connected_get(s)) /* temporary workaround, see XXX @ notify: + don't notify when not connected */ return ret; goto notify; } Modified: trunk/plugins/irc/irc.c =================================================================== --- trunk/plugins/irc/irc.c 2008-09-01 18:07:04 UTC (rev 4586) +++ trunk/plugins/irc/irc.c 2008-09-01 18:22:02 UTC (rev 4587) @@ -1365,6 +1365,35 @@ return -1; } +static void irc_display_awaylog(session_t *session) { + irc_private_t *j = irc_private(session); + + if (j->awaylog) { + list_t l; + const char *awaylog_timestampf = format_find("irc_awaylog_timestamp"); + + print_status("irc_awaylog_begin", session_name(session)); + for (l = j->awaylog; l; l = l->next) { + irc_awaylog_t *e = l->data; + + if (e->channame) + print_status("irc_awaylog_msg_chan", session_name(session), + timestamp_time(awaylog_timestampf, e->t), (e->channame)+4, (e->uid)+4, e->msg); + else + print_status("irc_awaylog_msg", session_name(session), + timestamp_time(awaylog_timestampf, e->t), "", (e->uid)+4, e->msg); + + xfree(e->channame); + xfree(e->uid); + xfree(e->msg); + } + print_status("irc_awaylog_end", session_name(session)); + + list_destroy(j->awaylog, 1); + j->awaylog = NULL; + } +} + static COMMAND(irc_command_away) { irc_private_t *j = irc_private(session); int isaway = 0; @@ -1399,33 +1428,27 @@ watch_write(j->send_watch, "AWAY :\r\n"); /* @ back, display awaylog. */ + irc_display_awaylog(session); + } + return 0; +} - if (j->awaylog) { - list_t l; - const char *awaylog_timestampf = format_find("irc_awaylog_timestamp"); +static void irc_statusdescr_handler(session_t *s, const char *varname) { + irc_private_t *j = irc_private(s); + const status_t status = session_status_get(s); - print_status("irc_awaylog_begin", session_name(session)); - for (l = j->awaylog; l; l = l->next) { - irc_awaylog_t *e = l->data; + if (status == EKG_STATUS_AWAY) { + const char *descr = session_descr_get(s); + if (descr) + watch_write(j->send_watch, "AWAY :%s\r\n", descr); + else + watch_write(j->send_watch, "AWAY :%s\r\n", ekg_status_string(status, 0)); + } else { + watch_write(j->send_watch, "AWAY :\r\n"); - if (e->channame) - print_status("irc_awaylog_msg_chan", session_name(session), - timestamp_time(awaylog_timestampf, e->t), (e->channame)+4, (e->uid)+4, e->msg); - else - print_status("irc_awaylog_msg", session_name(session), - timestamp_time(awaylog_timestampf, e->t), "", (e->uid)+4, e->msg); - - xfree(e->channame); - xfree(e->uid); - xfree(e->msg); - } - print_status("irc_awaylog_end", session_name(session)); - - list_destroy(j->awaylog, 1); - j->awaylog = NULL; - } + /* @ back, display awaylog. */ + irc_display_awaylog(s); } - return 0; } /*****************************************************************************/ @@ -2320,6 +2343,7 @@ PLUGIN_VAR_ADD("recode_list", VAR_STR, NULL, 0, irc_changed_recode_list), PLUGIN_VAR_ADD("recode_out_default_charset", VAR_STR, NULL, 0, irc_changed_recode), /* irssi-like-variable */ PLUGIN_VAR_ADD("server", VAR_STR, 0, 0, irc_changed_resolve), + PLUGIN_VAR_ADD("statusdescr", VAR_STR, 0, 0, irc_statusdescr_handler), /* upper case: names of variables, that reffer to protocol stuff */ PLUGIN_VAR_ADD("AUTO_JOIN", VAR_STR, 0, 0, NULL), Modified: trunk/plugins/jabber/jabber.c =================================================================== --- trunk/plugins/jabber/jabber.c 2008-09-01 18:07:04 UTC (rev 4586) +++ trunk/plugins/jabber/jabber.c 2008-09-01 18:22:02 UTC (rev 4587) @@ -1426,16 +1426,7 @@ } static void jabber_statusdescr_handler(session_t *s, const char *name) { - const char *descr = session_descr_get(s); - const status_t status = session_status_get(s); - const char *format = ekg_status_string(status, 0); - - /* well, it should be equal to one in session_statusdescr_set() - * this is why we print it */ - debug_function("jabber_statusdescr_handler(), status = %s [%d], descr = %s\n", ekg_status_string(status, 2), status, descr); - - if (session_connected_get(s)) - jabber_write_status(s); + jabber_write_status(s); } /** From svn w toxygen.net Mon Sep 1 20:33:34 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 20:33:34 +0200 (CEST) Subject: [ekg2-commit] r4588 - trunk/plugins/gg: trunk/plugins/gg/gg.c Message-ID: <20080901183334.3FB9F17B1F@toxygen.net> Author: peres Date: 2008-09-01 20:33:33 +0200 (Mon, 01 Sep 2008) New Revision: 4588 Modified: trunk/plugins/gg/gg.c Log: statusdescr in GG. Can some check it? XXX: support for descr too long / scrolling? Modified: trunk/plugins/gg/gg.c =================================================================== --- trunk/plugins/gg/gg.c 2008-09-01 18:22:02 UTC (rev 4587) +++ trunk/plugins/gg/gg.c 2008-09-01 18:33:33 UTC (rev 4588) @@ -1506,6 +1506,20 @@ array_free(auth); } +static void gg_statusdescr_handler(session_t *s, const char *varname) { + gg_private_t *g = session_private_get(s); + char *cpdescr = gg_locale_to_cp(xstrdup(session_descr_get(s))); + int _status = GG_S(gg_text_to_status(session_status_get(s), cpdescr)); + + if (session_int_get(s, "private")) + _status |= GG_STATUS_FRIENDS_MASK; + + if (cpdescr) gg_change_status_descr(g->sess, _status, cpdescr); + else gg_change_status(g->sess, _status); + + xfree(cpdescr); +} + static int gg_theme_init() { #ifndef NO_DEFAULT_THEME format_add("gg_version", _("%> %TGadu-Gadu%n: libgadu %g%1%n (headers %c%2%n), protocol %g%3%n (%c0x%4%n)"), 1); @@ -1628,6 +1642,7 @@ PLUGIN_VAR_ADD("scroll_long_desc", VAR_INT, "0", 0, NULL), PLUGIN_VAR_ADD("scroll_mode", VAR_STR, "bounce", 0, NULL), PLUGIN_VAR_ADD("server", VAR_STR, NULL, 0, NULL), + PLUGIN_VAR_ADD("statusdescr", VAR_STR, NULL, 0, gg_statusdescr_handler), PLUGIN_VAR_END() }; From svn w toxygen.net Mon Sep 1 20:44:20 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 20:44:20 +0200 (CEST) Subject: [ekg2-commit] r4589 - trunk/ekg: trunk/ekg/sessions.c trunk/ekg/sessions.h Message-ID: <20080901184420.B8B1317B1F@toxygen.net> Author: peres Date: 2008-09-01 20:44:20 +0200 (Mon, 01 Sep 2008) New Revision: 4589 Modified: trunk/ekg/sessions.c trunk/ekg/sessions.h Log: Well, we can't deliver full statusdescr string to plugin, so splitfunction doesn't need to be public. Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 18:33:33 UTC (rev 4588) +++ trunk/ekg/sessions.c 2008-09-01 18:44:20 UTC (rev 4589) @@ -534,7 +534,7 @@ /* Splits statusdescr into status and descr. * Returns status as status_t, and sets *statusdescr to descr. * Doesn't modify original *statusdescr */ -const status_t session_statusdescr_split(const char **statusdescr) { +static inline const status_t session_statusdescr_split(const char **statusdescr) { const char *descr = xstrchr(*statusdescr, ' '); char *status = NULL; status_t nstatus; Modified: trunk/ekg/sessions.h =================================================================== --- trunk/ekg/sessions.h 2008-09-01 18:33:33 UTC (rev 4588) +++ trunk/ekg/sessions.h 2008-09-01 18:44:20 UTC (rev 4589) @@ -178,8 +178,6 @@ int session_connected_get(session_t *s); int session_connected_set(session_t *s, int connected); -const status_t session_statusdescr_split(const char **statusdescr); - const char *session_get(session_t *s, const char *key); int session_int_get(session_t *s, const char *key); int session_set(session_t *s, const char *key, const char *value); From svn w toxygen.net Mon Sep 1 21:00:56 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 21:00:56 +0200 (CEST) Subject: [ekg2-commit] r4590 - trunk/ekg: trunk/ekg/legacyconfig.c trunk/ekg/themes.c Message-ID: <20080901190056.8768C17B1F@toxygen.net> Author: wiechu Date: 2008-09-01 21:00:56 +0200 (Mon, 01 Sep 2008) New Revision: 4590 Modified: trunk/ekg/legacyconfig.c trunk/ekg/themes.c Log: Big, fat warning: "Use --enable-unicode!" Modified: trunk/ekg/legacyconfig.c =================================================================== --- trunk/ekg/legacyconfig.c 2008-09-01 18:44:20 UTC (rev 4589) +++ trunk/ekg/legacyconfig.c 2008-09-01 19:00:56 UTC (rev 4590) @@ -30,6 +30,13 @@ void config_upgrade() { const int current_config_version = 6; +#if ! USE_UNICODE + if (!xstrcasecmp(config_console_charset, "UTF-8")) { + print("config_error", _("Warning, nl_langinfo(CODESET) reports that you are using utf-8 encoding, but you didn't compile ekg2 with (experimental/untested) --enable-unicode\n" + "\tPlease compile ekg2 with --enable-unicode or change your enviroment setting to use not utf-8 but iso-8859-1 maybe? (LC_ALL/LC_CTYPE)\n")); + } +#endif + if (xstrcasecmp(console_charset, config_console_charset)) print("console_charset_bad", console_charset, config_console_charset); else if (config_version == 0) Modified: trunk/ekg/themes.c =================================================================== --- trunk/ekg/themes.c 2008-09-01 18:44:20 UTC (rev 4589) +++ trunk/ekg/themes.c 2008-09-01 19:00:56 UTC (rev 4590) @@ -1625,6 +1625,7 @@ format_add("error_reading_config", _("%! Error reading configuration file: %1\n"), 1); format_add("config_read_success", _("%> Configuratin read correctly.%n\n"), 1); format_add("config_line_incorrect", _("%! Invalid line '%T%1%n', skipping\n"), 1); + format_add("config_error", _("%! %R%|%R%1\n"), 1); format_add("autosaved", _("%> Automatically saved settings\n"), 1); /* config_upgrade() */ From svn w toxygen.net Mon Sep 1 21:05:25 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 21:05:25 +0200 (CEST) Subject: [ekg2-commit] r4591 - trunk/ekg: trunk/ekg/commands.c Message-ID: <20080901190525.CF64117B1F@toxygen.net> Author: wiechu Date: 2008-09-01 21:05:25 +0200 (Mon, 01 Sep 2008) New Revision: 4591 Modified: trunk/ekg/commands.c Log: fix warning Modified: trunk/ekg/commands.c =================================================================== --- trunk/ekg/commands.c 2008-09-01 19:00:56 UTC (rev 4590) +++ trunk/ekg/commands.c 2008-09-01 19:05:25 UTC (rev 4591) @@ -2029,6 +2029,7 @@ xfree(_sts); } } + return 0; } static COMMAND(cmd_debug_timers) { From svn w toxygen.net Mon Sep 1 21:12:08 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 21:12:08 +0200 (CEST) Subject: [ekg2-commit] r4592 - in trunk: ekg plugins/dbus plugins/gg plugins/icq plugins/irc plugins/jabber plugins/jogger plugins/xmsg: trunk/ekg/commands.c trunk/ekg/plugins.h trunk/ekg/sessions.c trunk/plugins/dbus/dbus_iface_im.c trunk/plugins/gg/gg.c trunk/plugins/icq/icq.c trunk/plugins/irc/irc.c trunk/plugins/jabber/jabber.c trunk/plugins/jogger/jogger.c trunk/plugins/xmsg/xmsg.c Message-ID: <20080901191208.51ABE17B1F@toxygen.net> Author: peres Date: 2008-09-01 21:12:07 +0200 (Mon, 01 Sep 2008) New Revision: 4592 Modified: trunk/ekg/commands.c trunk/ekg/plugins.h trunk/ekg/sessions.c trunk/plugins/dbus/dbus_iface_im.c trunk/plugins/gg/gg.c trunk/plugins/icq/icq.c trunk/plugins/irc/irc.c trunk/plugins/jabber/jabber.c trunk/plugins/jogger/jogger.c trunk/plugins/xmsg/xmsg.c Log: Non-anonymous unions suck, so moving to struct*. Modified: trunk/ekg/commands.c =================================================================== --- trunk/ekg/commands.c 2008-09-01 19:05:25 UTC (rev 4591) +++ trunk/ekg/commands.c 2008-09-01 19:12:07 UTC (rev 4592) @@ -2009,13 +2009,15 @@ snprintf(buf, sizeof(buf), "%-15s %-10s %-3d", p->name, class, p->prio); printq("generic", buf); - if (p->pclass == PLUGIN_PROTOCOL) { - char *pr = array_join((char**) p->priv.protocol.protocols, ", "); + if (p->pclass == PLUGIN_PROTOCOL && p->priv) { + struct protocol_plugin_priv *pp = p->priv; + + char *pr = array_join((char**) pp->protocols, ", "); char *st; char **_sts = NULL; const status_t *_st; - for (_st = p->priv.protocol.statuses; *_st != EKG_STATUS_NULL; _st++) { + for (_st = pp->statuses; *_st != EKG_STATUS_NULL; _st++) { array_add(&_sts, (char*) ekg_status_string(*_st, 2)); } st = array_join(_sts, ", "); Modified: trunk/ekg/plugins.h =================================================================== --- trunk/ekg/plugins.h 2008-09-01 19:05:25 UTC (rev 4591) +++ trunk/ekg/plugins.h 2008-09-01 19:12:07 UTC (rev 4592) @@ -26,7 +26,7 @@ #include "dynstuff.h" #include "sessions.h" -#define EKG_ABI_VER 4582 +#define EKG_ABI_VER 4592 #define EXPORT __attribute__ ((visibility("default"))) @@ -59,6 +59,11 @@ plugin_notify_func_t *notify; /* notify */ } plugins_params_t; +struct protocol_plugin_priv { + const char **protocols; /* NULL-terminated list of supported protocols, replacing GET_PLUGIN_PROTOCOLS */ + const status_t *statuses; /* EKG_STATUS_NULL-terminated list of supported statuses */ +}; + typedef struct plugin { struct plugin *next; @@ -69,13 +74,8 @@ /* lt_dlhandle */ void *dl; plugins_params_t *params; plugin_theme_init_func_t theme_init; - - union { /* based on pclass */ - struct { - const char **protocols; /* NULL-terminated list of supported protocols, replacing GET_PLUGIN_PROTOCOLS */ - const status_t *statuses; /* EKG_STATUS_NULL-terminated list of supported statuses */ - } protocol; - } priv; + + const void *priv; } plugin_t; /* Note about plugin_t.statuses: Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 19:05:25 UTC (rev 4591) +++ trunk/ekg/sessions.c 2008-09-01 19:12:07 UTC (rev 4592) @@ -554,18 +554,22 @@ } static inline status_t session_status_nearest(session_t *s, status_t status) { - plugin_t *p = s->plugin; - const status_t *ast; + plugin_t *p = s->plugin; + struct protocol_plugin_priv *pp = p->priv; + const status_t *ast; if (p->pclass != PLUGIN_PROTOCOL) { debug_wtf("session_status_nearest(), session '%s' on non-protocol plugin '%s'!\n", session_uid_get(s), p->name); return EKG_STATUS_NULL; + } else if (!p->priv) { + debug_warn("session_status_nearest(), plugin '%s' doesn't declared supported statuses.\n", p->name); + return status; } for (; status < EKG_STATUS_LAST; status++) { if (status <= EKG_STATUS_NA) continue; - for (ast = p->priv.protocol.statuses; ast && (*ast != EKG_STATUS_NULL); ast++) { + for (ast = pp->statuses; ast && (*ast != EKG_STATUS_NULL); ast++) { if (*ast == status) /* is supported? */ return status; } Modified: trunk/plugins/dbus/dbus_iface_im.c =================================================================== --- trunk/plugins/dbus/dbus_iface_im.c 2008-09-01 19:05:25 UTC (rev 4591) +++ trunk/plugins/dbus/dbus_iface_im.c 2008-09-01 19:12:07 UTC (rev 4592) @@ -27,10 +27,11 @@ EKG2_DBUS_INIT_REPLY; for (p = plugins; p; p = p->next) { - if (p->pclass == PLUGIN_PROTOCOL) { + if (p->pclass == PLUGIN_PROTOCOL && p->priv) { + struct protocol_plugin_priv *pp = p->priv; const char **a; - for (a = p->priv.protocol.protocols; *a; a++) + for (a = pp->protocols; *a; a++) EKG2_DBUS_ADD_STRING(a); } } @@ -106,10 +107,11 @@ reply = dbus_message_new_method_return(msg); dbus_message_iter_init_append(reply, &args); for (p = plugins; p; p = p->next) { - if (p->pclass == PLUGIN_PROTOCOL) { + if (p->pclass == PLUGIN_PROTOCOL && p->priv) { + struct protocol_plugin_priv *pp = p->priv; const char **a; - for (a = p->priv.protocol.protocols; *a; a++) { + for (a = pp->protocols; *a; a++) { if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, a)) { debug("ekg2_dbus_iface_im_getProtocols cannot allocate memory?\n"); ekg_oom_handler(); Modified: trunk/plugins/gg/gg.c =================================================================== --- trunk/plugins/gg/gg.c 2008-09-01 19:05:25 UTC (rev 4591) +++ trunk/plugins/gg/gg.c 2008-09-01 19:12:07 UTC (rev 4592) @@ -1653,14 +1653,18 @@ EKG_STATUS_BLOCKED, EKG_STATUS_INVISIBLE, EKG_STATUS_NULL }; +static const struct protocol_plugin_priv gg_priv = { + .protocols = gg_protocols, + .statuses = gg_statuses +}; + int EXPORT gg_plugin_init(int prio) { va_list dummy; PLUGIN_CHECK_VER("gg"); - gg_plugin.params = gg_plugin_vars; - gg_plugin.priv.protocol.protocols = gg_protocols; - gg_plugin.priv.protocol.statuses = gg_statuses; + gg_plugin.params = gg_plugin_vars; + gg_plugin.priv = &gg_priv; plugin_register(&gg_plugin, prio); gg_setvar_default(NULL, dummy); Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-01 19:05:25 UTC (rev 4591) +++ trunk/plugins/icq/icq.c 2008-09-01 19:12:07 UTC (rev 4592) @@ -1454,6 +1454,11 @@ EKG_STATUS_INVISIBLE, EKG_STATUS_NULL }; +static const struct protocol_plugin_priv icq_priv = { + .protocols = icq_protocols, + .statuses = icq_statuses +}; + EXPORT int icq_plugin_init(int prio) { #define ICQ_ONLY SESSION_MUSTBELONG | SESSION_MUSTHASPRIVATE #define ICQ_FLAGS ICQ_ONLY | SESSION_MUSTBECONNECTED @@ -1464,9 +1469,8 @@ icq_convert_string_init(); - icq_plugin.params = icq_plugin_vars; - icq_plugin.priv.protocol.protocols = icq_protocols; - icq_plugin.priv.protocol.statuses = icq_statuses; + icq_plugin.params = icq_plugin_vars; + icq_plugin.priv = &icq_priv; plugin_register(&icq_plugin, prio); Modified: trunk/plugins/irc/irc.c =================================================================== --- trunk/plugins/irc/irc.c 2008-09-01 19:05:25 UTC (rev 4591) +++ trunk/plugins/irc/irc.c 2008-09-01 19:12:07 UTC (rev 4592) @@ -2375,6 +2375,11 @@ EKG_STATUS_NA, EKG_STATUS_AWAY, EKG_STATUS_AVAIL /* XXX */, EKG_STATUS_NULL }; +static const struct protocol_plugin_priv irc_priv = { + .protocols = irc_protocols, + .statuses = irc_statuses +}; + EXPORT int irc_plugin_init(int prio) { #ifndef NO_POSIX_SYSTEM @@ -2404,9 +2409,8 @@ irc_plugin_vars[20].value = pwd_name; irc_plugin_vars[23].value = pwd_realname; - irc_plugin.params = irc_plugin_vars; - irc_plugin.priv.protocol.protocols = irc_protocols; - irc_plugin.priv.protocol.statuses = irc_statuses; + irc_plugin.params = irc_plugin_vars; + irc_plugin.priv = &irc_priv; plugin_register(&irc_plugin, prio); Modified: trunk/plugins/jabber/jabber.c =================================================================== --- trunk/plugins/jabber/jabber.c 2008-09-01 19:05:25 UTC (rev 4591) +++ trunk/plugins/jabber/jabber.c 2008-09-01 19:12:07 UTC (rev 4592) @@ -1623,13 +1623,17 @@ EKG_STATUS_INVISIBLE, EKG_STATUS_ERROR, EKG_STATUS_UNKNOWN, EKG_STATUS_NULL }; +static const struct protocol_plugin_priv jabber_priv = { + .protocols = jabber_protocols, + .statuses = jabber_statuses +}; + EXPORT int jabber_plugin_init(int prio) { PLUGIN_CHECK_VER("jabber"); - jabber_plugin.params = jabber_plugin_vars; - jabber_plugin.priv.protocol.protocols = jabber_protocols; - jabber_plugin.priv.protocol.statuses = jabber_statuses; + jabber_plugin.params = jabber_plugin_vars; + jabber_plugin.priv = &jabber_priv; plugin_register(&jabber_plugin, prio); Modified: trunk/plugins/jogger/jogger.c =================================================================== --- trunk/plugins/jogger/jogger.c 2008-09-01 19:05:25 UTC (rev 4591) +++ trunk/plugins/jogger/jogger.c 2008-09-01 19:12:07 UTC (rev 4592) @@ -263,13 +263,16 @@ static const char *jogger_protocols[] = { "jogger:", NULL }; +static const struct protocol_plugin_priv jogger_priv = { + .protocols = jogger_protocols +}; + int jogger_plugin_init(int prio) { PLUGIN_CHECK_VER("jogger"); - jogger_plugin.params = jogger_plugin_vars; - jogger_plugin.priv.protocol.protocols = jogger_protocols; - /* statuses are not supported, we're just copying jabber session status */ + jogger_plugin.params = jogger_plugin_vars; + jogger_plugin.priv = &jogger_priv; query_connect_id(&jogger_plugin, PLUGIN_PRINT_VERSION, jogger_print_version, NULL); query_connect_id(&jogger_plugin, PROTOCOL_VALIDATE_UID, jogger_validate_uid, NULL); Modified: trunk/plugins/xmsg/xmsg.c =================================================================== --- trunk/plugins/xmsg/xmsg.c 2008-09-01 19:05:25 UTC (rev 4591) +++ trunk/plugins/xmsg/xmsg.c 2008-09-01 19:12:07 UTC (rev 4592) @@ -699,6 +699,10 @@ static const char *xmsg_protocols[] = { "xmsg:", NULL }; +static const struct protocol_plugin_priv xmsg_priv = { + .protocols = xmsg_protocols +}; + int xmsg_plugin_init(int prio) { PLUGIN_CHECK_VER("xmsg"); @@ -709,9 +713,8 @@ xdebug("inotify fd = %d", in_fd); - xmsg_plugin.params = xmsg_plugin_vars; - xmsg_plugin.priv.protocol.protocols = xmsg_protocols; - /* statuses not supported */ + xmsg_plugin.params = xmsg_plugin_vars; + xmsg_plugin.priv = &xmsg_priv; plugin_register(&xmsg_plugin, prio); query_connect_id(&xmsg_plugin, PROTOCOL_VALIDATE_UID, xmsg_validate_uid, NULL); From svn w toxygen.net Mon Sep 1 21:34:02 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 1 Sep 2008 21:34:02 +0200 (CEST) Subject: [ekg2-commit] r4593 - trunk/ekg: trunk/ekg/sessions.c Message-ID: <20080901193402.9705A17B1F@toxygen.net> Author: peres Date: 2008-09-01 21:34:02 +0200 (Mon, 01 Sep 2008) New Revision: 4593 Modified: trunk/ekg/sessions.c Log: Support 'reverse nearest status', i.e. ffc->avail. Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-01 19:12:07 UTC (rev 4592) +++ trunk/ekg/sessions.c 2008-09-01 19:34:02 UTC (rev 4593) @@ -557,6 +557,7 @@ plugin_t *p = s->plugin; struct protocol_plugin_priv *pp = p->priv; const status_t *ast; + const int dir = (status < EKG_STATUS_AVAIL); if (p->pclass != PLUGIN_PROTOCOL) { debug_wtf("session_status_nearest(), session '%s' on non-protocol plugin '%s'!\n", session_uid_get(s), p->name); @@ -566,9 +567,14 @@ return status; } - for (; status < EKG_STATUS_LAST; status++) { - if (status <= EKG_STATUS_NA) continue; + /* It's really hard to guess intentions + * so we currently are going 'towards' EKG_STATUS_AVAIL + * i.e. if status < EKG_STATUS_AVAIL, we're increasing it, + * else we're decreasing it */ + for (; dir ? (status <= EKG_STATUS_AVAIL) : (status >= EKG_STATUS_AVAIL); dir ? status++ : status--) { + if (status <= EKG_STATUS_NA || status >= EKG_STATUS_LAST) continue; + for (ast = pp->statuses; ast && (*ast != EKG_STATUS_NULL); ast++) { if (*ast == status) /* is supported? */ return status; From svn w toxygen.net Wed Sep 3 13:35:25 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 3 Sep 2008 13:35:25 +0200 (CEST) Subject: [ekg2-commit] r4594 - trunk/ekg: +trunk/ekg/recode.c Message-ID: <20080903113525.3746917B1F@toxygen.net> Author: darkjames Date: 2008-09-03 13:35:24 +0200 (Wed, 03 Sep 2008) New Revision: 4594 Added: trunk/ekg/recode.c Log: begin of recode.c file. Added: trunk/ekg/recode.c =================================================================== --- trunk/ekg/recode.c (rev 0) +++ trunk/ekg/recode.c 2008-09-03 11:35:24 UTC (rev 4594) @@ -0,0 +1,870 @@ +#include "ekg2-config.h" + +/* + * (C) Copyright XXX + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* NOTES/THINK/BUGS: + * - do we need any #define? + * - if we stop using ekg_convert_string_init() in plugins this file could be smaller. + * - don't use gg_*() funcs, always use iconv? lite iconv in compat/ ? + * - create: + * static struct ekg_converter same_enc; + * + * we should know if iconv_open() failed, or we have good console_charset.. + * give info to user, if this first happen. + * + * - we should also reinit encodings, if user changed console_charset. + * - implement ekg_any_to_locale(), ekg_locale_to_any() + * + * - Check if this code works OK. + */ + +#include +#include + +#ifdef HAVE_ICONV +# include +#endif + +#include "commands.h" +#include "dynstuff.h" +#include "dynstuff_inline.h" +#include "recode.h" +#include "stuff.h" +#include "windows.h" +#include "xmalloc.h" + +#define EKG_ICONV_BAD (void*) -1 + +/* some code based on libiconv utf8_mbtowc() && utf8_wctomb() from utf8.h under LGPL-2.1 */ + +#ifdef HAVE_ICONV +/* Following two functions shamelessly ripped from mutt-1.4.2i + * (http://www.mutt.org, license: GPL) + * + * Copyright (C) 1999-2000 Thomas Roessler + * Modified 2004 by Maciek Pasternacki + */ + +/* + * Like iconv, but keeps going even when the input is invalid + * If you're supplying inrepls, the source charset should be stateless; + * if you're supplying an outrepl, the target charset should be. + */ +static inline size_t mutt_iconv (iconv_t cd, char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft, + char **inrepls, const char *outrepl) +{ + size_t ret = 0, ret1; + char *ib = *inbuf; + size_t ibl = *inbytesleft; + char *ob = *outbuf; + size_t obl = *outbytesleft; + + for (;;) { + ret1 = iconv (cd, &ib, &ibl, &ob, &obl); + if (ret1 != (size_t)-1) + ret += ret1; + if (ibl && obl && errno == EILSEQ) { + if (inrepls) { + /* Try replacing the input */ + char **t; + for (t = inrepls; *t; t++) + { + char *ib1 = *t; + size_t ibl1 = xstrlen (*t); + char *ob1 = ob; + size_t obl1 = obl; + iconv (cd, &ib1, &ibl1, &ob1, &obl1); + if (!ibl1) { + ++ib, --ibl; + ob = ob1, obl = obl1; + ++ret; + break; + } + } + if (*t) + continue; + } + if (outrepl) { + /* Try replacing the output */ + int n = xstrlen (outrepl); + if (n <= obl) + { + memcpy (ob, outrepl, n); + ++ib, --ibl; + ob += n, obl -= n; + ++ret; + continue; + } + } + } + *inbuf = ib, *inbytesleft = ibl; + *outbuf = ob, *outbytesleft = obl; + return ret; + } +} + +/* + * Convert a string + * Used in rfc2047.c and rfc2231.c + * + * Broken for use within EKG2 (passing iconv_t instead of from/to) + */ + +static inline string_t mutt_convert_string (string_t s, iconv_t cd, int is_utf) +{ + string_t ret; + char *repls[] = { "\357\277\275", "?", 0 }; + /* we can assume that both from and to aren't NULL in EKG2, + * and cd is NULL in case of error, not -1 */ + if (cd) { + char *ib; + char *buf, *ob; + size_t ibl, obl; + char **inrepls = 0; + char *outrepl = 0; + + if ( is_utf == 2 ) /* to utf */ + outrepl = repls[0]; /* this would be more evil */ + else if ( is_utf == 1 ) /* from utf */ + inrepls = repls; + else + outrepl = "?"; + + ib = s->str; + ibl = s->len + 1; + obl = 16 * ibl; + ob = buf = xmalloc (obl + 1); + + mutt_iconv (cd, &ib, &ibl, &ob, &obl, inrepls, outrepl); + + ret = string_init(NULL); + string_append_raw(ret, buf, ob - buf); + + xfree(buf); + + return ret; + } + return NULL; +} + +/* End of code taken from mutt. */ +#endif /*HAVE_ICONV*/ + +#ifdef HAVE_ICONV +/** + * struct ekg_converter + * + * Used internally by EKG2, contains information about one initialized character converter. + */ +struct ekg_converter { + struct ekg_converter *next; + + iconv_t cd; /**< Magic thing given to iconv, always not NULL (else we won't alloc struct) */ + iconv_t rev; /**< Reverse conversion thing, can be NULL */ + char *from; /**< Input encoding (duped), always not NULL (even on console_charset) */ + char *to; /**< Output encoding (duped), always not NULL (even on console_charset) */ + int used; /**< Use counter - incr on _init(), decr on _destroy(), free if 0 */ + int rev_used; /**< Like above, but for rev; if !rev, value undefined */ + int is_utf; /**< Used internally for mutt_convert_string() */ +}; + +static struct ekg_converter *ekg_converters = NULL; /**< list for internal use of ekg_convert_string_*() */ + +static LIST_FREE_ITEM(list_ekg_converter_free, struct ekg_converter *) { xfree(data->from); xfree(data->to); } +DYNSTUFF_LIST_DECLARE(ekg_converters, struct ekg_converter, list_ekg_converter_free, + static __DYNSTUFF_LIST_ADD, /* ekg_converters_add() */ + static __DYNSTUFF_LIST_REMOVE_ITER, /* ekg_converters_removei() */ + __DYNSTUFF_NODESTROY) /* XXX? */ + +#endif + +/** + * ekg_convert_string_init() + * + * Initialize string conversion thing for two given charsets. + * + * @param from - input encoding (will be duped; if NULL, console_charset will be assumed). + * @param to - output encoding (will be duped; if NULL, console_charset will be assumed). + * @param rev - pointer to assign reverse conversion into; if NULL, no reverse converter will be initialized. + * + * @return Pointer that should be passed to other ekg_convert_string_*(), even if it's NULL. + * + * @sa ekg_convert_string_destroy() - deinits charset conversion. + * @sa ekg_convert_string_p() - main charset conversion function. + */ +void *ekg_convert_string_init(const char *from, const char *to, void **rev) { +#ifdef HAVE_ICONV + struct ekg_converter *p; + + if (!from) + from = config_console_charset; + if (!to) + to = config_console_charset; + if (!xstrcasecmp(from, to)) { /* if they're the same */ + if (rev) + *rev = NULL; + return NULL; + } + + /* maybe we've already got some converter for this charsets */ + for (p = ekg_converters; p; p = p->next) { + if (!xstrcasecmp(from, p->from) && !xstrcasecmp(to, p->to)) { + p->used++; + if (rev) { + if (!p->rev) { /* init rev */ + p->rev = iconv_open(from, to); + if (p->rev == (iconv_t)-1) /* we don't want -1 */ + p->rev = NULL; + else + p->rev_used = 1; + } else + p->rev_used++; + *rev = p->rev; + } + return p->cd; + } else if (!xstrcasecmp(from, p->to) && !xstrcasecmp(to, p->from)) { + /* we've got reverse thing */ + if (rev) { /* our rev means its forw */ + p->used++; + *rev = p->cd; + } + if (!p->rev) { + p->rev = iconv_open(to, from); + if (p->rev == (iconv_t)-1) + p->rev = NULL; + else + p->rev_used = 1; + } else + p->rev_used++; + return p->rev; + } + } + + { + iconv_t cd, rcd = NULL; + + if ((cd = iconv_open(to, from)) == (iconv_t)-1) + cd = NULL; + if (rev) { + if ((rcd = iconv_open(from, to)) == (iconv_t)-1) + rcd = NULL; + *rev = rcd; + } + + if (cd || rcd) { /* don't init struct if both are NULL */ + struct ekg_converter *c = xmalloc(sizeof(struct ekg_converter)); + + /* if cd is NULL, we reverse everything */ + c->cd = (cd ? cd : rcd); + c->rev = (cd ? rcd : cd); + c->from = (cd ? xstrdup(from) : xstrdup(to)); + c->to = (cd ? xstrdup(to) : xstrdup(from)); + c->used = 1; + c->rev_used = (cd && rcd ? 1 : 0); + /* for mutt_convert_string() */ + if (!xstrcasecmp(c->to, "UTF-8")) + c->is_utf = 2; + else if (!xstrcasecmp(c->from, "UTF-8")) + c->is_utf = 1; + ekg_converters_add(c); + } + + return cd; + } +#else + return NULL; +#endif +} + +/** + * ekg_convert_string_destroy() + * + * Frees internal data associated with given pointer, and uninitalizes iconv, if it's not needed anymore. + * + * @note If 'rev' param was used with ekg_convert_string_init(), this functions must be called two times + * - with returned value, and with rev-associated one. + * + * @param ptr - pointer returned by ekg_convert_string_init(). + * + * @sa ekg_convert_string_init() - init charset conversion. + * @sa ekg_convert_string_p() - main charset conversion function. + */ + +void ekg_convert_string_destroy(void *ptr) { +#ifdef HAVE_ICONV + struct ekg_converter *c; + + if (!ptr) /* we can be called with NULL ptr */ + return; + + for (c = ekg_converters; c; c = c->next) { + if (c->cd == ptr) + c->used--; + else if (c->rev == ptr) /* ptr won't be NULL here */ + c->rev_used--; + else + continue; /* we're gonna break */ + + if (c->rev && (c->rev_used == 0)) { /* deinit reverse converter */ + iconv_close(c->rev); + c->rev = NULL; + } + if (c->used == 0) { /* deinit forward converter, if not needed */ + iconv_close(c->cd); + + if (c->rev) { /* if reverse converter is still used, reverse the struct */ + c->cd = c->rev; + c->rev = NULL; /* rev_used becomes undef */ + c->used = c->rev_used; + { + char *tmp = c->from; + c->from = c->to; + c->to = tmp; + } + } else { /* else, free it */ + (void) ekg_converters_removei(c); + } + } + + break; + } +#endif +} + +/** + * ekg_convert_string_p() + * + * Converts string to specified encoding, using pointer returned by ekg_convert_string_init(). + * Invalid characters in input will be replaced with question marks. + * + * @param ps - string to be converted (won't be freed). + * @param ptr - pointer returned by ekg_convert_string_init(). + * + * @return Pointer to allocated result or NULL, if some failure has occured or no conversion + * is needed (i.e. resulting string would be same as input). + * + * @sa ekg_convert_string_init() - init charset conversion. + * @sa ekg_convert_string_destroy() - deinits charset conversion. + */ + +char *ekg_convert_string_p(const char *ps, void *ptr) { + string_t recod, s = string_init(ps); + char *r = NULL; + + if ((recod = ekg_convert_string_t_p(s, ptr))) { + r = xstrndup(recod->str, recod->len); + string_free(recod, 1); + } + + return r; +} + +/** + * ekg_convert_string() + * + * Converts string to specified encoding, replacing invalid chars with question marks. + * + * @note Deprecated, in favour of ekg_convert_string_p(). Should be used only on single + * conversions, where charset pair won't be used again. + * + * @param ps - string to be converted (it won't be freed). + * @param from - input encoding (if NULL, console_charset will be assumed). + * @param to - output encoding (if NULL, console_charset will be assumed). + * + * @return Pointer to allocated result on success, NULL on failure + * or when both encodings are equal. + * + * @sa ekg_convert_string_p() - more optimized version. + */ +char *ekg_convert_string(const char *ps, const char *from, const char *to) { + char *r; + void *p; + + if (!ps || !*ps) /* don't even init iconv if we've got NULL string */ + return NULL; + + p = ekg_convert_string_init(from, to, NULL); + r = ekg_convert_string_p(ps, p); + ekg_convert_string_destroy(p); + + return r; +} + +string_t ekg_convert_string_t_p(string_t s, void *ptr) { +#ifdef HAVE_ICONV + struct ekg_converter *c; + int is_utf = 0; + + if (!s || !s->len || !ptr) + return NULL; + + /* XXX, maybe some faster way? any ideas? */ + for (c = ekg_converters; c; c = c->next) { + if (c->cd == ptr) + is_utf = c->is_utf; + else if (c->rev == ptr) + is_utf = (c->is_utf == 2 ? 1 : (c->is_utf == 1 ? 2 : 0)); + else + continue; + + break; + } + + return mutt_convert_string(s, ptr, is_utf); +#else + return NULL; +#endif +} + +string_t ekg_convert_string_t(string_t s, const char *from, const char *to) { + string_t r; + void *p; + + if (!s || !s->len) /* don't even init iconv if we've got NULL string */ + return NULL; + + p = ekg_convert_string_init(from, to, NULL); + r = ekg_convert_string_t_p(s, p); + ekg_convert_string_destroy(p); + return r; +} + +static char *ekg_convert_string_p_safe(char *ps, void *ptr) { + char *out = ekg_convert_string_p(ps, ptr); + if (out) + xfree(ps); + else + out = ps; + return out; +} + +int ekg_converters_display(int quiet) { +#ifdef HAVE_ICONV + struct ekg_converter *c; + + for (c = ekg_converters; c; c = c->next) { + /* cd, rev, from, to, used, rev_used, is_utf */ + + printq("iconv_list", c->from, c->to, itoa(c->used), itoa(c->rev_used)); +// printq("iconv_list_bad", c->from, c->to, itoa(c->used), itoa(c->rev_used)); + + } + return 0; +#else + printq("generic_error", "Sorry, no iconv"); + return -1; +#endif +} + +static int utf8_helper(unsigned char *s, int n, unsigned short *ch) { + unsigned char c = s[0]; + + if (c < 0x80) { + *ch = c; + return 1; + } + + if (c < 0xc2) + goto invalid; + + if (c < 0xe0) { + if (n < 2) + goto invalid; + if (!((s[1] ^ 0x80) < 0x40)) + goto invalid; + *ch = ((unsigned short) (c & 0x1f) << 6) | (unsigned short) (s[1] ^ 0x80); + return 2; + } + + if (c < 0xf0) { + if (n < 3) + goto invalid; + if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && (c >= 0xe1 || s[1] >= 0xa0))) + goto invalid; + *ch = ((unsigned short) (c & 0x0f) << 12) | ((unsigned short) (s[1] ^ 0x80) << 6) | (unsigned short) (s[2] ^ 0x80); + return 3; + } + +invalid: + *ch = '?'; + return 1; +} + +/* cp1250 <==> any, use ekg_locale_to_cp() and ekg_cp_to_locale() */ + +#if (USE_UNICODE || HAVE_GTK) +static const unsigned short table_cp1250[] = { + 0x20ac, '?', 0x201a, '?', 0x201e, 0x2026, 0x2020, 0x2021, + '?', 0x2030, 0x0160, 0x2039, 0x015a, 0x0164, 0x017d, 0x0179, + '?', 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, + '?', 0x2122, 0x0161, 0x203a, 0x015b, 0x0165, 0x017e, 0x017a, + 0x00a0, 0x02c7, 0x02d8, 0x0141, 0x00a4, 0x0104, 0x00a6, 0x00a7, + 0x00a8, 0x00a9, 0x015e, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x017b, + 0x00b0, 0x00b1, 0x02db, 0x0142, 0x00b4, 0x00b5, 0x00b6, 0x00b7, + 0x00b8, 0x0105, 0x015f, 0x00bb, 0x013d, 0x02dd, 0x013e, 0x017c, + 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, + 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e, + 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, + 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df, + 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, + 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f, + 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, + 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9, +}; +#endif + +/* 80..9F = ?; here is A0..BF, C0..FF is the same */ +static const unsigned char iso_to_cp_table[] = { + 0xa0, 0xa5, 0xa2, 0xa3, 0xa4, 0xbc, 0x8c, 0xa7, + 0xa8, 0x8a, 0xaa, 0x8d, 0x8f, 0xad, 0x8e, 0xaf, + 0xb0, 0xb9, 0xb2, 0xb3, 0xb4, 0xbe, 0x9c, 0xa1, + 0xb8, 0x9a, 0xba, 0x9d, 0x9f, 0xbd, 0x9e, 0xbf, +}; + +static const unsigned char cp_to_iso_table[] = { + '?', '?', '?', '?', '?', '?', '?', '?', + '?', '?', 0xa9, '?', 0xa6, 0xab, 0xae, 0xac, + '?', '?', '?', '?', '?', '?', '?', '?', + '?', '?', 0xb9, '?', 0xb6, 0xbb, 0xbe, 0xbc, + 0xa0, 0xb7, 0xa2, 0xa3, 0xa4, 0xa1, '?', 0xa7, + 0xa8, '?', 0xaa, '?', '?', 0xad, '?', 0xaf, + 0xb0, '?', 0xb2, 0xb3, 0xb4, '?', '?', '?', + 0xb8, 0xb1, 0xba, '?', 0xa5, 0xbd, 0xb5, 0xbf, +}; + +void *cp_conv_in = EKG_ICONV_BAD; +void *cp_conv_out = EKG_ICONV_BAD; + +static char *gg_cp_to_iso(char *b) { + unsigned char *buf = (unsigned char *) b; + + while (*buf) { + if (*buf >= 0x80 && *buf < 0xC0) + *buf = cp_to_iso_table[*buf - 0x80]; + + buf++; + } + return b; +} + +static char *gg_cp_to_utf8(char *b) { + unsigned char *buf = (unsigned char *) b; + char *newbuf; + int newlen = 0; + int i, j; + + for (i = 0; buf[i]; i++) { + unsigned short znak = (buf[i] < 0x80) ? buf[i] : table_cp1250[buf[i]-0x80]; + + if (znak < 0x80) newlen += 1; + else if (znak < 0x800) newlen += 2; + else newlen += 3; + } + + newbuf = xmalloc(newlen+1); + + for (i = 0, j = 0; buf[i]; i++) { + unsigned short znak = (buf[i] < 0x80) ? buf[i] : table_cp1250[buf[i]-0x80]; + int count; + + if (znak < 0x80) count = 1; + else if (znak < 0x800) count = 2; + else count = 3; + + switch (count) { + case 3: newbuf[j+2] = 0x80 | (znak & 0x3f); znak = znak >> 6; znak |= 0x800; + case 2: newbuf[j+1] = 0x80 | (znak & 0x3f); znak = znak >> 6; znak |= 0xc0; + case 1: newbuf[j] = znak; + } + j += count; + } + newbuf[j] = '\0'; + + xfree(b); + return newbuf; +} + +static char *gg_iso_to_cp(char *b) { + unsigned char *buf = (unsigned char *) b; + + while (*buf) { + if (*buf >= 0x80 && *buf < 0xA0) + *buf = '?'; + else if (*buf >= 0xA0 && *buf < 0xC0) + *buf = iso_to_cp_table[*buf - 0xA0]; + + buf++; + } + return b; +} + +static char *gg_utf8_to_cp(char *b) { + unsigned char *buf = (unsigned char *) b; + + char *newbuf; + int newlen = 0; + int len; + int i, j; + + if (!buf) + return NULL; + + len = strlen(b); + + for (i = 0; i < len; newlen++) { + unsigned short discard; + + i += utf8_helper(&buf[i], len - i, &discard); + } + + newbuf = xmalloc(newlen+1); + + for (i = 0, j = 0; buf[i]; j++) { + unsigned short znak; + int k; + + i += utf8_helper(&buf[i], len - i, &znak); + + if (znak < 0x80) { + newbuf[j] = znak; + continue; + } + + newbuf[j] = '?'; + + for (k = 0; k < (sizeof(table_cp1250)/sizeof(table_cp1250[0])); k++) { + if (table_cp1250[k] == znak) { + newbuf[j] = (0x80 | k); + break; + } + } + } + newbuf[j] = '\0'; + + xfree(b); + + return newbuf; +} + +char *ekg_locale_to_cp(char *buf) { + if (!buf) + return NULL; +#if (USE_UNICODE || HAVE_GTK) + if (config_use_unicode) + return gg_utf8_to_cp(buf); +#endif + if (cp_conv_out != EKG_ICONV_BAD) + return ekg_convert_string_p_safe(buf, cp_conv_out); + return gg_iso_to_cp(buf); /* XXX, assuimg iso, iso bad? */ +} + +char *ekg_cp_to_locale(char *buf) { + if (!buf) + return NULL; +#if (USE_UNICODE || HAVE_GTK) + if (config_use_unicode) + return gg_cp_to_utf8(buf); +#endif + if (cp_conv_in != EKG_ICONV_BAD) + return ekg_convert_string_p_safe(buf, cp_conv_in); + return gg_cp_to_iso(buf); /* XXX, assuimg iso, is bad? */ +} + +/* ISO-8859-2 <===> any, use ekg_locale_to_latin2() and ekg_latin2_to_locale() */ + +#if (USE_UNICODE || HAVE_GTK) +static const unsigned short table_iso_8859_2[] = { + '?', '?', '?', '?', '?', '?', '?', '?', /* 0x80 - */ + '?', '?', '?', '?', '?', '?', '?', '?', /* - 0x8F */ + '?', '?', '?', '?', '?', '?', '?', '?', /* 0x90 - */ + '?', '?', '?', '?', '?', '?', '?', '?', /* - 0x9F */ + 0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7, /* 0xA0 - */ + 0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b, /* - 0xAF */ + 0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7, /* 0xB0 - */ + 0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c, /* - 0xBF */ + 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, /* 0xC0 - */ + 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e, /* - 0xCF */ + 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, /* 0xD0 - */ + 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df, /* - 0xDF */ + 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, /* 0xE0 - */ + 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f, /* - 0xEF */ + 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, /* 0xF0 - */ + 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9 /* - 0xFF */ +}; +#endif + +void *latin2_conv_in = EKG_ICONV_BAD; +void *latin2_conv_out = EKG_ICONV_BAD; + +static char *gg_utf8_to_latin2(char *b) +{ + unsigned char *buf = (unsigned char *) b; + + char *newbuf; + int newlen = 0; + int len; + int i, j; + + if (!buf) + return NULL; + + len = strlen(b); + + for (i = 0; i < len; newlen++) { + unsigned short discard; + + i += utf8_helper(&buf[i], len - i, &discard); + } + + newbuf = xmalloc(newlen+1); + + for (i = 0, j = 0; buf[i]; j++) { + unsigned short znak; + int k; + + i += utf8_helper(&buf[i], len - i, &znak); + + if (znak < 0x80) { + newbuf[j] = znak; + continue; + } + + newbuf[j] = '?'; + + for (k = 0; k < (sizeof(table_iso_8859_2)/sizeof(table_iso_8859_2[0])); k++) { + if (table_iso_8859_2[k] == znak) { + newbuf[j] = (0x80 | k); + break; + } + } + } + newbuf[j] = '\0'; + + xfree(buf); + + return newbuf; +} + +static char *gg_latin2_to_utf8(char *b) +{ + unsigned char *buf = (unsigned char *) b; + char *newbuf; + int newlen = 0; + int i, j; + + if (!buf) + return NULL; + + for (i = 0; buf[i]; i++) { + unsigned short znak = (buf[i] < 0x80) ? buf[i] : table_iso_8859_2[buf[i]-0x80]; + + if (znak < 0x80) newlen += 1; + else if (znak < 0x800) newlen += 2; + else newlen += 3; + } + + newbuf = xmalloc(newlen+1); + + for (i = 0, j = 0; buf[i]; i++) { + unsigned short znak = (buf[i] < 0x80) ? buf[i] : table_iso_8859_2[buf[i]-0x80]; + int count; + + if (znak < 0x80) count = 1; + else if (znak < 0x800) count = 2; + else count = 3; + + switch (count) { + case 3: newbuf[j+2] = 0x80 | (znak & 0x3f); znak = znak >> 6; znak |= 0x800; + case 2: newbuf[j+1] = 0x80 | (znak & 0x3f); znak = znak >> 6; znak |= 0xc0; + case 1: newbuf[j] = znak; + } + j += count; + } + newbuf[j] = '\0'; + + xfree(buf); + + return newbuf; +} + +char *ekg_locale_to_latin2(char *buf) { + if (!buf) + return NULL; +#if (USE_UNICODE || HAVE_GTK) + if (config_use_unicode) + return gg_utf8_to_latin2(buf); +#endif + if (latin2_conv_out != EKG_ICONV_BAD) + return ekg_convert_string_p_safe(buf, latin2_conv_out); + /* XXX, warn user. */ + return NULL; +} + +char *ekg_latin2_to_locale(char *buf) { + if (!buf) + return NULL; +#if (USE_UNICODE || HAVE_GTK) + if (config_use_unicode) + return gg_latin2_to_utf8(buf); +#endif + if (latin2_conv_in != EKG_ICONV_BAD) + return ekg_convert_string_p_safe(buf, latin2_conv_in); + /* XXX, warn user. */ + return NULL; +} + +/* UTF-8 <===> any, use ekg_locale_to_utf8() and ekg_utf8_to_locale() */ + +/* XXX, easier recode in/out to latin2? */ + +void *utf8_conv_in = EKG_ICONV_BAD; +void *utf8_conv_out = EKG_ICONV_BAD; + +char *ekg_locale_to_utf8(char *buf) { + if (!buf) + return NULL; + + if (utf8_conv_out != EKG_ICONV_BAD) + return ekg_convert_string_p_safe(buf, utf8_conv_out); + /* XXX, warn user. */ + return NULL; +} + +char *ekg_utf8_to_locale(char *buf) { + if (!buf) + return NULL; + if (utf8_conv_in != EKG_ICONV_BAD) + return ekg_convert_string_p_safe(buf, utf8_conv_in); + /* XXX, warn user. */ + return NULL; +} + +/* XXX any <===> any, use ekg_any_to_locale() and ekg_locale_to_any() */ + +char *ekg_any_to_locale(char *buf, char *inp) { + + +} + +char *ekg_locale_to_any(char *buf, char *inp) { + + +} + From svn w toxygen.net Wed Sep 3 15:54:18 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 3 Sep 2008 15:54:18 +0200 (CEST) Subject: [ekg2-commit] r4595 - trunk/ekg: trunk/ekg/recode.c Message-ID: <20080903135418.915F417B1F@toxygen.net> Author: darkjames Date: 2008-09-03 15:54:18 +0200 (Wed, 03 Sep 2008) New Revision: 4595 Modified: trunk/ekg/recode.c Log: cleanup recode file a little. Modified: trunk/ekg/recode.c =================================================================== --- trunk/ekg/recode.c 2008-09-03 11:35:24 UTC (rev 4594) +++ trunk/ekg/recode.c 2008-09-03 13:54:18 UTC (rev 4595) @@ -473,7 +473,7 @@ #endif } -static int utf8_helper(unsigned char *s, int n, unsigned short *ch) { +static int ekg_utf8_helper(unsigned char *s, int n, unsigned short *ch) { unsigned char c = s[0]; if (c < 0x80) { @@ -507,71 +507,59 @@ return 1; } -/* cp1250 <==> any, use ekg_locale_to_cp() and ekg_cp_to_locale() */ +static char *ekg_from_utf8(char *b, const unsigned short *recode_table) { /* sizeof(recode_table) MUST BE 0x100 ==> 0x80 items */ + unsigned char *buf = (unsigned char *) b; -#if (USE_UNICODE || HAVE_GTK) -static const unsigned short table_cp1250[] = { - 0x20ac, '?', 0x201a, '?', 0x201e, 0x2026, 0x2020, 0x2021, - '?', 0x2030, 0x0160, 0x2039, 0x015a, 0x0164, 0x017d, 0x0179, - '?', 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, - '?', 0x2122, 0x0161, 0x203a, 0x015b, 0x0165, 0x017e, 0x017a, - 0x00a0, 0x02c7, 0x02d8, 0x0141, 0x00a4, 0x0104, 0x00a6, 0x00a7, - 0x00a8, 0x00a9, 0x015e, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x017b, - 0x00b0, 0x00b1, 0x02db, 0x0142, 0x00b4, 0x00b5, 0x00b6, 0x00b7, - 0x00b8, 0x0105, 0x015f, 0x00bb, 0x013d, 0x02dd, 0x013e, 0x017c, - 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, - 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e, - 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, - 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df, - 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, - 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f, - 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, - 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9, -}; -#endif + char *newbuf; + int newlen = 0; + int len; + int i, j; -/* 80..9F = ?; here is A0..BF, C0..FF is the same */ -static const unsigned char iso_to_cp_table[] = { - 0xa0, 0xa5, 0xa2, 0xa3, 0xa4, 0xbc, 0x8c, 0xa7, - 0xa8, 0x8a, 0xaa, 0x8d, 0x8f, 0xad, 0x8e, 0xaf, - 0xb0, 0xb9, 0xb2, 0xb3, 0xb4, 0xbe, 0x9c, 0xa1, - 0xb8, 0x9a, 0xba, 0x9d, 0x9f, 0xbd, 0x9e, 0xbf, -}; + len = strlen(b); -static const unsigned char cp_to_iso_table[] = { - '?', '?', '?', '?', '?', '?', '?', '?', - '?', '?', 0xa9, '?', 0xa6, 0xab, 0xae, 0xac, - '?', '?', '?', '?', '?', '?', '?', '?', - '?', '?', 0xb9, '?', 0xb6, 0xbb, 0xbe, 0xbc, - 0xa0, 0xb7, 0xa2, 0xa3, 0xa4, 0xa1, '?', 0xa7, - 0xa8, '?', 0xaa, '?', '?', 0xad, '?', 0xaf, - 0xb0, '?', 0xb2, 0xb3, 0xb4, '?', '?', '?', - 0xb8, 0xb1, 0xba, '?', 0xa5, 0xbd, 0xb5, 0xbf, -}; + for (i = 0; i < len; newlen++) { + unsigned short discard; -void *cp_conv_in = EKG_ICONV_BAD; -void *cp_conv_out = EKG_ICONV_BAD; + i += ekg_utf8_helper(&buf[i], len - i, &discard); + } -static char *gg_cp_to_iso(char *b) { - unsigned char *buf = (unsigned char *) b; + newbuf = xmalloc(newlen+1); - while (*buf) { - if (*buf >= 0x80 && *buf < 0xC0) - *buf = cp_to_iso_table[*buf - 0x80]; + for (i = 0, j = 0; buf[i]; j++) { + unsigned short znak; + int k; - buf++; + i += ekg_utf8_helper(&buf[i], len - i, &znak); + + if (znak < 0x80) { + newbuf[j] = znak; + continue; + } + + newbuf[j] = '?'; + + for (k = 0; k < 0x80; k++) { + if (recode_table[k] == znak) { + newbuf[j] = (0x80 | k); + break; + } + } } - return b; + newbuf[j] = '\0'; + + xfree(b); + + return newbuf; } -static char *gg_cp_to_utf8(char *b) { +static char *ekg_to_utf8(char *b, const unsigned short *recode_table) { unsigned char *buf = (unsigned char *) b; char *newbuf; int newlen = 0; int i, j; for (i = 0; buf[i]; i++) { - unsigned short znak = (buf[i] < 0x80) ? buf[i] : table_cp1250[buf[i]-0x80]; + unsigned short znak = (buf[i] < 0x80) ? buf[i] : recode_table[buf[i]-0x80]; if (znak < 0x80) newlen += 1; else if (znak < 0x800) newlen += 2; @@ -581,7 +569,7 @@ newbuf = xmalloc(newlen+1); for (i = 0, j = 0; buf[i]; i++) { - unsigned short znak = (buf[i] < 0x80) ? buf[i] : table_cp1250[buf[i]-0x80]; + unsigned short znak = (buf[i] < 0x80) ? buf[i] : recode_table[buf[i]-0x80]; int count; if (znak < 0x80) count = 1; @@ -601,66 +589,75 @@ return newbuf; } -static char *gg_iso_to_cp(char *b) { +/* cp1250 <==> any, use ekg_locale_to_cp() and ekg_cp_to_locale() */ + +#if (USE_UNICODE || HAVE_GTK) +static const unsigned short table_cp1250[] = { + 0x20ac, '?', 0x201a, '?', 0x201e, 0x2026, 0x2020, 0x2021, /* 0x80 - */ + '?', 0x2030, 0x0160, 0x2039, 0x015a, 0x0164, 0x017d, 0x0179, /* - 0x8F */ + '?', 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, /* 0x90 - */ + '?', 0x2122, 0x0161, 0x203a, 0x015b, 0x0165, 0x017e, 0x017a, /* - 0x9F */ + 0x00a0, 0x02c7, 0x02d8, 0x0141, 0x00a4, 0x0104, 0x00a6, 0x00a7, /* 0xA0 - */ + 0x00a8, 0x00a9, 0x015e, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x017b, /* - 0xAF */ + 0x00b0, 0x00b1, 0x02db, 0x0142, 0x00b4, 0x00b5, 0x00b6, 0x00b7, /* 0xB0 - */ + 0x00b8, 0x0105, 0x015f, 0x00bb, 0x013d, 0x02dd, 0x013e, 0x017c, /* - 0xBF */ + 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, /* 0xC0 - */ + 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e, /* - 0xCF */ + 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, /* 0xD0 - */ + 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df, /* - 0xDF */ + 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, /* 0xE0 - */ + 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f, /* - 0xEF */ + 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, /* 0xF0 - */ + 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9, /* - 0xFF */ +}; +#endif + +/* 80..9F = ?; here is A0..BF, C0..FF is the same */ +static const unsigned char iso_to_cp_table[] = { + 0xa0, 0xa5, 0xa2, 0xa3, 0xa4, 0xbc, 0x8c, 0xa7, + 0xa8, 0x8a, 0xaa, 0x8d, 0x8f, 0xad, 0x8e, 0xaf, + 0xb0, 0xb9, 0xb2, 0xb3, 0xb4, 0xbe, 0x9c, 0xa1, + 0xb8, 0x9a, 0xba, 0x9d, 0x9f, 0xbd, 0x9e, 0xbf, +}; + +static const unsigned char cp_to_iso_table[] = { + '?', '?', '?', '?', '?', '?', '?', '?', + '?', '?', 0xa9, '?', 0xa6, 0xab, 0xae, 0xac, + '?', '?', '?', '?', '?', '?', '?', '?', + '?', '?', 0xb9, '?', 0xb6, 0xbb, 0xbe, 0xbc, + 0xa0, 0xb7, 0xa2, 0xa3, 0xa4, 0xa1, '?', 0xa7, + 0xa8, '?', 0xaa, '?', '?', 0xad, '?', 0xaf, + 0xb0, '?', 0xb2, 0xb3, 0xb4, '?', '?', '?', + 0xb8, 0xb1, 0xba, '?', 0xa5, 0xbd, 0xb5, 0xbf, +}; + +void *cp_conv_in = EKG_ICONV_BAD; +void *cp_conv_out = EKG_ICONV_BAD; + +static char *gg_cp_to_iso(char *b) { unsigned char *buf = (unsigned char *) b; while (*buf) { - if (*buf >= 0x80 && *buf < 0xA0) - *buf = '?'; - else if (*buf >= 0xA0 && *buf < 0xC0) - *buf = iso_to_cp_table[*buf - 0xA0]; + if (*buf >= 0x80 && *buf < 0xC0) + *buf = cp_to_iso_table[*buf - 0x80]; buf++; } return b; } -static char *gg_utf8_to_cp(char *b) { +static char *gg_iso_to_cp(char *b) { unsigned char *buf = (unsigned char *) b; - char *newbuf; - int newlen = 0; - int len; - int i, j; + while (*buf) { + if (*buf >= 0x80 && *buf < 0xA0) + *buf = '?'; + else if (*buf >= 0xA0 && *buf < 0xC0) + *buf = iso_to_cp_table[*buf - 0xA0]; - if (!buf) - return NULL; - - len = strlen(b); - - for (i = 0; i < len; newlen++) { - unsigned short discard; - - i += utf8_helper(&buf[i], len - i, &discard); + buf++; } - - newbuf = xmalloc(newlen+1); - - for (i = 0, j = 0; buf[i]; j++) { - unsigned short znak; - int k; - - i += utf8_helper(&buf[i], len - i, &znak); - - if (znak < 0x80) { - newbuf[j] = znak; - continue; - } - - newbuf[j] = '?'; - - for (k = 0; k < (sizeof(table_cp1250)/sizeof(table_cp1250[0])); k++) { - if (table_cp1250[k] == znak) { - newbuf[j] = (0x80 | k); - break; - } - } - } - newbuf[j] = '\0'; - - xfree(b); - - return newbuf; + return b; } char *ekg_locale_to_cp(char *buf) { @@ -668,7 +665,7 @@ return NULL; #if (USE_UNICODE || HAVE_GTK) if (config_use_unicode) - return gg_utf8_to_cp(buf); + return ekg_from_utf8(buf, table_cp1250); #endif if (cp_conv_out != EKG_ICONV_BAD) return ekg_convert_string_p_safe(buf, cp_conv_out); @@ -680,7 +677,7 @@ return NULL; #if (USE_UNICODE || HAVE_GTK) if (config_use_unicode) - return gg_cp_to_utf8(buf); + return ekg_to_utf8(buf, table_cp1250); #endif if (cp_conv_in != EKG_ICONV_BAD) return ekg_convert_string_p_safe(buf, cp_conv_in); @@ -713,103 +710,12 @@ void *latin2_conv_in = EKG_ICONV_BAD; void *latin2_conv_out = EKG_ICONV_BAD; -static char *gg_utf8_to_latin2(char *b) -{ - unsigned char *buf = (unsigned char *) b; - - char *newbuf; - int newlen = 0; - int len; - int i, j; - - if (!buf) - return NULL; - - len = strlen(b); - - for (i = 0; i < len; newlen++) { - unsigned short discard; - - i += utf8_helper(&buf[i], len - i, &discard); - } - - newbuf = xmalloc(newlen+1); - - for (i = 0, j = 0; buf[i]; j++) { - unsigned short znak; - int k; - - i += utf8_helper(&buf[i], len - i, &znak); - - if (znak < 0x80) { - newbuf[j] = znak; - continue; - } - - newbuf[j] = '?'; - - for (k = 0; k < (sizeof(table_iso_8859_2)/sizeof(table_iso_8859_2[0])); k++) { - if (table_iso_8859_2[k] == znak) { - newbuf[j] = (0x80 | k); - break; - } - } - } - newbuf[j] = '\0'; - - xfree(buf); - - return newbuf; -} - -static char *gg_latin2_to_utf8(char *b) -{ - unsigned char *buf = (unsigned char *) b; - char *newbuf; - int newlen = 0; - int i, j; - - if (!buf) - return NULL; - - for (i = 0; buf[i]; i++) { - unsigned short znak = (buf[i] < 0x80) ? buf[i] : table_iso_8859_2[buf[i]-0x80]; - - if (znak < 0x80) newlen += 1; - else if (znak < 0x800) newlen += 2; - else newlen += 3; - } - - newbuf = xmalloc(newlen+1); - - for (i = 0, j = 0; buf[i]; i++) { - unsigned short znak = (buf[i] < 0x80) ? buf[i] : table_iso_8859_2[buf[i]-0x80]; - int count; - - if (znak < 0x80) count = 1; - else if (znak < 0x800) count = 2; - else count = 3; - - switch (count) { - case 3: newbuf[j+2] = 0x80 | (znak & 0x3f); znak = znak >> 6; znak |= 0x800; - case 2: newbuf[j+1] = 0x80 | (znak & 0x3f); znak = znak >> 6; znak |= 0xc0; - case 1: newbuf[j] = znak; - } - j += count; - } - newbuf[j] = '\0'; - - xfree(buf); - - return newbuf; -} - char *ekg_locale_to_latin2(char *buf) { if (!buf) return NULL; #if (USE_UNICODE || HAVE_GTK) if (config_use_unicode) - return gg_utf8_to_latin2(buf); + return ekg_from_utf8(buf, table_iso_8859_2); #endif if (latin2_conv_out != EKG_ICONV_BAD) return ekg_convert_string_p_safe(buf, latin2_conv_out); @@ -822,7 +728,7 @@ return NULL; #if (USE_UNICODE || HAVE_GTK) if (config_use_unicode) - return gg_latin2_to_utf8(buf); + return ekg_to_utf8(buf, table_iso_8859_2); #endif if (latin2_conv_in != EKG_ICONV_BAD) return ekg_convert_string_p_safe(buf, latin2_conv_in); From svn w toxygen.net Wed Sep 3 22:37:33 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 3 Sep 2008 22:37:33 +0200 (CEST) Subject: [ekg2-commit] r4596 - trunk/ekg: trunk/ekg/recode.c trunk/ekg/stuff.c Message-ID: <20080903203733.D895217B1F@toxygen.net> Author: darkjames Date: 2008-09-03 22:37:33 +0200 (Wed, 03 Sep 2008) New Revision: 4596 Modified: trunk/ekg/recode.c trunk/ekg/stuff.c Log: optimize ekg_convert_string_p() Modified: trunk/ekg/recode.c =================================================================== --- trunk/ekg/recode.c 2008-09-03 13:54:18 UTC (rev 4595) +++ trunk/ekg/recode.c 2008-09-03 20:37:33 UTC (rev 4596) @@ -365,15 +365,13 @@ */ char *ekg_convert_string_p(const char *ps, void *ptr) { - string_t recod, s = string_init(ps); - char *r = NULL; + string_t s = string_init(ps); + string_t recod; - if ((recod = ekg_convert_string_t_p(s, ptr))) { - r = xstrndup(recod->str, recod->len); - string_free(recod, 1); - } + if ((recod = ekg_convert_string_t_p(s, ptr))) + return string_free(recod, 0); - return r; + return NULL; } /** Modified: trunk/ekg/stuff.c =================================================================== --- trunk/ekg/stuff.c 2008-09-03 13:54:18 UTC (rev 4595) +++ trunk/ekg/stuff.c 2008-09-03 20:37:33 UTC (rev 4596) @@ -3077,15 +3077,13 @@ */ char *ekg_convert_string_p(const char *ps, void *ptr) { - string_t recod, s = string_init(ps); - char *r = NULL; + string_t s = string_init(ps); + string_t recod; - if ((recod = ekg_convert_string_t_p(s, ptr))) { - r = xstrndup(recod->str, recod->len); - string_free(recod, 1); - } + if ((recod = ekg_convert_string_t_p(s, ptr))) + return string_free(recod, 0); - return r; + return NULL; } /** From svn w toxygen.net Wed Sep 3 23:10:02 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 3 Sep 2008 23:10:02 +0200 (CEST) Subject: [ekg2-commit] r4597 - in trunk: ekg plugins/gg plugins/icq plugins/rivchat plugins/sniff: trunk/ekg/Makefile.am trunk/ekg/ekg.c trunk/ekg/recode.c trunk/ekg/stuff.c trunk/ekg/stuff.h trunk/plugins/gg/commands.c trunk/plugins/gg/gg.c trunk/plugins/gg/misc.c trunk/plugins/gg/misc.h trunk/plugins/gg/pubdir.c trunk/plugins/gg/pubdir50.c trunk/plugins/icq/icq_snac_handlers_13userlist.inc trunk/plugins/icq/misc.c trunk/plugins/rivchat/misc.c trunk/plugins/rivchat/rivchat.c trunk/plugins/sniff/sniff.c trunk/plugins/sniff/sniff_gg.inc trunk/plugins/sniff/sniff_rivchat.inc Message-ID: <20080903211002.3698C17B1F@toxygen.net> Author: darkjames Date: 2008-09-03 23:10:01 +0200 (Wed, 03 Sep 2008) New Revision: 4597 Modified: trunk/ekg/Makefile.am trunk/ekg/ekg.c trunk/ekg/recode.c trunk/ekg/stuff.c trunk/ekg/stuff.h trunk/plugins/gg/commands.c trunk/plugins/gg/gg.c trunk/plugins/gg/misc.c trunk/plugins/gg/misc.h trunk/plugins/gg/pubdir.c trunk/plugins/gg/pubdir50.c trunk/plugins/icq/icq_snac_handlers_13userlist.inc trunk/plugins/icq/misc.c trunk/plugins/rivchat/misc.c trunk/plugins/rivchat/rivchat.c trunk/plugins/sniff/sniff.c trunk/plugins/sniff/sniff_gg.inc trunk/plugins/sniff/sniff_rivchat.inc Log: it looks ok, more cleanup later. Modified: trunk/ekg/Makefile.am =================================================================== --- trunk/ekg/Makefile.am 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/ekg/Makefile.am 2008-09-03 21:10:01 UTC (rev 4597) @@ -3,7 +3,7 @@ bin_PROGRAMS = ekg2 ekg2_SOURCES = audio.c commands.c configfile.c dynstuff.c ekg.c emoticons.c events.c legacyconfig.c log.c metacontacts.c \ - msgqueue.c plugins.c protocol.c sessions.c stuff.c themes.c userlist.c vars.c queries.h windows.c xmalloc.c net.c srv.c scripts.c strings.c win32.c $(ekg2_headers) + msgqueue.c plugins.c protocol.c recode.c sessions.c stuff.c themes.c userlist.c vars.c queries.h windows.c xmalloc.c net.c srv.c scripts.c strings.c win32.c $(ekg2_headers) ekg2includedir = $(includedir)/ekg2 Modified: trunk/ekg/ekg.c =================================================================== --- trunk/ekg/ekg.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/ekg/ekg.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -964,6 +964,7 @@ no_config = 1; config_postread(); + ekg_recode_reinit(); /* status window takes first session if not set before*/ if (!session_current && sessions) @@ -1160,6 +1161,7 @@ newconferences_destroy(); metacontacts_destroy(); sessions_free(); + ekg_recode_destroy(); { plugin_t *p; Modified: trunk/ekg/recode.c =================================================================== --- trunk/ekg/recode.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/ekg/recode.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -44,7 +44,7 @@ #include "commands.h" #include "dynstuff.h" #include "dynstuff_inline.h" -#include "recode.h" +// #include "recode.h" #include "stuff.h" #include "windows.h" #include "xmalloc.h" @@ -772,3 +772,32 @@ } + +void ekg_recode_destroy() { + if (cp_conv_in != EKG_ICONV_BAD) { + ekg_convert_string_destroy(cp_conv_in); + ekg_convert_string_destroy(cp_conv_out); + } + + if (utf8_conv_in != EKG_ICONV_BAD) { + ekg_convert_string_destroy(utf8_conv_in); + ekg_convert_string_destroy(utf8_conv_out); + } +} + + +void ekg_recode_reinit() { + ekg_recode_destroy(); + + if ( +#if (USE_UNICODE || HAVE_GTK) + config_use_unicode || +#endif + !xstrcasecmp(config_console_charset, "ISO-8859-2")) + cp_conv_in = cp_conv_out = (void*) EKG_ICONV_BAD; + else + cp_conv_in = ekg_convert_string_init("CP1250", NULL, &cp_conv_out); + + utf8_conv_in = ekg_convert_string_init("UTF-8", NULL, &utf8_conv_out); +} + Modified: trunk/ekg/stuff.c =================================================================== --- trunk/ekg/stuff.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/ekg/stuff.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -2765,417 +2765,7 @@ #endif } -#ifdef HAVE_ICONV -/* Following two functions shamelessly ripped from mutt-1.4.2i - * (http://www.mutt.org, license: GPL) - * - * Copyright (C) 1999-2000 Thomas Roessler - * Modified 2004 by Maciek Pasternacki - */ - -/* - * Like iconv, but keeps going even when the input is invalid - * If you're supplying inrepls, the source charset should be stateless; - * if you're supplying an outrepl, the target charset should be. - */ -static inline size_t mutt_iconv (iconv_t cd, char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft, - char **inrepls, const char *outrepl) -{ - size_t ret = 0, ret1; - char *ib = *inbuf; - size_t ibl = *inbytesleft; - char *ob = *outbuf; - size_t obl = *outbytesleft; - - for (;;) { - ret1 = iconv (cd, &ib, &ibl, &ob, &obl); - if (ret1 != (size_t)-1) - ret += ret1; - if (ibl && obl && errno == EILSEQ) { - if (inrepls) { - /* Try replacing the input */ - char **t; - for (t = inrepls; *t; t++) - { - char *ib1 = *t; - size_t ibl1 = xstrlen (*t); - char *ob1 = ob; - size_t obl1 = obl; - iconv (cd, &ib1, &ibl1, &ob1, &obl1); - if (!ibl1) { - ++ib, --ibl; - ob = ob1, obl = obl1; - ++ret; - break; - } - } - if (*t) - continue; - } - if (outrepl) { - /* Try replacing the output */ - int n = xstrlen (outrepl); - if (n <= obl) - { - memcpy (ob, outrepl, n); - ++ib, --ibl; - ob += n, obl -= n; - ++ret; - continue; - } - } - } - *inbuf = ib, *inbytesleft = ibl; - *outbuf = ob, *outbytesleft = obl; - return ret; - } -} - -/* - * Convert a string - * Used in rfc2047.c and rfc2231.c - * - * Broken for use within EKG2 (passing iconv_t instead of from/to) - */ - -static inline string_t mutt_convert_string (string_t s, iconv_t cd, int is_utf) -{ - string_t ret; - char *repls[] = { "\357\277\275", "?", 0 }; - /* we can assume that both from and to aren't NULL in EKG2, - * and cd is NULL in case of error, not -1 */ - if (cd) { - char *ib; - char *buf, *ob; - size_t ibl, obl; - char **inrepls = 0; - char *outrepl = 0; - - if ( is_utf == 2 ) /* to utf */ - outrepl = repls[0]; /* this would be more evil */ - else if ( is_utf == 1 ) /* from utf */ - inrepls = repls; - else - outrepl = "?"; - - ib = s->str; - ibl = s->len + 1; - obl = 16 * ibl; - ob = buf = xmalloc (obl + 1); - - mutt_iconv (cd, &ib, &ibl, &ob, &obl, inrepls, outrepl); - - ret = string_init(NULL); - string_append_raw(ret, buf, ob - buf); - - xfree(buf); - - return ret; - } - return NULL; -} - -/* End of code taken from mutt. */ -#endif /*HAVE_ICONV*/ - -#ifdef HAVE_ICONV /** - * struct ekg_converter - * - * Used internally by EKG2, contains information about one initialized character converter. - */ -struct ekg_converter { - struct ekg_converter *next; - - iconv_t cd; /**< Magic thing given to iconv, always not NULL (else we won't alloc struct) */ - iconv_t rev; /**< Reverse conversion thing, can be NULL */ - char *from; /**< Input encoding (duped), always not NULL (even on console_charset) */ - char *to; /**< Output encoding (duped), always not NULL (even on console_charset) */ - int used; /**< Use counter - incr on _init(), decr on _destroy(), free if 0 */ - int rev_used; /**< Like above, but for rev; if !rev, value undefined */ - int is_utf; /**< Used internally for mutt_convert_string() */ -}; - -static struct ekg_converter *ekg_converters = NULL; /**< list for internal use of ekg_convert_string_*() */ - -static LIST_FREE_ITEM(list_ekg_converter_free, struct ekg_converter *) { xfree(data->from); xfree(data->to); } -DYNSTUFF_LIST_DECLARE(ekg_converters, struct ekg_converter, list_ekg_converter_free, - static __DYNSTUFF_LIST_ADD, /* ekg_converters_add() */ - static __DYNSTUFF_LIST_REMOVE_ITER, /* ekg_converters_removei() */ - __DYNSTUFF_NODESTROY) /* XXX? */ - -#endif - -/** - * ekg_convert_string_init() - * - * Initialize string conversion thing for two given charsets. - * - * @param from - input encoding (will be duped; if NULL, console_charset will be assumed). - * @param to - output encoding (will be duped; if NULL, console_charset will be assumed). - * @param rev - pointer to assign reverse conversion into; if NULL, no reverse converter will be initialized. - * - * @return Pointer that should be passed to other ekg_convert_string_*(), even if it's NULL. - * - * @sa ekg_convert_string_destroy() - deinits charset conversion. - * @sa ekg_convert_string_p() - main charset conversion function. - */ -void *ekg_convert_string_init(const char *from, const char *to, void **rev) { -#ifdef HAVE_ICONV - struct ekg_converter *p; - - if (!from) - from = config_console_charset; - if (!to) - to = config_console_charset; - if (!xstrcasecmp(from, to)) { /* if they're the same */ - if (rev) - *rev = NULL; - return NULL; - } - - /* maybe we've already got some converter for this charsets */ - for (p = ekg_converters; p; p = p->next) { - if (!xstrcasecmp(from, p->from) && !xstrcasecmp(to, p->to)) { - p->used++; - if (rev) { - if (!p->rev) { /* init rev */ - p->rev = iconv_open(from, to); - if (p->rev == (iconv_t)-1) /* we don't want -1 */ - p->rev = NULL; - else - p->rev_used = 1; - } else - p->rev_used++; - *rev = p->rev; - } - return p->cd; - } else if (!xstrcasecmp(from, p->to) && !xstrcasecmp(to, p->from)) { - /* we've got reverse thing */ - if (rev) { /* our rev means its forw */ - p->used++; - *rev = p->cd; - } - if (!p->rev) { - p->rev = iconv_open(to, from); - if (p->rev == (iconv_t)-1) - p->rev = NULL; - else - p->rev_used = 1; - } else - p->rev_used++; - return p->rev; - } - } - - { - iconv_t cd, rcd = NULL; - - if ((cd = iconv_open(to, from)) == (iconv_t)-1) - cd = NULL; - if (rev) { - if ((rcd = iconv_open(from, to)) == (iconv_t)-1) - rcd = NULL; - *rev = rcd; - } - - if (cd || rcd) { /* don't init struct if both are NULL */ - struct ekg_converter *c = xmalloc(sizeof(struct ekg_converter)); - - /* if cd is NULL, we reverse everything */ - c->cd = (cd ? cd : rcd); - c->rev = (cd ? rcd : cd); - c->from = (cd ? xstrdup(from) : xstrdup(to)); - c->to = (cd ? xstrdup(to) : xstrdup(from)); - c->used = 1; - c->rev_used = (cd && rcd ? 1 : 0); - /* for mutt_convert_string() */ - if (!xstrcasecmp(c->to, "UTF-8")) - c->is_utf = 2; - else if (!xstrcasecmp(c->from, "UTF-8")) - c->is_utf = 1; - ekg_converters_add(c); - } - - return cd; - } -#else - return NULL; -#endif -} - -/** - * ekg_convert_string_destroy() - * - * Frees internal data associated with given pointer, and uninitalizes iconv, if it's not needed anymore. - * - * @note If 'rev' param was used with ekg_convert_string_init(), this functions must be called two times - * - with returned value, and with rev-associated one. - * - * @param ptr - pointer returned by ekg_convert_string_init(). - * - * @sa ekg_convert_string_init() - init charset conversion. - * @sa ekg_convert_string_p() - main charset conversion function. - */ - -void ekg_convert_string_destroy(void *ptr) { -#ifdef HAVE_ICONV - struct ekg_converter *c; - - if (!ptr) /* we can be called with NULL ptr */ - return; - - for (c = ekg_converters; c; c = c->next) { - if (c->cd == ptr) - c->used--; - else if (c->rev == ptr) /* ptr won't be NULL here */ - c->rev_used--; - else - continue; /* we're gonna break */ - - if (c->rev && (c->rev_used == 0)) { /* deinit reverse converter */ - iconv_close(c->rev); - c->rev = NULL; - } - if (c->used == 0) { /* deinit forward converter, if not needed */ - iconv_close(c->cd); - - if (c->rev) { /* if reverse converter is still used, reverse the struct */ - c->cd = c->rev; - c->rev = NULL; /* rev_used becomes undef */ - c->used = c->rev_used; - { - char *tmp = c->from; - c->from = c->to; - c->to = tmp; - } - } else { /* else, free it */ - (void) ekg_converters_removei(c); - } - } - - break; - } -#endif -} - -/** - * ekg_convert_string_p() - * - * Converts string to specified encoding, using pointer returned by ekg_convert_string_init(). - * Invalid characters in input will be replaced with question marks. - * - * @param ps - string to be converted (won't be freed). - * @param ptr - pointer returned by ekg_convert_string_init(). - * - * @return Pointer to allocated result or NULL, if some failure has occured or no conversion - * is needed (i.e. resulting string would be same as input). - * - * @sa ekg_convert_string_init() - init charset conversion. - * @sa ekg_convert_string_destroy() - deinits charset conversion. - */ - -char *ekg_convert_string_p(const char *ps, void *ptr) { - string_t s = string_init(ps); - string_t recod; - - if ((recod = ekg_convert_string_t_p(s, ptr))) - return string_free(recod, 0); - - return NULL; -} - -/** - * ekg_convert_string() - * - * Converts string to specified encoding, replacing invalid chars with question marks. - * - * @note Deprecated, in favour of ekg_convert_string_p(). Should be used only on single - * conversions, where charset pair won't be used again. - * - * @param ps - string to be converted (it won't be freed). - * @param from - input encoding (if NULL, console_charset will be assumed). - * @param to - output encoding (if NULL, console_charset will be assumed). - * - * @return Pointer to allocated result on success, NULL on failure - * or when both encodings are equal. - * - * @sa ekg_convert_string_p() - more optimized version. - */ -char *ekg_convert_string(const char *ps, const char *from, const char *to) { - char *r; - void *p; - - if (!ps || !*ps) /* don't even init iconv if we've got NULL string */ - return NULL; - - p = ekg_convert_string_init(from, to, NULL); - r = ekg_convert_string_p(ps, p); - ekg_convert_string_destroy(p); - - return r; -} - -string_t ekg_convert_string_t_p(string_t s, void *ptr) { -#ifdef HAVE_ICONV - struct ekg_converter *c; - int is_utf = 0; - - if (!s || !s->len || !ptr) - return NULL; - - /* XXX, maybe some faster way? any ideas? */ - for (c = ekg_converters; c; c = c->next) { - if (c->cd == ptr) - is_utf = c->is_utf; - else if (c->rev == ptr) - is_utf = (c->is_utf == 2 ? 1 : (c->is_utf == 1 ? 2 : 0)); - else - continue; - - break; - } - - return mutt_convert_string(s, ptr, is_utf); -#else - return NULL; -#endif -} - -string_t ekg_convert_string_t(string_t s, const char *from, const char *to) { - string_t r; - void *p; - - if (!s || !s->len) /* don't even init iconv if we've got NULL string */ - return NULL; - - p = ekg_convert_string_init(from, to, NULL); - r = ekg_convert_string_t_p(s, p); - ekg_convert_string_destroy(p); - return r; -} - -int ekg_converters_display(int quiet) -{ -#ifdef HAVE_ICONV - struct ekg_converter *c; - - for (c = ekg_converters; c; c = c->next) { - /* cd, rev, from, to, used, rev_used, is_utf */ - - printq("iconv_list", c->from, c->to, itoa(c->used), itoa(c->rev_used)); -// printq("iconv_list_bad", c->from, c->to, itoa(c->used), itoa(c->rev_used)); - - } - return 0; -#else - printq("generic_error", "Sorry, no iconv"); - return -1; -#endif -} - -/** * ekg_write() * * write data to given fd, if it cannot be done [because system buffer is too small. it'll create watch, and write as soon as possible] Modified: trunk/ekg/stuff.h =================================================================== --- trunk/ekg/stuff.h 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/ekg/stuff.h 2008-09-03 21:10:01 UTC (rev 4597) @@ -385,6 +385,7 @@ void ekg_yield_cpu(); +/* recode.c XXX, przeniesc do recode.h */ void *ekg_convert_string_init(const char *from, const char *to, void **rev); void ekg_convert_string_destroy(void *ptr); char *ekg_convert_string_p(const char *ps, void *ptr); @@ -392,6 +393,17 @@ string_t ekg_convert_string_t_p(string_t s, void *ptr); string_t ekg_convert_string_t(string_t s, const char *from, const char *to); int ekg_converters_display(int quiet); + +char *ekg_locale_to_cp(char *buf); +char *ekg_cp_to_locale(char *buf); +char *ekg_locale_to_latin2(char *buf); +char *ekg_latin2_to_locale(char *buf); +char *ekg_locale_to_utf8(char *buf); +char *ekg_utf8_to_locale(char *buf); +char *ekg_any_to_locale(char *buf, char *inp); +char *ekg_locale_to_any(char *buf, char *inp); + + char *password_input(const char *prompt, const char *rprompt, const bool norepeat); /* funkcje poza stuff.c */ Modified: trunk/plugins/gg/commands.c =================================================================== --- trunk/plugins/gg/commands.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/gg/commands.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -110,11 +110,11 @@ if (__reason) { if (!xstrcmp(__reason, "-")) myreason = NULL; else myreason = xstrdup(__reason); - tmp = gg_locale_to_cp(xstrdup(myreason)); + tmp = ekg_locale_to_cp(xstrdup(myreason)); session_descr_set(session, tmp ? myreason : NULL); } else { myreason = xstrdup(session_descr_get(session)); - tmp = gg_locale_to_cp(xstrdup(myreason)); + tmp = ekg_locale_to_cp(xstrdup(myreason)); } if (tmp) gg_change_status_descr(g->sess, GG_STATUS_NOT_AVAIL_DESCR, tmp); @@ -317,9 +317,9 @@ xfree(fwd); } - /* moved this further, because of gg_locale_to_cp() allocation */ + /* moved this further, because of ekg_locale_to_cp() allocation */ p.status = _status; - p.status_descr = gg_locale_to_cp(xstrdup(session_descr_get(session))); + p.status_descr = ekg_locale_to_cp(xstrdup(session_descr_get(session))); p.async = 1; g->sess = gg_login(&p); @@ -494,7 +494,7 @@ ekg_update_status(session); - cpdescr = gg_locale_to_cp(descr); + cpdescr = ekg_locale_to_cp(descr); _status = GG_S(gg_text_to_status(status, cpdescr)); /* descr can be NULL it doesn't matter... */ if (session_int_get(session, "private")) @@ -723,7 +723,7 @@ } raw_msg = xstrdup((char *) msg); - cpmsg = gg_locale_to_cp((char *) msg); + cpmsg = ekg_locale_to_cp((char *) msg); count = array_count(nicks); Modified: trunk/plugins/gg/gg.c =================================================================== --- trunk/plugins/gg/gg.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/gg/gg.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -667,7 +667,7 @@ descr = xstrdup(session_descr_get(s)); status = session_status_get(s); - cpdescr = gg_locale_to_cp(descr); + cpdescr = ekg_locale_to_cp(descr); /* ustawiamy swój status */ _status = GG_S(gg_text_to_status(status, s->descr ? cpdescr : NULL)); @@ -756,7 +756,7 @@ */ static void gg_session_handler_status(session_t *s, uin_t uin, int status, const char *descr, uint32_t ip, uint16_t port, int protocol) { char *__uid = saprintf(("gg:%d"), uin); - char *__descr = gg_cp_to_locale(xstrdup(descr)); + char *__descr = ekg_cp_to_locale(xstrdup(descr)); int i, j, dlen, state = 0, m = 0; { @@ -864,7 +864,7 @@ for (i = 0; i < e->event.msg.recipients_count; i++) array_add(&__rcpts, saprintf("gg:%d", e->event.msg.recipients[i])); - __text = gg_cp_to_locale(xstrdup((const char *) e->event.msg.message)); + __text = ekg_cp_to_locale(xstrdup((const char *) e->event.msg.message)); if (e->event.msg.formats && e->event.msg.formats_length) { unsigned char *p = e->event.msg.formats; @@ -1149,7 +1149,7 @@ gg_remove_notify_ex(g->sess, str_to_uin(parsed + 1), gg_userlist_type(u)); } - reply = gg_cp_to_locale(xstrdup(e->event.userlist.reply)); + reply = ekg_cp_to_locale(xstrdup(e->event.userlist.reply)); gg_userlist_set(s, reply); xfree(reply); gg_userlist_send(g->sess, s->userlist); @@ -1438,7 +1438,7 @@ if (!s || !s->connected || !(g = s->priv)) return; - cpdescr = gg_locale_to_cp(xstrdup(s->descr)); + cpdescr = ekg_locale_to_cp(xstrdup(s->descr)); status = gg_text_to_status(s->status, cpdescr); /* XXX, check if gg_text_to_status() return smth correct */ if (session_int_get(s, "private") > 0) @@ -1508,7 +1508,7 @@ static void gg_statusdescr_handler(session_t *s, const char *varname) { gg_private_t *g = session_private_get(s); - char *cpdescr = gg_locale_to_cp(xstrdup(session_descr_get(s))); + char *cpdescr = ekg_locale_to_cp(xstrdup(session_descr_get(s))); int _status = GG_S(gg_text_to_status(session_status_get(s), cpdescr)); if (session_int_get(s, "private")) @@ -1682,7 +1682,6 @@ query_connect_id(&gg_plugin, PROTOCOL_UNIGNORE, gg_user_online_handle, (void *)1); query_connect_id(&gg_plugin, USERLIST_INFO, gg_userlist_info_handle, NULL); query_connect_id(&gg_plugin, USERLIST_PRIVHANDLE, gg_userlist_priv_handler, NULL); - query_connect_id(&gg_plugin, CONFIG_POSTINIT, gg_convert_string_init, NULL); gg_register_commands(); @@ -1738,7 +1737,6 @@ gg_register_email = NULL; image_flush_queue(); - gg_convert_string_destroy(); plugin_unregister(&gg_plugin); Modified: trunk/plugins/gg/misc.c =================================================================== --- trunk/plugins/gg/misc.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/gg/misc.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -35,186 +35,7 @@ #include "gg.h" -void *conv_in = (void*) -1; -void *conv_out = (void*) -1; - -/* 80..9F = ?; here is A0..BF, C0..FF is the same */ -static const unsigned char iso_to_cp_table[] = { - 0xa0, 0xa5, 0xa2, 0xa3, 0xa4, 0xbc, 0x8c, 0xa7, - 0xa8, 0x8a, 0xaa, 0x8d, 0x8f, 0xad, 0x8e, 0xaf, - 0xb0, 0xb9, 0xb2, 0xb3, 0xb4, 0xbe, 0x9c, 0xa1, - 0xb8, 0x9a, 0xba, 0x9d, 0x9f, 0xbd, 0x9e, 0xbf, -}; - -static const unsigned char cp_to_iso_table[] = { - '?', '?', '?', '?', '?', '?', '?', '?', - '?', '?', 0xa9, '?', 0xa6, 0xab, 0xae, 0xac, - '?', '?', '?', '?', '?', '?', '?', '?', - '?', '?', 0xb9, '?', 0xb6, 0xbb, 0xbe, 0xbc, - 0xa0, 0xb7, 0xa2, 0xa3, 0xa4, 0xa1, '?', 0xa7, - 0xa8, '?', 0xaa, '?', '?', 0xad, '?', 0xaf, - 0xb0, '?', 0xb2, 0xb3, 0xb4, '?', '?', '?', - 0xb8, 0xb1, 0xba, '?', 0xa5, 0xbd, 0xb5, 0xbf, -}; - /* - * gg_cp_to_iso() - * - * zamienia na miejscu krzaczki pisane w cp1250 na iso-8859-2. - * - * - buf. - */ -static unsigned char *gg_cp_to_iso(unsigned char *buf) { - unsigned char *tmp = buf; - - if (!buf) - return NULL; - - while (*buf) { - if (*buf >= 0x80 && *buf < 0xC0) - *buf = cp_to_iso_table[*buf - 0x80]; - - buf++; - } - return tmp; -} - -/* - * gg_iso_to_cp() - * - * zamienia na miejscu iso-8859-2 na cp1250. - * - * - buf. - */ -static unsigned char *gg_iso_to_cp(unsigned char *buf) { - unsigned char *tmp = buf; - if (!buf) - return NULL; - - while (*buf) { - if (*buf >= 0x80 && *buf < 0xA0) - *buf = '?'; - else if (*buf >= 0xA0 && *buf < 0xC0) - *buf = iso_to_cp_table[*buf - 0xA0]; - - buf++; - } - return tmp; -} - -#if (USE_UNICODE || HAVE_GTK) -static const unsigned short table_cp1250[] = { - 0x20ac, 0x0000, 0x201a, 0x0000, 0x201e, 0x2026, 0x2020, 0x2021, - 0x0000, 0x2030, 0x0160, 0x2039, 0x015a, 0x0164, 0x017d, 0x0179, - 0x0000, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, - 0x0000, 0x2122, 0x0161, 0x203a, 0x015b, 0x0165, 0x017e, 0x017a, - 0x00a0, 0x02c7, 0x02d8, 0x0141, 0x00a4, 0x0104, 0x00a6, 0x00a7, - 0x00a8, 0x00a9, 0x015e, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x017b, - 0x00b0, 0x00b1, 0x02db, 0x0142, 0x00b4, 0x00b5, 0x00b6, 0x00b7, - 0x00b8, 0x0105, 0x015f, 0x00bb, 0x013d, 0x02dd, 0x013e, 0x017c, - 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, - 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e, - 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, - 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df, - 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, - 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f, - 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, - 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9, -}; -#endif - -char *gg_locale_to_cp(char *b) { - unsigned char *buf = (unsigned char *) b; - - if (!buf) - return NULL; -#if (USE_UNICODE || HAVE_GTK) - if (config_use_unicode) { /* why not iconv? iconv is too big for recoding only utf-8 <==> cp1250 */ - int len = mbstowcs(NULL, b, 0)+1; /* it's safe mbstowcs() can return -1 */ - wchar_t *tmp = xmalloc(len*sizeof(wchar_t)); /* so here we malloc(0) it returns NULL */ - int i; - - if (len == 0 || (mbstowcs(tmp, b, len-1)) == -1) { /* invalid multibyte seq */ - if (len) debug("[%s:%d] mbstowcs() failed with: %s (%d)\n", errno, strerror(errno)); - xfree(tmp); - return b; /* return `unicode` seq? */ - } - buf = xrealloc(buf, len * sizeof(char)); - - for (i = 0; i < len-1; i++) { - int j = 0; - buf[i] = '?'; - if (tmp[i] < 0x80) - buf[i] = tmp[i]; - else while (j < 8 * 16) { - if (table_cp1250[j++] != tmp[i]) continue; - buf[i] = 0x7F + j; - break; - } - } - xfree(tmp); - buf[len-1] = 0; - return (char *) buf; - } else -#endif - if (conv_out != (void*) -1) { - char *out = ekg_convert_string_p(b, conv_out); - if (out) - xfree(buf); - else - out = b; - return out; - } else - return (char *) gg_iso_to_cp(buf); -} - -char *gg_cp_to_locale(char *b) { - unsigned char *buf = (unsigned char *) b; - - if (!buf) - return NULL; -#if (USE_UNICODE || HAVE_GTK) - if (config_use_unicode) { /* shitty way with string_t */ - /* wchar */ - int len = xstrlen(b); - wchar_t *tmp = xmalloc((len+1)*sizeof(wchar_t)); /* optimize len ? DELAYED */ - /* char */ - char *newbuf; - int n, i; - - for (i=0; i < len; i++) { - if (buf[i] < 0x80) tmp[i] = buf[i]; /* ASCII */ - else if (buf[i] == 0x81 || buf[i] == 0x83 || buf[i] == 0x88 || buf[i] == 0x90 || buf[i] == 0x98) /* undefined chars in cp1250 */ - tmp[i] = '?'; - else tmp[i] = table_cp1250[buf[i]-0x80]; /* unicode <==> cp1250 */ - } - - n = wcstombs(NULL, tmp, 0)+1; - newbuf = xmalloc(n+1); - - if ((wcstombs(newbuf, tmp, n)) == -1) { - debug("[%s:%d] wcstombs() failed with: %s (%d)\n", errno, strerror(errno)); - xfree(newbuf); - xfree(tmp); - return b; /* return `cp` seq ? */ - } - xfree(tmp); - xfree(buf); /* XXX, need testing */ - return newbuf; - } else -#endif - if (conv_in != (void*) -1) { - char *out = ekg_convert_string_p(b, conv_in); - if (out) - xfree(b); - else - out = b; - return out; - } else - return (char *) gg_cp_to_iso(buf); -} - -/* * gg_status_to_text() * * zamienia stan GG na enum ekg2 (dawniej: tekst, stad nazwa). @@ -416,28 +237,6 @@ return res; } -void gg_convert_string_destroy() { - if (conv_in != (void*) -1) { - ekg_convert_string_destroy(conv_in); - ekg_convert_string_destroy(conv_out); - } -} - -QUERY(gg_convert_string_init) { - gg_convert_string_destroy(); /* reinit? */ - - if ( -#if (USE_UNICODE || HAVE_GTK) - config_use_unicode || -#endif - !xstrcasecmp(config_console_charset, "ISO-8859-2")) - conv_in = conv_out = (void*) -1; - else - conv_in = ekg_convert_string_init("CP1250", NULL, &conv_out); - - return 0; -} - /* * Local Variables: * mode: c Modified: trunk/plugins/gg/misc.h =================================================================== --- trunk/plugins/gg/misc.h 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/gg/misc.h 2008-09-03 21:10:01 UTC (rev 4597) @@ -26,17 +26,12 @@ int gg_status_to_text(const int status); int gg_text_to_status(const int status, const char *descr); -char *gg_locale_to_cp(char *buf); -char *gg_cp_to_locale(char *buf); char gg_userlist_type(userlist_t *u); int gg_blocked_add(session_t *s, const char *uid); int gg_blocked_remove(session_t *s, const char *uid); const char *gg_http_error_string(int h); int gg_userlist_send(struct gg_session *s, userlist_t *userlist); -void gg_convert_string_destroy(); -QUERY(gg_convert_string_init); - #endif /* Modified: trunk/plugins/gg/pubdir.c =================================================================== --- trunk/plugins/gg/pubdir.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/gg/pubdir.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -135,7 +135,7 @@ } else if (!(passwd_b = password_input(NULL, NULL, 0))) return -1; - passwd = gg_locale_to_cp(xstrdup(passwd_b)); + passwd = ekg_locale_to_cp(xstrdup(passwd_b)); if (!(h = gg_register3(params[0], passwd, last_tokenid, params[1], 1))) { xfree(passwd); @@ -223,7 +223,7 @@ printq("unregister_bad_uin", params[0]); return -1; } - passwd = gg_locale_to_cp(xstrdup(params[1])); + passwd = ekg_locale_to_cp(xstrdup(params[1])); if (!(h = gg_unregister3(uin, passwd, last_tokenid, params[2], 1))) { printq("unregister_failed", strerror(errno)); @@ -364,13 +364,13 @@ #else if (!params[0]) { #endif - newpasswd = gg_locale_to_cp(password_input(NULL, NULL, 0)); + newpasswd = ekg_locale_to_cp(password_input(NULL, NULL, 0)); if (!newpasswd) return -1; } else - newpasswd = gg_locale_to_cp(xstrdup(params[0])); + newpasswd = ekg_locale_to_cp(xstrdup(params[0])); - oldpasswd = gg_locale_to_cp(xstrdup(session_get(session, "password"))); + oldpasswd = ekg_locale_to_cp(xstrdup(session_get(session, "password"))); #ifdef HAVE_GG_CHANGE_PASSWD4 if (!(h = gg_change_passwd4(atoi(session->uid + 3), config_email, (oldpasswd) ? oldpasswd : "", newpasswd, last_tokenid, params[1] ? params[1] : params[0], 1))) @@ -624,7 +624,7 @@ } #endif contacts = gg_userlist_dump(session); - cpcontacts = gg_locale_to_cp(contacts); + cpcontacts = ekg_locale_to_cp(contacts); if (gg_userlist_request(g->sess, GG_USERLIST_PUT, cpcontacts) == -1) { printq("userlist_put_error", strerror(errno)); Modified: trunk/plugins/gg/pubdir50.c =================================================================== --- trunk/plugins/gg/pubdir50.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/gg/pubdir50.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -95,7 +95,7 @@ uargv = xcalloc(array_count(argv)+1, sizeof(char **)); for (i = 0; argv[i]; i++) - uargv[i] = gg_locale_to_cp(argv[i]); + uargv[i] = ekg_locale_to_cp(argv[i]); for (i = 0; argv[i]; i++) { char *arg = argv[i]; @@ -213,7 +213,7 @@ char **argv = array_make(params[0], (" \t"), 0, 1, 1); for (i = 0; argv[i]; i++) - argv[i] = gg_locale_to_cp(argv[i]); + argv[i] = ekg_locale_to_cp(argv[i]); for (i = 0; argv[i]; i++) { if (match_arg(argv[i], 'f', ("first"), 2) && argv[i + 1]) { @@ -326,10 +326,10 @@ const char *__birthyear = gg_pubdir50_get(res, i, "birthyear"); const char *__city = gg_pubdir50_get(res, i, "city"); - char *firstname = gg_cp_to_locale(xstrdup(__firstname)); - char *lastname = gg_cp_to_locale(xstrdup(__lastname)); - char *nickname = gg_cp_to_locale(xstrdup(__nickname)); - char *city = gg_cp_to_locale(xstrdup(__city)); + char *firstname = ekg_cp_to_locale(xstrdup(__firstname)); + char *lastname = ekg_cp_to_locale(xstrdup(__lastname)); + char *nickname = ekg_cp_to_locale(xstrdup(__nickname)); + char *city = ekg_cp_to_locale(xstrdup(__city)); int status = (__fmstatus) ? atoi(__fmstatus) : GG_STATUS_NOT_AVAIL; const char *birthyear = (__birthyear && xstrcmp(__birthyear, "0")) ? __birthyear : NULL; Modified: trunk/plugins/icq/icq_snac_handlers_13userlist.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_13userlist.inc 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/icq/icq_snac_handlers_13userlist.inc 2008-09-03 21:10:01 UTC (rev 4597) @@ -120,16 +120,16 @@ /* XXX make macro ? */ tmp = (t_comment && t_comment->len) ? xstrndup((char *) t_comment->buf, t_comment->len) : NULL; - comment = icq_convert_from_utf8(tmp); + comment = ekg_utf8_to_locale(tmp); tmp = (t_phone && t_phone->len) ? xstrndup((char *) t_phone->buf, t_phone->len) : NULL; - phone = icq_convert_from_utf8(tmp); + phone = ekg_utf8_to_locale(tmp); tmp = (t_email && t_email->len) ? xstrndup((char *) t_email->buf, t_email->len) : NULL; - email = icq_convert_from_utf8(tmp); + email = ekg_utf8_to_locale(tmp); tmp = (t_nick && t_nick->len) ? xstrndup((char *) t_nick->buf, t_nick->len) : xstrdup(uid); - nick = icq_convert_from_utf8(tmp); + nick = ekg_utf8_to_locale(tmp); userlist_t *u; @@ -344,7 +344,7 @@ tlvs = icq_unpack_tlvs_nc(buf, tlv_len, 0); - name = icq_convert_from_utf8(xstrdup(orgname)); + name = ekg_utf8_to_locale(xstrdup(orgname)); icq_userlist_parse_entry(s, tlvs, name, item_type, item_id, group_id); xfree(name); Modified: trunk/plugins/icq/misc.c =================================================================== --- trunk/plugins/icq/misc.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/icq/misc.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -36,10 +36,7 @@ void *ucs2be_conv_in = (void*) -1; void *ucs2be_conv_out = (void*) -1; -void *utf8_conv_in = (void*) -1; -void *utf8_conv_out = (void*) -1; - void icq_hexdump(int level, unsigned char *p, size_t len) { #define MAX_BYTES_PER_LINE 16 unsigned char *payload = (unsigned char *) p; @@ -624,7 +621,6 @@ void icq_convert_string_init() { ucs2be_conv_in = ekg_convert_string_init("UCS-2BE", NULL, &ucs2be_conv_out); - utf8_conv_in = ekg_convert_string_init("UTF-8", NULL, &utf8_conv_out); } void icq_convert_string_destroy() { @@ -632,10 +628,6 @@ ekg_convert_string_destroy(ucs2be_conv_in); ekg_convert_string_destroy(ucs2be_conv_out); } - if (utf8_conv_in != (void*) -1) { - ekg_convert_string_destroy(utf8_conv_in); - ekg_convert_string_destroy(utf8_conv_out); - } } char *icq_convert_from_ucs2be(string_t text) { @@ -670,22 +662,6 @@ return ret; } -char *icq_convert_from_utf8(char *text) { - char *tmp; - - if (!text || !*text) - return NULL; - - if (!(tmp = ekg_convert_string_p(text, utf8_conv_in))) { - tmp = text; - text = NULL; - /* XXX, warn user? */ - } - - xfree(text); - return tmp; -} - char *int2time_str(const char *format, int time) { static char buf[100]; time_t t = time; Modified: trunk/plugins/rivchat/misc.c =================================================================== --- trunk/plugins/rivchat/misc.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/rivchat/misc.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -24,229 +24,6 @@ #include #include -/* these stuff was stolen from ekg2 gadu-gadu plugin, and libgadu */ - -/* utf-8,iso-8859-2 <==> CP-1250 */ - -/* 80..9F = ?; here is A0..BF, C0..FF is the same */ -static const unsigned char iso_to_cp_table[] = { - 0xa0, 0xa5, 0xa2, 0xa3, 0xa4, 0xbc, 0x8c, 0xa7, - 0xa8, 0x8a, 0xaa, 0x8d, 0x8f, 0xad, 0x8e, 0xaf, - 0xb0, 0xb9, 0xb2, 0xb3, 0xb4, 0xbe, 0x9c, 0xa1, - 0xb8, 0x9a, 0xba, 0x9d, 0x9f, 0xbd, 0x9e, 0xbf, -}; - -static const unsigned char cp_to_iso_table[] = { - '?', '?', '?', '?', '?', '?', '?', '?', - '?', '?', 0xa9, '?', 0xa6, 0xab, 0xae, 0xac, - '?', '?', '?', '?', '?', '?', '?', '?', - '?', '?', 0xb9, '?', 0xb6, 0xbb, 0xbe, 0xbc, - 0xa0, 0xb7, 0xa2, 0xa3, 0xa4, 0xa1, '?', 0xa7, - 0xa8, '?', 0xaa, '?', '?', 0xad, '?', 0xaf, - 0xb0, '?', 0xb2, 0xb3, 0xb4, '?', '?', '?', - 0xb8, 0xb1, 0xba, '?', 0xa5, 0xbd, 0xb5, 0xbf, -}; - -/* - * rivchat_cp_to_iso() - * - * zamienia na miejscu krzaczki pisane w cp1250 na iso-8859-2. - * - * - buf. - */ -static unsigned char *rivchat_cp_to_iso(unsigned char *buf) { - unsigned char *tmp = buf; - - if (!buf) - return NULL; - - while (*buf) { - if (*buf >= 0x80 && *buf < 0xC0) - *buf = cp_to_iso_table[*buf - 0x80]; - - buf++; - } - return tmp; -} - -/* - * rivchat_iso_to_cp() - * - * zamienia na miejscu iso-8859-2 na cp1250. - * - * - buf. - */ -static unsigned char *rivchat_iso_to_cp(unsigned char *buf) { - unsigned char *tmp = buf; - if (!buf) - return NULL; - - while (*buf) { - if (*buf >= 0x80 && *buf < 0xA0) - *buf = '?'; - else if (*buf >= 0xA0 && *buf < 0xC0) - *buf = iso_to_cp_table[*buf - 0xA0]; - - buf++; - } - return tmp; -} - -#if (USE_UNICODE || HAVE_GTK) -static const uint16_t table_cp1250[] = { - 0x20ac, '?', 0x201a, '?', 0x201e, 0x2026, 0x2020, 0x2021, - '?', 0x2030, 0x0160, 0x2039, 0x015a, 0x0164, 0x017d, 0x0179, - '?', 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, - '?', 0x2122, 0x0161, 0x203a, 0x015b, 0x0165, 0x017e, 0x017a, - 0x00a0, 0x02c7, 0x02d8, 0x0141, 0x00a4, 0x0104, 0x00a6, 0x00a7, - 0x00a8, 0x00a9, 0x015e, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x017b, - 0x00b0, 0x00b1, 0x02db, 0x0142, 0x00b4, 0x00b5, 0x00b6, 0x00b7, - 0x00b8, 0x0105, 0x015f, 0x00bb, 0x013d, 0x02dd, 0x013e, 0x017c, - 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, - 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e, - 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, - 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df, - 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, - 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f, - 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, - 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9, -}; - -/* some code based on libiconv utf8_mbtowc() && utf8_wctomb() from utf8.h under LGPL-2.1 */ - -static int rivchat_utf8_helper(unsigned char *s, int n, uint16_t *ch) { - unsigned char c = s[0]; - - if (c < 0x80) { - *ch = c; - return 1; - } - - if (c < 0xc2) - goto invalid; - - if (c < 0xe0) { - if (n < 2) - goto invalid; - if (!((s[1] ^ 0x80) < 0x40)) - goto invalid; - *ch = ((uint16_t) (c & 0x1f) << 6) | (uint16_t) (s[1] ^ 0x80); - return 2; - } - - if (c < 0xf0) { - if (n < 3) - goto invalid; - if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && (c >= 0xe1 || s[1] >= 0xa0))) - goto invalid; - *ch = ((uint16_t) (c & 0x0f) << 12) | ((uint16_t) (s[1] ^ 0x80) << 6) | (uint16_t) (s[2] ^ 0x80); - return 3; - } - -invalid: - *ch = '?'; - return 1; -} -#endif - -char *rivchat_locale_to_cp(char *b) { - unsigned char *buf = (unsigned char *) b; - - if (!buf) - return NULL; -#if (USE_UNICODE || HAVE_GTK) - if (config_use_unicode) { /* why not iconv? iconv is too big for recoding only utf-8 <==> cp1250 */ - char *newbuf; - int newlen = 0; - int len; - int i, j; - - len = xstrlen(b); - - for (i = 0; i < len; newlen++) { - uint16_t discard; - - i += rivchat_utf8_helper(&buf[i], len - i, &discard); - } - - newbuf = xmalloc(newlen+1); - - for (i = 0, j = 0; buf[i]; j++) { - uint16_t znak; - int k; - - i += rivchat_utf8_helper(&buf[i], len - i, &znak); - - if (znak < 0x80) { - newbuf[j] = znak; - continue; - } - - newbuf[j] = '?'; - - for (k = 0; k < (sizeof(table_cp1250)/sizeof(table_cp1250[0])); k++) { - if (table_cp1250[k] == znak) { - newbuf[j] = (0x80 | k); - break; - } - } - } - newbuf[j] = '\0'; - - xfree(buf); - - return newbuf; - } else -#endif - return (char *) rivchat_iso_to_cp(buf); -} - -char *rivchat_cp_to_locale(char *b) { - unsigned char *buf = (unsigned char *) b; - - if (!buf) - return NULL; -#if (USE_UNICODE || HAVE_GTK) - if (config_use_unicode) { /* shitty way with string_t */ - char *newbuf; - int newlen = 0; - int i, j; - - for (i = 0; buf[i]; i++) { - uint16_t znak = (buf[i] < 0x80) ? buf[i] : table_cp1250[buf[i]-0x80]; - - if (znak < 0x80) newlen += 1; - else if (znak < 0x800) newlen += 2; - else newlen += 3; - } - - newbuf = xmalloc(newlen+1); - - for (i = 0, j = 0; buf[i]; i++) { - uint16_t znak = (buf[i] < 0x80) ? buf[i] : table_cp1250[buf[i]-0x80]; - int count; - - if (znak < 0x80) count = 1; - else if (znak < 0x800) count = 2; - else count = 3; - - switch (count) { - case 3: newbuf[j+2] = 0x80 | (znak & 0x3f); znak = znak >> 6; znak |= 0x800; - case 2: newbuf[j+1] = 0x80 | (znak & 0x3f); znak = znak >> 6; znak |= 0xc0; - case 1: newbuf[j] = znak; - } - j += count; - } - newbuf[j] = '\0'; - - xfree(buf); - - return newbuf; - } else -#endif - return (char *) rivchat_cp_to_iso(buf); -} - uint32_t rivchat_fix32(uint32_t x) { return x; /* Modified: trunk/plugins/rivchat/rivchat.c =================================================================== --- trunk/plugins/rivchat/rivchat.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/rivchat/rivchat.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -57,8 +57,6 @@ #include "rivchat.h" /* only protocol-stuff */ -extern char *rivchat_cp_to_locale(char *b); /* misc.c */ -extern char *rivchat_locale_to_cp(char *b); /* misc.c */ // extern uint32_t rivchat_fix32(uint32_t x); /* misc.c */ #define rivchat_fix32(x) x @@ -183,14 +181,14 @@ printq("rivchat_info_connected", itoa(ping->online * 10)); /* user, host */ - user = rivchat_cp_to_locale(xstrndup(ping->user, sizeof(ping->user))); - host = rivchat_cp_to_locale(xstrndup(ping->host, sizeof(ping->host))); + user = ekg_cp_to_locale(xstrndup(ping->user, sizeof(ping->user))); + host = ekg_cp_to_locale(xstrndup(ping->host, sizeof(ping->host))); printq("rivchat_info_username", user, host); xfree(user); xfree(host); /* prog, os, version */ - prog = rivchat_cp_to_locale(xstrndup(ping->prog, sizeof(ping->prog))); - os = rivchat_cp_to_locale(xstrndup(ping->os, sizeof(ping->os))); + prog = ekg_cp_to_locale(xstrndup(ping->prog, sizeof(ping->prog))); + os = ekg_cp_to_locale(xstrndup(ping->os, sizeof(ping->os))); sprintf(ver, "%u.%u", ping->version[0], ping->version[1]); printq("rivchat_info_version", prog, ver, os); xfree(prog); xfree(os); @@ -382,7 +380,7 @@ if (!src) return; - cpsrc = rivchat_locale_to_cp(xstrdup(src)); + cpsrc = ekg_locale_to_cp(xstrdup(src)); srclen = (xstrlen(cpsrc)+1); if (len < srclen) @@ -520,7 +518,7 @@ static int rivchat_send_packet_string(session_t *s, uint32_t type, userlist_t *user, const char *str) { int ret; - char *recodedstring = rivchat_locale_to_cp(xstrdup(str)); + char *recodedstring = ekg_locale_to_cp(xstrdup(str)); ret = rivchat_send_packet(s, type, user, recodedstring, xstrlen(recodedstring)); @@ -550,7 +548,7 @@ return; } - nick = rivchat_cp_to_locale(xstrndup(_hdr->nick, sizeof(_hdr->nick))); + nick = ekg_cp_to_locale(xstrndup(_hdr->nick, sizeof(_hdr->nick))); uid = saprintf("rivchat:%X", from_id); u = userlist_find(s, uid); @@ -611,7 +609,7 @@ { int to_us; - display_data = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + display_data = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); to_us = !!xstrstr(display_data, j->nick); display_activity = (is_priv || to_us) ? EKG_WINACT_IMPORTANT : EKG_WINACT_MSG; @@ -622,8 +620,8 @@ { rivchat_info_t *hdr2 = (rivchat_info_t *) _hdr->data; - char *user = rivchat_cp_to_locale(xstrndup(hdr2->user, sizeof(hdr2->user))); - char *host = rivchat_cp_to_locale(xstrndup(hdr2->host, sizeof(hdr2->host))); + char *user = ekg_cp_to_locale(xstrndup(hdr2->user, sizeof(hdr2->user))); + char *host = ekg_cp_to_locale(xstrndup(hdr2->host, sizeof(hdr2->host))); if (is_our) { /* we join? */ window_t *w = window_new(rivchat_make_window(j->port), s, 0); @@ -647,7 +645,7 @@ case RC_PINGAWAY: { /* if user is already in away state, do nothing... else do type = RC_AWAY */ - display_data = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + display_data = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); if (u->status == EKG_STATUS_AWAY && !xstrcmp(u->descr, display_data)) { xfree(display_data); display_data = NULL; @@ -661,7 +659,7 @@ { display_activity = EKG_WINACT_JUNK; if (!display_data) - display_data = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + display_data = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); xfree(u->descr); u->descr = xstrdup(display_data); u->status = EKG_STATUS_AWAY; @@ -680,7 +678,7 @@ case RC_QUIT: { - display_data = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + display_data = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); if (!xstrlen(display_data)) { xfree(display_data); display_data = xstrdup("no reason"); @@ -697,7 +695,7 @@ case RC_NEWTOPIC: { display_activity = EKG_WINACT_MSG; - display_data = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + display_data = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); if (type == RC_NEWTOPIC) { xfree(j->topic); @@ -717,7 +715,7 @@ case RC_POP: /* XXX, ladniej */ { - char *pop_data = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + char *pop_data = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); print_window(rivchat_make_window(j->port), s, is_priv ? EKG_WINACT_IMPORTANT : EKG_WINACT_JUNK, 1, is_priv ? "rivchat_pop_recv" : "rivchat_pop_broadcast", @@ -730,7 +728,7 @@ case RC_NICKCHANGE: { display_activity = EKG_WINACT_MSG; - display_data = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + display_data = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); xfree(u->nickname); u->nickname = xstrdup(display_data); @@ -744,7 +742,7 @@ case RC_ME: { display_activity = EKG_WINACT_MSG; - display_data = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + display_data = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); break; } @@ -790,7 +788,7 @@ break; } - filename = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + filename = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); /* XXX, na pewno 64bity? */ size = /* @@ -828,7 +826,7 @@ break; } - filename = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + filename = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); debug("RC_FILEREQUEST\n"); @@ -863,7 +861,7 @@ break; } - filename = rivchat_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); + filename = ekg_cp_to_locale(xstrndup(_hdr->data, sizeof(_hdr->data))); debug("RC_FILECANCEL2\n"); Modified: trunk/plugins/sniff/sniff.c =================================================================== --- trunk/plugins/sniff/sniff.c 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/sniff/sniff.c 2008-09-03 21:10:01 UTC (rev 4597) @@ -184,33 +184,6 @@ return &d; } -static const unsigned char cp_to_iso_table[] = { - '?', '?', '?', '?', '?', '?', '?', '?', - '?', '?', 0xa9, '?', 0xa6, 0xab, 0xae, 0xac, - '?', '?', '?', '?', '?', '?', '?', '?', - '?', '?', 0xb9, '?', 0xb6, 0xbb, 0xbe, 0xbc, - 0xa0, 0xb7, 0xa2, 0xa3, 0xa4, 0xa1, '?', 0xa7, - 0xa8, '?', 0xaa, '?', '?', 0xad, '?', 0xaf, - 0xb0, '?', 0xb2, 0xb3, 0xb4, '?', '?', '?', - 0xb8, 0xb1, 0xba, '?', 0xa5, 0xbd, 0xb5, 0xbf, -}; - -static char *gg_cp_to_iso(char *b) { - char *tmp = b; - unsigned char *buf = (unsigned char *) b; - - if (!buf) - return NULL; - - while (*buf) { - if (*buf >= 0x80 && *buf < 0xC0) - *buf = cp_to_iso_table[*buf - 0x80]; - - buf++; - } - return tmp; -} - static void tcp_print_payload(u_char *payload, size_t len) { #define MAX_BYTES_PER_LINE 16 int offset = 0; Modified: trunk/plugins/sniff/sniff_gg.inc =================================================================== --- trunk/plugins/sniff/sniff_gg.inc 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/sniff/sniff_gg.inc 2008-09-03 21:10:01 UTC (rev 4597) @@ -139,7 +139,7 @@ char *msg; CHECK_LEN(sizeof(gg_recv_msg)) len -= sizeof(gg_recv_msg); - msg = gg_cp_to_iso(xstrndup(pkt->msg_data, len)); + msg = ekg_cp_to_locale(xstrndup(pkt->msg_data, len)); sniff_gg_print_message(s, hdr, pkt->sender, EKG_MSGCLASS_CHAT, msg, pkt->time); xfree(msg); return 0; @@ -149,7 +149,7 @@ char *msg; CHECK_LEN(sizeof(gg_send_msg)) len -= sizeof(gg_send_msg); - msg = gg_cp_to_iso(xstrndup(pkt->msg_data, len)); + msg = ekg_cp_to_locale(xstrndup(pkt->msg_data, len)); sniff_gg_print_message(s, hdr, pkt->recipient, EKG_MSGCLASS_SENT_CHAT, msg, time(NULL)); xfree(msg); @@ -202,7 +202,7 @@ CHECK_LEN(sizeof(gg_status)) len -= sizeof(gg_status); status = gg_status_to_text(pkt->status, &has_descr); - descr = has_descr ? gg_cp_to_iso(xstrndup(pkt->status_data, len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup(pkt->status_data, len)) : NULL; sniff_gg_print_status(s, hdr, pkt->uin, status, descr); xfree(descr); @@ -218,7 +218,7 @@ CHECK_LEN(sizeof(gg_new_status)) len -= sizeof(gg_new_status); status = gg_status_to_text(pkt->status, &has_descr); - descr = has_descr ? gg_cp_to_iso(xstrndup(pkt->status_data, len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup(pkt->status_data, len)) : NULL; sniff_gg_print_new_status(s, hdr, 0, status, descr); xfree(descr); @@ -238,7 +238,7 @@ uin = pkt->uin & 0x00ffffff; status = gg_status_to_text(pkt->status, &has_descr); - descr = has_descr ? gg_cp_to_iso(xstrndup(pkt->status_data, len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup(pkt->status_data, len)) : NULL; sniff_gg_print_status(s, hdr, uin, status, descr); xfree(descr); @@ -268,7 +268,7 @@ build_hex(pkt->hash)); status = gg_status_to_text(pkt->status, &has_descr); - descr = has_descr ? gg_cp_to_iso(xstrndup(pkt->status_data, len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup(pkt->status_data, len)) : NULL; sniff_gg_print_new_status(s, hdr, pkt->uin, status, descr); xfree(descr); return 0; @@ -326,7 +326,7 @@ next += desc_len; } - descr = has_descr ? gg_cp_to_iso(xstrndup((char *) &pkt->next[1], desc_len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup((char *) &pkt->next[1], desc_len)) : NULL; sniff_gg_print_status(s, hdr, uin, status, descr); xfree(descr); @@ -375,7 +375,7 @@ tcp_print_payload((u_char *) pkt->data, len); } - datatmp = data = len ? gg_cp_to_iso(xstrndup(pkt->data, len)) : NULL; + datatmp = data = len ? ekg_cp_to_locale(xstrndup(pkt->data, len)) : NULL; print_window(build_windowip_name(hdr->dstip) /* ip and/or gg# */, s, EKG_WINACT_MSG, 1, "sniff_gg_userlist_reply", @@ -416,7 +416,7 @@ tcp_print_payload((u_char *) pkt->data, len); } - datatmp = data = len ? gg_cp_to_iso(xstrndup(pkt->data, len)) : NULL; + datatmp = data = len ? ekg_cp_to_locale(xstrndup(pkt->data, len)) : NULL; print_window(build_windowip_name(hdr->srcip) /* ip and/or gg# */, s, EKG_WINACT_MSG, 1, "sniff_gg_userlist_req", @@ -779,7 +779,7 @@ status = gg_status_to_text(pkt->status, &has_descr); - descr = has_descr ? gg_cp_to_iso(xstrndup(pkt->status_data, len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup(pkt->status_data, len)) : NULL; sniff_gg_print_new_status(s, hdr, pkt->uin, status, descr); xfree(descr); @@ -835,7 +835,7 @@ next += desc_len; } - descr = has_descr ? gg_cp_to_iso(xstrndup((char *) &pkt->next[1], desc_len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup((char *) &pkt->next[1], desc_len)) : NULL; sniff_gg_print_status(s, hdr, uin, status, descr); xfree(descr); @@ -886,7 +886,7 @@ CHECK_PRINT(dunno2, 0x00); status = gg_status_to_text(pkt->status, &has_descr); - descr = has_descr ? gg_cp_to_iso(xstrndup(pkt->status_data, len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup(pkt->status_data, len)) : NULL; sniff_gg_print_status(s, hdr, uin, status, descr); xfree(descr); @@ -961,7 +961,7 @@ status = gg_status_to_text(pkt->status, &has_descr); - descr = has_descr ? gg_cp_to_iso(xstrndup(pkt->status_data, len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup(pkt->status_data, len)) : NULL; sniff_gg_print_new_status(s, hdr, pkt->uin, status, descr); xfree(descr); @@ -1032,7 +1032,7 @@ next += desc_len; } - descr = has_descr ? gg_cp_to_iso(xstrndup((char *) &pkt->next[1], desc_len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup((char *) &pkt->next[1], desc_len)) : NULL; sniff_gg_print_status(s, hdr, uin, status, descr); xfree(descr); @@ -1090,7 +1090,7 @@ CHECK_PRINT(dunno2, 0x00); status = gg_status_to_text(pkt->status, &has_descr); - descr = has_descr ? gg_cp_to_iso(xstrndup(pkt->status_data, len)) : NULL; + descr = has_descr ? ekg_cp_to_locale(xstrndup(pkt->status_data, len)) : NULL; sniff_gg_print_status(s, hdr, uin, status, descr); xfree(descr); @@ -1158,7 +1158,7 @@ tcp_print_payload(((unsigned char *) pkt) + pkt->offset_attr, orglen - pkt->offset_attr); if (pkt->offset_plaintext < orglen) { - msg = gg_cp_to_iso(xstrndup(((char *) pkt) + pkt->offset_plaintext, orglen - pkt->offset_plaintext)); + msg = ekg_cp_to_locale(xstrndup(((char *) pkt) + pkt->offset_plaintext, orglen - pkt->offset_plaintext)); sniff_gg_print_message(s, hdr, pkt->recipient, EKG_MSGCLASS_SENT_CHAT, msg, time(NULL)); xfree(msg); } Modified: trunk/plugins/sniff/sniff_rivchat.inc =================================================================== --- trunk/plugins/sniff/sniff_rivchat.inc 2008-09-03 20:37:33 UTC (rev 4596) +++ trunk/plugins/sniff/sniff_rivchat.inc 2008-09-03 21:10:01 UTC (rev 4597) @@ -6,10 +6,10 @@ } SNIFF_HANDLER(sniff_rivchat_info, rivchat_packet_rcinfo) { - char *hostname = gg_cp_to_iso(xstrndup(pkt->host, sizeof(pkt->host))); - char *os = gg_cp_to_iso(xstrndup(pkt->os, sizeof(pkt->os))); - char *program = gg_cp_to_iso(xstrndup(pkt->prog, sizeof(pkt->prog))); - char *username = gg_cp_to_iso(xstrndup(pkt->user, sizeof(pkt->user))); + char *hostname = ekg_cp_to_locale(xstrndup(pkt->host, sizeof(pkt->host))); + char *os = ekg_cp_to_locale(xstrndup(pkt->os, sizeof(pkt->os))); + char *program = ekg_cp_to_locale(xstrndup(pkt->prog, sizeof(pkt->prog))); + char *username = ekg_cp_to_locale(xstrndup(pkt->user, sizeof(pkt->user))); char program_ver[8]; /* ddd '.' ddd */ @@ -36,7 +36,7 @@ CHECK_LEN(sizeof(rivchat_packet)) - nick = gg_cp_to_iso(xstrndup(pkt->nick, sizeof(pkt->nick))); + nick = ekg_cp_to_locale(xstrndup(pkt->nick, sizeof(pkt->nick))); debug("UDP RIVCHAT PACKET [SIZE: %d FROMID: %d TOID: %d TYPE: %x NICK: %s\n", pkt->size, pkt->fromid, pkt->toid, pkt->type, nick); @@ -48,7 +48,7 @@ case RIVCHAT_ME: debug_function("sniff_rivchat() RIVCHAT_ME\n"); - data = gg_cp_to_iso(xstrndup(pkt->data, sizeof(pkt->data))); + data = ekg_cp_to_locale(xstrndup(pkt->data, sizeof(pkt->data))); print_window(build_rivchatport_name(hdr) /* sniff:rc:port or smth */, s, EKG_WINACT_MSG, 1, "sniff_rivchat_me", inet_ntoa(hdr->srcip), nick, @@ -63,7 +63,7 @@ /* XXX secure, not secure */ - data = gg_cp_to_iso(xstrndup(pkt->data, sizeof(pkt->data))); + data = ekg_cp_to_locale(xstrndup(pkt->data, sizeof(pkt->data))); print_window(build_rivchatport_name(hdr) /* sniff:rc:port or smth */, s, EKG_WINACT_MSG, 1, "sniff_rivchat_message", inet_ntoa(hdr->srcip), nick, @@ -85,7 +85,7 @@ case RIVCHAT_PINGAWAY: debug_function("sniff_rivchat() RIVCHAT_AWAY/RIVCHAT_PINGAWAY\n"); - data = gg_cp_to_iso(xstrndup(pkt->data, sizeof(pkt->data))); + data = ekg_cp_to_locale(xstrndup(pkt->data, sizeof(pkt->data))); print_window(build_rivchatport_name(hdr) /* sniff:rc:port or smth */, s, EKG_WINACT_MSG, 1, type == RIVCHAT_AWAY ? "sniff_rivchat_away" : "sniff_rivchat_pingaway", inet_ntoa(hdr->srcip), From svn w toxygen.net Thu Sep 4 15:39:45 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 4 Sep 2008 15:39:45 +0200 (CEST) Subject: [ekg2-commit] r4598 - trunk/plugins/gg: trunk/plugins/gg/commands.c Message-ID: <20080904133946.087D917B1F@toxygen.net> Author: wiechu Date: 2008-09-04 15:39:45 +0200 (Thu, 04 Sep 2008) New Revision: 4598 Modified: trunk/plugins/gg/commands.c Log: fix calculate length of description Modified: trunk/plugins/gg/commands.c =================================================================== --- trunk/plugins/gg/commands.c 2008-09-03 21:10:01 UTC (rev 4597) +++ trunk/plugins/gg/commands.c 2008-09-04 13:39:45 UTC (rev 4598) @@ -399,14 +399,16 @@ } if (params0) { - if (xstrlen(params0) > GG_STATUS_DESCR_MAXSIZE && config_reason_limit) { + char *tmp = ekg_locale_to_cp(params0); + if (xstrlen(tmp) > GG_STATUS_DESCR_MAXSIZE && config_reason_limit) { if (!timeout) { char *descr_poss = xstrndup(params0, GG_STATUS_DESCR_MAXSIZE); char *descr_not_poss = xstrdup(params0 + GG_STATUS_DESCR_MAXSIZE); - printq("descr_too_long", itoa(xstrlen(params0) - GG_STATUS_DESCR_MAXSIZE), descr_poss, descr_not_poss); + printq("descr_too_long", itoa(xstrlen(tmp) - GG_STATUS_DESCR_MAXSIZE), descr_poss, descr_not_poss); g->scroll_op = 0; + xfree(tmp); xfree(descr_poss); xfree(descr_not_poss); @@ -414,6 +416,7 @@ return -1; } } + xfree(tmp); session_descr_set(session, (!xstrcmp(params0, "-")) ? NULL : params0); } else { From svn w toxygen.net Thu Sep 4 17:05:43 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 4 Sep 2008 17:05:43 +0200 (CEST) Subject: [ekg2-commit] r4599 - trunk/plugins/feed: trunk/plugins/feed/feed.c Message-ID: <20080904150543.D61E317B1F@toxygen.net> Author: darkjames Date: 2008-09-04 17:05:43 +0200 (Thu, 04 Sep 2008) New Revision: 4599 Modified: trunk/plugins/feed/feed.c Log: add debugs. Modified: trunk/plugins/feed/feed.c =================================================================== --- trunk/plugins/feed/feed.c 2008-09-04 13:39:45 UTC (rev 4598) +++ trunk/plugins/feed/feed.c 2008-09-04 15:05:43 UTC (rev 4599) @@ -148,11 +148,15 @@ if (!(target = get_nickname(s, uid))) target = uid; break; - } + } + debug_white("[feed] window_new(%s, %s [%x]) == ", target, session, s); + if (mw) targetwnd = window_new(target, s, 0); + debug_white("%x\n", targetwnd); + switch (dmode) { case 0: print_window_w(targetwnd, EKG_WINACT_MSG, "feed_message_new", title, url); /* only notify */ case -1: return 0; /* do nothing */ From svn w toxygen.net Thu Sep 4 17:32:21 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 4 Sep 2008 17:32:21 +0200 (CEST) Subject: [ekg2-commit] r4600 - trunk/plugins/ncurses: trunk/plugins/ncurses/main.c Message-ID: <20080904153221.38CA417B1F@toxygen.net> Author: darkjames Date: 2008-09-04 17:32:20 +0200 (Thu, 04 Sep 2008) New Revision: 4600 Modified: trunk/plugins/ncurses/main.c Log: fix /dump for unicode. Modified: trunk/plugins/ncurses/main.c =================================================================== --- trunk/plugins/ncurses/main.c 2008-09-04 15:05:43 UTC (rev 4599) +++ trunk/plugins/ncurses/main.c 2008-09-04 15:32:20 UTC (rev 4600) @@ -632,10 +632,13 @@ for (i = n->backlog_size; i; i--) { fstring_t *backlog = n->backlog[i-1]; - /* XXX, unicode, wcs_to_normal() + free_utf() */ /* XXX, kolorki gdy user chce */ +#ifdef USE_UNICODE + fprintf(f, "%ld %ls\n", backlog->ts, backlog->str.w); +#else fprintf(f, "%ld %s\n", backlog->ts, backlog->str.b); +#endif } fclose(f); From svn w toxygen.net Thu Sep 4 18:02:33 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 4 Sep 2008 18:02:33 +0200 (CEST) Subject: [ekg2-commit] r4601 - in trunk: ekg plugins/gg plugins/icq plugins/rivchat plugins/sniff: +trunk/ekg/recode.h trunk/ekg/Makefile.am trunk/ekg/ekg.c trunk/ekg/recode.c trunk/plugins/gg/gg.c trunk/plugins/icq/icq.c trunk/plugins/rivchat/rivchat.c trunk/plugins/sniff/sniff.c Message-ID: <20080904160233.B312817B1F@toxygen.net> Author: darkjames Date: 2008-09-04 18:02:33 +0200 (Thu, 04 Sep 2008) New Revision: 4601 Added: trunk/ekg/recode.h Modified: trunk/ekg/Makefile.am trunk/ekg/ekg.c trunk/ekg/recode.c trunk/plugins/gg/gg.c trunk/plugins/icq/icq.c trunk/plugins/rivchat/rivchat.c trunk/plugins/sniff/sniff.c Log: - don't init encoding conv, if not needed. It's shitty, yeah. Modified: trunk/ekg/Makefile.am =================================================================== --- trunk/ekg/Makefile.am 2008-09-04 15:32:20 UTC (rev 4600) +++ trunk/ekg/Makefile.am 2008-09-04 16:02:33 UTC (rev 4601) @@ -1,4 +1,4 @@ -ekg2_headers = audio.h audio_wav.h configfile.h dynstuff.h dynstuff_inline.h events.h metacontacts.h queries.h objects.h protocol.h sessions.h strings.h themes.h vars.h xmalloc.h \ +ekg2_headers = audio.h audio_wav.h configfile.h dynstuff.h dynstuff_inline.h events.h metacontacts.h queries.h objects.h protocol.h recode.h sessions.h strings.h themes.h vars.h xmalloc.h \ commands.h debug.h emoticons.h log.h msgqueue.h net.h srv.h plugins.h scripts.h stuff.h userlist.h windows.h win32.h ../gettext.h ../ekg2-config.h bin_PROGRAMS = ekg2 Modified: trunk/ekg/ekg.c =================================================================== --- trunk/ekg/ekg.c 2008-09-04 15:32:20 UTC (rev 4600) +++ trunk/ekg/ekg.c 2008-09-04 16:02:33 UTC (rev 4601) @@ -964,7 +964,6 @@ no_config = 1; config_postread(); - ekg_recode_reinit(); /* status window takes first session if not set before*/ if (!session_current && sessions) @@ -1161,7 +1160,6 @@ newconferences_destroy(); metacontacts_destroy(); sessions_free(); - ekg_recode_destroy(); { plugin_t *p; Modified: trunk/ekg/recode.c =================================================================== --- trunk/ekg/recode.c 2008-09-04 15:32:20 UTC (rev 4600) +++ trunk/ekg/recode.c 2008-09-04 16:02:33 UTC (rev 4601) @@ -44,7 +44,7 @@ #include "commands.h" #include "dynstuff.h" #include "dynstuff_inline.h" -// #include "recode.h" +#include "recode.h" #include "stuff.h" #include "windows.h" #include "xmalloc.h" @@ -629,8 +629,9 @@ 0xb8, 0xb1, 0xba, '?', 0xa5, 0xbd, 0xb5, 0xbf, }; -void *cp_conv_in = EKG_ICONV_BAD; -void *cp_conv_out = EKG_ICONV_BAD; +static void *cp_conv_in = EKG_ICONV_BAD; +static void *cp_conv_out = EKG_ICONV_BAD; +static int cp_ref; static char *gg_cp_to_iso(char *b) { unsigned char *buf = (unsigned char *) b; @@ -682,6 +683,30 @@ return gg_cp_to_iso(buf); /* XXX, assuimg iso, is bad? */ } +void ekg_recode_cp_inc() { + if (cp_ref == 0) { + if ( +#if (USE_UNICODE || HAVE_GTK) + config_use_unicode || +#endif + !xstrcasecmp(config_console_charset, "ISO-8859-2")) + cp_conv_in = cp_conv_out = EKG_ICONV_BAD; + else + cp_conv_in = ekg_convert_string_init("CP1250", NULL, &cp_conv_out); + } + cp_ref++; +} + +void ekg_recode_cp_dec() { + cp_ref--; + + if (cp_ref == 0 && cp_conv_in != EKG_ICONV_BAD) { + ekg_convert_string_destroy(cp_conv_in); + ekg_convert_string_destroy(cp_conv_out); + cp_conv_in = cp_conv_out = EKG_ICONV_BAD; + } +} + /* ISO-8859-2 <===> any, use ekg_locale_to_latin2() and ekg_latin2_to_locale() */ #if (USE_UNICODE || HAVE_GTK) @@ -705,8 +730,9 @@ }; #endif -void *latin2_conv_in = EKG_ICONV_BAD; -void *latin2_conv_out = EKG_ICONV_BAD; +static void *latin2_conv_in = EKG_ICONV_BAD; +static void *latin2_conv_out = EKG_ICONV_BAD; +static int latin2_ref; char *ekg_locale_to_latin2(char *buf) { if (!buf) @@ -738,8 +764,9 @@ /* XXX, easier recode in/out to latin2? */ -void *utf8_conv_in = EKG_ICONV_BAD; -void *utf8_conv_out = EKG_ICONV_BAD; +static void *utf8_conv_in = EKG_ICONV_BAD; +static void *utf8_conv_out = EKG_ICONV_BAD; +static int utf8_ref; char *ekg_locale_to_utf8(char *buf) { if (!buf) @@ -760,6 +787,21 @@ return NULL; } +void ekg_recode_utf8_inc() { + if (utf8_ref == 0) + utf8_conv_in = ekg_convert_string_init("UTF-8", NULL, &utf8_conv_out); + utf8_ref++; +} + +void ekg_recode_utf8_dec() { + utf8_ref--; + if (utf8_ref == 0 && utf8_conv_in != EKG_ICONV_BAD) { + ekg_convert_string_destroy(utf8_conv_in); + ekg_convert_string_destroy(utf8_conv_out); + utf8_conv_in = utf8_conv_out = EKG_ICONV_BAD; + } +} + /* XXX any <===> any, use ekg_any_to_locale() and ekg_locale_to_any() */ char *ekg_any_to_locale(char *buf, char *inp) { @@ -772,32 +814,3 @@ } - -void ekg_recode_destroy() { - if (cp_conv_in != EKG_ICONV_BAD) { - ekg_convert_string_destroy(cp_conv_in); - ekg_convert_string_destroy(cp_conv_out); - } - - if (utf8_conv_in != EKG_ICONV_BAD) { - ekg_convert_string_destroy(utf8_conv_in); - ekg_convert_string_destroy(utf8_conv_out); - } -} - - -void ekg_recode_reinit() { - ekg_recode_destroy(); - - if ( -#if (USE_UNICODE || HAVE_GTK) - config_use_unicode || -#endif - !xstrcasecmp(config_console_charset, "ISO-8859-2")) - cp_conv_in = cp_conv_out = (void*) EKG_ICONV_BAD; - else - cp_conv_in = ekg_convert_string_init("CP1250", NULL, &cp_conv_out); - - utf8_conv_in = ekg_convert_string_init("UTF-8", NULL, &utf8_conv_out); -} - Added: trunk/ekg/recode.h =================================================================== --- trunk/ekg/recode.h (rev 0) +++ trunk/ekg/recode.h 2008-09-04 16:02:33 UTC (rev 4601) @@ -0,0 +1,40 @@ +#ifndef __EKG_RECODE_H +#define __EKG_RECODE_H + +enum ekg_recode_name { + EKG_RECODE_CP = 0, + EKG_RECODE_LATIN2, + EKG_RECODE_UTF8 +}; + +void ekg_recode_inc_ref(enum ekg_recode_name ref); +void ekg_recode_dec_ref(enum ekg_recode_name ref); + +void *ekg_convert_string_init(const char *from, const char *to, void **rev); +void ekg_convert_string_destroy(void *ptr); +char *ekg_convert_string_p(const char *ps, void *ptr); +char *ekg_convert_string(const char *ps, const char *from, const char *to); +string_t ekg_convert_string_t_p(string_t s, void *ptr); +string_t ekg_convert_string_t(string_t s, const char *from, const char *to); +int ekg_converters_display(int quiet); + +/* CP-1250 */ +char *ekg_locale_to_cp(char *buf); +char *ekg_cp_to_locale(char *buf); +void ekg_recode_cp_inc(); +void ekg_recode_cp_dec(); + +/* ISO-8859-2 */ +char *ekg_locale_to_latin2(char *buf); +char *ekg_latin2_to_locale(char *buf); + +/* UTF-8 */ +char *ekg_locale_to_utf8(char *buf); +char *ekg_utf8_to_locale(char *buf); +void ekg_recode_utf8_inc(); +void ekg_recode_utf8_dec(); + +char *ekg_any_to_locale(char *buf, char *inp); char *ekg_locale_to_any(char *buf, char *inp); + + +#endif Modified: trunk/plugins/gg/gg.c =================================================================== --- trunk/plugins/gg/gg.c 2008-09-04 15:32:20 UTC (rev 4600) +++ trunk/plugins/gg/gg.c 2008-09-04 16:02:33 UTC (rev 4601) @@ -50,6 +50,7 @@ #include #include #include +#include #include @@ -1667,6 +1668,7 @@ gg_plugin.priv = &gg_priv; plugin_register(&gg_plugin, prio); + ekg_recode_cp_inc(); gg_setvar_default(NULL, dummy); query_connect_id(&gg_plugin, SET_VARS_DEFAULT, gg_setvar_default, NULL); @@ -1738,6 +1740,7 @@ image_flush_queue(); + ekg_recode_cp_dec(); plugin_unregister(&gg_plugin); return 0; Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-04 15:32:20 UTC (rev 4600) +++ trunk/plugins/icq/icq.c 2008-09-04 16:02:33 UTC (rev 4601) @@ -41,6 +41,7 @@ #include #include +#include #include #include "icq.h" @@ -1468,6 +1469,7 @@ PLUGIN_CHECK_VER("icq"); icq_convert_string_init(); + ekg_recode_utf8_inc(); icq_plugin.params = icq_plugin_vars; icq_plugin.priv = &icq_priv; @@ -1515,5 +1517,6 @@ static int icq_plugin_destroy() { icq_convert_string_destroy(); plugin_unregister(&icq_plugin); + ekg_recode_utf8_dec(); return 0; } Modified: trunk/plugins/rivchat/rivchat.c =================================================================== --- trunk/plugins/rivchat/rivchat.c 2008-09-04 15:32:20 UTC (rev 4600) +++ trunk/plugins/rivchat/rivchat.c 2008-09-04 16:02:33 UTC (rev 4601) @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1488,6 +1489,7 @@ rivchat_plugin.params = rivchat_plugin_vars; plugin_register(&rivchat_plugin, prio); + ekg_recode_cp_inc(); query_connect_id(&rivchat_plugin, PROTOCOL_VALIDATE_UID, rivchat_validate_uid, NULL); query_connect_id(&rivchat_plugin, SESSION_ADDED, rivchat_session_init, NULL); @@ -1522,6 +1524,7 @@ static int rivchat_plugin_destroy() { plugin_unregister(&rivchat_plugin); + ekg_recode_cp_dec(); return 0; } Modified: trunk/plugins/sniff/sniff.c =================================================================== --- trunk/plugins/sniff/sniff.c 2008-09-04 15:32:20 UTC (rev 4600) +++ trunk/plugins/sniff/sniff.c 2008-09-04 16:02:33 UTC (rev 4601) @@ -743,6 +743,7 @@ sniff_plugin.params = sniff_plugin_vars; plugin_register(&sniff_plugin, prio); + ekg_recode_cp_inc(); query_connect_id(&sniff_plugin, PROTOCOL_VALIDATE_UID, sniff_validate_uid, NULL); query_connect_id(&sniff_plugin, STATUS_SHOW, sniff_status_show, NULL); @@ -758,6 +759,7 @@ static int sniff_plugin_destroy() { plugin_unregister(&sniff_plugin); + ekg_recode_cp_dec(); return 0; } From svn w toxygen.net Thu Sep 4 21:58:34 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 4 Sep 2008 21:58:34 +0200 (CEST) Subject: [ekg2-commit] r4602 - trunk/plugins/icq: trunk/plugins/icq/icq.h trunk/plugins/icq/icq_debug.inc trunk/plugins/icq/icq_snac_handlers_03buddy.inc trunk/plugins/icq/icq_snac_handlers_04message.inc trunk/plugins/icq/misc.c trunk/plugins/icq/misc.h Message-ID: <20080904195834.31A8B17B1F@toxygen.net> Author: wiechu Date: 2008-09-04 21:58:33 +0200 (Thu, 04 Sep 2008) New Revision: 4602 Modified: trunk/plugins/icq/icq.h trunk/plugins/icq/icq_debug.inc trunk/plugins/icq/icq_snac_handlers_03buddy.inc trunk/plugins/icq/icq_snac_handlers_04message.inc trunk/plugins/icq/misc.c trunk/plugins/icq/misc.h Log: start (real) handle capabilities Modified: trunk/plugins/icq/icq.h =================================================================== --- trunk/plugins/icq/icq.h 2008-09-04 16:02:33 UTC (rev 4601) +++ trunk/plugins/icq/icq.h 2008-09-04 19:58:33 UTC (rev 4602) @@ -50,6 +50,29 @@ icq_rate_t **rates; } icq_private_t; +typedef enum { + CAP_HTML = 0, + CAP_VOICE, /* Client supports voice chat */ + CAP_AIMDIRPLAY, /* Client supports direct play service */ + CAP_SENDFILE, /* Client supports file transfer (can send files) */ + CAP_ICQDIRECT, /* Something called "route finder" (ICQ2K only) */ + CAP_IMIMAGE, /* Client supports DirectIM/IMImage */ + CAP_BUDDYICON, /* Client supports avatar service. */ + CAP_SAVESTOCKS, /* Client supports stocks (add-ins) */ + CAP_GETFILE, /* Client supports filetransfers (can receive files) */ + CAP_SRV_RELAY, /* Client supports channel 2 extended, TLV(0x2711) based messages */ + CAP_GAMES2, /* Client supports games */ + CAP_GAMES, /* Client supports games */ + CAP_CONTACTS, /* Client supports buddy lists transfer */ + CAP_INTEROPERATE, /* Setting this lets AIM users receive messages from ICQ users, and ICQ users receive messages from AIM users */ + CAP_UTF, /* Client supports UTF-8 messages */ + CAP_XTRAZ, + CAP_TYPING, /* Client supports mini typing notifications */ + CAP_CHAT, /* Client supports chat service */ + CAP_RTF, /* Client supports RTF messages */ + CAP_UNKNOWN +} capabilities_t; + int icq_send_pkt(session_t *s, string_t buf); void icq_session_connected(session_t *s); Modified: trunk/plugins/icq/icq_debug.inc =================================================================== --- trunk/plugins/icq/icq_debug.inc 2008-09-04 16:02:33 UTC (rev 4601) +++ trunk/plugins/icq/icq_debug.inc 2008-09-04 19:58:33 UTC (rev 4602) @@ -299,22 +299,6 @@ * Other names */ -struct fieldnames_t caps_names[]={ - {0x1341, "Client supports voice chat."}, - {0x1342, "Client supports direct play service."}, - {0x1343, "Client supports file transfer (can send files)."}, - {0x1344, "Something called \"route finder\"."}, - {0x1345, "Client supports DirectIM/IMImage."}, - {0x1346, "Client supports avatar service."}, - {0x1347, "Client supports stocks (add-ins)."}, - {0x1348, "Client supports filetransfers (can receive files)."}, - {0x1349, "Client supports channel 2 extended, TLV(0x2711) based messages."}, - {0x134A, "Client supports games."}, - {0x134B, "Client supports buddy lists transfer."}, - {0x134D, "Client supports from/to AIM and ICQ."}, - {0x134E, "Client supports UTF-8 messages."}, - {-1, NULL}}; - struct fieldnames_t snac_families[]={ {0x01, "Generic service controls"}, {0x02, "Location services"}, Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-04 16:02:33 UTC (rev 4601) +++ trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-04 19:58:33 UTC (rev 4602) @@ -286,18 +286,29 @@ case 0x0d: /* Client capabilities list */ { - debug_white("icq_snac_buddy_online() Capability list.\n"); + unsigned char *data = t->buf; + int d_len = t->len; + int caps = 0; + if (tlv_length_check("icq_snac_buddy_online()", t, t->len & ~0xF)) break; -#if ICQ_DEBUG_UNUSED_INFORMATIONS - unsigned char *data = t->buf; - int d_len = t->len; + if (!u) + break; + user_private_item_set_int(u, "caps", 0); + user_private_item_set_int(u, "utf", 0); while (d_len > 0) { - debug_white("icq_snac_buddy_online() %s\n", icq_capability_name(data)); + int cid = icq_cap_id(data); + if (cid != CAP_UNKNOWN) { + caps |= 1 << cid; + if (cid == CAP_UTF) + user_private_item_set_int(u, "utf", 1); + } else { + /* client id???*/ + } data += 0x10; // capability length d_len -= 0x10; } -#endif + user_private_item_set_int(u, "caps", caps); break; } Modified: trunk/plugins/icq/icq_snac_handlers_04message.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_04message.inc 2008-09-04 16:02:33 UTC (rev 4601) +++ trunk/plugins/icq/icq_snac_handlers_04message.inc 2008-09-04 19:58:33 UTC (rev 4602) @@ -125,12 +125,10 @@ debug_function("icq_snac_message_recv_simple() enc: %.4x cp: %.4x\n", t_msg.encoding, t_msg.codepage); - recode = xstrndup((char *) t_msg.message, t_len); switch (t_msg.encoding) { case 0x02: /* UCS-2BE */ { string_t str = string_init(NULL); - xfree(recode); string_append_raw(str, (char *) t_msg.message, t_len); recode = icq_convert_from_ucs2be(str); string_free(str, 1); @@ -138,6 +136,7 @@ } case 0x00: /* US-ASCII */ case 0x03: /* ANSI */ + recode = xstrndup((char *) t_msg.message, t_len); break; default: debug_error("icq_snac_message_recv_simple() Unsupported encoding 0x%x\n", t_msg.encoding); Modified: trunk/plugins/icq/misc.c =================================================================== --- trunk/plugins/icq/misc.c 2008-09-04 16:02:33 UTC (rev 4601) +++ trunk/plugins/icq/misc.c 2008-09-04 19:58:33 UTC (rev 4602) @@ -576,18 +576,80 @@ #include "icq_debug.inc" -const char *icq_capability_name(unsigned char *data) { - uint32_t c0, c1, c2, c3; - int len = 16; - (void) icq_unpack(data, &data, &len, "IIII", &c0, &c1, &c2, &c3); - if ( ((c0 >> 16) == 0x0946) && (c1==0x4c7f11d1) && (c2==0x82224445) && (c3==0x53540000) ) - return icq_lookuptable(caps_names, c0 & 0xffff); - else { - // debug_error("Unknown CAP %08x-%08x-%08x-%08x\n", c0, c1, c2, c3); - return "Unknown CAP"; +typedef unsigned char _capability_t[16]; +static const _capability_t _caps[] = +{ + {0x01, 0x38, 0xca, 0x7b, 0x76, 0x9a, 0x49, 0x15, 0x88, 0xf2, 0x13, 0xfc, 0x00, 0x97, 0x9e, 0xa8}, // CAP_HTML + {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_VOICE + {0x09, 0x46, 0x13, 0x42, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_AIMDIRPLAY + {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_SENDFILE + {0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_ICQDIRECT + {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_IMIMAGE + {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_BUDDYICON + {0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_SAVESTOCKS + {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_GETFILE + {0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_SRV_RELAY + {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1, 0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_GAMES2 + {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_GAMES + {0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_CONTACTS + {0x09, 0x46, 0x13, 0x4d, 0x4d, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_INTEROPERATE + {0x09, 0x46, 0x13, 0x4e, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_UTF + {0x1a, 0x09, 0x3c, 0x6c, 0xd7, 0xfd, 0x4e, 0xc5, 0x9d, 0x51, 0xa6, 0x47, 0x4e, 0x34, 0xf5, 0xa0}, // CAP_XTRAZ + {0x56, 0x3f, 0xc8, 0x09, 0x0b, 0x6f, 0x41, 0xbd, 0x9f, 0x79, 0x42, 0x26, 0x09, 0xdf, 0xa2, 0xf3}, // CAP_TYPING + {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_CHAT + {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}, // CAP_RTF + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // CAP_UNKNOWN +}; + +int icq_cap_id(unsigned char *buf) { + int i; + if (buf) + return CAP_UNKNOWN; + for (i=0; i0) && (id0) && (id Author: wiechu Date: 2008-09-04 22:17:01 +0200 (Thu, 04 Sep 2008) New Revision: 4603 Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc Log: fix segv Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-04 19:58:33 UTC (rev 4602) +++ trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-04 20:17:01 UTC (rev 4603) @@ -139,11 +139,11 @@ status = EKG_STATUS_AVAIL; /* assume avail */ uid = icq_uid(pkt.uid); - u =userlist_find(s, uid); + u = userlist_find(s, uid); debug_white("icq_snac_buddy_online() %s\n", uid); - for (t = tlvs; t; t = t->next) { + if (u) for (t = tlvs; t; t = t->next) { /* darkjames said: "I don't trust anything. Wiechu, check t->len" */ switch (t->type) { From svn w toxygen.net Thu Sep 4 23:44:21 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 4 Sep 2008 23:44:21 +0200 (CEST) Subject: [ekg2-commit] r4604 - trunk/plugins/icq: trunk/plugins/icq/icq.c Message-ID: <20080904214421.9170017B1F@toxygen.net> Author: wiechu Date: 2008-09-04 23:44:21 +0200 (Thu, 04 Sep 2008) New Revision: 4604 Modified: trunk/plugins/icq/icq.c Log: now we can send ascii and unicode messages Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-04 20:17:01 UTC (rev 4603) +++ trunk/plugins/icq/icq.c 2008-09-04 21:44:21 UTC (rev 4604) @@ -912,35 +912,44 @@ query_emit_id(NULL, PROTOCOL_TYPING_OUT, &sid, &uid, &len, &first); } - /* XXX, recode, and do other magic stuff :( */ /* sent message */ { - /* for now params[1] should be US-ASCII encoded message. - * sorry */ string_t pkt; string_t tlv_2, tlv_101; - string_t recode; + userlist_t *u = userlist_find(session, uid); + uint16_t enc = 0; /* ASCII */ + const char *tmp = params[1]; - /* TLV(101) */ - /* XXX ?wo? check if we can send utf message */ - recode = icq_convert_to_ucs2be((char *) params[1]); - tlv_101 = icq_pack("WW", 0x02, 0x00); // Unicode - string_append_raw(tlv_101, recode->str, recode->len); - string_free(recode, 1); + while (*tmp) { + if ((*tmp++ & ~0x7f)) { + enc = 2; /* not ascii char */ + break; + } + } + if ( enc && !(u || user_private_item_get_int(u, "utf")) ) + enc = 3; /* ANSI -- XXX ?wo? what should we do now? */ - /* send ASCII message - tlv_101 = icq_pack("WW", 0x03, 0x00); // codepage, encoding, copied from ICQ lite - string_append(tlv_101, params[1]); - */ + /* TLV(101) */ + if (enc == 2) { + /* send unicode message */ + string_t recode = icq_convert_to_ucs2be((char *) params[1]); + tlv_101 = icq_pack("WW", 0x02, 0x00); + string_append_raw(tlv_101, recode->str, recode->len); + string_free(recode, 1); + } else { + /* send ASCII/ANSII message */ + tlv_101 = icq_pack("WW", enc, 0x00); // encoding, codepage, copied from ICQ lite + string_append(tlv_101, params[1]); + } - /* TLV(2) */ + /* TLV(2) */ tlv_2 = icq_pack("tcT", icq_pack_tlv_char(0x501, 0x1), /* TLV(501) features, meaning unknown, duplicated from ICQ Lite */ icq_pack_tlv(0x0101, tlv_101->str, tlv_101->len)/* TLV(101) text TLV. */ ); string_free(tlv_101, 1); - /* main packet */ + /* main packet */ pkt = icq_pack("iiWu", (uint32_t) rand(), (uint32_t) rand(), 0x01, (uint32_t) uin); icq_pack_append(pkt, "TTT", icq_pack_tlv(0x02, tlv_2->str, tlv_2->len), /* TLV(2) message-block */ @@ -948,8 +957,8 @@ icq_pack_tlv(0x06, NULL, 0) /* TLV(6) received-offline */ ); - /* message-header */ - icq_makesnac(session, pkt, 0x04, 0x06, 0, 0); + /* message-header */ + icq_makesnac(session, pkt, 0x04, 0x06, NULL, NULL); icq_send_pkt(session, pkt); string_free(tlv_2, 1); @@ -1485,6 +1494,7 @@ command_add(&icq_plugin, "icq:", "?", icq_command_inline_msg, ICQ_ONLY, NULL); command_add(&icq_plugin, "icq:msg", "!uU !", icq_command_msg, ICQ_FLAGS_MSG, NULL); + command_add(&icq_plugin, "icq:chat", "!uU !", icq_command_msg, ICQ_FLAGS_MSG, NULL); command_add(&icq_plugin, "icq:addssi", "!p ?", icq_command_addssi, ICQ_FLAGS, "-p --phone -c --comment -e --email"); From svn w toxygen.net Fri Sep 5 19:30:54 2008 From: svn w toxygen.net (SVN commit) Date: Fri, 5 Sep 2008 19:30:54 +0200 (CEST) Subject: [ekg2-commit] r4605 - trunk/plugins/icq: +trunk/plugins/icq/icq_caps.c +trunk/plugins/icq/icq_caps.h trunk/plugins/icq/Makefile.am trunk/plugins/icq/icq.c trunk/plugins/icq/icq.h trunk/plugins/icq/icq_snac_handlers.c trunk/plugins/icq/misc.c trunk/plugins/icq/misc.h Message-ID: <20080905173054.5D78A17B1F@toxygen.net> Author: wiechu Date: 2008-09-05 19:30:53 +0200 (Fri, 05 Sep 2008) New Revision: 4605 Added: trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_caps.h Modified: trunk/plugins/icq/Makefile.am trunk/plugins/icq/icq.c trunk/plugins/icq/icq.h trunk/plugins/icq/icq_snac_handlers.c trunk/plugins/icq/misc.c trunk/plugins/icq/misc.h Log: rearrange Modified: trunk/plugins/icq/Makefile.am =================================================================== --- trunk/plugins/icq/Makefile.am 2008-09-04 21:44:21 UTC (rev 4604) +++ trunk/plugins/icq/Makefile.am 2008-09-05 17:30:53 UTC (rev 4605) @@ -3,7 +3,7 @@ ICQ_DEFS = -UDBG_CAPHTML -DDBG_CAPMTN -DDBG_CAPXTRAZ -UDBG_CAPXTRAZ_MUC -DDBG_NEWCAPS -DDBG_OSCARFT -DDBG_AIMCONTACTSEND lib_LTLIBRARIES = icq.la -icq_la_SOURCES = icq.c icq.h icq_flap_handlers.c icq_flap_handlers.h icq_snac_handlers.c icq_snac_handlers.h digest.c misc.c misc.h miscicq.h +icq_la_SOURCES = icq.c icq.h icq_caps.c icq_caps.h icq_flap_handlers.c icq_flap_handlers.h icq_snac_handlers.c icq_snac_handlers.h digest.c misc.c misc.h miscicq.h icq_la_LDFLAGS = -module -avoid-version icq_la_CPPFLAGS = $(C_FVISIBILITY) $(ICQ_DEFS) Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-04 21:44:21 UTC (rev 4604) +++ trunk/plugins/icq/icq.c 2008-09-05 17:30:53 UTC (rev 4605) @@ -155,10 +155,7 @@ icq_pack_append(tlv_5, "P", (uint32_t) 0x134E); /* CAP_UTF8MSGS - Client supports UTF-8 messages.*/ #ifdef DBG_NEWCAPS /* Tells server we understand to new format of caps */ - #if 0 - /* XXX -- it breaks CAPS */ - icq_pack_append(tlv_5, "I", (uint32_t) 0x0000); /* CAP_NEWCAPS */ - #endif + icq_pack_append(tlv_5, "P", (uint32_t) 0x0000); /* CAP_NEWCAPS */ #endif Modified: trunk/plugins/icq/icq.h =================================================================== --- trunk/plugins/icq/icq.h 2008-09-04 21:44:21 UTC (rev 4604) +++ trunk/plugins/icq/icq.h 2008-09-05 17:30:53 UTC (rev 4605) @@ -50,29 +50,6 @@ icq_rate_t **rates; } icq_private_t; -typedef enum { - CAP_HTML = 0, - CAP_VOICE, /* Client supports voice chat */ - CAP_AIMDIRPLAY, /* Client supports direct play service */ - CAP_SENDFILE, /* Client supports file transfer (can send files) */ - CAP_ICQDIRECT, /* Something called "route finder" (ICQ2K only) */ - CAP_IMIMAGE, /* Client supports DirectIM/IMImage */ - CAP_BUDDYICON, /* Client supports avatar service. */ - CAP_SAVESTOCKS, /* Client supports stocks (add-ins) */ - CAP_GETFILE, /* Client supports filetransfers (can receive files) */ - CAP_SRV_RELAY, /* Client supports channel 2 extended, TLV(0x2711) based messages */ - CAP_GAMES2, /* Client supports games */ - CAP_GAMES, /* Client supports games */ - CAP_CONTACTS, /* Client supports buddy lists transfer */ - CAP_INTEROPERATE, /* Setting this lets AIM users receive messages from ICQ users, and ICQ users receive messages from AIM users */ - CAP_UTF, /* Client supports UTF-8 messages */ - CAP_XTRAZ, - CAP_TYPING, /* Client supports mini typing notifications */ - CAP_CHAT, /* Client supports chat service */ - CAP_RTF, /* Client supports RTF messages */ - CAP_UNKNOWN -} capabilities_t; - int icq_send_pkt(session_t *s, string_t buf); void icq_session_connected(session_t *s); Added: trunk/plugins/icq/icq_caps.c =================================================================== --- trunk/plugins/icq/icq_caps.c (rev 0) +++ trunk/plugins/icq/icq_caps.c 2008-09-05 17:30:53 UTC (rev 4605) @@ -0,0 +1,98 @@ +/* + * (C) Copyright 2006-2008 Jakub Zawadzki + * 2008 Wiesław Ochmiński + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include + +#include "icq_caps.h" + +typedef unsigned char _capability_t[16]; +static const _capability_t _caps[CAP_UNKNOWN+1] = +{ + {0x01, 0x38, 0xca, 0x7b, 0x76, 0x9a, 0x49, 0x15, 0x88, 0xf2, 0x13, 0xfc, 0x00, 0x97, 0x9e, 0xa8}, // CAP_HTML + {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_NEWCAPS + {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_VOICE + {0x09, 0x46, 0x13, 0x42, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_AIMDIRPLAY + {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_SENDFILE + {0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_ICQDIRECT + {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_IMIMAGE + {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_BUDDYICON + {0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_SAVESTOCKS + {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_GETFILE + {0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_SRV_RELAY + {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1, 0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_GAMES2 + {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_GAMES + {0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_CONTACTS + {0x09, 0x46, 0x13, 0x4c, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_DEVILS + {0x09, 0x46, 0x13, 0x4d, 0x4d, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_INTEROPERATE + {0x09, 0x46, 0x13, 0x4e, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_UTF + {0x1a, 0x09, 0x3c, 0x6c, 0xd7, 0xfd, 0x4e, 0xc5, 0x9d, 0x51, 0xa6, 0x47, 0x4e, 0x34, 0xf5, 0xa0}, // CAP_XTRAZ + {0x56, 0x3f, 0xc8, 0x09, 0x0b, 0x6f, 0x41, 0xbd, 0x9f, 0x79, 0x42, 0x26, 0x09, 0xdf, 0xa2, 0xf3}, // CAP_TYPING + {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_CHAT + {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}, // CAP_RTF + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // CAP_UNKNOWN +}; + +int icq_cap_id(unsigned char *buf) { + int i; + if (buf) + return CAP_UNKNOWN; + for (i=0; i0) && (id0) && (id0) && (id0) && (id Author: wiechu Date: 2008-09-05 23:58:47 +0200 (Fri, 05 Sep 2008) New Revision: 4606 Modified: trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_caps.h trunk/plugins/icq/icq_snac_handlers_03buddy.inc Log: fix capabilities & start handle short caps Modified: trunk/plugins/icq/icq_caps.c =================================================================== --- trunk/plugins/icq/icq_caps.c 2008-09-05 17:30:53 UTC (rev 4605) +++ trunk/plugins/icq/icq_caps.c 2008-09-05 21:58:47 UTC (rev 4606) @@ -18,6 +18,8 @@ #include +#include + #include "icq_caps.h" typedef unsigned char _capability_t[16]; @@ -45,19 +47,28 @@ {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_CHAT {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}, // CAP_RTF {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // CAP_UNKNOWN + }; int icq_cap_id(unsigned char *buf) { int i; - if (buf) + if (!buf) return CAP_UNKNOWN; for (i=0; i0) && (idnext) { + if (u) { + user_private_item_set_int(u, "caps", 0); + user_private_item_set_int(u, "utf", 0); + } + for (t = tlvs; t; t = t->next) { + /* darkjames said: "I don't trust anything. Wiechu, check t->len" */ switch (t->type) { case 0x01: @@ -162,6 +168,22 @@ /* now we've got trusted length */ switch (t->type) { + case 0x01: /* User class */ + if (u) + user_private_item_set_int(u, "class", t->nr); + debug_white("icq_snac_buddy_online() class 0x%02x\n", t->nr); + break; + + case 0x03: /* Time when client gone online (unix time_t) */ + if (u) + user_private_item_set_int(u, "online", t->nr); + break; + + case 0x05: /* Time when this account was registered (unix time_t) */ + if (u && t->nr) + user_private_item_set_int(u, "member", t->nr); + break; + case 0x06: { /* User status @@ -177,6 +199,8 @@ continue; } + if (u) + user_private_item_set_int(u, "status_f", icq_status_flags); debug_white("icq_snac_buddy_online() status2=0x%04x status=0x%04x\n", icq_status_flags, icq_status); status = icq2ekg_status(icq_status); break; @@ -185,25 +209,11 @@ case 0x0a: /* IP address */ { uint32_t ip; - if (icq_unpack_nc(t->buf, t->len, "i", &ip)) + if (u && icq_unpack_nc(t->buf, t->len, "i", &ip)) user_private_item_set_int(u, "ip", ip); break; } - case 0x01: /* User class */ - debug_white("icq_snac_buddy_online() class 0x%02x\n", t->nr); - break; - case 0x03: /* Time when client gone online (unix time_t) */ - user_private_item_set_int(u, "online", t->nr); - break; - case 0x05: /* Time when this account was registered (unix time_t) */ - if (t->nr) - user_private_item_set_int(u, "member", t->nr); - break; - case 0x0f: /* Online time in seconds */ - debug_white("icq_snac_buddy_online() %d seconds online\n", t->nr); - break; - case 0x0c: /* DC info */ { struct { @@ -212,7 +222,6 @@ uint8_t tcp_flag; uint16_t version; uint32_t conn_cookie; - uint32_t web_port; uint32_t client_features; /* faked time signatures, used to identify clients */ @@ -222,20 +231,82 @@ uint16_t junk; } tlv_c; - if (!icq_unpack_nc(t->buf, t->len, "IICWI", + if (!icq_unpack_nc(t->buf, t->len, "IICWIII", &tlv_c.ip, &tlv_c.port, &tlv_c.tcp_flag, &tlv_c.version, - &tlv_c.conn_cookie)) + &tlv_c.conn_cookie, &tlv_c.web_port, + &tlv_c.client_features)) { debug_error("icq_snac_buddy_online() TLV(C) corrupted?\n"); continue; + } else { + if (u) { + user_private_item_set_int(u, "dcc.ip", tlv_c.ip); + user_private_item_set_int(u, "dcc.port", tlv_c.port); + user_private_item_set_int(u, "dcc.flag", tlv_c.tcp_flag); + user_private_item_set_int(u, "dcc.ver", tlv_c.version); + user_private_item_set_int(u, "dcc.cookie", tlv_c.conn_cookie); + user_private_item_set_int(u, "dcc.web_port", tlv_c.web_port); + } + if (t->len >= 12 && icq_unpack_nc(t->buf, t->len, "23 III", &tlv_c.ts1, &tlv_c.ts3, &tlv_c.ts3)) + ; } - /* XXX, this info should be saved for /dcc ! */ + break; + } + case 0x0d: /* Client capabilities list */ + { + unsigned char *data = t->buf; + int d_len = t->len; + int caps = user_private_item_get_int(u, "caps"); + + if (tlv_length_check("icq_snac_buddy_online()", t, t->len & ~0xF)) + break; + if (!u) + break; + while (d_len > 0) { + int cid = icq_cap_id(data); + if (cid != CAP_UNKNOWN) { + caps |= 1 << cid; + if (cid == CAP_UTF) + user_private_item_set_int(u, "utf", 1); + } else { + /* client id???*/ + } + data += 0x10; // capability length + d_len -= 0x10; + } + user_private_item_set_int(u, "caps", caps); break; } + case 0x0f: /* Online time in seconds */ + debug_white("icq_snac_buddy_online() %d seconds online\n", t->nr); + break; + + case 0x19: /* */ + { + unsigned char *data = t->buf; + int d_len = t->len; + int caps = user_private_item_get_int(u, "caps"); + + if (!u) + break; + while (d_len > 0) { + int cid = icq_short_cap_id(data); + if (cid != CAP_UNKNOWN) { + caps |= 1 << cid; + if (cid == CAP_UTF) + user_private_item_set_int(u, "utf", 1); + } else { + /* WTF? */ + } + data += 2; // short capability length + d_len -= 2; + } + user_private_item_set_int(u, "caps", caps); + } case 0x1d: /* user icon id & hash */ { unsigned char *t_data = t->buf; @@ -284,34 +355,6 @@ break; } - case 0x0d: /* Client capabilities list */ - { - unsigned char *data = t->buf; - int d_len = t->len; - int caps = 0; - - if (tlv_length_check("icq_snac_buddy_online()", t, t->len & ~0xF)) - break; - if (!u) - break; - user_private_item_set_int(u, "caps", 0); - user_private_item_set_int(u, "utf", 0); - while (d_len > 0) { - int cid = icq_cap_id(data); - if (cid != CAP_UNKNOWN) { - caps |= 1 << cid; - if (cid == CAP_UTF) - user_private_item_set_int(u, "utf", 1); - } else { - /* client id???*/ - } - data += 0x10; // capability length - d_len -= 0x10; - } - user_private_item_set_int(u, "caps", caps); - break; - } - default: debug_error("icq_snac_buddy_online() Unknown TLV(0x%x)\n", t->type); } From svn w toxygen.net Sat Sep 6 00:29:58 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 6 Sep 2008 00:29:58 +0200 (CEST) Subject: [ekg2-commit] r4607 - trunk/plugins/icq: trunk/plugins/icq/icq_snac_handlers_03buddy.inc Message-ID: <20080905222958.3EDE017B1F@toxygen.net> Author: wiechu Date: 2008-09-06 00:29:57 +0200 (Sat, 06 Sep 2008) New Revision: 4607 Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc Log: fix Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-05 21:58:47 UTC (rev 4606) +++ trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-05 22:29:57 UTC (rev 4607) @@ -306,7 +306,9 @@ d_len -= 2; } user_private_item_set_int(u, "caps", caps); + break; } + case 0x1d: /* user icon id & hash */ { unsigned char *t_data = t->buf; From svn w toxygen.net Sat Sep 6 11:36:09 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 6 Sep 2008 11:36:09 +0200 (CEST) Subject: [ekg2-commit] r4608 - trunk/plugins/icq: trunk/plugins/icq/icq_snac_handlers_01service.inc trunk/plugins/icq/icq_snac_handlers_03buddy.inc Message-ID: <20080906093609.BFD7017B1F@toxygen.net> Author: wiechu Date: 2008-09-06 11:36:09 +0200 (Sat, 06 Sep 2008) New Revision: 4608 Modified: trunk/plugins/icq/icq_snac_handlers_01service.inc trunk/plugins/icq/icq_snac_handlers_03buddy.inc Log: code complement Modified: trunk/plugins/icq/icq_snac_handlers_01service.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_01service.inc 2008-09-05 22:29:57 UTC (rev 4607) +++ trunk/plugins/icq/icq_snac_handlers_01service.inc 2008-09-06 09:36:09 UTC (rev 4608) @@ -309,44 +309,54 @@ if (xstrcmp(s->uid+4, uin)) debug_error("icq_snac_service_reqinfo() Warning: Server thinks our UIN is %s, when it is %s\n", uin, s->uid+4); - /* - * TLV(x01) User type? - * TLV(x0C) Empty CLI2CLI Direct connection info - * TLV(x0A) External IP - * TLV(x0F) Number of seconds that user has been online - * TLV(x03) The online since time. - * TLV(x0A) External IP again - * TLV(x22) Unknown - * TLV(x1E) Unknown: empty. - * TLV(x05) Member of ICQ since. - * TLV(x14) Unknown - */ tlvs = icq_unpack_tlvs(&databuf, &len, count); /* XXX, miranda check dwRef. */ /* XXX, miranda saves */ for (t = tlvs; t; t = t->next) { switch (t->type) { - case 0x03: + case 0x01: /* User type */ + if (tlv_length_check("icq_snac_service_reqinfo()", t, 2)) goto def; + debug_white("icq_snac_service_reqinfo() User type: 0x%x\n", t->nr); + break; + + case 0x03: /* The online since time */ if (tlv_length_check("icq_snac_service_reqinfo()", t, 4)) goto def; - debug_white("icq_snac_service_reqinfo() Logon TS: %u\n", t->nr); + debug_white("icq_snac_service_reqinfo() Logon time: %s\n", int2time_str("%Y-%m-%d %H:%M", t->nr)); break; - case 0x05: + case 0x05: /* Member of ICQ since */ if (tlv_length_check("icq_snac_service_reqinfo()", t, 4)) goto def; debug_white("icq_snac_service_reqinfo() ICQ Member since: %s\n", int2time_str("%Y-%m-%d %H:%M", t->nr)); break; - case 0x0A: + case 0x0a: /* External IP */ if (tlv_length_check("icq_snac_service_reqinfo()", t, 4)) goto def; debug_white("icq_snac_service_reqinfo() External IP: %u.%u.%u.%u\n", t->buf[0], t->buf[1], t->buf[2], t->buf[3]); break; + case 0x0c: /* Empty CLI2CLI Direct connection info */ + break; + + case 0x0d: /* Our capabilities */ + debug_white("icq_snac_service_reqinfo() Server knows %d our caps\n", t->len >> 4); + break; + + case 0x0f: /* Number of seconds that user has been online */ + if (tlv_length_check("icq_snac_service_reqinfo()", t, 4)) goto def; + debug_white("icq_snac_service_reqinfo() Online: %u seconds.\n", t->nr); + break; + + case 0x14: + case 0x1e: /* We know that we don't know them */ + case 0x22: + break; + /* XXX */ default: def: - debug_error("icq_snac_service_reqinfo() TLV[%u] datalen: %u\n", t->type, t->len); + debug_error("icq_snac_service_reqinfo() TLV[0x%x] datalen: %u\n", t->type, t->len); icq_hexdump(DEBUG_WHITE, t->buf, t->len); } } Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-05 22:29:57 UTC (rev 4607) +++ trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-06 09:36:09 UTC (rev 4608) @@ -285,7 +285,7 @@ debug_white("icq_snac_buddy_online() %d seconds online\n", t->nr); break; - case 0x19: /* */ + case 0x19: /* short caps */ { unsigned char *data = t->buf; int d_len = t->len; From svn w toxygen.net Mon Sep 8 19:47:30 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 8 Sep 2008 19:47:30 +0200 (CEST) Subject: [ekg2-commit] r4609 - trunk/plugins/icq: trunk/plugins/icq/icq.c trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_caps.h Message-ID: <20080908174730.F093E17B1F@toxygen.net> Author: wiechu Date: 2008-09-08 19:47:30 +0200 (Mon, 08 Sep 2008) New Revision: 4609 Modified: trunk/plugins/icq/icq.c trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_caps.h Log: fix & clean caps. Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-06 09:36:09 UTC (rev 4608) +++ trunk/plugins/icq/icq.c 2008-09-08 17:47:30 UTC (rev 4609) @@ -47,6 +47,7 @@ #include "icq.h" #include "misc.h" +#include "icq_caps.h" #include "icq_flap_handlers.h" #include "icq_snac_handlers.h" @@ -142,41 +143,35 @@ tlv_5 = string_init(NULL); #ifdef DBG_CAPMTN - icq_pack_append(tlv_5, "IIII", (uint32_t) 0x563FC809, /* CAP_TYPING */ - (uint32_t) 0x0B6F41BD, - (uint32_t) 0x9F794226, - (uint32_t) 0x09DFA2F3); + icq_pack_append_cap(tlv_5, CAP_TYPING); #endif - icq_pack_append(tlv_5, "P", (uint32_t) 0x1349); /* AIM_CAPS_ICQSERVERRELAY - Client supports channel 2 extended, TLV(0x2711) based messages. */ + icq_pack_append_cap(tlv_5, CAP_SRV_RELAY); /* Client supports channel 2 extended, TLV(0x2711) based messages. */ - /* Broadcasts the capability to receive UTF8 encoded messages */ - if (m_bUtfEnabled) - icq_pack_append(tlv_5, "P", (uint32_t) 0x134E); /* CAP_UTF8MSGS - Client supports UTF-8 messages.*/ + + if (m_bUtfEnabled) + icq_pack_append_cap(tlv_5, CAP_UTF); /* Broadcasts the capability to receive UTF8 encoded messages */ #ifdef DBG_NEWCAPS /* Tells server we understand to new format of caps */ - icq_pack_append(tlv_5, "P", (uint32_t) 0x0000); /* CAP_NEWCAPS */ + icq_pack_append_cap(tlv_5, CAP_NEWCAPS); #endif #ifdef DBG_CAPXTRAZ - icq_pack_append(tlv_5, "I", (uint32_t) 0x1a093c6c); /* CAP_XTRAZ */ - icq_pack_append(tlv_5, "I", (uint32_t) 0xd7fd4ec5); /* Broadcasts the capability to handle */ - icq_pack_append(tlv_5, "I", (uint32_t) 0x9d51a647); /* Xtraz */ - icq_pack_append(tlv_5, "I", (uint32_t) 0x4e34f5a0); + icq_pack_append_cap(tlv_5, CAP_XTRAZ); /* Broadcasts the capability to handle Xtraz */ #endif if (m_bAvatarsEnabled) - icq_pack_append(tlv_5, "P", (uint32_t) 0x134C); /* CAP_DEVILS */ + icq_pack_append_cap(tlv_5, CAP_DEVILS); #ifdef DBG_OSCARFT /* Broadcasts the capability to receive Oscar File Transfers */ - icq_pack_append(tlv_5, "P", (uint32_t) 0x1343); /* CAP_AIM_FILE - Client supports file transfer (can send files). */ + icq_pack_append_cap(tlv_5, CAP_SENDFILE); #endif if (j->aim) - icq_pack_append(tlv_5, "P", (uint32_t) 0x134D); /* Tells the server we can speak to AIM */ + icq_pack_append_cap(tlv_5, CAP_INTEROPERATE); /* Tells the server we can speak to AIM */ #ifdef DBG_AIMCONTACTSEND - icq_pack_append(tlv_5, "P", (uint32_t) 0x134B); /* CAP_AIM_SENDBUDDYLIST - Client supports buddy lists transfer. */ + icq_pack_append_cap(tlv_5, CAP_CONTACTS); /* Client supports buddy lists transfer. */ #endif #if 0 BYTE bXStatus = getContactXStatus(NULL); @@ -185,7 +180,7 @@ packBuffer(tlv_5, capXStatus[bXStatus-1], 0x10); } #endif - icq_pack_append(tlv_5, "P", (uint32_t) 0x1344); /* AIM_CAPS_ICQDIRECT - Something called "route finder". */ + icq_pack_append_cap(tlv_5, CAP_ICQDIRECT); /* Something called "route finder". */ /*packDWord(&packet, 0x178c2d9b); // Unknown cap packDWord(&packet, 0xdaa545bb); @@ -193,10 +188,7 @@ packDWord(&packet, 0xbd53a10a);*/ #ifdef DBG_CAPHTML - icq_pack_append(tlv_5, "I", (uint32_t) 0x0138ca7b); /* CAP_HTMLMSGS */ - icq_pack_append(tlv_5, "I", (uint32_t) 0x769a4915); /* Broadcasts the capability to receive */ - icq_pack_append(tlv_5, "I", (uint32_t) 0x88f213fc); /* HTML messages */ - icq_pack_append(tlv_5, "I", (uint32_t) 0x00979ea8); + icq_pack_append_cap(tlv_5, CAP_HTML); /* Broadcasts the capability to receive HTML messages */ #endif icq_pack_append(tlv_5, "I", (uint32_t) 0x4D697261); /* Miranda Signature */ icq_pack_append(tlv_5, "I", (uint32_t) 0x6E64614D); Modified: trunk/plugins/icq/icq_caps.c =================================================================== --- trunk/plugins/icq/icq_caps.c 2008-09-06 09:36:09 UTC (rev 4608) +++ trunk/plugins/icq/icq_caps.c 2008-09-08 17:47:30 UTC (rev 4609) @@ -107,3 +107,12 @@ return "Unknown"; } +void icq_pack_append_cap(string_t pkt, int cap_id) { + if ((cap_id >=CAP_UNKNOWN) || (cap_id < 0)) { + debug_error("icq_pack_append_cap() - unknown cap id: 0x%x\n", cap_id); + return; + } + + string_append_raw(pkt, _caps[cap_id], 0x10); + +} Modified: trunk/plugins/icq/icq_caps.h =================================================================== --- trunk/plugins/icq/icq_caps.h 2008-09-06 09:36:09 UTC (rev 4608) +++ trunk/plugins/icq/icq_caps.h 2008-09-08 17:47:30 UTC (rev 4609) @@ -1,8 +1,11 @@ #ifndef __ICQ_CAPS_H #define __ICQ_CAPS_H +#include + typedef enum { CAP_HTML = 0, + CAP_NEWCAPS, /* Client understands new format of caps */ CAP_VOICE, /* Client supports voice chat */ CAP_AIMDIRPLAY, /* Client supports direct play service */ CAP_SENDFILE, /* Client supports file transfer (can send files) */ @@ -22,7 +25,6 @@ CAP_TYPING, /* Client supports mini typing notifications */ CAP_CHAT, /* Client supports chat service */ CAP_RTF, /* Client supports RTF messages */ - CAP_NEWCAPS, /* Client understands new format of caps */ CAP_UNKNOWN } capabilities_t; @@ -33,6 +35,6 @@ const unsigned char *icq_cap_str(int id); +void icq_pack_append_cap(string_t pkt, int cap_id); - #endif From svn w toxygen.net Mon Sep 8 22:40:15 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 8 Sep 2008 22:40:15 +0200 (CEST) Subject: [ekg2-commit] r4610 - in trunk: ekg plugins/sim: trunk/ekg/recode.h trunk/plugins/sim/main.c trunk/plugins/sim/simlite.c Message-ID: <20080908204015.EC68917B1F@toxygen.net> Author: darkjames Date: 2008-09-08 22:40:15 +0200 (Mon, 08 Sep 2008) New Revision: 4610 Modified: trunk/ekg/recode.h trunk/plugins/sim/main.c trunk/plugins/sim/simlite.c Log: gg + sim + pliterki (marmarek) Modified: trunk/ekg/recode.h =================================================================== --- trunk/ekg/recode.h 2008-09-08 17:47:30 UTC (rev 4609) +++ trunk/ekg/recode.h 2008-09-08 20:40:15 UTC (rev 4610) @@ -1,6 +1,8 @@ #ifndef __EKG_RECODE_H #define __EKG_RECODE_H +#include "dynstuff.h" + enum ekg_recode_name { EKG_RECODE_CP = 0, EKG_RECODE_LATIN2, Modified: trunk/plugins/sim/main.c =================================================================== --- trunk/plugins/sim/main.c 2008-09-08 17:47:30 UTC (rev 4609) +++ trunk/plugins/sim/main.c 2008-09-08 20:40:15 UTC (rev 4610) @@ -17,9 +17,9 @@ #include #include +#include #include #include - #include #include "simlite.h" @@ -353,6 +353,7 @@ PLUGIN_CHECK_VER("sim"); plugin_register(&sim_plugin, prio); + ekg_recode_cp_inc(); query_connect_id(&sim_plugin, MESSAGE_ENCRYPT, message_encrypt, NULL); query_connect_id(&sim_plugin, MESSAGE_DECRYPT, message_decrypt, NULL); @@ -375,6 +376,7 @@ static int sim_plugin_destroy() { plugin_unregister(&sim_plugin); + ekg_recode_cp_dec(); xfree(sim_key_path); Modified: trunk/plugins/sim/simlite.c =================================================================== --- trunk/plugins/sim/simlite.c 2008-09-08 17:47:30 UTC (rev 4609) +++ trunk/plugins/sim/simlite.c 2008-09-08 20:40:15 UTC (rev 4610) @@ -39,6 +39,7 @@ #include "simlite.h" #include +#include #include char *sim_key_path = NULL; @@ -397,8 +398,9 @@ unsigned char bf_key_rsa[128]; /* symetryczny szyfrowany RSA */ BIO *mbio = NULL, *cbio = NULL, *bbio = NULL; RSA *private = NULL; - unsigned char *buf = NULL, *res = NULL, *data; - int len, cx; + unsigned char *buf = NULL, *data; + char *res = NULL; + int len; /* jeśli wiadomość jest krótsza niż najkrótsza zaszyfrowana, * nie ma sensu się bawić w próby odszyfrowania. */ @@ -484,15 +486,6 @@ memcpy(res, data + sizeof(head), len); res[len] = 0; - for(cx = 0; cx < len; cx++) - switch(res[cx]) { - case 156: res[cx] = 'ś'; break; - case 185: res[cx] = 'ą'; break; - case 159: res[cx] = 'ź'; break; - case 140: res[cx] = 'Ś'; break; - case 165: res[cx] = 'Ą'; break; - case 143: res[cx] = 'Ź'; break; - } cleanup: if (cbio) BIO_free(cbio); @@ -504,7 +497,7 @@ RSA_free(private); if (buf) free(buf); - return (char*) res; + return ekg_cp_to_locale(res); /* XXX, what if message isn't encoded in cp-1250? */ } /* From svn w toxygen.net Tue Sep 9 01:54:13 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 9 Sep 2008 01:54:13 +0200 (CEST) Subject: [ekg2-commit] r4611 - trunk/plugins/icq: trunk/plugins/icq/icq.c trunk/plugins/icq/icq.h trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_caps.h trunk/plugins/icq/icq_snac_handlers_03buddy.inc Message-ID: <20080908235413.4D93617B1F@toxygen.net> Author: wiechu Date: 2008-09-09 01:54:12 +0200 (Tue, 09 Sep 2008) New Revision: 4611 Modified: trunk/plugins/icq/icq.c trunk/plugins/icq/icq.h trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_caps.h trunk/plugins/icq/icq_snac_handlers_03buddy.inc Log: start handle xstatus & few fix. Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-08 20:40:15 UTC (rev 4610) +++ trunk/plugins/icq/icq.c 2008-09-08 23:54:12 UTC (rev 4611) @@ -173,13 +173,10 @@ #ifdef DBG_AIMCONTACTSEND icq_pack_append_cap(tlv_5, CAP_CONTACTS); /* Client supports buddy lists transfer. */ #endif -#if 0 - BYTE bXStatus = getContactXStatus(NULL); - if (bXStatus) - { - packBuffer(tlv_5, capXStatus[bXStatus-1], 0x10); - } -#endif + + if (j->xstatus) + icq_pack_append_xstatus(tlv_5, j->xstatus); + icq_pack_append_cap(tlv_5, CAP_ICQDIRECT); /* Something called "route finder". */ /*packDWord(&packet, 0x178c2d9b); // Unknown cap @@ -1386,10 +1383,14 @@ userlist_t *u = *va_arg(ap, userlist_t **); int quiet = *va_arg(ap, int *); const char *tmp; + int i; if (!u || valid_plugin_uid(&icq_plugin, u->uid) != 1) return 1; + if ( (i = user_private_item_get_int(u, "xstatus")) ) + printq("icq_user_info_generic", _("xStatus"), icq_xstatus_name(i)); + if ( (tmp = int2time_str("%Y-%m-%d %H:%M", user_private_item_get_int(u, "online"))) ) printq("icq_user_info_generic", _("Online since"), tmp); Modified: trunk/plugins/icq/icq.h =================================================================== --- trunk/plugins/icq/icq.h 2008-09-08 20:40:15 UTC (rev 4610) +++ trunk/plugins/icq/icq.h 2008-09-08 23:54:12 UTC (rev 4611) @@ -42,6 +42,7 @@ int ssi; /* server-side-userlist? */ int aim; /* aim-ok? */ int default_group_id; /* XXX ?wo? TEMP! We should support list of groups */ + int xstatus; char *default_group_name; string_t cookie; /* connection login cookie */ string_t stream_buf; Modified: trunk/plugins/icq/icq_caps.c =================================================================== --- trunk/plugins/icq/icq_caps.c 2008-09-08 20:40:15 UTC (rev 4610) +++ trunk/plugins/icq/icq_caps.c 2008-09-08 23:54:12 UTC (rev 4611) @@ -113,6 +113,106 @@ return; } - string_append_raw(pkt, _caps[cap_id], 0x10); + string_append_raw(pkt, (char *) _caps[cap_id], 0x10); } + +/* + * xStatuses + * + */ + +static const _capability_t _capXStatus[XSTATUS_COUNT] = { + {0x63, 0x62, 0x73, 0x37, 0xa0, 0x3f, 0x49, 0xff, 0x80, 0xe5, 0xf7, 0x09, 0xcd, 0xe0, 0xa4, 0xee}, + {0x5a, 0x58, 0x1e, 0xa1, 0xe5, 0x80, 0x43, 0x0c, 0xa0, 0x6f, 0x61, 0x22, 0x98, 0xb7, 0xe4, 0xc7}, + {0x83, 0xc9, 0xb7, 0x8e, 0x77, 0xe7, 0x43, 0x78, 0xb2, 0xc5, 0xfb, 0x6c, 0xfc, 0xc3, 0x5b, 0xec}, + {0xe6, 0x01, 0xe4, 0x1c, 0x33, 0x73, 0x4b, 0xd1, 0xbc, 0x06, 0x81, 0x1d, 0x6c, 0x32, 0x3d, 0x81}, + {0x8c, 0x50, 0xdb, 0xae, 0x81, 0xed, 0x47, 0x86, 0xac, 0xca, 0x16, 0xcc, 0x32, 0x13, 0xc7, 0xb7}, + {0x3f, 0xb0, 0xbd, 0x36, 0xaf, 0x3b, 0x4a, 0x60, 0x9e, 0xef, 0xcf, 0x19, 0x0f, 0x6a, 0x5a, 0x7f}, + {0xf8, 0xe8, 0xd7, 0xb2, 0x82, 0xc4, 0x41, 0x42, 0x90, 0xf8, 0x10, 0xc6, 0xce, 0x0a, 0x89, 0xa6}, + {0x80, 0x53, 0x7d, 0xe2, 0xa4, 0x67, 0x4a, 0x76, 0xb3, 0x54, 0x6d, 0xfd, 0x07, 0x5f, 0x5e, 0xc6}, + {0xf1, 0x8a, 0xb5, 0x2e, 0xdc, 0x57, 0x49, 0x1d, 0x99, 0xdc, 0x64, 0x44, 0x50, 0x24, 0x57, 0xaf}, + {0x1b, 0x78, 0xae, 0x31, 0xfa, 0x0b, 0x4d, 0x38, 0x93, 0xd1, 0x99, 0x7e, 0xee, 0xaf, 0xb2, 0x18}, + {0x61, 0xbe, 0xe0, 0xdd, 0x8b, 0xdd, 0x47, 0x5d, 0x8d, 0xee, 0x5f, 0x4b, 0xaa, 0xcf, 0x19, 0xa7}, + {0x48, 0x8e, 0x14, 0x89, 0x8a, 0xca, 0x4a, 0x08, 0x82, 0xaa, 0x77, 0xce, 0x7a, 0x16, 0x52, 0x08}, + {0x10, 0x7a, 0x9a, 0x18, 0x12, 0x32, 0x4d, 0xa4, 0xb6, 0xcd, 0x08, 0x79, 0xdb, 0x78, 0x0f, 0x09}, + {0x6f, 0x49, 0x30, 0x98, 0x4f, 0x7c, 0x4a, 0xff, 0xa2, 0x76, 0x34, 0xa0, 0x3b, 0xce, 0xae, 0xa7}, + {0x12, 0x92, 0xe5, 0x50, 0x1b, 0x64, 0x4f, 0x66, 0xb2, 0x06, 0xb2, 0x9a, 0xf3, 0x78, 0xe4, 0x8d}, + {0xd4, 0xa6, 0x11, 0xd0, 0x8f, 0x01, 0x4e, 0xc0, 0x92, 0x23, 0xc5, 0xb6, 0xbe, 0xc6, 0xcc, 0xf0}, + {0x60, 0x9d, 0x52, 0xf8, 0xa2, 0x9a, 0x49, 0xa6, 0xb2, 0xa0, 0x25, 0x24, 0xc5, 0xe9, 0xd2, 0x60}, + {0x1f, 0x7a, 0x40, 0x71, 0xbf, 0x3b, 0x4e, 0x60, 0xbc, 0x32, 0x4c, 0x57, 0x87, 0xb0, 0x4c, 0xf1}, + {0x78, 0x5e, 0x8c, 0x48, 0x40, 0xd3, 0x4c, 0x65, 0x88, 0x6f, 0x04, 0xcf, 0x3f, 0x3f, 0x43, 0xdf}, + {0xa6, 0xed, 0x55, 0x7e, 0x6b, 0xf7, 0x44, 0xd4, 0xa5, 0xd4, 0xd2, 0xe7, 0xd9, 0x5c, 0xe8, 0x1f}, + {0x12, 0xd0, 0x7e, 0x3e, 0xf8, 0x85, 0x48, 0x9e, 0x8e, 0x97, 0xa7, 0x2a, 0x65, 0x51, 0xe5, 0x8d}, + {0xba, 0x74, 0xdb, 0x3e, 0x9e, 0x24, 0x43, 0x4b, 0x87, 0xb6, 0x2f, 0x6b, 0x8d, 0xfe, 0xe5, 0x0f}, + {0x63, 0x4f, 0x6b, 0xd8, 0xad, 0xd2, 0x4a, 0xa1, 0xaa, 0xb9, 0x11, 0x5b, 0xc2, 0x6d, 0x05, 0xa1}, + {0x01, 0xd8, 0xd7, 0xee, 0xac, 0x3b, 0x49, 0x2a, 0xa5, 0x8d, 0xd3, 0xd8, 0x77, 0xe6, 0x6b, 0x92}, + {0x2c, 0xe0, 0xe4, 0xe5, 0x7c, 0x64, 0x43, 0x70, 0x9c, 0x3a, 0x7a, 0x1c, 0xe8, 0x78, 0xa7, 0xdc}, + {0x10, 0x11, 0x17, 0xc9, 0xa3, 0xb0, 0x40, 0xf9, 0x81, 0xac, 0x49, 0xe1, 0x59, 0xfb, 0xd5, 0xd4}, + {0x16, 0x0c, 0x60, 0xbb, 0xdd, 0x44, 0x43, 0xf3, 0x91, 0x40, 0x05, 0x0f, 0x00, 0xe6, 0xc0, 0x09}, + {0x64, 0x43, 0xc6, 0xaf, 0x22, 0x60, 0x45, 0x17, 0xb5, 0x8c, 0xd7, 0xdf, 0x8e, 0x29, 0x03, 0x52}, + {0x16, 0xf5, 0xb7, 0x6f, 0xa9, 0xd2, 0x40, 0x35, 0x8c, 0xc5, 0xc0, 0x84, 0x70, 0x3c, 0x98, 0xfa}, + {0x63, 0x14, 0x36, 0xff, 0x3f, 0x8a, 0x40, 0xd0, 0xa5, 0xcb, 0x7b, 0x66, 0xe0, 0x51, 0xb3, 0x64}, + {0xb7, 0x08, 0x67, 0xf5, 0x38, 0x25, 0x43, 0x27, 0xa1, 0xff, 0xcf, 0x4c, 0xc1, 0x93, 0x97, 0x97}, + {0xdd, 0xcf, 0x0e, 0xa9, 0x71, 0x95, 0x40, 0x48, 0xa9, 0xc6, 0x41, 0x32, 0x06, 0xd6, 0xf2, 0x80} +}; + +const char* _nameXStatus[XSTATUS_COUNT] = { + "Shopping", + "Taking a bath", + "Tired", + "Party", + "Drinking beer", + "Thinking", + "Eating", + "Watching TV", + "Meeting", + "Coffee", + "Listening to music", + "Business", + "Shooting", + "Having fun", + "On the phone", + "Gaming", + "Studying", + "Feeling sick", + "Sleeping", + "Surfing", + "Browsing", + "Working", + "Typing", + "Angry", + "Picnic", + "Cooking", + "Smoking", + "I'm high", + "On WC", + "To be or not to be", + "Watching pro7 on TV", + "Love"}; + + +const char *icq_xstatus_name(int id) { + if ((id <=0) || (id > XSTATUS_COUNT)) + return "unknown"; + return _nameXStatus[id-1]; +} + +int icq_xstatus_id(unsigned char *buf) { + int i; + if (!buf) + return 0; + for (i=0; i XSTATUS_COUNT)) + return; + + string_append_raw(pkt, (char *) _capXStatus[x_id-1], 0x10); + +} Modified: trunk/plugins/icq/icq_caps.h =================================================================== --- trunk/plugins/icq/icq_caps.h 2008-09-08 20:40:15 UTC (rev 4610) +++ trunk/plugins/icq/icq_caps.h 2008-09-08 23:54:12 UTC (rev 4611) @@ -37,4 +37,18 @@ void icq_pack_append_cap(string_t pkt, int cap_id); + +/* + * xStatuses + * + */ + +#define XSTATUS_COUNT 32 + +const char *icq_xstatus_name(int id); + +int icq_xstatus_id(unsigned char *buf); + +void icq_pack_append_xstatus(string_t pkt, int x_id); + #endif Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-08 20:40:15 UTC (rev 4610) +++ trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-08 23:54:12 UTC (rev 4611) @@ -179,6 +179,10 @@ user_private_item_set_int(u, "online", t->nr); break; + case 0x04: /* ?wo? AIM idle timer? XXX */ + debug_white("icq_snac_buddy_online() idle %d\n", t->nr); + break; + case 0x05: /* Time when this account was registered (unix time_t) */ if (u && t->nr) user_private_item_set_int(u, "member", t->nr); @@ -246,7 +250,7 @@ user_private_item_set_int(u, "dcc.flag", tlv_c.tcp_flag); user_private_item_set_int(u, "dcc.ver", tlv_c.version); user_private_item_set_int(u, "dcc.cookie", tlv_c.conn_cookie); - user_private_item_set_int(u, "dcc.web_port", tlv_c.web_port); + user_private_item_set_int(u, "dcc.web_port", tlv_c.web_port); // ?wo? do we need it? } if (t->len >= 12 && icq_unpack_nc(t->buf, t->len, "23 III", &tlv_c.ts1, &tlv_c.ts3, &tlv_c.ts3)) ; @@ -271,8 +275,12 @@ caps |= 1 << cid; if (cid == CAP_UTF) user_private_item_set_int(u, "utf", 1); + } else if ((cid = icq_xstatus_id(data))) { + user_private_item_set_int(u, "xstatus", cid); } else { - /* client id???*/ + /* ?wo? client id???*/ + debug_error("Unknown cap\n"); + icq_hexdump(DEBUG_ERROR, data, 0x10); } data += 0x10; // capability length d_len -= 0x10; From svn w toxygen.net Tue Sep 9 12:53:12 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 9 Sep 2008 12:53:12 +0200 (CEST) Subject: [ekg2-commit] r4612 - trunk/ekg: trunk/ekg/ekg.c Message-ID: <20080909105312.D767C17B1F@toxygen.net> Author: darkjames Date: 2008-09-09 12:53:12 +0200 (Tue, 09 Sep 2008) New Revision: 4612 Modified: trunk/ekg/ekg.c Log: useless. Modified: trunk/ekg/ekg.c =================================================================== --- trunk/ekg/ekg.c 2008-09-08 23:54:12 UTC (rev 4611) +++ trunk/ekg/ekg.c 2008-09-09 10:53:12 UTC (rev 4612) @@ -860,13 +860,6 @@ xfree(tmp); tmp = NULL; - { - query_t **ll; - - for (ll = queries; ll <= &queries[QUERY_EXTERNAL]; ll++) - *ll = NULL; - } - variable_init(); variable_set_default(); From svn w toxygen.net Tue Sep 9 17:25:52 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 9 Sep 2008 17:25:52 +0200 (CEST) Subject: [ekg2-commit] r4613 - trunk/contrib/patches: +trunk/contrib/patches/cmd-upgrade-proof-of-concept.diff Message-ID: <20080909152552.843CE17B1F@toxygen.net> Author: darkjames Date: 2008-09-09 17:25:52 +0200 (Tue, 09 Sep 2008) New Revision: 4613 Added: trunk/contrib/patches/cmd-upgrade-proof-of-concept.diff Log: proof-of-concept /upgrade in ekg2. - current config - windows backlog (ncurses only) sessions later. Added: trunk/contrib/patches/cmd-upgrade-proof-of-concept.diff =================================================================== --- trunk/contrib/patches/cmd-upgrade-proof-of-concept.diff (rev 0) +++ trunk/contrib/patches/cmd-upgrade-proof-of-concept.diff 2008-09-09 15:25:52 UTC (rev 4613) @@ -0,0 +1,965 @@ +Index: ekg/commands.c +=================================================================== +--- ekg/commands.c (wersja 4609) ++++ ekg/commands.c (kopia robocza) +@@ -108,6 +108,7 @@ + char *send_nicks[SEND_NICKS_MAX] = { NULL }; + int send_nicks_count = 0, send_nicks_index = 0; + static int quit_command = 0; ++static int upgrade_command = 0; + + command_t *commands = NULL; + +@@ -1821,6 +1822,14 @@ + return res; + } + ++static COMMAND(cmd_upgrade) ++{ ++ query_emit_id(NULL, EKG_UPGRADE); ++ upgrade_command = 1; ++ ++ return 0; ++} ++ + static COMMAND(cmd_quit) + { + char *reason; +@@ -2429,7 +2438,7 @@ + { + int res; + +- if ((res = config_read_plugins())) printq("error_reading_config", strerror(errno)); ++ if ((res = config_read_plugins(NULL))) printq("error_reading_config", strerror(errno)); + if (res == -1) return -1; + + if ((res = config_read(NULL))) printq("error_reading_config", strerror(errno)); +@@ -2863,6 +2872,9 @@ + if (quit_command) + ekg_exit(); + ++ if (upgrade_command) ++ ekg_upgrade(); ++ + return res; + } + +@@ -4475,6 +4487,8 @@ + "-a --add -d --del -l --list"); + + command_add(NULL, ("unignore"), "i ?", cmd_ignore, 0, NULL); ++ ++ command_add(NULL, ("upgrade"), NULL, cmd_upgrade, 0, NULL); + + command_add(NULL, ("version"), NULL, cmd_version, 0, NULL); + +Index: ekg/queries.h +=================================================================== +--- ekg/queries.h (wersja 4609) ++++ ekg/queries.h (kopia robocza) +@@ -65,8 +65,9 @@ + PROTOCOL_DISCONNECTING, + + USERLIST_REFRESH, ++ EKG_UPGRADE, EKG_RESTORE, + +- QUERY_EXTERNAL, ++ QUERY_EXTERNAL + }; + + #ifdef __DECLARE_QUERIES_STUFF +@@ -453,6 +454,12 @@ + + { USERLIST_REFRESH, "userlist-refresh", { + QUERY_ARG_END } }, ++ ++ { EKG_UPGRADE, "ekg-upgrade", { ++ QUERY_ARG_END } }, ++ ++ { EKG_RESTORE, "ekg-restore", { ++ QUERY_ARG_END } } + }; + + /* other, not listed above here queries, for example plugin which use internally his own query, +Index: ekg/themes.c +=================================================================== +--- ekg/themes.c (wersja 4609) ++++ ekg/themes.c (kopia robocza) +@@ -1361,6 +1361,7 @@ + format_add("unknown_command", _("%! Unknown command: %T%1%n\n"), 1); + format_add("welcome", _("%> %Tekg2-%1%n (%ge%Gk%gg %Gr%ge%Gl%go%Ga%gd%Ge%gd%n)\n%> Software licensed on GPL v2 terms\n\n"), 1); + format_add("welcome,speech", _("welcome in e k g 2."), 1); ++ format_add("welcome_again", _("%> %Tekg2-%1%n (%ge%Gk%gg %Gr%ge%Gl%go%Ga%gd%Ge%gd%n) (compiled %2)"), 1); + format_add("ekg_version", _("%) %Tekg2-%1%n (compiled %2)\n"), 1); + format_add("secure", _("%Y(encrypted)%n"), 1); + format_add("day_changed", _("%) Day changed to: %W%1"), 1); +Index: ekg/configfile.c +=================================================================== +--- ekg/configfile.c (wersja 4609) ++++ ekg/configfile.c (kopia robocza) +@@ -48,6 +48,7 @@ + #include "vars.h" + #include "xmalloc.h" + #include "plugins.h" ++#include "sessions.h" + #include "windows.h" + + #include "queries.h" +@@ -89,9 +90,9 @@ + * + * initialized after config is read + */ +-void config_postread() ++void config_postread(int restoring) + { +- if (config_windows_save && config_windows_layout) { ++ if ((config_windows_save || restoring) && config_windows_layout) { + char **targets = array_make(config_windows_layout, "|", 0, 0, 0); + int i; + +@@ -141,17 +142,18 @@ + query_emit_id(NULL, CONFIG_POSTINIT); + } + +-int config_read_plugins() ++int config_read_plugins(const char *filename) + { + char*buf, *foo; +- const char *filename; + FILE *f; + struct stat st; + ++ if (!filename) ++ filename = prepare_path("plugins", 0); + +- if (!(filename = prepare_path("plugins", 0))) +- return -1; +- ++ if (!filename) ++ return -1; ++ + check_file(); + + while ((buf = read_file(f, 0))) { +@@ -735,6 +737,90 @@ + } + } + ++ /* XXX: ++ * - save children list ++ - metacontact_write() ++ - script_variables_write()) ++ ++ */ ++int config_write_upgrade() { ++ FILE *f; ++ plugin_t *p; ++ const char *path; ++ session_t *s; ++ ++ if (!prepare_path(NULL, 1)) /* try to create ~/.ekg2 dir */ ++ return -1; ++ ++ /* first of all we are saving plugins */ ++ if (!(path = prepare_pathf("upgrade-plugins.%d", getpid()))) ++ return -1; ++ if (!(f = fopen(path, "w"))) ++ return -1; ++ fchmod(fileno(f), 0600); ++ config_write_plugins(f); ++ fclose(f); ++ ++ /* now we are saving global variables and settings ++ * timers, bindings etc. */ ++ if (!(path = prepare_pathf("upgrade-config.%d", getpid()))) ++ return -1; ++ if (!(f = fopen(path, "w"))) ++ return -1; ++ fchmod(fileno(f), 0600); ++ config_write_main(f); ++ /* now plugins variables (unline config_write() it saves all variables to the same file) */ ++ for (p = plugins; p; p = p->next) { ++ variable_t *v; ++ ++ for (v = variables; v; v = v->next) { ++ if (p == v->plugin) ++ config_write_variable(f, v); ++ } ++ } ++ fclose(f); ++ ++ /* XXX, sessions_write() */ ++ if (!(path = prepare_pathf("upgrade-sessions.%d", getpid()))) ++ return -1; ++ if (!(f = fopen(path, "w"))) ++ return -1; ++ ++ for (s = sessions; s; s = s->next) { ++ int i; ++ ++ p = s->plugin; ++ ++ // userlist_write(s); // XXX ++ fprintf(f, "[%s]\n", s->uid); ++ if (s->alias) ++ fprintf(f, "alias=%s\n", s->alias); ++ if (s->status) ++ fprintf(f, "status=%s\n", ekg_status_string(s->autoaway ? s->last_status : s->status, 0)); /* XXX? */ ++ if (s->descr) { ++ char *myvar = (s->autoaway ? s->last_descr : s->descr); /* XXX? */ ++ xstrtr(myvar, '\n', '\002'); ++ fprintf(f, "descr=%s\n", myvar); ++ xstrtr(myvar, '\002', '\n'); ++ } ++ if (s->password) ++ fprintf(f, "password=\001%s\n", s->password); ++ ++ if (!p->params) ++ continue; ++ ++ for (i = 0; (p->params[i].key /* && p->params[i].id != -1 */); i++) { ++ if (!s->values[i]) ++ continue; ++ fprintf(f, "%s=%s\n", p->params[i].key, s->values[i]); ++ } ++ /* XXX, save _locale_ variables */ ++ } ++ fclose(f); ++ ++ return 0; ++} ++ + /* + * debug_write_crash() + * +Index: ekg/ekg.c +=================================================================== +--- ekg/ekg.c (wersja 4612) ++++ ekg/ekg.c (kopia robocza) +@@ -668,6 +668,7 @@ + int auto_connect = 1, c = 0, no_global_config = 0, no_config = 0, new_status = 0; + char *tmp = NULL, *new_descr = NULL; + char *load_theme = NULL, *new_profile = NULL, *frontend = NULL; ++ int is_restore = 0; + #ifndef NO_POSIX_SYSTEM + struct rlimit rlim; + #else +@@ -732,7 +733,7 @@ + signal(SIGALRM, SIG_IGN); + signal(SIGPIPE, SIG_IGN); + #endif +- while ((c = getopt_long(argc, argv, "b::a::i::d::f::x::u:F:t:nmNhvU", ekg_options, NULL)) != -1) ++ while ((c = getopt_long(argc, argv, "b::a::i::d::f::x::u:F:t:nmrNhvU", ekg_options, NULL)) != -1) + { + switch (c) { + case 'a': +@@ -812,6 +813,9 @@ + no_global_config = 1; + break; + ++ case 'r': ++ is_restore = 1; ++ break; + + case 'h': + printf(_(EKG_USAGE), argv[0]); +@@ -863,7 +867,7 @@ + variable_init(); + variable_set_default(); + +- mesg_startup = mesg_set(MESG_CHECK); ++ mesg_startup = mesg_set(MESG_CHECK); /* is_restore OK */ + #ifdef DEFAULT_THEME + if (theme_read(DEFAULT_THEME, 1) == -1) + #endif +@@ -873,7 +877,7 @@ + window_status = window_new(NULL, NULL, 1); /* okno stanu */ + window_current = window_status; + +- if (!no_global_config) ++ if (!is_restore && !no_global_config) + config_read(SYSCONFDIR "/ekg2.conf"); + + if (frontend) { +@@ -881,43 +885,57 @@ + config_changed = 1; + } + +- config_read_plugins(); +- if (!no_global_config) ++ config_read_plugins(is_restore ? prepare_pathf("upgrade-plugins.%d", ekg_pid) : NULL); ++ ++ if (!is_restore && !no_global_config) + config_read(SYSCONFDIR "/ekg2-override.conf"); + + /* userlist_read(); */ +- emoticon_read(); +- msg_queue_read(); ++ emoticon_read(); /* is_restore OK */ ++ msg_queue_read(); /* is_restore OK */ + ++ if (is_restore) ++ query_emit_id(NULL, EKG_RESTORE); ++ ++ if (is_restore == 0) { + #ifdef HAVE_NCURSES +- if (!have_plugin_of_class(PLUGIN_UI)) plugin_load(("ncurses"), -254, 1); ++ if (!have_plugin_of_class(PLUGIN_UI)) plugin_load(("ncurses"), -254, 1); + #endif + #ifdef HAVE_GTK +- if (!have_plugin_of_class(PLUGIN_UI)) plugin_load(("gtk"), -254, 1); ++ if (!have_plugin_of_class(PLUGIN_UI)) plugin_load(("gtk"), -254, 1); + #endif + #ifdef HAVE_READLINE +- if (!have_plugin_of_class(PLUGIN_UI)) plugin_load(("readline"), -254, 1); ++ if (!have_plugin_of_class(PLUGIN_UI)) plugin_load(("readline"), -254, 1); + #endif +- if (!have_plugin_of_class(PLUGIN_UI)) fprintf(stderr, "No UI-PLUGIN!\n"); +- else { ++ } ++ ++ if (!have_plugin_of_class(PLUGIN_UI)) ++ fprintf(stderr, "No UI-PLUGIN!\n"); /* also display when restore, it means ABI changed! / you deleted this plugin */ ++ /* XXX, try /upgrade in next 30s? 10m? 30m? 1h? :> */ ++ /* , or when keypressed? */ ++ ++ if (have_plugin_of_class(PLUGIN_UI)) { + struct buffer *b; + for (b = buffer_debug.data; b; b = b->next) + print_window_w(window_debug, EKG_WINACT_NONE, b->target, b->line); + } + +- if (!have_plugin_of_class(PLUGIN_PROTOCOL)) { ++ if (is_restore == 0) { ++ if (!have_plugin_of_class(PLUGIN_PROTOCOL)) { + #ifdef HAVE_EXPAT +- plugin_load(("jabber"), -254, 1); ++ plugin_load(("jabber"), -254, 1); + #endif + #ifdef HAVE_LIBGADU +- plugin_load(("gg"), -254, 1); ++ plugin_load(("gg"), -254, 1); + #endif +- plugin_load(("irc"), -254, 1); ++ plugin_load(("irc"), -254, 1); ++ } + } ++ + theme_plugins_init(); + + scripts_init(); +- config_read(NULL); ++ config_read(is_restore ? prepare_pathf("upgrade-config.%d", ekg_pid) : NULL); + + /* jeśli ma być theme, niech będzie theme */ + if (load_theme) theme_read(load_theme, 1); +@@ -943,7 +961,7 @@ + } + + if (!batch_mode && config_display_welcome) +- print("welcome", VERSION); ++ print(is_restore ? "welcome_again" : "welcome", VERSION, compile_time()); + + protocol_init(); + events_init(); +@@ -953,10 +971,10 @@ + + /* it has to be done after plugins are loaded, either we wouldn't know if we are + * supporting some protocol in current build */ +- if (session_read(NULL) == -1) ++ if (session_read(is_restore ? prepare_pathf("upgrade-sessions.%d", ekg_pid) : NULL) == -1) + no_config = 1; + +- config_postread(); ++ config_postread(is_restore); + + /* status window takes first session if not set before*/ + if (!session_current && sessions) +@@ -965,13 +983,19 @@ + if (session_current != window_current->session) + window_current->session = session_current; + window_debug->session = window_current->session; ++ + /* ++ if (is_restore) ++ query_emit_id(NULL, EKG_RESTORE); ++ */ ++ ++/* + query_emit_id(NULL, SESSION_CHANGED); + query_emit_id(NULL, UI_REFRESH); + */ +- metacontact_read(); /* read the metacontacts info */ ++ metacontact_read(); /* read the metacontacts info */ /* XXX, is_restore */ + +- { ++ if (is_restore == 0) { + session_t *s; + + /* wylosuj opisy i zmień stany klientów */ +@@ -997,10 +1021,10 @@ + } + } + +- if (config_auto_save) ++ if (config_auto_save) /* XXX, is_restore */ + last_save = time(NULL); + +- if (no_config) { ++ if (!is_restore && no_config) { + #ifdef HAVE_LIBGADU + if (plugin_find("gg")) + print("no_config"); +@@ -1012,7 +1036,7 @@ + } + + idle_add(NULL, ekg_less_important_handler, &ekg_tv); +- reason_changed = 0; ++ reason_changed = 0; /* XXX, is_restore */ + /* jesli jest emit: ui-loop (plugin-side) to dajemy mu kontrole, jesli nie + * to wywolujemy normalnie sami ekg_loop() w petelce */ + if (query_emit_id(NULL, UI_LOOP) != -1) { +@@ -1027,6 +1051,148 @@ + return 0; + } + ++static void send_nicks_destroy() { ++ int i; ++ ++ for (i = 0; i < SEND_NICKS_MAX; i++) { ++ xfree(send_nicks[i]); ++ send_nicks[i] = NULL; ++ } ++ send_nicks_count = 0; ++} ++ ++static void watches_destroy() { ++ list_t l; ++ ++ for (l = watches; l; l = l->next) { ++ watch_t *w = l->data; ++ ++ watch_free(w); ++ } ++ list_destroy(watches, 0); watches = NULL; ++} ++ ++static void plugins_destroy(plugin_class_t pclass) { ++ extern int ekg2_dlclose(void *plugin); ++ plugin_t *p; ++ ++ for (p = plugins; p; ) { ++ plugin_t *next = p->next; ++ ++ if (p->pclass == pclass || pclass == PLUGIN_ANY) { ++ p->destroy(); ++ ++ if (p->dl) ++ ekg2_dlclose(p->dl); ++ } ++ p = next; ++ } ++} ++ ++static void queries_destroy() { ++ query_t **ll; ++ ++ for (ll = queries; ll <= &queries[QUERY_EXTERNAL]; ll++) { ++ query_t *q; ++ ++ for (q = *ll; q; ) { /* free other queries... connected by protocol_init() for example */ ++ query_t *next = q->next; ++ ++ query_free(q); ++ ++ q = next; ++ } ++ LIST_DESTROY2(*ll, NULL); /* XXX: really needed? */ ++ } ++} ++ ++static void lastsearch_destroy() { ++ xfree(last_search_first_name); ++ xfree(last_search_last_name); ++ xfree(last_search_nickname); ++ xfree(last_search_uid); ++} ++ ++static void ekg_destroy_common() { ++/* XXX, think about sequence of unloading. */ ++ msgs_queue_destroy(); ++ conferences_destroy(); ++ newconferences_destroy(); ++ metacontacts_destroy(); ++ sessions_free(); ++ plugins_destroy(PLUGIN_ANY); ++ audio_deinitialize(); ++ aliases_destroy(); ++ theme_free(); ++ variables_destroy(); ++ script_variables_free(1); ++ emoticons_destroy(); ++ commands_destroy(); ++ timers_destroy(); ++ binding_free(); ++ lasts_destroy(); ++ buffer_free(&buffer_debug); buffer_free(&buffer_speech); ++ event_free(); ++ xfree(read_file(NULL, -1)); /* free internal read_file() buffer */ ++ ++/* windows: */ ++ windows_destroy(); ++ window_status = NULL; window_debug = NULL; window_current = NULL; /* just in case */ ++ ++ queries_destroy(); ++ query_external_free(); ++ ++ xfree(home_dir); ++ xfree(config_dir); ++ xfree(console_charset); ++#ifdef NO_POSIX_SYSTEM ++ WSACleanup(); ++#endif ++ close(stderr_backup); ++} ++ ++void ekg_upgrade() ++{ ++ int tmp; ++ ++ msg_queue_write(); ++ lastsearch_destroy(); ++ ++ /* save window configuration */ ++ tmp = config_windows_save; ++ config_windows_save = 1; ++ windows_save(); ++ config_windows_save = tmp; ++ ++ /* XXX, save current session (XXX, use session_default variable?)*/ ++ if (config_sessions_save && session_current) { ++ const char *vars[] = { "session_default", NULL }; ++ xfree(config_session_default); config_session_default = xstrdup(session_current->uid); ++ ++ config_write_partly(NULL, vars); ++ } ++ ++ send_nicks_destroy(); ++ config_write_upgrade(); ++ children_destroy(); ++ watches_destroy(); ++ ++ ekg_destroy_common(); ++ ++ mesg_set(mesg_startup); ++ ++ /* XXX, execl() with /bin/sh ? */ ++ if (config_profile) ++ execlp(argv0, argv0, "-r", "-u", config_profile, NULL); ++ else ++ execlp(argv0, argv0, "-r", NULL); ++ ++ /* XXX, call main() ? */ ++ ++ printf("ekg_upgrade() failed!\n"); ++ exit(1); ++} ++ + /* + * ekg_exit() + * +@@ -1036,16 +1202,10 @@ + void ekg_exit() + { + char *exit_exec = config_exit_exec; +- extern int ekg2_dlclose(void *plugin); +- int i; + + msg_queue_write(); ++ lastsearch_destroy(); + +- xfree(last_search_first_name); +- xfree(last_search_last_name); +- xfree(last_search_nickname); +- xfree(last_search_uid); +- + windows_save(); + + /* setting windows layout */ +@@ -1062,51 +1222,19 @@ + config_write_partly(NULL, vars); + } + +- for (i = 0; i < SEND_NICKS_MAX; i++) { +- xfree(send_nicks[i]); +- send_nicks[i] = NULL; +- } +- send_nicks_count = 0; ++ send_nicks_destroy(); + + { + child_t *c; + +- for (c = children; c; c = c->next) { +-#ifndef NO_POSIX_SYSTEM ++ for (c = children; c; c = c->next) + kill(c->pid, SIGTERM); +-#else +- /* TerminateProcess / TerminateThread */ +-#endif +- } + children_destroy(); + } + +- { +- list_t l; ++ watches_destroy(); ++ plugins_destroy(PLUGIN_UI); + +- for (l = watches; l; l = l->next) { +- watch_t *w = l->data; +- +- watch_free(w); +- } +- } +- +- { +- plugin_t *p, *next; +- +- for (p = plugins; p; p = next) { +- next = p->next; +- +- if (p->pclass != PLUGIN_UI) +- continue; +- +- p->destroy(); +- +-// if (p->dl) ekg2_dlclose(p->dl); +- } +- } +- list_destroy(watches, 0); watches = NULL; +- + if (config_changed && !config_speech_app && config_save_quit == 1) { + char line[80]; + +@@ -1146,78 +1274,9 @@ + } + config_exit_exec = NULL; /* avoid freeing it */ + +-/* XXX, think about sequence of unloading. */ ++ ekg_destroy_common(); + +- msgs_queue_destroy(); +- conferences_destroy(); +- newconferences_destroy(); +- metacontacts_destroy(); +- sessions_free(); +- +- { +- plugin_t *p; +- +- for (p = plugins; p; ) { +- plugin_t *next = p->next; +- +- p->destroy(); +- +-// if (p->dl) ekg2_dlclose(p->dl); +- +- p = next; +- } +- } +- +- audio_deinitialize(); +- aliases_destroy(); +- theme_free(); +- variables_destroy(); +- script_variables_free(1); +- emoticons_destroy(); +- commands_destroy(); +- timers_destroy(); +- binding_free(); +- lasts_destroy(); +- +- buffer_free(&buffer_debug); buffer_free(&buffer_speech); +- event_free(); +- +- xfree(read_file(NULL, -1)); /* free internal read_file() buffer */ +- +-/* windows: */ +- windows_destroy(); +- window_status = NULL; window_debug = NULL; window_current = NULL; /* just in case */ +- +-/* queries: */ +- { +- query_t **ll; +- +- for (ll = queries; ll <= &queries[QUERY_EXTERNAL]; ll++) { +- query_t *q; +- +- for (q = *ll; q; ) { /* free other queries... connected by protocol_init() for example */ +- query_t *next = q->next; +- +- query_free(q); +- +- q = next; +- } +- +- LIST_DESTROY2(*ll, NULL); /* XXX: really needed? */ +- } +- } +- query_external_free(); +- +- xfree(home_dir); +- +- xfree(config_dir); +- xfree(console_charset); +- + mesg_set(mesg_startup); +-#ifdef NO_POSIX_SYSTEM +- WSACleanup(); +-#endif +- close(stderr_backup); + + if (exit_exec) { + #ifndef NO_POSIX_SYSTEM +Index: ekg/configfile.h +=================================================================== +--- ekg/configfile.h (wersja 4609) ++++ ekg/configfile.h (kopia robocza) +@@ -28,13 +28,14 @@ + + #include "plugins.h" + +-void config_postread(); ++void config_postread(int restoring); + int config_read(const char *filename); +-int config_read_plugins(); ++int config_read_plugins(const char *filename); + int config_read_later(const char *filename); + int config_write(); + int config_write_partly(plugin_t *plugin, const char **vars); + void config_write_crash(); ++int config_write_upgrade(); + void debug_write_crash(); + + #endif +Index: ekg/stuff.h +=================================================================== +--- ekg/stuff.h (wersja 4609) ++++ ekg/stuff.h (kopia robocza) +@@ -408,6 +408,7 @@ + + /* funkcje poza stuff.c */ + void ekg_exit(); ++void ekg_upgrade(); + void ekg_debug_handler(int level, const char *format, va_list ap); + + int ekg_close(int fd); +Index: plugins/ncurses/main.c +=================================================================== +--- plugins/ncurses/main.c (wersja 4608) ++++ plugins/ncurses/main.c (kopia robocza) +@@ -20,9 +20,11 @@ + + #include "ekg2-config.h" + ++#include /* sscanf() */ + #include + #include + #include ++#include /* getpid() */ + #include + + #include +@@ -494,6 +496,182 @@ + return retval; + } + ++/* XXX, unicode-not-ok. XXX: SPOT logs also, copy to core */ ++static char *fstring_reverse(fstring_t *fstr) { ++ const char *str; ++ const short *attr; ++ string_t asc; ++ int i; ++ ++ if (!fstr) ++ return NULL; ++ ++ attr = fstr->attr; ++ str = fstr->str.b; ++ ++ if (!attr || !str) ++ return NULL; ++ ++ asc = string_init(NULL); ++ ++ for (i = 0; str[i]; i++) { ++#define prev attr[i-1] ++#define cur attr[i] ++ int reset = 0; ++ ++ if (i) { ++ if (!(cur & FSTR_BOLD) && (prev & FSTR_BOLD)) reset = 1; ++ if (!(cur & FSTR_BLINK) && (prev & FSTR_BLINK)) reset = 1; ++ if (!(cur & FSTR_UNDERLINE) && (prev & FSTR_UNDERLINE)) reset = 1; ++ if (!(cur & FSTR_REVERSE) && (prev & FSTR_REVERSE)) reset = 1; ++ if ((cur & FSTR_NORMAL) && !(prev & FSTR_NORMAL)) reset = 1; /* colors disappear */ ++ ++ if (reset) ++ string_append(asc, "%n"); ++ } else ++ reset = 1; ++ ++ /* attr */ ++ if ((cur & FSTR_BLINK) && (reset || !(prev & FSTR_BLINK))) string_append(asc, "%i"); ++// if ((cur & FSTR_UNDERLINE) && (reset || !(prev & FSTR_UNDERLINE))) string_append(asc, "%"); ++// if ((cur & FSTR_REVERSE) && (reset || !(prev & FSTR_REVERSE))) string_append(asc, "%"); ++ ++ if (!(cur & FSTR_NORMAL)) { ++ /* background color XXX */ ++#define BGCOLOR(x) -1 ++ if (0 && ((reset || BGCOLOR(cur) != BGCOLOR(prev)))) { ++ string_append_c(asc, '%'); ++ switch (BGCOLOR(cur)) { ++ case (0): string_append_c(asc, 'l'); break; ++ case (1): string_append_c(asc, 's'); break; ++ case (2): string_append_c(asc, 'h'); break; ++ case (3): string_append_c(asc, 'z'); break; ++ case (4): string_append_c(asc, 'e'); break; ++ case (5): string_append_c(asc, 'q'); break; ++ case (6): string_append_c(asc, 'd'); break; ++ case (7): string_append_c(asc, 'x'); break; ++ } ++ } ++#undef BGCOLOR ++ ++ /* foreground color */ ++#define FGCOLOR(x) ((!(x & FSTR_NORMAL)) ? (x & FSTR_FOREMASK) : -1) ++ if (((reset || FGCOLOR(cur) != FGCOLOR(prev)) || (i && (prev & FSTR_BOLD) != (cur & FSTR_BOLD)))) { ++ string_append_c(asc, '%'); ++ switch ((cur & FSTR_FOREMASK)) { ++ case (0): string_append_c(asc, (cur & FSTR_BOLD) ? 'K' : 'k'); break; ++ case (1): string_append_c(asc, (cur & FSTR_BOLD) ? 'R' : 'r'); break; ++ case (2): string_append_c(asc, (cur & FSTR_BOLD) ? 'G' : 'g'); break; ++ case (3): string_append_c(asc, (cur & FSTR_BOLD) ? 'Y' : 'y'); break; ++ case (4): string_append_c(asc, (cur & FSTR_BOLD) ? 'B' : 'b'); break; ++ case (5): string_append_c(asc, (cur & FSTR_BOLD) ? 'M' : 'm'); break; /* | fioletowy | %m/%p | %M/%P | %q | */ ++ case (6): string_append_c(asc, (cur & FSTR_BOLD) ? 'C' : 'c'); break; ++ case (7): string_append_c(asc, (cur & FSTR_BOLD) ? 'W' : 'w'); break; ++ } ++ } ++#undef FGCOLOR ++ } else { /* no color */ ++ if ((cur & FSTR_BOLD) && (reset || !(prev & FSTR_BOLD))) ++ string_append(asc, "%T"); ++ } ++ ++ /* str */ ++ if (str[i] == '%' || str[i] == '\\') ++ string_append_c(asc, '\\'); ++ string_append_c(asc, str[i]); ++ } ++ ++/* reset, and return. */ ++ string_append(asc, "%n"); ++ return string_free(asc, 0); ++ ++#undef prev ++#undef cur ++} ++ ++static QUERY(ncurses_upgrade) { ++ const char *path; ++ FILE *f; ++ ++ window_t *wl; ++ ++#ifdef USE_UNICODE ++ return 1; ++#endif ++ ++ if (!(path = prepare_pathf("upgrade-ncurses.%d", getpid()))) ++ return 1; ++ ++ if (!(f = fopen(path, "w"))) ++ return 1; ++ ++ for (wl = windows; wl; wl = wl->next) { ++ ncurses_window_t *n = wl->private; ++ int i; ++ ++ if (!n) ++ continue; ++ ++ fprintf(f, "[window-dump-%d]\n", wl->id); ++ ++ for (i = n->backlog_size; i; i--) { ++ fstring_t *backlog = n->backlog[i-1]; ++ char *tmp; ++ ++ tmp = fstring_reverse(n->backlog[i-1]); ++ fprintf(f, "%ld %s\n", backlog->ts, tmp); ++ xfree(tmp); ++ } ++ } ++ ++ fclose(f); ++ return 0; ++} ++ ++static QUERY(ncurses_restore) { ++ ++ const char *path; ++ char *buf; ++ FILE *f; ++ ++ window_t *wl = NULL; ++ ++ if (!(path = prepare_pathf("upgrade-ncurses.%d", getpid()))) ++ return 1; ++ ++ if (!(f = fopen(path, "r"))) ++ return 1; ++ ++ while ((buf = read_file(f, 0))) { ++ fstring_t *fstr; ++ time_t ts; ++ int id; ++ ++ if (sscanf(buf, "[window-dump-%d]", &id) == 1) { ++ wl = window_exist(id); ++ continue; ++ } ++ ++ if (!wl) ++ continue; ++ ++ wl->lock++; ++ /* assuming file is correct! */ ++ ++ ts = strtol(buf, &buf, 10); ++ buf++; ++ fstr = fstring_new_format(buf); ++ fstr->ts = ts; ++ query_emit_id(&ncurses_plugin, UI_WINDOW_PRINT, &wl, &fstr); ++ ++ wl->lock--; ++ } ++ query_emit_id(NULL, UI_WINDOW_REFRESH); ++ ++ fclose(f); ++ return 0; ++} ++ + static QUERY(ncurses_setvar_default) + { + config_contacts_size = 9; /* szerokość okna kontaktów */ +@@ -689,6 +867,8 @@ + + query_connect_id(&ncurses_plugin, CONFIG_POSTINIT, ncurses_postinit, NULL); + query_connect_id(&ncurses_plugin, PROTOCOL_DISCONNECTING, ncurses_session_disconnect_handler, NULL); ++ query_connect_id(&ncurses_plugin, EKG_UPGRADE, ncurses_upgrade, NULL); ++ query_connect_id(&ncurses_plugin, EKG_RESTORE, ncurses_restore, NULL); + + /* redraw userlisty: */ + /* podanie czegokolwiek jako data do ncurses_all_contacts_changed() powoduje wyzerowanie n->start */ From svn w toxygen.net Tue Sep 9 22:13:54 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 9 Sep 2008 22:13:54 +0200 (CEST) Subject: [ekg2-commit] r4614 - trunk/plugins/gg: trunk/plugins/gg/commands.c Message-ID: <20080909201354.754FA17B1F@toxygen.net> Author: darkjames Date: 2008-09-09 22:13:53 +0200 (Tue, 09 Sep 2008) New Revision: 4614 Modified: trunk/plugins/gg/commands.c Log: fix double free (wrkq) Modified: trunk/plugins/gg/commands.c =================================================================== --- trunk/plugins/gg/commands.c 2008-09-09 15:25:52 UTC (rev 4613) +++ trunk/plugins/gg/commands.c 2008-09-09 20:13:53 UTC (rev 4614) @@ -399,7 +399,7 @@ } if (params0) { - char *tmp = ekg_locale_to_cp(params0); + char *tmp = ekg_locale_to_cp(xstrdup(params0)); if (xstrlen(tmp) > GG_STATUS_DESCR_MAXSIZE && config_reason_limit) { if (!timeout) { char *descr_poss = xstrndup(params0, GG_STATUS_DESCR_MAXSIZE); From svn w toxygen.net Wed Sep 10 00:07:20 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 10 Sep 2008 00:07:20 +0200 (CEST) Subject: [ekg2-commit] r4615 - trunk/plugins/feed: trunk/plugins/feed/rss.c Message-ID: <20080909220720.B899417B1F@toxygen.net> Author: darkjames Date: 2008-09-10 00:07:20 +0200 (Wed, 10 Sep 2008) New Revision: 4615 Modified: trunk/plugins/feed/rss.c Log: rewrite rss to dynstuff-inline. Modified: trunk/plugins/feed/rss.c =================================================================== --- trunk/plugins/feed/rss.c 2008-09-09 20:13:53 UTC (rev 4614) +++ trunk/plugins/feed/rss.c 2008-09-09 22:07:20 UTC (rev 4615) @@ -48,6 +48,7 @@ #include #include +#include #include #ifdef HAVE_EXPAT_H @@ -70,7 +71,9 @@ RSS_PROTO_EXEC, } rss_proto_t; -typedef struct { +typedef struct rss_item_list { + struct rss_item_list *next; + char *session; int new; /* is new? */ @@ -88,7 +91,9 @@ */ } rss_item_t; -typedef struct { +typedef struct rss_channel_list { + struct rss_channel_list *next; + char *session; int new; /* is new? */ @@ -101,10 +106,12 @@ char *lang; /* lang */ int hash_lang; /* ekg_hash of lang */ - list_t rss_items; /* list of channel items, rss_item_t struct */ + struct rss_item_list *rss_items; /* list of channel items */ } rss_channel_t; -typedef struct { +typedef struct rss_feed_list { + struct rss_feed_list *next; + char *session; char *url; /* url */ @@ -115,7 +122,7 @@ int getting; /* we wait for read() ? */ int headers_done; - list_t rss_channels; + struct rss_channel_list *rss_channels; /* XXX headers_* */ string_t headers; /* headers */ @@ -128,8 +135,54 @@ char *file; /* protos: j/w RSS_PROTO_FILE file */ } rss_feed_t; -static list_t feeds; /* list of feeds, rss_feed_t struct */ +static LIST_FREE_ITEM(rss_item_free_item, rss_item_t *) { + xfree(data->session); + xfree(data->url); + xfree(data->title); + xfree(data->descr); +} +DYNSTUFF_LIST_DECLARE_WC(rss_items, rss_item_t, rss_item_free_item, + static __DYNSTUFF_ADD, /* rss_items_add() */ + __DYNSTUFF_NOREMOVE, + static __DYNSTUFF_DESTROY, /* rss_items_destroy() */ + static __DYNSTUFF_COUNT) /* rss_items_count() */ + +static LIST_FREE_ITEM(rss_channel_free_item, rss_channel_t *) { + xfree(data->session); + xfree(data->url); + xfree(data->title); + xfree(data->descr); + xfree(data->lang); + rss_items_destroy(&data->rss_items); +} + +DYNSTUFF_LIST_DECLARE_WC(rss_channels, rss_channel_t, rss_channel_free_item, + static __DYNSTUFF_ADD, /* rss_channels_add() */ + __DYNSTUFF_NOREMOVE, + static __DYNSTUFF_DESTROY, /* rss_channels_destroy() */ + static __DYNSTUFF_COUNT) /* rss_channels_count() */ + +static rss_feed_t *feeds; + +static LIST_FREE_ITEM(feeds_free_item, rss_feed_t *) { + xfree(data->session); + xfree(data->url); + xfree(data->uid); + rss_channels_destroy(&data->rss_channels); + string_free(data->buf, 1); + string_free(data->headers, 1); + xfree(data->host); + xfree(data->ip); + xfree(data->file); +} + +DYNSTUFF_LIST_DECLARE(feeds, rss_feed_t, feeds_free_item, + static __DYNSTUFF_LIST_ADD, /* feeds_add() */ + __DYNSTUFF_NOREMOVE, + static __DYNSTUFF_LIST_DESTROY) /* feeds_destroy() */ + + static void rss_string_append(rss_feed_t *f, const char *str) { string_t buf = f->buf; @@ -172,11 +225,11 @@ int hash_title = title ? ekg_hash(title) : 0; int hash_descr = descr ? ekg_hash(descr) : 0; - list_t l; + struct rss_item_list *l; rss_item_t *item; for (l = c->rss_items; l; l = l->next) { - item = l->data; + item = l; if (item->hash_url != hash_url || xstrcmp(url, item->url)) continue; if (session_int_get(s, "item_enable_title_checking") == 1 && (item->hash_title != hash_title || xstrcmp(title, item->title))) continue; @@ -196,7 +249,7 @@ item->other_tags= string_init(NULL); item->new = 1; - list_add(&(c->rss_items), item); + rss_items_add(&(c->rss_items), item); return item; } @@ -208,11 +261,11 @@ int hash_descr = descr ? ekg_hash(descr) : 0; int hash_lang = lang ? ekg_hash(lang) : 0; - list_t l; + struct rss_channel_list *l; rss_channel_t *channel; for (l = f->rss_channels; l; l = l->next) { - channel = l->data; + channel = l; if (channel->hash_url != hash_url || xstrcmp(url, channel->url)) continue; if (session_int_get(s, "channel_enable_title_checking") == 1 && (channel->hash_title != hash_title || xstrcmp(title, channel->title))) continue; @@ -235,19 +288,18 @@ channel->new = 1; - list_add(&(f->rss_channels), channel); + rss_channels_add(&(f->rss_channels), channel); return channel; } static rss_feed_t *rss_feed_find(session_t *s, const char *url) { - list_t newsgroups = feeds; - list_t l; + struct rss_feed_list *l; rss_feed_t *feed; if (!xstrncmp(url, "rss:", 4)) url += 4; - for (l = newsgroups; l; l = l->next) { - feed = l->data; + for (l = feeds; l; l = l->next) { + feed = l; if (!xstrcmp(feed->url, url)) return feed; @@ -299,7 +351,7 @@ debug_white("[rss] proto: %d url: %s port: %d url: %s file: %s\n", feed->proto, feed->url, feed->port, feed->url, feed->file); - list_add(&(feeds), feed); + feeds_add(feed); return feed; } @@ -520,7 +572,7 @@ static void rss_parsexml_rdf(rss_feed_t *f, xmlnode_t *node) { rss_channel_t *chan; - debug("rss_parsexml_rdf (channels oldcount: %d)\n", list_count(f->rss_channels)); + debug("rss_parsexml_rdf (channels oldcount: %d)\n", rss_channels_count(f->rss_channels)); debug_error("XXX http://web.resource.org/rss/1.0/"); chan = rss_channel_find(f, /* chanlink, chantitle, chandescr, chanlang */ "", "", "", ""); @@ -565,7 +617,7 @@ } static void rss_parsexml_rss(rss_feed_t *f, xmlnode_t *node) { - debug("rss_parsexml_rss (channels oldcount: %d)\n", list_count(f->rss_channels)); + debug("rss_parsexml_rss (channels oldcount: %d)\n", rss_channels_count(f->rss_channels)); for (; node; node = node->next) { if (!xstrcmp(node->name, "channel")) { @@ -587,7 +639,7 @@ } chan = rss_channel_find(f, chanlink, chantitle, chandescr, chanlang); - debug("rss_parsexml_rss (items oldcount: %d)\n", list_count(chan->rss_items)); + debug("rss_parsexml_rss (items oldcount: %d)\n", rss_items_count(chan->rss_items)); for (subnode = node->children; subnode; subnode = subnode->next) { if (!xstrcmp(subnode->name, "item")) { @@ -639,7 +691,7 @@ static void rss_fetch_process(rss_feed_t *f, const char *str) { int new_items = 0; - list_t l; + struct rss_channel_list *l; rss_fetch_process_t *priv = xmalloc(sizeof(rss_fetch_process_t)); xmlnode_t *node; @@ -673,11 +725,11 @@ } for (l = f->rss_channels; l; l = l->next) { - rss_channel_t *channel = l->data; - list_t k; + rss_channel_t *channel = l; + struct rss_item_list *k; for (k = channel->rss_items; k; k = k->next) { - rss_item_t *item = k->data; + rss_item_t *item = k; char *proto_headers = f->headers->len ? f->headers->str : NULL; char *headers = item->other_tags->len ? item->other_tags->str : NULL; int modify = 0; /* XXX */ @@ -1043,52 +1095,7 @@ } void rss_deinit() { - list_t l; - for (l = feeds; l; l = l->next) { - list_t k; - rss_feed_t *f = l->data; - - xfree(f->session); - xfree(f->url); - xfree(f->uid); - - for (k = f->rss_channels; k; k = k->next) { - rss_channel_t *channel = k->data; - list_t j; - - xfree(channel->session); - xfree(channel->url); - xfree(channel->title); - xfree(channel->descr); - xfree(channel->lang); - - for (j = channel->rss_items; j; j = j->next) { - rss_item_t *item = j->data; - - xfree(item->session); - xfree(item->url); - xfree(item->title); - xfree(item->descr); - - xfree(item); - j->data = NULL; - } - list_destroy(channel->rss_items, 0); - xfree(channel); - k->data = NULL; - } - list_destroy(f->rss_channels, 0); - - string_free(f->buf, 1); - string_free(f->headers, 1); - xfree(f->host); - xfree(f->ip); - xfree(f->file); - xfree(f); - - l->data = NULL; - } - list_destroy(feeds, 0); + feeds_destroy(); } void rss_init() { From svn w toxygen.net Wed Sep 10 00:25:14 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 10 Sep 2008 00:25:14 +0200 (CEST) Subject: [ekg2-commit] r4616 - trunk/plugins/feed: trunk/plugins/feed/feed.c trunk/plugins/feed/rss.c Message-ID: <20080909222514.5843817B1F@toxygen.net> Author: darkjames Date: 2008-09-10 00:25:13 +0200 (Wed, 10 Sep 2008) New Revision: 4616 Modified: trunk/plugins/feed/feed.c trunk/plugins/feed/rss.c Log: give more info when /list performed. Modified: trunk/plugins/feed/feed.c =================================================================== --- trunk/plugins/feed/feed.c 2008-09-09 22:07:20 UTC (rev 4615) +++ trunk/plugins/feed/feed.c 2008-09-09 22:25:13 UTC (rev 4616) @@ -354,6 +354,14 @@ static int feed_theme_init() { #ifndef NO_DEFAULT_THEME + /* url - %1; title - %2; descr - %3; lang: %4 */ + format_add("rss_user_info_channel_unread", _("%K| %g[unread]%n %2 (%1)"), 1); + format_add("rss_user_info_channel_read", _("%K| %R[read]%n %2 (%1)"), 1); + + /* same, but without lang (%4) */ + format_add("rss_user_info_item_unread", _("%K| %g[unread]%n %2 (%1)"), 1); + format_add("rss_user_info_item_read", _("%K| %R[read]%n %2 (%1)"), 1); + format_add("feed_status", _("%> Newstatus: %1 (%2) %3"), 1); /* XXX */ format_add("feed_added", _("%> (%2) Added %T%1%n to subscription\n"), 1); Modified: trunk/plugins/feed/rss.c =================================================================== --- trunk/plugins/feed/rss.c 2008-09-09 22:07:20 UTC (rev 4615) +++ trunk/plugins/feed/rss.c 2008-09-09 22:25:13 UTC (rev 4616) @@ -1098,6 +1098,38 @@ feeds_destroy(); } +static QUERY(rss_userlist_info) { + userlist_t *u = *va_arg(ap, userlist_t **); + int quiet = *va_arg(ap, int *); + + rss_feed_t *feed; + + if (!u || valid_plugin_uid(&feed_plugin, u->uid) != 1 || u->uid[0] != 'r') + return 1; + + for (feed = feeds; feed; feed = feed->next) { + if (!xstrcmp(feed->uid, u->uid)) { + rss_channel_t *chan; + + for (chan = feed->rss_channels; chan; chan = chan->next) { + rss_item_t *item; + + printq(chan->new ? "rss_user_info_channel_unread" : "rss_user_info_channel_read", + chan->url, chan->title, chan->descr, chan->lang); + + for (item = chan->rss_items; item; item = item->next) { + printq(item->new ? "rss_user_info_item_unread" : "rss_user_info_item_read", + item->url, item->title, item->descr); + + } + } + return 0; + } + } + + return 1; +} + void rss_init() { command_add(&feed_plugin, ("rss:connect"), "?", rss_command_connect, RSS_ONLY, NULL); command_add(&feed_plugin, ("rss:check"), "u", rss_command_check, RSS_FLAGS, NULL); @@ -1105,6 +1137,8 @@ command_add(&feed_plugin, ("rss:subscribe"), "! ?", rss_command_subscribe, RSS_FLAGS_TARGET, NULL); command_add(&feed_plugin, ("rss:unsubscribe"), "!u",rss_command_unsubscribe, RSS_FLAGS_TARGET, NULL); + + query_connect_id(&feed_plugin, USERLIST_INFO, rss_userlist_info, NULL); } #endif From svn w toxygen.net Wed Sep 10 01:02:56 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 10 Sep 2008 01:02:56 +0200 (CEST) Subject: [ekg2-commit] r4617 - trunk/plugins/feed: trunk/plugins/feed/feed.c trunk/plugins/feed/rss.c Message-ID: <20080909230256.BBEC317B1F@toxygen.net> Author: darkjames Date: 2008-09-10 01:02:56 +0200 (Wed, 10 Sep 2008) New Revision: 4617 Modified: trunk/plugins/feed/feed.c trunk/plugins/feed/rss.c Log: - implement /rss:show - increase priority of rss-messages: from EKG_WINACT_MSG to EKG_WINACT_IMPORTANT (dmilith request) Modified: trunk/plugins/feed/feed.c =================================================================== --- trunk/plugins/feed/feed.c 2008-09-09 22:25:13 UTC (rev 4616) +++ trunk/plugins/feed/feed.c 2008-09-09 23:02:56 UTC (rev 4617) @@ -99,6 +99,9 @@ return 0; } +// #define EKG_WINACT_RSS EKG_WINACT_MSG // till 4616 +#define EKG_WINACT_RSS EKG_WINACT_IMPORTANT + /* new: * 0x0 - old * 0x1 - new @@ -120,7 +123,7 @@ char *body = *(va_arg(ap, char **)); int *new = va_arg(ap, int *); /* 0 - old; 1 - new; 2 - modified */ - int UNUSED(mtags) = *(va_arg(ap, int *)); + int mtags = *(va_arg(ap, int *)); session_t *s = session_find(session); char *tmp; @@ -133,8 +136,11 @@ char *target = NULL; window_t *targetwnd = NULL; - if (*new == 0) return 0; + if (*new == 0 && !mtags) return 0; + if (mtags) /* XXX */ + dmode = mtags; + switch (mw) { /* XXX, __current ? */ case 0: target = "__status"; @@ -158,7 +164,7 @@ debug_white("%x\n", targetwnd); switch (dmode) { - case 0: print_window_w(targetwnd, EKG_WINACT_MSG, "feed_message_new", title, url); /* only notify */ + case 0: print_window_w(targetwnd, EKG_WINACT_RSS, "feed_message_new", title, url); /* only notify */ case -1: return 0; /* do nothing */ case 2: body = NULL; /* only headers */ @@ -168,7 +174,7 @@ case 4: break; /* shreaders+headers+body */ } - print_window_w(targetwnd, EKG_WINACT_MSG, "feed_message_header", title, url); + print_window_w(targetwnd, EKG_WINACT_RSS, "feed_message_header", title, url); if (sheaders) { char *str = xstrdup(sheaders); @@ -187,11 +193,11 @@ if (!format_exists(formatka)) { xfree(formatka); formatka = NULL; } formated = format_string(format_find(formatka ? formatka : "feed_server_header_generic"), tmp, value ? value+1 : ""); - print_window_w(targetwnd, EKG_WINACT_MSG, "feed_message_body", formated ? formated : tmp); + print_window_w(targetwnd, EKG_WINACT_RSS, "feed_message_body", formated ? formated : tmp); xfree(formatka); } - if (headers || body) print_window_w(targetwnd, EKG_WINACT_MSG, "feed_message_body", ""); /* rozdziel */ + if (headers || body) print_window_w(targetwnd, EKG_WINACT_RSS, "feed_message_body", ""); /* rozdziel */ } if (headers) { char *str, *org; @@ -213,12 +219,12 @@ if (!format_exists(formatka)) { xfree(formatka); formatka = NULL; } formated = format_string(format_find(formatka ? formatka : "feed_message_header_generic"), tmp, value ? value+1 : ""); - print_window_w(targetwnd, EKG_WINACT_MSG, "feed_message_body", formated ? formated : tmp); + print_window_w(targetwnd, EKG_WINACT_RSS, "feed_message_body", formated ? formated : tmp); xfree(formated); xfree(formatka); } - if (body) print_window_w(targetwnd, EKG_WINACT_MSG, "feed_message_body", ""); /* rozdziel */ + if (body) print_window_w(targetwnd, EKG_WINACT_RSS, "feed_message_body", ""); /* rozdziel */ xfree(org); } if (body) { @@ -255,16 +261,16 @@ formated = format_string(f, tmp); } - print_window_w(targetwnd, EKG_WINACT_MSG, "feed_message_body", formated ? formated : tmp); + print_window_w(targetwnd, EKG_WINACT_RSS, "feed_message_body", formated ? formated : tmp); xfree(formated); } xfree(org); } else { - print_window_w(targetwnd, EKG_WINACT_MSG, "feed_message_body", body); + print_window_w(targetwnd, EKG_WINACT_RSS, "feed_message_body", body); } } - print_window_w(targetwnd, EKG_WINACT_MSG, "feed_message_footer"); + print_window_w(targetwnd, EKG_WINACT_RSS, "feed_message_footer"); *new = 0; return 0; Modified: trunk/plugins/feed/rss.c =================================================================== --- trunk/plugins/feed/rss.c 2008-09-09 22:25:13 UTC (rev 4616) +++ trunk/plugins/feed/rss.c 2008-09-09 23:02:56 UTC (rev 4617) @@ -1023,6 +1023,36 @@ return rss_url_fetch(rss_feed_find(session, target), quiet); } +static COMMAND(rss_command_show) { + rss_feed_t *feed; + + for (feed = feeds; feed; feed = feed->next) { + /* if (!xstrcmp(feed->uid, XXX)); */ + rss_channel_t *chan; + + for (chan = feed->rss_channels; chan; chan = chan->next) { + rss_item_t *item; + /* if (!xstrcmp(chan->url, XXX)); */ + + for (item = chan->rss_items; item; item = item->next) { + + if (!xstrcmp(item->url, params[0])) { + char *proto_headers = feed->headers->len ? feed->headers->str : NULL; + char *headers = item->other_tags->len ? item->other_tags->str : NULL; + int modify = 0x04; /* XXX */ + + query_emit_id(NULL, RSS_MESSAGE, + &(feed->session), &(feed->uid), &proto_headers, &headers, &(item->title), + &(item->url), &(item->descr), &(item->new), &modify); + } + + } + } + } + + return 0; +} + static COMMAND(rss_command_connect) { if (session_connected_get(session)) { printq("already_connected", session_name(session)); @@ -1135,6 +1165,8 @@ command_add(&feed_plugin, ("rss:check"), "u", rss_command_check, RSS_FLAGS, NULL); command_add(&feed_plugin, ("rss:get"), "!u", rss_command_get, RSS_FLAGS_TARGET, NULL); + command_add(&feed_plugin, ("rss:show"), "!", rss_command_show, RSS_FLAGS | COMMAND_ENABLEREQPARAMS, NULL); + command_add(&feed_plugin, ("rss:subscribe"), "! ?", rss_command_subscribe, RSS_FLAGS_TARGET, NULL); command_add(&feed_plugin, ("rss:unsubscribe"), "!u",rss_command_unsubscribe, RSS_FLAGS_TARGET, NULL); From svn w toxygen.net Wed Sep 10 01:30:26 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 10 Sep 2008 01:30:26 +0200 (CEST) Subject: [ekg2-commit] r4618 - trunk/plugins/logs: trunk/plugins/logs/main.c Message-ID: <20080909233026.E6FE817B1F@toxygen.net> Author: darkjames Date: 2008-09-10 01:30:26 +0200 (Wed, 10 Sep 2008) New Revision: 4618 Modified: trunk/plugins/logs/main.c Log: logs:log_raw stuff should fail, when we can have problems restoring/saving data (becuase we don't sanity path, and we have '/' char somewhere) Modified: trunk/plugins/logs/main.c =================================================================== --- trunk/plugins/logs/main.c 2008-09-09 23:02:56 UTC (rev 4617) +++ trunk/plugins/logs/main.c 2008-09-09 23:30:26 UTC (rev 4618) @@ -488,7 +488,6 @@ /* i'm weird, let's search for logs/__internal__ than check if there are smth after it... & check if there are two '/' */ if ((beg = xstrstr(file, "logs/__internal__")) && xstrlen(beg) > 19 && xstrchr(beg+18, '/') && xstrchr(beg+18, '/') != xstrrchr(beg+18, '/')) { profile = beg + 18; - /* XXX, if profile || sesion hasgot '/' we are in trouble */ sesja = xstrchr(profile, '/')+1; target = xstrchr(sesja, '/')+1; } @@ -1094,6 +1093,13 @@ if (!config_logs_log_raw) return 0; if (!w || !line || w->id == 0) return 0; /* don't log debug window */ + /* if profile || sesion hasgot '/' we are in trouble */ + /* XXX, what about changing / to somethink different? */ + if (xstrchr(config_profile, '/') || xstrchr(session_uid_get(w->session), '/') || xstrchr(get_uid(w->session, window_target(w)), '/')) { + debug_error("logs_handler_raw() %s %s %s cannot be saved\n", config_profile, session_uid_get(w->session), get_uid(w->session, window_target(w))); + return 0; + } + /* line->str + line->attr == ascii str with formats */ path = logs_prepare_path(w->id != 1 ? w->session : NULL, "~/.ekg2/logs/__internal__/%P/%S/%u", window_target(w), 0); str = fstring_reverse(line); @@ -1117,6 +1123,14 @@ char *line; char *path; + /* if profile || sesion hasgot '/' we are in trouble */ + /* XXX, what about changing / to somethink different? */ + + if (xstrchr(config_profile, '/') || xstrchr(session_uid_get(w->session), '/') || xstrchr(get_uid(w->session, window_target(w)), '/')) { + debug_error("logs_handler_newwin() %s %s %s cannot be restored\n", config_profile, session_uid_get(w->session), get_uid(w->session, window_target(w))); + return 0; + } + path = logs_prepare_path(w->id != 1 ? w->session : NULL, "~/.ekg2/logs/__internal__/%P/%S/%u", window_target(w), 0 /* time(NULL) */ ); debug("logs_handler_newwin() loading buffer from: %s\n", __(path)); From svn w toxygen.net Wed Sep 10 11:44:12 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 10 Sep 2008 11:44:12 +0200 (CEST) Subject: [ekg2-commit] r4619 - trunk/plugins/feed: trunk/plugins/feed/feed.c Message-ID: <20080910094412.1F55B17B1F@toxygen.net> Author: darkjames Date: 2008-09-10 11:44:11 +0200 (Wed, 10 Sep 2008) New Revision: 4619 Modified: trunk/plugins/feed/feed.c Log: useless debug. Modified: trunk/plugins/feed/feed.c =================================================================== --- trunk/plugins/feed/feed.c 2008-09-09 23:30:26 UTC (rev 4618) +++ trunk/plugins/feed/feed.c 2008-09-10 09:44:11 UTC (rev 4619) @@ -156,13 +156,9 @@ break; } - debug_white("[feed] window_new(%s, %s [%x]) == ", target, session, s); - if (mw) targetwnd = window_new(target, s, 0); - debug_white("%x\n", targetwnd); - switch (dmode) { case 0: print_window_w(targetwnd, EKG_WINACT_RSS, "feed_message_new", title, url); /* only notify */ case -1: return 0; /* do nothing */ From svn w toxygen.net Wed Sep 10 12:41:56 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 10 Sep 2008 12:41:56 +0200 (CEST) Subject: [ekg2-commit] r4620 - trunk/plugins/feed: trunk/plugins/feed/rss.c Message-ID: <20080910104156.5E65917B1F@toxygen.net> Author: darkjames Date: 2008-09-10 12:41:55 +0200 (Wed, 10 Sep 2008) New Revision: 4620 Modified: trunk/plugins/feed/rss.c Log: Modified: trunk/plugins/feed/rss.c =================================================================== --- trunk/plugins/feed/rss.c 2008-09-10 09:44:11 UTC (rev 4619) +++ trunk/plugins/feed/rss.c 2008-09-10 10:41:55 UTC (rev 4620) @@ -456,13 +456,14 @@ static const char quot[] = { 'q', 'u', 'o', 't', ';' }; static const char nbsp[] = { 'n', 'b', 's', 'p', ';' }; - if (!xstrncmp(&(text[i+1]), lt, sizeof(lt))) { i += sizeof(lt); string_append_c(recode, '<'); continue; } - if (!xstrncmp(&(text[i+1]), gt, sizeof(gt))) { i += sizeof(gt); string_append_c(recode, '>'); continue; } - if (!xstrncmp(&(text[i+1]), amp, sizeof(amp))) { i += sizeof(amp); string_append_c(recode, '&'); continue; } - if (!xstrncmp(&(text[i+1]), quot, sizeof(quot))){ i += sizeof(quot); string_append_c(recode, '"'); continue; } - if (!xstrncmp(&(text[i+1]), nbsp, sizeof(nbsp))){ i += sizeof(nbsp); string_append_c(recode, 0xA0); continue; } + i++; + if (!xstrncmp(&(text[i]), lt, sizeof(lt))) { i += sizeof(lt); string_append_c(recode, '<'); continue; } + if (!xstrncmp(&(text[i]), gt, sizeof(gt))) { i += sizeof(gt); string_append_c(recode, '>'); continue; } + if (!xstrncmp(&(text[i]), amp, sizeof(amp))) { i += sizeof(amp); string_append_c(recode, '&'); continue; } + if (!xstrncmp(&(text[i]), quot, sizeof(quot))) { i += sizeof(quot); string_append_c(recode, '"'); continue; } + if (!xstrncmp(&(text[i]), nbsp, sizeof(nbsp))) { i += sizeof(nbsp); string_append_c(recode, 0xA0); continue; } + i--; - #if 0 if (text[i+1] == '#') { /* khem? */ int j = i + 2; From svn w toxygen.net Fri Sep 12 21:50:22 2008 From: svn w toxygen.net (SVN commit) Date: Fri, 12 Sep 2008 21:50:22 +0200 (CEST) Subject: [ekg2-commit] r4621 - trunk/plugins/icq: trunk/plugins/icq/icq_snac_handlers_03buddy.inc Message-ID: <20080912195022.EEE8317B1F@toxygen.net> Author: wiechu Date: 2008-09-12 21:50:22 +0200 (Fri, 12 Sep 2008) New Revision: 4621 Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc Log: icqmood Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-10 10:41:55 UTC (rev 4620) +++ trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-12 19:50:22 UTC (rev 4621) @@ -337,11 +337,20 @@ /* just some validity check */ if (item_len > t_len) item_len = t_len; - if ((item_type == 2) && (item_flags == 4)) { - /* iChat online message */ - char *tmp; - icq_unpack_nc(t_data, item_len, "U", &tmp); - descr = xstrdup(tmp); + if ((item_type == 0x02) && (item_flags == 4)) { + /* iChat online message */ + char *tmp; + icq_unpack_nc(t_data, item_len, "U", &tmp); + descr = xstrdup(tmp); + } else if ((item_type == 0x0e) && (item_len>7)) { + /* 000E: Custom Status (ICQ6) */ + char *tmp = xstrndup((char *)t_data, item_len); + if ( !xstrncmp(tmp, "icqmood", 7) && xisdigit(*tmp+7) ) { + int xstatus = atoi(tmp+7) + 1; + if (xstatus<=XSTATUS_COUNT) + user_private_item_set_int(u, "xstatus", xstatus); + } + xfree(tmp); } else if (memcmp(t_data, empty_item, (item_len < 0x10) ? item_len : 0x10)) { /* Item types * 0000: AIM mini avatar @@ -351,7 +360,6 @@ * 0009: iTunes music store link * 000C: ICQ contact photo (16 bytes) * 000D: ? - * 000E: Custom Status (ICQ6) */ debug_white("icq_snac_buddy_online() user has got avatar: type: %d flags: %d\n", item_type, item_flags); @@ -417,6 +425,7 @@ user_private_item_set_int(u, "online", 0); user_private_item_set_int(u, "last_ip", user_private_item_get_int(u, "ip")); user_private_item_set_int(u, "ip", 0); + user_private_item_set_int(u, "xstatus", 0); } debug_white("icq_snac_buddy_offline() uid: %s\n", uid); protocol_status_emit(s, uid, EKG_STATUS_NA, descr, time(NULL)); From svn w toxygen.net Sat Sep 13 12:10:00 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 13 Sep 2008 12:10:00 +0200 (CEST) Subject: [ekg2-commit] r4622 - trunk/plugins/icq: trunk/plugins/icq/icq.c trunk/plugins/icq/icq_snac_handlers_03buddy.inc trunk/plugins/icq/icq_snac_handlers_15extension.inc Message-ID: <20080913101000.D553C17B1F@toxygen.net> Author: wiechu Date: 2008-09-13 12:10:00 +0200 (Sat, 13 Sep 2008) New Revision: 4622 Modified: trunk/plugins/icq/icq.c trunk/plugins/icq/icq_snac_handlers_03buddy.inc trunk/plugins/icq/icq_snac_handlers_15extension.inc Log: - new meta information response (draft) - fix icqmood (shame on me) Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-12 19:50:22 UTC (rev 4621) +++ trunk/plugins/icq/icq.c 2008-09-13 10:10:00 UTC (rev 4622) @@ -1423,6 +1423,7 @@ format_add("icq_userinfo_work", "%g|| %n %T%3:%n %4", 1); format_add("icq_userinfo_interests", "%g|| %n %T%3:%n %4", 1); format_add("icq_userinfo_notes", "%g|| %n %T%3:%n %4", 1); + format_add("icq_userinfo_hpagecat", "%g|| %n %T%3:%n %4", 1); format_add("icq_userinfo_end", "%g`+=%G----- End%n", 1); Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-12 19:50:22 UTC (rev 4621) +++ trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-13 10:10:00 UTC (rev 4622) @@ -345,7 +345,7 @@ } else if ((item_type == 0x0e) && (item_len>7)) { /* 000E: Custom Status (ICQ6) */ char *tmp = xstrndup((char *)t_data, item_len); - if ( !xstrncmp(tmp, "icqmood", 7) && xisdigit(*tmp+7) ) { + if ( !xstrncmp(tmp, "icqmood", 7) && xisdigit(*(tmp+7)) ) { int xstatus = atoi(tmp+7) + 1; if (xstatus<=XSTATUS_COUNT) user_private_item_set_int(u, "xstatus", xstatus); Modified: trunk/plugins/icq/icq_snac_handlers_15extension.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-12 19:50:22 UTC (rev 4621) +++ trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-13 10:10:00 UTC (rev 4622) @@ -37,63 +37,223 @@ return 0; } -#define METASNAC_SUBHANDLER(x) static int x(session_t *s, unsigned char *buf, int len, uint32_t uid, uint8_t retcode) -typedef int (*metasnac_subhandler_t) (session_t *s, unsigned char *, int, uint32_t, uint8_t ); +#define METASNAC_SUBHANDLER(x) static int x(session_t *s, unsigned char *buf, int len, uint32_t uid, uint8_t retcode, private_data_t **info) +typedef int (*metasnac_subhandler_t) (session_t *s, unsigned char *, int, uint32_t, uint8_t, private_data_t **info); #include "icq_fieldnames.inc" -METASNAC_SUBHANDLER(icq_snac_extensions_hpagecat) { - debug_function("icq_snac_extensions_hpagecat() uid: %u\n", uid); - return 0; +#define META_BASIC_USERINFO 0x00c8 +#define META_WORK_USERINFO 0x00d2 +#define META_MORE_USERINFO 0x00dc +#define META_NOTES_USERINFO 0x00e6 +#define META_EMAIL_USERINFO 0x00eb +#define META_INTERESTS_USERINFO 0x00f0 +#define META_AFFILATIONS_USERINFO 0x00fa +#define META_SHORT_USERINFO 0x0104 +#define META_HPAGECAT_USERINFO 0x010e + +typedef struct { + int type; // 1 - basic; + int item; // 'S' - str; 'w' - word; 'c' - byte; 'L' bool + const char *display; + const char *name; + void *tablica; +} _userinfo_t; + +const static _userinfo_t userinfo[] = { + /* User basic info reply */ + {META_BASIC_USERINFO, 'S', "Nickname", "nick", NULL}, + {META_BASIC_USERINFO, 'S', "Firstname", "first_name", NULL}, + {META_BASIC_USERINFO, 'S', "Lastname", "last_name", NULL}, + {META_BASIC_USERINFO, 'S', "Email", "email", NULL}, + {META_BASIC_USERINFO, 'S', "City", "city", NULL}, + {META_BASIC_USERINFO, 'S', "State", "state", NULL}, + {META_BASIC_USERINFO, 'S', "Phone", "phone", NULL}, + {META_BASIC_USERINFO, 'S', "Fax", "fax", NULL}, + {META_BASIC_USERINFO, 'S', "Street", "street", NULL}, + {META_BASIC_USERINFO, 'S', "Cellular", "mobile", NULL}, + {META_BASIC_USERINFO, 'S', "Zip", "zip", NULL}, + {META_BASIC_USERINFO, 'w', "Country", "country", countryField}, + {META_BASIC_USERINFO, 'c', "Timezone", "tzone", NULL}, + {META_BASIC_USERINFO, 'c', "Authorization", "auth", NULL}, // lookup XXX ?wo? + {META_BASIC_USERINFO, 'c', "Webaware", "webaware", NULL}, // lookup XXX ?wo? + {META_BASIC_USERINFO, 'L', "Direct connection", "dc_perm", NULL}, + {META_BASIC_USERINFO, 'L', "Publish primary email", "pub_email", NULL}, + {META_BASIC_USERINFO, 'S', NULL, NULL, NULL}, // Is here 'zip code' again? + /* User work info reply */ + {META_WORK_USERINFO, 'S', "CompanyCity", "c_city", NULL}, + {META_WORK_USERINFO, 'S', "CompanyState", "c_state", NULL}, + {META_WORK_USERINFO, 'S', "CompanyPhone", "c_phone", NULL}, + {META_WORK_USERINFO, 'S', "CompanyFax", "c_fax", NULL}, + {META_WORK_USERINFO, 'S', "CompanyStreet", "c_street", NULL}, + {META_WORK_USERINFO, 'S', "CompanyZIP", "c_zip", NULL}, + {META_WORK_USERINFO, 'w', "CompanyCountry", "c_country", countryField}, + {META_WORK_USERINFO, 'S', "Company", "c_name", NULL}, + {META_WORK_USERINFO, 'S', "CompanyDepartment", "c_depart", NULL}, + {META_WORK_USERINFO, 'S', "CompanyPosition", "c_pos", NULL}, + {META_WORK_USERINFO, 'w', "CompanyOccupation", "c_occup", workField}, + {META_WORK_USERINFO, 'S', "CompanyHomepage", "c_www", NULL}, + {META_WORK_USERINFO, 'S', NULL, "", NULL}, // Is here 'zip code' again? + /* User more info reply */ + {META_MORE_USERINFO, 'w', "Age", "age", NULL}, + {META_MORE_USERINFO, 'c', "Gender", "gender", genderField}, + {META_MORE_USERINFO, 'S', "Homepage", "www", NULL}, + {META_MORE_USERINFO, 'w', "Birth date", "birth", NULL}, + {META_MORE_USERINFO, 'c', NULL, ".month", NULL}, + {META_MORE_USERINFO, 'c', NULL, ".day", NULL}, + {META_MORE_USERINFO, 'c', "Language1", "lang1", languageField}, + {META_MORE_USERINFO, 'c', "Language2", "lang2", languageField}, + {META_MORE_USERINFO, 'c', "Language3", "lang3", languageField}, + {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes + {META_MORE_USERINFO, 'S', "Original from City" "o_city", NULL}, + {META_MORE_USERINFO, 'S', "Original from State" "o_state", NULL}, + {META_MORE_USERINFO, 'w', "Original from Country", "o_country", countryField}, + {META_MORE_USERINFO, 'c', NULL, NULL, NULL}, // Timezone + {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes + {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes + {META_MORE_USERINFO, 'S', NULL, NULL, NULL}, // skip unknown string + {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes + {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes + {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes + {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes + {META_MORE_USERINFO, 'S', NULL, NULL, NULL}, // skip unknown string + {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes + {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes + {META_MORE_USERINFO, 'c', NULL, NULL, NULL}, // skip 1 unknown byte + {META_MORE_USERINFO, 'S', NULL, NULL, NULL}, // skip unknown string + /* User notes (about) info reply */ + {META_NOTES_USERINFO, 'S', "About", "about", NULL}, + /* User extended email info reply */ + {META_EMAIL_USERINFO, 'S', "Email", "email1", NULL}, + {META_EMAIL_USERINFO, 'S', "Email", "email2", NULL}, + {META_EMAIL_USERINFO, 'S', "Email", "email3", NULL}, + {META_EMAIL_USERINFO, 'S', "Email", "email4", NULL}, // more emails? ?wo? + /* User interests info reply */ + {META_INTERESTS_USERINFO, 'w', "Interests", "interests1", interestsField}, + {META_INTERESTS_USERINFO, 'S', "InterestsStr", "interestsStr1", NULL}, + {META_INTERESTS_USERINFO, 'w', "Interests", "interests2", interestsField}, + {META_INTERESTS_USERINFO, 'S', "InterestsStr", "interestsStr2", NULL}, + {META_INTERESTS_USERINFO, 'w', "Interests", "interests3", interestsField}, + {META_INTERESTS_USERINFO, 'S', "InterestsStr", "interestsStr3", NULL}, + {META_INTERESTS_USERINFO, 'w', "Interests", "interests4", interestsField}, + {META_INTERESTS_USERINFO, 'S', "InterestsStr", "interestsStr4", NULL}, + /* User past/affilations info reply */ + {META_AFFILATIONS_USERINFO, 'w', "PastAff", "pastaff1", pastField}, + {META_AFFILATIONS_USERINFO, 'S', "PastAffStr", "pastaffStr1", NULL}, + {META_AFFILATIONS_USERINFO, 'w', "PastAff", "pastaff2", pastField}, + {META_AFFILATIONS_USERINFO, 'S', "PastAffStr", "pastaffStr2", NULL}, + {META_AFFILATIONS_USERINFO, 'w', "PastAff", "pastaff3", pastField}, + {META_AFFILATIONS_USERINFO, 'S', "PastAffStr", "pastaffStr3", NULL}, + {META_AFFILATIONS_USERINFO, 'w', "Aff", "aff1", pastField}, + {META_AFFILATIONS_USERINFO, 'S', "AffStr", "affStr1", NULL}, + {META_AFFILATIONS_USERINFO, 'w', "Aff", "aff2", pastField}, + {META_AFFILATIONS_USERINFO, 'S', "AffStr", "affStr2", NULL}, + {META_AFFILATIONS_USERINFO, 'w', "Aff", "aff3", pastField}, + {META_AFFILATIONS_USERINFO, 'S', "AffStr", "affStr3", NULL}, + /* Short user information reply */ + {META_SHORT_USERINFO, 'S', "Nickname", "nick", NULL}, // ?WO? "nick" or "s_nick" ??? + {META_SHORT_USERINFO, 'S', "Firstname", "first_name", NULL}, // as above + {META_SHORT_USERINFO, 'S', "Lastname", "last_name", NULL}, // as above + {META_SHORT_USERINFO, 'S', "Email", "email", NULL}, // as above + /* User homepage category information reply */ + {META_HPAGECAT_USERINFO, 'b', NULL, "", NULL}, // 1-enabled, 0-disabled + {META_HPAGECAT_USERINFO, 'w', "Homepage category", "wwwcat", NULL}, // ?WO? lookup??? + {META_HPAGECAT_USERINFO, 'S', "Homepage keywords", "wwwkeys", NULL}, + {META_HPAGECAT_USERINFO, 'b', NULL, NULL, NULL}, // unknown + + {0, 0, NULL, NULL, NULL} +}; + +static int __get_userinfo_data(unsigned char *buf, int len, int type, private_data_t **info) { + int i, ret = 0; + + for (i=0; userinfo[i].type; i++) { + if (userinfo[i].type != type) + continue; + switch (userinfo[i].item) { + case 'S': + { + char *str; + if (!ICQ_UNPACK(&buf, "S", &str)) + ret = 1; + else + private_item_set(info, userinfo[i].name, str); + break; + } + case 'w': + { + uint16_t w = 0; + if (!ICQ_UNPACK(&buf, "w", &w)) + ret = 1; + else + private_item_set_int(info, userinfo[i].name, w); + break; + } + case 'c': + case 'L': + { + uint8_t b = 0; + if (!ICQ_UNPACK(&buf, "c", &b)) + ret = 1; + else + private_item_set_int(info, userinfo[i].name, b); + break; + } + default: + debug_error("__get_userinfo_data() unknown item type %d\n", userinfo[i].item); + ret = 1; + break; + } + if (ret) + private_item_set(info, userinfo[i].name, ""); + } + if (len) + debug_error("icq_snac_extensions_basicinfo() more data follow: %u\n", len); + if (ret) + debug_error("icq_snac_extensions_basicinfo() error: %u\n", len); /* XXX ?WO? */ + return ret; } static int __displayed = 0; /* Luckily we're not multithreaded */ -#define printq_userinfo(theme, param, paramval) { \ - if (!__displayed) \ - print("icq_userinfo_start", session_name(s), itoa(uid), theme); \ - print(theme, session_name(s), itoa(uid), param, paramval); \ - __displayed = 1; \ - } +static void __display_info(session_t *s, int type, private_data_t *data, int uid) { + struct fieldnames_t themes[]={ + {META_BASIC_USERINFO, "icq_userinfo_basic"}, + {META_WORK_USERINFO, "icq_userinfo_work"}, + {META_MORE_USERINFO, "icq_userinfo_more"}, + {META_NOTES_USERINFO, "icq_userinfo_notes"}, + {META_EMAIL_USERINFO, "icq_userinfo_email"}, + {META_INTERESTS_USERINFO, "icq_userinfo_interests"}, + {META_AFFILATIONS_USERINFO, "icq_userinfo_affilations"}, + {META_SHORT_USERINFO, "icq_userinfo_short"}, + {META_HPAGECAT_USERINFO, "icq_userinfo_hpagecat"}, + {-1, NULL}}; -#define expand_display_byte(formatka, param) \ - { \ - uint8_t __value; \ - if (!ICQ_UNPACK(&buf, "c", &__value)) return -1; \ - if (__value) printq_userinfo(formatka, param, itoa(__value)); \ - } + int i; + const char *str, *theme = icq_lookuptable(themes, type); -#define expand_display_byteT(formatka, table, param) \ - { \ - uint8_t __value; \ - if (!ICQ_UNPACK(&buf, "c", &__value)) return -1; \ - if (__value) printq_userinfo(formatka, param, icq_lookuptable(table, __value)); \ - } + for (i=0; userinfo[i].type; i++) { + if (userinfo[i].type != type) + continue; + if (userinfo[i].tablica) + str = icq_lookuptable(userinfo[i].tablica, private_item_get_int(&data, userinfo[i].name)); + else if (userinfo[i].item == 'L') + str = private_item_get_int(&data, userinfo[i].name) ? _("Yes") : _("No"); + else + str = private_item_get(&data, userinfo[i].name); + if ( str && *str) { + char *___str = xstrdup(str); /* XXX, recode */ -#define expand_display_word(formatka, param) \ - { \ - uint16_t __value; \ - if (!ICQ_UNPACK(&buf, "w", &__value)) return -1; \ - if (__value) printq_userinfo(formatka, param, itoa(__value)); \ - } + if (!__displayed) + print("icq_userinfo_start", session_name(s), itoa(uid), theme); + print(theme, session_name(s), itoa(uid), userinfo[i].display, ___str); + __displayed = 1; -#define expand_display_wordT(formatka, table, param) \ - { \ - uint16_t __value; \ - if (!ICQ_UNPACK(&buf, "w", &__value)) return -1; \ - if (__value) printq_userinfo(formatka, param, icq_lookuptable(table, __value)); \ + xfree(___str); + } } +} -#define expand_display_str(formatka, param) \ - { \ - char *__str; \ - if (!ICQ_UNPACK(&buf, "S", &__str)) return -1; \ - if (__str[0]) { \ - char *___str = xstrdup(__str); /* XXX, recode */ \ - printq_userinfo(formatka, param, ___str);\ - xfree(___str); \ - } \ - } METASNAC_SUBHANDLER(icq_snac_extensions_interests) { @@ -115,89 +275,81 @@ count = 4; for (i = 0; i < count; i++) { - expand_display_wordT("icq_userinfo_interests", interestsField, "Interests"); - expand_display_str("icq_userinfo_interests", "InterestsStr"); + char *tmp; + const char *str; + uint16_t w; + + if (ICQ_UNPACK(&buf, "wS", &w, &str)) { + tmp = saprintf("interests%d", i+1); + private_item_set_int(info, tmp, w); + xfree(tmp); + tmp = saprintf("interestsStr%d", i+1); + private_item_set(info, tmp, str); + xfree(tmp); + } } return 0; } METASNAC_SUBHANDLER(icq_snac_extensions_affilations) { + const static char *names[] = {"pastaff", "aff"}; uint8_t count; - int i; + int i, k; debug_function("icq_snac_extensions_affilations() %u\n", uid); if (retcode != 0x0A) return 0; - if (!ICQ_UNPACK(&buf, "C", &count)) - return -1; + for (k=0; k<2; k++) { + if (!ICQ_UNPACK(&buf, "C", &count)) + return -1; - /* 3 is the maximum allowed backgrounds, if count is - higher it's likely a parsing error */ + /* 3 is the maximum allowed backgrounds, if count is + higher it's likely a parsing error */ - if (count > 3) - count = 3; + if (count > 3) + count = 3; - for (i = 0; i < count; i++) { - expand_display_wordT("icq_userinfo_affilations", pastField, "PastAff"); - expand_display_str("icq_userinfo_affilations", "PastAffStr"); + for (i = 0; i < count; i++) { + char *tmp; + const char *str; + uint16_t w; + + if (ICQ_UNPACK(&buf, "wS", &w, &str)) { + tmp = saprintf("%s%d", names[k], i+1); + private_item_set_int(info, tmp, w); + xfree(tmp); + tmp = saprintf("%sStr%d", names[k], i+1); + private_item_set(info, tmp, str); + xfree(tmp); + } + } } - if (!ICQ_UNPACK(&buf, "C", &count)) - return -1; - - /* 3 is the maximum allowed affiliations, if count is - higher it's likely a parsing error */ - - if (count > 3) - count = 3; - - for (i = 0; i < count; i++) { - expand_display_wordT("icq_userinfo_affilations", pastField, "Aff"); - expand_display_str("icq_userinfo_affilations", "AffStr"); - } return 0; } + METASNAC_SUBHANDLER(icq_snac_extensions_basicinfo) { debug_function("icq_snac_extensions_basicinfo() %u\n", uid); -#define printq_userinfo_basic(param, paramval) printq_userinfo("icq_userinfo_basic", param, paramval) +//#define printq_userinfo_basic(param, paramval) printq_userinfo("icq_userinfo_basic", param, paramval) if (retcode != 0x0A) return 0; - expand_display_str("icq_userinfo_basic", "Nickname"); - expand_display_str("icq_userinfo_basic", "Firstname"); - expand_display_str("icq_userinfo_basic", "Lastname"); - expand_display_str("icq_userinfo_basic", "Email"); - expand_display_str("icq_userinfo_basic", "City"); - expand_display_str("icq_userinfo_basic", "State"); - expand_display_str("icq_userinfo_basic", "Phone"); - expand_display_str("icq_userinfo_basic", "Fax"); - expand_display_str("icq_userinfo_basic", "Street"); - expand_display_str("icq_userinfo_basic", "Cellular"); - expand_display_str("icq_userinfo_basic", "Zip"); - expand_display_wordT("icq_userinfo_basic", countryField, "Country"); + __get_userinfo_data(buf, len, META_BASIC_USERINFO, info); + { - int8_t tz; - uint8_t auth_f, web_f, dc_perm, email_f; - if (!ICQ_UNPACK(&buf, "ccccc", &tz, &auth_f, &web_f, &dc_perm, &email_f)) return -1; - char *p = saprintf("GMT%+d", tz/2); + char *tmp; + int tz = private_item_get_int(info, "tzone"); + if (tz & 0x80) + tz -= 256; + tmp = saprintf("GMT%+d", tz/2); + private_item_set(info, "tzone", tmp); + xfree(tmp); + } - printq_userinfo("icq_userinfo_basic", "Timezone", p); - xfree(p); - printq_userinfo("icq_userinfo_basic", "Authorization flag", itoa(auth_f)); - printq_userinfo("icq_userinfo_basic", "Webaware flag", itoa(web_f)); - printq_userinfo("icq_userinfo_basic", "Direct connection permissions", itoa(dc_perm)); - printq_userinfo("icq_userinfo_basic", "Publish primary email flag (?)", itoa(email_f)); - __displayed = 1; - } - // ??? Is here 'zip code' again? - expand_display_str("icq_userinfo_basic", "Another zip code (?)"); - if (len) - debug_error("icq_snac_extensions_basicinfo() more data follow: %u\n", len); -#undef printq_userinfo_basic return 0; } @@ -207,7 +359,8 @@ if (retcode != 0x0A) return 0; - expand_display_str("icq_userinfo_notes", "About"); + __get_userinfo_data(buf, len, META_NOTES_USERINFO, info); + return 0; } @@ -217,19 +370,8 @@ if (retcode != 0x0A) return 0; - expand_display_str("icq_userinfo_work", "CompanyCity"); - expand_display_str("icq_userinfo_work", "CompanyStany"); - expand_display_str("icq_userinfo_work", "CompanyPhone"); - expand_display_str("icq_userinfo_work", "CompanyFax"); - expand_display_str("icq_userinfo_work", "CompanyStreet"); - expand_display_str("icq_userinfo_work", "CompanyZIP"); - expand_display_word("icq_userinfo_work", "CompanyCountry"); - expand_display_str("icq_userinfo_work", "Company"); - expand_display_str("icq_userinfo_work", "CompanyDepartment"); - expand_display_str("icq_userinfo_work", "CompanyPosition"); - expand_display_word("icq_userinfo_work", "CompanyOccupation"); - expand_display_str("icq_userinfo_work", "CompanyHomepage"); - expand_display_str("icq_userinfo_work", "CompanyZIP"); + __get_userinfo_data(buf, len, META_WORK_USERINFO, info); + return 0; } @@ -241,10 +383,7 @@ /* XXX miranda-Broken */ - expand_display_str("icq_userinfo_short", "Nickname"); - expand_display_str("icq_userinfo_short", "Firstname"); - expand_display_str("icq_userinfo_short", "Lastname"); - expand_display_str("icq_userinfo_short", "Email"); + __get_userinfo_data(buf, len, META_SHORT_USERINFO, info); return 0; } @@ -268,12 +407,19 @@ for (i = 0; (len > 4); i++) { + char *tmp; + const char *str; + uint8_t publish_flag; /* Don't publish flag */ if (!ICQ_UNPACK(&buf, "C", &publish_flag)) return -1; - expand_display_str("icq_userinfo_email", "Email"); + if (!ICQ_UNPACK(&buf, "S", &str)) { + tmp = saprintf("email%d", i+1); + private_item_set(info, tmp, str); + xfree(tmp); + } } return 0; @@ -286,51 +432,42 @@ if (retcode != 0x0A) return 0; - expand_display_word("icq_userinfo_more", "Age"); + __get_userinfo_data(buf, len, META_MORE_USERINFO, info); + { - uint8_t gender; - if (!ICQ_UNPACK(&buf, "c", &gender)) return -1; - if (gender) printq_userinfo_more("Gender", gender == 1 ? "Female" : "Male"); - } - expand_display_str("icq_userinfo_more", "Homepage"); - { - uint16_t year; - uint8_t month, day; - if (!ICQ_UNPACK(&buf, "wcc", &year, &month, &day)) - return -1; + int year = private_item_get_int(info, "birth"); + int month = private_item_get_int(info, ".month"); + int day = private_item_get_int(info, ".day"); + if (year && month && day) { - char *bdate = saprintf("%04d-%02d-%02d", year, month,day); - printq_userinfo("icq_userinfo_more", "Birth date", bdate); + char *bdate = saprintf("%04d-%02d-%02d", year, month, day); + private_item_set(info, "birth", bdate); xfree(bdate); - } - } - expand_display_byteT("icq_userinfo_more", languageField, "Language1"); - expand_display_byteT("icq_userinfo_more", languageField, "Language2"); - expand_display_byteT("icq_userinfo_more", languageField, "Language3"); + } else + private_item_set(info, "birth", ""); - if (!ICQ_UNPACK(&buf, "2")) return -1; // skip 2 unknown bytes - if (len >= 3+3+2+5+3+8+3+5+3) { - expand_display_str("icq_userinfo_more", "Original from City"); - expand_display_str("icq_userinfo_more", "Original from State"); - expand_display_wordT("icq_userinfo_more", countryField, "Original from Country"); - { // TimeZone + 4 unknown bytes - int8_t tz; - if (!ICQ_UNPACK(&buf, "c4", &tz)) return -1; - } - expand_display_str("icq_userinfo_more", "fixme 1"); - if (!ICQ_UNPACK(&buf, "8")) return -1; // another 8 unknown bytes - expand_display_str("icq_userinfo_more", "fixme 2"); - if (!ICQ_UNPACK(&buf, "5")) return -1; // and yet another 5 - expand_display_str("icq_userinfo_more", "fixme 3"); + private_item_set(info, ".month", ""); + private_item_set(info, ".day", ""); + + if (!private_item_get_int(info, "age")) + private_item_set(info, "age", ""); } - if (len) { - debug_error("icq_snac_extensions_moreinfo() more data follow: %u\n", len); - icq_hexdump(DEBUG_ERROR, buf, len); - } #undef printq_userinfo_more return 0; } +METASNAC_SUBHANDLER(icq_snac_extensions_hpagecat) { + debug_function("icq_snac_extensions_hpagecat() uid: %u\n", uid); + + if (retcode != 0x0A) + return 0; + + __get_userinfo_data(buf, len, META_MORE_USERINFO, info); + + return 0; +} + + static int icq_snac_extension_userfound_common(session_t *s, unsigned char *buf, int len, uint32_t uid, uint8_t retcode, int islast) { char *nickname = NULL; char *first_name = NULL; @@ -478,6 +615,22 @@ METASNAC_SUBHANDLER(icq_snac_extension_userfound) { return icq_snac_extension_userfound_common(s, buf, len, uid, retcode, 0); } METASNAC_SUBHANDLER(icq_snac_extension_userfound_last) { return icq_snac_extension_userfound_common(s, buf, len, uid, retcode, 1); } +static metasnac_subhandler_t get_userinfo_extension_handler(uint16_t subtype) { + switch (subtype) { + /* userinfo */ + case META_BASIC_USERINFO: return icq_snac_extensions_basicinfo; + case META_INTERESTS_USERINFO: return icq_snac_extensions_interests; + case META_NOTES_USERINFO: return icq_snac_extensions_notes; + case META_HPAGECAT_USERINFO: return icq_snac_extensions_hpagecat; + case META_WORK_USERINFO: return icq_snac_extensions_workinfo; + case META_MORE_USERINFO: return icq_snac_extensions_moreinfo; + case META_AFFILATIONS_USERINFO: return icq_snac_extensions_affilations; + case META_EMAIL_USERINFO: return icq_snac_extensions_email; + case META_SHORT_USERINFO: return icq_snac_extensions_shortinfo; + } + return NULL; +} + SNAC_SUBHANDLER(icq_snac_extension_replyreq_0x7da) { struct { uint16_t subtype; @@ -485,6 +638,8 @@ unsigned char *data; } pkt; int uid = data ? private_item_get_int(&data, "uid") : -1; + int userinfo = 0; + private_data_t *info = NULL; metasnac_subhandler_t handler; @@ -495,38 +650,37 @@ debug_white("icq_snac_extension_replyreq_0x7da() subtype=%.4x result=%.2x (len=%d)\n", pkt.subtype, pkt.result, len); - switch (pkt.subtype) { - /* userinfo */ - case 0x00C8: handler = icq_snac_extensions_basicinfo; break; /* Miranda: OK, META_BASIC_USERINFO */ - case 0x00F0: handler = icq_snac_extensions_interests; break; /* Miranda: OK, META_INTERESTS_USERINFO */ - case 0x00E6: handler = icq_snac_extensions_notes; break; /* Miranda: OK, META_NOTES_USERINFO */ - case 0x010E: handler = icq_snac_extensions_hpagecat; break; /* Miranda: OK, META_HPAGECAT_USERINFO */ - case 0x00d2: handler = icq_snac_extensions_workinfo; break; /* Miranda: OK, META_WORK_USERINFO */ - case 0x00DC: handler = icq_snac_extensions_moreinfo; break; /* Miranda: OK, META_MORE_USERINFO */ - case 0x00FA: handler = icq_snac_extensions_affilations; break; /* Miranda: OK, META_AFFILATIONS_USERINFO */ - case 0x00EB: handler = icq_snac_extensions_email; break; /* Miranda: OK, META_EMAIL_USERINFO */ - case 0x0104: handler = icq_snac_extensions_shortinfo; break; /* Miranda: OK, META_SHORT_USERINFO */ - /* search */ - case 0x01AE: handler = icq_snac_extension_userfound_last; break;/* Miranda: OK, SRV_LAST_USER_FOUND */ - case 0x01A4: handler = icq_snac_extension_userfound; break; /* Miranda: OK, SRV_USER_FOUND */ + if ( (handler = get_userinfo_extension_handler(pkt.subtype)) ) { + userinfo = 1; + } else { + switch (pkt.subtype) { + /* search */ + case 0x01AE: handler = icq_snac_extension_userfound_last; break;/* Miranda: OK, SRV_LAST_USER_FOUND */ + case 0x01A4: handler = icq_snac_extension_userfound; break; /* Miranda: OK, SRV_USER_FOUND */ - case 0x0366: handler = NULL; break; /* XXX, SRV_RANDOM_FOUND */ - default: handler = NULL; + case 0x0366: handler = NULL; break; /* XXX, SRV_RANDOM_FOUND */ + default: handler = NULL; + } } + __displayed = 0; if (!handler) { debug_error("icq_snac_extension_replyreq_0x7da() ignored: %.4x\n", pkt.subtype); icq_hexdump(DEBUG_ERROR, pkt.data, len); return 0; } else { - __displayed = 0; - handler(s, pkt.data, len, uid, pkt.result); + handler(s, pkt.data, len, uid, pkt.result, &info); - if (__displayed) - print("icq_userinfo_end", session_name(s), itoa(uid)); + if (userinfo) { + __display_info(s, pkt.subtype, info, uid); + if (__displayed) + print("icq_userinfo_end", session_name(s), itoa(uid)); + } } + private_items_destroy(&info); + return 0; } From svn w toxygen.net Sat Sep 13 15:09:50 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 13 Sep 2008 15:09:50 +0200 (CEST) Subject: [ekg2-commit] r4623 - trunk/plugins/icq: trunk/plugins/icq/icq.c trunk/plugins/icq/icq.h trunk/plugins/icq/icq_snac_handlers_15extension.inc Message-ID: <20080913130950.406AA17B1F@toxygen.net> Author: wiechu Date: 2008-09-13 15:09:49 +0200 (Sat, 13 Sep 2008) New Revision: 4623 Modified: trunk/plugins/icq/icq.c trunk/plugins/icq/icq.h trunk/plugins/icq/icq_snac_handlers_15extension.inc Log: meta information response (clean & fix) Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-13 10:10:00 UTC (rev 4622) +++ trunk/plugins/icq/icq.c 2008-09-13 13:09:49 UTC (rev 4623) @@ -451,6 +451,7 @@ #endif s->priv = NULL; + private_items_destroy(&j->whoami); xfree(j->default_group_name); string_free(j->cookie, 1); string_free(j->stream_buf, 1); Modified: trunk/plugins/icq/icq.h =================================================================== --- trunk/plugins/icq/icq.h 2008-09-13 10:10:00 UTC (rev 4622) +++ trunk/plugins/icq/icq.h 2008-09-13 13:09:49 UTC (rev 4623) @@ -43,6 +43,7 @@ int aim; /* aim-ok? */ int default_group_id; /* XXX ?wo? TEMP! We should support list of groups */ int xstatus; + private_data_t *whoami; char *default_group_name; string_t cookie; /* connection login cookie */ string_t stream_buf; Modified: trunk/plugins/icq/icq_snac_handlers_15extension.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-13 10:10:00 UTC (rev 4622) +++ trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-13 13:09:49 UTC (rev 4623) @@ -37,8 +37,8 @@ return 0; } -#define METASNAC_SUBHANDLER(x) static int x(session_t *s, unsigned char *buf, int len, uint32_t uid, uint8_t retcode, private_data_t **info) -typedef int (*metasnac_subhandler_t) (session_t *s, unsigned char *, int, uint32_t, uint8_t, private_data_t **info); +#define METASNAC_SUBHANDLER(x) static int x(session_t *s, unsigned char *buf, int len, private_data_t **info) +typedef int (*metasnac_subhandler_t) (session_t *s, unsigned char *, int, private_data_t **info); #include "icq_fieldnames.inc" @@ -52,12 +52,16 @@ #define META_SHORT_USERINFO 0x0104 #define META_HPAGECAT_USERINFO 0x010e +#define SRV_USER_FOUND 0x01a4 +#define SRV_LAST_USER_FOUND 0x01ae +#define SRV_RANDOM_FOUND 0x0366 + typedef struct { - int type; // 1 - basic; - int item; // 'S' - str; 'w' - word; 'c' - byte; 'L' bool - const char *display; - const char *name; - void *tablica; + int type; + int item; // 'S' - str; 'w' - word; 'c' - byte; 'L' bool + const char *display; // display name + const char *name; // private item name + void *ltab; } _userinfo_t; const static _userinfo_t userinfo[] = { @@ -164,6 +168,23 @@ {0, 0, NULL, NULL, NULL} }; +struct fieldnames_t meta_name[]={ + {META_BASIC_USERINFO, "basic"}, + {META_WORK_USERINFO, "work"}, + {META_MORE_USERINFO, "more"}, + {META_NOTES_USERINFO, "notes"}, + {META_EMAIL_USERINFO, "email"}, + {META_INTERESTS_USERINFO, "interests"}, + {META_AFFILATIONS_USERINFO, "affilations"}, + {META_SHORT_USERINFO, "short"}, + {META_HPAGECAT_USERINFO, "hpagecat"}, + + {SRV_USER_FOUND, "userfound"}, + {SRV_LAST_USER_FOUND, "userfound_last"}, + {SRV_RANDOM_FOUND, ""}, + {-1, NULL}}; + + static int __get_userinfo_data(unsigned char *buf, int len, int type, private_data_t **info) { int i, ret = 0; @@ -216,27 +237,16 @@ static int __displayed = 0; /* Luckily we're not multithreaded */ -static void __display_info(session_t *s, int type, private_data_t *data, int uid) { - struct fieldnames_t themes[]={ - {META_BASIC_USERINFO, "icq_userinfo_basic"}, - {META_WORK_USERINFO, "icq_userinfo_work"}, - {META_MORE_USERINFO, "icq_userinfo_more"}, - {META_NOTES_USERINFO, "icq_userinfo_notes"}, - {META_EMAIL_USERINFO, "icq_userinfo_email"}, - {META_INTERESTS_USERINFO, "icq_userinfo_interests"}, - {META_AFFILATIONS_USERINFO, "icq_userinfo_affilations"}, - {META_SHORT_USERINFO, "icq_userinfo_short"}, - {META_HPAGECAT_USERINFO, "icq_userinfo_hpagecat"}, - {-1, NULL}}; +static void __display_info(session_t *s, int type, private_data_t *data) { + int i, uid = private_item_get_int(&data, "uid"); + const char *str; + char *theme = saprintf("icq_userinfo_%s", icq_lookuptable(meta_name, type)); - int i; - const char *str, *theme = icq_lookuptable(themes, type); - for (i=0; userinfo[i].type; i++) { if (userinfo[i].type != type) continue; - if (userinfo[i].tablica) - str = icq_lookuptable(userinfo[i].tablica, private_item_get_int(&data, userinfo[i].name)); + if (userinfo[i].ltab) + str = icq_lookuptable(userinfo[i].ltab, private_item_get_int(&data, userinfo[i].name)); else if (userinfo[i].item == 'L') str = private_item_get_int(&data, userinfo[i].name) ? _("Yes") : _("No"); else @@ -252,19 +262,20 @@ xfree(___str); } } + xfree(theme); } +/* + * Userinfo handlers + * + */ + METASNAC_SUBHANDLER(icq_snac_extensions_interests) { uint8_t count; int i; - debug_function("icq_snac_extensions_interests() uid: %u\n", uid); - - if (retcode != 0x0A) - return 0; - if (!ICQ_UNPACK(&buf, "C", &count)) return -1; @@ -296,11 +307,6 @@ uint8_t count; int i, k; - debug_function("icq_snac_extensions_affilations() %u\n", uid); - - if (retcode != 0x0A) - return 0; - for (k=0; k<2; k++) { if (!ICQ_UNPACK(&buf, "C", &count)) return -1; @@ -330,14 +336,8 @@ return 0; } - METASNAC_SUBHANDLER(icq_snac_extensions_basicinfo) { - debug_function("icq_snac_extensions_basicinfo() %u\n", uid); -//#define printq_userinfo_basic(param, paramval) printq_userinfo("icq_userinfo_basic", param, paramval) - if (retcode != 0x0A) - return 0; - __get_userinfo_data(buf, len, META_BASIC_USERINFO, info); { @@ -354,37 +354,18 @@ } METASNAC_SUBHANDLER(icq_snac_extensions_notes) { - debug_function("icq_snac_extensions_notes() %u\n", uid); - - if (retcode != 0x0A) - return 0; - __get_userinfo_data(buf, len, META_NOTES_USERINFO, info); - return 0; } METASNAC_SUBHANDLER(icq_snac_extensions_workinfo) { - debug_function("icq_snac_extensions_workinfo() %u\n", uid); - - if (retcode != 0x0A) - return 0; - __get_userinfo_data(buf, len, META_WORK_USERINFO, info); - return 0; } METASNAC_SUBHANDLER(icq_snac_extensions_shortinfo) { - debug_function("icq_snac_extensions_shortinfo() %u\n", uid); - - if (retcode != 0x0A) - return 0; - /* XXX miranda-Broken */ - __get_userinfo_data(buf, len, META_SHORT_USERINFO, info); - return 0; } @@ -392,11 +373,6 @@ uint8_t count_discard; int i; - debug_function("icq_snac_extensions_email() %u\n", uid); - - if (retcode != 0x0A) - return 0; - /* This value used to be a e-mail counter. Either that was wrong or * Mirabilis changed the behaviour again. It usually says NULL now so * I use the packet byte count to extract the e-mails instead. @@ -405,7 +381,6 @@ if (!ICQ_UNPACK(&buf, "C", &count_discard)) return -1; - for (i = 0; (len > 4); i++) { char *tmp; const char *str; @@ -426,12 +401,7 @@ } METASNAC_SUBHANDLER(icq_snac_extensions_moreinfo) { - debug_function("icq_snac_extensions_moreinfo() uid: %u\n", uid); -#define printq_userinfo_more(param, paramval) printq_userinfo("icq_userinfo_more", param, paramval) - if (retcode != 0x0A) - return 0; - __get_userinfo_data(buf, len, META_MORE_USERINFO, info); { @@ -452,23 +422,21 @@ if (!private_item_get_int(info, "age")) private_item_set(info, "age", ""); } -#undef printq_userinfo_more return 0; } METASNAC_SUBHANDLER(icq_snac_extensions_hpagecat) { - debug_function("icq_snac_extensions_hpagecat() uid: %u\n", uid); - - if (retcode != 0x0A) - return 0; - __get_userinfo_data(buf, len, META_MORE_USERINFO, info); - return 0; } -static int icq_snac_extension_userfound_common(session_t *s, unsigned char *buf, int len, uint32_t uid, uint8_t retcode, int islast) { +/* + * search handlers + * + */ + +static int icq_snac_extension_userfound_common(session_t *s, unsigned char *buf, int len, int islast) { char *nickname = NULL; char *first_name = NULL; char *last_name = NULL; @@ -483,16 +451,8 @@ uint16_t len2; uint8_t auth, status, gender, age; - debug_function("icq_snac_extension_userfound()\n"); - /* XXX, sprawdzic czy mamy cookie. */ - if (retcode != 0xA) { - /* Failed search */ - debug_error("icq_snac_extension_userfound() search error: %u\n", retcode); - return 0; - } - if (!ICQ_UNPACK(&buf, "w", &len2)) return -1; @@ -612,8 +572,8 @@ return -1; } -METASNAC_SUBHANDLER(icq_snac_extension_userfound) { return icq_snac_extension_userfound_common(s, buf, len, uid, retcode, 0); } -METASNAC_SUBHANDLER(icq_snac_extension_userfound_last) { return icq_snac_extension_userfound_common(s, buf, len, uid, retcode, 1); } +METASNAC_SUBHANDLER(icq_snac_extension_userfound) { return icq_snac_extension_userfound_common(s, buf, len, 0); } +METASNAC_SUBHANDLER(icq_snac_extension_userfound_last) { return icq_snac_extension_userfound_common(s, buf, len, 1); } static metasnac_subhandler_t get_userinfo_extension_handler(uint16_t subtype) { switch (subtype) { @@ -631,15 +591,13 @@ return NULL; } -SNAC_SUBHANDLER(icq_snac_extension_replyreq_0x7da) { +static int icq_snac_extension_replyreq_0x7da(session_t *s, unsigned char *buf, int len, private_data_t **info, int show) { struct { uint16_t subtype; uint8_t result; unsigned char *data; } pkt; - int uid = data ? private_item_get_int(&data, "uid") : -1; int userinfo = 0; - private_data_t *info = NULL; metasnac_subhandler_t handler; @@ -655,11 +613,11 @@ } else { switch (pkt.subtype) { /* search */ - case 0x01AE: handler = icq_snac_extension_userfound_last; break;/* Miranda: OK, SRV_LAST_USER_FOUND */ - case 0x01A4: handler = icq_snac_extension_userfound; break; /* Miranda: OK, SRV_USER_FOUND */ + case SRV_LAST_USER_FOUND: handler = icq_snac_extension_userfound_last; break;/* Miranda: OK, SRV_LAST_USER_FOUND */ + case SRV_USER_FOUND: handler = icq_snac_extension_userfound; break; /* Miranda: OK, SRV_USER_FOUND */ - case 0x0366: handler = NULL; break; /* XXX, SRV_RANDOM_FOUND */ - default: handler = NULL; + case SRV_RANDOM_FOUND: handler = NULL; break; /* XXX, SRV_RANDOM_FOUND */ + default: handler = NULL; } } @@ -669,95 +627,120 @@ icq_hexdump(DEBUG_ERROR, pkt.data, len); return 0; } else { + int uid = info ? private_item_get_int(info, "uid") : -1; + debug_function("icq_snac_extensions_%s()", icq_lookuptable(meta_name, pkt.subtype)); + if (userinfo) + debug_function(" uid: %u\n", uid); - handler(s, pkt.data, len, uid, pkt.result, &info); + if (pkt.result == 0x0A) { + handler(s, pkt.data, len, info); + } else if (!userinfo){ + /* Failed search */ + debug_error("icq_snac_extension_userfound() search error: %u\n", pkt.result); + } - if (userinfo) { - __display_info(s, pkt.subtype, info, uid); + if (show) { + __display_info(s, pkt.subtype, *info); if (__displayed) print("icq_userinfo_end", session_name(s), itoa(uid)); } } - private_items_destroy(&info); - return 0; } -SNAC_SUBHANDLER(icq_snac_extension_replyreq) { - /* - * Handle SNAC(0x15, 0x3) -- Meta information response - * - */ - +static int check_replyreq(session_t *s, unsigned char **buf, int *len, int *type) { struct { + uint16_t type; uint16_t len; + } tlv; + struct { + uint16_t len; uint32_t uid; uint16_t type; uint16_t id; } pkt; - struct icq_tlv_list *tlvs; - icq_tlv_t *t; - unsigned char *tlv_data; - int tlv_len; - - debug_function("icq_snac_extension_replyreq()\n"); - - tlvs = icq_unpack_tlvs(&buf, &len, 0); - - if (!(t = icq_tlv_get(tlvs, 1)) || t->len < 10) { + if (!icq_unpack(*buf, buf, len, "WW", &tlv.type, &tlv.len) || (tlv.type != 0x0001) || (tlv.len < 10)) { debug_error("icq_snac_extension_replyreq() broken(1)\n"); - icq_tlvs_destroy(&tlvs); - return -1; + return 0; } - if (len) { + if (*len!=tlv.len) { debug_error("icq_snac_extension_replyreq() broken(1,5)\n"); - icq_tlvs_destroy(&tlvs); - return -2; + return 0; } - tlv_data = t->buf; - tlv_len = t->len; - - if (!icq_unpack(tlv_data, &tlv_data, &tlv_len, "wiwW", &pkt.len, &pkt.uid, &pkt.type, &pkt.id)) { + if (!icq_unpack(*buf, buf, len, "wiwW", &pkt.len, &pkt.uid, &pkt.type, &pkt.id)) { debug_error("icq_snac_extension_replyreq() broken(2)\n"); - icq_tlvs_destroy(&tlvs); - return -1; + return 0; } debug_white("icq_snac_extension_replyreq() uid=%d type=%.4x (len=%d, len2=%d)\n", pkt.uid, pkt.type, len, pkt.len); if (xstrcmp(s->uid+4, itoa(pkt.uid))) { debug_error("icq_snac_extension_replyreq() 1919 UIN mismatch: %s vs %ld.\n", s->uid+4, pkt.uid); - icq_tlvs_destroy(&tlvs); - return -2; + return 0; } - if (t->len - 2 != pkt.len) { + if (tlv.len - 2 != pkt.len) { debug("icq_snac_extension_replyreq() 1743 Size mismatch in packet lengths.\n"); - icq_tlvs_destroy(&tlvs); - return -2; + return 0; } - switch (pkt.type) { + *type = pkt.type; + + return 1; +} + +SNAC_SUBHANDLER(icq_snac_extension_replyreq) { + /* + * Handle SNAC(0x15, 0x3) -- Meta information response + * + */ + int type = 0; + private_data_t *info = NULL; + + debug_function("icq_snac_extension_replyreq()\n"); + + if (!check_replyreq(s, &buf, &len, &type)) + return -1; + + private_item_set_int(&info, "uid", private_item_get_int(&data, "uid")); + + switch (type) { case 0x7da: - icq_snac_extension_replyreq_0x7da(s, tlv_data, tlv_len, data); /* Miranda: STARTED */ + icq_snac_extension_replyreq_0x7da(s, buf, len, &info, 1); /* Miranda: STARTED */ break; default: - debug_error("icq_snac_extension_replyreq() METASNAC with unknown code: %x received.\n", pkt.type); + debug_error("icq_snac_extension_replyreq() METASNAC with unknown code: %x received.\n", type); break; } - icq_tlvs_destroy(&tlvs); + private_items_destroy(&info); + return 0; } SNAC_SUBHANDLER(icq_my_meta_information_response) { - /* XXX it's only example */ - print("icq_user_info_generic", _("It's me"), ""); - icq_snac_extension_replyreq(s, buf, len, data); + int type; + icq_private_t *j = s->priv; + + debug_function("icq_my_meta_information_response()\n"); + + if (!check_replyreq(s, &buf, &len, &type)) + return -1; + + private_item_set(&j->whoami, "uid", s->uid+4); + + switch (type) { + case 0x7da: + icq_snac_extension_replyreq_0x7da(s, buf, len, &j->whoami, 0); + break; + default: + debug_error("icq_snac_extension_replyreq() METASNAC with unknown code: %x received.\n", type); + break; + } return 0; } From svn w toxygen.net Sat Sep 13 16:30:11 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 13 Sep 2008 16:30:11 +0200 (CEST) Subject: [ekg2-commit] r4624 - trunk/plugins/gtk: trunk/plugins/gtk/xtext.c trunk/plugins/gtk/xtext.h Message-ID: <20080913143011.ED74817B1F@toxygen.net> Author: darkjames Date: 2008-09-13 16:30:11 +0200 (Sat, 13 Sep 2008) New Revision: 4624 Modified: trunk/plugins/gtk/xtext.c trunk/plugins/gtk/xtext.h Log: 5c73aeca2209bdb8ef6c69ee262c082c62d49005 upstream. xtext: Make compile with 2.13.x reported also by Dominik 'Rathann' Mierzejewski @ ekg2-devel Modified: trunk/plugins/gtk/xtext.c =================================================================== --- trunk/plugins/gtk/xtext.c 2008-09-13 13:09:49 UTC (rev 4623) +++ trunk/plugins/gtk/xtext.c 2008-09-13 14:30:11 UTC (rev 4624) @@ -2120,9 +2120,9 @@ xtext_class->word_click = NULL; } -GtkType gtk_xtext_get_type(void) +GType gtk_xtext_get_type(void) { - static GtkType xtext_type = 0; + static GType xtext_type = 0; if (!xtext_type) { static const GTypeInfo xtext_info = { Modified: trunk/plugins/gtk/xtext.h =================================================================== --- trunk/plugins/gtk/xtext.h 2008-09-13 13:09:49 UTC (rev 4623) +++ trunk/plugins/gtk/xtext.h 2008-09-13 14:30:11 UTC (rev 4624) @@ -240,6 +240,6 @@ xtext_buffer *gtk_xtext_buffer_new(GtkXText * xtext); void gtk_xtext_buffer_free(xtext_buffer * buf); void gtk_xtext_buffer_show(GtkXText * xtext, xtext_buffer * buf, int render); -GtkType gtk_xtext_get_type(void); +GType gtk_xtext_get_type(void); #endif From svn w toxygen.net Sat Sep 13 17:16:13 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 13 Sep 2008 17:16:13 +0200 (CEST) Subject: [ekg2-commit] r4625 - trunk/plugins/icq: trunk/plugins/icq/icq.c trunk/plugins/icq/icq_snac_handlers.h trunk/plugins/icq/icq_snac_handlers_15extension.inc Message-ID: <20080913151613.BAE1017B1F@toxygen.net> Author: wiechu Date: 2008-09-13 17:16:13 +0200 (Sat, 13 Sep 2008) New Revision: 4625 Modified: trunk/plugins/icq/icq.c trunk/plugins/icq/icq_snac_handlers.h trunk/plugins/icq/icq_snac_handlers_15extension.inc Log: - new command /whoami - meta information response (clean & fix) Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-13 14:30:11 UTC (rev 4624) +++ trunk/plugins/icq/icq.c 2008-09-13 15:16:13 UTC (rev 4625) @@ -1375,6 +1375,11 @@ return 0; } +static COMMAND(icq_command_whoami) { + display_whoami(session); + return 0; +} + static COMMAND(icq_command_register) { printq("generic_error", "Create a new ICQ account on http://lite.icq.com/register"); return 0; @@ -1511,6 +1516,8 @@ command_add(&icq_plugin, "icq:disconnect", NULL,icq_command_disconnect, ICQ_ONLY, NULL); command_add(&icq_plugin, "icq:reconnect", NULL, icq_command_reconnect, ICQ_ONLY, NULL); + command_add(&icq_plugin, "icq:whoami", NULL, icq_command_whoami, ICQ_ONLY, NULL); + command_add(&icq_plugin, "icq:_rates", NULL, icq_command_rates, ICQ_ONLY, NULL); return 0; Modified: trunk/plugins/icq/icq_snac_handlers.h =================================================================== --- trunk/plugins/icq/icq_snac_handlers.h 2008-09-13 14:30:11 UTC (rev 4624) +++ trunk/plugins/icq/icq_snac_handlers.h 2008-09-13 15:16:13 UTC (rev 4625) @@ -28,5 +28,6 @@ SNAC_SUBHANDLER(icq_my_meta_information_response); SNAC_SUBHANDLER(icq_cmd_addssi_ack); +void display_whoami(session_t *s); #endif Modified: trunk/plugins/icq/icq_snac_handlers_15extension.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-13 14:30:11 UTC (rev 4624) +++ trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-13 15:16:13 UTC (rev 4625) @@ -97,7 +97,7 @@ {META_WORK_USERINFO, 'S', "CompanyPosition", "c_pos", NULL}, {META_WORK_USERINFO, 'w', "CompanyOccupation", "c_occup", workField}, {META_WORK_USERINFO, 'S', "CompanyHomepage", "c_www", NULL}, - {META_WORK_USERINFO, 'S', NULL, "", NULL}, // Is here 'zip code' again? + {META_WORK_USERINFO, 'S', NULL, NULL, NULL}, // Is here 'zip code' again? /* User more info reply */ {META_MORE_USERINFO, 'w', "Age", "age", NULL}, {META_MORE_USERINFO, 'c', "Gender", "gender", genderField}, @@ -160,10 +160,10 @@ {META_SHORT_USERINFO, 'S', "Lastname", "last_name", NULL}, // as above {META_SHORT_USERINFO, 'S', "Email", "email", NULL}, // as above /* User homepage category information reply */ - {META_HPAGECAT_USERINFO, 'b', NULL, "", NULL}, // 1-enabled, 0-disabled + {META_HPAGECAT_USERINFO, 'c', NULL, NULL, NULL}, // 1-enabled, 0-disabled {META_HPAGECAT_USERINFO, 'w', "Homepage category", "wwwcat", NULL}, // ?WO? lookup??? {META_HPAGECAT_USERINFO, 'S', "Homepage keywords", "wwwkeys", NULL}, - {META_HPAGECAT_USERINFO, 'b', NULL, NULL, NULL}, // unknown + {META_HPAGECAT_USERINFO, 'c', NULL, NULL, NULL}, // unknown {0, 0, NULL, NULL, NULL} }; @@ -210,6 +210,7 @@ private_item_set_int(info, userinfo[i].name, w); break; } + case 'b': case 'c': case 'L': { @@ -229,9 +230,9 @@ private_item_set(info, userinfo[i].name, ""); } if (len) - debug_error("icq_snac_extensions_basicinfo() more data follow: %u\n", len); + debug_error("__get_userinfo_data() more data follow: %u\n", len); if (ret) - debug_error("icq_snac_extensions_basicinfo() error: %u\n", len); /* XXX ?WO? */ + debug_error("__get_userinfo_data() type:0x%x error: %u\n", type, len); return ret; } @@ -243,7 +244,7 @@ char *theme = saprintf("icq_userinfo_%s", icq_lookuptable(meta_name, type)); for (i=0; userinfo[i].type; i++) { - if (userinfo[i].type != type) + if ( (userinfo[i].type != type) || (!userinfo[i].name) ) continue; if (userinfo[i].ltab) str = icq_lookuptable(userinfo[i].ltab, private_item_get_int(&data, userinfo[i].name)); @@ -426,7 +427,7 @@ } METASNAC_SUBHANDLER(icq_snac_extensions_hpagecat) { - __get_userinfo_data(buf, len, META_MORE_USERINFO, info); + __get_userinfo_data(buf, len, META_HPAGECAT_USERINFO, info); return 0; } @@ -662,7 +663,7 @@ } pkt; if (!icq_unpack(*buf, buf, len, "WW", &tlv.type, &tlv.len) || (tlv.type != 0x0001) || (tlv.len < 10)) { - debug_error("icq_snac_extension_replyreq() broken(1)\n"); + debug_error("check_replyreq() broken(1)\n"); return 0; } @@ -676,7 +677,7 @@ return 0; } - debug_white("icq_snac_extension_replyreq() uid=%d type=%.4x (len=%d, len2=%d)\n", pkt.uid, pkt.type, len, pkt.len); + debug_white("icq_snac_extension_replyreq() uid=%d type=%.4x (len=%d, len2=%d)\n", pkt.uid, pkt.type, *len, pkt.len); if (xstrcmp(s->uid+4, itoa(pkt.uid))) { debug_error("icq_snac_extension_replyreq() 1919 UIN mismatch: %s vs %ld.\n", s->uid+4, pkt.uid); @@ -738,12 +739,37 @@ icq_snac_extension_replyreq_0x7da(s, buf, len, &j->whoami, 0); break; default: - debug_error("icq_snac_extension_replyreq() METASNAC with unknown code: %x received.\n", type); + debug_error("icq_my_meta_information_response() METASNAC with unknown code: %x received.\n", type); break; } return 0; } +void display_whoami(session_t *s) { + icq_private_t *j = s->priv; + int uid = private_item_get_int(&j->whoami, "uid"); + int end = 0; + __displayed = 0; + __display_info(s, META_BASIC_USERINFO, j->whoami); + end |= __displayed; __displayed = 0; + __display_info(s, META_MORE_USERINFO, j->whoami); + end |= __displayed; __displayed = 0; + __display_info(s, META_EMAIL_USERINFO, j->whoami); + end |= __displayed; __displayed = 0; + __display_info(s, META_NOTES_USERINFO, j->whoami); + end |= __displayed; __displayed = 0; + __display_info(s, META_HPAGECAT_USERINFO, j->whoami); + end |= __displayed; __displayed = 0; + __display_info(s, META_WORK_USERINFO, j->whoami); + end |= __displayed; __displayed = 0; + __display_info(s, META_INTERESTS_USERINFO, j->whoami); + end |= __displayed; __displayed = 0; + __display_info(s, META_AFFILATIONS_USERINFO, j->whoami); + if (end) + print("icq_userinfo_end", session_name(s), itoa(uid)); +} + + SNAC_HANDLER(icq_snac_extension_handler) { snac_subhandler_t handler; From svn w toxygen.net Sat Sep 13 20:00:19 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 13 Sep 2008 20:00:19 +0200 (CEST) Subject: [ekg2-commit] r4626 - trunk/plugins/icq: trunk/plugins/icq/icq_snac_handlers_15extension.inc Message-ID: <20080913180019.BCDA217B1F@toxygen.net> Author: wiechu Date: 2008-09-13 20:00:19 +0200 (Sat, 13 Sep 2008) New Revision: 4626 Modified: trunk/plugins/icq/icq_snac_handlers_15extension.inc Log: meta information response (clean & fix) Modified: trunk/plugins/icq/icq_snac_handlers_15extension.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-13 15:16:13 UTC (rev 4625) +++ trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-13 18:00:19 UTC (rev 4626) @@ -160,10 +160,8 @@ {META_SHORT_USERINFO, 'S', "Lastname", "last_name", NULL}, // as above {META_SHORT_USERINFO, 'S', "Email", "email", NULL}, // as above /* User homepage category information reply */ - {META_HPAGECAT_USERINFO, 'c', NULL, NULL, NULL}, // 1-enabled, 0-disabled {META_HPAGECAT_USERINFO, 'w', "Homepage category", "wwwcat", NULL}, // ?WO? lookup??? {META_HPAGECAT_USERINFO, 'S', "Homepage keywords", "wwwkeys", NULL}, - {META_HPAGECAT_USERINFO, 'c', NULL, NULL, NULL}, // unknown {0, 0, NULL, NULL, NULL} }; @@ -427,7 +425,27 @@ } METASNAC_SUBHANDLER(icq_snac_extensions_hpagecat) { - __get_userinfo_data(buf, len, META_HPAGECAT_USERINFO, info); + struct { + uint8_t enabled; + uint16_t cat; + char *str; + } pkt; + + private_item_set(info, "wwwcat", NULL); + private_item_set(info, "wwwkeys", NULL); + + if (!ICQ_UNPACK(&buf, "c", &pkt.enabled)) + return -1; + + if (!pkt.enabled) + return 0; + + if (!ICQ_UNPACK(&buf, "wS", &pkt.cat, &pkt.str)) + return -1; + + private_item_set_int(info, "wwwcat", pkt.cat); + private_item_set(info, "wwwkeys", pkt.str); + return 0; } @@ -631,7 +649,8 @@ int uid = info ? private_item_get_int(info, "uid") : -1; debug_function("icq_snac_extensions_%s()", icq_lookuptable(meta_name, pkt.subtype)); if (userinfo) - debug_function(" uid: %u\n", uid); + debug_function(" uid: %u", uid); + debug_function("\n"); if (pkt.result == 0x0A) { handler(s, pkt.data, len, info); From svn w toxygen.net Sat Sep 13 21:42:44 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 13 Sep 2008 21:42:44 +0200 (CEST) Subject: [ekg2-commit] r4627 - trunk/plugins/jabber: trunk/plugins/jabber/jabber.c trunk/plugins/jabber/jabber_handlers_iq_result.inc Message-ID: <20080913194244.C844C17B1F@toxygen.net> Author: peres Date: 2008-09-13 21:42:44 +0200 (Sat, 13 Sep 2008) New Revision: 4627 Modified: trunk/plugins/jabber/jabber.c trunk/plugins/jabber/jabber_handlers_iq_result.inc Log: Finally! Modified: trunk/plugins/jabber/jabber.c =================================================================== --- trunk/plugins/jabber/jabber.c 2008-09-13 18:00:19 UTC (rev 4626) +++ trunk/plugins/jabber/jabber.c 2008-09-13 19:42:44 UTC (rev 4627) @@ -1326,7 +1326,7 @@ format_add("jabber_userinfo_adr_country", _("%g|| || %n Country: %T%2"), 1); format_add("jabber_userinfo_adr_end", _("%g|| %g`+=%G-----"), 1); - format_add("jabber_userinfo_photourl", _("%g||\n%g|| %nYou can view attached photo at: %Thttp://vcard.nomicon.pl/%1"), 1); + format_add("jabber_userinfo_photourl", _("%g||\n%g|| %nYou can view attached photo at: %T%2%1"), 1); format_add("jabber_userinfo_end", _("%g`+=%G-----"), 1); format_add("jabber_userinfo_error", _("%! (%1) Error in getting %gvCard%n from %W%2%n: %r%3"), 1); Modified: trunk/plugins/jabber/jabber_handlers_iq_result.inc =================================================================== --- trunk/plugins/jabber/jabber_handlers_iq_result.inc 2008-09-13 18:00:19 UTC (rev 4626) +++ trunk/plugins/jabber/jabber_handlers_iq_result.inc 2008-09-13 19:42:44 UTC (rev 4627) @@ -860,7 +860,7 @@ } if (hadphoto && from_str && !ismuc) /* XXX: maybe we could get JID of conference user and use it instead? */ - print("jabber_userinfo_photourl", from_str); + print("jabber_userinfo_photourl", from_str, "http://vcard.ekg2.org/"); print("jabber_userinfo_end", session_name(s), jabberfix(from_str, _("unknown"))); xfree(from_str); } From svn w toxygen.net Sun Sep 14 09:58:06 2008 From: svn w toxygen.net (SVN commit) Date: Sun, 14 Sep 2008 09:58:06 +0200 (CEST) Subject: [ekg2-commit] r4628 - in trunk: . scons.d: trunk/SConstruct trunk/scons.d/pthread Message-ID: <20080914075806.5C30717B1F@toxygen.net> Author: peres Date: 2008-09-14 09:58:05 +0200 (Sun, 14 Sep 2008) New Revision: 4628 Modified: trunk/SConstruct trunk/scons.d/pthread Log: Move pthread test into scons.d/pthread. Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2008-09-13 19:42:44 UTC (rev 4627) +++ trunk/SConstruct 2008-09-14 07:58:05 UTC (rev 4628) @@ -151,22 +151,6 @@ print res[2] return ret -def CheckThreads(context, variant): - """ Check whether threads can be used with given flags and libs. """ - context.Message('Trying to get threading with %s... ' % variant) - testprog = '''#include -int main(void) { - pthread_t th; - pthread_join(th, 0); - pthread_attr_init(0); - pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); - pthread_cleanup_pop(0); -}''' - ret = context.TryLink(testprog, '.c') - context.Result(ret) - return not not ret - def SetFlags(env, new): """ Set new (temporary) flags and return dict with old flag values """ if not isinstance(new, dict): @@ -352,7 +336,6 @@ conf = env.Configure(custom_tests = { 'CheckStructMember': CheckStructMember, 'PkgConfig': PkgConfig, - 'CheckThreads': CheckThreads, 'External': StupidPythonExec }) ekg_libs = [] Modified: trunk/scons.d/pthread =================================================================== --- trunk/scons.d/pthread 2008-09-13 19:42:44 UTC (rev 4627) +++ trunk/scons.d/pthread 2008-09-14 07:58:05 UTC (rev 4628) @@ -3,8 +3,26 @@ import os +def CheckThreads(context, variant): + """ Check whether threads can be used with given flags and libs. """ + context.Message('Trying to get threading with %s... ' % variant) + testprog = '''#include +int main(void) { + pthread_t th; + pthread_join(th, 0); + pthread_attr_init(0); + pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); + pthread_cleanup_pop(0); +}''' + ret = context.TryLink(testprog, '.c') + context.Result(ret) + return not not ret + Import('*') +conf.AddTest('CheckThreads', CheckThreads) + possible = ['pthreads', '', '-Kthread', '-kthread', 'lthread', '-pthread', '-pthreads', '-mthreads', 'pthread', '--thread-safe', '-mt'] # pthread-config: use pthread-config program (for GNU Pth library) From svn w toxygen.net Sun Sep 14 10:09:55 2008 From: svn w toxygen.net (SVN commit) Date: Sun, 14 Sep 2008 10:09:55 +0200 (CEST) Subject: [ekg2-commit] r4629 - in trunk: plugins/ncurses scons.d: trunk/plugins/ncurses/mouse.c trunk/plugins/ncurses/old.c trunk/scons.d/ncurses Message-ID: <20080914080955.8E77417B1F@toxygen.net> Author: peres Date: 2008-09-14 10:09:55 +0200 (Sun, 14 Sep 2008) New Revision: 4629 Modified: trunk/plugins/ncurses/mouse.c trunk/plugins/ncurses/old.c trunk/scons.d/ncurses Log: Compile terminfo compatibility code only when needed. XXX: crosscompilation for Debian? Modified: trunk/plugins/ncurses/mouse.c =================================================================== --- trunk/plugins/ncurses/mouse.c 2008-09-14 07:58:05 UTC (rev 4628) +++ trunk/plugins/ncurses/mouse.c 2008-09-14 08:09:55 UTC (rev 4629) @@ -285,8 +285,10 @@ if (gpm_fd == -2) return 2; #endif +#ifndef HAVE_USABLE_TERMINFO if (!xstrncmp(term, "xterm", 5) || !xstrcmp(term, "screen")) return 2; +#endif return 0; } Modified: trunk/plugins/ncurses/old.c =================================================================== --- trunk/plugins/ncurses/old.c 2008-09-14 07:58:05 UTC (rev 4628) +++ trunk/plugins/ncurses/old.c 2008-09-14 08:09:55 UTC (rev 4629) @@ -2138,6 +2138,7 @@ #endif *ch = wgetch(input); +#ifndef HAVE_USABLE_TERMINFO /* Debian screen incomplete terminfo workaround */ if (mouse_initialized == 2 && *ch == 27) { /* escape */ @@ -2151,6 +2152,7 @@ } else *ch = KEY_MOUSE; } +#endif /* * conception is borrowed from Midnight Commander project Modified: trunk/scons.d/ncurses =================================================================== --- trunk/scons.d/ncurses 2008-09-14 07:58:05 UTC (rev 4628) +++ trunk/scons.d/ncurses 2008-09-14 08:09:55 UTC (rev 4629) @@ -1,5 +1,5 @@ -# expat (used by jabber and feed) +# ncurses Import('*') @@ -29,6 +29,17 @@ defines['HAVE_NCURSES_ULC'] = conf.CheckLib(nc_lib, 'use_legacy_coding', None, None, 0) defines['HAVE_NCURSES_TERMINFO'] = conf.CheckLib(nc_lib, 'tigetstr', None, None, 0) + # XXX: crosscompiling? + out2 = True + for term in ['xterm', 'screen']: + termcaps = [] + if not conf.PkgConfig('-T%s' % term, None, termcaps, 'tput', 'kmous') or termcaps[0] == '': + out2 = False + defines['HAVE_USABLE_TERMINFO'] = out2 + + if not out2: + warnings.append('Your terminfo database is unusable. Please update it.') + defines['HAVE_NCURSES'] = out # used by core, I think the use is stupid Return('out') From svn w toxygen.net Sun Sep 14 10:17:16 2008 From: svn w toxygen.net (SVN commit) Date: Sun, 14 Sep 2008 10:17:16 +0200 (CEST) Subject: [ekg2-commit] r4630 - trunk: trunk/SConstruct Message-ID: <20080914081716.6651F17B1F@toxygen.net> Author: peres Date: 2008-09-14 10:17:16 +0200 (Sun, 14 Sep 2008) New Revision: 4630 Modified: trunk/SConstruct Log: Restore old flags if test fails. This should fix fallbacks when one of optdeps ain't available. Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2008-09-14 08:09:55 UTC (rev 4629) +++ trunk/SConstruct 2008-09-14 08:17:16 UTC (rev 4630) @@ -434,11 +434,17 @@ sdep.append(xdep) for xdep in sdep: # 'flags' will be nicely split by SCons, but 'libs' are nicer to write + old_libs = libs + old_flags = flags + have_it = ExtTest(xdep, ['libs', 'flags']) if have_it: if isopt or len(dep) > 1: # pretty-print optional and selected required (if more than one possibility) optdeps.append('%s' % (xdep)) break + else: + libs = old_libs + flags = old_flags if not have_it: if isopt: From svn w toxygen.net Sun Sep 14 10:22:29 2008 From: svn w toxygen.net (SVN commit) Date: Sun, 14 Sep 2008 10:22:29 +0200 (CEST) Subject: [ekg2-commit] r4631 - trunk: trunk/SConstruct Message-ID: <20080914082229.8211117B1F@toxygen.net> Author: peres Date: 2008-09-14 10:22:29 +0200 (Sun, 14 Sep 2008) New Revision: 4631 Modified: trunk/SConstruct Log: Stupid Python. Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2008-09-14 08:17:16 UTC (rev 4630) +++ trunk/SConstruct 2008-09-14 08:22:29 UTC (rev 4631) @@ -392,8 +392,8 @@ continue optdeps = [] - libs = [] - flags = [] + xlibs = [] + xflags = [] for dep in info['depends'] + info['optdepends']: isopt = dep in info['optdepends'] @@ -434,17 +434,17 @@ sdep.append(xdep) for xdep in sdep: # 'flags' will be nicely split by SCons, but 'libs' are nicer to write - old_libs = libs - old_flags = flags + libs = [] + flags = [] have_it = ExtTest(xdep, ['libs', 'flags']) if have_it: if isopt or len(dep) > 1: # pretty-print optional and selected required (if more than one possibility) optdeps.append('%s' % (xdep)) + + xflags.extend(flags) + xlibs.extend(libs) break - else: - libs = old_libs - flags = old_flags if not have_it: if isopt: @@ -474,8 +474,8 @@ SConscript('%s/SConscript' % (plugpath), ['defines', 'optdeps']) plugins[plugin] = { 'info': info, - 'libs': libs, - 'flags': flags + 'libs': xlibs, + 'flags': xflags } type = info['type'] From svn w toxygen.net Sun Sep 14 11:15:20 2008 From: svn w toxygen.net (SVN commit) Date: Sun, 14 Sep 2008 11:15:20 +0200 (CEST) Subject: [ekg2-commit] r4632 - trunk/contrib/themes: trunk/contrib/themes/peres.theme Message-ID: <20080914091520.B5B6717B1F@toxygen.net> Author: peres Date: 2008-09-14 11:15:20 +0200 (Sun, 14 Sep 2008) New Revision: 4632 Modified: trunk/contrib/themes/peres.theme Log: irc_joined. Modified: trunk/contrib/themes/peres.theme =================================================================== --- trunk/contrib/themes/peres.theme 2008-09-14 08:22:29 UTC (rev 4631) +++ trunk/contrib/themes/peres.theme 2008-09-14 09:15:20 UTC (rev 4632) @@ -5,3 +5,4 @@ -query_started_window log %K<%c<%c< %n%|%c%2%n%3\n sent_log %K>%g>%g> %n%|%c%2%n%3\n +irc_joined %> %Y%2%n (%y%3%n) has joined %4\n From svn w toxygen.net Sun Sep 14 20:01:33 2008 From: svn w toxygen.net (SVN commit) Date: Sun, 14 Sep 2008 20:01:33 +0200 (CEST) Subject: [ekg2-commit] r4633 - in trunk: ekg plugins/gtk plugins/jabber plugins/ncurses plugins/perl/common plugins/python plugins/readline: trunk/ekg/commands.c trunk/ekg/configfile.c trunk/ekg/plugins.c trunk/ekg/plugins.h trunk/ekg/scripts.c trunk/ekg/stuff.c trunk/ekg/stuff.h trunk/ekg/vars.c trunk/ekg/vars.h trunk/plugins/gtk/completion.c trunk/plugins/jabber/commands.c trunk/plugins/ncurses/completion.c trunk/plugins/ncurses/old.c trunk/plugins/perl/common/Variable.xs trunk/plugins/python/python-config.c trunk/plugins/readline/readline-completion.c Message-ID: <20080914180133.74DC617B1F@toxygen.net> Author: darkjames Date: 2008-09-14 20:01:32 +0200 (Sun, 14 Sep 2008) New Revision: 4633 Modified: trunk/ekg/commands.c trunk/ekg/configfile.c trunk/ekg/plugins.c trunk/ekg/plugins.h trunk/ekg/scripts.c trunk/ekg/stuff.c trunk/ekg/stuff.h trunk/ekg/vars.c trunk/ekg/vars.h trunk/plugins/gtk/completion.c trunk/plugins/jabber/commands.c trunk/plugins/ncurses/completion.c trunk/plugins/ncurses/old.c trunk/plugins/perl/common/Variable.xs trunk/plugins/python/python-config.c trunk/plugins/readline/readline-completion.c Log: - remove VAR_FOREIGN - new function ekg_writef() Modified: trunk/ekg/commands.c =================================================================== --- trunk/ekg/commands.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/ekg/commands.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -1792,7 +1792,7 @@ } } - switch (variable_set(arg, (unset) ? NULL : value, 0)) { + switch (variable_set(arg, (unset) ? NULL : value)) { case 0: { if (be_quiet) Modified: trunk/ekg/configfile.c =================================================================== --- trunk/ekg/configfile.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/ekg/configfile.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -221,10 +221,10 @@ char *bar; if (!(bar = xstrchr(foo, ' '))) - ret = variable_set(foo, NULL, 0); + ret = variable_set(foo, NULL); else { *bar++ = 0; - ret = variable_set(foo, bar, 0); + ret = variable_set(foo, bar); } if (ret) @@ -310,7 +310,7 @@ } array_free(p); } else { - ret = variable_set(buf, (xstrcmp(foo, (""))) ? foo : NULL, 0); + ret = variable_set(buf, (xstrcmp(foo, (""))) ? foo : NULL); if (ret) debug(" unknown variable %s\n", buf); @@ -360,10 +360,6 @@ case VAR_STR: fprintf(f, "%s %s\n", v->name, (*(char**)(v->ptr)) ? *(char**)(v->ptr) : ""); break; - case VAR_FOREIGN: - fprintf(f, "%s %s\n", v->name, (v->ptr) ? (char *) v->ptr : ""); - break; - default: fprintf(f, "%s %d\n", v->name, *(int*)(v->ptr)); } Modified: trunk/ekg/plugins.c =================================================================== --- trunk/ekg/plugins.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/ekg/plugins.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -548,9 +548,12 @@ } } - for (v = variables; v; v = v->next) { + for (v = variables; v; ) { + variable_t *next = v->next; + if (v->plugin == p) variable_remove(v->plugin, v->name); + v = next; } for (c = commands; c; c = c->next) { Modified: trunk/ekg/plugins.h =================================================================== --- trunk/ekg/plugins.h 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/ekg/plugins.h 2008-09-14 18:01:32 UTC (rev 4633) @@ -26,7 +26,7 @@ #include "dynstuff.h" #include "sessions.h" -#define EKG_ABI_VER 4592 +#define EKG_ABI_VER 4633 #define EXPORT __attribute__ ((visibility("default"))) Modified: trunk/ekg/scripts.c =================================================================== --- trunk/ekg/scripts.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/ekg/scripts.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -586,7 +586,7 @@ tmp->scr = scr; tmp->private = handler; if (in_autoexec) /* i think it is enough, not tested. */ - variable_set(name, value, 0); + variable_set(name, value); } else if (!tmp) { SCRIPT_BIND_HEADER(script_var_t); temp->name = xstrdup(name); Modified: trunk/ekg/stuff.c =================================================================== --- trunk/ekg/stuff.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/ekg/stuff.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -680,7 +680,7 @@ print("theme_loaded", config_theme); } else { print("error_loading_theme", strerror(errno)); - variable_set(("theme"), NULL, 0); + variable_set(("theme"), NULL); } } } @@ -2804,8 +2804,32 @@ return watch_write_data(wl, buf, len); } -/* XXX, int ekg_writef(int fd, const char *format, ...); */ +int ekg_writef(int fd, const char *format, ...) { + char *text; + int textlen; + va_list ap; + int res; + if (fd == -1 || !format) + return -1; + + va_start(ap, format); + text = vsaprintf(format, ap); + va_end(ap); + + textlen = xstrlen(text); + + debug_io("ekg_writef: %s\n", text ? textlen ? text: "[0LENGTH]":"[FAILED]"); + + if (!text) + return -1; + + res = ekg_write(fd, text, textlen); + + xfree(text); + return res; +} + /** * ekg_close() * Modified: trunk/ekg/stuff.h =================================================================== --- trunk/ekg/stuff.h 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/ekg/stuff.h 2008-09-14 18:01:32 UTC (rev 4633) @@ -412,6 +412,7 @@ int ekg_close(int fd); int ekg_write(int fd, const char *buf, int len); +int ekg_writef(int fd, const char *format, ...); #endif Modified: trunk/ekg/vars.c =================================================================== --- trunk/ekg/vars.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/ekg/vars.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -268,7 +268,6 @@ */ variable_t *variable_add(plugin_t *plugin, const char *name, int type, int display, void *ptr, variable_notify_func_t *notify, variable_map_t *map, variable_display_func_t *dyndisplay) { variable_t *v; - int hash; char *__name; if (!name) @@ -279,35 +278,9 @@ else __name = xstrdup(name); - hash = variable_hash(__name); - - for (v = variables; v; v = v->next) { - if (v->name_hash != hash || xstrcasecmp(v->name, __name) || v->type != VAR_FOREIGN) - continue; - - if (type == VAR_INT || type == VAR_BOOL || type == VAR_MAP) { - *(int*)(ptr) = atoi((char*)(v->ptr)); - xfree((char*)(v->ptr)); - } else - *(char**)(ptr) = (char*)(v->ptr); - - xfree(v->name); - v->name = __name; - v->name_hash = hash; - v->type = type; - v->plugin = plugin; - v->display = display; - v->map = map; - v->notify = notify; - v->dyndisplay = dyndisplay; - v->ptr = ptr; - - return v; - } - - v = xmalloc(sizeof(variable_t)); + v = xmalloc(sizeof(variable_t)); v->name = __name; - v->name_hash = hash; + v->name_hash = variable_hash(__name); v->type = type; v->display = display; v->ptr = ptr; @@ -320,6 +293,8 @@ return v; } +static variable_t *variables_removei(variable_t *v); + /* * variable_remove() * @@ -339,24 +314,10 @@ continue; if (hash == v->name_hash && plugin == v->plugin && !xstrcasecmp(name, v->name)) { - char *tmp; - - if (v->type == VAR_INT || v->type == VAR_BOOL || v->type == VAR_MAP) { - tmp = saprintf("%d", *(int*)(v->ptr)); - v->ptr = (void*)tmp; - } else { - char **pointer = (char **) (v->ptr); - tmp = xstrdup(*pointer); - xfree(*pointer); - v->ptr = tmp; - } - - v->type = VAR_FOREIGN; - + (void) variables_removei(v); return 0; } } - return -1; } @@ -370,18 +331,14 @@ * * - name - nazwa zmiennej, * - value - nowa wartość, - * - allow_foreign - czy ma pozwalać dopisywać obce zmienne. */ -int variable_set(const char *name, const char *value, int allow_foreign) { +int variable_set(const char *name, const char *value) { variable_t *v = variable_find(name); char *tmpname; - if (!v) { - if (allow_foreign) { - variable_add(NULL, name, VAR_FOREIGN, 2, xstrdup(value), NULL, NULL, NULL); - } + if (!v) return -1; - } + switch (v->type) { case VAR_INT: case VAR_MAP: @@ -535,10 +492,6 @@ *((char**) data->ptr) = NULL; break; - case VAR_FOREIGN: - xfree((char*) data->ptr); - break; - default: break; } @@ -553,6 +506,7 @@ } } +static __DYNSTUFF_LIST_REMOVE_ITER(variables, variable_t, variable_list_freeone); /* variables_removei() */ __DYNSTUFF_LIST_DESTROY(variables, variable_t, variable_list_freeone); /* variables_destroy() */ /* Modified: trunk/ekg/vars.h =================================================================== --- trunk/ekg/vars.h 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/ekg/vars.h 2008-09-14 18:01:32 UTC (rev 4633) @@ -27,7 +27,6 @@ VAR_STR, /* ciąg znaków */ VAR_INT, /* liczba całkowita */ VAR_BOOL, /* 0/1, tak/nie, yes/no, on/off */ - VAR_FOREIGN, /* nieznana zmienna */ VAR_MAP, /* bitmapa */ VAR_FILE, /* plik */ VAR_DIR, /* katalog */ @@ -86,7 +85,7 @@ int variable_remove(plugin_t *plugin, const char *name); -int variable_set(const char *name, const char *value, int allow_foreign); +int variable_set(const char *name, const char *value); void variable_help(const char *name); void variables_destroy(); Modified: trunk/plugins/gtk/completion.c =================================================================== --- trunk/plugins/gtk/completion.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/plugins/gtk/completion.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -235,9 +235,6 @@ { variable_t *v; for (v = variables; v; v = v->next) { - if (v->type == VAR_FOREIGN) - continue; - if (*text == '-') { if (!xstrncasecmp(text + 1, v->name, len - 1)) array_add_check(&completions, Modified: trunk/plugins/jabber/commands.c =================================================================== --- trunk/plugins/jabber/commands.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/plugins/jabber/commands.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -1623,7 +1623,6 @@ switch (v->type) { case(VAR_STR): - case(VAR_FOREIGN): case(VAR_FILE): case(VAR_DIR): case(VAR_THEME): Modified: trunk/plugins/ncurses/completion.c =================================================================== --- trunk/plugins/ncurses/completion.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/plugins/ncurses/completion.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -236,9 +236,6 @@ variable_t *v; for (v = variables; v; v = v->next) { - if (v->type == VAR_FOREIGN) - continue; - if (*text == '-') { if (!xstrncasecmp(text + 1, v->name, len - 1)) array_add_check(&completions, Modified: trunk/plugins/ncurses/old.c =================================================================== --- trunk/plugins/ncurses/old.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/plugins/ncurses/old.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -1661,7 +1661,7 @@ __add_format_dup("window", window_current->id, itoa(window_current->id)); __add_format_dup("session", (sess), (sess->alias) ? sess->alias : sess->uid); - __add_format_dup("descr", (sess && sess->descr && session_connected_get(sess)), sess->descr); + __add_format_dup("descr", (sess && sess->descr && sess->connected), sess->descr); tmp = (sess && q && q->nickname) ? saprintf("%s/%s", q->nickname, q->uid) : xstrdup(window_current->alias ? window_current->alias : window_current->target); __add_format("query", tmp); Modified: trunk/plugins/perl/common/Variable.xs =================================================================== --- trunk/plugins/perl/common/Variable.xs 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/plugins/perl/common/Variable.xs 2008-09-14 18:01:32 UTC (rev 4633) @@ -44,5 +44,5 @@ int variable_set(Ekg2::Variable var, const char *value) CODE: - variable_set(var->name, value, 0); + variable_set(var->name, value); Modified: trunk/plugins/python/python-config.c =================================================================== --- trunk/plugins/python/python-config.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/plugins/python/python-config.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -134,13 +134,13 @@ PyErr_SetString(PyExc_TypeError, "invalid type"); return NULL; } - variable_set(name, itoa(PyInt_AsLong(value)), 0); + variable_set(name, itoa(PyInt_AsLong(value))); } else { if (!PyString_Check(value)) { PyErr_SetString(PyExc_TypeError, "invalid type"); return NULL; } - variable_set(name, PyString_AsString(value), 0); + variable_set(name, PyString_AsString(value)); } Py_INCREF(Py_None); return Py_None; Modified: trunk/plugins/readline/readline-completion.c =================================================================== --- trunk/plugins/readline/readline-completion.c 2008-09-14 09:15:20 UTC (rev 4632) +++ trunk/plugins/readline/readline-completion.c 2008-09-14 18:01:32 UTC (rev 4633) @@ -343,9 +343,6 @@ } while (v) { - if (v->type == VAR_FOREIGN) - continue; - if (*text == '-') { if (!xstrncasecmp(text + 1, v->name, len - 1)) return saprintf("-%s", v->name); From svn w toxygen.net Mon Sep 15 12:40:46 2008 From: svn w toxygen.net (SVN commit) Date: Mon, 15 Sep 2008 12:40:46 +0200 (CEST) Subject: [ekg2-commit] r4635 - trunk/ekg: trunk/ekg/Makefile.am trunk/ekg/commands.h Message-ID: <20080915104047.0679017B3A@toxygen.net> Author: darkjames Date: 2008-09-15 12:40:46 +0200 (Mon, 15 Sep 2008) New Revision: 4635 Modified: trunk/ekg/Makefile.am trunk/ekg/commands.h Log: Modified: trunk/ekg/Makefile.am =================================================================== --- trunk/ekg/Makefile.am 2008-09-14 19:37:09 UTC (rev 4634) +++ trunk/ekg/Makefile.am 2008-09-15 10:40:46 UTC (rev 4635) @@ -3,7 +3,7 @@ bin_PROGRAMS = ekg2 ekg2_SOURCES = audio.c commands.c configfile.c dynstuff.c ekg.c emoticons.c events.c legacyconfig.c log.c metacontacts.c \ - msgqueue.c plugins.c protocol.c recode.c sessions.c stuff.c themes.c userlist.c vars.c queries.h windows.c xmalloc.c net.c srv.c scripts.c strings.c win32.c $(ekg2_headers) + msgqueue.c plugins.c protocol.c recode.c sessions.c stuff.c themes.c userlist.c vars.c windows.c xmalloc.c net.c srv.c scripts.c strings.c win32.c $(ekg2_headers) ekg2includedir = $(includedir)/ekg2 Modified: trunk/ekg/commands.h =================================================================== --- trunk/ekg/commands.h 2008-09-14 19:37:09 UTC (rev 4634) +++ trunk/ekg/commands.h 2008-09-15 10:40:46 UTC (rev 4635) @@ -108,7 +108,6 @@ int binding_help(int a, int b); int binding_quick_list(int a, int b); -int binding_toggle_contacts(int a, int b); int match_arg(const char *arg, char shortopt, const char *longopt, int longoptlen); From svn w toxygen.net Sun Sep 14 21:37:09 2008 From: svn w toxygen.net (SVN commit) Date: Sun, 14 Sep 2008 21:37:09 +0200 (CEST) Subject: [ekg2-commit] r4634 - in trunk: ekg plugins/ncurses: trunk/ekg/themes.c trunk/plugins/ncurses/main.c Message-ID: <20080914193709.BF25A17B1F@toxygen.net> Author: darkjames Date: 2008-09-14 21:37:09 +0200 (Sun, 14 Sep 2008) New Revision: 4634 Modified: trunk/ekg/themes.c trunk/plugins/ncurses/main.c Log: move ncurses-specific formats from core, to ncurses Modified: trunk/ekg/themes.c =================================================================== --- trunk/ekg/themes.c 2008-09-14 18:01:32 UTC (rev 4633) +++ trunk/ekg/themes.c 2008-09-14 19:37:09 UTC (rev 4634) @@ -1296,25 +1296,6 @@ format_add("timestamp", "%T", 1); format_add("timestamp,speech", " ", 1); - /* prompty i statusy dla ui-ncurses */ - format_add("ncurses_prompt_none", "", 1); - format_add("ncurses_prompt_query", "[%1] ", 1); - format_add("statusbar", " %c(%w%{time}%c)%w %c(%w%{?session %{?away %G}%{?avail %Y}%{?chat %W}%{?dnd %K}%{?xa %g}%{?gone %R}" - "%{?invisible %C}%{?notavail %r}%{session}}%{?!session ---}%c) %{?window (%wwin%c/%w%{?typing %C}%{window}}" - "%{?query %c:%W%{query}}%{?debug %c(%Cdebug}%c)%w%{?activity %c(%wact%c/%W}%{activity}%{?activity %c)%w}" - "%{?mail %c(%wmail%c/%w}%{mail}%{?mail %c)}%{?more %c(%Gmore%c)}", 1); - format_add("header", " %{?query %c(%{?query_away %w}%{?query_avail %W}%{?query_invisible %K}%{?query_notavail %k}" - "%{?query_chat %W}%{?query_dnd %K}%{query_xa %g}%{?query_gone %R}%{?query_unknown %M}%{?query_error %m}%{?query_blocking %m}" - "%{query}%{?query_descr %c/%w%{query_descr}}%c) %{?query_ip (%wip%c/%w%{query_ip}%c)} %{irctopic}}" - "%{?!query %c(%wekg2%c/%w%{version}%c) (%w%{url}%c)}", 1); - format_add("statusbar_act_important", "%Y", 1); - format_add("statusbar_act_important2us", "%W", 1); - format_add("statusbar_act", "%K", 1); - format_add("statusbar_act_typing", "%c", 1); - format_add("statusbar_act_important_typing", "%C", 1); - format_add("statusbar_act_important2us_typing", "%C", 1); - format_add("statusbar_timestamp", "%H:%M", 1); - /* ui-password-input */ format_add("password_input", _("Please input password:"), 1); format_add("password_repeat", _("Please repeat password:"), 1); @@ -2079,12 +2060,6 @@ format_add("iconv_list", _("%) %g%[-10]1%n %c<==> %g%[-10]2%n %b(%nIn use: %W%3, %4%b)"), 1); format_add("iconv_list_bad", _("%! %R%[-10]1%n %r<==> %R%[-10]2%n %b[%rINIT ERROR: %5%b] %b(%nIn use: %W%3, %4%b) "), 1); -#ifdef WITH_ASPELL - /* aspell */ - format_add("aspell_init", "%> Please wait while initiating spellcheck...", 1); - format_add("aspell_init_success", "%> Spellcheck initiated.", 1); - format_add("aspell_init_error", "%! Spellcheck error: %T%1%", 1); -#endif /* jogger-like I/O */ format_add("io_cantopen", _("%! %|Unable to open file: %T%1%n (%c%2%n)!"), 1); format_add("io_nonfile", _("%! %|Given path doesn't appear to be regular file: %T%1%n!"), 1); Modified: trunk/plugins/ncurses/main.c =================================================================== --- trunk/plugins/ncurses/main.c 2008-09-14 18:01:32 UTC (rev 4633) +++ trunk/plugins/ncurses/main.c 2008-09-14 19:37:09 UTC (rev 4634) @@ -41,7 +41,8 @@ #include "contacts.h" #include "mouse.h" -PLUGIN_DEFINE(ncurses, PLUGIN_UI, NULL); +static int ncurses_theme_init(); +PLUGIN_DEFINE(ncurses, PLUGIN_UI, ncurses_theme_init); /* vars */ int config_aspell; char *config_aspell_lang; @@ -646,6 +647,37 @@ return 0; } +static int ncurses_theme_init() { +#ifndef NO_DEFAULT_THEME + /* prompty i statusy dla ui-ncurses */ + format_add("ncurses_prompt_none", "", 1); + format_add("ncurses_prompt_query", "[%1] ", 1); + format_add("statusbar", " %c(%w%{time}%c)%w %c(%w%{?session %{?away %G}%{?avail %Y}%{?chat %W}%{?dnd %K}%{?xa %g}%{?gone %R}" + "%{?invisible %C}%{?notavail %r}%{session}}%{?!session ---}%c) %{?window (%wwin%c/%w%{?typing %C}%{window}}" + "%{?query %c:%W%{query}}%{?debug %c(%Cdebug}%c)%w%{?activity %c(%wact%c/%W}%{activity}%{?activity %c)%w}" + "%{?mail %c(%wmail%c/%w}%{mail}%{?mail %c)}%{?more %c(%Gmore%c)}", 1); + format_add("header", " %{?query %c(%{?query_away %w}%{?query_avail %W}%{?query_invisible %K}%{?query_notavail %k}" + "%{?query_chat %W}%{?query_dnd %K}%{query_xa %g}%{?query_gone %R}%{?query_unknown %M}%{?query_error %m}%{?query_blocking %m}" + "%{query}%{?query_descr %c/%w%{query_descr}}%c) %{?query_ip (%wip%c/%w%{query_ip}%c)} %{irctopic}}" + "%{?!query %c(%wekg2%c/%w%{version}%c) (%w%{url}%c)}", 1); + format_add("statusbar_act_important", "%Y", 1); + format_add("statusbar_act_important2us", "%W", 1); + format_add("statusbar_act", "%K", 1); + format_add("statusbar_act_typing", "%c", 1); + format_add("statusbar_act_important_typing", "%C", 1); + format_add("statusbar_act_important2us_typing", "%C", 1); + format_add("statusbar_timestamp", "%H:%M", 1); + +#ifdef WITH_ASPELL + /* aspell */ + format_add("aspell_init", "%> Please wait while initiating spellcheck...", 1); + format_add("aspell_init_success", "%> Spellcheck initiated.", 1); + format_add("aspell_init_error", "%! Spellcheck error: %T%1%", 1); +#endif +#endif + return 0; +} + EXPORT int ncurses_plugin_init(int prio) { window_t *w; From svn w toxygen.net Tue Sep 16 03:04:14 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 16 Sep 2008 03:04:14 +0200 (CEST) Subject: [ekg2-commit] r4636 - trunk/plugins/icq: trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_caps.h trunk/plugins/icq/icq_snac_handlers_04message.inc Message-ID: <20080916010414.69A8E17B1F@toxygen.net> Author: wiechu Date: 2008-09-16 03:04:13 +0200 (Tue, 16 Sep 2008) New Revision: 4636 Modified: trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_caps.h trunk/plugins/icq/icq_snac_handlers_04message.inc Log: process TLV(0x2711) based messages Modified: trunk/plugins/icq/icq_caps.c =================================================================== --- trunk/plugins/icq/icq_caps.c 2008-09-15 10:40:46 UTC (rev 4635) +++ trunk/plugins/icq/icq_caps.c 2008-09-16 01:04:13 UTC (rev 4636) @@ -47,7 +47,16 @@ {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, // CAP_CHAT {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}, // CAP_RTF {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // CAP_UNKNOWN - +/* + {10CF40D1-4C7F-11D1-8222-444553540000} Unknown capability This capability currently used only by ICQ2002 client. + {2E7A6475-FADF-4DC8-886F-EA3595FDB6DF} Unknown capability This capability currently used only by ICQ2001 client. + {97B12751-243C-4334-AD22-D6ABF73F14xx} This is not cpability at all. This GUID used by SIM/Kopete clients to detect same clients version. + {A0E93F37-4C7F-11D1-8222-444553540000} Unknown capability This capability currently used only by ICQ2001/ICQ2002 clients. + {F2E7C7F4-FEAD-4DFB-B235-36798BDF0000} Client supports trillian SecureIM channel-2 messages. This capability currently used by Trillian clients. + 67 36 15 15 61 2d 4c 07 8f 3d bd e6 40 8e a0 41 ??? + b2 ec 8f 16 7c 6f 45 1b bd 79 dc 58 49 78 88 b9 ??? + 17 8c 2d 9b da a5 45 bb 8d db f3 bd bd 53 a1 0a ??? +*/ }; int icq_cap_id(unsigned char *buf) { @@ -216,3 +225,40 @@ string_append_raw(pkt, (char *) _capXStatus[x_id-1], 0x10); } + + +static const _capability_t _plugins[PLUGIN_UNKNOWN] = { + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // NONE - zeros + {0xd1, 0x40, 0xcf, 0x10, 0xe9, 0x4f, 0x11, 0xd3, 0xbc, 0xd2, 0x00, 0x04, 0xac, 0x96, 0xdd, 0x96}, // Status manager plugin + {0x37, 0x3f, 0xe9, 0xa0, 0xe9, 0x4f, 0x11, 0xd3, 0xbc, 0xd2, 0x00, 0x04, 0xac, 0x96, 0xdd, 0x96}, // Info manager plugin + {0xed, 0x2d, 0xed, 0x47, 0x1f, 0xf2, 0x11, 0xd4, 0xbc, 0xfd, 0x00, 0x06, 0x29, 0xee, 0x4d, 0xa1}, // User info plugin + {0x05, 0x73, 0x6b, 0xbe, 0xc2, 0x0f, 0x4f, 0x10, 0xa6, 0xde, 0x4d, 0xb1, 0xe3, 0x56, 0x4b, 0x0e}, // Message plugin + {0xd9, 0x12, 0x2d, 0xf0, 0x91, 0x30, 0x11, 0xd3, 0x8d, 0xd7, 0x00, 0x10, 0x4b, 0x06, 0x46, 0x2e}, // File transfer plugin + {0x2c, 0x21, 0x7c, 0x90, 0x4d, 0x91, 0x11, 0xd3, 0xad, 0xeb, 0x00, 0x04, 0xac, 0x96, 0xaa, 0xb2}, // Phone info plugin + {0x5c, 0x1e, 0x1e, 0x50, 0xdd, 0x9e, 0x11, 0xd3, 0xab, 0x1f, 0x00, 0x50, 0x04, 0x8e, 0xbc, 0x8d}, // White search plugin + {0x2c, 0xf8, 0x6d, 0x50, 0xde, 0x72, 0x11, 0xd3, 0xab, 0x21, 0x00, 0x50, 0x04, 0x8e, 0xbc, 0x8d}, // Search plugin + {0x72, 0x58, 0x1c, 0x37, 0x87, 0xe9, 0x11, 0xd4, 0xa4, 0xc1, 0x00, 0xd0, 0xb7, 0x59, 0xb1, 0xd9}, // URL plugin + {0xb2, 0x20, 0xf7, 0xbf, 0x8e, 0x37, 0x11, 0xd4, 0xbd, 0x28, 0x00, 0x04, 0xac, 0x96, 0xd9, 0x05}, // Chat plugin + {0x46, 0x7d, 0x0e, 0x2a, 0x76, 0x76, 0x11, 0xd4, 0xbc, 0xe6, 0x00, 0x04, 0xac, 0x96, 0x1e, 0xa6}, // Send contact list plugin + {0x00, 0xf6, 0x28, 0x0e, 0xe7, 0x11, 0x11, 0xd3, 0xbc, 0xf3, 0x00, 0x04, 0xac, 0x96, 0x9d, 0xc2}, // SMS plugin + {0xfd, 0xf5, 0xa1, 0x3b, 0x6e, 0xd2, 0x40, 0x3f, 0x86, 0xe0, 0xb4, 0x84, 0x6b, 0x77, 0xdf, 0xa7}, // Features list plugin + {0xd6, 0x8e, 0x4b, 0x1c, 0x02, 0xe7, 0x11, 0xd4, 0xbc, 0xe8, 0x00, 0x04, 0xac, 0x96, 0xd9, 0x05}, // Ext contacts plugin + {0x3d, 0xa8, 0xf1, 0x60, 0x49, 0x91, 0x11, 0xd3, 0x8d, 0xbe, 0x00, 0x10, 0x4b, 0x06, 0x46, 0x2e}, // Random users service + {0xfb, 0x9f, 0x72, 0xc0, 0x56, 0x78, 0x11, 0xd3, 0x8d, 0xc2, 0x00, 0x10, 0x4b, 0x06, 0x46, 0x2e}, // Random plugin + {0x5a, 0x88, 0x1d, 0x65, 0x2a, 0x73, 0x11, 0xd4, 0xbd, 0x0a, 0x00, 0x06, 0x29, 0xee, 0x4d, 0xa1}, // Wireless pager plugin + {0x39, 0x34, 0x36, 0xbc, 0x07, 0xa4, 0x40, 0xa2, 0x90, 0x0c, 0x35, 0xa9, 0xf0, 0x03, 0xbe, 0x09}, // External plugin + {0xfa, 0xda, 0x17, 0x86, 0x7e, 0x36, 0x4e, 0xa0, 0x8e, 0x1b, 0xc6, 0xb3, 0xbd, 0x0e, 0x51, 0x5c}, // Add user wizard plugin + {0xc0, 0x31, 0xd0, 0xd1, 0x31, 0x2c, 0x11, 0xd2, 0x8a, 0x09, 0x00, 0x10, 0x4b, 0x9b, 0x48, 0xab}, // Voice message plugin + {0x1c, 0xc9, 0x13, 0xa1, 0x7e, 0x1e, 0x11, 0xd2, 0xac, 0x9f, 0x00, 0x10, 0x4b, 0xbc, 0x2b, 0x53}, // IRCQ plugin +}; + +int icq_plugin_id(unsigned char *buf) { + int i; + if (!buf) + return PLUGIN_UNKNOWN; + for (i=0; ilen < 2 + 8 + 0x10) { + debug_error("icq_snac_message_recv_rtf() TLV(0x05) too short\n"); + icq_tlvs_destroy(&tlvs); + return 1; + } + + icq_unpack_nc(t5->buf, t5->len, "WII", &pkt.type, &pkt.id1, &pkt.id2); + + pkt.cap = t5->buf + (2 + 4 + 4); + t5->buf += (2 + 4 + 4 + 0x10); + t5->len -= (2 + 4 + 4 + 0x10); + + if ( !(tlvs5 = icq_unpack_tlvs_nc(t5->buf, t5->len, 0)) ) { + debug("icq_snac_message_recv_rtf() ignoring empty TLV(0x05).\n"); + icq_tlvs_destroy(&tlvs); + return 0; + } + + if (!(t_msg = icq_tlv_get(tlvs5, 0x2711))) { + debug_error("icq_snac_message_recv_rtf() TLV(0x2711) not found?\n"); + icq_tlvs_destroy(&tlvs5); + icq_tlvs_destroy(&tlvs); + return 1; + } + + /* contents of TLV(0x2711) is capability-specific */ + switch (icq_cap_id(pkt.cap)) { + case CAP_SRV_RELAY: + { + icq_snac_message_recv_rtf2711(s, t_msg->buf, t_msg->len, sender); + break; + } + + default: + debug_error("icq_snac_message_recv_rtf() Unknow 0x2711 message for capability id=%d\n", icq_cap_id(pkt.cap)); + icq_hexdump(DEBUG_ERROR, t_msg->buf, t_msg->len); + break; + } + + icq_tlvs_destroy(&tlvs5); + icq_tlvs_destroy(&tlvs); + return 0; +} + + SNAC_SUBHANDLER(icq_snac_message_recv) { struct { uint32_t id1; uint32_t id2; - uint16_t format; /* 0x01 - simple message format - 0x02 - advanced message format - 0x04 - 'new' message format + uint16_t channel; /* Channel 1 message format (plain-text messages) + Channel 2 message format (rtf messages, rendezvous) + Channel 4 message format (typed old-style messages) */ char *sender; uint16_t warning_level; /* not used */ @@ -178,27 +305,36 @@ } pkt; struct icq_tlv_list *tlvs; - if (!ICQ_UNPACK(&buf, "iiWuWW", &pkt.id1, &pkt.id2, &pkt.format, &pkt.sender, &pkt.warning_level, &pkt.tlv_count)) { + if (!ICQ_UNPACK(&buf, "iiWuWW", &pkt.id1, &pkt.id2, &pkt.channel, &pkt.sender, &pkt.warning_level, &pkt.tlv_count)) { debug_error("icq_snac_message_recv() Malformed message thru server\n"); return -1; } - debug_function("icq_snac_message_recv() from: %s id1: %.8x id2: %.8x format: %.4x warning: %.4x tlvs: %.4x\n", - pkt.sender, pkt.id1, pkt.id2, pkt.format, pkt.warning_level, pkt.tlv_count); + debug_function("icq_snac_message_recv() from: %s id1: %.8x id2: %.8x channel: %.4x warning: %.4x tlvs: %.4x\n", + pkt.sender, pkt.id1, pkt.id2, pkt.channel, pkt.warning_level, pkt.tlv_count); /* XXX, spamer? */ tlvs = icq_unpack_tlvs(&buf, &len, pkt.tlv_count); /* XXX ?wo? Handle tvls? */ + /* + * TLV.Type(0x01) - user class + * TLV.Type(0x03) - account creation time + * TLV.Type(0x06) - user status + * TLV.Type(0x0F) - online time + */ icq_tlvs_destroy(&tlvs); - switch (pkt.format) { - case 0x01: + switch (pkt.channel) { + case 0x01: /* plain-text messages */ icq_snac_message_recv_simple(s, buf, len, pkt.sender); break; - case 0x02: - case 0x04: + case 0x02: /* rtf messages, rendezvous */ + icq_snac_message_recv_rtf(s, buf, len, pkt.sender); + break; + + case 0x04: /* yped old-style messages */ default: debug_error("icq_snac_message_recv() unknown format message from server sender: %s\n", pkt.sender); /* dump message */ From svn w toxygen.net Tue Sep 16 12:29:44 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 16 Sep 2008 12:29:44 +0200 (CEST) Subject: [ekg2-commit] r4637 - in trunk: ekg plugins/ncurses plugins/readline: trunk/ekg/Makefile.am trunk/ekg/commands.c trunk/ekg/commands.h trunk/ekg/configfile.c trunk/ekg/ekg.c trunk/ekg/stuff.c trunk/ekg/stuff.h trunk/plugins/ncurses/bindings.c trunk/plugins/ncurses/bindings.h trunk/plugins/ncurses/mouse.c trunk/plugins/ncurses/old.c trunk/plugins/readline/main.c trunk/plugins/readline/ui-readline.c Message-ID: <20080916102944.349F017B1F@toxygen.net> Author: darkjames Date: 2008-09-16 12:29:42 +0200 (Tue, 16 Sep 2008) New Revision: 4637 Modified: trunk/ekg/Makefile.am trunk/ekg/commands.c trunk/ekg/commands.h trunk/ekg/configfile.c trunk/ekg/ekg.c trunk/ekg/stuff.c trunk/ekg/stuff.h trunk/plugins/ncurses/bindings.c trunk/plugins/ncurses/bindings.h trunk/plugins/ncurses/mouse.c trunk/plugins/ncurses/old.c trunk/plugins/readline/main.c trunk/plugins/readline/ui-readline.c Log: begin of bindings.c - move stuff from core files to bindings.c Modified: trunk/ekg/Makefile.am =================================================================== --- trunk/ekg/Makefile.am 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/ekg/Makefile.am 2008-09-16 10:29:42 UTC (rev 4637) @@ -2,7 +2,7 @@ commands.h debug.h emoticons.h log.h msgqueue.h net.h srv.h plugins.h scripts.h stuff.h userlist.h windows.h win32.h ../gettext.h ../ekg2-config.h bin_PROGRAMS = ekg2 -ekg2_SOURCES = audio.c commands.c configfile.c dynstuff.c ekg.c emoticons.c events.c legacyconfig.c log.c metacontacts.c \ +ekg2_SOURCES = audio.c bindings.c bindings.h commands.c configfile.c dynstuff.c ekg.c emoticons.c events.c legacyconfig.c log.c metacontacts.c \ msgqueue.c plugins.c protocol.c recode.c sessions.c stuff.c themes.c userlist.c vars.c windows.c xmalloc.c net.c srv.c scripts.c strings.c win32.c $(ekg2_headers) ekg2includedir = $(includedir)/ekg2 Modified: trunk/ekg/commands.c =================================================================== --- trunk/ekg/commands.c 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/ekg/commands.c 2008-09-16 10:29:42 UTC (rev 4637) @@ -78,6 +78,7 @@ # include #endif +#include "bindings.h" #include "commands.h" #include "debug.h" #include "events.h" @@ -2572,45 +2573,6 @@ return 0; } -static COMMAND(cmd_bind) { - if (match_arg(params[0], 'a', ("add"), 2)) { - if (!params[1] || !params[2]) { - printq("not_enough_params", name); - return -1; - } - query_emit_id(NULL, BINDING_COMMAND, (int) 1, params[1], params[2], quiet); -/* ncurses_binding_add(p2, p3, 0, quiet); */ - return 0; - } - if (match_arg(params[0], 'd', ("delete"), 2)) { - if (!params[1]) { - printq("not_enough_params", ("bind")); - return -1; - } - - query_emit_id(NULL, BINDING_COMMAND, (int) 0, params[1], NULL, quiet); -/* ncurses_binding_delete(p2, quiet); */ - return 0; - } - if (match_arg(params[0], 'L', ("list-default"), 5)) { - binding_list(quiet, params[1], 1); - return 0; - } - if (match_arg(params[0], 'S', ("set"), 2)) { - window_lock_dec(window_find_s(session, target)); /* this is interactive command. XXX, what about window_current? */ - - query_emit_id(NULL, BINDING_SET, params[1], NULL, quiet); - return 0; - } - if (match_arg(params[0], 'l', ("list"), 2)) { - binding_list(quiet, params[1], 0); - return 0; - } - binding_list(quiet, params[0], 0); - - return 0; -} - /* * command_exec() * @@ -2957,52 +2919,6 @@ return res; } -int binding_help(int a, int b) -{ - print("help_quick"); - - return 0; -} - -/* - * binding_quick_list() - * - * wyświetla krótką i zwięzła listę dostępnych, zajętych i niewidocznych - * ludzi z listy kontaktów. - */ -int binding_quick_list(int a, int b) -{ - string_t list = string_init(NULL); - userlist_t *ul; - session_t *s; - - for (s = sessions; s; s = s->next) { - for (ul = s->userlist; ul; ul = ul->next) { - userlist_t *u = ul; - const char *format; - - if (!u->nickname) - continue; - - format = format_find(ekg_status_label(u->status, NULL, "quick_list_")); - - if (format_ok(format)) { - char *tmp = format_string(format, u->nickname); - string_append(list, tmp); - - xfree(tmp); - } - } - } - - if (list->len > 0) - print("quick_list", list->str); - - string_free(list, 1); - - return 0; -} - COMMAND(cmd_alias_exec) { list_t tmp = NULL, m = NULL; Modified: trunk/ekg/commands.h =================================================================== --- trunk/ekg/commands.h 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/ekg/commands.h 2008-09-16 10:29:42 UTC (rev 4637) @@ -88,6 +88,7 @@ COMMAND(cmd_exec); COMMAND(cmd_list); COMMAND(cmd_dcc); +COMMAND(cmd_bind); /* bindings.c */ COMMAND(session_command); /* sessions.c */ COMMAND(cmd_on); /* events.c */ COMMAND(cmd_metacontact); /* metacontacts.c */ @@ -106,8 +107,6 @@ void tabnick_add(const char *nick); void tabnick_remove(const char *nick); -int binding_help(int a, int b); -int binding_quick_list(int a, int b); int match_arg(const char *arg, char shortopt, const char *longopt, int longoptlen); Modified: trunk/ekg/configfile.c =================================================================== --- trunk/ekg/configfile.c 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/ekg/configfile.c 2008-09-16 10:29:42 UTC (rev 4637) @@ -39,6 +39,7 @@ #include #include +#include "bindings.h" #include "commands.h" #include "debug.h" #include "dynstuff.h" Modified: trunk/ekg/ekg.c =================================================================== --- trunk/ekg/ekg.c 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/ekg/ekg.c 2008-09-16 10:29:42 UTC (rev 4637) @@ -82,6 +82,7 @@ #include #include "audio.h" +#include "bindings.h" #include "commands.h" #include "debug.h" #include "events.h" Modified: trunk/ekg/stuff.c =================================================================== --- trunk/ekg/stuff.c 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/ekg/stuff.c 2008-09-16 10:29:42 UTC (rev 4637) @@ -98,7 +98,6 @@ alias_t *aliases = NULL; list_t autofinds = NULL; -struct binding *bindings = NULL; struct timer *timers = NULL; static LIST_FREE_ITEM(timer_free_item, struct timer *) { data->function(1, data->data); xfree(data->name); } @@ -116,7 +115,6 @@ struct buffer_info buffer_debug = { NULL, 0, DEBUG_MAX_LINES }; /**< debug buffer */ struct buffer_info buffer_speech = { NULL, 0, 50 }; /**< speech buffer */ -binding_added_t *bindings_added; int old_stderr; char *config_subject_prefix; char *config_subject_reply_prefix; @@ -382,66 +380,6 @@ return 0; } -/* - * binding_list() - * - * wyświetla listę przypisanych komend. - */ -void binding_list(int quiet, const char *name, int all) -{ - struct binding *b; - int found = 0; - - if (!bindings) - printq("bind_seq_list_empty"); - - for (b = bindings; b; b = b->next) { - if (name) { - if (xstrcasestr(b->key, name)) { - printq("bind_seq_list", b->key, b->action); - found = 1; - } - continue; - } - - if (!b->internal || (all && b->internal)) - printq("bind_seq_list", b->key, b->action); - } - - if (name && !found) { - for (b = bindings; b; b = b->next) { - if (xstrcasestr(b->action, name)) - printq("bind_seq_list", b->key, b->action); - } - } -} - -static LIST_FREE_ITEM(binding_free_item, struct binding *) { - xfree(data->key); - xfree(data->action); - xfree(data->arg); - xfree(data->default_action); - xfree(data->default_arg); -} - -static LIST_FREE_ITEM(binding_added_free_item, binding_added_t *) { - xfree(data->sequence); -} - -static __DYNSTUFF_LIST_DESTROY(bindings, struct binding, binding_free_item); /* bindings_destroy() */ -static __DYNSTUFF_LIST_DESTROY(bindings_added, binding_added_t, binding_added_free_item); /* bindings_added_destroy() */ - -/** - * binding_free() - * - * Free memory allocated for key bindings. - */ - -void binding_free() { - bindings_destroy(); - bindings_added_destroy(); -} - static LIST_FREE_ITEM(list_buffer_free, struct buffer *) { xfree(data->line); xfree(data->target); } static __DYNSTUFF_ADD(buffers, struct buffer, NULL) /* buffers_add() */ Modified: trunk/ekg/stuff.h =================================================================== --- trunk/ekg/stuff.h 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/ekg/stuff.h 2008-09-16 10:29:42 UTC (rev 4637) @@ -80,30 +80,6 @@ } alias_t; #endif -#define BINDING_FUNCTION(x) void x(const char *arg) - -struct binding { - struct binding *next; - - char *key; - - char *action; /* akcja */ - unsigned int internal : 1; /* czy domyślna kombinacja? */ - void (*function)(const char *arg); /* funkcja obsługująca */ - char *arg; /* argument funkcji */ - - char *default_action; /* domyślna akcja */ - void (*default_function)(const char *arg); /* domyślna funkcja */ - char *default_arg; /* domyślny argument */ -}; - -typedef struct binding_added { - struct binding_added *next; - - char *sequence; - struct binding *binding; -} binding_added_t; - enum mesg_t { MESG_CHECK = -1, MESG_OFF, @@ -171,13 +147,11 @@ extern child_t *children; extern alias_t *aliases; extern list_t autofinds; /* char* data */ -extern struct binding *bindings; extern struct timer *timers; extern struct conference *conferences; extern newconference_t *newconferences; extern struct buffer_info buffer_debug; extern struct buffer_info buffer_speech; -extern binding_added_t *bindings_added; extern time_t last_save; extern char *config_profile; @@ -282,9 +256,6 @@ char *base64_encode(const char *buf, size_t len); char *base64_decode(const char *buf); -void binding_list(int quiet, const char *name, int all); -void binding_free(); - int buffer_add(struct buffer_info *type, const char *target, const char *line); int buffer_add_str(struct buffer_info *type, const char *target, const char *str); char *buffer_tail(struct buffer_info *type); Modified: trunk/plugins/ncurses/bindings.c =================================================================== --- trunk/plugins/ncurses/bindings.c 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/plugins/ncurses/bindings.c 2008-09-16 10:29:42 UTC (rev 4637) @@ -27,6 +27,7 @@ #include #include +#include #include #include #include Modified: trunk/plugins/ncurses/bindings.h =================================================================== --- trunk/plugins/ncurses/bindings.h 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/plugins/ncurses/bindings.h 2008-09-16 10:29:42 UTC (rev 4637) @@ -22,6 +22,7 @@ #include "ecurses.h" +#include #include #define KEY_CTRL_ENTER 350 Modified: trunk/plugins/ncurses/mouse.c =================================================================== --- trunk/plugins/ncurses/mouse.c 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/plugins/ncurses/mouse.c 2008-09-16 10:29:42 UTC (rev 4637) @@ -27,6 +27,7 @@ #include "ecurses.h" +#include #include #include #include Modified: trunk/plugins/ncurses/old.c =================================================================== --- trunk/plugins/ncurses/old.c 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/plugins/ncurses/old.c 2008-09-16 10:29:42 UTC (rev 4637) @@ -43,6 +43,7 @@ # include "compat/strlcpy.h" #endif +#include #include #include #include Modified: trunk/plugins/readline/main.c =================================================================== --- trunk/plugins/readline/main.c 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/plugins/readline/main.c 2008-09-16 10:29:42 UTC (rev 4637) @@ -10,6 +10,7 @@ #include #include +#include #include #include #include Modified: trunk/plugins/readline/ui-readline.c =================================================================== --- trunk/plugins/readline/ui-readline.c 2008-09-16 01:04:13 UTC (rev 4636) +++ trunk/plugins/readline/ui-readline.c 2008-09-16 10:29:42 UTC (rev 4637) @@ -46,6 +46,7 @@ # include #endif +#include #include #ifndef HAVE_STRLCPY # include From svn w toxygen.net Tue Sep 16 12:50:25 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 16 Sep 2008 12:50:25 +0200 (CEST) Subject: [ekg2-commit] r4638 - trunk/ekg: +trunk/ekg/bindings.c +trunk/ekg/bindings.h Message-ID: <20080916105025.B1A3A17B1F@toxygen.net> Author: darkjames Date: 2008-09-16 12:50:25 +0200 (Tue, 16 Sep 2008) New Revision: 4638 Added: trunk/ekg/bindings.c trunk/ekg/bindings.h Log: From svn w toxygen.net Tue Sep 16 16:06:09 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 16 Sep 2008 16:06:09 +0200 (CEST) Subject: [ekg2-commit] r4639 - trunk/ekg: trunk/ekg/bindings.c trunk/ekg/bindings.h Message-ID: <20080916140609.340F117B1F@toxygen.net> Author: darkjames Date: 2008-09-16 16:06:08 +0200 (Tue, 16 Sep 2008) New Revision: 4639 Modified: trunk/ekg/bindings.c trunk/ekg/bindings.h Log: nieee, tego nie mialo byc, przynajmniej nie teraz :) Modified: trunk/ekg/bindings.c =================================================================== --- trunk/ekg/bindings.c 2008-09-16 10:50:25 UTC (rev 4638) +++ trunk/ekg/bindings.c 2008-09-16 14:06:08 UTC (rev 4639) @@ -159,260 +159,3 @@ return 0; } - -static int binding_key(struct binding *b, const char *key, int add) -{ - /* debug("Key: %s\n", key); */ - if (!xstrncasecmp(key, ("Alt-"), 4)) { - unsigned char ch; - - if (!xstrcasecmp(key + 4, ("Enter"))) { - b->key = xstrdup(("Alt-Enter")); - if (add) - ncurses_binding_map_meta[13] = LIST_ADD2(&bindings, xmemdup(b, sizeof(struct binding))); - return 0; - } - - if (!xstrcasecmp(key + 4, ("Backspace"))) { - b->key = xstrdup(("Alt-Backspace")); - if (add) { - ncurses_binding_map_meta[KEY_BACKSPACE] = LIST_ADD2(&bindings, xmemdup(b, sizeof(struct binding))); - ncurses_binding_map_meta[127] = ncurses_binding_map_meta[KEY_BACKSPACE]; - } - return 0; - } - - if (xstrlen(key) != 5) - return -1; - - ch = xtoupper(key[4]); - - b->key = saprintf(("Alt-%c"), ch); - - if (add) { - ncurses_binding_map_meta[ch] = LIST_ADD2(&bindings, xmemdup(b, sizeof(struct binding))); - if (xisalpha(ch)) - ncurses_binding_map_meta[xtolower(ch)] = ncurses_binding_map_meta[ch]; - } - - return 0; - } - - if (!xstrncasecmp(key, ("Ctrl-"), 5)) { - unsigned char ch; - -// if (xstrlen(key) != 6) -// return -1; -#define __key(x, y, z) \ - if (!xstrcasecmp(key + 5, (x))) { \ - b->key = xstrdup(key); \ - if (add) { \ - ncurses_binding_map[y] = LIST_ADD2(&bindings, xmemdup(b, sizeof(struct binding))); \ - if (z) \ - ncurses_binding_map[z] = ncurses_binding_map[y]; \ - } \ - return 0; \ - } - - __key("Enter", KEY_CTRL_ENTER, 0); - __key("Escape", KEY_CTRL_ESCAPE, 0); - __key("Home", KEY_CTRL_HOME, 0); - __key("End", KEY_CTRL_END, 0); - __key("Delete", KEY_CTRL_DC, 0); - __key("Backspace", KEY_CTRL_BACKSPACE, 0); - __key("Tab", KEY_CTRL_TAB, 0); - -#undef __key - - ch = xtoupper(key[5]); - b->key = saprintf(("Ctrl-%c"), ch); - - if (add) { - if (xisalpha(ch)) - ncurses_binding_map[ch - 64] = LIST_ADD2(&bindings, xmemdup(b, sizeof(struct binding))); - else - return -1; - } - - return 0; - } - - if (xtoupper(key[0]) == 'F' && atoi(key + 1)) { - int f = atoi(key + 1); - - if (f < 1 || f > 24) - return -1; - - b->key = saprintf(("F%d"), f); - - if (add) - ncurses_binding_map[KEY_F(f)] = LIST_ADD2(&bindings, xmemdup(b, sizeof(struct binding))); - - return 0; - } - -#define __key(x, y, z) \ - if (!xstrcasecmp(key, (x))) { \ - b->key = xstrdup((x)); \ - if (add) { \ - ncurses_binding_map[y] = LIST_ADD2(&bindings, xmemdup(b, sizeof(struct binding))); \ - if (z) \ - ncurses_binding_map[z] = ncurses_binding_map[y]; \ - } \ - return 0; \ - } - - __key("Enter", 13, 0); - __key("Escape", 27, 0); - __key("Home", KEY_HOME, KEY_FIND); - __key("End", KEY_END, KEY_SELECT); - __key("Delete", KEY_DC, 0); - __key("Backspace", KEY_BACKSPACE, 127); - __key("Tab", 9, 0); - __key("Left", KEY_LEFT, 0); - __key("Right", KEY_RIGHT, 0); - __key("Up", KEY_UP, 0); - __key("Down", KEY_DOWN, 0); - __key("PageUp", KEY_PPAGE, 0); - __key("PageDown", KEY_NPAGE, 0); - -#undef __key - - return -1; -} - -void ncurses_binding_add(const char *key, const char *action, int internal, int quiet) -{ - struct binding b, *c = NULL, *d; - - if (!key || !action) - return; - - memset(&b, 0, sizeof(b)); - - b.internal = internal; - - for (d = bindings; d; d = d->next) { - if (!xstrcasecmp(key, d->key)) { - if (d->internal) { - c = d; - break; - } - printq("bind_seq_exist", d->key); - return; - } - } - - binding_parse(&b, action); - - if (internal) { - b.default_action = xstrdup(b.action); - b.default_function = b.function; - b.default_arg = xstrdup(b.arg); - } - - if (binding_key(&b, key, (c) ? 0 : 1)) { - printq("bind_seq_incorrect", key); - xfree(b.action); - xfree(b.arg); - xfree(b.default_action); - xfree(b.default_arg); - xfree(b.key); - } else { - printq("bind_seq_add", b.key); - - if (c) { - xfree(c->action); - c->action = b.action; - xfree(c->arg); - c->arg = b.arg; - c->function = b.function; - xfree(b.default_action); - xfree(b.default_arg); - xfree(b.key); - c->internal = 0; - } - - if (!in_autoexec) - config_changed = 1; - } -} - -void bindings_default() { - /* ncurses bindings */ - - ncurses_binding_add("Alt-`", "/window switch 0", 1, 1); - ncurses_binding_add("Alt-1", "/window switch 1", 1, 1); - ncurses_binding_add("Alt-2", "/window switch 2", 1, 1); - ncurses_binding_add("Alt-3", "/window switch 3", 1, 1); - ncurses_binding_add("Alt-4", "/window switch 4", 1, 1); - ncurses_binding_add("Alt-5", "/window switch 5", 1, 1); - ncurses_binding_add("Alt-6", "/window switch 6", 1, 1); - ncurses_binding_add("Alt-7", "/window switch 7", 1, 1); - ncurses_binding_add("Alt-8", "/window switch 8", 1, 1); - ncurses_binding_add("Alt-9", "/window switch 9", 1, 1); - ncurses_binding_add("Alt-0", "/window switch 10", 1, 1); - ncurses_binding_add("Alt-Q", "/window switch 11", 1, 1); - ncurses_binding_add("Alt-W", "/window switch 12", 1, 1); - ncurses_binding_add("Alt-E", "/window switch 13", 1, 1); - ncurses_binding_add("Alt-R", "/window switch 14", 1, 1); - ncurses_binding_add("Alt-T", "/window switch 15", 1, 1); - ncurses_binding_add("Alt-Y", "/window switch 16", 1, 1); - ncurses_binding_add("Alt-U", "/window switch 17", 1, 1); - ncurses_binding_add("Alt-I", "/window switch 18", 1, 1); - ncurses_binding_add("Alt-O", "/window switch 19", 1, 1); - ncurses_binding_add("Alt-P", "/window switch 20", 1, 1); - ncurses_binding_add("Alt-K", "window-kill", 1, 1); - ncurses_binding_add("Alt-N", "/window new", 1, 1); - ncurses_binding_add("Alt-A", "/window active", 1, 1); - ncurses_binding_add("Alt-G", "ignore-query", 1, 1); - ncurses_binding_add("Alt-B", "backward-word", 1, 1); - ncurses_binding_add("Alt-F", "forward-word", 1, 1); - ncurses_binding_add("Alt-D", "kill-word", 1, 1); - ncurses_binding_add("Alt-Enter", "toggle-input", 1, 1); - ncurses_binding_add("Escape", "cancel-input", 1, 1); - ncurses_binding_add("Ctrl-N", "/window next", 1, 1); - ncurses_binding_add("Ctrl-P", "/window prev", 1, 1); - ncurses_binding_add("Backspace", "backward-delete-char", 1, 1); - ncurses_binding_add("Ctrl-H", "backward-delete-char", 1, 1); - ncurses_binding_add("Ctrl-A", "beginning-of-line", 1, 1); - ncurses_binding_add("Home", "beginning-of-line", 1, 1); - ncurses_binding_add("Ctrl-D", "delete-char", 1, 1); - ncurses_binding_add("Delete", "delete-char", 1, 1); - ncurses_binding_add("Ctrl-E", "end-of-line", 1, 1); - ncurses_binding_add("End", "end-of-line", 1, 1); - ncurses_binding_add("Ctrl-K", "kill-line", 1, 1); - ncurses_binding_add("Ctrl-Y", "yank", 1, 1); - ncurses_binding_add("Enter", "accept-line", 1, 1); - ncurses_binding_add("Ctrl-M", "accept-line", 1, 1); - ncurses_binding_add("Ctrl-U", "line-discard", 1, 1); - ncurses_binding_add("Ctrl-V", "quoted-insert", 1, 1); - ncurses_binding_add("Ctrl-W", "word-rubout", 1, 1); - ncurses_binding_add("Alt-Backspace", "word-rubout", 1, 1); - ncurses_binding_add("Ctrl-L", "/window refresh", 1, 1); - ncurses_binding_add("Tab", "complete", 1, 1); - ncurses_binding_add("Right", "forward-char", 1, 1); - ncurses_binding_add("Left", "backward-char", 1, 1); - ncurses_binding_add("Up", "previous-history", 1, 1); - ncurses_binding_add("Down", "next-history", 1, 1); - ncurses_binding_add("PageUp", "backward-page", 1, 1); - ncurses_binding_add("Ctrl-F", "backward-page", 1, 1); - ncurses_binding_add("PageDown", "forward-page", 1, 1); - ncurses_binding_add("Ctrl-G", "forward-page", 1, 1); - ncurses_binding_add("Ctrl-X", "cycle-sessions", 1, 1); - ncurses_binding_add("F1", "/help", 1, 1); - ncurses_binding_add("F2", "quick-list", 1, 1); - ncurses_binding_add("F3", "toggle-contacts", 1, 1); - ncurses_binding_add("F4", "next-contacts-group", 1, 1); - ncurses_binding_add("F12", "/window switch 0", 1, 1); - ncurses_binding_add("F11", "ui-ncurses-debug-toggle", 1, 1); - /* ncurses_binding_add("Ctrl-Down", "forward-contacts-page", 1, 1); - ncurses_binding_add("Ctrl-Up", "backward-contacts-page", 1, 1); */ - - query_emit_id(NULL, BINDING_DEFAULT); /* allow ui's to process binding-list */ /* XXX, change name */ -} - -void bindings_init() { - bindings_default(); -} - Modified: trunk/ekg/bindings.h =================================================================== --- trunk/ekg/bindings.h 2008-09-16 10:50:25 UTC (rev 4638) +++ trunk/ekg/bindings.h 2008-09-16 14:06:08 UTC (rev 4639) @@ -33,8 +33,6 @@ int binding_help(int a, int b); int binding_quick_list(int a, int b); -void bindings_init(); -void bindings_default(); void binding_free(); #endif From svn w toxygen.net Tue Sep 16 21:13:20 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 16 Sep 2008 21:13:20 +0200 (CEST) Subject: [ekg2-commit] r4640 - trunk/ekg: trunk/ekg/configfile.c trunk/ekg/ekg.c trunk/ekg/sessions.c trunk/ekg/windows.c trunk/ekg/windows.h Message-ID: <20080916191320.317AD17B1F@toxygen.net> Author: darkjames Date: 2008-09-16 21:13:19 +0200 (Tue, 16 Sep 2008) New Revision: 4640 Modified: trunk/ekg/configfile.c trunk/ekg/ekg.c trunk/ekg/sessions.c trunk/ekg/windows.c trunk/ekg/windows.h Log: session_current i curse you! left: - /session --sw, but it's buggy. - session_remove(), it's even more buggy, and likes to segfault :/ Modified: trunk/ekg/configfile.c =================================================================== --- trunk/ekg/configfile.c 2008-09-16 14:06:08 UTC (rev 4639) +++ trunk/ekg/configfile.c 2008-09-16 19:13:19 UTC (rev 4640) @@ -131,9 +131,7 @@ if (s) { debug("setted default session to %s\n", s->uid); - session_current = s; - window_current->session = s; - query_emit_id(NULL, SESSION_CHANGED); + window_session_set(window_status, s); } else { debug("default session not found\n"); } Modified: trunk/ekg/ekg.c =================================================================== --- trunk/ekg/ekg.c 2008-09-16 14:06:08 UTC (rev 4639) +++ trunk/ekg/ekg.c 2008-09-16 19:13:19 UTC (rev 4640) @@ -960,16 +960,9 @@ config_postread(); /* status window takes first session if not set before*/ - if (!session_current && sessions) - session_current = sessions; + if (!window_status->session && sessions) + window_session_set(window_status, sessions); - if (session_current != window_current->session) - window_current->session = session_current; - window_debug->session = window_current->session; -/* - query_emit_id(NULL, SESSION_CHANGED); - query_emit_id(NULL, UI_REFRESH); - */ metacontact_read(); /* read the metacontacts info */ { Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-16 14:06:08 UTC (rev 4639) +++ trunk/ekg/sessions.c 2008-09-16 19:13:19 UTC (rev 4640) @@ -160,15 +160,9 @@ sessions_add(s); /* XXX, wywalic sprawdzanie czy juz jest sesja? w koncu jak dodajemy sesje.. to moze chcemy sie od razu na nia przelaczyc? */ - if (!window_current->session && (window_current->id == 0 || window_current->id == 1)) { - window_current->session = s; - session_current = s; + if (!window_current->session && (window_current == window_debug || window_current == window_status)) + window_session_set(window_current, s); - query_emit_id(NULL, UI_WINDOW_TARGET_CHANGED, &window_current); - query_emit_id(NULL, SESSION_CHANGED); - } - - /* XXX, i still don't understand why session_current isn't macro to window_current->session... */ if (!session_current) session_current = s; @@ -207,14 +201,8 @@ * with w->target: "Aga". it's not uid. it's nickname.. so we must search for it in userlist. * it's better idea than what was.. however it's slow and I still want to do it other way. */ - if (!w->session && !w->floating && get_uid(s, w->target)) { - w->session = s; - - query_emit_id(NULL, UI_WINDOW_TARGET_CHANGED, &w); - - if (w == window_current) - query_emit_id(NULL, SESSION_CHANGED); - } + if (!w->session && !w->floating && get_uid(s, w->target)) + window_session_set(w, s); } return s; Modified: trunk/ekg/windows.c =================================================================== --- trunk/ekg/windows.c 2008-09-16 14:06:08 UTC (rev 4639) +++ trunk/ekg/windows.c 2008-09-16 19:13:19 UTC (rev 4640) @@ -879,6 +879,36 @@ return 0; } +/* NOTE: XXX, if you talk with someone on window_status/ window_debug we fail */ +void window_session_set(window_t *w, session_t *new_session) { + static int lock; + + if (!w || !new_session) /* XXX, new_session == NULL? */ + return; + + if (w->session == new_session) + return; + + w->session = new_session; + + if (w == window_current) { + session_current = new_session; + query_emit_id(NULL, SESSION_CHANGED); + } + + query_emit_id(NULL, UI_WINDOW_TARGET_CHANGED, &w); + + /* let's sync window_status->session with window_debug->session */ + if (lock == 0) { + lock = 1; + if (w == window_debug) + window_session_set(window_status, new_session); + if (w == window_status) + window_session_set(window_debug, new_session); + lock = 0; + } +} + /** * window_session_cycle() * @@ -896,8 +926,6 @@ * @todo Gdy config_window_session_allow == 2, to najpierw sprobowac znalezc dobra sesje a potem jesli nie to * nastepna? * - * @todo Create window_session_set() for some stuff here. - * * @param w - window * * @return 0 - if session of window was changed @@ -973,8 +1001,6 @@ return -1; } - w->session = new_session; - if ((nickname = get_nickname(new_session, uid))) { /* if we've got nickname for old uid, than use it as w->target */ char *tmp = w->target; w->target = xstrdup(nickname); @@ -985,36 +1011,7 @@ xfree(tmp); } - if (w == window_current) { - session_current = new_session; - query_emit_id(NULL, SESSION_CHANGED); - } - query_emit_id(NULL, UI_WINDOW_TARGET_CHANGED, &w); - - { /* here sync window_status->session with window_debug->session */ - if (w == window_status) { - if (window_debug->session != new_session) { - window_debug->session = new_session; - if (window_current == window_debug) { - session_current = new_session; - query_emit_id(NULL, SESSION_CHANGED); - } - query_emit_id(NULL, UI_WINDOW_TARGET_CHANGED, &window_debug); - } - } - - if (w == window_debug) { - if (window_status->session != new_session) { - window_status->session = new_session; - if (window_current == window_status) { - session_current = new_session; - query_emit_id(NULL, SESSION_CHANGED); - } - query_emit_id(NULL, UI_WINDOW_TARGET_CHANGED, &window_status); - } - } - } - + window_session_set(w, new_session); return 0; } Modified: trunk/ekg/windows.h =================================================================== --- trunk/ekg/windows.h 2008-09-16 14:06:08 UTC (rev 4639) +++ trunk/ekg/windows.h 2008-09-16 19:13:19 UTC (rev 4640) @@ -109,6 +109,7 @@ void print_window_w(window_t *w, int activity, const char *theme, ...); /* themes.c */ char *window_target(window_t *window); +void window_session_set(window_t *w, session_t *newsession); int window_session_cycle(window_t *w); int window_lock_inc(window_t *w); From svn w toxygen.net Tue Sep 16 22:30:40 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 16 Sep 2008 22:30:40 +0200 (CEST) Subject: [ekg2-commit] r4641 - trunk/plugins/irc: trunk/plugins/irc/misc.c Message-ID: <20080916203040.A421517B1F@toxygen.net> Author: darkjames Date: 2008-09-16 22:30:39 +0200 (Tue, 16 Sep 2008) New Revision: 4641 Modified: trunk/plugins/irc/misc.c Log: Approved by wiechu. Modified: trunk/plugins/irc/misc.c =================================================================== --- trunk/plugins/irc/misc.c 2008-09-16 19:13:19 UTC (rev 4640) +++ trunk/plugins/irc/misc.c 2008-09-16 20:30:39 UTC (rev 4641) @@ -1316,6 +1316,8 @@ if (xstrcmp(irc_channel, chname)) newwin->alias = xstrdup(chname); /* ?WO? format for alias here??? */ + query_emit_id(NULL, UI_WINDOW_TARGET_CHANGED, &newwin); /* let's emit UI_WINDOW_TARGET_CHANGED XXX, another/new query? */ + window_switch(newwin->id); debug("[irc] c_join() %08X\n", newwin); ischan = irc_add_channel(s, j , irc_channel, newwin); From svn w toxygen.net Tue Sep 16 22:53:05 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 16 Sep 2008 22:53:05 +0200 (CEST) Subject: [ekg2-commit] r4642 - trunk/ekg: trunk/ekg/protocol.c trunk/ekg/queries.h trunk/ekg/themes.c trunk/ekg/themes.h Message-ID: <20080916205305.632D317B1F@toxygen.net> Author: darkjames Date: 2008-09-16 22:53:04 +0200 (Tue, 16 Sep 2008) New Revision: 4642 Modified: trunk/ekg/protocol.c trunk/ekg/queries.h trunk/ekg/themes.c trunk/ekg/themes.h Log: - UI_WINDOW_ACT_CHANGED now gives info about window - new function theme_enumerate() Modified: trunk/ekg/protocol.c =================================================================== --- trunk/ekg/protocol.c 2008-09-16 20:30:39 UTC (rev 4641) +++ trunk/ekg/protocol.c 2008-09-16 20:53:04 UTC (rev 4642) @@ -930,7 +930,7 @@ else goto xs_userlist; - query_emit_id(NULL, UI_WINDOW_ACT_CHANGED); + query_emit_id(NULL, UI_WINDOW_ACT_CHANGED, &w); /* XXX, UI_WINDOW_TYPING_CHANGED? :> */ } xs_userlist: Modified: trunk/ekg/queries.h =================================================================== --- trunk/ekg/queries.h 2008-09-16 20:30:39 UTC (rev 4641) +++ trunk/ekg/queries.h 2008-09-16 20:53:04 UTC (rev 4642) @@ -378,6 +378,7 @@ QUERY_ARG_END } }, /* no params */ { UI_WINDOW_ACT_CHANGED, "ui-window-act-changed", { + QUERY_ARG_WINDOW, /* window */ QUERY_ARG_END } }, /* no params */ { UI_WINDOW_CLEAR, "ui-window-clear", { Modified: trunk/ekg/themes.c =================================================================== --- trunk/ekg/themes.c 2008-09-16 20:30:39 UTC (rev 4641) +++ trunk/ekg/themes.c 2008-09-16 20:53:04 UTC (rev 4642) @@ -739,7 +739,7 @@ if (activity > w->act) { w->act = activity; /* emit UI_WINDOW_ACT_CHANGED only when w->act changed */ - query_emit_id(NULL, UI_WINDOW_ACT_CHANGED); + query_emit_id(NULL, UI_WINDOW_ACT_CHANGED, &w); } } @@ -1207,6 +1207,22 @@ return 0; } +void theme_enumerate(int *(enumerator)(const char *theme, const char *value)) { + int i; + + if (!enumerator) + return; + + for (i = 0; i < 0x100; i++) { + struct format *ff; + + for (ff = formats[i]; ff; ff = ff->next) { + if (!enumerator(ff->name, ff->value)) + return; + } + } +} + /* * theme_free() * Modified: trunk/ekg/themes.h =================================================================== --- trunk/ekg/themes.h 2008-09-16 20:30:39 UTC (rev 4641) +++ trunk/ekg/themes.h 2008-09-16 20:53:04 UTC (rev 4642) @@ -66,6 +66,7 @@ void theme_init(); void theme_plugins_init(); +void theme_enumerate(int *(enumerator)(const char *theme, const char *value)); int theme_read(const char *filename, int replace); int theme_write(const char *filename); void theme_cache_reset(); From svn w toxygen.net Tue Sep 16 22:53:56 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 16 Sep 2008 22:53:56 +0200 (CEST) Subject: [ekg2-commit] r4643 - trunk/ekg: trunk/ekg/queries.h Message-ID: <20080916205356.53A1317B1F@toxygen.net> Author: darkjames Date: 2008-09-16 22:53:55 +0200 (Tue, 16 Sep 2008) New Revision: 4643 Modified: trunk/ekg/queries.h Log: blah, remove 'no params' Modified: trunk/ekg/queries.h =================================================================== --- trunk/ekg/queries.h 2008-09-16 20:53:04 UTC (rev 4642) +++ trunk/ekg/queries.h 2008-09-16 20:53:55 UTC (rev 4643) @@ -379,7 +379,7 @@ { UI_WINDOW_ACT_CHANGED, "ui-window-act-changed", { QUERY_ARG_WINDOW, /* window */ - QUERY_ARG_END } }, /* no params */ + QUERY_ARG_END } }, { UI_WINDOW_CLEAR, "ui-window-clear", { QUERY_ARG_WINDOW, /* window */ From svn w toxygen.net Tue Sep 16 23:10:29 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 16 Sep 2008 23:10:29 +0200 (CEST) Subject: [ekg2-commit] r4644 - in trunk/plugins: . remote: +trunk/plugins/remote/ +trunk/plugins/remote/Makefile.am +trunk/plugins/remote/remote.c Message-ID: <20080916211029.9C08B17B1F@toxygen.net> Author: darkjames Date: 2008-09-16 23:10:29 +0200 (Tue, 16 Sep 2008) New Revision: 4644 Added: trunk/plugins/remote/ trunk/plugins/remote/Makefile.am trunk/plugins/remote/remote.c Log: esktremalnie fajny plugin UI, z ekstremalnie fajnym protokolem. ssl, zlib, i inne fajne pierdolki pozniej. Added: trunk/plugins/remote/Makefile.am =================================================================== --- trunk/plugins/remote/Makefile.am (rev 0) +++ trunk/plugins/remote/Makefile.am 2008-09-16 21:10:29 UTC (rev 4644) @@ -0,0 +1,8 @@ +EXTRA_DIST = vars-pl.txt + +lib_LTLIBRARIES = remote.la +remote_la_SOURCES = remote.c +remote_la_CPPFLAGS = $(C_FVISIBILITY) +remote_la_LDFLAGS = -module -avoid-version + +override libdir = $(plugindir) Added: trunk/plugins/remote/remote.c =================================================================== --- trunk/plugins/remote/remote.c (rev 0) +++ trunk/plugins/remote/remote.c 2008-09-16 21:10:29 UTC (rev 4644) @@ -0,0 +1,1114 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifndef HAVE_STRLCPY +# include "compat/strlcpy.h" +#endif + +typedef enum { + RC_INPUT_PIPE = 1, /* pipe:/home/user/.ekg/pipe */ + RC_INPUT_UDP, /* udp:12345 */ + RC_INPUT_TCP, /* tcp:12345 */ + RC_INPUT_UNIX, /* unix:/home/user/.ekg/socket */ + RC_INPUT_TCP_CLIENT, + RC_INPUT_UNIX_CLIENT +} rc_input_type_t; + +typedef struct { + rc_input_type_t type; /* rodzaj wejścia */ + char *path; /* ścieżka */ + int fd; /* deskryptor */ + int mark; /* do zaznaczania, wnętrzności */ + + int login_ok; +} rc_input_t; + +typedef struct { + char *str; + time_t ts; +} remote_backlog_t; + +typedef struct { + remote_backlog_t **backlog; /* bufor z liniami */ /* XXX, przerobic na liste? */ + int backlog_size; /* rozmiar backloga */ +} remote_window_t; + +PLUGIN_DEFINE(remote, PLUGIN_UI, NULL); + +static void rc_input_close(rc_input_t *r); + +static list_t rc_inputs = NULL; +static char *rc_paths = NULL; +static char *rc_password = NULL; +static int rc_first = 1; + +static const char *rc_var_get_value(variable_t *v) { + if (!v) + return NULL; + + switch (v->type) { + case VAR_INT: + case VAR_BOOL: + return itoa(*((int *) v->ptr)); + + case VAR_THEME: + case VAR_FILE: + case VAR_DIR: + case VAR_STR: + return *((const char **) v->ptr); + + case VAR_MAP: + default: + return "notimplemented"; + } +} + +static char *rc_fstring_reverse(fstring_t *fstr) { + const char *str; + const short *attr; + string_t asc; + int i; + + if (!fstr) + return NULL; + + attr = fstr->attr; + str = fstr->str.b; + + if (!attr || !str) + return NULL; + + asc = string_init(NULL); + + for (i = 0; str[i]; i++) { +#define prev attr[i-1] +#define cur attr[i] + int reset = 0; + + if (i) { + if (!(cur & FSTR_BOLD) && (prev & FSTR_BOLD)) reset = 1; + if (!(cur & FSTR_BLINK) && (prev & FSTR_BLINK)) reset = 1; + if (!(cur & FSTR_UNDERLINE) && (prev & FSTR_UNDERLINE)) reset = 1; + if (!(cur & FSTR_REVERSE) && (prev & FSTR_REVERSE)) reset = 1; + if ((cur & FSTR_NORMAL) && !(prev & FSTR_NORMAL)) reset = 1; /* colors disappear */ + + if (reset) + string_append(asc, "%n"); + } else + reset = 1; + + /* attr */ + if ((cur & FSTR_BLINK) && (reset || !(prev & FSTR_BLINK))) string_append(asc, "%i"); + if ((cur & FSTR_UNDERLINE) && (reset || !(prev & FSTR_UNDERLINE))) string_append(asc, "%U"); + if ((cur & FSTR_REVERSE) && (reset || !(prev & FSTR_REVERSE))) string_append(asc, "%V"); + + if (!(cur & FSTR_NORMAL)) { + /* background color XXX */ +#define BGCOLOR(x) -1 + if (0 && ((reset || BGCOLOR(cur) != BGCOLOR(prev)))) { + string_append_c(asc, '%'); + switch (BGCOLOR(cur)) { + case (0): string_append_c(asc, 'l'); break; + case (1): string_append_c(asc, 's'); break; + case (2): string_append_c(asc, 'h'); break; + case (3): string_append_c(asc, 'z'); break; + case (4): string_append_c(asc, 'e'); break; + case (5): string_append_c(asc, 'q'); break; + case (6): string_append_c(asc, 'd'); break; + case (7): string_append_c(asc, 'x'); break; + } + } +#undef BGCOLOR + + /* foreground color */ +#define FGCOLOR(x) ((!(x & FSTR_NORMAL)) ? (x & FSTR_FOREMASK) : -1) + if (((reset || FGCOLOR(cur) != FGCOLOR(prev)) || (i && (prev & FSTR_BOLD) != (cur & FSTR_BOLD)))) { + string_append_c(asc, '%'); + switch ((cur & FSTR_FOREMASK)) { + case (0): string_append_c(asc, (cur & FSTR_BOLD) ? 'K' : 'k'); break; + case (1): string_append_c(asc, (cur & FSTR_BOLD) ? 'R' : 'r'); break; + case (2): string_append_c(asc, (cur & FSTR_BOLD) ? 'G' : 'g'); break; + case (3): string_append_c(asc, (cur & FSTR_BOLD) ? 'Y' : 'y'); break; + case (4): string_append_c(asc, (cur & FSTR_BOLD) ? 'B' : 'b'); break; + case (5): string_append_c(asc, (cur & FSTR_BOLD) ? 'M' : 'm'); break; /* | fioletowy | %m/%p | %M/%P | %q | */ + case (6): string_append_c(asc, (cur & FSTR_BOLD) ? 'C' : 'c'); break; + case (7): string_append_c(asc, (cur & FSTR_BOLD) ? 'W' : 'w'); break; + } + } +#undef FGCOLOR + } else { /* no color */ + if ((cur & FSTR_BOLD) && (reset || !(prev & FSTR_BOLD))) + string_append(asc, "%T"); + } + + /* str */ + if (str[i] == '%' || str[i] == '\\') + string_append_c(asc, '\\'); + string_append_c(asc, str[i]); + } + +/* reset, and return. */ + string_append(asc, "%n"); + return string_free(asc, 0); + +#undef prev +#undef cur +} + +static string_t remote_what_to_write(char *what, va_list ap) { + string_t str; + char *_str; + + str = string_init(what); + + while ((_str = va_arg(ap, char *))) { + string_append_c(str, '\002'); + /* XXX, kazde cos co wymaga sanityzacji, sanityzowac :) */ + /* przy okazji mozna tez i rekodowac :) */ + string_append(str, _str); + } + string_append_c(str, '\n'); + + debug_io("remote_what_to_write: %s\n", str->str); + + return str; +} + +static int remote_broadcast(char *what, ...) { + string_t str; + va_list ap; + list_t l; + + va_start(ap, what); + str = remote_what_to_write(what, ap); + va_end(ap); + + for (l = rc_inputs; l; l = l->next) { + rc_input_t *r = l->data; + + if (r->type == RC_INPUT_TCP_CLIENT || r->type == RC_INPUT_UNIX_CLIENT) { + /* XXX, discarding ret value */ + if (r->login_ok) + ekg_write(r->fd, str->str, str->len); + } + } + + string_free(str, 1); + return 0; +} + +static int remote_writefd(int fd, char *what, ...) { + string_t str; + va_list ap; + + va_start(ap, what); + str = remote_what_to_write(what, ap); + va_end(ap); + + ekg_write(fd, str->str, str->len); + + string_free(str, 1); + return 0; +} + +static int rc_theme_enumerate_fd = -1; + +int rc_theme_enumerate(const char *name, const char *value) { + char *esc_name; + char *esc_value; + + if (rc_theme_enumerate_fd == -1) + return 0; + + esc_name = escape(name); + esc_value = escape(value); + + remote_writefd(rc_theme_enumerate_fd, "FORMAT", esc_name, esc_value, NULL); + /* XXX, if remote_writefd() fails, we should set rc_theme_enumerate_fd to -1, and return 0 */ + + xfree(esc_name); + xfree(esc_value); + return 1; +} + +/* + * rc_input_handler_line() + * + * obsługa przychodzących poleceń. + */ +static WATCHER_LINE(rc_input_handler_line) { + rc_input_t *r = data; + char **arr; + int arrcnt; + + if (type == 1) { + rc_input_close(r); + return 0; + } + + if (!data) + return -1; + + arr = array_make(watch, "\001", 0, 0, 0); + arrcnt = array_count(arr); + + if (!r->login_ok) { + if (!xstrcmp(arr[0], "REQLOGIN")) { + if (arrcnt == 1 && rc_password == NULL) + r->login_ok = 1; + else if (arrcnt == 2 && !xstrcmp(rc_password, arr[1])) + r->login_ok = 1; + + if (!r->login_ok) { + remote_writefd(fd, "-LOGIN", NULL); + array_free(arr); + return -1; + } + + remote_writefd(fd, "+LOGIN", NULL); + + } else { + debug_error("unknown command: %s\n", arr[0]); + array_free(arr); + return -1; + } + + array_free(arr); + return 0; + } + + if (arr[0]) { + char *cmd = arr[0]; + + if (0) { + +/* synchronization ekg2-remote <==> ekg2 */ + } else if (!xstrcmp(cmd, "REQCONFIG")) { + variable_t *v; + + for (v = variables; v; v = v->next) { + const char *_val; + + _val = rc_var_get_value(v); + remote_writefd(fd, "CONFIG", v->name, _val, NULL); /* _val can be NULL */ + } + remote_writefd(fd, "+CONFIG", NULL); + + } else if (!xstrcmp(cmd, "REQCOMMANDS")) { + command_t *c; + + for (c = commands; c; c = c->next) { + if (c->params) { + char *tmp = array_join(c->params, " "); + remote_writefd(fd, "COMMAND", c->name, tmp, NULL); + xfree(tmp); + } else + remote_writefd(fd, "COMMAND", c->name, NULL); + } + remote_writefd(fd, "+COMMAND", NULL); + + } else if (!xstrcmp(cmd, "REQPLUGINS")) { + plugin_t *p; + + for (p = plugins; p; p = p->next) + remote_writefd(fd, "PLUGIN", p->name, itoa(p->prio), NULL); + remote_writefd(fd, "+PLUGIN", NULL); + + } else if (!xstrcmp(cmd, "REQFORMATS")) { + /* XXX, dirty hack */ + rc_theme_enumerate_fd = fd; + theme_enumerate(rc_theme_enumerate); + if (rc_theme_enumerate_fd == -1) + /* XXX, error */ + ; + + remote_writefd(fd, "+FORMAT", NULL); + + } else if (!xstrcmp(cmd, "REQBACKLOGS")) { + window_t *w; + + for (w = windows; w; w = w->next) { + remote_window_t *n = w->private; + int i; + + if (!n) + continue; + + for (i = n->backlog_size; i; i--) { + remote_writefd(fd, "BACKLOG", itoa(w->id), itoa(n->backlog[i-1]->ts), n->backlog[i-1]->str, NULL); + } + } + remote_writefd(fd, "+BACKLOG", NULL); + + } else if (!xstrcmp(cmd, "REQSESSIONS")) { + session_t *s; + + for (s = sessions; s; s = s->next) { + remote_writefd(fd, "SESSION", s->uid, (s->plugin) ? ((plugin_t *) s->plugin)->name : "-", NULL); + remote_writefd(fd, "SESSIONINFO", s->uid, "STATUS", itoa(s->status), NULL); + remote_writefd(fd, "SESSIONINFO", s->uid, "CONNECTED", itoa(s->connected), NULL); + + } + remote_writefd(fd, "+SESSION", NULL); + + } else if (!xstrcmp(cmd, "REQWINDOWS")) { + window_t *w; + + for (w = windows; w; w = w->next) { + remote_writefd(fd, "WINDOW", itoa(w->id), w->target, NULL); /* NOTE: w->target can be NULL */ + + if (w->alias) + remote_writefd(fd, "WINDOWINFO", itoa(w->id), "ALIAS", w->alias, NULL); + + if (w->session) + remote_writefd(fd, "WINDOWINFO", itoa(w->id), "SESSION", w->session->uid, NULL); + } + remote_writefd(fd, "WINDOW_SWITCH", itoa(window_current->id), NULL); + remote_writefd(fd, "+WINDOW", NULL); +/* rozniaste */ + } else if (!xstrcmp(cmd, "REQSESSION_CYCLE")) { + if (arrcnt == 2) { + int id = atoi(arr[1]); + int ret; + + ret = window_session_cycle(window_exist(id)); + if (ret == 0) + remote_writefd(fd, "+SESSION_CYCLE", NULL); + else + remote_writefd(fd, "-SESSION_CYCLE", NULL); + } + } else if (!xstrcmp(cmd, "REQEXECUTE")) { + if (arrcnt == 2) { + int ret; + + ret = command_exec(window_current->target, window_current->session, arr[1], 0); + + /* XXX, send retcode? */ + + remote_writefd(fd, "+EXECUTE", NULL); + } else + remote_writefd(fd, "-EXECUTE", NULL); + } else { + debug_error("unknown command: %s\n", cmd); + } + + } +cleanup: + array_free(arr); + return 0; +} + +/* + * rc_input_handler_accept() + * + * obsługa przychodzących połączeń. + */ +static WATCHER(rc_input_handler_accept) { + rc_input_t *r = data, *rn; + struct sockaddr sa; + socklen_t salen = sizeof(sa), cfd; + + if (type == 1) { + rc_input_close(r); + return 0; + } + if (!data) return -1; + + if ((cfd = accept(fd, &sa, &salen)) == -1) { + debug_error("[rc] accept() failed: %s\n", strerror(errno)); + return -1; + } + + debug("rc_input_handler_accept() new connection... [%s] %d\n", r->path, cfd); + + rn = xmalloc(sizeof(rc_input_t)); + + rn->fd = cfd; + rn->path = saprintf("%sc", r->path); /* maybe ip:port of client or smth? */ + rn->type = (r->type == RC_INPUT_TCP) ? RC_INPUT_TCP_CLIENT : RC_INPUT_UNIX_CLIENT; + list_add(&rc_inputs, rn); + watch_add_line(&remote_plugin, cfd, WATCH_READ_LINE, rc_input_handler_line, rn); + return 0; +} + +/* + * rc_input_find() + * + * zwraca strukturę rc_input_t kanału wejściowego o podanej ścieżce. + */ +static rc_input_t *rc_input_find(const char *path) +{ + list_t l; + + for (l = rc_inputs; l; l = l->next) { + rc_input_t *r = l->data; + + if (!xstrcmp(r->path, path)) + return r; + } + + return NULL; +} + +static watch_t *rc_watch_find(int fd) { + list_t l; + + for (l = watches; l; l = l->next) { + watch_t *w = l->data; + + if (w && w->plugin == &remote_plugin && w->fd == fd) + return w; + } + + return NULL; +} + +/* + * rc_input_close() + * + * zamyka kanał wejściowy. + */ +static void rc_input_close(rc_input_t *r) { + if (!r) + return; + + debug_function("[rc] closing (0x%x) fd: %d path:%s\n", r, r->fd, r->path); + + if (r->type == RC_INPUT_PIPE) + unlink(r->path); + + if (r->fd != -1) { + watch_t *w = rc_watch_find(r->fd); + + if (w) { + if (w->data == r) + debug_function("[rc] rc_input_close() watch 0x%x OK\n", r); + else debug_error("[rc] rc_input_close() watch: 0x%x r: 0x%x\n", w->data, r); + + w->data = NULL; /* to avoid double free */ + watch_free(w); /* free watch */ + } + /* i don't really know if we really must do it.. coz WATCH_READ_LINE watches close always fd...., + * maybe let's move it to handlers which really need it? */ + close(r->fd); + r->fd = -1; + } + + xfree(r->path); + list_remove(&rc_inputs, r, 1); +} + +/* + * rc_input_new_inet() + * + * tworzy nowe gniazdo AF_INET. + */ +static int rc_input_new_inet(const char *path, int type) +{ + struct sockaddr_in sin; + int port, fd; + uint32_t addr = INADDR_ANY; + + if (xstrchr(path, ':')) { + char *tmp = xstrdup(path), *c = xstrchr(tmp, ':'); + + port = atoi(c + 1); + *c = 0; + addr = inet_addr(tmp); + xfree(tmp); + } else + port = atoi(path); + + sin.sin_family = AF_INET; + sin.sin_port = htons(port); + sin.sin_addr.s_addr = addr; + + if ((fd = socket(AF_INET, type, 0)) == -1) { + debug_error("[rc] socket() failed: %s\n", strerror(errno)); + return -1; + } + +#ifdef SO_REUSEADDR + { + int one = 1; + + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) == -1) + debug_error("[rc] setsockopt(SO_REUSEADDR) failed: %s\n", strerror(errno)); + } +#endif + + if (bind(fd, (struct sockaddr*) &sin, sizeof(sin))) { + debug_error("[rc] bind() failed: %s\n", strerror(errno)); + close(fd); + return -1; + } + + if (type == SOCK_STREAM && listen(fd, 10)) { + debug_error("[rc] listen() failed: %s\n", strerror(errno)); + close(fd); + return -1; + } + + return fd; +} + +static int rc_input_new_tcp(const char *path) +{ + return rc_input_new_inet(path, SOCK_STREAM); +} + +static int rc_input_new_udp(const char *path) +{ + return rc_input_new_inet(path, SOCK_DGRAM); +} + +/* + * rc_input_new_pipe() + * + * tworzy nazwany potok (named pipe). + */ +static int rc_input_new_pipe(const char *path) +{ + struct stat st; + int fd; + + if (!stat(path, &st) && !S_ISFIFO(st.st_mode)) { + debug_error("[rc] file exists, but isn't a pipe\n"); + return -1; + } + + if (mkfifo(path, 0600) == -1 && errno != EEXIST) { + debug_error("[rc] mkfifo() failed: %s\n", strerror(errno)); + return -1; + } + + if ((fd = open(path, O_RDWR | O_NONBLOCK)) == -1) { + debug_error("[rc] open() failed: %s\n", strerror(errno)); + return -1; + } + + return fd; +} + +/* + * rc_input_new_unix() + * + * tworzy gniazdo AF_UNIX. + */ +static int rc_input_new_unix(const char *path) +{ + struct sockaddr_un beeth; + int fd; + + beeth.sun_family = AF_UNIX; + strlcpy(beeth.sun_path, path, sizeof(beeth.sun_path)); + + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { + debug("[rc] socket() failed: %s\n", strerror(errno)); + return -1; + } + + if (bind(fd, (struct sockaddr*) &beeth, sizeof(beeth))) { + debug("[rc] bind() failed: %s\n", strerror(errno)); + close(fd); + return -1; + } + + if (listen(fd, 10)) { + debug("[rc] listen() failed: %s\n", strerror(errno)); + close(fd); + return -1; + } + + return fd; +} + +/* + * rc_paths_changed() + * + * zmieniono zmienną remote_control. dodaj nowe kanały wejściowe, usuń te, + * których już nie ma. + */ +static void rc_paths_changed(const char *name) +{ + char **paths = array_make(rc_paths, ",; ", 0, 1, 1); + list_t l; + int i; + + /* usuń znaczniki. zaznaczymy sobie te, które są nadal wpisane */ + for (l = rc_inputs; l; l = l->next) { + rc_input_t *r = l->data; + + r->mark = 0; + } + + /* przejrzyj, czego chce użytkownik */ + for (i = 0; paths[i]; i++) { + watcher_handler_func_t *rc_input_handler = NULL; + int (*rc_input_new)(const char *) = NULL; + + rc_input_type_t type = 0; + const char *path = NULL; + + rc_input_t *r; + + if ((r = rc_input_find(paths[i]))) { + r->mark = 1; + continue; + } + + if (!strncmp(paths[i], "tcp:", 4)) { + rc_input_new = rc_input_new_tcp; + rc_input_handler = rc_input_handler_accept; + path = paths[i] + 4; + type = RC_INPUT_TCP; + } + + if (!strncmp(paths[i], "udp:", 4)) { + rc_input_new = rc_input_new_udp; + rc_input_handler = (watcher_handler_func_t*) rc_input_handler_line; + path = paths[i] + 4; + type = RC_INPUT_UDP; + } + + if (!strncmp(paths[i], "unix:", 5)) { + rc_input_new = rc_input_new_unix; + rc_input_handler = rc_input_handler_accept; + path = paths[i] + 5; + type = RC_INPUT_UNIX; + } + + if (!strncmp(paths[i], "pipe:", 5)) { + rc_input_new = rc_input_new_pipe; + rc_input_handler = (watcher_handler_func_t*) rc_input_handler_line; + path = paths[i] + 5; + type = RC_INPUT_PIPE; + } + + if (rc_input_new) { + rc_input_t *r; + int rfd; + + if ((rfd = (*rc_input_new)(path)) == -1) continue; + + r = xmalloc(sizeof(rc_input_t)); + + r->fd = rfd; + r->mark = 1; + r->path = xstrdup(paths[i]); + r->type = type; + + list_add(&rc_inputs, r); + + watch_add(&remote_plugin, rfd, + ((void *) rc_input_handler != (void *) rc_input_handler_line) ? WATCH_READ : WATCH_READ_LINE, + rc_input_handler, r); + continue; + } + + debug_error("[rc] unknown input type: %s\n", paths[i]); + } + + /* usuń te, które nie zostały zaznaczone */ + for (l = rc_inputs; l; ) { + /* to usunie rowniez aktualnie nawiazane polaczenia... */ + rc_input_t *r = l->data; + + l = l->next; + + if (r->mark) + continue; + + rc_input_close(r); /* it'll remove l->data */ + } + + array_free(paths); +} + +static int remote_window_new(window_t *w) { + remote_window_t *n; + + if (w->private) + return 0; + + n = xmalloc(sizeof(remote_window_t)); + + w->private = n; + return 0; +} + +static void remote_backlog_add(window_t *w, remote_backlog_t *str) { + remote_window_t *n = w->private; + + if (!w) + return; +#define config_backlog_size -1 + + if (n->backlog_size == config_backlog_size) { + remote_backlog_t *line = n->backlog[n->backlog_size - 1]; + + xfree(line->str); + xfree(line); + + n->backlog_size--; + } else + n->backlog = xrealloc(n->backlog, (n->backlog_size + 1) * sizeof(char *)); + + memmove(&n->backlog[1], &n->backlog[0], n->backlog_size * sizeof(char *)); + + n->backlog[0] = str; + + n->backlog_size++; +} + +static int remote_window_kill(window_t *w) { + remote_window_t *n = w->private; + + if (!n) + return -1; + + w->private = 0; + + if (n->backlog) { + int i; + + for (i = 0; i < n->backlog_size; i++) + xfree(n->backlog[i]); + + xfree(n->backlog); + + n->backlog = NULL; + n->backlog_size = 0; + } + + xfree(n); + return 0; +} + +/* XXX, nicer? */ +/* XXX, pipe: && udp: sucks */ +/* XXX, ssl: zlib: ? */ +static QUERY(remote_postinit) { + if (rc_inputs) + return 1; + + if (!rc_first) + printf("!!! rc_inputs == NULL, need reconfiguration of remote plugin!\n"); + + printf("Hi,\nI'm remote_postinit() function\n"); + + if (rc_first) + printf("According to remote:first_run value, this is your first run (or you manually changed it!)\n"); + + printf("I'm here to help you configure remote plugin\n"); + printf("\n"); + printf("remote:remote_control (Current value: %s)\n", rc_paths ? rc_paths : "null"); + printf("\te.g.: tcp:127.0.0.1:1234;tcp:1234;udp:127.0.0.1:1234;unix:mysocket;pipe:/tmp/mypipe\n"); + printf("\t (tcp:* or unix:* is prefered!\n"); + + do { + char *tmp; + + printf("(ekg2-remote) "); + fflush(stdout); + + tmp = read_file(stdin, 0); + + variable_set("remote:remote_control", tmp); + if (!rc_inputs) + printf("Sorry, rc_inputs still NULL, try again\n"); + + } while (rc_inputs == NULL); + printf("\n"); + + /* XXX, haslo pozniej */ + variable_set("remote:password", itoa(getpid())); + printf("Your password is: %s\n", rc_password); + + variable_set("remote:first_run", "0"); + + printf("\n"); + printf("ekg2-remote-plugin: configured!\n"); + printf("remember to change password (/set remote:password yournewpassword) and to save configuration after connect!\n"); + + return 0; +} + +static QUERY(remote_ui_is_initialized) { + int *tmp = va_arg(ap, int *); + + *tmp = 1; + return 0; +} + +static QUERY(remote_ui_window_clear) { + window_t *w = *(va_arg(ap, window_t **)); + + remote_broadcast("WINDOW_CLEAR", itoa(w->id), NULL); + return 0; +} + +static QUERY(remote_ui_window_new) { + window_t *w = *(va_arg(ap, window_t **)); + + remote_broadcast("WINDOW_NEW", itoa(w->id), w->target, NULL); /* w->target can be NULL */ + + if (w->alias) + remote_broadcast("WINDOWINFO", itoa(w->id), "ALIAS", w->alias, NULL); + + if (w->session) + remote_broadcast("WINDOWINFO", itoa(w->id), "SESSION", w->session->uid, NULL); + + remote_window_new(w); + return 0; +} + +static QUERY(remote_ui_window_kill) { + window_t *w = *(va_arg(ap, window_t **)); + + remote_broadcast("WINDOW_KILL", itoa(w->id), NULL); + + remote_window_kill(w); + return 0; +} + +static QUERY(remote_ui_window_switch) { + window_t *w = *(va_arg(ap, window_t **)); + + remote_broadcast("WINDOW_SWITCH", itoa(w->id), NULL); + return 0; +} + +static QUERY(remote_ui_window_print) { + window_t *w = *(va_arg(ap, window_t **)); + fstring_t *line = *(va_arg(ap, fstring_t **)); + char *fstr; + + remote_window_t *n; + + if (w == window_debug) /* XXX! */ + goto cleanup; + + /* XXX, sanityzowac (? na pewno?)*/ + + if (!(n = w->private)) { + /* BUGFIX, cause @ ui-window-print handler (not ncurses plugin one, ncurses plugin one is called last cause of 0 prio) + * plugin may call print_window() + */ + remote_window_new(w); + if (!(n = w->private)) { + debug("remote_ui_window_print() IInd CC still not w->private, quitting...\n"); + return -1; + } + } + + fstr = rc_fstring_reverse(line); + { + remote_backlog_t *ln = xmalloc(sizeof(remote_backlog_t)); + + ln->ts = line->ts; + ln->str = fstr; + + remote_backlog_add(w, ln); + } + + remote_broadcast("WINDOW_PRINT", itoa(w->id), itoa(line->ts), fstr, NULL); /* XXX, using id is ok? */ + +cleanup: + fstring_free(line); + return -1; /* XXX, sry, jak ktos potrzebuje tego stringa oprocz nas, to go nie dostanie. (memleaki sa gorsze) */ +} + +static QUERY(remote_ui_beep) { + remote_broadcast("BEEP", NULL); + return 0; +} + +static QUERY(remote_variable_changed) { + char *name = *(va_arg(ap, char**)); + const char *_val; + variable_t *v; + + if (!(v = variable_find(name))) { + debug_error("remote_variable_changed(%s) damn!\n", name); + return 0; /* XXX, we don't care ? */ + } + + _val = rc_var_get_value(v); + remote_broadcast("VARIABLE_CHANGED", name, _val, NULL); + + return 0; +} + +static QUERY(remote_protocol_connected) { + char *uid = *(va_arg(ap, char **)); + + remote_broadcast("SESSIONINFO", uid, "CONNECTED", "1", NULL); + return 0; +} + +static QUERY(remote_protocol_disconnected) { + char *uid = *(va_arg(ap, char **)); + char *reason = *(va_arg(ap, char **)); + int type = *(va_arg(ap, int*)); + + remote_broadcast("SESSIONINFO", uid, "CONNECTED", "0", NULL); + return 0; +} + +static QUERY(remote_ui_window_target_changed) { + window_t *w = *(va_arg(ap, window_t **)); + +/* wysylamy wszystko, bo nie wiemy co sie zmienilo, a co nie */ + remote_broadcast("WINDOWINFO", itoa(w->id), "ALIAS", w->alias, NULL); + remote_broadcast("WINDOWINFO", itoa(w->id), "TARGET", w->target, NULL); + remote_broadcast("WINDOWINFO", itoa(w->id), "SESSION", w->session ? w->session->uid : NULL, NULL); + return 0; +} + +static QUERY(remote_session_changed) { +#if 0 /* fajne, ale dla nas fajniejsze jest UI_WINDOW_TARGET_CHANGED */ + + /* emitowane gdy sie zmienia session_current */ + /* XXX, zweryfikowac jeszcze raz (tylko core) */ + + if (!session_current) { + debug_error("remote_session_changed() but session_current == NULL?\n"); + return 0; + } + + remote_broadcast("SESSIONCHANGED", session_current->uid, NULL); +#endif + return 0; +} + +static QUERY(remote_all_contacts_changed) { +// remote_broadcast((data) ? "REFRESH_USERLIST_FULL\n" : "REFRESH_USERLIST\n"); /* XXX, nie przetwarzane */ + /* XXX, inaczej, to tak nie bedzie dzialac. trzeba zrobic wsparcie dla wszystkich */ + return 0; +} + +EXPORT int remote_plugin_init(int prio) { + int is_UI = 0; + + PLUGIN_CHECK_VER("remote"); + + query_emit_id(NULL, UI_IS_INITIALIZED, &is_UI); + + if (is_UI) + return -1; + + plugin_register(&remote_plugin, prio); + + variable_add(&remote_plugin, ("remote_control"), VAR_STR, 1, &rc_paths, rc_paths_changed, NULL, NULL); + variable_add(&remote_plugin, ("first_run"), VAR_INT, 2, &rc_first, NULL, NULL, NULL); + variable_add(&remote_plugin, ("password"), VAR_STR, 0, &rc_password, NULL, NULL, NULL); + + query_connect_id(&remote_plugin, UI_IS_INITIALIZED, remote_ui_is_initialized, NULL); + query_connect_id(&remote_plugin, CONFIG_POSTINIT, remote_postinit, NULL); + + query_connect_id(&remote_plugin, UI_WINDOW_SWITCH, remote_ui_window_switch, NULL); + query_connect_id(&remote_plugin, UI_WINDOW_KILL, remote_ui_window_kill, NULL); + query_connect_id(&remote_plugin, UI_BEEP, remote_ui_beep, NULL); + query_connect_id(&remote_plugin, UI_WINDOW_PRINT, remote_ui_window_print, NULL); + query_connect_id(&remote_plugin, UI_WINDOW_CLEAR, remote_ui_window_clear, NULL); + query_connect_id(&remote_plugin, UI_WINDOW_NEW, remote_ui_window_new, NULL); + query_connect_id(&remote_plugin, UI_WINDOW_TARGET_CHANGED, remote_ui_window_target_changed, NULL); + query_connect_id(&remote_plugin, VARIABLE_CHANGED, remote_variable_changed, NULL); + + /* SESSION_EVENT */ + query_connect_id(&remote_plugin, PROTOCOL_CONNECTED, remote_protocol_connected, NULL); + query_connect_id(&remote_plugin, PROTOCOL_DISCONNECTED, remote_protocol_disconnected, NULL); + + query_connect_id(&remote_plugin, SESSION_CHANGED, remote_session_changed, NULL); + +#if 0 + + query_connect_id(&remote_plugin, UI_WINDOW_TARGET_CHANGED, ncurses_ui_window_target_changed, NULL); + query_connect_id(&remote_plugin, UI_WINDOW_ACT_CHANGED, ncurses_ui_window_act_changed, NULL); + query_connect_id(&remote_plugin, UI_WINDOW_REFRESH, ncurses_ui_window_refresh, NULL); + query_connect_id(&remote_plugin, UI_WINDOW_UPDATE_LASTLOG, ncurses_ui_window_lastlog, NULL); + query_connect_id(&remote_plugin, UI_REFRESH, ncurses_ui_refresh, NULL); + query_connect_id(&remote_plugin, SESSION_ADDED, ncurses_statusbar_query, NULL); + query_connect_id(&remote_plugin, SESSION_REMOVED, ncurses_statusbar_query, NULL); + query_connect_id(&remote_plugin, SESSION_RENAMED, ncurses_statusbar_query, NULL); + query_connect_id(&remote_plugin, BINDING_SET, ncurses_binding_set_query, NULL); + query_connect_id(&remote_plugin, BINDING_COMMAND, ncurses_binding_adddelete_query, NULL); + query_connect_id(&remote_plugin, BINDING_DEFAULT, ncurses_binding_default, NULL); + query_connect_id(&remote_plugin, CONFERENCE_RENAMED, ncurses_conference_renamed, NULL); + + query_connect_id(&remote_plugin, PROTOCOL_DISCONNECTING, ncurses_session_disconnect_handler, NULL); +#endif + + /* podanie czegokolwiek jako data do remote_all_contacts_changed() powoduje wyzerowanie n->start */ + query_connect_id(&remote_plugin, UI_REFRESH, remote_all_contacts_changed, (void *) 1); + query_connect_id(&remote_plugin, USERLIST_REFRESH, remote_all_contacts_changed, NULL /* ? */); + + query_connect_id(&remote_plugin, SESSION_CHANGED, remote_all_contacts_changed, (void *) 1); + query_connect_id(&remote_plugin, SESSION_EVENT, remote_all_contacts_changed, NULL); + + query_connect_id(&remote_plugin, METACONTACT_ADDED, remote_all_contacts_changed, NULL); + query_connect_id(&remote_plugin, METACONTACT_REMOVED, remote_all_contacts_changed, NULL); + query_connect_id(&remote_plugin, METACONTACT_ITEM_ADDED, remote_all_contacts_changed, NULL); + query_connect_id(&remote_plugin, METACONTACT_ITEM_REMOVED, remote_all_contacts_changed, NULL); + + query_connect_id(&remote_plugin, USERLIST_CHANGED, remote_all_contacts_changed, NULL); + query_connect_id(&remote_plugin, USERLIST_ADDED, remote_all_contacts_changed, NULL); + query_connect_id(&remote_plugin, USERLIST_REMOVED, remote_all_contacts_changed, NULL); + query_connect_id(&remote_plugin, USERLIST_RENAMED, remote_all_contacts_changed, NULL); + + + +/* XXX, signal()? on ^C, do ekg_exit() etc..? */ + + return 0; +} + +static int remote_plugin_destroy() { + list_t l; + + for (l = rc_inputs; l;) { + rc_input_t *r = l->data; + + l = l->next; + + rc_input_close(r); + } + + plugin_unregister(&remote_plugin); + + return 0; +} + +/* + * Local Variables: + * mode: c + * c-file-style: "k&r" + * c-basic-offset: 8 + * indent-tabs-mode: t + * End: + */ From svn w toxygen.net Tue Sep 16 23:59:48 2008 From: svn w toxygen.net (SVN commit) Date: Tue, 16 Sep 2008 23:59:48 +0200 (CEST) Subject: [ekg2-commit] r4645 - trunk/plugins/icq: +trunk/plugins/icq/icq_const.h trunk/plugins/icq/icq_snac_handlers.c trunk/plugins/icq/icq_snac_handlers_04message.inc Message-ID: <20080916215948.0F5C017B1F@toxygen.net> Author: wiechu Date: 2008-09-16 23:59:47 +0200 (Tue, 16 Sep 2008) New Revision: 4645 Added: trunk/plugins/icq/icq_const.h Modified: trunk/plugins/icq/icq_snac_handlers.c trunk/plugins/icq/icq_snac_handlers_04message.inc Log: process TLV(0x2711) based messages (next step) Added: trunk/plugins/icq/icq_const.h =================================================================== --- trunk/plugins/icq/icq_const.h (rev 0) +++ trunk/plugins/icq/icq_const.h 2008-09-16 21:59:47 UTC (rev 4645) @@ -0,0 +1,30 @@ +#ifndef __ICQ_CONST_H +#define __ICQ_CONST_H + +/* + * Message types. + * Each OSCAR message has type. It can be just plain message, url message, contact list, wwp, email express or another. + * Only one byte used for message type. Here is the list of known message types: + */ + +#define MTYPE_PLAIN 0x01 /* Plain text (simple) message */ +#define MTYPE_CHAT 0x02 /* Chat request message */ +#define MTYPE_FILEREQ 0x03 /* File request / file ok message */ +#define MTYPE_URL 0x04 /* URL message (0xFE formatted) */ +#define MTYPE_AUTHREQ 0x06 /* Authorization request message (0xFE formatted) */ +#define MTYPE_AUTHDENY 0x07 /* Authorization denied message (0xFE formatted) */ +#define MTYPE_AUTHOK 0x08 /* Authorization given message (empty) */ +#define MTYPE_SERVER 0x09 /* Message from OSCAR server (0xFE formatted) */ +#define MTYPE_ADDED 0x0C /* "You-were-added" message (0xFE formatted) */ +#define MTYPE_WWP 0x0D /* Web pager message (0xFE formatted) */ +#define MTYPE_EEXPRESS 0x0E /* Email express message (0xFE formatted) */ +#define MTYPE_CONTACTS 0x13 /* Contact list message */ +#define MTYPE_PLUGIN 0x1A /* Plugin message described by text string */ +#define MTYPE_AUTOAWAY 0xE8 /* Auto away message */ +#define MTYPE_AUTOBUSY 0xE9 /* Auto occupied message */ +#define MTYPE_AUTONA 0xEA /* Auto not available message */ +#define MTYPE_AUTODND 0xEB /* Auto do not disturb message */ +#define MTYPE_AUTOFFC 0xEC /* Auto free for chat message */ + + +#endif Modified: trunk/plugins/icq/icq_snac_handlers.c =================================================================== --- trunk/plugins/icq/icq_snac_handlers.c 2008-09-16 21:10:29 UTC (rev 4644) +++ trunk/plugins/icq/icq_snac_handlers.c 2008-09-16 21:59:47 UTC (rev 4645) @@ -32,6 +32,7 @@ #include "misc.h" #include "icq_caps.h" +#include "icq_const.h" #include "icq_flap_handlers.h" #include "icq_snac_handlers.h" Modified: trunk/plugins/icq/icq_snac_handlers_04message.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_04message.inc 2008-09-16 21:10:29 UTC (rev 4644) +++ trunk/plugins/icq/icq_snac_handlers_04message.inc 2008-09-16 21:59:47 UTC (rev 4645) @@ -165,20 +165,20 @@ } -static int icq_snac_message_recv_rtf2711(session_t *s, unsigned char *buf, int len, const char *sender) { +static int icq_snac_message_recv_rtf2711(session_t *s, unsigned char *buf, int len, const char *sender, int ack) { struct { uint16_t len; /* length of following data (LE) */ uint16_t ver; /* protocol version (LE) */ unsigned char *plug; /* plugin or zero bytes (len=0x16) */ - uint16_t unkn1; /* unknown */ - uint32_t capflg; /* client capabilities flags */ - uint8_t unkn2; /* unknown */ - uint16_t dcnt; /* seems to be a downcounter (LE) */ + uint16_t _unkn1; /* unknown */ + uint32_t _capflg; /* client capabilities flags */ + uint8_t _unkn2; /* unknown */ + uint16_t _dcnt; /* seems to be a downcounter (LE) */ } pkt1; struct { uint16_t len; /* length of following data (LE) */ - uint16_t dcnt; /* seems to be a downcounter as in first chunk above */ - char *unkn; /* unknown, usually zeros */ + uint16_t _dcnt; /* seems to be a downcounter as in first chunk above */ + char *_unkn; /* unknown, usually zeros */ } pkt2; /* if plugin field in first chunk above is zero, here is message, overwise here is plugin-specific data. */ struct { @@ -208,18 +208,42 @@ buf += pkt2.len + 2; len -= pkt2.len + 2; - if (icq_plugin_id(pkt1.plug) != PLUGIN_NONE) { - debug_error("icq_snac_message_recv_rtf2711() we've got data for unknown plugin\n"); - icq_hexdump(DEBUG_ERROR, buf, len); - return 1; + switch (icq_plugin_id(pkt1.plug)) { + case PLUGIN_NONE: + { + /* message */ + ICQ_UNPACK(&buf, "ccwww", &msg.type, &msg.flags, &msg.status, &msg.prio, &msg.len); + msg.str = (char *)buf; + + switch (msg.type) { + /* strange types - XXX ?wo? handle? */ + case MTYPE_FILEREQ: + case MTYPE_CHAT: + case MTYPE_PLUGIN: + debug_warn("icq_snac_message_recv_rtf2711() message type 0x%x not handled yet\n", msg.type); + break; + default: + /* normal message */ + if (msg.len) { + time_t sent = time(NULL); + char *uid = icq_uid(sender); + char *tmp = ekg_utf8_to_locale(xstrdup(msg.str)); + + protocol_message_emit(s, uid, NULL, tmp, NULL, sent, EKG_MSGCLASS_CHAT, NULL, EKG_TRY_BEEP, 0); + + xfree(tmp); + xfree(uid); + } + break; + } + break; + } + default: + debug_error("icq_snac_message_recv_rtf2711() we've got data for unknown plugin\n"); + icq_hexdump(DEBUG_ERROR, buf, len); } - ICQ_UNPACK(&buf, "ccwww", &msg.type, &msg.flags, &msg.status, &msg.prio, &msg.len); - msg.str = (char *)buf; - /* XXX XXX XXX ...and now we... ??? */ - debug_error(" 2711 string is '%s'\n", msg.str); - return 0; } @@ -230,8 +254,9 @@ unsigned char *cap; // capability (determines format of message data) } pkt; + int ack = -1; struct icq_tlv_list *tlvs, *tlvs5; - icq_tlv_t *t5, *t_msg; + icq_tlv_t *t, *t5, *t_msg; debug_function("icq_snac_message_recv_rtf() from: %s leftlen: %d\n", sender, len); @@ -254,7 +279,7 @@ icq_unpack_nc(t5->buf, t5->len, "WII", &pkt.type, &pkt.id1, &pkt.id2); - pkt.cap = t5->buf + (2 + 4 + 4); + pkt.cap = t5->buf + (2 + 4 + 4); /* msg capability */ t5->buf += (2 + 4 + 4 + 0x10); t5->len -= (2 + 4 + 4 + 0x10); @@ -263,7 +288,22 @@ icq_tlvs_destroy(&tlvs); return 0; } + /* + * TLV.Type(0x0A) - Acktype: + * 0x0000 - normal message + * 0x0001 - file request / abort request + * 0x0002 - file ack + * + * TLV.Type(0x03) - external ip + * TLV.Type(0x04) - internal ip + * TLV.Type(0x05) - listening port + * TLV.Type(0x0F) - unknown (empty) + * TLV.Type(0x2711) - extention data + */ + if ( (t = icq_tlv_get(tlvs5, 0x0a) ) ) + ack = t->nr; + if (!(t_msg = icq_tlv_get(tlvs5, 0x2711))) { debug_error("icq_snac_message_recv_rtf() TLV(0x2711) not found?\n"); icq_tlvs_destroy(&tlvs5); @@ -275,9 +315,13 @@ switch (icq_cap_id(pkt.cap)) { case CAP_SRV_RELAY: { - icq_snac_message_recv_rtf2711(s, t_msg->buf, t_msg->len, sender); + icq_snac_message_recv_rtf2711(s, t_msg->buf, t_msg->len, sender, ack); break; } + /* TO DO! ?wo? XXX */ + case CAP_ICQDIRECT: + case CAP_SENDFILE: + case CAP_CONTACTS: default: debug_error("icq_snac_message_recv_rtf() Unknow 0x2711 message for capability id=%d\n", icq_cap_id(pkt.cap)); From svn w toxygen.net Wed Sep 17 10:50:52 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 17 Sep 2008 10:50:52 +0200 (CEST) Subject: [ekg2-commit] r4646 - trunk/ekg: trunk/ekg/themes.c trunk/ekg/themes.h Message-ID: <20080917085052.A098817B1F@toxygen.net> Author: darkjames Date: 2008-09-17 10:50:52 +0200 (Wed, 17 Sep 2008) New Revision: 4646 Modified: trunk/ekg/themes.c trunk/ekg/themes.h Log: forgotten about "no_prompt_cache" Modified: trunk/ekg/themes.c =================================================================== --- trunk/ekg/themes.c 2008-09-16 21:59:47 UTC (rev 4645) +++ trunk/ekg/themes.c 2008-09-17 08:50:52 UTC (rev 4646) @@ -1207,12 +1207,18 @@ return 0; } -void theme_enumerate(int *(enumerator)(const char *theme, const char *value)) { +void theme_enumerate(int (*enumerator)(const char *theme, const char *value)) { int i; if (!enumerator) return; + if (no_prompt_cache) { + if (!enumerator("no_prompt_cache", "")) + return; + } + + for (i = 0; i < 0x100; i++) { struct format *ff; Modified: trunk/ekg/themes.h =================================================================== --- trunk/ekg/themes.h 2008-09-16 21:59:47 UTC (rev 4645) +++ trunk/ekg/themes.h 2008-09-17 08:50:52 UTC (rev 4646) @@ -66,7 +66,7 @@ void theme_init(); void theme_plugins_init(); -void theme_enumerate(int *(enumerator)(const char *theme, const char *value)); +void theme_enumerate(int (*enumerator)(const char *theme, const char *value)); int theme_read(const char *filename, int replace); int theme_write(const char *filename); void theme_cache_reset(); From svn w toxygen.net Wed Sep 17 11:24:48 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 17 Sep 2008 11:24:48 +0200 (CEST) Subject: [ekg2-commit] r4647 - trunk/ekg: trunk/ekg/sessions.c Message-ID: <20080917092448.51D4217B1F@toxygen.net> Author: darkjames Date: 2008-09-17 11:24:47 +0200 (Wed, 17 Sep 2008) New Revision: 4647 Modified: trunk/ekg/sessions.c Log: - fix SESSION_RENAMED emit Modified: trunk/ekg/sessions.c =================================================================== --- trunk/ekg/sessions.c 2008-09-17 08:50:52 UTC (rev 4646) +++ trunk/ekg/sessions.c 2008-09-17 09:24:47 UTC (rev 4647) @@ -737,9 +737,20 @@ return -1; if (!xstrcasecmp(key, "alias")) { - char *tmp = xstrdup(value); + char *tmp; + ret = session_alias_set(s, value); + /* note: + * if we unset session alias, than value is NULL + * some code in metacontacts and remote plugin + * rely on if they can find session, session_find(NULL) will always return NULL :( + * + * I think it'll be better if we always pass s->uid + * but for now this is enough for me + */ + + tmp = xstrdup((value) ? value : s->uid); query_emit_id(NULL, SESSION_RENAMED, &tmp); xfree(tmp); From svn w toxygen.net Wed Sep 17 16:01:30 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 17 Sep 2008 16:01:30 +0200 (CEST) Subject: [ekg2-commit] r4648 - trunk/ekg: trunk/ekg/plugins.c Message-ID: <20080917140130.4EDA717B1F@toxygen.net> Author: darkjames Date: 2008-09-17 16:01:29 +0200 (Wed, 17 Sep 2008) New Revision: 4648 Modified: trunk/ekg/plugins.c Log: uch, fix bad-code. Modified: trunk/ekg/plugins.c =================================================================== --- trunk/ekg/plugins.c 2008-09-17 09:24:47 UTC (rev 4647) +++ trunk/ekg/plugins.c 2008-09-17 14:01:29 UTC (rev 4648) @@ -963,7 +963,8 @@ int ret, res = 0; int (*handler)(int, int, const char *, void *) = w->handler; - if (w || w->removed == -1); /* watch is running in another thread / context */ + if (!w || w->removed == -1) + return; /* watch is running in another thread / context */ w->removed = -1; #ifndef NO_POSIX_SYSTEM From svn w toxygen.net Wed Sep 17 19:08:15 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 17 Sep 2008 19:08:15 +0200 (CEST) Subject: [ekg2-commit] r4649 - trunk: trunk/SConstruct Message-ID: <20080917170815.383EF17B1F@toxygen.net> Author: peres Date: 2008-09-17 19:08:14 +0200 (Wed, 17 Sep 2008) New Revision: 4649 Modified: trunk/SConstruct Log: Fix missing SConscript. Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2008-09-17 14:01:29 UTC (rev 4648) +++ trunk/SConstruct 2008-09-17 17:08:14 UTC (rev 4649) @@ -263,6 +263,8 @@ for p in avplugins: info = SConscript('plugins/%s/SConscript' % p, ['env', 'opts']) + if not info: + continue values = [] if 'depends' in info: for a in info['depends']: From svn w toxygen.net Wed Sep 17 19:10:35 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 17 Sep 2008 19:10:35 +0200 (CEST) Subject: [ekg2-commit] r4650 - trunk/plugins/remote: +trunk/plugins/remote/SConscript Message-ID: <20080917171035.D3C9517B1F@toxygen.net> Author: peres Date: 2008-09-17 19:10:35 +0200 (Wed, 17 Sep 2008) New Revision: 4650 Added: trunk/plugins/remote/SConscript Log: Add plugin definition. Added: trunk/plugins/remote/SConscript =================================================================== --- trunk/plugins/remote/SConscript (rev 0) +++ trunk/plugins/remote/SConscript 2008-09-17 17:10:35 UTC (rev 4650) @@ -0,0 +1,18 @@ + +Import('*') + +try: + env +except NameError: + pass +else: + plugin = { + 'type': 'ui', + 'state': 'experimental', + 'depends': [], + 'optdepends': [] + } + + Return('plugin') + +# vim:ts=4:sts=4:sw=4:syntax=python From svn w toxygen.net Wed Sep 17 20:09:52 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 17 Sep 2008 20:09:52 +0200 (CEST) Subject: [ekg2-commit] r4651 - trunk/plugins/ncurses: trunk/plugins/ncurses/vars-pl.txt Message-ID: <20080917180952.8B5F117B34@toxygen.net> Author: darkjames Date: 2008-09-17 20:09:52 +0200 (Wed, 17 Sep 2008) New Revision: 4651 Modified: trunk/plugins/ncurses/vars-pl.txt Log: fix /help set ncurses:kill_irc_window Modified: trunk/plugins/ncurses/vars-pl.txt =================================================================== --- trunk/plugins/ncurses/vars-pl.txt 2008-09-17 17:10:35 UTC (rev 4650) +++ trunk/plugins/ncurses/vars-pl.txt 2008-09-17 18:09:52 UTC (rev 4651) @@ -166,7 +166,7 @@ domyślna wartość: 1 jeśli ustawiona na 0, nie można zamknąć okna kanału ircowego przy - pomocy bindingu klawiaturowego. + pomocy bindingu klawiaturowego. margin_size typ: liczba From svn w toxygen.net Wed Sep 17 22:22:37 2008 From: svn w toxygen.net (SVN commit) Date: Wed, 17 Sep 2008 22:22:37 +0200 (CEST) Subject: [ekg2-commit] r4652 - in trunk: ekg plugins/gg: trunk/ekg/userlist.c trunk/plugins/gg/pubdir.c Message-ID: <20080917202237.C830117B1F@toxygen.net> Author: darkjames Date: 2008-09-17 22:22:37 +0200 (Wed, 17 Sep 2008) New Revision: 4652 Modified: trunk/ekg/userlist.c trunk/plugins/gg/pubdir.c Log: - poprawka odswiezania userlist po /gg:userlist --get - poprawka odswiezania userlisty po userlist_read() Modified: trunk/ekg/userlist.c =================================================================== --- trunk/ekg/userlist.c 2008-09-17 18:09:52 UTC (rev 4651) +++ trunk/ekg/userlist.c 2008-09-17 20:22:37 UTC (rev 4652) @@ -199,6 +199,8 @@ userlist_add_entry(session, buf); } + query_emit_id(NULL, USERLIST_REFRESH); /* XXX, wywolywac tylko kiedy dodalismy przynajmniej 1 */ + fclose(f); return 0; Modified: trunk/plugins/gg/pubdir.c =================================================================== --- trunk/plugins/gg/pubdir.c 2008-09-17 18:09:52 UTC (rev 4651) +++ trunk/plugins/gg/pubdir.c 2008-09-17 20:22:37 UTC (rev 4652) @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -531,6 +532,8 @@ array_free(entries); + query_emit_id(NULL, USERLIST_REFRESH); + return 0; } From svn w toxygen.net Thu Sep 18 00:15:56 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 18 Sep 2008 00:15:56 +0200 (CEST) Subject: [ekg2-commit] r4653 - trunk/plugins/remote: trunk/plugins/remote/remote.c Message-ID: <20080917221556.9D61017B1F@toxygen.net> Author: darkjames Date: 2008-09-18 00:15:56 +0200 (Thu, 18 Sep 2008) New Revision: 4653 Modified: trunk/plugins/remote/remote.c Log: aliasy, userlista (na razie tylko po polaczeniu) Modified: trunk/plugins/remote/remote.c =================================================================== --- trunk/plugins/remote/remote.c 2008-09-17 20:22:37 UTC (rev 4652) +++ trunk/plugins/remote/remote.c 2008-09-17 22:15:56 UTC (rev 4653) @@ -372,6 +372,8 @@ remote_writefd(fd, "SESSIONINFO", s->uid, "STATUS", itoa(s->status), NULL); remote_writefd(fd, "SESSIONINFO", s->uid, "CONNECTED", itoa(s->connected), NULL); + if (s->alias) + remote_writefd(fd, "SESSIONINFO", s->uid, "ALIAS", s->alias, NULL); } remote_writefd(fd, "+SESSION", NULL); @@ -389,6 +391,36 @@ } remote_writefd(fd, "WINDOW_SWITCH", itoa(window_current->id), NULL); remote_writefd(fd, "+WINDOW", NULL); + + } else if (!xstrcmp(cmd, "REQUSERLISTS")) { + +#define fix(x) ((x) ? x : "") + session_t *s; + window_t *w; + userlist_t *u; + + /* najpierw sesyjna userlista */ + for (s = sessions; s; s = s->next) { + for (u = s->userlist; u; u = u->next) { + char *groups = (u->groups) ? group_to_string(u->groups, 1, 0) : NULL; + remote_writefd(fd, "SESSIONITEM", s->uid, fix(u->uid), itoa(u->status), fix(u->nickname), fix(groups), NULL); + xfree(groups); + } + } + + /* potem okienkowe userlisty */ + for (w = windows; w; w = w->next) { + for (u = w->userlist; u; u = u->next) { + char *groups = (u->groups) ? group_to_string(u->groups, 1, 0) : NULL; + remote_writefd(fd, "WINDOWITEM", itoa(w->id), fix(u->uid), itoa(u->status), fix(u->nickname), fix(groups), NULL); + xfree(groups); + } + + } + /* XXX, konferencyjne userlisty? */ +#undef fix + remote_writefd(fd, "+USERLIST", NULL); + /* rozniaste */ } else if (!xstrcmp(cmd, "REQSESSION_CYCLE")) { if (arrcnt == 2) { @@ -417,7 +449,6 @@ } } -cleanup: array_free(arr); return 0; } @@ -1006,6 +1037,34 @@ return 0; } +static QUERY(remote_session_renamed) { + char *alias = *(va_arg(ap, char **)); + session_t *s; + + if (!(s = session_find(alias))) { + debug_error("remote_session_renamed(%s) damn!\n", alias); + return 0; + } + + remote_broadcast("SESSIONINFO", s->uid, "ALIAS", s->alias, NULL); + + return 0; +} + +static QUERY(remote_userlist_refresh) { + /* ze wstepnej analizy wynika ze ulubionym query po userlist_add() jest emitowanie USERLIST_REFRESH... + * bez parametrow, najwygodniejsze, + * + * w zwiazku z tym mozemy wyslac (ponownie) userliste ze wszystkich (sesji,okien) poprzedzajac jakims CLEARSMTH (b. niefajne) + * albo przynajmniej dodac do USERLIST_REFRESH parametr na ktorej sesji/oknie robimy te operacje... + * + * Tutaj przelecimy wszystkie znane listy, i sprawdzimy czy jakis pointer sie zgadza, jak tak to wyslemy tylko ja. + */ + + return 0; +} + + static QUERY(remote_all_contacts_changed) { // remote_broadcast((data) ? "REFRESH_USERLIST_FULL\n" : "REFRESH_USERLIST\n"); /* XXX, nie przetwarzane */ /* XXX, inaczej, to tak nie bedzie dzialac. trzeba zrobic wsparcie dla wszystkich */ @@ -1045,7 +1104,10 @@ query_connect_id(&remote_plugin, PROTOCOL_DISCONNECTED, remote_protocol_disconnected, NULL); query_connect_id(&remote_plugin, SESSION_CHANGED, remote_session_changed, NULL); + query_connect_id(&remote_plugin, SESSION_RENAMED, remote_session_renamed, NULL); + query_connect_id(&remote_plugin, USERLIST_REFRESH, remote_userlist_refresh, NULL); + #if 0 query_connect_id(&remote_plugin, UI_WINDOW_TARGET_CHANGED, ncurses_ui_window_target_changed, NULL); @@ -1055,7 +1117,6 @@ query_connect_id(&remote_plugin, UI_REFRESH, ncurses_ui_refresh, NULL); query_connect_id(&remote_plugin, SESSION_ADDED, ncurses_statusbar_query, NULL); query_connect_id(&remote_plugin, SESSION_REMOVED, ncurses_statusbar_query, NULL); - query_connect_id(&remote_plugin, SESSION_RENAMED, ncurses_statusbar_query, NULL); query_connect_id(&remote_plugin, BINDING_SET, ncurses_binding_set_query, NULL); query_connect_id(&remote_plugin, BINDING_COMMAND, ncurses_binding_adddelete_query, NULL); query_connect_id(&remote_plugin, BINDING_DEFAULT, ncurses_binding_default, NULL); From svn w toxygen.net Thu Sep 18 00:17:45 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 18 Sep 2008 00:17:45 +0200 (CEST) Subject: [ekg2-commit] r4654 - trunk/ekg: trunk/ekg/dynstuff.c trunk/ekg/userlist.c Message-ID: <20080917221745.888E117B1F@toxygen.net> Author: wiechu Date: 2008-09-18 00:17:45 +0200 (Thu, 18 Sep 2008) New Revision: 4654 Modified: trunk/ekg/dynstuff.c trunk/ekg/userlist.c Log: - fix memleak (reported by darkjames on !ekg2) - speed up private_item_find() Modified: trunk/ekg/dynstuff.c =================================================================== --- trunk/ekg/dynstuff.c 2008-09-17 22:15:56 UTC (rev 4653) +++ trunk/ekg/dynstuff.c 2008-09-17 22:17:45 UTC (rev 4654) @@ -1409,14 +1409,16 @@ static private_data_t *private_item_find(private_data_t **data, const char *item_name) { private_data_t *item; + int cmp; if (!item_name) return NULL; for (item = *data; item; item = item->next) { - int cmp = xstrcmp(item->name, item_name); - if (!cmp) + if ( !(cmp = xstrcmp(item->name, item_name)) ) return item; + if (cmp>0) + return NULL; } return NULL; Modified: trunk/ekg/userlist.c =================================================================== --- trunk/ekg/userlist.c 2008-09-17 22:15:56 UTC (rev 4653) +++ trunk/ekg/userlist.c 2008-09-17 22:17:45 UTC (rev 4654) @@ -102,10 +102,7 @@ static LIST_ADD_COMPARE(userlist_compare, userlist_t *) { return xstrcasecmp(data1->nickname, data2->nickname); } static LIST_FREE_ITEM(userlist_free_item, userlist_t *) { userlist_private_free(data); - if (data->priv_list) { - private_data_free(data->priv_list); - xfree(data->priv_list); - } + private_items_destroy(&data->priv_list); xfree(data->uid); xfree(data->nickname); xfree(data->descr); xfree(data->foreign); xfree(data->last_descr); ekg_groups_destroy(&(data->groups)); ekg_resources_destroy(&(data->resources)); From svn w toxygen.net Thu Sep 18 00:41:08 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 18 Sep 2008 00:41:08 +0200 (CEST) Subject: [ekg2-commit] r4655 - trunk/ekg: trunk/ekg/dynstuff.c trunk/ekg/dynstuff.h Message-ID: <20080917224108.E338A17B1F@toxygen.net> Author: darkjames Date: 2008-09-18 00:41:08 +0200 (Thu, 18 Sep 2008) New Revision: 4655 Modified: trunk/ekg/dynstuff.c trunk/ekg/dynstuff.h Log: small style-fixes Modified: trunk/ekg/dynstuff.c =================================================================== --- trunk/ekg/dynstuff.c 2008-09-17 22:17:45 UTC (rev 4654) +++ trunk/ekg/dynstuff.c 2008-09-17 22:41:08 UTC (rev 4655) @@ -1396,17 +1396,16 @@ return xstrcmp(item1->name, item2->name); } -void private_data_free(private_data_t *item) { - xfree(item->name); - xfree(item->value); +static LIST_FREE_ITEM(private_data_free, private_data_t *) { + xfree(data->name); + xfree(data->value); } -static __DYNSTUFF_ADD_SORTED(private_items, private_data_t, private_data_cmp) +DYNSTUFF_LIST_DECLARE_SORTED(private_items, private_data_t, private_data_cmp, private_data_free, + static __DYNSTUFF_ADD_SORTED, /* private_items_add() */ + static __DYNSTUFF_REMOVE_SAFE, /* private_items_remove() */ + __DYNSTUFF_DESTROY) /* private_items_destroy() */ -static __DYNSTUFF_REMOVE_SAFE(private_items, private_data_t, private_data_free) - -__DYNSTUFF_DESTROY(private_items, private_data_t, private_data_free) - static private_data_t *private_item_find(private_data_t **data, const char *item_name) { private_data_t *item; int cmp; Modified: trunk/ekg/dynstuff.h =================================================================== --- trunk/ekg/dynstuff.h 2008-09-17 22:17:45 UTC (rev 4654) +++ trunk/ekg/dynstuff.h 2008-09-17 22:41:08 UTC (rev 4655) @@ -201,7 +201,6 @@ void private_item_set(private_data_t **data, const char *item_name, const char *value); void private_item_set_int(private_data_t **data, const char *item_name, int value); -void private_data_free(private_data_t *item); void private_items_destroy(private_data_t **data); From svn w toxygen.net Thu Sep 18 14:50:24 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 18 Sep 2008 14:50:24 +0200 (CEST) Subject: [ekg2-commit] r4656 - trunk/plugins/remote: trunk/plugins/remote/remote.c Message-ID: <20080918125024.4C0BC17B1F@toxygen.net> Author: darkjames Date: 2008-09-18 14:50:23 +0200 (Thu, 18 Sep 2008) New Revision: 4656 Modified: trunk/plugins/remote/remote.c Log: - w->act Modified: trunk/plugins/remote/remote.c =================================================================== --- trunk/plugins/remote/remote.c 2008-09-17 22:41:08 UTC (rev 4655) +++ trunk/plugins/remote/remote.c 2008-09-18 12:50:23 UTC (rev 4656) @@ -385,9 +385,10 @@ if (w->alias) remote_writefd(fd, "WINDOWINFO", itoa(w->id), "ALIAS", w->alias, NULL); - if (w->session) remote_writefd(fd, "WINDOWINFO", itoa(w->id), "SESSION", w->session->uid, NULL); + if (w->act) + remote_writefd(fd, "WINDOWINFO", itoa(w->id), "ACTIVITY", itoa(w->act), NULL); } remote_writefd(fd, "WINDOW_SWITCH", itoa(window_current->id), NULL); remote_writefd(fd, "+WINDOW", NULL); @@ -447,7 +448,6 @@ } else { debug_error("unknown command: %s\n", cmd); } - } array_free(arr); return 0; @@ -1021,6 +1021,14 @@ return 0; } +static QUERY(remote_ui_window_act_changed) { + window_t *w = *(va_arg(ap, window_t **)); /* note: since r4642 */ + /* XXX, in_typing */ + + remote_broadcast("WINDOWINFO", itoa(w->id), "ACTIVITY", itoa(w->act), NULL); + return 0; +} + static QUERY(remote_session_changed) { #if 0 /* fajne, ale dla nas fajniejsze jest UI_WINDOW_TARGET_CHANGED */ @@ -1097,6 +1105,7 @@ query_connect_id(&remote_plugin, UI_WINDOW_CLEAR, remote_ui_window_clear, NULL); query_connect_id(&remote_plugin, UI_WINDOW_NEW, remote_ui_window_new, NULL); query_connect_id(&remote_plugin, UI_WINDOW_TARGET_CHANGED, remote_ui_window_target_changed, NULL); + query_connect_id(&remote_plugin, UI_WINDOW_ACT_CHANGED, remote_ui_window_act_changed, NULL); query_connect_id(&remote_plugin, VARIABLE_CHANGED, remote_variable_changed, NULL); /* SESSION_EVENT */ @@ -1111,7 +1120,6 @@ #if 0 query_connect_id(&remote_plugin, UI_WINDOW_TARGET_CHANGED, ncurses_ui_window_target_changed, NULL); - query_connect_id(&remote_plugin, UI_WINDOW_ACT_CHANGED, ncurses_ui_window_act_changed, NULL); query_connect_id(&remote_plugin, UI_WINDOW_REFRESH, ncurses_ui_window_refresh, NULL); query_connect_id(&remote_plugin, UI_WINDOW_UPDATE_LASTLOG, ncurses_ui_window_lastlog, NULL); query_connect_id(&remote_plugin, UI_REFRESH, ncurses_ui_refresh, NULL); From svn w toxygen.net Thu Sep 18 16:21:14 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 18 Sep 2008 16:21:14 +0200 (CEST) Subject: [ekg2-commit] r4657 - trunk/plugins/remote: trunk/plugins/remote/remote.c Message-ID: <20080918142114.4F37E17B1F@toxygen.net> Author: darkjames Date: 2008-09-18 16:21:13 +0200 (Thu, 18 Sep 2008) New Revision: 4657 Modified: trunk/plugins/remote/remote.c Log: - sensowna obsluga backlogow. Modified: trunk/plugins/remote/remote.c =================================================================== --- trunk/plugins/remote/remote.c 2008-09-18 12:50:23 UTC (rev 4656) +++ trunk/plugins/remote/remote.c 2008-09-18 14:21:13 UTC (rev 4657) @@ -350,18 +350,68 @@ } else if (!xstrcmp(cmd, "REQBACKLOGS")) { window_t *w; + int req_ok = 0; - for (w = windows; w; w = w->next) { - remote_window_t *n = w->private; - int i; + /* XXX, uniknac duplikowania kodu... */ - if (!n) - continue; + if (arrcnt == 3) { + if (!xstrcmp(arr[1], "LAST")) { + int only = atoi(arr[2]); /* note: to jest limit dla kazdego okienka */ - for (i = n->backlog_size; i; i--) { - remote_writefd(fd, "BACKLOG", itoa(w->id), itoa(n->backlog[i-1]->ts), n->backlog[i-1]->str, NULL); + req_ok = 1; + + for (w = windows; w; w = w->next) { + remote_window_t *n = w->private; + int from; + int i; + + if (!n) + continue; + + if (n->backlog_size > only) + from = only; + else + from = n->backlog_size; + + /* XXX, zakladamy ze backlog jest posortowany w/g czasu */ + + for (i = from; i; i--) { + remote_writefd(fd, "BACKLOG", itoa(w->id), itoa(n->backlog[i-1]->ts), n->backlog[i-1]->str, NULL); + } + } + } else if (!xstrcmp(arr[1], "FROMTIME")) { + time_t ts = atoi(arr[2]); + + req_ok = 1; + + for (w = windows; w; w = w->next) { + remote_window_t *n = w->private; + int i; + + if (!n) + continue; + + for (i = n->backlog_size; i; i--) { + if (n->backlog[i-1]->ts >= ts) + remote_writefd(fd, "BACKLOG", itoa(w->id), itoa(n->backlog[i-1]->ts), n->backlog[i-1]->str, NULL); + } + } } } + if (req_ok == 0) { /* jesli requet nie byl przetwarzany, to wysylamy caly backlog */ + for (w = windows; w; w = w->next) { + remote_window_t *n = w->private; + int i; + + if (!n) + continue; + + for (i = n->backlog_size; i; i--) { + remote_writefd(fd, "BACKLOG", itoa(w->id), itoa(n->backlog[i-1]->ts), n->backlog[i-1]->str, NULL); + } + } + } + remote_writefd(fd, "+BACKLOG", NULL); } else if (!xstrcmp(cmd, "REQSESSIONS")) { From svn w toxygen.net Thu Sep 18 20:30:04 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 18 Sep 2008 20:30:04 +0200 (CEST) Subject: [ekg2-commit] r4658 - trunk/plugins/icq: trunk/plugins/icq/icq.c Message-ID: <20080918183004.A035A17B1F@toxygen.net> Author: wiechu Date: 2008-09-18 20:30:04 +0200 (Thu, 18 Sep 2008) New Revision: 4658 Modified: trunk/plugins/icq/icq.c Log: clear stream buffer before connect and after disconnect Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-18 14:21:13 UTC (rev 4657) +++ trunk/plugins/icq/icq.c 2008-09-18 18:30:04 UTC (rev 4658) @@ -530,6 +530,7 @@ ekg_close(j->fd2); j->fd2 = -1; } + string_free(j->stream_buf, 0); } static WATCHER_SESSION(icq_handle_stream); @@ -554,6 +555,8 @@ debug("[icq] handle_connect(%d)\n", s->connecting); + string_free(j->stream_buf, 0); + if (type || getsockopt(fd, SOL_SOCKET, SO_ERROR, &res, &res_size) || res) { if (type) debug_error("[icq] handle_connect(): SO_ERROR %s\n", strerror(res)); From svn w toxygen.net Thu Sep 18 21:35:33 2008 From: svn w toxygen.net (SVN commit) Date: Thu, 18 Sep 2008 21:35:33 +0200 (CEST) Subject: [ekg2-commit] r4659 - trunk/plugins/icq: trunk/plugins/icq/icq.c Message-ID: <20080918193533.6ACDE17B1F@toxygen.net> Author: wiechu Date: 2008-09-18 21:35:33 +0200 (Thu, 18 Sep 2008) New Revision: 4659 Modified: trunk/plugins/icq/icq.c Log: s/string_free/string_clear/; sorry about my mistake; correction: darkjames Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-18 18:30:04 UTC (rev 4658) +++ trunk/plugins/icq/icq.c 2008-09-18 19:35:33 UTC (rev 4659) @@ -530,7 +530,7 @@ ekg_close(j->fd2); j->fd2 = -1; } - string_free(j->stream_buf, 0); + string_clear(j->stream_buf); } static WATCHER_SESSION(icq_handle_stream); @@ -555,7 +555,7 @@ debug("[icq] handle_connect(%d)\n", s->connecting); - string_free(j->stream_buf, 0); + string_clear(j->stream_buf, 0); if (type || getsockopt(fd, SOL_SOCKET, SO_ERROR, &res, &res_size) || res) { if (type) From svn w toxygen.net Fri Sep 19 00:40:51 2008 From: svn w toxygen.net (SVN commit) Date: Fri, 19 Sep 2008 00:40:51 +0200 (CEST) Subject: [ekg2-commit] r4660 - trunk/plugins/remote: trunk/plugins/remote/remote.c Message-ID: <20080918224051.0A74917B1F@toxygen.net> Author: darkjames Date: 2008-09-19 00:40:50 +0200 (Fri, 19 Sep 2008) New Revision: 4660 Modified: trunk/plugins/remote/remote.c Log: - window-switched-remotely Modified: trunk/plugins/remote/remote.c =================================================================== --- trunk/plugins/remote/remote.c 2008-09-18 19:35:33 UTC (rev 4659) +++ trunk/plugins/remote/remote.c 2008-09-18 22:40:50 UTC (rev 4660) @@ -484,6 +484,15 @@ else remote_writefd(fd, "-SESSION_CYCLE", NULL); } + + } else if (!xstrcmp(cmd, "REQWINDOW_SWITCH")) { + if (arrcnt == 2) { + int id = atoi(arr[1]); + + window_switch(id); + remote_writefd(fd, "+WINDOW_SWITCH", NULL); + + } } else if (!xstrcmp(cmd, "REQEXECUTE")) { if (arrcnt == 2) { int ret; From svn w toxygen.net Fri Sep 19 01:16:56 2008 From: svn w toxygen.net (SVN commit) Date: Fri, 19 Sep 2008 01:16:56 +0200 (CEST) Subject: [ekg2-commit] r4661 - trunk/plugins/icq: trunk/plugins/icq/icq.c Message-ID: <20080918231656.661AD17B1F@toxygen.net> Author: wiechu Date: 2008-09-19 01:16:55 +0200 (Fri, 19 Sep 2008) New Revision: 4661 Modified: trunk/plugins/icq/icq.c Log: fix, shame on me Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-18 22:40:50 UTC (rev 4660) +++ trunk/plugins/icq/icq.c 2008-09-18 23:16:55 UTC (rev 4661) @@ -555,7 +555,7 @@ debug("[icq] handle_connect(%d)\n", s->connecting); - string_clear(j->stream_buf, 0); + string_clear(j->stream_buf); if (type || getsockopt(fd, SOL_SOCKET, SO_ERROR, &res, &res_size) || res) { if (type) From svn w toxygen.net Fri Sep 19 11:41:04 2008 From: svn w toxygen.net (SVN commit) Date: Fri, 19 Sep 2008 11:41:04 +0200 (CEST) Subject: [ekg2-commit] r4662 - trunk/plugins/icq: trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_const.h trunk/plugins/icq/icq_fieldnames.inc trunk/plugins/icq/icq_snac_handlers_15extension.inc Message-ID: <20080919094104.3F15F17B1F@toxygen.net> Author: wiechu Date: 2008-09-19 11:41:03 +0200 (Fri, 19 Sep 2008) New Revision: 4662 Modified: trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_const.h trunk/plugins/icq/icq_fieldnames.inc trunk/plugins/icq/icq_snac_handlers_15extension.inc Log: meta information response (clean & fix) Modified: trunk/plugins/icq/icq_caps.c =================================================================== --- trunk/plugins/icq/icq_caps.c 2008-09-18 23:16:55 UTC (rev 4661) +++ trunk/plugins/icq/icq_caps.c 2008-09-19 09:41:03 UTC (rev 4662) @@ -167,7 +167,7 @@ }; const char* _nameXStatus[XSTATUS_COUNT] = { - "Shopping", + ("Shopping"), "Taking a bath", "Tired", "Party", Modified: trunk/plugins/icq/icq_const.h =================================================================== --- trunk/plugins/icq/icq_const.h 2008-09-18 23:16:55 UTC (rev 4661) +++ trunk/plugins/icq/icq_const.h 2008-09-19 09:41:03 UTC (rev 4662) @@ -27,4 +27,48 @@ #define MTYPE_AUTOFFC 0xEC /* Auto free for chat message */ +/* + * Server response types to client meta request. + */ +#define SRV_OFFLINE_MESSAGE 0x0041 +#define SRV_END_OF_OFFLINE_MSGS 0x0042 +#define SRV_META_INFO_REPLY 0x07da + +/* + * Server response subtypes to client meta info request + * SNAC(15,03)/07da + */ +#define META_SET_HOMEINFO_ACK 0x0064 +#define META_SET_WORKINFO_ACK 0x006e +#define META_SET_MOREINFO_ACK 0x0078 +#define META_SET_NOTES_ACK 0x0082 +#define META_SET_EMAILINFO_ACK 0x0087 +#define META_SET_INTINFO_ACK 0x008c +#define META_SET_AFFINFO_ACK 0x0096 +#define META_SMS_DELIVERY_RECEIPT 0x0096 +#define META_SET_PERMS_ACK 0x00a0 +#define META_SET_PASSWORD_ACK 0x00aa +#define META_UNREGISTER_ACK 0x00b4 +#define META_SET_HPAGECAT_ACK 0x00be + +#define META_BASIC_USERINFO 0x00c8 +#define META_WORK_USERINFO 0x00d2 +#define META_MORE_USERINFO 0x00dc +#define META_NOTES_USERINFO 0x00e6 +#define META_EMAIL_USERINFO 0x00eb +#define META_INTERESTS_USERINFO 0x00f0 +#define META_AFFILATIONS_USERINFO 0x00fa +#define META_SHORT_USERINFO 0x0104 +#define META_HPAGECAT_USERINFO 0x010e + +#define SRV_USER_FOUND 0x01a4 +#define SRV_LAST_USER_FOUND 0x01ae + +#define META_REGISTRATION_STATS_ACK 0x0302 +#define SRV_RANDOM_FOUND 0x0366 +#define META_XML_INFO 0x08a2 +#define META_SET_FULLINFO_ACK 0x0c3f +#define META_SPAM_REPORT_ACK 0x2012 + + #endif Modified: trunk/plugins/icq/icq_fieldnames.inc =================================================================== --- trunk/plugins/icq/icq_fieldnames.inc 2008-09-18 23:16:55 UTC (rev 4661) +++ trunk/plugins/icq/icq_fieldnames.inc 2008-09-19 09:41:03 UTC (rev 4662) @@ -437,4 +437,10 @@ {40, LPGEN("Widowed")}, {-1, NULL}}; +struct fieldnames_t webawareField[]={ + {1, LPGEN("Offline")}, + {2, LPGEN("Online")}, + {3, LPGEN("Non webaware")}, + {-1, NULL}}; + // vim:syn=c Modified: trunk/plugins/icq/icq_snac_handlers_15extension.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-18 23:16:55 UTC (rev 4661) +++ trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-19 09:41:03 UTC (rev 4662) @@ -42,20 +42,6 @@ #include "icq_fieldnames.inc" -#define META_BASIC_USERINFO 0x00c8 -#define META_WORK_USERINFO 0x00d2 -#define META_MORE_USERINFO 0x00dc -#define META_NOTES_USERINFO 0x00e6 -#define META_EMAIL_USERINFO 0x00eb -#define META_INTERESTS_USERINFO 0x00f0 -#define META_AFFILATIONS_USERINFO 0x00fa -#define META_SHORT_USERINFO 0x0104 -#define META_HPAGECAT_USERINFO 0x010e - -#define SRV_USER_FOUND 0x01a4 -#define SRV_LAST_USER_FOUND 0x01ae -#define SRV_RANDOM_FOUND 0x0366 - typedef struct { int type; int item; // 'S' - str; 'w' - word; 'c' - byte; 'L' bool @@ -66,55 +52,56 @@ const static _userinfo_t userinfo[] = { /* User basic info reply */ - {META_BASIC_USERINFO, 'S', "Nickname", "nick", NULL}, - {META_BASIC_USERINFO, 'S', "Firstname", "first_name", NULL}, - {META_BASIC_USERINFO, 'S', "Lastname", "last_name", NULL}, - {META_BASIC_USERINFO, 'S', "Email", "email", NULL}, - {META_BASIC_USERINFO, 'S', "City", "city", NULL}, - {META_BASIC_USERINFO, 'S', "State", "state", NULL}, - {META_BASIC_USERINFO, 'S', "Phone", "phone", NULL}, - {META_BASIC_USERINFO, 'S', "Fax", "fax", NULL}, - {META_BASIC_USERINFO, 'S', "Street", "street", NULL}, - {META_BASIC_USERINFO, 'S', "Cellular", "mobile", NULL}, - {META_BASIC_USERINFO, 'S', "Zip", "zip", NULL}, - {META_BASIC_USERINFO, 'w', "Country", "country", countryField}, - {META_BASIC_USERINFO, 'c', "Timezone", "tzone", NULL}, - {META_BASIC_USERINFO, 'c', "Authorization", "auth", NULL}, // lookup XXX ?wo? - {META_BASIC_USERINFO, 'c', "Webaware", "webaware", NULL}, // lookup XXX ?wo? - {META_BASIC_USERINFO, 'L', "Direct connection", "dc_perm", NULL}, - {META_BASIC_USERINFO, 'L', "Publish primary email", "pub_email", NULL}, + {META_BASIC_USERINFO, 'S', N_("Nickname"), "nick", NULL}, + {META_BASIC_USERINFO, 'S', N_("Firstname"), "first_name", NULL}, + {META_BASIC_USERINFO, 'S', N_("Lastname"), "last_name", NULL}, + {META_BASIC_USERINFO, 'S', N_("Email"), "email", NULL}, + {META_BASIC_USERINFO, 'S', N_("City"), "city", NULL}, + {META_BASIC_USERINFO, 'S', N_("State"), "state", NULL}, + {META_BASIC_USERINFO, 'S', N_("Phone"), "phone", NULL}, + {META_BASIC_USERINFO, 'S', N_("Fax"), "fax", NULL}, + {META_BASIC_USERINFO, 'S', N_("Street"), "street", NULL}, + {META_BASIC_USERINFO, 'S', N_("Cellular"), "mobile", NULL}, + {META_BASIC_USERINFO, 'S', N_("Zip"), "zip", NULL}, + {META_BASIC_USERINFO, 'w', N_("Country"), "country", countryField}, + {META_BASIC_USERINFO, 'c', N_("Timezone"), "tzone", NULL}, + {META_BASIC_USERINFO, 'L', N_("Authorization"), "auth", NULL}, + {META_BASIC_USERINFO, 'c', N_("Webaware"), "webaware", webawareField}, + {META_BASIC_USERINFO, 'L', N_("Publish primary email"),"pub_email", NULL}, + {META_BASIC_USERINFO, 'L', N_("Direct connection"), "dc_perm", NULL}, {META_BASIC_USERINFO, 'S', NULL, NULL, NULL}, // Is here 'zip code' again? /* User work info reply */ - {META_WORK_USERINFO, 'S', "CompanyCity", "c_city", NULL}, - {META_WORK_USERINFO, 'S', "CompanyState", "c_state", NULL}, - {META_WORK_USERINFO, 'S', "CompanyPhone", "c_phone", NULL}, - {META_WORK_USERINFO, 'S', "CompanyFax", "c_fax", NULL}, - {META_WORK_USERINFO, 'S', "CompanyStreet", "c_street", NULL}, - {META_WORK_USERINFO, 'S', "CompanyZIP", "c_zip", NULL}, - {META_WORK_USERINFO, 'w', "CompanyCountry", "c_country", countryField}, - {META_WORK_USERINFO, 'S', "Company", "c_name", NULL}, - {META_WORK_USERINFO, 'S', "CompanyDepartment", "c_depart", NULL}, - {META_WORK_USERINFO, 'S', "CompanyPosition", "c_pos", NULL}, - {META_WORK_USERINFO, 'w', "CompanyOccupation", "c_occup", workField}, - {META_WORK_USERINFO, 'S', "CompanyHomepage", "c_www", NULL}, + {META_WORK_USERINFO, 'S', N_("CompanyCity"), "c_city", NULL}, + {META_WORK_USERINFO, 'S', N_("CompanyState"), "c_state", NULL}, + {META_WORK_USERINFO, 'S', N_("CompanyPhone"), "c_phone", NULL}, + {META_WORK_USERINFO, 'S', N_("CompanyFax"), "c_fax", NULL}, + {META_WORK_USERINFO, 'S', N_("CompanyStreet"), "c_street", NULL}, + {META_WORK_USERINFO, 'S', N_("CompanyZIP"), "c_zip", NULL}, + {META_WORK_USERINFO, 'w', N_("CompanyCountry"), "c_country", countryField}, + {META_WORK_USERINFO, 'S', N_("Company"), "c_name", NULL}, + {META_WORK_USERINFO, 'S', N_("CompanyDepartment"), "c_depart", NULL}, + {META_WORK_USERINFO, 'S', N_("CompanyPosition"), "c_pos", NULL}, + {META_WORK_USERINFO, 'w', N_("CompanyOccupation"), "c_occup", workField}, + {META_WORK_USERINFO, 'S', N_("CompanyHomepage"), "c_www", NULL}, {META_WORK_USERINFO, 'S', NULL, NULL, NULL}, // Is here 'zip code' again? /* User more info reply */ - {META_MORE_USERINFO, 'w', "Age", "age", NULL}, - {META_MORE_USERINFO, 'c', "Gender", "gender", genderField}, - {META_MORE_USERINFO, 'S', "Homepage", "www", NULL}, - {META_MORE_USERINFO, 'w', "Birth date", "birth", NULL}, + {META_MORE_USERINFO, 'w', N_("Age"), "age", NULL}, + {META_MORE_USERINFO, 'c', N_("Gender"), "gender", genderField}, + {META_MORE_USERINFO, 'S', N_("Homepage"), "www", NULL}, + {META_MORE_USERINFO, 'w', N_("Birth date"), "birth", NULL}, {META_MORE_USERINFO, 'c', NULL, ".month", NULL}, {META_MORE_USERINFO, 'c', NULL, ".day", NULL}, - {META_MORE_USERINFO, 'c', "Language1", "lang1", languageField}, - {META_MORE_USERINFO, 'c', "Language2", "lang2", languageField}, - {META_MORE_USERINFO, 'c', "Language3", "lang3", languageField}, + {META_MORE_USERINFO, 'c', N_("Language1"), "lang1", languageField}, + {META_MORE_USERINFO, 'c', N_("Language2"), "lang2", languageField}, + {META_MORE_USERINFO, 'c', N_("Language3"), "lang3", languageField}, {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes - {META_MORE_USERINFO, 'S', "Original from City" "o_city", NULL}, - {META_MORE_USERINFO, 'S', "Original from State" "o_state", NULL}, - {META_MORE_USERINFO, 'w', "Original from Country", "o_country", countryField}, - {META_MORE_USERINFO, 'c', NULL, NULL, NULL}, // Timezone - {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes - {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes + {META_MORE_USERINFO, 'S', N_("Original from City"), "o_city", NULL}, + {META_MORE_USERINFO, 'S', N_("Original from State"), "o_state", NULL}, + {META_MORE_USERINFO, 'w', N_("Original from Country"),"o_country", countryField}, + {META_MORE_USERINFO, 'c', N_("Marital status"), "marital", maritalField}, + {META_MORE_USERINFO, 'L', N_("AllowSpam"), "AllowSpam", NULL}, + {META_MORE_USERINFO, 'w', N_("InfoCP"), "InfoCP", NULL}, + {META_MORE_USERINFO, 'c', NULL, NULL, NULL}, // skip 1 unknown byte {META_MORE_USERINFO, 'S', NULL, NULL, NULL}, // skip unknown string {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes {META_MORE_USERINFO, 'w', NULL, NULL, NULL}, // skip 2 unknown bytes @@ -126,42 +113,42 @@ {META_MORE_USERINFO, 'c', NULL, NULL, NULL}, // skip 1 unknown byte {META_MORE_USERINFO, 'S', NULL, NULL, NULL}, // skip unknown string /* User notes (about) info reply */ - {META_NOTES_USERINFO, 'S', "About", "about", NULL}, + {META_NOTES_USERINFO, 'S', N_("About"), "about", NULL}, /* User extended email info reply */ - {META_EMAIL_USERINFO, 'S', "Email", "email1", NULL}, - {META_EMAIL_USERINFO, 'S', "Email", "email2", NULL}, - {META_EMAIL_USERINFO, 'S', "Email", "email3", NULL}, - {META_EMAIL_USERINFO, 'S', "Email", "email4", NULL}, // more emails? ?wo? + {META_EMAIL_USERINFO, 'S', N_("Email"), "email1", NULL}, + {META_EMAIL_USERINFO, 'S', N_("Email"), "email2", NULL}, + {META_EMAIL_USERINFO, 'S', N_("Email"), "email3", NULL}, + {META_EMAIL_USERINFO, 'S', N_("Email"), "email4", NULL}, // more emails? ?wo? /* User interests info reply */ - {META_INTERESTS_USERINFO, 'w', "Interests", "interests1", interestsField}, - {META_INTERESTS_USERINFO, 'S', "InterestsStr", "interestsStr1", NULL}, - {META_INTERESTS_USERINFO, 'w', "Interests", "interests2", interestsField}, - {META_INTERESTS_USERINFO, 'S', "InterestsStr", "interestsStr2", NULL}, - {META_INTERESTS_USERINFO, 'w', "Interests", "interests3", interestsField}, - {META_INTERESTS_USERINFO, 'S', "InterestsStr", "interestsStr3", NULL}, - {META_INTERESTS_USERINFO, 'w', "Interests", "interests4", interestsField}, - {META_INTERESTS_USERINFO, 'S', "InterestsStr", "interestsStr4", NULL}, + {META_INTERESTS_USERINFO, 'w', N_("Interests"), "interests1", interestsField}, + {META_INTERESTS_USERINFO, 'S', N_("InterestsStr"), "interestsStr1", NULL}, + {META_INTERESTS_USERINFO, 'w', N_("Interests"), "interests2", interestsField}, + {META_INTERESTS_USERINFO, 'S', N_("InterestsStr"), "interestsStr2", NULL}, + {META_INTERESTS_USERINFO, 'w', N_("Interests"), "interests3", interestsField}, + {META_INTERESTS_USERINFO, 'S', N_("InterestsStr"), "interestsStr3", NULL}, + {META_INTERESTS_USERINFO, 'w', N_("Interests"), "interests4", interestsField}, + {META_INTERESTS_USERINFO, 'S', N_("InterestsStr"), "interestsStr4", NULL}, /* User past/affilations info reply */ - {META_AFFILATIONS_USERINFO, 'w', "PastAff", "pastaff1", pastField}, - {META_AFFILATIONS_USERINFO, 'S', "PastAffStr", "pastaffStr1", NULL}, - {META_AFFILATIONS_USERINFO, 'w', "PastAff", "pastaff2", pastField}, - {META_AFFILATIONS_USERINFO, 'S', "PastAffStr", "pastaffStr2", NULL}, - {META_AFFILATIONS_USERINFO, 'w', "PastAff", "pastaff3", pastField}, - {META_AFFILATIONS_USERINFO, 'S', "PastAffStr", "pastaffStr3", NULL}, - {META_AFFILATIONS_USERINFO, 'w', "Aff", "aff1", pastField}, - {META_AFFILATIONS_USERINFO, 'S', "AffStr", "affStr1", NULL}, - {META_AFFILATIONS_USERINFO, 'w', "Aff", "aff2", pastField}, - {META_AFFILATIONS_USERINFO, 'S', "AffStr", "affStr2", NULL}, - {META_AFFILATIONS_USERINFO, 'w', "Aff", "aff3", pastField}, - {META_AFFILATIONS_USERINFO, 'S', "AffStr", "affStr3", NULL}, + {META_AFFILATIONS_USERINFO, 'w', N_("PastAff"), "pastaff1", pastField}, + {META_AFFILATIONS_USERINFO, 'S', N_("PastAffStr"), "pastaffStr1", NULL}, + {META_AFFILATIONS_USERINFO, 'w', N_("PastAff"), "pastaff2", pastField}, + {META_AFFILATIONS_USERINFO, 'S', N_("PastAffStr"), "pastaffStr2", NULL}, + {META_AFFILATIONS_USERINFO, 'w', N_("PastAff"), "pastaff3", pastField}, + {META_AFFILATIONS_USERINFO, 'S', N_("PastAffStr"), "pastaffStr3", NULL}, + {META_AFFILATIONS_USERINFO, 'w', N_("Aff"), "aff1", pastField}, + {META_AFFILATIONS_USERINFO, 'S', N_("AffStr"), "affStr1", NULL}, + {META_AFFILATIONS_USERINFO, 'w', N_("Aff"), "aff2", pastField}, + {META_AFFILATIONS_USERINFO, 'S', N_("AffStr"), "affStr2", NULL}, + {META_AFFILATIONS_USERINFO, 'w', N_("Aff"), "aff3", pastField}, + {META_AFFILATIONS_USERINFO, 'S', N_("AffStr"), "affStr3", NULL}, /* Short user information reply */ - {META_SHORT_USERINFO, 'S', "Nickname", "nick", NULL}, // ?WO? "nick" or "s_nick" ??? - {META_SHORT_USERINFO, 'S', "Firstname", "first_name", NULL}, // as above - {META_SHORT_USERINFO, 'S', "Lastname", "last_name", NULL}, // as above - {META_SHORT_USERINFO, 'S', "Email", "email", NULL}, // as above + {META_SHORT_USERINFO, 'S', N_("Nickname"), "nick", NULL}, + {META_SHORT_USERINFO, 'S', N_("Firstname"), "first_name", NULL}, + {META_SHORT_USERINFO, 'S', N_("Lastname"), "last_name", NULL}, + {META_SHORT_USERINFO, 'S', N_("Email"), "email", NULL}, /* User homepage category information reply */ - {META_HPAGECAT_USERINFO, 'w', "Homepage category", "wwwcat", NULL}, // ?WO? lookup??? - {META_HPAGECAT_USERINFO, 'S', "Homepage keywords", "wwwkeys", NULL}, + {META_HPAGECAT_USERINFO, 'w', N_("Homepage category"), "wwwcat", NULL}, // ?WO? lookup??? + {META_HPAGECAT_USERINFO, 'S', N_("Homepage keywords"), "wwwkeys", NULL}, {0, 0, NULL, NULL, NULL} }; @@ -251,7 +238,7 @@ else str = private_item_get(&data, userinfo[i].name); if ( str && *str) { - char *___str = xstrdup(str); /* XXX, recode */ + char *___str = xstrdup(str); /* XXX, guess recode */ if (!__displayed) print("icq_userinfo_start", session_name(s), itoa(uid), theme); @@ -317,18 +304,20 @@ count = 3; for (i = 0; i < count; i++) { - char *tmp; + char *name1, *name2; const char *str; uint16_t w; - if (ICQ_UNPACK(&buf, "wS", &w, &str)) { - tmp = saprintf("%s%d", names[k], i+1); - private_item_set_int(info, tmp, w); - xfree(tmp); - tmp = saprintf("%sStr%d", names[k], i+1); - private_item_set(info, tmp, str); - xfree(tmp); + name1 = saprintf("%s%d", names[k], i+1); + name2 = saprintf("%sStr%d", names[k], i+1); + if (!ICQ_UNPACK(&buf, "wS", &w, &str)) { + w = 0; + str = ""; } + private_item_set_int(info, name1, w); + private_item_set(info, name2, str); + xfree(name1); + xfree(name2); } } @@ -347,6 +336,9 @@ tmp = saprintf("GMT%+d", tz/2); private_item_set(info, "tzone", tmp); xfree(tmp); + + private_item_set_int(info, "auth", !private_item_get_int(info, "auth")); + private_item_set_int(info, "webaware", private_item_get_int(info, "webaware") + 1); } return 0; @@ -363,7 +355,6 @@ } METASNAC_SUBHANDLER(icq_snac_extensions_shortinfo) { - /* XXX miranda-Broken */ __get_userinfo_data(buf, len, META_SHORT_USERINFO, info); return 0; } @@ -468,7 +459,8 @@ uint32_t uin; uint16_t len2; - uint8_t auth, status, gender, age; + uint16_t status, age; + uint8_t auth, gender; /* XXX, sprawdzic czy mamy cookie. */ @@ -498,7 +490,7 @@ else full_name = xstrdup(first_name[0] ? first_name : last_name); - if (ICQ_UNPACK(&buf, "cc x cc", &auth, &status, &gender, &age)) { + if (ICQ_UNPACK(&buf, "cwcw", &auth, &status, &gender, &age)) { if (age) __age = itoa(age); // XXX calculate birthyear? if (gender) @@ -507,6 +499,7 @@ debug_error("icq_snac_extension_userfound_common() broken\n"); auth = status = gender = age = 0; } + /* XXX, "search_results_multi", "search_results_single" */ /* XXX, instead of email we had city */ /* XXX, some time ago i was thinking to of function which @@ -556,33 +549,15 @@ xfree(__active); xfree(full_name); - icq_hexdump(DEBUG_WHITE, buf, len); -#if 0 - // Authentication needed flag - if (wPacketLen < 1) - break; - unpackByte(&databuf, &sr.auth); - - sr.uid = NULL; // icq contact - // Finally, broadcast the result - BroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)wCookie, (LPARAM)&sr); - - // Broadcast "Last result" ack if this was the last user found - if (wReplySubtype == SRV_LAST_USER_FOUND) - { - if (wPacketLen>=10) - { - DWORD dwLeft; - - databuf += 5; - unpackLEDWord(&databuf, &dwLeft); - if (dwLeft) - NetLog_Server("Warning: %d search results omitted", dwLeft); - } - ReleaseSearchCookie(wCookie, pCookie); + if (islast && len>=4) { + uint32_t omit; + ICQ_UNPACK(&buf, "I", omit); + debug_warn("icq_snac_extension_userfound_last() Bulshit warning!\n"); + debug_white("icq_snac_extension_userfound_last() %d search results omitted\n", omit); } -#endif + icq_hexdump(DEBUG_WHITE, buf, len); + xfree(nickname); xfree(first_name); xfree(last_name); xfree(email); return 0; @@ -610,7 +585,7 @@ return NULL; } -static int icq_snac_extension_replyreq_0x7da(session_t *s, unsigned char *buf, int len, private_data_t **info, int show) { +static int icq_meta_info_reply(session_t *s, unsigned char *buf, int len, private_data_t **info, int show) { struct { uint16_t subtype; uint8_t result; @@ -621,28 +596,28 @@ metasnac_subhandler_t handler; if (!ICQ_UNPACK(&pkt.data, "wc", &pkt.subtype, &pkt.result)) { - debug_error("icq_snac_extension_replyreq_0x7da() broken\n"); + debug_error("icq_meta_info_reply() broken\n"); return -1; } - debug_white("icq_snac_extension_replyreq_0x7da() subtype=%.4x result=%.2x (len=%d)\n", pkt.subtype, pkt.result, len); + debug_white("icq_meta_info_reply() subtype=%.4x result=%.2x (len=%d)\n", pkt.subtype, pkt.result, len); if ( (handler = get_userinfo_extension_handler(pkt.subtype)) ) { userinfo = 1; } else { switch (pkt.subtype) { /* search */ - case SRV_LAST_USER_FOUND: handler = icq_snac_extension_userfound_last; break;/* Miranda: OK, SRV_LAST_USER_FOUND */ - case SRV_USER_FOUND: handler = icq_snac_extension_userfound; break; /* Miranda: OK, SRV_USER_FOUND */ + case SRV_LAST_USER_FOUND: handler = icq_snac_extension_userfound_last; break; + case SRV_USER_FOUND: handler = icq_snac_extension_userfound; break; - case SRV_RANDOM_FOUND: handler = NULL; break; /* XXX, SRV_RANDOM_FOUND */ + case SRV_RANDOM_FOUND: handler = NULL; break; /* XXX, SRV_RANDOM_FOUND */ default: handler = NULL; } } __displayed = 0; if (!handler) { - debug_error("icq_snac_extension_replyreq_0x7da() ignored: %.4x\n", pkt.subtype); + debug_error("icq_meta_info_reply() ignored: %.4x\n", pkt.subtype); icq_hexdump(DEBUG_ERROR, pkt.data, len); return 0; } else { @@ -729,9 +704,13 @@ private_item_set_int(&info, "uid", private_item_get_int(&data, "uid")); switch (type) { - case 0x7da: - icq_snac_extension_replyreq_0x7da(s, buf, len, &info, 1); /* Miranda: STARTED */ + case SRV_OFFLINE_MESSAGE: + case SRV_END_OF_OFFLINE_MSGS: + debug_error("icq_snac_extension_replyreq() METASNAC type: 0x%x not supported yet.\n", type); break; + case SRV_META_INFO_REPLY: + icq_meta_info_reply(s, buf, len, &info, 1); + break; default: debug_error("icq_snac_extension_replyreq() METASNAC with unknown code: %x received.\n", type); break; @@ -755,7 +734,7 @@ switch (type) { case 0x7da: - icq_snac_extension_replyreq_0x7da(s, buf, len, &j->whoami, 0); + icq_meta_info_reply(s, buf, len, &j->whoami, 0); break; default: debug_error("icq_my_meta_information_response() METASNAC with unknown code: %x received.\n", type); @@ -794,7 +773,7 @@ switch (cmd) { case 0x01: handler = icq_snac_extension_error; break; - case 0x03: handler = icq_snac_extension_replyreq; break; /* Miranda: OK */ + case 0x03: handler = icq_snac_extension_replyreq; break; default: handler = NULL; break; } From svn w toxygen.net Fri Sep 19 13:46:21 2008 From: svn w toxygen.net (SVN commit) Date: Fri, 19 Sep 2008 13:46:21 +0200 (CEST) Subject: [ekg2-commit] r4663 - trunk/plugins/remote: trunk/plugins/remote/remote.c Message-ID: <20080919114621.A40A717B1F@toxygen.net> Author: darkjames Date: 2008-09-19 13:46:21 +0200 (Fri, 19 Sep 2008) New Revision: 4663 Modified: trunk/plugins/remote/remote.c Log: - very small optimization of rc_input_handler_line() Modified: trunk/plugins/remote/remote.c =================================================================== --- trunk/plugins/remote/remote.c 2008-09-19 09:41:03 UTC (rev 4662) +++ trunk/plugins/remote/remote.c 2008-09-19 11:46:21 UTC (rev 4663) @@ -53,8 +53,8 @@ } remote_backlog_t; typedef struct { - remote_backlog_t **backlog; /* bufor z liniami */ /* XXX, przerobic na liste? */ - int backlog_size; /* rozmiar backloga */ + remote_backlog_t **backlog; /* bufor z liniami */ /* XXX, przerobic na liste */ + int backlog_size; /* rozmiar backloga */ } remote_window_t; PLUGIN_DEFINE(remote, PLUGIN_UI, NULL); @@ -255,6 +255,35 @@ return 1; } +static char **array_make_count(const char *string, char sep, int *arrcnt) { + const char *p; + char **result = NULL; + int items = 0; + + for (p = string; *p; p++) { + const char *q; + char *token; + int len; + + for (q = p, len = 0; (*q && *q != sep); q++, len++); + + /* XXX, odsanityzowac, gdy trzeba */ + /* XXX, albo mhmh, nie korzystac z xstrndup() ? */ + token = xstrndup(p, len); + p = q; + + result = xrealloc(result, (items + 2) * sizeof(char*)); + result[items] = token; + result[++items] = NULL; + + if (!*p) + break; + } + *arrcnt = items; + + return result; +} + /* * rc_input_handler_line() * @@ -270,11 +299,11 @@ return 0; } - if (!data) + if (!data || !watch) return -1; - arr = array_make(watch, "\001", 0, 0, 0); - arrcnt = array_count(arr); + if (!(arr = array_make_count(watch, '\001', &arrcnt))) + return 0; if (!r->login_ok) { if (!xstrcmp(arr[0], "REQLOGIN")) { From svn w toxygen.net Fri Sep 19 14:35:40 2008 From: svn w toxygen.net (SVN commit) Date: Fri, 19 Sep 2008 14:35:40 +0200 (CEST) Subject: [ekg2-commit] r4664 - trunk/contrib: +trunk/contrib/vcekg Message-ID: <20080919123540.AB0AB17B3A@toxygen.net> Author: darkjames Date: 2008-09-19 14:35:40 +0200 (Fri, 19 Sep 2008) New Revision: 4664 Added: trunk/contrib/vcekg Log: - add script for executing callgrind (valgrind profiler) Added: trunk/contrib/vcekg =================================================================== --- trunk/contrib/vcekg (rev 0) +++ trunk/contrib/vcekg 2008-09-19 12:35:40 UTC (rev 4664) @@ -0,0 +1,36 @@ +#!/bin/bash + +EKG_BIN="" + + # First try to find ekg2 in current directory +[ -x 'ekg2' ] && EKG_BIN="./ekg2" +[[ -z "${EKG_BIN}" && -x 'ekg/ekg2' ]] && EKG_BIN="ekg/ekg2" +[[ -z "${EKG_BIN}" && -x '../ekg/ekg2' ]] && EKG_BIN="../ekg/ekg2" + + # Then try script directory +SCDIR="$(dirname "$0")" +if [[ -z "${EKG_BIN}" && -n "${SCDIR}" && "${SCDIR}" != '.' ]]; then + cd "$(dirname $0)" + [[ -z "${EKG_BIN}" && -x 'ekg2' ]] && EKG_BIN="ekg2" + [[ -z "${EKG_BIN}" && -x 'ekg/ekg2' ]] && EKG_BIN="ekg/ekg2" + [[ -z "${EKG_BIN}" && -x '../ekg/ekg2' ]] && EKG_BIN="../ekg/ekg2" +fi + + # Finally, try ${PATH} +[ -z "${EKG_BIN}" ] && EKG_BIN="$(which ekg2 2>/dev/null)" + +if [ -z "${EKG_BIN}" ]; then + echo 'Unable to find any usable ekg2 binary.' + exit 127 +fi + +valgrind \ + -v \ + --tool=callgrind \ + --log-file="$HOME"/.ekg2/valgrind."$(date +%Y%m%d-%H%M)" \ + --callgrind-out-file="$HOME"/.ekg2/callgrind.out."$(date +%Y%m%d-%H%M)" \ + --demangle=no \ + --num-callers=20 \ + "${EKG_BIN}" "$@" + +exit $? Property changes on: trunk/contrib/vcekg ___________________________________________________________________ Name: svn:executable + * From svn w toxygen.net Fri Sep 19 14:38:41 2008 From: svn w toxygen.net (SVN commit) Date: Fri, 19 Sep 2008 14:38:41 +0200 (CEST) Subject: [ekg2-commit] r4665 - trunk/ekg: trunk/ekg/plugins.c trunk/ekg/vars.c trunk/ekg/vars.h Message-ID: <20080919123841.1B61817B3A@toxygen.net> Author: darkjames Date: 2008-09-19 14:38:40 +0200 (Fri, 19 Sep 2008) New Revision: 4665 Modified: trunk/ekg/plugins.c trunk/ekg/vars.c trunk/ekg/vars.h Log: - we have variables_removei() use it. Modified: trunk/ekg/plugins.c =================================================================== --- trunk/ekg/plugins.c 2008-09-19 12:35:40 UTC (rev 4664) +++ trunk/ekg/plugins.c 2008-09-19 12:38:40 UTC (rev 4665) @@ -548,12 +548,9 @@ } } - for (v = variables; v; ) { - variable_t *next = v->next; - + for (v = variables; v; v = v->next) { if (v->plugin == p) - variable_remove(v->plugin, v->name); - v = next; + v = variables_removei(v); } for (c = commands; c; c = c->next) { Modified: trunk/ekg/vars.c =================================================================== --- trunk/ekg/vars.c 2008-09-19 12:35:40 UTC (rev 4664) +++ trunk/ekg/vars.c 2008-09-19 12:38:40 UTC (rev 4665) @@ -293,8 +293,6 @@ return v; } -static variable_t *variables_removei(variable_t *v); - /* * variable_remove() * @@ -506,7 +504,7 @@ } } -static __DYNSTUFF_LIST_REMOVE_ITER(variables, variable_t, variable_list_freeone); /* variables_removei() */ +__DYNSTUFF_LIST_REMOVE_ITER(variables, variable_t, variable_list_freeone); /* variables_removei() */ __DYNSTUFF_LIST_DESTROY(variables, variable_t, variable_list_freeone); /* variables_destroy() */ /* Modified: trunk/ekg/vars.h =================================================================== --- trunk/ekg/vars.h 2008-09-19 12:35:40 UTC (rev 4664) +++ trunk/ekg/vars.h 2008-09-19 12:38:40 UTC (rev 4665) @@ -83,10 +83,11 @@ variable_map_t *map, variable_display_func_t *dyndisplay); +int variable_set(const char *name, const char *value); +void variable_help(const char *name); int variable_remove(plugin_t *plugin, const char *name); -int variable_set(const char *name, const char *value); -void variable_help(const char *name); +variable_t *variables_removei(variable_t *v); void variables_destroy(); #endif From svn w toxygen.net Fri Sep 19 22:07:16 2008 From: svn w toxygen.net (SVN commit) Date: Fri, 19 Sep 2008 22:07:16 +0200 (CEST) Subject: [ekg2-commit] r4666 - trunk/plugins/icq: trunk/plugins/icq/icq.c trunk/plugins/icq/icq_snac_handlers_13userlist.inc trunk/plugins/icq/icq_snac_handlers_15extension.inc Message-ID: <20080919200716.DE1AE17B3A@toxygen.net> Author: wiechu Date: 2008-09-19 22:07:16 +0200 (Fri, 19 Sep 2008) New Revision: 4666 Modified: trunk/plugins/icq/icq.c trunk/plugins/icq/icq_snac_handlers_13userlist.inc trunk/plugins/icq/icq_snac_handlers_15extension.inc Log: - add users first & last name - fix mispelling Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-19 12:38:40 UTC (rev 4665) +++ trunk/plugins/icq/icq.c 2008-09-19 20:07:16 UTC (rev 4666) @@ -714,7 +714,7 @@ userlist_t *u; icq_private_t *j; private_data_t *refdata = NULL; - uint32_t uin; + uint32_t u_id; uint16_t group; char *nickname = NULL; @@ -734,7 +734,7 @@ return -1; } - if (!(uin = icq_get_uid(session, target))) { + if (!(u_id = icq_get_uid(session, target))) { printq("invalid_uid", target); return -1; } @@ -829,7 +829,7 @@ if (comment) icq_pack_append(data, "T", icq_pack_tlv_str(0x13c, comment)); // buddy comment - private_item_set_int(&refdata, "uin", uin); + private_item_set_int(&refdata, "uid", u_id); private_item_set(&refdata, "nick", nickname); private_item_set_int(&refdata, "iid", iid); private_item_set_int(&refdata, "gid", group); Modified: trunk/plugins/icq/icq_snac_handlers_13userlist.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_13userlist.inc 2008-09-19 12:38:40 UTC (rev 4665) +++ trunk/plugins/icq/icq_snac_handlers_13userlist.inc 2008-09-19 20:07:16 UTC (rev 4666) @@ -575,7 +575,7 @@ if (!ICQ_UNPACK(&buf, "W", &error)) return -1; - uid = icq_uid(itoa(private_item_get_int(&data, "uin"))); + uid = icq_uid(private_item_get(&data, "uid")); if (!error) { if ( (u = userlist_add(s, uid, nick)) ) { Modified: trunk/plugins/icq/icq_snac_handlers_15extension.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-19 12:38:40 UTC (rev 4665) +++ trunk/plugins/icq/icq_snac_handlers_15extension.inc 2008-09-19 20:07:16 UTC (rev 4666) @@ -328,7 +328,7 @@ __get_userinfo_data(buf, len, META_BASIC_USERINFO, info); - { + { /* correct results */ char *tmp; int tz = private_item_get_int(info, "tzone"); if (tz & 0x80) @@ -341,6 +341,16 @@ private_item_set_int(info, "webaware", private_item_get_int(info, "webaware") + 1); } + { + userlist_t *u; + char *uid = icq_uid(private_item_get(info, "uid")); + if ( (u = userlist_find(s, uid)) ) { + user_private_item_set(u, "first_name", private_item_get(info, "first_name")); + user_private_item_set(u, "last_name", private_item_get(info, "last_name")); + } + xfree(uid); + } + return 0; } @@ -551,7 +561,7 @@ if (islast && len>=4) { uint32_t omit; - ICQ_UNPACK(&buf, "I", omit); + ICQ_UNPACK(&buf, "I", &omit); debug_warn("icq_snac_extension_userfound_last() Bulshit warning!\n"); debug_white("icq_snac_extension_userfound_last() %d search results omitted\n", omit); } From svn w toxygen.net Sat Sep 20 13:31:26 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 20 Sep 2008 13:31:26 +0200 (CEST) Subject: [ekg2-commit] r4667 - in trunk: plugins/irc po: trunk/plugins/irc/irc.c trunk/plugins/irc/misc.h trunk/po/pl.po Message-ID: <20080920113126.9810F17B1F@toxygen.net> Author: peres Date: 2008-09-20 13:31:25 +0200 (Sat, 20 Sep 2008) New Revision: 4667 Modified: trunk/plugins/irc/irc.c trunk/plugins/irc/misc.h trunk/po/pl.po Log: Miscellanous /irc:whois information (320). Modified: trunk/plugins/irc/irc.c =================================================================== --- trunk/plugins/irc/irc.c 2008-09-19 20:07:16 UTC (rev 4666) +++ trunk/plugins/irc/irc.c 2008-09-20 11:31:25 UTC (rev 4667) @@ -2615,6 +2615,7 @@ format_add("RPL_WHOISSERVER", _("%G||%n %|server : %3 (%4)\n"), 1); format_add("RPL_WHOISOPERATOR", _("%G||%n %|ircOp : %3\n"), 1); format_add("RPL_WHOISIDLE", _("%G||%n %|idle : %3 (signon: %4)\n"), 1); + format_add("RPL_WHOISMISC", _("%G||%n %| * %3\n"), 1); format_add("RPL_ENDOFWHOIS", _("%G`+===%g-----\n"), 1); format_add("RPL_ENDOFWHOWAS", _("%G`+===%g-----\n"), 1); Modified: trunk/plugins/irc/misc.h =================================================================== --- trunk/plugins/irc/misc.h 2008-09-19 20:07:16 UTC (rev 4666) +++ trunk/plugins/irc/misc.h 2008-09-20 11:31:25 UTC (rev 4667) @@ -177,6 +177,7 @@ { 1, 317, NULL, "RPL_WHOISIDLE", &irc_c_whois,IRC_WHOIS}, { 1, 318, NULL, "RPL_ENDOFWHOIS", &irc_c_whois,IRC_WHOIS}, { 1, 319, NULL, "RPL_WHOISCHANNELS", &irc_c_whois,IRC_WHOIS}, + { 1, 320, NULL, "RPL_WHOISMISC", &irc_c_whois,IRC_WHOIS}, { 1, 314, NULL, "RPL_WHOWASUSER", &irc_c_whois,IRC_WHOWAS}, { 1, 369, NULL, "RPL_ENDOFWHOWAS", &irc_c_whois,IRC_WHOWAS}, Modified: trunk/po/pl.po =================================================================== --- trunk/po/pl.po 2008-09-19 20:07:16 UTC (rev 4666) +++ trunk/po/pl.po 2008-09-20 11:31:25 UTC (rev 4667) @@ -4143,6 +4143,9 @@ msgid "Author: Adam 'dredzik' Kuczynski" msgstr "Autor: Adam 'dredzik' Kuczyński" +msgid "%G||%n %| * %3\n" +msgstr "%G||%n %| * %3\n" + #~ msgid "%! Error initialising charset conversion (%1->%2): %3" #~ msgstr "%! Bład przy inicjalizacji kodowania(%1->%2): %3" From svn w toxygen.net Sat Sep 20 15:30:37 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 20 Sep 2008 15:30:37 +0200 (CEST) Subject: [ekg2-commit] r4668 - trunk/plugins/icq: trunk/plugins/icq/icq.c trunk/plugins/icq/icq_flap_handlers.c Message-ID: <20080920133038.0B71517B1F@toxygen.net> Author: wiechu Date: 2008-09-20 15:30:37 +0200 (Sat, 20 Sep 2008) New Revision: 4668 Modified: trunk/plugins/icq/icq.c trunk/plugins/icq/icq_flap_handlers.c Log: - fix 'need more data' Modified: trunk/plugins/icq/icq.c =================================================================== --- trunk/plugins/icq/icq.c 2008-09-20 11:31:25 UTC (rev 4667) +++ trunk/plugins/icq/icq.c 2008-09-20 13:30:37 UTC (rev 4668) @@ -572,7 +572,7 @@ static WATCHER_SESSION(icq_handle_stream) { icq_private_t *j = NULL; char buf[8192]; - int len, ret, start_len; + int len, ret, start_len, left; if (!s || !(j = s->priv)) { debug_error("icq_handle_stream() s: 0x%x j: 0x%x\n", s, j); @@ -599,7 +599,10 @@ ret = icq_flap_handler(s, j->stream_buf); - string_remove(j->stream_buf, start_len - j->stream_buf->len); + if ( (left = j->stream_buf->len) > 0 ) { + j->stream_buf->len = start_len; + string_remove(j->stream_buf, start_len - left); + } switch (ret) { /* XXX, magic values */ case 0: @@ -607,15 +610,16 @@ break; case -1: - debug_white("icq_flap_loop() NEED MORE DATA\n"); + { + debug_white("icq_handle_stream() NEED MORE DATA\n"); break; - + } case -2: - debug_error("icq_flap_loop() DISCONNECT\n"); + debug_error("icq_handle_stream() DISCONNECT\n"); return -1; default: - debug_error("icq_flap_loop() == %d ???\n", ret); + debug_error("icq_handle_stream() icq_flap_loop() returns %d ???\n", ret); break; } Modified: trunk/plugins/icq/icq_flap_handlers.c =================================================================== --- trunk/plugins/icq/icq_flap_handlers.c 2008-09-20 11:31:25 UTC (rev 4667) +++ trunk/plugins/icq/icq_flap_handlers.c 2008-09-20 13:30:37 UTC (rev 4668) @@ -472,7 +472,7 @@ if (buf[0] != 0x2A) { debug_error("icq_flap_loop() Incoming packet is not a FLAP: id is %d.\n", buf[0]); - icq_hexdump(DEBUG_ERROR, (unsigned char *) buf, len); + icq_hexdump(DEBUG_ERROR, buf, len); return -2; } @@ -504,12 +504,12 @@ handler(s, flap.data, flap.len); - /* next flap? */ + /* next flap? */ buf += (flap.len); len -= (flap.len); buffer->len = len; next_flap = 1; } - return next_flap ? 0 : -1; /* ??? XXX */ + return len ? -1 : 0; } From svn w toxygen.net Sat Sep 20 17:14:32 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 20 Sep 2008 17:14:32 +0200 (CEST) Subject: [ekg2-commit] r4669 - trunk/plugins/icq: trunk/plugins/icq/icq_snac_handlers_03buddy.inc trunk/plugins/icq/icq_snac_handlers_04message.inc Message-ID: <20080920151432.1398517B1F@toxygen.net> Author: wiechu Date: 2008-09-20 17:14:31 +0200 (Sat, 20 Sep 2008) New Revision: 4669 Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc trunk/plugins/icq/icq_snac_handlers_04message.inc Log: fix status description & xstatus change Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-20 13:30:37 UTC (rev 4668) +++ trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-20 15:14:31 UTC (rev 4669) @@ -60,11 +60,18 @@ static void icq_get_description(session_t *s, char *uin, int status) { string_t pkt, tlv5, rdv; uint32_t cookie1=rand(), cookie2=rand(); + uint32_t mtype; debug_function("icq_get_description() for: %s\n", uin); - if (status != EKG_STATUS_AWAY && status != EKG_STATUS_GONE && status != EKG_STATUS_XA && status != EKG_STATUS_DND && status != EKG_STATUS_FFC) - return; + switch (status) { + case EKG_STATUS_AWAY: mtype = MTYPE_AUTOAWAY; break; + case EKG_STATUS_GONE: mtype = MTYPE_AUTONA; break; + case EKG_STATUS_XA: mtype = MTYPE_AUTOBUSY; break; + case EKG_STATUS_DND: mtype = MTYPE_AUTODND; break; + case EKG_STATUS_FFC: mtype = MTYPE_AUTOFFC; break; + default: return; + } pkt = string_init(NULL); icq_pack_append(pkt, "II", cookie1, cookie2); // cookie @@ -74,31 +81,30 @@ tlv5 = string_init(NULL); icq_pack_append(tlv5, "W", (uint32_t) 0); icq_pack_append(tlv5, "II", cookie1, cookie2); // cookie - icq_pack_append(tlv5, "P", (uint32_t) 0x1349); // AIM_CAPS_ICQSERVERRELAY - Client supports channel 2 extended, TLV(0x2711) based messages. + icq_pack_append_cap(tlv5, CAP_SRV_RELAY); // AIM_CAPS_ICQSERVERRELAY - Client supports channel 2 extended, TLV(0x2711) based messages. icq_pack_append(tlv5, "tW", icq_pack_tlv_word(0xA, 1)); // TLV 0x0A: acktype (1 = normal message) icq_pack_append(tlv5, "T", icq_pack_tlv(0x0F, NULL, 0)); // TLV 0x0F: unknown // RendezvousMessageData rdv = string_init(NULL); - icq_pack_append(rdv, "wwiiiiwicwwwiiiccwwwcii", + icq_pack_append(rdv, "wwiiiiwicw wwiiiccwwwc", (uint32_t) 27, // length of this data segment, always 27 (uint32_t) 8, // protocol version (uint32_t) 0, (uint32_t) 0, (uint32_t) 0, (uint32_t) 0, // pluginID (uint32_t) 0, // unknown (uint32_t) 3, // unknown - (uint32_t) 0, // unknown + (uint32_t) 0, // unknown byte (uint32_t) 0x7fff, // channel 2 counter XXX + (uint32_t) 14, // length of this data segment, always 14 (uint32_t) 0x7fff, // channel 2 counter XXX (uint32_t) 0, (uint32_t) 0, (uint32_t) 0, // unknown, usually all zeros - (uint32_t) 0xe8, // msg type XXX ??? + mtype, // msg type (uint32_t) 3, // msg flags XXX ??? (uint32_t) 1, // status code ??? XXX (uint32_t) 1, // priority ??? XXX - (uint32_t) 1, // - (uint32_t) 0, // - (uint32_t) 0, // foreground - (uint32_t) 0x00ffffff); // foreground + (uint32_t) 1, // msg length + (uint32_t) 0); // msg icq_pack_append(tlv5, "T", icq_pack_tlv(0x2711, rdv->str, rdv->len)); string_free(rdv, 1); @@ -147,6 +153,7 @@ if (u) { user_private_item_set_int(u, "caps", 0); user_private_item_set_int(u, "utf", 0); + user_private_item_set_int(u, "xstatus", 0); } for (t = tlvs; t; t = t->next) { @@ -378,12 +385,17 @@ } } - if (!descr) { - if (u) - descr = xstrdup(u->descr); + if (status == EKG_STATUS_AVAIL) { + if (u) { + xfree(u->descr); + u->descr = NULL; + } + } else icq_get_description(s, pkt.uid, status); - } + if (!descr && u) + descr = xstrdup(u->descr); + protocol_status_emit(s, uid, status, descr, time(NULL)); icq_tlvs_destroy(&tlvs); Modified: trunk/plugins/icq/icq_snac_handlers_04message.inc =================================================================== --- trunk/plugins/icq/icq_snac_handlers_04message.inc 2008-09-20 13:30:37 UTC (rev 4668) +++ trunk/plugins/icq/icq_snac_handlers_04message.inc 2008-09-20 15:14:31 UTC (rev 4669) @@ -492,8 +492,6 @@ /* XXX, more cookies... */ - icq_hexdump(DEBUG_ERROR, buf, len); - if (flags == 3) { /* A status message reply */ char *reason; @@ -504,7 +502,8 @@ icq_snac_message_status_reply(s, "SNAC(4,B)", pkt.uid, version, reason); xfree(reason); return 0; - } + } else + icq_hexdump(DEBUG_ERROR, buf, len); } else { /* XXX */ icq_hexdump(DEBUG_ERROR, buf, len); From svn w toxygen.net Sat Sep 20 18:41:22 2008 From: svn w toxygen.net (SVN commit) Date: Sat, 20 Sep 2008 18:41:22 +0200 (CEST) Subject: [ekg2-commit] r4670 - trunk/plugins/icq: trunk/plugins/icq/icq.h trunk/plugins/icq/icq_const.h trunk/plugins/icq/icq_snac_handlers_03buddy.inc trunk/plugins/icq/icq_snac_handlers_04message.inc Message-ID: <20080920164122.C702E17B34@toxygen.net> Author: wiechu Date: 2008-09-20 18:41:22 +0200 (Sat, 20 Sep 2008) New Revision: 4670 Modified: trunk/plugins/icq/icq.h trunk/plugins/icq/icq_const.h trunk/plugins/icq/icq_snac_handlers_03buddy.inc trunk/plugins/icq/icq_snac_handlers_04message.inc Log: - request uft-8 status description - clean code Modified: trunk/plugins/icq/icq.h =================================================================== --- trunk/plugins/icq/icq.h 2008-09-20 15:14:31 UTC (rev 4669) +++ trunk/plugins/icq/icq.h 2008-09-20 16:41:22 UTC (rev 4670) @@ -38,6 +38,7 @@ int flap_seq; /* FLAP seq id */ uint16_t snac_seq; /* SNAC seq id */ int snacmeta_seq; /* META SNAC seq id */ + int cookie_seq; /* Cookie seq id */ int ssi; /* server-side-userlist? */ int aim; /* aim-ok? */ Modified: trunk/plugins/icq/icq_const.h =================================================================== --- trunk/plugins