def call(self, phone, person, language): if phone == None: print "abandon" self.complete_request() return root = ResultCallback(commands=[]) rootView = AddViews("", temporary=False, dialogPhase="Completion", views=[]) root.commands.append(rootView) rootView.views.append( AssistantUtteranceView( text=responses['callPerson'][language].format( person.fullName, numberTypesLocalized[phone.label][language], phone.number), speakableText=responses['callPersonSpeak'][language].format( person.fullName, numberTypesLocalized[phone.label][language]), dialogIdentifier="PhoneCall#initiatePhoneCall", listenAfterSpeaking=False)) rootView.callbacks = [] # create some infos of the target personAttribute = PersonAttribute(data=phone.number, displayText=person.fullName, obj=Person()) personAttribute.object.identifer = person.identifier call = PhoneCall("", recipient=phone.number, faceTime=False, callRecipient=personAttribute) rootView.callbacks.append(ResultCallback(commands=[call])) call.callbacks = [] # now fill in error messages (airplanemode, no service, invalidNumber, fatal) for i in range(4): errorRoot = AddViews(None, temporary=False, dialogPhase="Completion", scrollToTop=False, views=[]) errorRoot.views.append( AssistantUtteranceView( text=errorOnCallResponse[language][i]['text'], speakableText=errorOnCallResponse[language][i]['text'], dialogIdentifier=errorOnCallResponse[language][i] ['dialogIdentifier'], listenAfterSpeaking=False)) call.callbacks.append( ResultCallback(commands=[errorRoot], code=errorOnCallResponse[language][i]['code'])) self.complete_request([root])
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
def __init__(self, refId, recipient="", faceTime=False, callRecipient=None, targetAppId=""): super(PhoneCall, self).__init__("Call", "com.apple.ace.phone", None, refId) self.recipient = recipient self.faceTime = faceTime self.callRecipient = callRecipient if callRecipient != None else PersonAttribute( ) self.targetAppId = targetAppId