Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
gajim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
194
Issues
194
List
Boards
Labels
Service Desk
Milestones
Merge Requests
20
Merge Requests
20
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim
Commits
4481b635
Commit
4481b635
authored
Jul 19, 2013
by
Dicson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle gc outgoing messages with events.
parent
a0f7501f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
4 deletions
+69
-4
src/common/connection.py
src/common/connection.py
+40
-0
src/common/connection_handlers_events.py
src/common/connection_handlers_events.py
+19
-0
src/groupchat_control.py
src/groupchat_control.py
+5
-3
src/remote_control.py
src/remote_control.py
+5
-1
No files found.
src/common/connection.py
View file @
4481b635
...
...
@@ -757,6 +757,8 @@ def __init__(self, name):
self
.
_nec_agent_info_received
)
gajim
.
ged
.
register_event_handler
(
'message-outgoing'
,
ged
.
OUT_CORE
,
self
.
_nec_message_outgoing
)
gajim
.
ged
.
register_event_handler
(
'gc-message-outgoing'
,
ged
.
OUT_CORE
,
self
.
_nec_gc_message_outgoing
)
# END __init__
def
cleanup
(
self
):
...
...
@@ -769,6 +771,8 @@ def cleanup(self):
self
.
_nec_agent_info_received
)
gajim
.
ged
.
remove_event_handler
(
'message-outgoing'
,
ged
.
OUT_CORE
,
self
.
_nec_message_outgoing
)
gajim
.
ged
.
remove_event_handler
(
'message-outgoing'
,
ged
.
OUT_CORE
,
self
.
_nec_gc_message_outgoing
)
def
get_config_values_or_default
(
self
):
if
gajim
.
config
.
get_per
(
'accounts'
,
self
.
name
,
'keep_alives_enabled'
):
...
...
@@ -2600,6 +2604,42 @@ def send_gc_message(self, jid, msg, xhtml=None, label=None,
if
callback
:
callback
(
msg_iq
,
msg
)
def
_nec_gc_message_outgoing
(
self
,
obj
):
if
obj
.
account
!=
self
.
name
:
return
if
not
gajim
.
account_is_connected
(
self
.
name
):
return
if
obj
.
correction_msg
:
id_
=
obj
.
correction_msg
.
getID
()
if
obj
.
correction_msg
.
getTag
(
'replace'
):
obj
.
correction_msg
.
delChild
(
'replace'
)
obj
.
correction_msg
.
setTag
(
'replace'
,
attrs
=
{
'id'
:
id_
},
namespace
=
nbxmpp
.
NS_CORRECT
)
id2
=
self
.
connection
.
getAnID
()
obj
.
correction_msg
.
setID
(
id2
)
obj
.
correction_msg
.
setBody
(
obj
.
message
)
if
obj
.
xhtml
:
obj
.
correction_msg
.
setXHTML
(
xhtml
)
self
.
connection
.
send
(
obj
.
correction_msg
)
gajim
.
nec
.
push_incoming_event
(
MessageSentEvent
(
None
,
conn
=
self
,
jid
=
obj
.
jid
,
message
=
obj
.
message
,
keyID
=
None
,
chatstate
=
None
))
if
obj
.
callback
:
obj
.
callback
(
obj
.
correction_msg
,
obj
.
message
)
return
if
not
obj
.
xhtml
and
gajim
.
config
.
get
(
'rst_formatting_outgoing_messages'
):
from
common.rst_xhtml_generator
import
create_xhtml
obj
.
xhtml
=
create_xhtml
(
obj
.
message
)
msg_iq
=
nbxmpp
.
Message
(
obj
.
jid
,
obj
.
message
,
typ
=
'groupchat'
,
xhtml
=
obj
.
xhtml
)
if
obj
.
label
is
not
None
:
msg_iq
.
addChild
(
node
=
label
)
self
.
connection
.
send
(
msg_iq
)
gajim
.
nec
.
push_incoming_event
(
MessageSentEvent
(
None
,
conn
=
self
,
jid
=
obj
.
jid
,
message
=
obj
.
message
,
keyID
=
None
,
chatstate
=
None
))
if
obj
.
callback
:
obj
.
callback
(
msg_iq
,
obj
.
message
)
def
send_gc_subject
(
self
,
jid
,
subject
):
if
not
gajim
.
account_is_connected
(
self
.
name
):
return
...
...
src/common/connection_handlers_events.py
View file @
4481b635
...
...
@@ -2444,6 +2444,25 @@ def init(self):
def
generate
(
self
):
return
True
class
GcMessageOutgoingEvent
(
nec
.
NetworkOutgoingEvent
):
name
=
'gc-message-outgoing'
base_network_events
=
[]
def
init
(
self
):
self
.
message
=
''
self
.
xhtml
=
None
self
.
label
=
None
self
.
callback
=
None
self
.
callback_args
=
[]
self
.
is_loggable
=
True
self
.
control
=
None
self
.
correction_msg
=
None
def
generate
(
self
):
return
True
class
ClientCertPassphraseEvent
(
nec
.
NetworkIncomingEvent
):
name
=
'client-cert-passphrase'
base_network_events
=
[]
...
...
src/groupchat_control.py
View file @
4481b635
...
...
@@ -54,6 +54,7 @@
from
command_system.implementation.hosts
import
PrivateChatCommands
from
command_system.implementation.hosts
import
GroupChatCommands
from
common.connection_handlers_events
import
GcMessageOutgoingEvent
import
logging
log
=
logging
.
getLogger
(
'gajim.groupchat_control'
)
...
...
@@ -1923,9 +1924,10 @@ def _cb(msg, msg_txt):
else
:
correction_msg
=
None
# Send the message
gajim
.
connections
[
self
.
account
].
send_gc_message
(
self
.
room_jid
,
message
,
xhtml
=
xhtml
,
label
=
label
,
correction_msg
=
correction_msg
,
callback
=
_cb
)
gajim
.
nec
.
push_outgoing_event
(
GcMessageOutgoingEvent
(
None
,
account
=
self
.
account
,
jid
=
self
.
room_jid
,
message
=
message
,
xhtml
=
xhtml
,
label
=
label
,
callback
=
_cb
,
callback_args
=
[
_cb
]
+
[
message
],
correction_msg
=
correction_msg
))
self
.
msg_textview
.
get_buffer
().
set_text
(
''
)
self
.
msg_textview
.
grab_focus
()
...
...
src/remote_control.py
View file @
4481b635
...
...
@@ -37,7 +37,9 @@
from
time
import
time
from
dialogs
import
AddNewContactWindow
,
NewChatDialog
,
JoinGroupchatWindow
from
common
import
ged
from
common.connection_handlers_events
import
MessageOutgoingEvent
from
common.connection_handlers_events
import
MessageOutgoingEvent
,
GcMessageOutgoingEvent
from
common
import
dbus_support
if
dbus_support
.
supported
:
...
...
@@ -478,6 +480,8 @@ def send_groupchat_message(self, room_jid, message, account):
if
connected_account
:
connection
=
gajim
.
connections
[
connected_account
]
connection
.
send_gc_message
(
room_jid
,
message
)
gajim
.
nec
.
push_outgoing_event
(
GcMessageOutgoingEvent
(
None
,
account
=
connected_account
,
jid
=
room_jid
,
message
=
message
))
return
DBUS_BOOLEAN
(
True
)
return
DBUS_BOOLEAN
(
False
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment