Clean up and adding of an sms command to the debug prompt
[theonering] / src / channel / debug_prompt.py
index 3352c2a..bc0ea38 100644 (file)
@@ -49,7 +49,7 @@ class DebugPromptChannel(telepathy.server.ChannelTypeText, cmd.Cmd):
                finally:
                        self.stdin, self.stdout = oldStdin, oldStdout
 
-               self._report_new_message(currentStdout.getvalue().strip())
+               self._report_new_message(currentStdout.getvalue())
 
        @gtk_toolbox.log_exception(_moduleLogger)
        def Close(self):
@@ -68,7 +68,7 @@ class DebugPromptChannel(telepathy.server.ChannelTypeText, cmd.Cmd):
                timestamp = int(time.time())
                type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL
 
-               self.Received(currentReceivedId, timestamp, self._otherHandle, type, 0, message)
+               self.Received(currentReceivedId, timestamp, self._otherHandle, type, 0, message.strip())
 
                self._nextRecievedId += 1
 
@@ -154,7 +154,7 @@ class DebugPromptChannel(telepathy.server.ChannelTypeText, cmd.Cmd):
 
        def do_call(self, args):
                if len(args) != 1:
-                       self._report_new_message("No arguments supported")
+                       self._report_new_message("Must specify the phone number and only the phone nunber")
                        return
 
                try:
@@ -162,3 +162,15 @@ class DebugPromptChannel(telepathy.server.ChannelTypeText, cmd.Cmd):
                        self._conn.session.backend.call(number)
                except Exception, e:
                        self._report_new_message(str(e))
+
+       def do_send_sms(self, args):
+               if 1 < len(args):
+                       self._report_new_message("Must specify the phone number and then message")
+                       return
+
+               try:
+                       number = args[0]
+                       message = " ".join(args[1:])
+                       self._conn.session.backend.send_sms(number, message)
+               except Exception, e:
+                       self._report_new_message(str(e))