Setting up the chain for the ui to tell the session to make a call
authorEd Page <eopage@byu.net>
Wed, 6 Oct 2010 02:06:38 +0000 (21:06 -0500)
committerEd Page <eopage@byu.net>
Wed, 6 Oct 2010 02:15:47 +0000 (21:15 -0500)
src/dialcentral_qt.py
src/session.py

index 7de8926..5d95ebc 100755 (executable)
@@ -276,7 +276,9 @@ class SMSEntryWindow(object):
                self._characterCountLabel = QtGui.QLabel("Letters: %s" % 0)
                self._singleNumberSelector = QtGui.QComboBox()
                self._smsButton = QtGui.QPushButton("SMS")
+               self._smsButton.clicked.connect(self._on_sms_clicked)
                self._dialButton = QtGui.QPushButton("Dial")
+               self._dialButton.clicked.connect(self._on_call_clicked)
 
                self._buttonLayout = QtGui.QHBoxLayout()
                self._buttonLayout.addWidget(self._characterCountLabel)
@@ -398,7 +400,7 @@ class SMSEntryWindow(object):
                        self._on_change_number,
                        cid
                )
-               callback.__name__ = "b"
+               callback.__name__ = "thanks partials for not having names and pyqt for requiring them"
                selector.currentIndexChanged.connect(
                        QtCore.pyqtSlot(int)(callback)
                )
@@ -406,6 +408,19 @@ class SMSEntryWindow(object):
        def _scroll_to_bottom(self):
                self._scrollEntry.ensureWidgetVisible(self._smsEntry)
 
+       @QtCore.pyqtSlot()
+       @misc_utils.log_exception(_moduleLogger)
+       def _on_sms_clicked(self):
+               message = str(self._smsEntry.toPlainText())
+               self._session.draft.send(message)
+               self._smsEntry.setPlainText("")
+
+       @QtCore.pyqtSlot()
+       @misc_utils.log_exception(_moduleLogger)
+       def _on_call_clicked(self):
+               self._session.draft.call()
+               self._smsEntry.setPlainText("")
+
        @misc_utils.log_exception(_moduleLogger)
        def _on_remove_contact(self, cid):
                self._session.draft.remove_contact(cid)
index afebf93..17c32b5 100644 (file)
@@ -41,13 +41,15 @@ class Draft(QtCore.QObject):
 
        def send(self, text):
                assert 0 < len(self._contacts)
+               numbers = [contact.selectedNumber for contact in self._contacts.itervalues()]
                le = concurrent.AsyncLinearExecution(self._pool, self._send)
-               le.start(text)
+               le.start(numbers, text)
 
        def call(self):
                assert len(self._contacts) == 1
+               (contact, ) = self._contacts.itervalues()
                le = concurrent.AsyncLinearExecution(self._pool, self._call)
-               le.start()
+               le.start(contact.selectedNumber)
 
        def cancel(self):
                le = concurrent.AsyncLinearExecution(self._pool, self._cancel)
@@ -93,7 +95,7 @@ class Draft(QtCore.QObject):
                if oldContacts:
                        self.recipientsChanged.emit()
 
-       def _send(self, text):
+       def _send(self, numbers, text):
                self.sendingMessage.emit()
                try:
                        self.error.emit("Not Implemented")
@@ -102,7 +104,7 @@ class Draft(QtCore.QObject):
                except Exception, e:
                        self.error.emit(str(e))
 
-       def _call(self):
+       def _call(self, number):
                self.calling.emit()
                try:
                        self.error.emit("Not Implemented")