Hello,

Another patch, now icqStatus is displayed properly.


--
Oleg
-------------- next part --------------
--- src/legacy/icqt.py  Mon Aug  1 03:37:50 2005
+++ src/legacy/icqt.py  Mon Aug  1 07:37:53 2005
@@ -99,7 +99,7 @@
                debug.log("B: updateBuddy %s" % (user))
                buddyjid = icq2jid(user.name)
                ptype = None
-               show = None
+               show = user.icqStatus
                status = None
                if (user.flags.count("away")):
                        
self.getAway(user.name).addCallback(self.sendAwayPresence, user)
@@ -162,7 +162,12 @@
 
                buddyjid = icq2jid(user.name)
                ptype = None
-               show = "away"
+               show = user.icqStatus
+               if show == "busy":
+                       show = "dnd"
+               if show == "unknown":
+                       show = "away"
+                   
                status = msg[1]
 
                if status != None: 
--- src/tlib/oscar.py   Mon Aug  1 03:37:50 2005
+++ src/tlib/oscar.py   Mon Aug  1 07:40:39 2005
@@ -111,6 +111,7 @@
         self.warning = warn
         self.flags = []
         self.caps = []
+        self.icqStatus = 'unknown'
         for k,v in tlvs.items():
             if k == 1: # user flags
                 v=struct.unpack('!H',v)[0]
@@ -130,17 +131,23 @@
                 self.idleTime = struct.unpack('!H',v)[0]
             elif k == 5: # unknown
                 pass
-            elif k == 6: # icq online status
-                if v[2] == '\x00':
+            elif k == 6: # icq online status 
http://iserverd1.khstu.ru/oscar/lists.html#user_status
+
+
+                statusbyte=struct.unpack('!4B',v)[3]
+
+                if statusbyte == 0x00:
                     self.icqStatus = 'online'
-                elif v[2] == '\x01':
+                elif statusbyte == 0x01:
                     self.icqStatus = 'away'
-                elif v[2] == '\x02':
+                elif statusbyte >= 0x02 and statusbyte < 0x04:
                     self.icqStatus = 'dnd'
-                elif v[2] == '\x04':
+                elif statusbyte >= 0x04 and statusbyte < 0x08:
                     self.icqStatus = 'xa'
-                elif v[2] == '\x10':
+                elif statusbyte >= 0x10 and statusbyte < 0x20:
                     self.icqStatus = 'busy'
+                elif statusbyte >= 0x20 and statusbyte < 0x40:
+                    self.icqStatus = 'chat'
                 else:
                     self.icqStatus = 'unknown'
             elif k == 10: # icq ip address
@@ -171,6 +178,7 @@
         o = []
         if self.warning!=0: o.append('warning level %s'%self.warning)
         if hasattr(self, 'flags'): o.append('flags %s'%self.flags)
+        if hasattr(self, 'icqStatus'): o.append('icqStatus is 
%s'%self.icqStatus)
         if hasattr(self, 'sessionLength'): o.append('online for %i minutes' % 
(self.sessionLength/60,))
         if hasattr(self, 'idleTime'): o.append('idle for %i minutes' % 
self.idleTime)
         if self.caps: o.append('caps %s'%self.caps)
From [EMAIL PROTECTED]  Mon Aug  1 04:12:41 2005
From: [EMAIL PROTECTED] (Oleg Motienko)
Date: Mon Aug  1 04:12:53 2005
Subject: [py-transports] Re: PyICQ-t patch for detecting IP address
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>     <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

Daniel Henninger wrote:
> Ok, no worries then.  I'm about to commit my changes.
> 
> Anyone interested in testing it out can check out SVN and pull a vcard 
> of any particular user and you should see the ip address type 
> information in the DESC/About field.
> 
> Daniel
> 

If I try to list vcard of user which never be online at this session, 
I've got:

 
desc.addContent("\n\n-----\n"+c['lanipaddr']+'/'+c['ipaddr']+':'+"%s"%(c['lanipport'])+'
 
v.'+"%s"%(c['icqprotocol']))
exceptions.TypeError: cannot concatenate 'str' and 'NoneType' objects

I think it must be an additional check there.

--
Oleg
From [EMAIL PROTECTED]  Mon Aug  1 08:24:39 2005
From: [EMAIL PROTECTED] (Oleg Motienko)
Date: Mon Aug  1 08:24:51 2005
Subject: [py-transports] Re: PyICQ-t patch for detecting IP address
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>     <[EMAIL PROTECTED]>     
<[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

Oleg Motienko wrote:
> Daniel Henninger wrote:
>> Ok, no worries then.  I'm about to commit my changes.
>>
>> Anyone interested in testing it out can check out SVN and pull a vcard 
>> of any particular user and you should see the ip address type 
>> information in the DESC/About field.
>>
>> Daniel
>>
> 
> If I try to list vcard of user which never be online at this session, 
> I've got:
> 
> 
> desc.addContent("\n\n-----\n"+c['lanipaddr']+'/'+c['ipaddr']+':'+"%s"%(c['lanipport'])+'
>  
> v.'+"%s"%(c['icqprotocol']))
> exceptions.TypeError: cannot concatenate 'str' and 'NoneType' objects
> 
> I think it must be an additional check there.
> 
see attachment
works ok for me

--
Oleg
-------------- next part --------------
--- src/legacy/icqt.py  Mon Aug  1 07:45:12 2005
+++ src/legacy/icqt.py  Mon Aug  1 12:11:07 2005
@@ -371,9 +376,12 @@
                        bday.addContent(usercol.birthday)
                        desc = vcard.addElement("DESC")
                        desc.addContent(usercol.about)
-                       if (self.contacts.ssicontacts[usercol.userinfo]):
-                               c = self.contacts.ssicontacts[usercol.userinfo]
-                               
desc.addContent("\n\n-----\n"+c['lanipaddr']+'/'+c['ipaddr']+':'+"%s"%(c['lanipport'])+'
 v.'+"%s"%(c['icqprotocol']))
+                       try:
+                           if (self.contacts.ssicontacts[usercol.userinfo]):
+                                   c = 
self.contacts.ssicontacts[usercol.userinfo]
+                                   
desc.addContent("\n\n-----\n"+c['lanipaddr']+'/'+c['ipaddr']+':'+"%s"%(c['lanipport'])+'
 v.'+"%s"%(c['icqprotocol']))
+                       except:
+                               pass
                        url = vcard.addElement("URL")
                        url.addContent(usercol.homepage)
 
From [EMAIL PROTECTED]  Mon Aug  1 08:30:56 2005
From: [EMAIL PROTECTED] (Sander Devrieze)
Date: Mon Aug  1 08:31:13 2005
Subject: [py-transports] Re: PyICQ-t patch for detecting IP address
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

Op maandag 01 augustus 2005 04:29, schreef Oleg Motienko:
<snip>
> > I'm going to commit the changes for now so others can play with it if
> > they are interested, but i'm curious about these 0's and if they're
> > normal.
>
> 0.0.0.0 means user hide own IP (many clients support this).

Idea: if the user hide his IP, 0.0.0.0 is replaced by the transport with the 
text "User hides his IP".

-- 
Mvg, Sander Devrieze.

xmpp:[EMAIL PROTECTED] ( http://jabber.tk/ )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : 
http://modevia.com/pipermail/py-transports/attachments/20050801/da1c8606/attachment.pgp
From [EMAIL PROTECTED]  Mon Aug  1 08:50:37 2005
From: [EMAIL PROTECTED] (Oleg Motienko)
Date: Mon Aug  1 08:50:42 2005
Subject: [py-transports] PyICQ-t patch for detecting IP address
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

On 8/1/05, Daniel Henninger <[EMAIL PROTECTED]> wrote:
> Hey Oleg, got a question for you.  I decided not to put this
> information in presence and instead put it in the DESC field in the
> VCARD similar to how JIT does.  I was wondering, however, if it's
> normal for a lot of this information to come in as all or mostly
> 0's?  For example:
> 
> 0.0.0.0/0.0.0.0(0) v.8
> or
> 0.0.0.0/24.163.106.248:0 v.0

It's really strange, because JIT can detect more IP's. I try to detect
via JIT, it give me both IP's and port of user, PyICQ-t give zeroes
for same user.
Anybody know, why ? Maybe the reason is compatibilities which PyICQ-t
announce for itself ?

-- 
Regards,
Oleg
From [EMAIL PROTECTED]  Mon Aug  1 09:18:25 2005
From: [EMAIL PROTECTED] (Oleg Motienko)
Date: Mon Aug  1 09:18:29 2005
Subject: [py-transports] PyICQ-t patch for detecting IP address
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

On 8/1/05, Oleg Motienko <[EMAIL PROTECTED]> wrote:

> It's really strange, because JIT can detect more IP's. I try to detect
> via JIT, it give me both IP's and port of user, PyICQ-t give zeroes
> for same user.
> Anybody know, why ? Maybe the reason is compatibilities which PyICQ-t
> announce for itself ?

Sorry I missed that I use different uins for JIT and PyICQ-t. If I use
the same uin, all works fine. This because most of IP's cannot be
detected if my uin isn't in server list of user.

-- 
Regards,
Oleg
From [EMAIL PROTECTED]  Mon Aug  1 14:01:19 2005
From: [EMAIL PROTECTED] (Oleg Motienko)
Date: Mon Aug  1 14:01:32 2005
Subject: [py-transports] Re: PyICQ-t patch for detecting IP address
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>     <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

Sander Devrieze wrote:

> Idea: if the user hide his IP, 0.0.0.0 is replaced by the transport with the 
> text "User hides his IP".

Another patch :)
Adding support for version detecting and changing a bit displaying 
format of this information.
It can also detect non-official clients like Miranda, SIM, Kopete etc.

--
Oleg

-------------- next part --------------
diff -ur src/legacy/icqt.py src/legacy/icqt.py
--- src/legacy/icqt.py  Mon Aug  1 13:52:59 2005
+++ src/legacy/icqt.py  Mon Aug  1 17:51:24 2005
@@ -105,7 +105,7 @@
                        
self.getAway(user.name).addCallback(self.sendAwayPresence, user)
                else:
                        self.session.sendPresence(to=self.session.jabberID, 
fro=buddyjid, show=show, status=status, ptype=ptype)
-                       self.icqcon.contacts.updateSSIContact(user.name, 
presence=ptype, show=show, status=status, ipaddr=user.icqIPaddy, 
lanipaddr=user.icqLANIPaddy, lanipport=user.icqLANIPport, 
icqprotocol=user.icqProtocolVersion)
+                       self.icqcon.contacts.updateSSIContact(user.name, 
presence=ptype, show=show, status=status, ipaddr=user.icqIPaddy, 
lanipaddr=user.icqLANIPaddy, lanipport=user.icqLANIPport, 
icqprotocol=user.icqProtocolVersion, icqforeignclient=user.icqForeignClient)
 
        def offlineBuddy(self, user):
                from glue import icq2jid
@@ -185,7 +185,7 @@
                                % (charset, msg[0], status) )
 
                self.session.sendPresence(to=self.session.jabberID, 
fro=buddyjid, show=show, status=status, ptype=ptype)
-               self.icqcon.contacts.updateSSIContact(user.name, 
presence=ptype, show=show, status=status, ipaddr=user.icqIPaddy, 
lanipaddr=user.icqLANIPaddy, lanipport=user.icqLANIPport, 
icqprotocol=user.icqProtocolVersion)
+               self.icqcon.contacts.updateSSIContact(user.name, 
presence=ptype, show=show, status=status, ipaddr=user.icqIPaddy, 
lanipaddr=user.icqLANIPaddy, lanipport=user.icqLANIPport, 
icqprotocol=user.icqProtocolVersion, icqforeignclient=user.icqForeignClient)
 
        def gotSelfInfo(self, user):
                debug.log("B: gotSelfInfo: %s" % (user.__dict__))
@@ -371,9 +371,31 @@
                        bday.addContent(usercol.birthday)
                        desc = vcard.addElement("DESC")
                        desc.addContent(usercol.about)
-                       if (self.contacts.ssicontacts[usercol.userinfo]):
-                               c = self.contacts.ssicontacts[usercol.userinfo]
-                               
desc.addContent("\n\n-----\n"+c['lanipaddr']+'/'+c['ipaddr']+':'+"%s"%(c['lanipport'])+'
 v.'+"%s"%(c['icqprotocol']))
+                       try:
+                           if (self.contacts.ssicontacts[usercol.userinfo]):
+                                   c = 
self.contacts.ssicontacts[usercol.userinfo]
+                                   ipinfo = 'Not detected'
+                                   icqprotocol = 'Unknown'
+                                   icqclient = ''
+                                   if c['ipaddr'] != None and c['ipaddr'] != 
'0.0.0.0':
+                                       ipinfo = c['ipaddr']
+                                   if c['lanipaddr'] != None and 
c['lanipaddr'] != '0.0.0.0':
+                                       ipinfo = 
c['lanipaddr']+':'+"%s"%(c['lanipport']) +' / '+ipinfo
+                                   if c['icqprotocol'] != None and 
c['icqprotocol'] > 0:
+                                       icqprotocol = "%s"%(c['icqprotocol'])
+
+                                       for ver, cname in [(0x0004,'ICQ98'),
+                                              (0x0006,'ICQ99'),
+                                              (0x0007,'ICQ2000'),
+                                              (0x0008,'ICQ2001'),
+                                              (0x0009,'ICQ Lite'),
+                                              (0x000A,'ICQ2003B')]:
+                                             if c['icqprotocol'] == ver: 
icqclient = ' / ' + cname
+                                   if c['icqforeignclient'] != None and 
c['icqforeignclient'] != 'unknown':
+                                          icqclient = ' / ' + 
c['icqforeignclient']
+                                   desc.addContent("\n\n-----\nIP: "+ipinfo+' 
; v.'+ icqprotocol +  icqclient)
+                       except:
+                               pass
                        url = vcard.addElement("URL")
                        url.addContent(usercol.homepage)
 
@@ -690,7 +712,7 @@
                self.xdbcontacts = self.getXDBBuddies()
                self.xdbchanged = False
 
-       def updateSSIContact(self, contact, presence="unavailable", show=None, 
status=None, skipsave=False, nick=None, ipaddr=None, lanipaddr=None, 
lanipport=None, icqprotocol=None):
+       def updateSSIContact(self, contact, presence="unavailable", show=None, 
status=None, skipsave=False, nick=None, ipaddr=None, lanipaddr=None, 
lanipport=None, icqprotocol=None, icqforeignclient=None):
                debug.log("ICQContacts: updating contact %s" % 
(contact.lower()))
                self.ssicontacts[contact.lower()] = {
                        'presence': presence,
@@ -699,7 +721,8 @@
                        'ipaddr' : ipaddr,
                        'lanipaddr' : lanipaddr,
                        'lanipport' : lanipport,
-                       'icqprotocol' : icqprotocol
+                       'icqprotocol' : icqprotocol,
+                       'icqforeignclient' : icqforeignclient
                }
 
                if (not self.xdbcontacts.count(contact.lower())):
diff -ur src/tlib/oscar.py src/tlib/oscar.py
--- src/tlib/oscar.py   Mon Aug  1 13:52:59 2005
+++ src/tlib/oscar.py   Mon Aug  1 17:51:24 2005
@@ -113,6 +113,8 @@
         self.warning = warn
         self.flags = []
         self.caps = []
+        self.icqStatus = 'unknown'
+       self.icqForeignClient = 'unknown'
         for k,v in tlvs.items():
             if k == 1: # user flags
                 v=struct.unpack('!H',v)[0]
@@ -132,17 +134,23 @@
                 self.idleTime = struct.unpack('!H',v)[0]
             elif k == 5: # unknown
                 pass
-            elif k == 6: # icq online status
-                if v[2] == '\x00':
+            elif k == 6: # icq online status 
http://iserverd1.khstu.ru/oscar/lists.html#user_status
+
+
+                statusbyte=struct.unpack('!4B',v)[3]
+
+                if statusbyte == 0x00:
                     self.icqStatus = 'online'
-                elif v[2] == '\x01':
+                elif statusbyte == 0x01:
                     self.icqStatus = 'away'
-                elif v[2] == '\x02':
+                elif statusbyte >= 0x02 and statusbyte < 0x04:
                     self.icqStatus = 'dnd'
-                elif v[2] == '\x04':
+                elif statusbyte >= 0x04 and statusbyte < 0x08:
                     self.icqStatus = 'xa'
-                elif v[2] == '\x10':
+                elif statusbyte >= 0x10 and statusbyte < 0x20:
                     self.icqStatus = 'busy'
+                elif statusbyte >= 0x20 and statusbyte < 0x40:
+                    self.icqStatus = 'chat'
                 else:
                     self.icqStatus = 'unknown'
             elif k == 10: # icq ip address
@@ -153,15 +161,43 @@
                 self.icqLANIPaddy = socket.inet_ntoa(self.icqRandom[0])
                 self.icqLANIPport = self.icqRandom[1]
                 self.icqProtocolVersion = self.icqRandom[3]
+
             elif k == 13: # capabilities
                 caps=[]
                 while v:
                     c=v[:16]
                     if CAPS.has_key(c): caps.append(CAPS[c])
-                    else: caps.append(("unknown",c))
+                    elif c[7:] == "QIP 2005a":
+                       self.icqForeignClient = 'QIP 2005a'
+                    elif c[:8] == "MirandaM":
+                       fcver = struct.unpack('!8B',c[8:])
+                       self.icqForeignClient = "MirandaM %s.%s.%s.%s ICQ 
Plugin %s.%s.%s.%s" % 
(fcver[0],fcver[1],fcver[2],fcver[3],fcver[4],fcver[5],fcver[6],fcver[7])
+                    elif c[:12] == "Kopete ICQ  ":
+                       fcver = struct.unpack('!4B',c[12:])
+                       self.icqForeignClient = "Kopete ICQ %s.%s.%s.%s" % 
(fcver[0],fcver[1],fcver[2],fcver[3])
+                    elif c[:12] == "SIM client  ":
+                       fcver = struct.unpack('!4B',c[12:])
+                       self.icqForeignClient = "SIM client %s.%s.%s.%s" % 
(fcver[0],fcver[1],fcver[2],fcver[3])
+                    elif c[:9] == "&RQinside":
+                       fcver = struct.unpack('!7B',c[9:])
+                       self.icqForeignClient = "&RQinside 
%s.%s.%s.%s.%s.%s.%s" % 
(fcver[0],fcver[1],fcver[2],fcver[3],fcver[4],fcver[5],fcver[6])
+                    elif c[:12] == "Licq client ":
+                       fcver = struct.unpack('!4B',c[12:])
+                       self.icqForeignClient = "Licq client %s.%s.%s.%s" % 
(fcver[0],fcver[1],fcver[2],fcver[3])
+                   else: caps.append(("unknown",c))
                     v=v[16:]
                 caps.sort()
-                self.caps=caps
+                if (caps.count("trilliancrypt")):
+                   self.icqForeignClient = 'Trillian'
+                if (caps.count("secureim")):
+                   self.icqForeignClient = 'secureim'
+                if (caps.count("hiptop")):
+                   self.icqForeignClient = 'Hiptop'
+                if (caps.count("ichat")):
+                   self.icqForeignClient = 'ichat'
+                if (caps.count("ichatav")):
+                   self.icqForeignClient = 'ichatav'
+               self.caps=caps
             elif k == 14: pass
             elif k == 15: # session length (aim)
                 self.sessionLength = struct.unpack('!L',v)[0]
@@ -177,6 +213,8 @@
         o = []
         if self.warning!=0: o.append('warning level %s'%self.warning)
         if hasattr(self, 'flags'): o.append('flags %s'%self.flags)
+        if hasattr(self, 'icqStatus'): o.append('icqStatus is 
%s'%self.icqStatus)
+        if hasattr(self, 'icqForeignClient'): o.append('icqForeignClient is 
%s'%self.icqForeignClient)
         if hasattr(self, 'sessionLength'): o.append('online for %i minutes' % 
(self.sessionLength/60,))
         if hasattr(self, 'idleTime'): o.append('idle for %i minutes' % 
self.idleTime)
         if self.caps: o.append('caps %s'%self.caps)
From [EMAIL PROTECTED]  Mon Aug  1 23:09:54 2005
From: [EMAIL PROTECTED] (Oscar =?ISO-8859-1?Q?Hellstr=F6m?=)
Date: Mon Aug  1 23:09:49 2005
Subject: [py-transports] Encoding problems with PyICQ-t
Message-ID: <[EMAIL PROTECTED]>

Installed the latest CVS tarball and look, i can recieve ???? and such
from ICQ folks. However, the Vcards and status messages are messed up
still. If someone doesn't know a quick fix, i'll tell you more about
what happends, when and what encoding, icq client etc...

-- 
Oscar Hellstr?m, [EMAIL PROTECTED]
jid: [EMAIL PROTECTED]
icq: 52604556
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : 
http://modevia.com/pipermail/py-transports/attachments/20050802/6859f97b/attachment.pgp
From [EMAIL PROTECTED]  Mon Aug  1 23:58:45 2005
From: [EMAIL PROTECTED] (Daniel Henninger)
Date: Mon Aug  1 23:58:43 2005
Subject: [py-transports] Encoding problems with PyICQ-t
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

I have another patch waiting to fix the problem with the status messages .
. . however vcards are messed up?  That's interesting.. I thought that was
fixed.  =(  Could you go ahead and tell me more?  (more information is
always better than not enough  ;)  )

Daniel

-- 
"The most addictive drug in the world is music."
     - The Lost Boyz

> Installed the latest CVS tarball and look, i can recieve ???????? and such
> from ICQ folks. However, the Vcards and status messages are messed up
> still. If someone doesn't know a quick fix, i'll tell you more about
> what happends, when and what encoding, icq client etc...
>
> --
> Oscar Hellstr??m, [EMAIL PROTECTED]
> jid: [EMAIL PROTECTED]
> icq: 52604556
> _______________________________________________
> py-transports mailing list
> [email protected]
> http://www.modevia.com/cgi-bin/mailman/listinfo/py-transports
>

Reply via email to