def getSmssForIdentifier(self, identifier):
     # fetch the current version
     retrieveCMD = DomainObjectRetrieve(self.refId)
     x = SmsSms()
     x.identifier = identifier
     retrieveCMD.identifiers = [x]
     answer = self.getResponseForRequest(retrieveCMD)
     if ObjectIsCommand(answer, DomainObjectRetrieveCompleted):
         answer = DomainObjectRetrieveCompleted(answer)
         if len(answer.objects) > 1:
             self.logger.warning("I do not support multiple messages!")
         result = SmsSms()
         result.initializeFromPlist(answer.objects[0].to_plist())
         return result
     else:
         return None
Example #2
0
    def askAndSetMessage(self, sms, language):
        createAnchor = self.createSmsSnippet(
            sms, False, "CreateSms#smsMissingMessage",
            random.choice(responses['askForMessage'][language]), language)

        smsText = self.getResponseForRequest(createAnchor)
        # update the domain object

        updateCMD = DomainObjectUpdate(self.refId)
        updateCMD.identifier = sms
        updateCMD.addFields = SmsSms()
        updateCMD.setFields = SmsSms()
        updateCMD.setFields.message = smsText
        updateCMD.removeFields = SmsSms()

        answer = self.getResponseForRequest(updateCMD)
        if ObjectIsCommand(answer, DomainObjectUpdateCompleted):
            return sms
        else:
            return None
Example #3
0
 def createNewMessage(self, phone, person):
     # create a new domain object the sms...
     x = SmsSms()
     x.recipients = [phone.number]
     msgRecipient = PersonAttribute()
     msgRecipient.object = Person()
     msgRecipient.object.identifier = person.identifier
     msgRecipient.data = phone.number
     msgRecipient.displayText = person.fullName
     x.msgRecipients = [msgRecipient]
     x.outgoing = True
     answer = self.getResponseForRequest(DomainObjectCreate(self.refId, x))
     if ObjectIsCommand(answer, DomainObjectCreateCompleted):
         answer = DomainObjectCreateCompleted(answer)
         x = SmsSms()
         x.outgoing = True
         x.identifier = answer.identifier
         return x
     else:
         return None
Example #4
0
 def getSmssForIdentifier(self, identifier):
     # fetch the current version
     retrieveCMD = DomainObjectRetrieve(self.refId)
     x = SmsSms()
     x.identifier = identifier
     retrieveCMD.identifiers = [x]
     answer = self.getResponseForRequest(retrieveCMD)
     if ObjectIsCommand(answer, DomainObjectRetrieveCompleted):
         answer = DomainObjectRetrieveCompleted(answer)
         if len(answer.objects) > 1:
             self.logger.warning("I do not support multiple messages!")
         result = SmsSms()
         result.initializeFromPlist(answer.objects[0].to_plist())
         return result
     else:
         return None
Example #5
0
    def cancelSms(self, sms, language):
        # cancel the sms
        cancelCMD = DomainObjectCancel(self.refId)
        cancelCMD.identifier = SmsSms()
        cancelCMD.identifier.identifier = sms.identifier

        answer = self.getResponseForRequest(cancelCMD)
        if ObjectIsCommand(answer, DomainObjectCancelCompleted):
            createAnchor = UIAddViews(self.refId)
            createAnchor.dialogPhase = createAnchor.DialogPhaseCanceledValue
            cancelView = UIAssistantUtteranceView()
            cancelView.dialogIdentifier = "CreateSms#wontSendSms"
            cancelView.text = cancelView.speakableText = random.choice(
                responses['cancelSms'][language])
            createAnchor.views = [cancelView]

            self.sendRequestWithoutAnswer(createAnchor)
            self.complete_request()
        else:
            self.say(random.choice(responses['cancelFail'][language]))
            self.complete_request()
 def createNewMessage(self, phone, person):
     # create a new domain object the sms...
     x = SmsSms()
     x.recipients = [phone.number]
     msgRecipient = PersonAttribute()
     msgRecipient.object = Person()
     msgRecipient.object.identifier = person.identifier
     msgRecipient.data = phone.number
     msgRecipient.displayText = person.fullName
     x.msgRecipients = [msgRecipient]
     x.outgoing = True
     answer = self.getResponseForRequest(DomainObjectCreate(self.refId, x))
     if ObjectIsCommand(answer, DomainObjectCreateCompleted):
         answer = DomainObjectCreateCompleted(answer)
         x = SmsSms()
         x.outgoing = True
         x.identifier = answer.identifier
         return x
     else:
         return None
Example #7
0
    def finalSend(self, sms, language):

        commitCMD = DomainObjectCommit(self.refId)
        commitCMD.identifier = SmsSms()
        commitCMD.identifier.identifier = sms.identifier

        answer = self.getResponseForRequest(commitCMD)
        if ObjectIsCommand(answer, DomainObjectCommitCompleted):
            answer = DomainObjectCommitCompleted(answer)
            # update the sms object with current identifier and time stamp
            sms.identifier = answer.identifier
            # the timestamp should be timezone aware
            # we could use the pytz lib for that
            # get the timezone from the assistant
            # and supply it to pytz which we can
            # supply to now()
            sms.dateSent = datetime.datetime.now()
            # tell the user we sent the sms
            createAnchor = UIAddViews(self.refId)
            createAnchor.dialogPhase = createAnchor.DialogPhaseConfirmedValue

            # create a view to ask for the message
            askCreateView = UIAssistantUtteranceView()
            askCreateView.dialogIdentifier = "CreateSms#sentSMS"
            askCreateView.text = askCreateView.speakableText = random.choice(
                responses['sendSms'][language])
            askCreateView.listenAfterSpeaking = False

            snippet = SmsSnippet()
            snippet.smss = [sms]

            createAnchor.views = [askCreateView, snippet]

            self.sendRequestWithoutAnswer(createAnchor)
            self.complete_request()
        else:
            self.say(random.choice(responses['sendSmsFail'][language]))
            self.complete_request()