SiriServerCore icon indicating copy to clipboard operation
SiriServerCore copied to clipboard

SetAlertContext

Open danzatt opened this issue 12 years ago • 6 comments

Siri is sending packet SetAlertContext in which new messages and so on are stored. It is sent before starting the first SpeechRequest and it can't be requested again. So we need to save this plist/object and then provide function to get it from plugin. We must also add handler for ClearContext which will delete this plist/object.

I added this code :

to init of SiriProtocolHandler :

    self.alertContext = None

to process_recognized_speech plugin = PluginManager.getPluginForImmediateExecution(self.assistant.assistantId, best_match, self.assistant.language, (self.send_object, self.send_plist, self.assistant, self.current_location), self.alertContext)

to end of received_plist :

    elif ObjectIsCommand(plist, SetAlertContext):
    self.logger.debug("Setting AlertContext")
    self.alertContext = SetAlertContext(plist)

    elif ObjectIsCommand(plist, SetAlertContext):
    self.logger.debug("Clearing AlertContext")
    self.alertContext = None

to plugin.py

    def initialize(self, method, speech, language, send_object, send_plist, assistant, location, alertContext)

to initialize added self.alertContext = alertContext

to Plugin class added function def getContext(self): return self.alertContext

and in PluginManager edited getPluginForImmediateExecution as follows : def getPluginForImmediateExecution(assistantId, speech, language, otherPluginParams, alertContext): (sendObj, sendPlist, assistant, location) = otherPluginParams

(pluginObj, method) = searchPrioritizedPlugin(assistantId, speech, language)
if pluginObj == None and method == None:
    (clazz, method) = getPlugin(speech, language)
    if clazz != None and method != None:
        logger.debug("Instantiating plugin and method: {0}.{1}".format(clazz.__name__, method.__name__))
        pluginObj = clazz()
        pluginObj.initialize(method, speech, language, sendObj, sendPlist, assistant, location, alertContext)
        #prioritizePluginObject(pluginObj, assistantId)
else:
    #reinitialize it
    logger.info("Found a matching prioritized plugin")
    pluginObj.initialize(method, speech, language, sendObj, sendPlist, assistant, location, alertContext)

return pluginObj

This can be used for reading new messages

danzatt avatar Jun 02 '12 10:06 danzatt

I added similar code to my SiriProtocolHandler, however I took a different approach to the alert context, I added it to the assistant object. The alert contexts can then be accessed from the plugin by accessing the

self.assistant.alerts

property from the plugin.

I don't have time to go through and document my changes tonight, but I could tomorrow.

ericyanush avatar Jun 06 '12 05:06 ericyanush

Thanks for idea. It's much easier.

danzatt avatar Jun 06 '12 17:06 danzatt

I have added code to the sms plugin Eichhoernchen built to be able to read back new messages, as well as reply to them. I will upload my code and make a pull request for that either tonight or tomorrow.

ericyanush avatar Jun 06 '12 17:06 ericyanush

post it here :) - http://ioshack.org/forums/

markhack avatar Jun 15 '12 09:06 markhack

For anyone looking for my plugin, seeing as how the ioshack forums are unreliable and the grwh one got spammed, I have uploaded it to my git. Feel free to use, re-use, improve and modify as you wish.

Eric

https://github.com/ericyanush/SiriServerSMSPlugin

ericyanush avatar Jul 12 '12 00:07 ericyanush

ioshack is not unreliable, they where taken down until eich knows what he wants to do with it.

ioshack is aimed for free hosting space atm.

On Jul 11, 2012, at 7:51 PM, Eric Yanush wrote:

For anyone looking for my plugin, seeing as how the ioshack forums are unreliable and the grwh one got spammed, I have uploaded it to my git. Feel free to use, re-use, improve and modify as you wish.

Eric

https://github.com/ericyanush/SiriServerSMSPlugin


Reply to this email directly or view it on GitHub: https://github.com/Eichhoernchen/SiriServerCore/issues/72#issuecomment-6924379

markhack avatar Jul 12 '12 20:07 markhack