My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 74 attachment: pyicq20070712.patch (8.1 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
diff -Naur 1/globals.py 2/globals.py
--- 1/globals.py 2007-03-30 11:34:45.000000000 +0300
+++ 2/globals.py 2007-07-12 09:59:56.000000000 +0300
@@ -37,6 +37,7 @@
XAVATAR = "jabber:x:avatar"
XCONFERENCE = "jabber:x:conference"
XDATA = "jabber:x:data"
+XDELAY = "jabber:x:delay"
XEVENT = "jabber:x:event"
XHTML = "http://jabber.org/protocol/xhtml-im"
SAPO_NOERROR = "sapo:noerror"
diff -Naur 1/jabw.py 2/jabw.py
--- 1/jabw.py 2007-03-30 11:34:45.000000000 +0300
+++ 2/jabw.py 2007-07-12 09:59:56.000000000 +0300
@@ -22,7 +22,7 @@

if delay:
x = el.addElement("x")
- x.attributes["xmlns"] = globals.IQDELAY
+ x.attributes["xmlns"] = globals.XDELAY
x.attributes["from"] = fro
x.attributes["stamp"] = delay

diff -Naur 1/legacy/icqt.py 2/legacy/icqt.py
--- 1/legacy/icqt.py 2007-03-30 11:34:44.000000000 +0300
+++ 2/legacy/icqt.py 2007-07-12 13:27:51.000000000 +0300
@@ -153,6 +153,11 @@
status = status.decode("iso-8859-1", "replace")
if status == "Away" or status=="I am currently away from the computer." or status=="I am away from my computer right now.":
status = ""
+ try:
+ status = status.decode("utf16be", "replace")
+ debug.log("mxx: icqt status.decode utf16be")
+ except:
+ pass
if user.idleTime:
if user.idleTime>60*24:
idle_time = "Idle %d days"%(user.idleTime/(60*24))
@@ -176,7 +181,6 @@

if user.caps:
self.oscarcon.legacyList.setCapabilities(user.name, user.caps)
- status = status.encode("utf-8", "replace")
if user.flags.count("away"):
self.getAway(user.name).addCallback(self.sendAwayPresence, user)
else:
@@ -201,7 +205,7 @@
c.updatePresence(show=show, status=status, ptype=ptype)
self.oscarcon.legacyList.updateSSIContact(user.name, presence=ptype, show=show, status=status)

- def receiveMessage(self, user, multiparts, flags):
+ def receiveMessage(self, user, multiparts, flags, delay=None):
from glue import icq2jid

LogEvent(INFO, self.session.jabberID, "%s %s %s" % (user.name, multiparts, flags))
@@ -224,7 +228,7 @@
if "auto" in flags:
mtype = "headline"

- self.session.sendMessage(to=self.session.jabberID, fro=sourcejid, body=text, mtype=mtype, xhtml=xhtml)
+ self.session.sendMessage(to=self.session.jabberID, fro=sourcejid, body=text, mtype=mtype, delay=delay, xhtml=xhtml)
self.session.pytrans.serviceplugins['Statistics'].stats['IncomingMessages'] += 1
self.session.pytrans.serviceplugins['Statistics'].sessionUpdate(self.session.jabberID, 'IncomingMessages', 1)
if not config.disableAwayMessage and self.awayMessage and not "auto" in flags:
@@ -306,11 +310,12 @@
else:
show = 'away'

- status = oscar.dehtml(msg[1]) # Removes any HTML tags
+ #status = oscar.dehtml(msg[1]) # Removes any HTML tags
+ status = msg[1]
url = user.url

if status != None:
- charset = "iso-8859-1"
+ charset = config.encoding
m = None
if msg[0]:
m = re.search('charset="(.+)"', msg[0])
@@ -327,7 +332,14 @@
status = msg[0] + ": " + status

status = status.decode(charset, 'replace')
- LogEvent(INFO, self.session.jabberID, "Away (%s, %s) message %s" % (charset, msg[0], status))
+ if charset == 'utf-16be':
+ status = status.encode(config.encoding, 'replace')
+ status = oscar.dehtml(status) # Removes any HTML tags
+ try:
+ LogEvent(INFO, self.session.jabberID, "Away (%s, %s) message %s" % (charset, msg[0], status))
+ except:
+ LogEvent(INFO, self.session.jabberID, "Away broken (%s, s) message s" % (charset))
+ pass

if status == "Away" or status=="I am currently away from the computer." or status=="I am away from my computer right now.":
status = ""
diff -Naur 1/main.py 2/main.py
--- 1/main.py 2007-03-30 11:34:45.000000000 +0300
+++ 2/main.py 2007-07-12 16:33:11.957894897 +0300
@@ -89,7 +89,10 @@
import signal
signal.signal(signal.SIGHUP, reloadConfig)
# Load scripts for PID and daemonizing
- from twisted.scripts import twistd
+ try:
+ from twisted.scripts import _twistd_unix as twistd
+ except:
+ from twisted.scripts import twistd

selectWarning = "Unable to install any good reactors (kqueue, cf, epoll, poll).\nWe fell back to using select. You may have scalability problems.\nThis reactor will not support more than 1024 connections +at a time. You may silence this message by choosing 'select' or 'default' as your reactor in the transport config."
if config.reactor and len(config.reactor) > 0:
diff -Naur 1/tlib/oscar.py 2/tlib/oscar.py
--- 1/tlib/oscar.py 2007-06-18 16:49:35.000000000 +0300
+++ 2/tlib/oscar.py 2007-07-12 10:20:33.000000000 +0300
@@ -19,6 +19,7 @@

from scheduler import Scheduler

+import config
import struct
import md5
import string
@@ -199,7 +200,7 @@
# in the docutils extension module
# see http://docutils.sourceforge.net
# modified for better use here
-def guess_encoding(data, defaultencoding='iso-8859-1'):
+def guess_encoding(data, defaultencoding=config.encoding):
"""
Given a byte string, attempt to decode it.
Tries 'utf-16be, 'utf-8' and 'iso-8859-1' (or something else) encodings.
@@ -870,7 +871,7 @@
self.connectPort = 5190
# Note that this is "no unicode" default encoding
# We use unicode if it's there
- self.defaultEncoding = 'iso-8859-1'
+ self.defaultEncoding = config.encoding

if not self.capabilities:
self.capabilities = [CAP_CHAT]
@@ -1641,12 +1642,12 @@
# Offline message
senderuin = struct.unpack('<I',v[10:14])[0]
#print "senderuin: "+str(senderuin)+"\n"
- msg_date = str( "%4d-%02d-%02d %02d:%02d"
- % struct.unpack('<HBBBB', v[14:20]) )
+ msg_date = str( "%4d-%02d-%02dT%02d:%02d:00Z" #XEP-091 date format
+ % struct.unpack('<HBBBB', v[14:20]) )
messagetype, messageflags,messagelen = struct.unpack('<BBH',v[20:24])
umessage, encoding = guess_encoding(v[24:24+messagelen-1],self.defaultEncoding)
log.msg("Converted message, encoding %r: %r" % (encoding, umessage))
- umessage = umessage + "\n\n/sent " + msg_date
+ #umessage = umessage + "\n\n/sent " + msg_date
message = [ umessage.encode("utf-16be"), "unicode" ]
#message = [ str( v[24:24+messagelen-1] )
# + "\n\n/sent " + msg_date ]
@@ -1657,7 +1658,7 @@
tlvs = dict()
multiparts.append(tuple(message))
user = OSCARUser(str(senderuin), None, tlvs)
- self.receiveMessage(user, multiparts, flags)
+ self.receiveMessage(user, multiparts, flags, msg_date)
elif (type == 0x42):
# End of offline messages
reqdata = '\x08\x00'+struct.pack("<I",int(self.username))+'\x3e\x00\x02\x00'
@@ -2022,14 +2023,14 @@
charSet = 0x0000
except:
try:
- part[0] = part[0].encode('iso-8859-1')
+ part[0] = part[0].encode(config.encoding)
charSet = 0x0003
except:
try:
part[0] = part[0].encode('utf-16be', 'replace')
charSet = 0x0002
except:
- part[0] = part[0].encode('iso-8859-1', 'replace')
+ part[0] = part[0].encode(config.encoding, 'replace')
charSet = 0x0003
if 'macintosh' in part[1:]:
charSubSet = 0x000b
@@ -2042,7 +2043,7 @@
# We'll investigate this in more detail later.
features = '\x01\x01\x02'
# Why do i need to encode this? I shouldn't .. it's data.
- data = data.encode('iso-8859-1', 'replace') + TLV(2, TLV(0x0501, features)+messageData)
+ data = data.encode(config.encoding, 'replace') + TLV(2, TLV(0x0501, features)+messageData)
if wantAck:
log.msg("sendMessage: Sending wanting ACK")
data = data + TLV(3)
Powered by Google Project Hosting