Ejemplo n.º 1
0
    def update_addrs(self,index):
        # print("come in update_addrs")
        self.sipaddrcomboBox.clear()
        # friend_l=user.data_dict.get("usr",None)
        friend_l=user.get_data_dict("usr")
        if friend_l:
            if index==0:
                user.set_info_dict("PID","0002")
                for l in friend_l:
                    if l.get("type",None)=="gateway":
                        self.sipaddrcomboBox.addItem(l.get("friend"))

            elif index==1:
                user.set_info_dict("PID","0008")
                for l in friend_l:
                    if l.get("type",None)=="mirror":
                        self.sipaddrcomboBox.addItem(l.get("friend"))
            elif index==2:
                user.set_info_dict("PID","0003")
                for l in friend_l:
                    if l.get("type",None)=="coordin_zigbee":
                        self.sipaddrcomboBox.addItem(l.get("friend"))
            elif index==3:
                user.set_info_dict("PID","0001")
                for l in friend_l:
                    if l.get("type",None)=="icool":
                        self.sipaddrcomboBox.addItem(l.get("friend"))
            elif index==4:
                user.set_info_dict("PID","0004")
                for l in friend_l:
                    if l.get("type",None)=="aqms":
                        self.sipaddrcomboBox.addItem(l.get("friend"))
        else:
            QtGui.QMessageBox.about(self,"Info","no friends")
Ejemplo n.º 2
0
 def search_devices(self):
     self.ipcomboBox.clear()
     if self.username2lineEdit.text():
         user.set_info_dict("USERNAME",str(self.username2lineEdit.text()))
         SearchDevice().search()
         devices_list=user.get_data_dict("search")
         if devices_list:
             dev_list=function.search_devices_by_type(devices_list)
             if dev_list:
                 for l in dev_list:
                     self.ipcomboBox.addItem(l.get("server_ip"))
                 self.update_device_info(0)
     else:
         QtGui.QMessageBox.about(self,"Info",_fromUtf8("please filling in username"))
Ejemplo n.º 3
0
 def okbutton_updataUI(self):
     # print("come in set_sipaddr")
     sipaddr=self.sipaddrcomboBox.currentText()
     user.set_info_dict("SIPADDR",str(sipaddr))
     if sipaddr=="":
         QtGui.QMessageBox.about(self,"Info",_fromUtf8("please choose sipaddr"))
     else:
         self.devlisttextBrowser.clear()
         query_instance=QueryMsg()# 初始化QueryMsg实例
         query_instance.get_dev_status()
         self.display_combs()
         self.display_devices()
         self.control_thread=controlThread()
         self.control_thread.start()#向服务器发送控制cmd线程
         self.sendButton.clicked.connect(self.send_control_cmd)
Ejemplo n.º 4
0
 def update_device_type(self,index):
     # print("come in update_port")
     if index==0: #gateway
         user.set_info_dict("PID","0002")
     elif index==1: #zigbee
         user.set_info_dict("PID","0003")
     elif index==2: #mirror
         user.set_info_dict("PID","0008")
Ejemplo n.º 5
0
 def update_device_info(self,index):
     # print("come in update device info")
     SERVER_IP=str(self.ipcomboBox.currentText())
     user.set_info_dict("SERVER_IP",SERVER_IP)
     # print("server_ip===",user.get_info_dict("SERVER_IP"))
     user.set_info_dict("getHttp","http://{0}/lua/getall".format(SERVER_IP))
     user.set_info_dict("postHttp","http://{0}/lua".format(SERVER_IP))
     devices_list=user.get_data_dict("search")
     if devices_list:
         dev_list=function.search_devices_by_type(devices_list)
         device=dev_list[index]
         SERVER_PORT=device.get("server_port",None)
         if SERVER_PORT:
             user.set_info_dict("SERVER_PORT",SERVER_PORT)
         # print("server_port===", SERVER_PORT)
         data_length=device.get("data_length",None)
         if data_length:
             user.set_info_dict("data_length",data_length)
         # print("data_length===",data_length)
         SIPADDR=device.get("sip_addr",None)
         if SIPADDR:
             user.set_info_dict("SIPADDR",SIPADDR)
Ejemplo n.º 6
0
    def login(self):
        """
        Net_flag=0 #走内网
        Net_flag=1 #走公网
        默认 Net_flag=1
        """
        if self.publicradioButton.isChecked() or self.netradioButton.isChecked():
            if self.publicradioButton.isChecked():
                # print("choose public network")
                # user.Net_flag=1
                user.set_info_dict("Net_flag",1)
            elif self.netradioButton.isChecked():
                # print("choose local network")
                # user.Net_flag=0 #走内网
                user.set_info_dict("Net_flag",0)

            # print(user.Net_flag)
            # print(user.get_info_dict("Net_flag"))
            if user.get_info_dict("Net_flag")==1: #走公网
                try:
                    Server_IP=socket.gethostbyname(HostName)
                except Exception as e:
                    Server_IP="139.159.224.188"
                # POST_SECUREPORT_URL="http://112.74.28.12/secureport"
                # POST_MSG_URL="http://112.74.28.12/postmsg"
                # GET_URL="http://112.74.28.12/getmsg"
                finally:
                    user.set_info_dict("POST_SECUREPORT_URL","http://{0}/secureport".format(Server_IP))
                    user.set_info_dict("POST_MSG_URL","http://{0}/postmsg".format(Server_IP))
                    user.set_info_dict("GET_URL","http://{0}/getmsg".format(Server_IP))
                    user.set_info_dict("USERNAME",str(self.usernameEdit.text()))
                    password=str(self.passwordEdit.text())
                    user.set_info_dict("PASSWORD",password)
                    if len(password)>=6 and len(password)<=16:
                        msg=LoginManage().login()
                        if msg=="Login success":
                            #停止内网线程
                            if self.getRecvall_thread_l:
                                # print("stop getRecvall_thread_l thread")
                                self.getRecvall_thread_l.stop()

                            self.key_thread_p=getAesKeyThread()
                            self.key_thread_p.start() #动态获取密钥线程
                            time.sleep(0.1)
                            self.get_thread_p=getMsgThread()
                            self.get_thread_p.start() #向服务器get请求线程

                            QueryMsg().get_all_friends() #向服务器get_friends
                            self.connect(self.pidcomboBox,QtCore.SIGNAL('activated(int)'),self.update_addrs)
                            self.update_addrs(0) #设置默认值
                            self.okButton.clicked.connect(self.okbutton_updataUI)
                            self.logoutButton.clicked.connect(self.logout)
                        QtGui.QMessageBox.about(self,"Info",_fromUtf8(msg))
                    else:
                        QtGui.QMessageBox.about(self,"Info",_fromUtf8(str("password length is 6 to 16")))

            else:  #走内网
                connect_flag=1
                if user.get_info_dict("SERVER_PORT")==9101: #室内机通讯---tcp socket;网关通讯---http(get,post)
                    connect_flag=user.create_tcp_socket(user.get_info_dict("SERVER_IP"),user.get_info_dict("SERVER_PORT"))
                    # print(connect_flag)
                if connect_flag:
                    self.getRecvall_thread_l=getRecvallThread() #接受服务器信息线程
                    self.getRecvall_thread_l.start()
                    login_flag=SendRecvManage().login()
                    if login_flag:
                        QtGui.QMessageBox.about(self,"Info","login success")
                        #停止公网有关线程
                        if self.get_thread_p:
                            # print("stop get_thread_p thread")
                            self.get_thread_p.stop()
                        if self.key_thread_p:
                            # print("stop key_thread_p thread")
                            self.key_thread_p.stop()
                        query_manage=QueryMsg()
                        query_manage.combination_control_query()
                        query_manage.room_query()
                        query_manage.devices_query()
                        time.sleep(2)
                        self.devlisttextBrowser.clear()
                        self.combstextBrowser.clear()
                        self.display_combs()
                        self.display_devices()
                    else:
                        queue.logout_Q.put("login_failure")
                        self.getRecvall_thread_l.stop()
                        self.getResult_thread.stop()
                else:
                    QtGui.QMessageBox.about(self,"Info","tcp connect failure")
        else:
            QtGui.QMessageBox.about(self,"Info","please choose login mode")