コード例 #1
0
ファイル: ServerCallback.cs プロジェクト: zstanecic/TeamTalk5
        void ttserver_OnUserLogin(ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, ref UserAccount lpUserAccount)
        {
            String str = String.Format("Login attempt from IP {0}, username={1}, password={2}",
                                       lpUser.szIPAddress, lpUserAccount.szUsername,
                                       lpUserAccount.szPassword);

            Console.WriteLine(str);

            foreach (UserAccount u in useraccounts)
            {
                // validate user account
                if (u.szUsername.Equals(lpUserAccount.szUsername) &&
                    u.szPassword.Equals(lpUserAccount.szPassword))
                {
                    // manually copy every field
                    lpUserAccount.szUsername  = u.szUsername;
                    lpUserAccount.szPassword  = u.szPassword;
                    lpUserAccount.uUserRights = u.uUserRights;
                    lpUserAccount.uUserType   = UserType.USERTYPE_ADMIN;
                    lpClientErrorMsg.nErrorNo = (int)ClientError.SUCCESS;
                    return;
                }
            }

            // login rejected
            lpClientErrorMsg.nErrorNo   = (int)ClientError.CMDERR_INVALID_ACCOUNT;
            lpClientErrorMsg.szErrorMsg = "Invalid username or password";
        }
コード例 #2
0
ファイル: ServerCallback.cs プロジェクト: zstanecic/TeamTalk5
        void ttserver_OnUserDeleteUserAccount(ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, string szUsername)
        {
            String str = String.Format("User {0} is deleting useraccount {1}",
                                       lpUser.szUsername, szUsername);

            Console.WriteLine(str);

            switch (lpUser.uUserType)
            {
            case UserType.USERTYPE_ADMIN:
                UserAccount ua = new UserAccount();
                foreach (UserAccount u in useraccounts)
                {
                    if (u.szUsername.Equals(szUsername))
                    {
                        ua = u;
                    }
                }
                useraccounts.Remove(ua);
                lpClientErrorMsg.nErrorNo = (int)ClientError.SUCCESS;
                break;

            case UserType.USERTYPE_DEFAULT:
                lpClientErrorMsg.nErrorNo   = (int)ClientError.CMDERR_NOT_AUTHORIZED;
                lpClientErrorMsg.szErrorMsg = "Not allowed!";
                break;

            default:
                break;
            }
        }
コード例 #3
0
ファイル: UserAccountsDlg.cs プロジェクト: tla001/TeamTalk5
 void ttclient_OnCmdError(int nCmdID, ClientErrorMsg clienterrormsg)
 {
     //clear create account if unsuccessful
     if (nCmdID == create_cmdid)
     {
         account_create = new UserAccount();
         MessageBox.Show(clienterrormsg.szErrorMsg);
     }
 }
コード例 #4
0
ファイル: LoginDlg.cs プロジェクト: jbzhang99/TeamTalk5
        void ttclient_OnCmdError(int nCmdID, ClientErrorMsg clienterrormsg)
        {
            if (nCmdID == login_cmdid)
            {
                login_cmdid             = 0; //reset cmdid
                button1.Enabled         = true;
                nickTextBox.Enabled     = true;
                usernameTextBox.Enabled = true;
                passwdTextBox.Enabled   = true;

                MessageBox.Show(clienterrormsg.szErrorMsg);
            }
        }
コード例 #5
0
ファイル: ServerCallback.cs プロジェクト: zstanecic/TeamTalk5
        void ttserver_OnUserAddServerBan(ref ClientErrorMsg lpClientErrorMsg, ref User lpBanner, ref User lpBanee)
        {
            UserAccount ua = getUserAccount(lpBanner.szUsername);

            if ((ua.uUserRights & UserRight.USERRIGHT_BAN_USERS) != 0)
            {
                lpClientErrorMsg.nErrorNo = (int)ClientError.SUCCESS;
                banned_ipaddr.Add(lpBanee.szIPAddress);
            }
            else
            {
                lpClientErrorMsg.nErrorNo   = (int)ClientError.CMDERR_NOT_AUTHORIZED;
                lpClientErrorMsg.szErrorMsg = "Not allowed!";
            }
        }
コード例 #6
0
ファイル: ServerCallback.cs プロジェクト: zstanecic/TeamTalk5
        void ttserver_OnUserChangeNickname(ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, string szNewNickname)
        {
            String str = String.Format("User {0} is requesting to change nickname to {1}",
                                       lpUser.szNickname, szNewNickname);

            Console.WriteLine(str);

            if (szNewNickname.IndexOf("crap") >= 0)
            {
                lpClientErrorMsg.nErrorNo   = 4567;
                lpClientErrorMsg.szErrorMsg = "Nickname not allowed";
            }
            else
            {
                lpClientErrorMsg.nErrorNo = (int)ClientError.CMDERR_SUCCESS;
            }
        }
コード例 #7
0
ファイル: ServerCallback.cs プロジェクト: zstanecic/TeamTalk5
        void ttserver_OnUserChangeStatus(ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, ref int nNewStatusMode, string szNewStatusMsg)
        {
            String str = String.Format("User {0} is requesting to change status message to {1}",
                                       lpUser.szNickname, szNewStatusMsg);

            Console.WriteLine(str);

            if (szNewStatusMsg.IndexOf("crap") >= 0)
            {
                lpClientErrorMsg.nErrorNo   = 4568;
                lpClientErrorMsg.szErrorMsg = "Status not allowed";
            }
            else
            {
                lpClientErrorMsg.nErrorNo = (int)ClientError.CMDERR_SUCCESS;
            }
        }
コード例 #8
0
 void TeamTalkSrv_OnUserLoginCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, ref UserAccount lpUserAccount)
 {
     if (OnUserLogin != null)
     {
         OnUserLogin(ref lpClientErrorMsg, ref lpUser, ref lpUserAccount);
     }
 }
コード例 #9
0
 void TeamTalkSrv_OnUserAddServerBanCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpBanner, ref User lpBanee)
 {
     if (OnUserAddServerBan != null)
     {
         OnUserAddServerBan(ref lpClientErrorMsg, ref lpBanner, ref lpBanee);
     }
 }
コード例 #10
0
 void TeamTalkSrv_OnUserAddServerBanIPAddressCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpBanner, string szIPAddress)
 {
     if (OnUserAddServerBanIPAddress != null)
     {
         OnUserAddServerBanIPAddress(ref lpClientErrorMsg, ref lpBanner, szIPAddress);
     }
 }
コード例 #11
0
 void TeamTalkSrv_OnUserDeleteUserAccountCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, string szUsername)
 {
     if (OnUserDeleteUserAccount != null)
     {
         OnUserDeleteUserAccount(ref lpClientErrorMsg, ref lpUser, szUsername);
     }
 }
コード例 #12
0
 void TeamTalk5Srv_OnUserChangeNicknameCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, string szNewNickname)
 {
     if (OnUserChangeNickname != null)
     {
         OnUserChangeNickname(ref lpClientErrorMsg, ref lpUser, szNewNickname);
     }
 }
コード例 #13
0
 void TeamTalk5Srv_OnUserChangeStatusCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, ref int nNewStatusMode, string szNewStatusMsg)
 {
     if (OnUserChangeStatus != null)
     {
         OnUserChangeStatus(ref lpClientErrorMsg, ref lpUser, ref nNewStatusMode, szNewStatusMsg);
     }
 }
コード例 #14
0
 static void ttclient_OnCmdError(int nCmdID, ClientErrorMsg clienterrormsg)
 {
     Console.WriteLine("Command with ID #{0} failed with the following error: {1}",
                       nCmdID, clienterrormsg.szErrorMsg);
 }