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
97b75de3
Commit
97b75de3
authored
19 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
split NOTIFY event into NOTIFY and GC_NOTIFY
parent
619ffb95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/connection.py
+71
-56
71 additions, 56 deletions
src/common/connection.py
src/gajim.py
+19
-13
19 additions, 13 deletions
src/gajim.py
with
90 additions
and
69 deletions
src/common/connection.py
+
71
−
56
View file @
97b75de3
...
...
@@ -330,25 +330,22 @@ class Connection:
def
_presenceCB
(
self
,
con
,
prs
):
"""
Called when we receive a presence
"""
who
=
unicode
(
prs
.
getFrom
())
prio
=
prs
.
getPriority
()
if
not
prio
:
prio
=
0
ptype
=
prs
.
getType
()
if
ptype
==
'
available
'
:
ptype
=
None
gajim
.
log
.
debug
(
'
PresenceCB: %s
'
%
ptype
)
xtags
=
prs
.
getTags
(
'
x
'
)
is_gc
=
False
# is it a GC presence ?
sigTag
=
None
keyID
=
''
status
=
prs
.
getStatus
()
for
xtag
in
xtags
:
if
xtag
.
getNamespace
()
==
common
.
xmpp
.
NS_SIGNED
:
xtags
=
prs
.
getTags
(
'
x
'
)
for
x
in
xtags
:
if
x
.
getNamespace
()
==
common
.
xmpp
.
NS_MUC_USER
:
is_gc
=
True
if
x
.
getNamespace
()
==
common
.
xmpp
.
NS_SIGNED
:
sigTag
=
xtag
break
if
sigTag
and
USE_GPG
:
#verify
sigmsg
=
sigTag
.
getData
()
keyID
=
self
.
gpg
.
verify
(
status
,
sigmsg
)
jid_from
=
prs
.
getFrom
()
who
=
unicode
(
jid_from
)
jid_stripped
=
jid_from
.
getStripped
()
resource
=
jid_from
.
getResource
()
status
=
prs
.
getStatus
(
)
show
=
prs
.
getShow
()
if
not
show
in
STATUS_LIST
:
show
=
''
# We ignore unknown show
...
...
@@ -356,7 +353,57 @@ class Connection:
show
=
'
online
'
elif
ptype
==
'
unavailable
'
:
show
=
'
offline
'
elif
ptype
==
'
subscribe
'
:
if
is_gc
:
if
ptype
==
'
error
'
:
errmsg
=
prs
.
getError
()
errcode
=
prs
.
getErrorCode
()
if
errcode
==
'
502
'
:
# Internal Timeout:
self
.
dispatch
(
'
NOTIFY
'
,
(
jid_stripped
,
'
error
'
,
errmsg
,
resource
,
prio
,
keyID
))
elif
errcode
==
'
401
'
:
# password required to join
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
A password is required to join this room.
'
)))
elif
errcode
==
'
403
'
:
# we are banned
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
You are banned from this room.
'
)))
elif
errcode
==
'
404
'
:
# room does not exist
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
Such room does not exist.
'
)))
elif
errcode
==
'
405
'
:
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
Room creation is restricted.
'
)))
elif
errcode
==
'
406
'
:
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
Your registered nickname must be used.
'
)))
elif
errcode
==
'
407
'
:
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
You are not in the members list.
'
)))
elif
errcode
==
'
409
'
:
# nick conflict
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
Your desired nickname is in use or registered by another user.
'
)))
else
:
# print in the window the error
self
.
dispatch
(
'
ERROR_ANSWER
'
,
(
''
,
jid_stripped
,
errmsg
,
errcode
))
if
not
ptype
or
ptype
==
'
unavailable
'
:
gajim
.
logger
.
write
(
'
status
'
,
status
,
who
,
show
)
self
.
dispatch
(
'
GC_NOTIFY
'
,
(
jid_stripped
,
show
,
status
,
resource
,
prs
.
getRole
(),
prs
.
getAffiliation
(),
prs
.
getJid
(),
prs
.
getReason
(),
prs
.
getActor
(),
prs
.
getStatusCode
(),
prs
.
getNewNick
()))
return
prio
=
prs
.
getPriority
()
try
:
prio
=
int
(
prio
)
except
:
prio
=
0
keyID
=
''
if
sigTag
and
USE_GPG
:
#verify
sigmsg
=
sigTag
.
getData
()
keyID
=
self
.
gpg
.
verify
(
status
,
sigmsg
)
if
ptype
==
'
subscribe
'
:
gajim
.
log
.
debug
(
'
subscribe request from %s
'
%
who
)
if
gajim
.
config
.
get
(
'
alwaysauth
'
)
or
who
.
find
(
"
@
"
)
<=
0
:
if
self
.
connection
:
...
...
@@ -365,65 +412,33 @@ class Connection:
self
.
to_be_sent
.
append
(
p
)
if
who
.
find
(
"
@
"
)
<=
0
:
self
.
dispatch
(
'
NOTIFY
'
,
(
prs
.
getFrom
().
getStripped
(),
'
offline
'
,
'
offline
'
,
prs
.
getFrom
().
getResource
(),
prio
,
keyID
,
None
,
None
,
None
,
None
,
None
,
None
))
(
jid_stripped
,
'
offline
'
,
'
offline
'
,
resource
,
prio
,
keyID
))
else
:
if
not
status
:
status
=
_
(
'
I would like to add you to my roster.
'
)
self
.
dispatch
(
'
SUBSCRIBE
'
,
(
who
,
status
))
elif
ptype
==
'
subscribed
'
:
jid
=
prs
.
getFrom
()
self
.
dispatch
(
'
SUBSCRIBED
'
,
(
jid
.
getStripped
(),
jid
.
getResource
()))
self
.
dispatch
(
'
SUBSCRIBED
'
,
(
jid_stripped
,
resource
))
# BE CAREFUL: no con.updateRosterItem() in a callback
gajim
.
log
.
debug
(
_
(
'
we are now subscribed to %s
'
)
%
who
)
elif
ptype
==
'
unsubscribe
'
:
gajim
.
log
.
debug
(
_
(
'
unsubscribe request from %s
'
)
%
who
)
elif
ptype
==
'
unsubscribed
'
:
gajim
.
log
.
debug
(
_
(
'
we are now unsubscribed from %s
'
)
%
who
)
self
.
dispatch
(
'
UNSUBSCRIBED
'
,
prs
.
getFrom
().
getS
tripped
()
)
self
.
dispatch
(
'
UNSUBSCRIBED
'
,
jid_s
tripped
)
elif
ptype
==
'
error
'
:
errmsg
=
prs
.
getError
()
errcode
=
prs
.
getErrorCode
()
if
errcode
==
'
502
'
:
# Internal Timeout:
self
.
dispatch
(
'
NOTIFY
'
,
(
prs
.
getFrom
().
getStripped
(),
'
error
'
,
errmsg
,
prs
.
getFrom
().
getResource
(),
prio
,
keyID
,
prs
.
getRole
(),
prs
.
getAffiliation
(),
prs
.
getJid
(),
prs
.
getReason
(),
prs
.
getActor
(),
prs
.
getStatusCode
(),
prs
.
getNewNick
()))
elif
errcode
==
'
401
'
:
# password required to join
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
A password is required to join this room.
'
)))
elif
errcode
==
'
403
'
:
# we are banned
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
You are banned from this room.
'
)))
elif
errcode
==
'
404
'
:
# room does not exist
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
Such room does not exist.
'
)))
elif
errcode
==
'
405
'
:
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
Room creation is restricted.
'
)))
elif
errcode
==
'
406
'
:
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
Your registered nickname must be used.
'
)))
elif
errcode
==
'
407
'
:
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
You are not in the members list.
'
)))
elif
errcode
==
'
409
'
:
# nick conflict
self
.
dispatch
(
'
ERROR
'
,
(
_
(
'
Unable to join room
'
),
_
(
'
Your desired nickname is in use or registered by another user.
'
)))
self
.
dispatch
(
'
NOTIFY
'
,
(
jid_stripped
,
'
error
'
,
errmsg
,
resource
,
prio
,
keyID
))
else
:
# print in the window the error
self
.
dispatch
(
'
ERROR_ANSWER
'
,
(
''
,
prs
.
getFrom
().
getS
tripped
()
,
self
.
dispatch
(
'
ERROR_ANSWER
'
,
(
''
,
jid_s
tripped
,
errmsg
,
errcode
))
if
not
ptype
or
ptype
==
'
unavailable
'
:
jid
=
unicode
(
prs
.
getFrom
())
gajim
.
logger
.
write
(
'
status
'
,
status
,
jid
,
show
)
account
=
prs
.
getFrom
().
getStripped
()
resource
=
prs
.
getFrom
().
getResource
()
self
.
dispatch
(
'
NOTIFY
'
,
(
account
,
show
,
status
,
resource
,
prio
,
keyID
,
prs
.
getRole
(),
prs
.
getAffiliation
(),
prs
.
getJid
(),
prs
.
getReason
(),
prs
.
getActor
(),
prs
.
getStatusCode
(),
prs
.
getNewNick
()))
gajim
.
logger
.
write
(
'
status
'
,
status
,
jid_stripped
,
show
)
self
.
dispatch
(
'
NOTIFY
'
,
(
jid_stripped
,
show
,
status
,
resource
,
prio
,
keyID
))
# END presenceCB
def
_disconnectedCB
(
self
):
...
...
This diff is collapsed.
Click to expand it.
src/gajim.py
+
19
−
13
View file @
97b75de3
...
...
@@ -163,6 +163,7 @@ class Interface:
gajim
.
connections
[
account
].
build_http_auth_answer
(
data
[
2
],
answer
)
def
handle_event_error_answer
(
self
,
account
,
array
):
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
id
,
jid_from
,
errmsg
,
errcode
=
array
if
unicode
(
errcode
)
in
[
'
403
'
,
'
406
'
]
and
id
:
# show the error dialog
...
...
@@ -189,7 +190,6 @@ class Interface:
(
jid_from
,
file_props
))
conn
.
disconnect_transfer
(
file_props
)
return
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
if
jid_from
in
self
.
windows
[
account
][
'
gc
'
]:
self
.
windows
[
account
][
'
gc
'
][
jid_from
].
print_conversation
(
'
Error %s: %s
'
%
(
array
[
2
],
array
[
1
]),
jid_from
)
...
...
@@ -216,8 +216,7 @@ class Interface:
self
.
remote
.
raise_signal
(
'
AccountPresence
'
,
(
status
,
account
))
def
handle_event_notify
(
self
,
account
,
array
):
#('NOTIFY', account, (jid, status, message, resource, priority, keyID,
# role, affiliation, real_jid, reason, actor, statusCode, new_nick))
#('NOTIFY', account, (jid, status, message, resource, priority, keyID))
# if we're here it means contact changed show
statuss
=
[
'
offline
'
,
'
error
'
,
'
online
'
,
'
chat
'
,
'
away
'
,
'
xa
'
,
'
dnd
'
,
'
invisible
'
]
...
...
@@ -347,16 +346,6 @@ class Interface:
if
self
.
remote
and
self
.
remote
.
is_enabled
():
self
.
remote
.
raise_signal
(
'
ContactAbsence
'
,
(
account
,
array
))
# stop non active file transfers
elif
self
.
windows
[
account
][
'
gc
'
].
has_key
(
ji
):
# ji is then room_jid
#it is a groupchat presence
#FIXME: upgrade the chat instances (for pm)
#FIXME: real_jid can be None
self
.
windows
[
account
][
'
gc
'
][
ji
].
chg_contact_status
(
ji
,
resource
,
array
[
1
],
array
[
2
],
array
[
6
],
array
[
7
],
array
[
8
],
array
[
9
],
array
[
10
],
array
[
11
],
array
[
12
],
account
)
if
self
.
remote
and
self
.
remote
.
is_enabled
():
self
.
remote
.
raise_signal
(
'
GCPresence
'
,
(
account
,
array
))
def
handle_event_msg
(
self
,
account
,
array
):
#('MSG', account, (jid, msg, time, encrypted, msg_type, subject, chatstate))
...
...
@@ -637,6 +626,22 @@ class Interface:
if
self
.
remote
and
self
.
remote
.
is_enabled
():
self
.
remote
.
raise_signal
(
'
OsInfo
'
,
(
account
,
array
))
def
handle_event_gc_notify
(
self
,
account
,
array
):
#('GC_NOTIFY', account, (jid, status, message, resource,
# role, affiliation, jid, reason, actor, statusCode, newNick))
jid
=
array
[
0
].
split
(
'
/
'
)[
0
]
resource
=
array
[
3
]
if
not
resource
:
resource
=
''
if
self
.
windows
[
account
][
'
gc
'
].
has_key
(
jid
):
# ji is then room_jid
#FIXME: upgrade the chat instances (for pm)
#FIXME: real_jid can be None
self
.
windows
[
account
][
'
gc
'
][
jid
].
chg_contact_status
(
jid
,
resource
,
array
[
1
],
array
[
2
],
array
[
4
],
array
[
5
],
array
[
6
],
array
[
7
],
array
[
8
],
array
[
9
],
array
[
10
],
account
)
if
self
.
remote
and
self
.
remote
.
is_enabled
():
self
.
remote
.
raise_signal
(
'
GCPresence
'
,
(
account
,
array
))
def
handle_event_gc_msg
(
self
,
account
,
array
):
#('GC_MSG', account, (jid, msg, time))
jids
=
array
[
0
].
split
(
'
/
'
,
1
)
...
...
@@ -999,6 +1004,7 @@ class Interface:
'
MYVCARD
'
:
self
.
handle_event_myvcard
,
'
VCARD
'
:
self
.
handle_event_vcard
,
'
OS_INFO
'
:
self
.
handle_event_os_info
,
'
GC_NOTIFY
'
:
self
.
handle_event_gc_notify
,
'
GC_MSG
'
:
self
.
handle_event_gc_msg
,
'
GC_SUBJECT
'
:
self
.
handle_event_gc_subject
,
'
GC_CONFIG
'
:
self
.
handle_event_gc_config
,
...
...
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