Lines 5-15
Link Here
|
5 |
from tlib.jabber import jid |
5 |
from tlib.jabber import jid |
6 |
import utils |
6 |
import utils |
7 |
import debug |
7 |
import debug |
|
|
8 |
import locale |
8 |
|
9 |
|
9 |
|
|
|
10 |
def sendMessage(pytrans, to, fro, body, mtype=None, errorType=None, delay=None): |
10 |
def sendMessage(pytrans, to, fro, body, mtype=None, errorType=None, delay=None): |
11 |
""" Sends a Jabber message """ |
11 |
""" Sends a Jabber message """ |
12 |
debug.log("jabw: Sending a Jabber message \"%s\" \"%s\" \"%s\" \"%s\"" % (to, fro, utils.latin1(body), mtype)) |
12 |
debug.log("jabw: Sending a Jabber message \"%s\" \"%s\" \"%s\" \"%s\"" % (to, fro, body, mtype)) |
13 |
el = Element((None, "message")) |
13 |
el = Element((None, "message")) |
14 |
el.attributes["to"] = to |
14 |
el.attributes["to"] = to |
15 |
el.attributes["from"] = fro |
15 |
el.attributes["from"] = fro |
Lines 33-39
Link Here
|
33 |
x.attributes["stamp"] = delay |
33 |
x.attributes["stamp"] = delay |
34 |
|
34 |
|
35 |
b = el.addElement("body") |
35 |
b = el.addElement("body") |
36 |
b.addContent(utils.utf8encode(body)) |
36 |
b.addContent(body) |
37 |
x = el.addElement("x") |
37 |
x = el.addElement("x") |
38 |
x.attributes["xmlns"] = "jabber:x:event" |
38 |
x.attributes["xmlns"] = "jabber:x:event" |
39 |
composing = x.addElement("composing") |
39 |
composing = x.addElement("composing") |
Lines 47-56
Link Here
|
47 |
el.attributes["type"] = ptype |
47 |
el.attributes["type"] = ptype |
48 |
if(show): |
48 |
if(show): |
49 |
s = el.addElement("show") |
49 |
s = el.addElement("show") |
50 |
s.addContent(utils.utf8encode(show)) |
50 |
s.addContent(show) |
51 |
if(status): |
51 |
if(status): |
52 |
s = el.addElement("status") |
52 |
s = el.addElement("status") |
53 |
s.addContent(utils.utf8encode(status)) |
53 |
s.addContent(status) |
54 |
if(priority): |
54 |
if(priority): |
55 |
s = el.addElement("priority") |
55 |
s = el.addElement("priority") |
56 |
s.addContent(priority) |
56 |
s.addContent(priority) |
Lines 121-127
Link Here
|
121 |
For this message to be an error, mtype="error", errorType=("modify", "bad-request", "Human readable descriptive text") - See XMPP Core (RFC3920) for more details |
121 |
For this message to be an error, mtype="error", errorType=("modify", "bad-request", "Human readable descriptive text") - See XMPP Core (RFC3920) for more details |
122 |
For this message to have a <x xmlns="jabber:x:delay"/> you must pass a correctly formatted timestamp (See JEP0091) |
122 |
For this message to have a <x xmlns="jabber:x:delay"/> you must pass a correctly formatted timestamp (See JEP0091) |
123 |
""" |
123 |
""" |
124 |
debug.log("User: %s - JabberConnection sending message \"%s\" \"%s\" \"%s\" \"%s\"" % (self.jabberID, to, fro, utils.latin1(body), mtype)) |
124 |
debug.log("User: %s - JabberConnection sending message \"%s\" \"%s\" \"%s\" \"%s\"" % (self.jabberID, to, fro, body, mtype)) |
125 |
sendMessage(self.pytrans, to, fro, body, mtype, errorType, delay) |
125 |
sendMessage(self.pytrans, to, fro, body, mtype, errorType, delay) |
126 |
|
126 |
|
127 |
def sendErrorMessage(self, to, fro, etype, eelement, econtent, body=None): |
127 |
def sendErrorMessage(self, to, fro, etype, eelement, econtent, body=None): |
Lines 194-203
Link Here
|
194 |
self.typingNotificationReceived(toj.userhost(), toj.resource, composing) |
194 |
self.typingNotificationReceived(toj.userhost(), toj.resource, composing) |
195 |
|
195 |
|
196 |
if(body): |
196 |
if(body): |
197 |
# body = utils.utf8(body) |
|
|
198 |
# Save the message ID for later |
197 |
# Save the message ID for later |
199 |
self.messageIDs[to] = mID |
198 |
self.messageIDs[to] = mID |
200 |
debug.log("User: %s - JabberConnection parsed message packet \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"" % (self.jabberID, froj.userhost(), to, froj.resource, mtype, utils.latin1(body))) |
199 |
debug.log("User: %s - JabberConnection parsed message packet \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"" % (self.jabberID, froj.userhost(), to, froj.resource, mtype, body)) |
201 |
self.messageReceived(froj.userhost(), froj.resource, toj.userhost(), toj.resource, mtype, body) |
200 |
self.messageReceived(froj.userhost(), froj.resource, toj.userhost(), toj.resource, mtype, body) |
202 |
|
201 |
|
203 |
def onPresence(self, el): |
202 |
def onPresence(self, el): |