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
Weblate
gajim
Commits
12bb7205
Commit
12bb7205
authored
17 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
ability to forward unread messages through adhoc commands. fixes #1910
parent
7abaabc4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/commands.py
+31
-1
31 additions, 1 deletion
src/common/commands.py
src/common/connection.py
+21
-15
21 additions, 15 deletions
src/common/connection.py
src/common/connection_handlers.py
+6
-0
6 additions, 0 deletions
src/common/connection_handlers.py
with
58 additions
and
16 deletions
src/common/commands.py
+
31
−
1
View file @
12bb7205
...
@@ -236,12 +236,42 @@ class LeaveGroupchatsCommand(AdHocCommand):
...
@@ -236,12 +236,42 @@ class LeaveGroupchatsCommand(AdHocCommand):
return
False
return
False
class
ForwardMessagesCommand
(
AdHocCommand
):
# http://www.xmpp.org/extensions/xep-0146.html#forward
commandnode
=
'
forward-messages
'
commandname
=
_
(
'
Forward unread messages
'
)
@staticmethod
def
isVisibleFor
(
samejid
):
'''
Change status is visible only if the entity has the same bare jid.
'''
return
samejid
def
execute
(
self
,
request
):
account
=
self
.
connection
.
name
# Forward messages
events
=
gajim
.
events
.
get_events
(
account
,
types
=
[
'
chat
'
,
'
normal
'
])
j
,
resource
=
gajim
.
get_room_and_nick_from_fjid
(
self
.
jid
)
for
jid
in
events
:
for
event
in
events
[
jid
]:
self
.
connection
.
send_message
(
j
,
event
.
parameters
[
0
],
''
,
type
=
event
.
type_
,
subject
=
event
.
parameters
[
1
],
resource
=
resource
,
forward_from
=
jid
)
# Inform other client of completion
response
,
cmd
=
self
.
buildResponse
(
request
,
status
=
'
completed
'
)
cmd
.
addChild
(
'
note
'
,
{},
_
(
'
All unread messages have been forwarded.
'
))
self
.
connection
.
connection
.
send
(
response
)
return
False
# finish the session
class
ConnectionCommands
:
class
ConnectionCommands
:
'''
This class depends on that it is a part of Connection() class.
'''
'''
This class depends on that it is a part of Connection() class.
'''
def
__init__
(
self
):
def
__init__
(
self
):
# a list of all commands exposed: node -> command class
# a list of all commands exposed: node -> command class
self
.
__commands
=
{}
self
.
__commands
=
{}
for
cmdobj
in
(
ChangeStatusCommand
,
LeaveGroupchatsCommand
):
for
cmdobj
in
(
ChangeStatusCommand
,
ForwardMessagesCommand
,
LeaveGroupchatsCommand
):
self
.
__commands
[
cmdobj
.
commandnode
]
=
cmdobj
self
.
__commands
[
cmdobj
.
commandnode
]
=
cmdobj
# a list of sessions; keys are tuples (jid, sessionid, node)
# a list of sessions; keys are tuples (jid, sessionid, node)
...
...
This diff is collapsed.
Click to expand it.
src/common/connection.py
+
21
−
15
View file @
12bb7205
...
@@ -808,7 +808,7 @@ class Connection(ConnectionHandlers):
...
@@ -808,7 +808,7 @@ class Connection(ConnectionHandlers):
def
send_message
(
self
,
jid
,
msg
,
keyID
,
type
=
'
chat
'
,
subject
=
''
,
def
send_message
(
self
,
jid
,
msg
,
keyID
,
type
=
'
chat
'
,
subject
=
''
,
chatstate
=
None
,
msg_id
=
None
,
composing_xep
=
None
,
resource
=
None
,
chatstate
=
None
,
msg_id
=
None
,
composing_xep
=
None
,
resource
=
None
,
user_nick
=
None
,
xhtml
=
None
):
user_nick
=
None
,
xhtml
=
None
,
forward_from
=
None
):
if
not
self
.
connection
:
if
not
self
.
connection
:
return
1
return
1
if
msg
and
not
xhtml
and
gajim
.
config
.
get
(
'
rst_formatting_outgoing_messages
'
):
if
msg
and
not
xhtml
and
gajim
.
config
.
get
(
'
rst_formatting_outgoing_messages
'
):
...
@@ -877,21 +877,27 @@ class Connection(ConnectionHandlers):
...
@@ -877,21 +877,27 @@ class Connection(ConnectionHandlers):
if
chatstate
is
'
composing
'
or
msgtxt
:
if
chatstate
is
'
composing
'
or
msgtxt
:
chatstate_node
.
addChild
(
name
=
'
composing
'
)
chatstate_node
.
addChild
(
name
=
'
composing
'
)
if
forward_from
:
addresses
=
msg_iq
.
addChild
(
'
addresses
'
,
namespace
=
common
.
xmpp
.
NS_ADDRESS
)
addresses
.
addChild
(
'
address
'
,
attrs
=
{
'
type
'
:
'
ofrom
'
,
'
jid
'
:
forward_from
})
self
.
connection
.
send
(
msg_iq
)
self
.
connection
.
send
(
msg_iq
)
no_log_for
=
gajim
.
config
.
get_per
(
'
accounts
'
,
self
.
name
,
'
no_log_for
'
)
\
if
not
forward_from
:
.
split
()
no_log_for
=
gajim
.
config
.
get_per
(
'
accounts
'
,
self
.
name
,
'
no_log_for
'
)
\
ji
=
gajim
.
get_jid_without_resource
(
jid
)
.
split
()
if
self
.
name
not
in
no_log_for
and
ji
not
in
no_log_for
:
ji
=
gajim
.
get_jid_without_resource
(
jid
)
log_msg
=
msg
if
self
.
name
not
in
no_log_for
and
ji
not
in
no_log_for
:
if
subject
:
log_msg
=
msg
log_msg
=
_
(
'
Subject: %s
\n
%s
'
)
%
(
subject
,
msg
)
if
subject
:
if
log_msg
:
log_msg
=
_
(
'
Subject: %s
\n
%s
'
)
%
(
subject
,
msg
)
if
type
==
'
chat
'
:
if
log_msg
:
kind
=
'
chat_msg_sent
'
if
type
==
'
chat
'
:
else
:
kind
=
'
chat_msg_sent
'
kind
=
'
single_msg_sent
'
else
:
gajim
.
logger
.
write
(
kind
,
jid
,
log_msg
)
kind
=
'
single_msg_sent
'
self
.
dispatch
(
'
MSGSENT
'
,
(
jid
,
msg
,
keyID
))
gajim
.
logger
.
write
(
kind
,
jid
,
log_msg
)
self
.
dispatch
(
'
MSGSENT
'
,
(
jid
,
msg
,
keyID
))
def
send_stanza
(
self
,
stanza
):
def
send_stanza
(
self
,
stanza
):
'''
send a stanza untouched
'''
'''
send a stanza untouched
'''
...
...
This diff is collapsed.
Click to expand it.
src/common/connection_handlers.py
+
6
−
0
View file @
12bb7205
...
@@ -1427,6 +1427,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
...
@@ -1427,6 +1427,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
tim
=
localtime
(
timegm
(
tim
))
tim
=
localtime
(
timegm
(
tim
))
frm
=
helpers
.
get_full_jid_from_iq
(
msg
)
frm
=
helpers
.
get_full_jid_from_iq
(
msg
)
jid
=
helpers
.
get_jid_from_iq
(
msg
)
jid
=
helpers
.
get_jid_from_iq
(
msg
)
addressTag
=
msg
.
getTag
(
'
addresses
'
,
namespace
=
common
.
xmpp
.
NS_ADDRESS
)
if
addressTag
:
address
=
addressTag
.
getTag
(
'
address
'
,
attrs
=
{
'
type
'
:
'
ofrom
'
})
if
address
:
frm
=
address
.
getAttr
(
'
jid
'
)
jid
=
gajim
.
get_jid_without_resource
(
frm
)
no_log_for
=
gajim
.
config
.
get_per
(
'
accounts
'
,
self
.
name
,
no_log_for
=
gajim
.
config
.
get_per
(
'
accounts
'
,
self
.
name
,
'
no_log_for
'
)
'
no_log_for
'
)
if
not
no_log_for
:
if
not
no_log_for
:
...
...
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