Esempio n. 1
0
    def on_authenticated(self, token):
        """Triggered when device authentication has been completed

        :param token: Authentication token details
        :type token: dict
        """
        self.authorization = token
        setSetting('authorization', dumps(self.authorization))
        logger.debug('Authentication complete: %r' % token)
        self.authDialog.close()
        notification(getString(32157), getString(32152), 3000)
        self.updateUser()
Esempio n. 2
0
    def on_authenticated(self, token):
        """Triggered when device authentication has been completed

        :param token: Authentication token details
        :type token: dict
        """
        self.authorization = token
        setSetting('authorization', dumps(self.authorization))
        logger.debug('Authentication complete: %r' % token)
        self.authDialog.close()
        notification(getString(32157), getString(32152), 3000)
        self.updateUser()
Esempio n. 3
0
    def updateSettings(self):
        if getSetting('authorization'):
            _auth = loads(getSetting('authorization'))
        else:
            _auth = {}

        if self.authorization != _auth:
            self.authorization = _auth
            user = self.getUser()
            if user and 'user' in user:
                setSetting('user', user['user']['username'])
            else:
                setSetting('user', '')
Esempio n. 4
0
    def onClick(self, control):
        logger.debug('onClick: %s' % (control))

        if control == LATER_BUTTON:
            notification(getString(32157), getString(32150), 5000)
            setSetting('last_reminder', str(int(time.time())))

        if control == NEVER_BUTTON:
            notification(getString(32157), getString(32151), 5000)
            setSetting('last_reminder', '-1')

        if control in [LATER_BUTTON, NEVER_BUTTON]:
            self.close()
Esempio n. 5
0
    def onClick(self, control):
        logger.debug('onClick: %s' % (control))

        if control == LATER_BUTTON:
            notification(getString(32157), getString(32150), 5000)
            setSetting('last_reminder', str(int(time.time())))

        if control == NEVER_BUTTON:
            notification(getString(32157), getString(32151), 5000)
            setSetting('last_reminder', '-1')

        if control in [LATER_BUTTON, NEVER_BUTTON]:
            self.close()
Esempio n. 6
0
    def authenticate(self, pin=None):
        # Attempt authentication (retrieve new token)
        with Trakt.configuration.http(retry=True):
            try:
                # Exchange `code` for `access_token`
                logger.debug("Exchanging pin for access token")
                self.authorization = Trakt['oauth'].token_exchange(pin, 'urn:ietf:wg:oauth:2.0:oob')

                if not self.authorization:
                    logger.debug("Authentication Failure")
                    return False
                else:
                    setSetting('authorization', dumps(self.authorization))
                    return True
            except Exception as ex:
                message = createError(ex)
                logger.fatal(message)
                logger.debug("Cannot connect to server")
                notification('Trakt', getString(32023))
Esempio n. 7
0
        def onClick(self, control):
            #print 'onClick: %s' % (control)
            logger.debug('onClick: %s' % (control))
            if control == AUTH_BUTTON:
                if not self.__get_token():
                    logger.debug("Authentification error")
                    notification(getString(32157), getString(32147), 5000)
                    return
                self.auth = True

            if control == LATER_BUTTON:
                notification(getString(32157), getString(32150), 5000)
                setSetting('last_reminder', str(int(time.time())))

            if control == NEVER_BUTTON:
                notification(getString(32157), getString(32151), 5000)
                setSetting('last_reminder', '-1')

            if control in [AUTH_BUTTON, LATER_BUTTON, NEVER_BUTTON]:
                self.close()
Esempio n. 8
0
    def on_token_refreshed(self, response):
        # OAuth token refreshed, save token for future calls
        self.authorization = response
        setSetting('authorization', dumps(self.authorization))

        logger.debug('Token refreshed')
Esempio n. 9
0
 def updateUser(self):
     user = self.getUser()
     if user and 'user' in user:
         setSetting('user', user['user']['username'])
     else:
         setSetting('user', '')
Esempio n. 10
0
    def on_token_refreshed(self, response):
        # OAuth token refreshed, save token for future calls
        self.authorization = response
        setSetting('authorization', dumps(self.authorization))

        logger.debug('Token refreshed')
Esempio n. 11
0
 def updateUser(self):
     user = self.getUser()
     if user and 'user' in user:
         setSetting('user', user['user']['username'])
     else:
         setSetting('user', '')