changeset 3c789e643723 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=3c789e643723
description: Reimplemeted the /dtmf command
diffstat:
src/command_system/implementation/middleware.py | 9 ++++++++-
src/command_system/implementation/standard.py | 22 ++++++++++------------
2 files changed, 18 insertions(+), 13 deletions(-)
diffs (51 lines):
diff -r aa168d39f846 -r 3c789e643723
src/command_system/implementation/middleware.py
--- a/src/command_system/implementation/middleware.py Sat Aug 07 16:38:05
2010 +0300
+++ b/src/command_system/implementation/middleware.py Sat Aug 07 17:26:12
2010 +0300
@@ -182,4 +182,11 @@
"""
Get the current connection object.
"""
- return gajim.connections[self.account]
\ No newline at end of file
+ return gajim.connections[self.account]
+
+ @property
+ def full_jid(self):
+ """
+ Get a full JID of the contact.
+ """
+ return self.contact.get_full_jid()
\ No newline at end of file
diff -r aa168d39f846 -r 3c789e643723
src/command_system/implementation/standard.py
--- a/src/command_system/implementation/standard.py Sat Aug 07 16:38:05
2010 +0300
+++ b/src/command_system/implementation/standard.py Sat Aug 07 17:26:12
2010 +0300
@@ -181,19 +181,17 @@
gajim.connections[self.account].sendPing(self.contact)
@command
- @doc(_("Send DTMF events through an open audio session"))
- def dtmf(self, events):
+ @doc(_("Send DTMF sequence through an open audio session"))
+ def dtmf(self, sequence):
if not self.audio_sid:
- raise CommandError(_("There is no open audio session with this
contact"))
- # Valid values for DTMF tones are *, # or a number.
- events = [e for e in events if e in ('*', '#') or e.isdigit()]
- if events:
- session = gajim.connections[self.account].get_jingle_session(
- self.contact.get_full_jid(), self.audio_sid)
- content = session.get_content('audio')
- content.batch_dtmf(events)
- else:
- raise CommandError(_("No valid DTMF event specified"))
+ raise CommandError(_("No open audio sessions with the contact"))
+ for tone in sequence:
+ if not (tone in ("*", "#") or tone.isdigit()):
+ raise CommandError(_("%s is not a valid tone") % tone)
+ gjs = self.connection.get_jingle_session
+ session = gjs(self.full_jid, self.audio_sid)
+ content = session.get_content("audio")
+ content.batch_dtmf(sequence)
@command
@doc(_("Toggle audio session"))
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits