Exemplo n.º 1
0
 def general_messages(rc1, sc1, dt1, data1, sip1, dip1):
     mes = message_pb2.GeneralMessages()
     mes.RC = rc1
     mes.SC = sc1
     mes.DT = dt1
     mes.DATA = data1
     mes.SIP = sip1
     mes.DIP = dip1
     return mes.SerializeToString()
Exemplo n.º 2
0
 def SignIn(self, str_1):
     json_operation = JO.JsonServer('0')
     print("check" + self.result)
     check_msg = PTB.GeneralMessages()
     check_msg = str_1
     if op.eq(check_msg.SC, "66666"):
         reply = QMessageBox.warning(self, "!", "注册成功", QMessageBox.Yes)
         json_operation.CreateJson(self.account, check_msg.DATA)
         quit()  # 注册成功
     if op.eq(check_msg.SC, "00100"):
         reply = QMessageBox.warning(self, "!", "账号不存在", QMessageBox.Yes)
         quit()  # 注册失败
Exemplo n.º 3
0
 def agree(self, mes_1):
     self.addFD.hide()
     json_operation = JO.JsonServer('0')
     print("check" + self.result)
     # check_msg = PTB.GeneralMessages()
     check_msg_data = PTB.GeneralMessages()
     check_msg = mes_1
     check_msg_data.ParseFromString(str.encode(check_msg.DATA))
     json_operation.add_friend_json(self.myname, check_msg_data.SIP,
                                    check_msg_data.DIP)
     send_message_1 = IntegrationMessage.general_messages(
         '000010', '66666', '0', check_msg.DATA, get_host_ip(), '127.0.0.1')
     self.sign_send.emit("00" + send_message_1)
Exemplo n.º 4
0
 def slot_recv(self, mes_1):
     print("recv now")
     # print(Event_msg)
     self.result = mes_1
     check_msg = PTB.GeneralMessages()
     check_msg.ParseFromString(str.encode(mes_1[2:]))
     if op.eq(check_msg.RC, "010010") or op.eq(check_msg.RC, "010011"):
         if op.eq(mes_1[0:2], "00"):
             if op.eq(check_msg.RC, '010010'):
                 if op.eq(check_msg.SC, "00000"):
                     self.AddFDRecv(check_msg)
                 else:
                     self.AddFDSend(check_msg)
             if op.eq(check_msg.RC, '010011'):
                 self.DelFD(check_msg)
Exemplo n.º 5
0
 def slot_recv(self, mes_1):
     print("recv now")
     # print(Event_msg)
     self.result = mes_1
     check_msg = PTB.GeneralMessages()
     check_msg.ParseFromString(str.encode(mes_1[2:]))
     if op.eq(check_msg.RC, "010001") or op.eq(check_msg.RC, "011001"):
         if op.eq(mes_1[0:2], "00"):
             if op.eq(check_msg.RC, "010001"):
                 self.SignUp(check_msg)
             if op.eq(check_msg.RC, "011001"):
                 self.SignIn(check_msg)
     else:
         reply = QMessageBox.warning(self, "!", "Isn't the right message",
                                     QMessageBox.Yes)
Exemplo n.º 6
0
 def AddFDSend(self, mes_1):
     self.addfriend_name = self.lineEdit.text()
     json_operation = JO.JsonServer('0')
     print("check" + self.result)
     check_msg = PTB.GeneralMessages()
     check_msg = mes_1
     if op.eq(check_msg.SC, "66666"):
         reply = QMessageBox.warning(self.listWidget, "!", "添加成功",
                                     QMessageBox.Yes)
         json_operation.UpdateJson(self.addfriend_name, check_msg.DATA)
         self.load_friend()
         quit()  # 注册成功
     if op.eq(check_msg.SC, "00010"):
         reply = QMessageBox.warning(self.listWidget, "!", "拒绝申请",
                                     QMessageBox.Yes)
         quit()  # 注册失败
Exemplo n.º 7
0
 def SignUp(self, str_1):
     json_operation = JO.JsonServer('0')
     print("check" + self.result)
     check_msg = PTB.GeneralMessages()
     check_msg = str_1
     if op.eq(check_msg.SC, "66666"):
         reply = QMessageBox.warning(self, "!", "登录成功", QMessageBox.Yes)
         json_operation.UpdateJson(self.account, check_msg.DATA)
         self.close()  # 登录成功
         self.idnewclose()  # 跳转到聊天界面
     if op.eq(check_msg.SC, "00001"):
         reply = QMessageBox.warning(self, "!", "账号或密码输入错误",
                                     QMessageBox.Yes)
         quit()  # 登录失败
     if op.eq(check_msg.SC, "00100"):
         reply = QMessageBox.warning(self, "!", "账号不存在", QMessageBox.Yes)
         quit()  # 登录失败
Exemplo n.º 8
0
 def slot_recv(self, msg):  #接受从服务区发来的消息
     check_msg = PTB.GeneralMessages()
     check_msg.ParseFromString(str.encode(msg[2:]))
     if op.eq(check_msg.RC, "010000"):
         if op.eq(msg[0:2], "00"):
             check_msg_data = PTB.gm_signup()
             check_msg_data.ParseFromString(check_msg.DATA)
             if op.eq(check_msg_data.SIP, self.friendname):
                 self.history_message.append(
                     'From' + self.friendname +
                     time.asctime(time.localtime(time.time())) + '\n' +
                     check_msg_data.DIP)
             else:
                 self.history_message.append(
                     "friend's message " + 'From' + self.friendname +
                     time.asctime(time.localtime(time.time())) + '\n' +
                     check_msg_data.DIP)
     """
Exemplo n.º 9
0
 def get_message(mes):
     mes_1 = mes
     mes_2 = message_pb2.GeneralMessages()
     mes_2.ParseFromString(mes[2:])
     if op.eq(mes_1[0:1], '00'):
         return mes_2.RC, mes_2.SC, mes_2.DATA, mes_2.SIP, mes_2.DIP