예제 #1
0
    def directions(cls, directionsType, source, destination, utterance=None):
        '''Create a :class:`.SiriObject` to display directions between two
        locations.

        * directionsType -- The type of directions to provide
        * source -- The source location
        * destination -- The destination location
        * utterance -- The utterance to speak

        '''
        # @todo: Allow source and destination to be passed as
        #        Locations, OR MapItems, and convert the Locations
        #        to MapItems accordingly.
        mapPoints = Views.create(Views.MapPoints, source=source,
                                 destination=destination,
                                 directionsType=directionsType)

        commands = [mapPoints]
        resultCallback = Commands.create(Commands.ResultCallback,
                                         commands=commands)

        callbacks = [resultCallback]

        views = []
        # Add the utternace to the views, if an utterance is given
        if utterance is not None:
            views.append(utterance)

        addViews = Views.create(Views.AddViews, callbacks=callbacks,
                                views=views)

        # Note: Adding the ace id makes the map points work properly
        addViews.setAceId()

        commands = [addViews]
        resultCallback = Commands.create(Commands.ResultCallback,
                                         commands=commands)
        callbacks = [resultCallback]
        completed = Requests.create(Requests.RequestCompleted,
                                    callbacks=callbacks)
        return completed
예제 #2
0
    def view(cls, refId, subObjects, dialogPhase="Completion"):
        '''Create an utterance view composed of several sub objects.

        * refId -- The reference id
        * subObjects -- The list of SiriObjects the view will be composed of
                        or a list of tuple arguments to create SiriObjects
        * dialogPhase -- The dialogPhase

        '''
        addViews = Views.create(Views.AddViews, dialogPhase=dialogPhase,
                                views=subObjects)
        addViews.makeRoot(refId)
        return addViews.toDict()
예제 #3
0
    def utterance(cls, displayText, spokenText=None, listenAfterSpeaking=False,
                  identifier="Misc#ident"):
        '''Create a :class:`.SiriObject` utterance.

        * displayText -- The text to display
        * spokenText -- The text that Siri will speak
        * listenAfterSpeaking -- True for Siri to listen for a response
        * identifier -- The identifier for the utterance

        '''
        return Views.create(Views.Utterance, displayText=displayText,
                            spokenText=spokenText,
                            listenAfterSpeaking=listenAfterSpeaking,
                            dialogIdentifier=identifier)
예제 #4
0
    def mapItem(cls, locations):
        '''Create a :class:`.SiriObject` map item.

        * locations -- The list of locations to display on the map

        '''
        items = []

        # Create locations for all of the locations in the given list
        for label, location in locations:
            mapItem = DataObjects.create(DataObjects.MapItem, label=label,
                                         location=location)
            items.append(mapItem)

        return Views.create(Views.MapItemSnippet, useCurrentLocation=False,
                            items=items)