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
l-n-s
gajim
Commits
c16544c0
Commit
c16544c0
authored
20 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
some cleanup ni jabber.py
parent
446dcc49
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
common/jabber.py
+19
-23
19 additions, 23 deletions
common/jabber.py
with
19 additions
and
23 deletions
common/jabber.py
+
19
−
23
View file @
c16544c0
...
...
@@ -66,6 +66,7 @@ An example of usage for a simple client would be ( only psuedo code !)
import
xmlstream
import
sha
,
time
import
string
debug
=
xmlstream
.
debug
...
...
@@ -277,7 +278,7 @@ class Connection(xmlstream.Client):
if
not
self
.
handlers
[
name
].
has_key
(
ns
):
ns
=
''
if
not
self
.
handlers
[
name
].
has_key
(
typ
):
typ
=
''
if
not
self
.
handlers
[
name
].
has_key
(
typns
):
typns
=
''
if
typ
==
typns
:
typns
=
''
if
typ
==
typns
:
typns
=
''
# we don't want to launch twice the same handler
chain
=
[]
for
key
in
[
'
default
'
,
typ
,
ns
,
typns
]:
# we will use all handlers: from very common to very particular
...
...
@@ -433,10 +434,13 @@ class Client(Connection):
self
.
send
(
Presence
(
type
=
'
unavailable
'
))
xmlstream
.
Client
.
disconnect
(
self
)
def
sendPresence
(
self
,
type
=
None
,
priority
=
None
,
show
=
None
,
status
=
None
):
def
sendPresence
(
self
,
type
=
None
,
priority
=
None
,
show
=
None
,
status
=
None
,
signedStatus
=
None
):
"""
Sends a presence protocol element to the server.
Used to inform the server that you are online
"""
self
.
send
(
Presence
(
type
=
type
,
priority
=
priority
,
show
=
show
,
status
=
status
))
presence
=
Presence
(
type
=
type
,
priority
=
priority
,
show
=
show
,
status
=
status
)
if
signedStatus
:
presence
.
setX
(
NS_XSIGNED
).
insertData
(
signedStatus
)
self
.
send
(
presence
)
sendInitPresence
=
sendPresence
...
...
@@ -612,12 +616,12 @@ class Client(Connection):
def
requestRegInfo
(
self
,
agent
=
''
):
"""
Requests registration info from the server.
Returns the Iq object received from the server.
"""
# if agent: agent = agent + '.'
if
string
.
find
(
agent
,
self
.
_host
)
==
-
1
:
if
agent
:
agent
=
agent
+
'
.
'
agent
=
+
self
.
_host
self
.
_reg_info
=
{}
# reg_iq = Iq(type='get', to = agent + self._host)
reg_iq
=
Iq
(
type
=
'
get
'
,
to
=
agent
)
reg_iq
.
setQuery
(
NS_REGISTER
)
# self.DEBUG("Requesting reg info from %s%s:" % (agent, self._host), DBG_NODE_IQ)
self
.
DEBUG
(
"
Requesting reg info from %s:
"
%
agent
,
DBG_NODE_IQ
)
self
.
DEBUG
(
ustr
(
reg_iq
),
DBG_NODE_IQ
)
return
self
.
SendAndWaitForResponse
(
reg_iq
)
...
...
@@ -637,11 +641,11 @@ class Client(Connection):
self
.
_reg_info
[
key
]
=
val
def
sendRegInfo
(
self
,
agent
=
None
):
def
sendRegInfo
(
self
,
agent
=
''
):
"""
Sends the populated registration dictionary back to the server
"""
#
if
agent: agent = agent + '.'
if
agent
is
None
:
agent
=
''
#
reg_iq = Iq(to
= agent + self._host
, type='set')
if
string
.
find
(
agent
,
self
.
_host
)
==
-
1
:
if
agent
:
agent
=
agent
+
'
.
'
agent
=
agent
+
self
.
_host
reg_iq
=
Iq
(
to
=
agent
,
type
=
'
set
'
)
q
=
reg_iq
.
setQuery
(
NS_REGISTER
)
for
info
in
self
.
_reg_info
.
keys
():
...
...
@@ -649,22 +653,21 @@ class Client(Connection):
return
self
.
SendAndWaitForResponse
(
reg_iq
)
def
deregister
(
self
,
agent
=
None
):
def
deregister
(
self
,
agent
=
''
):
"""
Send off a request to deregister with the server or with the given
agent. Returns True if successful, else False.
Note that you must be authorised before attempting to deregister.
"""
if
agent
:
#
agent = agent + '.'
#
self.send(Presence(to=agent+self._host,type='unsubscribed')) # This is enough f.e. for icqv7t or ji
t
if
string
.
find
(
agent
,
self
.
_host
)
==
-
1
:
agent
=
agent
+
'
.
'
+
self
.
_hos
t
self
.
send
(
Presence
(
to
=
agent
,
type
=
'
unsubscribed
'
))
# This is enough f.e. for icqv7t or jit
if
agent
is
Non
e
:
agent
=
''
els
e
:
agent
=
self
.
_host
q
=
self
.
requestRegInfo
()
kids
=
q
.
getQueryPayload
()
keyTag
=
kids
.
getTag
(
"
key
"
)
# iq = Iq(to=agent+self._host, type="set")
iq
=
Iq
(
to
=
agent
,
type
=
"
set
"
)
iq
.
setQuery
(
NS_REGISTER
)
iq
.
setQueryNode
(
""
)
...
...
@@ -731,12 +734,9 @@ class Client(Connection):
if
not
rep
:
return
identities
,
features
,
items
q
=
rep
.
getTag
(
'
service
'
)
if
q
:
identities
=
[
q
.
attrs
]
else
:
identities
=
[]
if
not
q
:
return
identities
,
features
,
items
identities
=
[
q
.
attrs
]
for
node
in
q
.
kids
:
if
node
.
getName
()
==
'
ns
'
:
features
.
append
(
node
.
getData
())
...
...
@@ -1442,10 +1442,6 @@ class JID:
__repr__
=
__str__
def
getBasic
(
self
):
"""
Returns a jid string with no resource
"""
return
self
.
node
+
'
@
'
+
self
.
domain
def
getNode
(
self
):
"""
Returns JID Node as string
"""
return
self
.
node
...
...
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