Example #1
0
    def __init__(self, logger=None):
        '''
        * logger -- The logger

        '''
        self.__dict__ = self.__shared_state

        # If the manager has not been initialized, then initialize it
        if getattr(self, "_initialized", False) == False:
            # Create a map of directions to connection objects
            self._connections = {
                Directions.From_iPhone: None,
                Directions.From_Server: None,
            }

            # Map incoming direction, to its forwarding direction
            self._forwardMap = {
                Directions.From_iPhone: Directions.From_Server,
                Directions.From_Server: Directions.From_iPhone
            }

            # String readable versions of the directions
            self._nameMap = {
                Directions.From_iPhone: "iPhone",
                Directions.From_Server: "Server",
            }

            # Create the logger for this class
            if logger is None:
                logger = LogData()
            self._log = logger.get("ConnectionManager",
                                   color=Colors.Foreground.Orange)

            # The connection manager has now been initialized
            self._initialized = True
Example #2
0
    def __init__(self, logData=None, logColor=Colors.Foreground.Green):
        '''
        * logData -- The LogData object
        * logColor -- The color to use for the Logger

        '''
        # Create a logger just for the options loading
        if logData is None:
            logData = LogData()
        self.__log = logData.get("PluginTester", color=logColor)

        # Parse the siri proxy configuration options object
        options = Options(logData)
        options.parse(argv, Files.ConfigFile)

        # Set the callback for the iPhone, and Server connections
        Server.Callback = self.iPhoneCallback
        Server.Callback = self.serverCallback

        # Create the connection manager, and connect the iPhone and
        # Server connections to it
        connectionManager = ConnectionManager(logData)
        connectionManager.connect(iPhone)
        connectionManager.connect(Server)

        # Grab an instance to the plugin manager
        self.__pluginManager = PluginManager(connectionManager, logData)
Example #3
0
    def __init__(self, connectionManager, logger=None):
        """
        * connectionManager -- An instance of the ConnectionManager
        * logger -- The LogData object

        """
        self.__dict__ = self.__shared_state

        # If plugins have not been loaded, then load them
        if getattr(self, "_plugins", False) == False:
            self._connectionManager = connectionManager

            # Get data pertaining to the directory containing plugins
            self.PluginsDirectory = Options.get(Sections.General, Ids.PluginsDir)
            self.PluginsDirectoryName = split(self.PluginsDirectory)[-1]

            # Create a logger if one was not given
            if logger is None:
                logger = LogData()
            self.log = logger.get("PluginManager")
            self._logger = logger

            self._pluginMap = {}

            self._options = Options()
            self.loadPlugins(self.PluginsDirectory)

            # The Response object waiting for a response from Siri
            self._response = None
Example #4
0
    def __init__(self, logger=None):
        '''
        * logger -- The logger

        '''
        self.__dict__ = self.__shared_state

        # If the manager has not been initialized, then initialize it
        if getattr(self, "_initialized", False) == False:
            # Create a map of directions to connection objects
            self._connections = {
                Directions.From_iPhone: None,
                Directions.From_Server: None,
                }

            # Map incoming direction, to its forwarding direction
            self._forwardMap = {
                Directions.From_iPhone: Directions.From_Server,
                Directions.From_Server: Directions.From_iPhone
                }

            # String readable versions of the directions
            self._nameMap = {
                Directions.From_iPhone: "iPhone",
                Directions.From_Server: "Server",
                }

            # Create the logger for this class
            if logger is None:
                logger = LogData()
            self._log = logger.get("ConnectionManager",
                                   color=Colors.Foreground.Orange)

            # The connection manager has now been initialized
            self._initialized = True
Example #5
0
    def __init__(self, logData=None, logColor=Colors.Foreground.Green):
        '''
        * logData -- The LogData object
        * logColor -- The color to use for the Logger

        '''
        # Create a logger just for the options loading
        if logData is None:
            logData = LogData()
        self.__log = logData.get("PluginTester", color=logColor)

        # Parse the siri proxy configuration options object
        options = Options(logData)
        options.parse(argv, Files.ConfigFile)

        # Set the callback for the iPhone, and Server connections
        Server.Callback = self.iPhoneCallback
        Server.Callback = self.serverCallback

        # Create the connection manager, and connect the iPhone and
        # Server connections to it
        connectionManager = ConnectionManager(logData)
        connectionManager.connect(iPhone)
        connectionManager.connect(Server)

        # Grab an instance to the plugin manager
        self.__pluginManager = PluginManager(connectionManager, logData)
Example #6
0
    def __init__(self, connectionManager, logger=None):
        '''
        * connectionManager -- An instance of the ConnectionManager
        * logger -- The LogData object

        '''
        self.__dict__ = self.__shared_state

        # If plugins have not been loaded, then load them
        if getattr(self, "_plugins", False) == False:
            self._connectionManager = connectionManager

            # Get data pertaining to the directory containing plugins
            self.PluginsDirectory = Options.get(Sections.General,
                                                Ids.PluginsDir)
            self.PluginsDirectoryName = split(self.PluginsDirectory)[-1]

            # Create a logger if one was not given
            if logger is None:
                logger = LogData()
            self.log = logger.get("PluginManager")
            self._logger = logger

            self._pluginMap = {}

            self._options = Options()
            self.loadPlugins(self.PluginsDirectory)

            # The Response object waiting for a response from Siri
            self._response = None
Example #7
0
    def __log(cls, message):
        """Log an information message to the output.

        * message -- The message to log

        """
        logger = LogData().get(cls.Direction, color=Colors.Foreground.Red)
        logger.info(message)
Example #8
0
    def __log(cls, message):
        '''Log an information message to the output.

        * message -- The message to log

        '''
        logger = LogData().get(cls.Direction, color=Colors.Foreground.Red)
        logger.info(message)
Example #9
0
    def __init__(self, name, direction, logger,
                 logColor=Colors.Foreground.White):
        '''
        * name -- The name of this Connection
        * direction -- The direction of the data coming into this Connection
        * logger -- The logger for this Connection
        * logColor -- The log color for this Connection

        '''
        self.__direction = direction
    
        # Connect this connection to the connection manager
        self.__connectionManager = ConnectionManager(logger)
        self.__connectionManager.connect(self)

        # Grab an instance to the plugin manager
        self.__pluginManager = PluginManager(self.__connectionManager, logger)

        # If no logger is given, be sure to create it
        if logger is None:
            logger = LogData(name)
        self.log = logger.get(name, color=logColor)
        self.__logger = logger

        self.__compStream = zlib.compressobj()
        self.__zipStream = zlib.decompressobj()
        self.__processedHeaders = False
        self.__consumedAce = False

        self.__inputBuffer = ""
        self.__outputBuffer = ""
        self.__unzippedInput = ""
        self.__unzippedOutput = ""

        self.ssled = False
        self.__lastRefId = None
        self.__blockRestOfSession = False
        self.otherConnection = None

        # Starts in line mode
        self.__mode = Modes.Line