Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
35412535
Commit
35412535
authored
18 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
[sgala] add some xmpp functions for xhtml-im support. see #316
parent
ee508248
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/xmpp/protocol.py
+13
-2
13 additions, 2 deletions
src/common/xmpp/protocol.py
with
13 additions
and
2 deletions
src/common/xmpp/protocol.py
+
13
−
2
View file @
35412535
...
@@ -19,7 +19,7 @@ Protocol module contains tools that is needed for processing of
...
@@ -19,7 +19,7 @@ Protocol module contains tools that is needed for processing of
xmpp-related data structures.
xmpp-related data structures.
"""
"""
from
simplexml
import
Node
,
ustr
from
simplexml
import
Node
,
NodeBuilder
,
ustr
import
time
import
time
NS_ACTIVITY
=
'
http://jabber.org/protocol/activity
'
# JEP-0108
NS_ACTIVITY
=
'
http://jabber.org/protocol/activity
'
# JEP-0108
NS_ADDRESS
=
'
http://jabber.org/protocol/address
'
# JEP-0033
NS_ADDRESS
=
'
http://jabber.org/protocol/address
'
# JEP-0033
...
@@ -94,6 +94,7 @@ NS_VCARD_UPDATE =NS_VCARD+':x:update'
...
@@ -94,6 +94,7 @@ NS_VCARD_UPDATE =NS_VCARD+':x:update'
NS_VERSION
=
'
jabber:iq:version
'
NS_VERSION
=
'
jabber:iq:version
'
NS_WAITINGLIST
=
'
http://jabber.org/protocol/waitinglist
'
# JEP-0130
NS_WAITINGLIST
=
'
http://jabber.org/protocol/waitinglist
'
# JEP-0130
NS_XHTML_IM
=
'
http://jabber.org/protocol/xhtml-im
'
# JEP-0071
NS_XHTML_IM
=
'
http://jabber.org/protocol/xhtml-im
'
# JEP-0071
NS_XHTML
=
'
http://www.w3.org/1999/xhtml
'
# "
NS_DATA_LAYOUT
=
'
http://jabber.org/protocol/xdata-layout
'
# JEP-0141
NS_DATA_LAYOUT
=
'
http://jabber.org/protocol/xdata-layout
'
# JEP-0141
NS_DATA_VALIDATE
=
'
http://jabber.org/protocol/xdata-validate
'
# JEP-0122
NS_DATA_VALIDATE
=
'
http://jabber.org/protocol/xdata-validate
'
# JEP-0122
NS_XMPP_STREAMS
=
'
urn:ietf:params:xml:ns:xmpp-streams
'
NS_XMPP_STREAMS
=
'
urn:ietf:params:xml:ns:xmpp-streams
'
...
@@ -385,16 +386,21 @@ class Protocol(Node):
...
@@ -385,16 +386,21 @@ class Protocol(Node):
class
Message
(
Protocol
):
class
Message
(
Protocol
):
"""
XMPP Message stanza -
"
push
"
mechanism.
"""
"""
XMPP Message stanza -
"
push
"
mechanism.
"""
def
__init__
(
self
,
to
=
None
,
body
=
None
,
typ
=
None
,
subject
=
None
,
attrs
=
{},
frm
=
None
,
payload
=
[],
timestamp
=
None
,
xmlns
=
NS_CLIENT
,
node
=
None
):
def
__init__
(
self
,
to
=
None
,
body
=
None
,
xhtml
=
None
,
typ
=
None
,
subject
=
None
,
attrs
=
{},
frm
=
None
,
payload
=
[],
timestamp
=
None
,
xmlns
=
NS_CLIENT
,
node
=
None
):
"""
Create message object. You can specify recipient, text of message, type of message
"""
Create message object. You can specify recipient, text of message, type of message
any additional attributes, sender of the message, any additional payload (f.e. jabber:x:delay element) and namespace in one go.
any additional attributes, sender of the message, any additional payload (f.e. jabber:x:delay element) and namespace in one go.
Alternatively you can pass in the other XML object as the
'
node
'
parameted to replicate it as message.
"""
Alternatively you can pass in the other XML object as the
'
node
'
parameted to replicate it as message.
"""
Protocol
.
__init__
(
self
,
'
message
'
,
to
=
to
,
typ
=
typ
,
attrs
=
attrs
,
frm
=
frm
,
payload
=
payload
,
timestamp
=
timestamp
,
xmlns
=
xmlns
,
node
=
node
)
Protocol
.
__init__
(
self
,
'
message
'
,
to
=
to
,
typ
=
typ
,
attrs
=
attrs
,
frm
=
frm
,
payload
=
payload
,
timestamp
=
timestamp
,
xmlns
=
xmlns
,
node
=
node
)
if
body
:
self
.
setBody
(
body
)
if
body
:
self
.
setBody
(
body
)
if
xhtml
:
self
.
setXHTML
(
xhtml
)
if
subject
:
self
.
setSubject
(
subject
)
if
subject
:
self
.
setSubject
(
subject
)
def
getBody
(
self
):
def
getBody
(
self
):
"""
Returns text of the message.
"""
"""
Returns text of the message.
"""
return
self
.
getTagData
(
'
body
'
)
return
self
.
getTagData
(
'
body
'
)
def
getXHTML
(
self
):
"""
Returns serialized xhtml-im body text of the message.
"""
xhtml
=
self
.
getTag
(
'
xhtml
'
)
return
str
(
xhtml
.
getTag
(
'
body
'
))
def
getSubject
(
self
):
def
getSubject
(
self
):
"""
Returns subject of the message.
"""
"""
Returns subject of the message.
"""
return
self
.
getTagData
(
'
subject
'
)
return
self
.
getTagData
(
'
subject
'
)
...
@@ -404,6 +410,11 @@ class Message(Protocol):
...
@@ -404,6 +410,11 @@ class Message(Protocol):
def
setBody
(
self
,
val
):
def
setBody
(
self
,
val
):
"""
Sets the text of the message.
"""
"""
Sets the text of the message.
"""
self
.
setTagData
(
'
body
'
,
val
)
self
.
setTagData
(
'
body
'
,
val
)
def
setXHTML
(
self
,
val
):
"""
Sets the xhtml text of the message (JEP-0071).
The parameter is the
"
inner html
"
to the body.
"""
dom
=
NodeBuilder
(
val
)
self
.
setTag
(
'
html
'
,
namespace
=
NS_XHTML_IM
).
setTag
(
'
body
'
,
namespace
=
NS_XHTML
).
addChild
(
node
=
dom
.
getDom
())
def
setSubject
(
self
,
val
):
def
setSubject
(
self
,
val
):
"""
Sets the subject of the message.
"""
"""
Sets the subject of the message.
"""
self
.
setTagData
(
'
subject
'
,
val
)
self
.
setTagData
(
'
subject
'
,
val
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment