Пример #1
0
    def requestCompleted(cls, refId, callbacks=None):
        '''Create a request completed object.

        * refId -- The reference id
        * callbacks -- The list of callbacks

        '''
        completed = Requests.create(Requests.RequestCompleted,
                                    callbacks=callbacks)
        completed.makeRoot(refId)

        return completed.toDict()
Пример #2
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