Beispiel #1
0
 def updateAllLists(self):
     self.currentUser = userDB.load_user_info(None, self.currentUser.id,
                                              'user_id')
     self.currentGroup = userDB.load_group_info(self.currentGroup.id)
     self.page.initGroupList(self.currentUser.groups)
     self.page.initFriendList(self.currentUser)
     self.page.updateGroupList(self.currentUser.groups)
     self.page.updateFriendList(self.currentUser)
     self.ChangeGroupChat(self.currentGroup.id, updateName=True)
Beispiel #2
0
 def leaveCurrentGroup(self):
     if (self.currentGroup.id == '00000000'):
         print("You cannot leave General group!")
         return
     else:
         print("Leaving current group...")
         userDB.leave_group(self.currentGroup.id, self.currentUser.id)
         self.currentUser = userDB.load_user_info(None, self.currentUser.id,
                                                  'user_id')
         self.page.updateGroupList(self.currentUser.groups)
         self.currentGroup = userDB.load_group_info('00000000')
         self.ChangeGroupChat(self.currentGroup.id)
Beispiel #3
0
    def addFriend(self, AddFriendPopup):
        newFriend = User()

        newFriend.name = self.addFriendOpen.new_friend_name.get()

        if (newFriend.id not in self.currentUser.friends):
            if (userDB.checkAccExistence(newFriend.name, 'username')
                    and newFriend.name !=
                    self.currentUser.name):  #if the account is found, add
                # append to user friends list
                newFriend = userDB.load_user_info(newFriend.name)
                groupID = userDB.create_group_id()

                print("Friend chat ID: %s" % groupID)

                userDB.join_group(groupID, newFriend.name, self.currentUser.id,
                                  'dm')
                userDB.join_group(groupID, self.currentUser.name, newFriend.id,
                                  'dm')

                self.currentUser = userDB.load_user_info(
                    None, self.currentUser.id, 'user_id')
                print("My friends!!!!!!!!!!!!!!!!!!")
                print(self.currentUser.friends)
                AddFriendPopup.friendlabel.config(text="User found!",
                                                  foreground="yellow")
                self.page.updateFriendList(self.currentUser)

                ## UPDATE NEW FRIEND'S LIST IF THEY ARE LOGGED ON
                Client.updateAllGroupMembers(self, self,
                                             self.currentGroup.member_ids)
            else:
                AddFriendPopup.friendlabel.config(text="User not found!",
                                                  foreground="red")
        else:
            AddFriendPopup.friendlabel.config(text="Friend already added!",
                                              foreground="red")
Beispiel #4
0
    def insertNewGroup(self, CreateGroupPopup):
        newName = self.createGroupOpen.new_group_name.get()

        if (newName == ""):
            self.createGroupOpen.glabel.config(
                text="Please enter a group name!", foreground="red")
            return

        else:
            group_id = userDB.create_group_id()
            userDB.join_group(group_id, newName, self.currentUser.id)
            self.currentUser = userDB.load_user_info(None, self.currentUser.id,
                                                     'user_id')
            self.createGroupOpen.glabel.config(text=("Created Group! ID: " +
                                                     str(group_id)),
                                               foreground="yellow")
            self.page.updateGroupList(self.currentUser.groups)
Beispiel #5
0
    def logInClick(
            self):  # loads a user and their groups on a successful login
        if ((self.page.Name_entry.get() == "")
                or (self.page.Pass_entry.get() == "")
                or (self.page.Name_entry.get() == "Username")
                or (self.page.Pass_entry.get() == "Password")):
            self.page.elabel.config(text="Incomplete Sign In!")
        elif (userDB.login_user(self.page.Name_entry.get(),
                                self.page.Pass_entry.get()) == 0):
            self.page.elabel.config(
                text=
                "You are not currently registered!\n Please Register first.")
        elif (userDB.login_user(self.page.Name_entry.get(),
                                self.page.Pass_entry.get()) == 1):
            self.page.elabel.config(text="")
            self.currentUser = userDB.load_user_info(
                self.page.Name_entry.get())

            # unless the user checks 'Remember Me', delete text entries
            if (self.page.rememberUser.get() == 0):
                self.page.Name_entry.delete(0, 'end')
                self.page.Pass_entry.delete(0, 'end')

            self.switch_page(ChatPage)
            self.page.initGroupList(self.currentUser.groups)
            self.page.initFriendList(self.currentUser)
            self.changeColors(self.currentUser.theme)

            if self.newLog is 0:
                self.client = threading.Thread(target=Client,
                                               args=(
                                                   self,
                                                   self.currentUser,
                                                   self.userIP,
                                               ))
                self.client.daemon = True
                self.client.start()

            self.currentGroup = userDB.load_group_info('00000000')
            self.page.updateGroupList(self.currentUser.groups)
            self.page.updateFriendList(self.currentUser)
            self.ChangeGroupChat(self.currentGroup.id, login=True)

        elif (userDB.login_user(self.page.Name_entry.get(),
                                self.page.Pass_entry.get()) == 2):
            self.page.elabel.config(text="Login Information Invalid!")
Beispiel #6
0
    def enterP(self, event):  # Registers 'enter' as a way to sign in.
        self.page.sin.focus_set()
        if ((self.page.Name_entry.get() == "")
                or (self.page.Pass_entry.get() == "")
                or (self.page.Name_entry.get() == "Username")
                or (self.page.Pass_entry.get() == "Password")):
            self.page.elabel.config(text="Incomplete Sign In!")
        elif (userDB.login_user(self.page.Name_entry.get(),
                                self.page.Pass_entry.get()) == 0):
            self.page.elabel.config(
                text=
                "You are not currently registered!\n Please register first.")
        elif (userDB.login_user(self.page.Name_entry.get(),
                                self.page.Pass_entry.get()) == 1):
            self.page.elabel.config(text="")
            self.currentUser = userDB.load_user_info(
                self.page.Name_entry.get())

            if (self.page.rememberUser.get() == 0):
                self.page.Name_entry.delete(0, 'end')
                self.page.Pass_entry.delete(0, 'end')

            self.switch_page(ChatPage)
            self.page.initGroupList(self.currentUser.groups)
            self.page.initFriendList(self.currentUser)
            self.changeColors(self.currentUser.theme)

            if self.newLog is 0:
                self.client = threading.Thread(target=Client,
                                               args=(
                                                   self,
                                                   self.currentUser,
                                                   self.userIP,
                                               ))
                self.client.daemon = True
                self.client.start()

            self.currentGroup = userDB.load_group_info('00000000')
            self.page.updateGroupList(self.currentUser.groups)
            self.page.updateFriendList(self.currentUser)
            self.ChangeGroupChat(self.currentGroup.id, login=True)

        elif (userDB.login_user(self.page.Name_entry.get(),
                                self.page.Pass_entry.get()) == 2):
            self.page.elabel.config(text="Login Information Invalid!")
Beispiel #7
0
    def joinNewGroup(self, JoinGroupPopup):
        groupID = self.joinGroupOpen.join_group_id.get()

        if (groupID not in self.currentUser.groups):
            if (userDB.checkGroupExistence(groupID) == True):
                groupName = userDB.get_group_name(groupID)
                userDB.join_group(groupID, groupName, self.currentUser.id)
                self.currentUser = userDB.load_user_info(
                    None, self.currentUser.id, 'user_id')
                self.joinGroupOpen.jlabel.config(text="Joined Group!",
                                                 foreground="yellow")
                self.page.updateGroupList(self.currentUser.groups)
            else:
                self.joinGroupOpen.jlabel.config(text="Group does not exist!",
                                                 foreground="red")

        else:
            self.joinGroupOpen.jlabel.config(text="Already in this group!",
                                             foreground="red")
Beispiel #8
0
    def changeGroupInfo(self, GroupSettingsPopup):
        if (self.currentGroup.id == '00000000'):
            GroupSettingsPopup.errLabel.config(
                text="You cannot modify the general group!", foreground="red")
            return
        elif (GroupSettingsPopup.changeGroupNameInput.get() != ""):
            userDB.update_group_info(
                GroupSettingsPopup.changeGroupNameInput.get(), 'group_name',
                self.currentGroup.id)
            self.currentUser = userDB.load_user_info(None, self.currentUser.id,
                                                     'user_id')
            self.currentGroup = userDB.load_group_info(self.currentGroup.id)
            self.page.updateGroupList(self.currentUser.groups)
            self.ChangeGroupChat(self.currentGroup.id, updateName=True)

            ## UPDATE THE LISTS OF ALL LOGGED IN USERS IN THE LIST
            Client.updateAllGroupMembers(self, self,
                                         self.currentGroup.member_ids)

        else:
            GroupSettingsPopup.errLabel.config(
                text="Please enter a new group name!", foreground="red")
Beispiel #9
0
 def Textbg(self, AccSettingsPopup):
     self.currentUser.textbg = AccSettingsPopup.defaultV.get()
     userDB.update_user_info(AccSettingsPopup.defaultV.get(), 'textbg',
                             self.currentUser.id)
     self.currentUser = userDB.load_user_info(None, self.currentUser.id,
                                              'user_id')
Beispiel #10
0
    def changeUserAndPass(self, AccSettingsPopup):
        self.accSettingsOpen.errLabel.config(text="", foreground="red")
        self.newuser = ""
        self.newpass = ""
        self.newemail = ""
        self.olduser = self.currentUser.name
        self.oldemail = self.currentUser.email
        self.oldpass = AccSettingsPopup.oldPassEntry.get()
        self.currentID = self.currentUser.id

        #Check for valid password, if it is valid, we can change settings
        if (userDB.login_user(self.currentUser.name, self.oldpass) == 2):
            self.accSettingsOpen.errLabel.config(text="Invalid Password!")
            return
        else:
            # Check new password input
            if AccSettingsPopup.changePasswordInput.get() != "":
                if AccSettingsPopup.confirmPasswordInput.get(
                ) != AccSettingsPopup.changePasswordInput.get():
                    self.accSettingsOpen.errLabel.config(
                        text="New Password does not match confirmation")
                    return
                else:
                    #if new passwords match, set newpass
                    self.newpass = AccSettingsPopup.changePasswordInput.get()
                    self.accSettingsOpen.errLabel.config(
                        text="Settings Changed", foreground="green")
                    userDB.update_user_info(self.newpass, 'password',
                                            self.currentUser.id)
                    self.currentUser = userDB.load_user_info(
                        None, self.currentUser.id, 'user_id')

            # Check new email input
            if AccSettingsPopup.changeEmailInput.get() != "":
                self.newemail = AccSettingsPopup.changeEmailInput.get()

                if (self.newemail == self.oldemail):
                    self.accSettingsOpen.errLabel.config(
                        text="E-Mail unchanged", foreground="yellow")
                if (userDB.check_valid_email(self.newemail) == None):
                    self.accSettingsOpen.errLabel.config(
                        text="E-Mail already registered", foreground="green")
                    return
                elif (userDB.check_valid_email(self.newemail) == True):
                    userDB.update_user_info(self.newemail, 'email',
                                            self.currentUser.id)
                    #self.currentUser = userDB.load_user_info(None, self.currentUser.id[0], 'user_id')
                else:
                    self.accSettingsOpen.errLabel.config(
                        text="Invalid or already registered E-Mail Address.")
                    return

            #Check username input
            if AccSettingsPopup.changeUserNameInput.get() != "":
                self.newuser = AccSettingsPopup.changeUserNameInput.get()

                if (self.newuser == self.olduser):
                    self.accSettingsOpen.errLabel.config(
                        text="Username unchanged", foreground="yellow")
                    return

                if (userDB.checkAccExistence(self.newuser, 'username')
                    ):  #if the new username is already registered
                    self.accSettingsOpen.errLabel.config(
                        text=
                        "Username is already taken.\nPlease choose a different username"
                    )
                    return

                userDB.update_user_info(self.newuser, 'username',
                                        self.currentUser.id, self.olduser)
                self.accSettingsOpen.errLabel.config(text="Settings Changed",
                                                     foreground="green")
                Client.updateAllGroupMembers(self, self,
                                             self.currentUser.friends)

        #Call changes with updated information
        self.currentUser = userDB.load_user_info(None, self.currentUser.id,
                                                 'user_id')