[ekg2-commit] r4606 - trunk/plugins/icq: trunk/plugins/icq/icq_caps.c trunk/plugins/icq/icq_caps.h trunk/plugins/icq/icq_snac_handlers_03buddy.inc
SVN commit
svn w toxygen.net
Pią, 5 Wrz 2008, 23:58:47 CEST
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 <string.h>
+#include <ekg/debug.h>
+
#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; i<CAP_UNKNOWN; i++) {
- if (memcmp(buf, _caps[i], 0x10))
+ if (!memcmp(buf, _caps[i], 0x10))
return i;
}
return CAP_UNKNOWN;
}
+int icq_short_cap_id(unsigned char *buf) {
+ _capability_t cap;
+ memcpy(&cap, _caps[CAP_VOICE], 0x10);
+ cap[2] = buf[0];
+ cap[3] = buf[1];
+ return icq_cap_id(cap);
+}
+
const unsigned char *icq_cap_str(int id) {
if ( (id>0) && (id<CAP_UNKNOWN) )
return _caps[id];
Modified: trunk/plugins/icq/icq_caps.h
===================================================================
--- trunk/plugins/icq/icq_caps.h 2008-09-05 17:30:53 UTC (rev 4605)
+++ trunk/plugins/icq/icq_caps.h 2008-09-05 21:58:47 UTC (rev 4606)
@@ -29,6 +29,7 @@
const char *icq_capability_name(int id);
int icq_cap_id(unsigned char *buf);
+int icq_short_cap_id(unsigned char *buf);
const unsigned char *icq_cap_str(int id);
Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.inc
===================================================================
--- trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-05 17:30:53 UTC (rev 4605)
+++ trunk/plugins/icq/icq_snac_handlers_03buddy.inc 2008-09-05 21:58:47 UTC (rev 4606)
@@ -139,12 +139,18 @@
status = EKG_STATUS_AVAIL; /* assume avail */
uid = icq_uid(pkt.uid);
- u = userlist_find(s, uid);
+ if (!(u = userlist_find(s, uid)) && config_auto_user_add)
+ u = userlist_add(s, uid, uid);
debug_white("icq_snac_buddy_online() %s\n", uid);
- if (u) for (t = tlvs; t; t = t->next) {
+ 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);
}
Więcej informacji o liście dyskusyjnej ekg2-commit