예제 #1
0
        void UpdateControls()
        {
            ClientFlag flags = ttclient.Flags;
            UserType myusertype = ttclient.UserType;
            ServerProperties srvprop = new ServerProperties();

            if ((flags & ClientFlag.CLIENT_CONNECTED) != ClientFlag.CLIENT_CONNECTED)
                ResetControls();

            ttclient.GetServerProperties(ref srvprop);

            int userid = channels.GetSelectedUser();
            int channelid = channels.GetSelectedChannel();

            connectToolStripMenuItem.Text =
                ((flags & ClientFlag.CLIENT_CONNECTED) == ClientFlag.CLIENT_CONNECTED ||
                (flags & ClientFlag.CLIENT_CONNECTING) == ClientFlag.CLIENT_CONNECTING) ? "Disconnect" : "Connect";

            changeNicknameToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            changeStatusModeToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            enableDesktopSharingToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            enableDesktopSharingToolStripMenuItem.Checked = flags.HasFlag(ClientFlag.CLIENT_DESKTOP_ACTIVE);

            muteAllToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_SNDOUTPUT_READY);
            muteAllToolStripMenuItem.Checked = flags.HasFlag(ClientFlag.CLIENT_SNDOUTPUT_MUTE);
            storeAudioToDiskToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            storeAudioToDiskToolStripMenuItem.Checked = settings.audiofolder.Length > 0;

            User user = new User();
            if (userid > 0 && ttclient.GetUser(userid, ref user))
            {
                Debug.Assert((flags & ClientFlag.CLIENT_AUTHORIZED) == ClientFlag.CLIENT_AUTHORIZED);
                viewUserInformationToolStripMenuItem.Enabled = true;
                sendMessageToolStripMenuItem.Enabled = true;
                opDeOpToolStripMenuItem.Enabled = true;
                mutevoiceToolStripMenuItem.Enabled = true;
                mutevoiceToolStripMenuItem.Checked = user.uUserState.HasFlag(UserState.USERSTATE_MUTE_VOICE);
                kickToolStripMenuItem.Enabled = true;
                kickAndBanToolStripMenuItem.Enabled = true;
                subscriptionsToolStripMenuItem.Enabled = true;
                allowDesktopAccessToolStripMenuItem.Enabled = true;
                allowDesktopAccessToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_DESKTOPINPUT);

                userMessagesToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_USER_MSG);
                channelMessagesToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_CHANNEL_MSG);
                broadcastMessagesToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_BROADCAST_MSG);
                voiceToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_VOICE);
                videocaptureToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_VIDEOCAPTURE);
                desktopToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_DESKTOP);
                desktopAccessToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_DESKTOPINPUT);
                interceptUserMessagesToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_INTERCEPT_USER_MSG);
                interceptUserMessagesToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
                interceptChannelMessagesToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_INTERCEPT_CHANNEL_MSG);
                interceptChannelMessagesToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
                interceptvoiceToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_INTERCEPT_VOICE);
                interceptvoiceToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
                interceptvideocaptureToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_INTERCEPT_VIDEOCAPTURE);
                interceptvideocaptureToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
                interceptDesktopToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_INTERCEPT_DESKTOP);
                interceptDesktopToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);

                advancedToolStripMenuItem.Enabled = true;

                Channel userchan = new Channel();
                if (ttclient.GetChannel(user.nChannelID, ref userchan))
                {
                    allowVoiceTransmissionToolStripMenuItem.Checked = userchan.GetTransmitStreamTypes(user.nUserID).HasFlag(StreamType.STREAMTYPE_VOICE);
                    allowVideoTransmissionToolStripMenuItem.Checked = userchan.GetTransmitStreamTypes(user.nUserID).HasFlag(StreamType.STREAMTYPE_VIDEOCAPTURE);
                    allowVoiceTransmissionToolStripMenuItem.Enabled = userchan.uChannelType.HasFlag(ChannelType.CHANNEL_CLASSROOM);
                    allowVideoTransmissionToolStripMenuItem.Enabled = userchan.uChannelType.HasFlag(ChannelType.CHANNEL_CLASSROOM);
                }
            }
            else
            {
                viewUserInformationToolStripMenuItem.Enabled = false;
                sendMessageToolStripMenuItem.Enabled = false;
                opDeOpToolStripMenuItem.Enabled = false;
                mutevoiceToolStripMenuItem.Enabled = false;
                kickToolStripMenuItem.Enabled = false;
                kickAndBanToolStripMenuItem.Enabled = false;
                allowDesktopAccessToolStripMenuItem.Enabled = false;
                subscriptionsToolStripMenuItem.Enabled = false;
                advancedToolStripMenuItem.Enabled = false;
                allowVoiceTransmissionToolStripMenuItem.Enabled = false;
                allowVideoTransmissionToolStripMenuItem.Enabled = false;
            }

            Channel chan = new Channel();
            if (channelid > 0 && ttclient.GetChannel(channelid, ref chan))
            {
                Debug.Assert((flags & ClientFlag.CLIENT_AUTHORIZED) == ClientFlag.CLIENT_AUTHORIZED);
                joinChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                joinNewChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                viewChannelInformationToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                createChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                updateChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                deleteChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                streamMediaFileToChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            }
            else
            {
                joinChannelToolStripMenuItem.Enabled = false;
                joinNewChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                viewChannelInformationToolStripMenuItem.Enabled = false;
                createChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                updateChannelToolStripMenuItem.Enabled = false;
                deleteChannelToolStripMenuItem.Enabled = false;
                streamMediaFileToChannelToolStripMenuItem.Enabled = false;
            }

            listUserAccountsToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
            serverPropertiesToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            saveConfigurationToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
            broadcastTestMessageToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            serverStatisticsToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
        }
예제 #2
0
 public static extern BearWare.ClientError TTS_UpdateServer(IntPtr lpTTSInstance, [In] ref BearWare.ServerProperties lpServerInfo);
예제 #3
0
 /**
  * @brief Update server properties.
  *
  * User rights required:
  * - ::USERRIGHT_UPDATE_SERVERPROPERTIES
  *
  * Possible errors:
  * - #ClientError ::CMDERR_NOT_LOGGEDIN
  * - #ClientError ::CMDERR_NOT_AUTHORIZED
  *
  * @param lpServerProperties A structure holding the information to be set
  * on the server.
  * @return Returns command ID which will be passed in
  * #OnCmdProcessing event when the server is processing the
  * command. -1 is returned in case of error.
  * @see GetServerProperties */
 public int DoUpdateServer(ServerProperties lpServerProperties)
 {
     return TTDLL.TT_DoUpdateServer(m_ttInst, ref lpServerProperties);
 }
예제 #4
0
 /** @} */
 /**
  * @addtogroup server
  * @{ */
 /**
  *
  * @brief Get the server's properties.
  *
  * @param lpServerProperties A struct to hold the server's properties. */
 public bool GetServerProperties(ref ServerProperties lpServerProperties)
 {
     return TTDLL.TT_GetServerProperties(m_ttInst, ref lpServerProperties);
 }
예제 #5
0
 void ttserver_OnServerUpdated(ref ServerProperties lpServerProperties, ref User lpUser)
 {
     String str = String.Format("Server properties updated, name is now {0}",
                            lpServerProperties.szServerName);
     Console.WriteLine(str);
 }
예제 #6
0
        public void TestIpLogins()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_UPDATE_SERVERPROPERTIES | UserRight.USERRIGHT_MULTI_LOGIN;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);

            ServerProperties srvprop = new ServerProperties();
            Assert.IsTrue(ttclient.GetServerProperties(ref srvprop));

            ServerProperties srvprop2 = srvprop;
            srvprop2.nMaxLoginsPerIPAddress = 2;

            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoUpdateServer(srvprop2), DEF_WAIT), "Update server");

            ttclient.Disconnect();

            TeamTalk ttclient2 = new TeamTalk(true);
            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            Connect(ttclient2);
            Login(ttclient2, NICKNAME, USERNAME, PASSWORD);

            TeamTalk ttclient3 = new TeamTalk(true);
            Connect(ttclient3);
            Assert.IsTrue(!WaitCmdSuccess(ttclient3, ttclient3.DoLogin(NICKNAME, USERNAME, PASSWORD), 500), "Login failure");
            
            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoUpdateServer(srvprop), DEF_WAIT), "Update server");
        }
예제 #7
0
        public void TestServerUpdateCommands()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_NONE;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            int cmdid;
            TTMessage msg = new TTMessage();

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);

            ServerProperties prop = new ServerProperties(), prop2 = new ServerProperties(), org_prop = new ServerProperties();
            Assert.IsTrue(ttclient.GetServerProperties(ref prop));
            cmdid = ttclient.DoUpdateServer(prop);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_ERROR, DEF_WAIT, ref msg), "server update fail");

            TeamTalk ttclient2 = NewClientInstance();
            Connect(ttclient2);
            cmdid = ttclient2.DoLogin(ADMIN_NICKNAME, ADMIN_USERNAME, ADMIN_PASSWORD);
            Assert.IsTrue(cmdid > 0, "login issued");
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_SERVER_UPDATE, DEF_WAIT, ref msg), "login complete");
            org_prop = prop2 = (ServerProperties)msg.DataToObject();

            Assert.AreEqual(prop.nMaxDesktopTxPerSecond, prop2.nMaxDesktopTxPerSecond);
            Assert.AreEqual(prop.nMaxLoginsPerIPAddress, prop2.nMaxLoginsPerIPAddress);
            Assert.AreEqual(prop.nMaxMediaFileTxPerSecond, prop2.nMaxMediaFileTxPerSecond);
            Assert.AreEqual(prop.nMaxTotalTxPerSecond, prop2.nMaxTotalTxPerSecond);
            Assert.AreEqual(prop.nMaxUsers, prop2.nMaxUsers);
            Assert.AreEqual(prop.nMaxVideoCaptureTxPerSecond, prop2.nMaxVideoCaptureTxPerSecond);
            Assert.AreEqual(prop.nMaxVoiceTxPerSecond, prop2.nMaxVoiceTxPerSecond);
            Assert.AreEqual(prop.nUserTimeout, prop2.nUserTimeout);
            Assert.AreEqual(prop.szMOTD, prop2.szMOTD);
            Assert.AreEqual(prop.szServerName, prop2.szServerName);
            Assert.AreEqual(prop.szServerProtocolVersion, prop2.szServerProtocolVersion);
            Assert.AreEqual(prop.szServerVersion, prop2.szServerVersion);

            //Assert.AreEqual(prop.bAutoSave, prop2.bAutoSave);
            //Assert.AreEqual(prop.szMOTDRaw, prop2.szMOTDRaw);
            //Assert.AreEqual(prop.nMaxLoginAttempts, prop2.nMaxLoginAttempts);
            //Assert.AreEqual(prop.nTcpPort, prop2.nTcpPort);
            //Assert.AreEqual(prop.nUdpPort, prop2.nUdpPort);

            prop = prop2;

            prop.bAutoSave = false;
            prop.nMaxDesktopTxPerSecond = 45000;
            prop.nMaxLoginAttempts = 2;
            prop.nMaxLoginsPerIPAddress = 300;
            prop.nMaxMediaFileTxPerSecond = 56000;
            prop.nMaxTotalTxPerSecond = 4566;
            prop.nMaxUsers = 45;
            prop.nMaxVideoCaptureTxPerSecond = 56700;
            prop.nMaxVoiceTxPerSecond = 44567;
            prop.nTcpPort = 450;
            prop.nUdpPort = 564;
            prop.nUserTimeout = 2323;
            prop.szMOTDRaw = "this is the motd";
            prop.szServerName = "this is the server name";

            prop.szMOTD = "foo";
            prop.szServerProtocolVersion = "445";
            prop.szServerVersion = "444";

            cmdid = ttclient2.DoUpdateServer(prop);
            Assert.IsTrue(cmdid > 0, "issued srv upd");
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_SERVER_UPDATE, DEF_WAIT, ref msg), "srv upd");
            prop2 = (ServerProperties)msg.DataToObject();

            Assert.AreEqual(prop.nMaxDesktopTxPerSecond, prop2.nMaxDesktopTxPerSecond);
            Assert.AreEqual(prop.nMaxLoginsPerIPAddress, prop2.nMaxLoginsPerIPAddress);
            Assert.AreEqual(prop.nMaxMediaFileTxPerSecond, prop2.nMaxMediaFileTxPerSecond);
            Assert.AreEqual(prop.nMaxTotalTxPerSecond, prop2.nMaxTotalTxPerSecond);
            Assert.AreEqual(prop.nMaxUsers, prop2.nMaxUsers);
            Assert.AreEqual(prop.nMaxVideoCaptureTxPerSecond, prop2.nMaxVideoCaptureTxPerSecond);
            Assert.AreEqual(prop.nMaxVoiceTxPerSecond, prop2.nMaxVoiceTxPerSecond);
            Assert.AreEqual(prop.nUserTimeout, prop2.nUserTimeout);
            Assert.AreEqual(prop.szServerName, prop2.szServerName);

            Assert.AreNotEqual(prop.szMOTD, prop2.szMOTD);
            Assert.AreNotEqual(prop.szServerProtocolVersion, prop2.szServerProtocolVersion);
            Assert.AreNotEqual(prop.szServerVersion, prop2.szServerVersion);

            Assert.AreEqual(prop.bAutoSave, prop2.bAutoSave);
            Assert.AreEqual(prop.szMOTDRaw, prop2.szMOTDRaw);
            Assert.AreEqual(prop.nMaxLoginAttempts, prop2.nMaxLoginAttempts);
            Assert.AreEqual(prop.nTcpPort, prop2.nTcpPort);
            Assert.AreEqual(prop.nUdpPort, prop2.nUdpPort);

            cmdid = ttclient2.DoUpdateServer(org_prop);
            Assert.IsTrue(cmdid > 0, "issued srv upd");
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_SERVER_UPDATE, DEF_WAIT, ref msg), "srv upd");

            //prop.szServerProtocolVersion = "";
            //prop.szMOTD = "this is the motd";
            //prop.szServerVersion = "";
        }
예제 #8
0
 static void ttclient_OnCmdServerUpdate(ServerProperties serverproperties)
 {
     Console.WriteLine("Get new server properties.");
     Console.WriteLine("Server Name: " + serverproperties.szServerName);
     Console.WriteLine("MOTD: " + serverproperties.szMOTD);
     Console.WriteLine("Server Version: " + serverproperties.szServerVersion);
 }
예제 #9
0
        void ttclient_OnCmdChannelNew(Channel chan)
        {
            TreeNode parent = GetChannel(chan.nParentID);
            if (parent == null)
            {
                //it's the root channel

                //user servername as root channel name
                ServerProperties prop = new ServerProperties();
                ttclient.GetServerProperties(ref prop);
                TreeNode newnode = new TreeNode(prop.szServerName, (int)ImageIndex.CHANNEL, (int)ImageIndex.CHANNEL);
                newnode.Tag = chan.nChannelID;
                treeview.Nodes.Add(newnode);
            }
            else
            {
                TreeNode newnode = new TreeNode(chan.szName, (int)ImageIndex.CHANNEL, (int)ImageIndex.CHANNEL);
                newnode.Tag = chan.nChannelID;
                parent.Nodes.Add(newnode);
            }
        }