Esempio n. 1
0
        def listboxDoubleClick(event):
            print("双击")
            get_select_info = self.Ls_box1.get(self.Ls_box1.curselection())
            print(get_select_info)
            user_info = get_select_info.split("\\")

            u = user_db.USER()
            user = u.find_byQQ(user_info[0])
            print(user)
            self.user_data(user[0], len(user_info), True)
Esempio n. 2
0
 def run(self, sock, addr):
     print('Accept new connection from %s:%s...' % addr)
     userName = sock.recv(1024)  # 接受客户端发送的信息以1k作为单位这里接受到的信息为byte类型
     self.users[userName.decode("utf-8")] = sock  # 解码并储存用户的信息
     # print(users)
     printStr = "" + userName.decode(
         "utf-8") + "----连接成功" + "----" + self.get_time(
         ) + "\n"  # 在连接显示框中显示是否连接成功
     self.Tex_info.insert(END, printStr)  # END索引号表示在最后插入   INSERT索引表示在光标处插入
     # .configure(state='disabled')  # 操作信息窗口属性设为disable 此时窗口内容不可编辑  normal
     try:
         while True:
             if not self.is_start:
                 break
             rData = sock.recv(1024)  # 接受客户端发送的信息以1k作为单位这里接受到的信息为byte类型
             dataStr = rData.decode("utf-8")
             infolist = dataStr.split(":")  # 分割字符串从而得到所要发送的用户名和客户端所发送的信息
             # users[infolist[0]].send((userName.decode("utf-8") + "说" + infolist[1]).encode("utf"))
             if infolist[0] in self.users.keys():
                 if infolist[1] == "USER":
                     users = user_db.USER()
                     if infolist[2] == "find_byQQ":
                         user = users.find_byQQ(infolist[3])
                         print(user)
                         if len(user) > 0:
                             for u in user:
                                 account = u[3]
                                 password = u[4]
                             sendInfo = "LOGIN###" + account + "###" + password
                             self.users[infolist[0]].send(
                                 sendInfo.encode("utf-8"))
                             # 要发送信息的客户端向目标客户端发送信息
                         else:
                             sendInfo = "NOACCOUNT###"
                             self.users[infolist[0]].send(
                                 sendInfo.encode("utf-8"))
                 else:
                     self.users[infolist[0]].send(
                         (infolist[1]).encode("utf-8"))
             else:
                 print(str(infolist[0]) + ":该用户已离线")
                 self.users[userName.decode("utf-8")].send(
                     "OfflineInfo###用户已离线\n".encode("utf-8"))
     except ConnectionResetError as cr:
         print(cr)
         printStr = "" + userName.decode(
             "utf-8") + "----已断开连接" + "----" + self.get_time(
             ) + "\n"  # 在连接显示框中显示是否连接成功
         self.Tex_info.insert(END, printStr)
         sock.close()
         self.users.pop(userName.decode("utf-8"))
         print('Connection from %s:%s closed.' % addr)
Esempio n. 3
0
 def query_apply_list():
     global user_qq
     f = user_db.FRIEND()
     u = user_db.USER()
     apply_list = f.get_friend_apply(user_qq)
     if len(apply_list) > 0:
         for data in apply_list:
             qq = data[1]
             user = u.find_byQQ(qq)
             user_name = user[0][2]
             is_friend = ""
             if data[4] == 0:
                 is_friend += "\\已拒绝"
             self.Ls_box2.insert(END,
                                 str(qq) + "\\" + user_name + is_friend)
     else:
         self.Ls_box2.insert(END, "没有申请的用户")
Esempio n. 4
0
 def validateName(self, event):
     """
     验证昵称:
     """
     name = self.tx_nameVar.get()
     print(name)
     if name is None or name == "":
         self.La_name_validate["text"] = "昵称不能为空"
     else:
         pattern = re.compile("^[a-zA-Z0-9_\\-\u4e00-\u9fa5]+$")
         res = re.findall(pattern, name)
         if len(res) == 0 or len(name) == 0 or len(name) > 7:
             print("名称格式错误")
             self.La_name_validate["text"] = "名称格式有误"
         else:
             user = user_db.USER()
             if user.find_user_ByName(name):
                 self.La_name_validate["text"] = "该用户名已存在"
             else:
                 print("名称可以")
                 self.La_name_validate["text"] = ""
Esempio n. 5
0
 def query_data():
     global user_qq
     self_qq = user_qq
     u = user_db.USER()
     f = user_db.FRIEND()
     users = u.find_byQQ_like(search_info)
     if len(users) > 0 and search_info != "":
         for user in users:
             qq = user[3]
             if int(qq) == int(self_qq):
                 continue
             user_name = user[2]
             is_friend = ""
             friend = f.find_friend(self_qq, qq)
             if len(friend) > 0:
                 if friend[0][4] == 1:
                     is_friend += "\\已发送好友申请"
                 else:
                     is_friend += "\\该用户已经是好友"
             self.Ls_box1.insert(END, qq + "\\" + user_name + is_friend)
     else:
         self.Ls_box1.insert(END, "该用户不存在")
Esempio n. 6
0
 def Com_register_Cmd(self, event=None):
     '''
     注册按钮事件
     :param event:
     :return:
     '''
     validate = self.validate_all()
     if validate:
         is_ = self.C_clauseVar.get()  # 是否同意条款
         if is_ == '1':
             try:
                 user = user_db.USER()
                 user_info, qq = self.get_user_info()
                 user.add_user(user_info)
                 showinfo(title='提示', message="申请成功!你申请的QQ号是:" + str(qq))
                 self.start_lofin()
             except Exception as ex:
                 print("数据插入异常", ex)
                 showerror("info", "注册失败!")
         else:
             showerror("info", "请阅读并确认条款")
     else:
         showerror("info", "你输入的数据格式有误,请检查后重新输入")
Esempio n. 7
0
 def validatePhone(self, event):
     """
     验证手机号码:
         1.总长度11位
         2.第一位为1,第二位为[3-9],第3-11位[0-9]
     """
     phone = self.tx_phonVar.get()
     print(phone)
     if phone is None or phone == "":
         self.La_phone_validate["text"] = "手机号码不能为空"
     else:
         pattern = r"^1[3-9]\d{9}$"
         res = re.findall(pattern, phone)
         if len(res) == 0:
             print("手机号码不匹配")
             self.La_phone_validate["text"] = "手机号码错误"
         else:
             user = user_db.USER()
             if user.find_user_ByPhone(phone):
                 self.La_phone_validate["text"] = "手机号已存在"
             else:
                 self.La_phone_validate["text"] = ""
                 print("手机号码匹配", res)
Esempio n. 8
0
 def set_data():
     f = user_db.FRIEND()
     friends = f.get_friend_from_qq(user_qq)
     print(friends)
     u = user_db.USER()
     myid_num = 0
     myFriend_num = 0
     myFamily_num = 0
     myClassmate_num = 0
     myColleague_num = 0
     stranger_num = 0
     blacklist_num = 0
     for friend in friends:
         friend_qq = friend[2]
         user = u.find_byQQ(friend_qq)
         name = user[0][2]
         if friend[3] == 0:
             self.Tree.insert(myid,
                              myid_num,
                              name,
                              text=name,
                              values=friend_qq)
             myid_num += 1
         if friend[3] == 1:
             self.Tree.insert(myFriend,
                              myFriend_num,
                              name,
                              text=name,
                              values=friend_qq)
             myFriend_num += 1
         if friend[3] == 2:
             self.Tree.insert(myFamily,
                              myFamily_num,
                              name,
                              text=name,
                              values=friend_qq)
             myFamily_num += 1
         if friend[3] == 3:
             self.Tree.insert(myClassmate,
                              myClassmate_num,
                              name,
                              text=name,
                              values=friend_qq)
             myClassmate_num += 1
         if friend[3] == 4:
             self.Tree.insert(myColleague,
                              myColleague_num,
                              name,
                              text=name,
                              values=friend_qq)
             myColleague_num += 1
         if friend[3] == 5:
             self.Tree.insert(stranger,
                              stranger_num,
                              name,
                              text=name,
                              values=friend_qq)
             stranger_num += 1
         if friend[3] == 6:
             self.Tree.insert(blacklist,
                              blacklist_num,
                              name,
                              text=name,
                              values=friend_qq)
             blacklist_num += 1