示例#1
0
    def sipc_auth_t_finished(self):
        kill_qthread(self.sipc_auth_t_killer)

        res_obj = self.sipc_auth_t.get_return()
        code = res_obj.code

        if code == SIPResponse.OK:
            self._retry_times = 0
            i_update_user_after_sipc_auth_success(self.user, res_obj)
            self.show_contact_list_win()
            return

        elif code == SIPResponse.EXTENSION_REQUIRED:  # login location changed
            self.verification = i_generate_verification_pic(self.user, res_obj)
            body = "%s<br />%s" % (self.verification.text,
                                   self.verification.tips)
            (btn_val, chars) = GetVerificationDialog.get_input(
                body=body, path=self.verification.picture_path)

            if btn_val:
                logger.info("(SIPC auth) Input recognise chars: %s" % chars)
                self.verification.chars = chars
                self.sipc_auth_t_run()
            else:
                self.verification = None
                self.user = None
                self.show_or_hide_login_widgets(show=True)

            return

        self.show_or_hide_login_widgets(show=True)
        popup_error(self, "SIPC authentication response code: %d" % code)
示例#2
0
文件: iblah.py 项目: qq40660/iBlah_py
    def sipc_auth_t_finished(self):
        kill_qthread(self.sipc_auth_t_killer)

        res_obj = self.sipc_auth_t.get_return()
        code = res_obj.code

        if code == SIPResponse.OK:
            self._retry_times = 0
            i_update_user_after_sipc_auth_success(self.user, res_obj)
            self.show_contact_list_win()
            return

        elif code == SIPResponse.EXTENSION_REQUIRED: # login location changed
            self.verification = i_generate_verification_pic(self.user, res_obj)
            body = "%s<br />%s" % (self.verification.text, self.verification.tips)
            (btn_val, chars) = GetVerificationDialog.get_input(body = body,
                        path = self.verification.picture_path)
            
            if btn_val:
                logger.info("(SIPC auth) Input recognise chars: %s" % chars)
                self.verification.chars = chars
                self.sipc_auth_t_run()
            else:
                self.verification = None
                self.user = None
                self.show_or_hide_login_widgets(show = True)

            return

        self.show_or_hide_login_widgets(show = True)
        popup_error(self, "SIPC authentication response code: %d" % code)
示例#3
0
文件: iblah.py 项目: qq40660/iBlah_py
    def kill_ssi_auth_t(self):
        if self._retry_times < MAX_RETRY_TIMES:
            self._retry_times += 1
            logger.error("SSI authentication failed, auto re-try ...")
            self.ssi_auth_t_run()
            return 

        self.verification = None
        self.user = None
        self.show_or_hide_login_widgets(show = True)

        popup_error(self, u"连接超时(SSI),请稍候再尝试")
示例#4
0
    def kill_ssi_auth_t(self):
        if self._retry_times < MAX_RETRY_TIMES:
            self._retry_times += 1
            logger.error("SSI authentication failed, auto re-try ...")
            self.ssi_auth_t_run()
            return

        self.verification = None
        self.user = None
        self.show_or_hide_login_widgets(show=True)

        popup_error(self, u"连接超时(SSI),请稍候再尝试")
示例#5
0
文件: iblah.py 项目: qq40660/iBlah_py
    def kill_download_sys_config_t(self):
        kill_qthread(self.download_sys_config_t)

        if self._retry_times < MAX_RETRY_TIMES:
            self._retry_times += 1
            logger.error("Download configuration failed, auto re-try ...")
            self.download_sys_config_t_run()
            return

        self.verification = None
        self.user = None
        self.show_or_hide_login_widgets(show = True)

        popup_error(self, "Download configuration failed, try again later")
示例#6
0
    def kill_download_sys_config_t(self):
        kill_qthread(self.download_sys_config_t)

        if self._retry_times < MAX_RETRY_TIMES:
            self._retry_times += 1
            logger.error("Download configuration failed, auto re-try ...")
            self.download_sys_config_t_run()
            return

        self.verification = None
        self.user = None
        self.show_or_hide_login_widgets(show=True)

        popup_error(self, "Download configuration failed, try again later")
示例#7
0
文件: iblah.py 项目: qq40660/iBlah_py
    def download_sys_config_t_finished(self):
        kill_qthread(self.download_sys_config_t_killer)

        res_obj = self.download_sys_config_t.get_return()
        code = res_obj.code

        if code == httplib.OK:
            self.download_sys_config_t = None
            self.download_sys_config_t_killer = None
            self._retry_times = 0
            i_update_user_after_get_sys_config_success(self.user, res_obj.body)
            self.sipc_auth_t_run()
            return

        self.download_sys_config_t = None
        self.download_sys_config_t_killer = None
        self.show_or_hide_login_widgets(show = True)
        popup_error(self, "Download configuration response code: %d" % code)
示例#8
0
    def download_sys_config_t_finished(self):
        kill_qthread(self.download_sys_config_t_killer)

        res_obj = self.download_sys_config_t.get_return()
        code = res_obj.code

        if code == httplib.OK:
            self.download_sys_config_t = None
            self.download_sys_config_t_killer = None
            self._retry_times = 0
            i_update_user_after_get_sys_config_success(self.user, res_obj.body)
            self.sipc_auth_t_run()
            return

        self.download_sys_config_t = None
        self.download_sys_config_t_killer = None
        self.show_or_hide_login_widgets(show=True)
        popup_error(self, "Download configuration response code: %d" % code)
示例#9
0
文件: iblah.py 项目: qq40660/iBlah_py
    def on_login_btn_click(self):
        self._retry_times = 0
        account = self.get_account()
        passwd = self.get_passwd()

#        self._debug_mode = self.debug_mode_cb.checkState() == QtCore.Qt.Checked

        if not len(account) or not len(passwd):
            popup_error(self, u"帐号和密码都不能为空!")
            return
        else:
            last_char = account[-1]
            if last_char < '0' or last_char > '9':
                popup_error(self, u"您输入的不是一个有效的飞信号或者移动手机号,飞信邮箱协议暂时不兼容本软件")
                return

        hashed_passwd = i_hash_passwd(passwd)
        presence = self.get_presence()
        self.user = i_create_user(account, hashed_passwd, presence)
        self.ssi_auth_t_run()
        self.show_or_hide_login_widgets(show = False)
示例#10
0
    def on_login_btn_click(self):
        self._retry_times = 0
        account = self.get_account()
        passwd = self.get_passwd()

        #        self._debug_mode = self.debug_mode_cb.checkState() == QtCore.Qt.Checked

        if not len(account) or not len(passwd):
            popup_error(self, u"帐号和密码都不能为空!")
            return
        else:
            last_char = account[-1]
            if last_char < '0' or last_char > '9':
                popup_error(self, u"您输入的不是一个有效的飞信号或者移动手机号,飞信邮箱协议暂时不兼容本软件")
                return

        hashed_passwd = i_hash_passwd(passwd)
        presence = self.get_presence()
        self.user = i_create_user(account, hashed_passwd, presence)
        self.ssi_auth_t_run()
        self.show_or_hide_login_widgets(show=False)
示例#11
0
    def ssi_auth_t_finished(self):
        # why not necessary to call disconnect(SIGNAL) here
        # http://doc.qt.nokia.com/4.7/qobject.html#disconnect-3
        kill_qthread(self.ssi_auth_t_killer)

        res_obj = self.ssi_auth_t.get_return()
        code = res_obj.code

        if code == httplib.OK:
            i_update_user_after_ssi_auth_success(self.user, res_obj,
                                                 self.get_if_remember_passwd())

            self._retry_times = 0

            self.download_sys_config_t_run()

        elif code == HTTPResponse.PASSWD_ERROR:
            self.user = None
            self.show_or_hide_login_widgets(show=True)
            popup_error(self, u"密码错误")

        elif code in (HTTPResponse.CCPS_CHECK_ERROR, HTTPResponse.NEED_VERIFY):
            self.verification = i_generate_verification_pic(self.user, res_obj)
            body = "%s<br />%s" % (self.verification.text,
                                   self.verification.tips)
            (btn_val, chars) = GetVerificationDialog.get_input(
                body=body, path=self.verification.picture_path)

            if btn_val:
                logger.info("(SSI auth)Input recognise chars: %s" % chars)
                self.verification.chars = chars
                self.ssi_auth_t_run()
            else:
                self.verification = None
                self.user = None
                self.show_or_hide_login_widgets(show=True)
        else:
            raise Exception("SSI authentication response code: %d" % code)
示例#12
0
文件: iblah.py 项目: qq40660/iBlah_py
    def ssi_auth_t_finished(self):
        # why not necessary to call disconnect(SIGNAL) here
        # http://doc.qt.nokia.com/4.7/qobject.html#disconnect-3
        kill_qthread(self.ssi_auth_t_killer)

        res_obj = self.ssi_auth_t.get_return()
        code = res_obj.code

        if code == httplib.OK:
            i_update_user_after_ssi_auth_success(self.user, res_obj, self.get_if_remember_passwd())

            self._retry_times = 0
            
            self.download_sys_config_t_run()

        elif code == HTTPResponse.PASSWD_ERROR:
            self.user = None
            self.show_or_hide_login_widgets(show = True)
            popup_error(self, u"密码错误")
            
        elif code in (HTTPResponse.CCPS_CHECK_ERROR, HTTPResponse.NEED_VERIFY):
            self.verification = i_generate_verification_pic(self.user, res_obj)
            body = "%s<br />%s" % (self.verification.text, self.verification.tips)
            (btn_val, chars) = GetVerificationDialog.get_input(body = body,
                        path = self.verification.picture_path)

            if btn_val:
                logger.info("(SSI auth)Input recognise chars: %s" % chars)
                self.verification.chars = chars
                self.ssi_auth_t_run()
            else:
                self.verification = None
                self.user = None
                self.show_or_hide_login_widgets(show = True)
        else:
            raise Exception("SSI authentication response code: %d" % code)
示例#13
0
    def _consume_notification(self, res_obj, sock):
        assert (sock is not None)
        sip_event_str = res_obj.headers.get_field_value("N")
        sip_event = SIPEvent.get_const_by_str(SIPEvent, sip_event_str)
        events = get_conversation_events(res_obj)

        body_dom = minidom.parseString(res_obj.body)
        CONTACT_PRESENCE_CHANGED = sip_event == SIPEvent.PRESENCE_V4 and \
                                   NotificationEvent.PRESENCE_CHANGED in events

        CONTACT_LEFT = sip_event == SIPEvent.CONVERSATION and \
                       NotificationEvent.USER_LEFT in events

        SYNC_USER_INFO_V4 = sip_event == SIPEvent.SYNC_USER_INFO_V4 and \
                        NotificationEvent.SYNC_USER_INFO in events

        BEEN_DISCONNECTED = sip_event == SIPEvent.REGISTRATION and \
                                NotificationEvent.DEREGISTRATION in events

        ADD_BUDDY_REFUSED = sip_event == SIPEvent.SYSTEM_NOTIFY_V4 and \
                            NotificationEvent.ADD_BUDDY_REFUSED in events

        USER_DYNAMICS_CHANGED = sip_event == SIPEvent.SYSTEM_NOTIFY_V4 and \
                                NotificationEvent.USER_DYNAMICS_CHANGED

        ADD_BUDDY_APPLICATION = sip_event == SIPEvent.CONTACT and \
                                NotificationEvent.ADD_BUDDY_APPLICATION in events

        convs = self.user.get_conversations()
        if CONTACT_PRESENCE_CHANGED:
            offline_uri_list = update_contacts_presence_from_response(
                self.user, body_dom)
            for uri in offline_uri_list:
                if uri in convs:
                    conv = convs[uri]
                    assert conv.sock != self.user.get_sock()
                    conv.over()
                    #convs.pop(uri)
            self.update_portraits_t_run()

            self.emit(
                QtCore.SIGNAL(
                    'dataChanged ( const QModelIndex & , const QModelIndex &  )'
                ))

        elif CONTACT_LEFT:
            member_nodes = body_dom.getElementsByTagName("member")
            for member_node in member_nodes:
                uri = member_node.getAttribute("uri")
                conv = convs[uri]
                assert conv.sock != self.user.get_sock()
                conv.over()
                #convs.pop(uri)

        elif SYNC_USER_INFO_V4:
            self._consume_noti_sync_user_info_v4(res_obj)

        elif BEEN_DISCONNECTED:
            OFFLINE_ALERTS = "You have been disconnected" \
                "as someone has signed in with your ID on another computer." \
                "<br /><br />" \
                "Please note that if this was not intentional, some may have stolen your passwrod. "\
                "Please change your password."
            popup_error(self, OFFLINE_ALERTS)
            self.switch_presence_to_offline()
            #"Sign in again", "OK"

        elif ADD_BUDDY_REFUSED:
            uri, reason = i_parse_add_buddy_refused(body_dom)
            assert uri != reason
            logger.error(
                "User (URI: %s) refused your add buddy application, reason: %s"
                % (uri, reason))

        elif ADD_BUDDY_APPLICATION:
            self._consume_add_buddy_application(res_obj)

        elif USER_DYNAMICS_CHANGED:
            pass
示例#14
0
    def _consume_notification(self, res_obj, sock):
        assert (sock is not None)
        sip_event_str = res_obj.headers.get_field_value("N")
        sip_event = SIPEvent.get_const_by_str(SIPEvent, sip_event_str)
        events = get_conversation_events(res_obj)

        body_dom = minidom.parseString(res_obj.body)
        CONTACT_PRESENCE_CHANGED = sip_event == SIPEvent.PRESENCE_V4 and \
                                   NotificationEvent.PRESENCE_CHANGED in events

        CONTACT_LEFT = sip_event == SIPEvent.CONVERSATION and \
                       NotificationEvent.USER_LEFT in events

        SYNC_USER_INFO_V4 = sip_event == SIPEvent.SYNC_USER_INFO_V4 and \
                        NotificationEvent.SYNC_USER_INFO in events

        BEEN_DISCONNECTED = sip_event == SIPEvent.REGISTRATION and \
                                NotificationEvent.DEREGISTRATION in events

        ADD_BUDDY_REFUSED = sip_event == SIPEvent.SYSTEM_NOTIFY_V4 and \
                            NotificationEvent.ADD_BUDDY_REFUSED in events

        USER_DYNAMICS_CHANGED = sip_event == SIPEvent.SYSTEM_NOTIFY_V4 and \
                                NotificationEvent.USER_DYNAMICS_CHANGED

        ADD_BUDDY_APPLICATION = sip_event == SIPEvent.CONTACT and \
                                NotificationEvent.ADD_BUDDY_APPLICATION in events

        convs = self.user.get_conversations()
        if CONTACT_PRESENCE_CHANGED:
            offline_uri_list = update_contacts_presence_from_response(self.user, body_dom)
            for uri in offline_uri_list:
                if uri in convs:
                    conv = convs[uri]
                    assert conv.sock != self.user.get_sock()
                    conv.over()
                    #convs.pop(uri)
            self.update_portraits_t_run()

            self.emit(QtCore.SIGNAL('dataChanged ( const QModelIndex & , const QModelIndex &  )'))

        elif CONTACT_LEFT:
            member_nodes = body_dom.getElementsByTagName("member")
            for member_node in member_nodes:
                uri = member_node.getAttribute("uri")
                conv = convs[uri]
                assert conv.sock != self.user.get_sock()
                conv.over()
                #convs.pop(uri)

        elif SYNC_USER_INFO_V4:
            self._consume_noti_sync_user_info_v4(res_obj)

        elif BEEN_DISCONNECTED:
            OFFLINE_ALERTS = "You have been disconnected" \
                "as someone has signed in with your ID on another computer." \
                "<br /><br />" \
                "Please note that if this was not intentional, some may have stolen your passwrod. "\
                "Please change your password."
            popup_error(self, OFFLINE_ALERTS)
            self.switch_presence_to_offline()
            #"Sign in again", "OK"

        elif ADD_BUDDY_REFUSED:
            uri, reason = i_parse_add_buddy_refused(body_dom)
            assert uri != reason
            logger.error("User (URI: %s) refused your add buddy application, reason: %s" % (uri, reason))

        elif ADD_BUDDY_APPLICATION:
            self._consume_add_buddy_application(res_obj)

        elif USER_DYNAMICS_CHANGED:
            pass