Example #1
0
 def presentPossibleUsers(self, persons, language):
     root = AddViews(self.refId, False, False, "Clarification", [], [])
     root.views.append(AssistantUtteranceView(responses['select'][language], responses['select'][language], "ContactDataResolutionDucs#disambiguateContact", True))
     lst = DisambiguationList([], "OK!", True, "OK!", speakableDemitter[language], ", ", "OK!")
     root.views.append(lst)
     for person in persons:
         item = ListItem(person.fullName, person.fullName, [], person.fullName, person)
         item.commands.append(SendCommands([StartRequest(False, "^phoneCallContactId^=^urn:ace:{0}".format(person.identifier))]))
         lst.items.append(item)
     return root
Example #2
0
 def findPhoneForNumberType(self, person, numberType, language):         
     # first check if a specific number was already requested
     phoneToCall = None
     if numberType != None:
         # try to find the phone that fits the numberType
         phoneToCall = filter(lambda x: x.label == numberType, person.phones)
     else:
         favPhones = filter(lambda y: y.favoriteVoice if hasattr(y, "favoriteVoice") else False, person.phones)
         if len(favPhones) == 1:
             phoneToCall = favPhones[0]
     if phoneToCall == None:
         # lets check if there is more than one number
         if len(person.phones) == 1:
             if numberType != None:
                 self.say(errorNumberNotPresent.format(numberTypesLocalized[numberType][language], person.fullName))
             phoneToCall = person.phones[0]
         else:
             # damn we need to ask the user which one he wants...
             while(phoneToCall == None):
                 rootView = AddViews(self.refId, temporary=False, dialogPhase="Clarification", scrollToTop=False, views=[])
                 sayit = responses['selectNumber'][language].format(person.fullName)
                 rootView.views.append(AssistantUtteranceView(text=sayit, speakableText=sayit, listenAfterSpeaking=True,dialogIdentifier="ContactDataResolutionDucs#foundAmbiguousPhoneNumberForContact"))
                 lst = DisambiguationList(items=[], speakableSelectionResponse="OK...", listenAfterSpeaking=True, speakableText="", speakableFinalDemitter=speakableDemitter[language], speakableDemitter=", ",selectionResponse="OK...")
                 rootView.views.append(lst)
                 for phone in person.phones:
                     numberType = phone.label
                     item = ListItem()
                     item.title = ""
                     item.text = u"{0}: {1}".format(numberTypesLocalized[numberType][language], phone.number)
                     item.selectionText = item.text
                     item.speakableText = u"{0}  ".format(numberTypesLocalized[numberType][language])
                     item.object = phone
                     item.commands.append(SendCommands(commands=[StartRequest(handsFree=False, utterance=numberTypesLocalized[numberType][language])]))
                     lst.items.append(item)
                 answer = self.getResponseForRequest(rootView)
                 numberType = self.getNumberTypeForName(answer, language)
                 if numberType != None:
                     matches = filter(lambda x: x.label == numberType, person.phones)
                     if len(matches) == 1:
                         phoneToCall = matches[0]
                     else:
                         self.say(errorNumberTypes[language])
                 else:
                     self.say(errorNumberTypes[language])
     return phoneToCall