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: pyicq20080115.patch (9.8 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
diff -Naur src2-1/globals.py src2-2/globals.py
--- src2-1/globals.py 2007-12-19 14:40:55.000000000 +0200
+++ src2-2/globals.py 2007-12-21 19:26:25.000000000 +0200
@@ -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 src2-1/jabw.py src2-2/jabw.py
--- src2-1/jabw.py 2007-12-19 14:40:55.000000000 +0200
+++ src2-2/jabw.py 2007-12-21 19:26:25.000000000 +0200
@@ -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

@@ -105,7 +105,12 @@

pytrans.send(el)

-def sendErrorMessage(pytrans, to, fro, etype, condition, explanation, body=None, el=Element((None, "message"))):
+#http://hancke.name/jabber/doubleerror.patch
+#http://www.blathersource.org/bugs_view.php?projid=pyicq-t&bugid=281
+#def sendErrorMessage(pytrans, to, fro, etype, condition, explanation, body=None, el=Element((None, "message"))):
+def sendErrorMessage(pytrans, to, fro, etype, condition, explanation, body=None, el=None):
+ if el is None:
+ el = Element((None, "message"))
el.attributes["to"] = to
el.attributes["from"] = fro
el.attributes["type"] = "error"
diff -Naur src2-1/langs/ru.py src2-2/langs/ru.py
--- src2-1/langs/ru.py 2007-12-19 14:40:53.000000000 +0200
+++ src2-2/langs/ru.py 2007-12-22 18:50:35.000000000 +0200
@@ -10,5 +10,4 @@
notregistered = u"Извините. Вы не зарегистрированы в этой службе. Зарегистрирутесь и попробуйте снова. В крайнем случае обратитесь к администратору вашего сервера Jabber."
waitforlogin = u"Сообщение пока не может быть доставлено. Подождите, пока служба выполнит регистрацию."
gatewaytranslator = u"Введите номер ICQ пользователя."
- # added by Oleg Motienko (motienko@gmail.com)
- sessionnotactive = u"?~Rа?~Hа ICQ ?~Aе?~A?~Aи?~O ?~Aей???~A не ак?~Bивна."
+ sessionnotactive = u"Ваша сессия ICQ в данный момент неактивна."
diff -Naur src2-1/legacy/icqt.py src2-2/legacy/icqt.py
--- src2-1/legacy/icqt.py 2007-12-19 14:40:54.000000000 +0200
+++ src2-2/legacy/icqt.py 2008-01-15 16:29:16.000000000 +0200
@@ -234,7 +234,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))
@@ -257,7 +257,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:
@@ -339,7 +339,8 @@
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:
@@ -365,7 +366,7 @@
except:
pass
try:
- status1 = status.encode('cp1250', 'strict')
+ status1 = status.encode(config.encoding, 'strict')
status = status1.decode('utf-8', 'strict')
except:
if ord(status[0]) == 0 and ord(status[len(status)-1]) == 0:
@@ -374,13 +375,14 @@
status = str(status).decode('utf-8', 'strict')
except:
try:
- status = str(status).decode('iso-8859-2', 'strict')
+ status = str(status).decode(config.encoding, 'strict')
except:
status = "Status decoding failed: " + status
try:
utfmsg = unicode(msg[0], errors='replace')
except:
utfmsg = msg[0]
+ status = oscar.dehtml(status)
LogEvent(INFO, self.session.jabberID, "Away (%s, %s) message %s" % (charset, utfmsg, status))

if status == "Away" or status=="I am currently away from the computer." or status=="I am away from my computer right now.":
diff -Naur src2-1/main.py src2-2/main.py
--- src2-1/main.py 2008-01-08 09:59:58.000000000 +0200
+++ src2-2/main.py 2007-12-21 19:35:37.000000000 +0200
@@ -22,9 +22,6 @@
print "Unable to find a reactor.\nExiting..."
sys.exit(1)

-import twistfix
-twistfix.main()
-
if __name__ == "__main__":
print "The transport can no longer be started from main.py. Please use"
print "PyICQt.py from the root of the distribution instead."
@@ -140,7 +137,7 @@
import lang
import globals

-
+startTime = int(time.time())

class PyTransport(component.Service):
routewrap = 0
@@ -179,7 +176,7 @@
self.loadPlugins("src/legacy/services")

# Misc tracking variables
- self.startTime = int(time.time())
+# self.startTime = int(time.time())
self.xmlstream = None
self.sessions = {}
# Message IDs
@@ -220,7 +217,7 @@
def loopFunc(self):
numsessions = len(self.sessions)

- self.serviceplugins['Statistics'].stats["Uptime"] = int(time.time()) - self.startTime
+ self.serviceplugins['Statistics'].stats["Uptime"] = int(time.time()) - startTime
if numsessions > 0:
oldDict = self.sessions.copy()
self.sessions = {}
@@ -444,13 +441,4 @@

def main():
app = App()
- if config.webport:
- try:
- from nevow import appserver
- import web
- site = appserver.NevowSite(web.WebInterface(pytrans=app.transportSvc))
- reactor.listenTCP(config.webport, site)
- LogEvent(INFO, msg="Web interface activated")
- except:
- LogEvent(WARN, msg="Unable to start web interface. Either Nevow is not installed or you need a more recent version of Twisted. (>= 2.0.0.0)")
reactor.run()
diff -Naur src2-1/services/LastActivity.py src2-2/services/LastActivity.py
--- src2-1/services/LastActivity.py 2007-12-19 14:40:52.000000000 +0200
+++ src2-2/services/LastActivity.py 2007-12-21 19:26:25.000000000 +0200
@@ -1,7 +1,7 @@
# Copyright 2004-2006 Daniel Henninger <jadestorm@nc.rr.com>
# Licensed for distribution under the GPL version 2, check COPYING for details

-import utils
+import utils, time, main
from twisted.words.xish.domish import Element
import config
from debug import LogEvent, INFO, WARN, ERROR
@@ -29,6 +29,6 @@
iq.attributes["id"] = el.getAttribute("id")
query = iq.addElement("query")
query.attributes["xmlns"] = globals.IQLAST
- query.attributes["seconds"] = "0"
+ query.attributes["seconds"] = str(int(time.time()) - main.startTime)

self.pytrans.send(iq)
diff -Naur src2-1/services/VersionTeller.py src2-2/services/VersionTeller.py
--- src2-1/services/VersionTeller.py 2007-12-19 14:40:52.000000000 +0200
+++ src2-2/services/VersionTeller.py 2008-01-15 16:30:22.000000000 +0200
@@ -17,7 +17,7 @@
self.pytrans.disco.addFeature(globals.IQVERSION, self.incomingIq, config.jid)
self.pytrans.disco.addFeature(globals.IQVERSION, self.incomingIq, "USER")
try:
- self.version = "%s - SVN r%s" % (legacy.version, svninfo.getSVNVersion())
+ self.version = "%s - SVN r%s + patchcyr-20080115" % (legacy.version, svninfo.getSVNVersion())
except:
self.version = legacy.version
self.os = "Python " + sys.version.split(' ')[0] + "/" + sys.platform + ", Twisted " + twisted.copyright.version
diff -Naur src2-1/tlib/oscar.py src2-2/tlib/oscar.py
--- src2-1/tlib/oscar.py 2007-12-19 14:40:53.000000000 +0200
+++ src2-2/tlib/oscar.py 2008-01-14 11:36:40.000000000 +0200
@@ -200,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.
@@ -1645,12 +1645,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 ]
@@ -1661,7 +1661,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'
Powered by Google Project Hosting