Skip to content

Commit

Permalink
New user right USERRIGHT_TEXTMESSAGE_CHANNEL to prevent channel text …
Browse files Browse the repository at this point in the history
…messages
  • Loading branch information
bear101 committed Oct 15, 2023
1 parent f5f0f30 commit 892776a
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Version 5.15, unreleased
Default Qt Client
- PulseAudio support on Ubuntu 22
- User right to prevent private text messages
- User right to prevent channel text messages
- Fixed state of "Close when completed" checkbox on "Transfer file" dialog
- Support for 320 KBit MP3 recording (Windows only)
Android Client
Expand All @@ -16,6 +17,7 @@ iOS Client
-
Server
- User right to prevent private text messages
- User right to prevent channel text messages

Version 5.14, 2023/08/16
Default Qt Client
Expand Down
3 changes: 3 additions & 0 deletions Client/qtTeamTalk/useraccountsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ void UserRightsModel::insertUserRights()
m_userrights.push_back(USERRIGHT_TRANSMIT_MEDIAFILE_AUDIO);
m_userrights.push_back(USERRIGHT_TRANSMIT_MEDIAFILE_VIDEO);
m_userrights.push_back(USERRIGHT_TEXTMESSAGE_USER);
m_userrights.push_back(USERRIGHT_TEXTMESSAGE_CHANNEL);
//m_userrights.push_back(USERRIGHT_LOCKED_STATUS);
}

Expand Down Expand Up @@ -239,6 +240,8 @@ QVariant UserRightsModel::data(const QModelIndex & index, int role /*= Qt::Displ
break;
case USERRIGHT_TEXTMESSAGE_USER :
return tr("User can send private text messages");
case USERRIGHT_TEXTMESSAGE_CHANNEL :
return tr("User can send channel text messages");
case USERRIGHT_LOCKED_NICKNAME :
return tr("User can change nickname"); // inverted text explanation due to compatibility
case USERRIGHT_LOCKED_STATUS :
Expand Down
5 changes: 4 additions & 1 deletion Library/TeamTalk.NET/TeamTalk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,10 @@ public enum UserRight : uint
/** @brief User can send private text messages, i.e.
* #BearWare.TextMsgType.MSGTYPE_USER. @see TeamTalkBase.DoTextMessage() */
USERRIGHT_TEXTMESSAGE_USER = 0x00400000,

/** @brief User can send private text messages, i.e.
* #BearWare.TextMsgType.MSGTYPE_CHANNEL. @see TeamTalkBase.DoTextMessage() */
USERRIGHT_TEXTMESSAGE_CHANNEL = 0x00800000,

/** @brief User with all rights.*/
USERRIGHT_ALL = 0xFFFFFFFF & ~USERRIGHT_LOCKED_NICKNAME & ~USERRIGHT_LOCKED_STATUS
}
Expand Down
3 changes: 2 additions & 1 deletion Library/TeamTalk.NET/TeamTalkTest.NET/TeamTalkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,8 @@ public void TestTextMessage()
{
const string USERNAME = "tt_test", PASSWORD = "tt_test"; string NICKNAME = "TeamTalkBase.NET - " + GetCurrentMethod();
const UserRight USERRIGHTS = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL |
UserRight.USERRIGHT_VIEW_ALL_USERS | UserRight.USERRIGHT_TEXTMESSAGE_USER;
UserRight.USERRIGHT_VIEW_ALL_USERS | UserRight.USERRIGHT_TEXTMESSAGE_USER |
UserRight.USERRIGHT_TEXTMESSAGE_CHANNEL;
MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
TeamTalkBase ttclient = NewClientInstance();

Expand Down
1 change: 1 addition & 0 deletions Library/TeamTalkJNI/src/dk/bearware/UserRight.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public interface UserRight
public static final int USERRIGHT_RECORD_VOICE = 0x00100000;
public static final int USERRIGHT_VIEW_HIDDEN_CHANNELS = 0x00200000;
public static final int USERRIGHT_TEXTMESSAGE_USER = 0x00400000;
public static final int USERRIGHT_TEXTMESSAGE_CHANNEL = 0x00800000;

public static final int USERRIGHT_ALL = 0xFFFFFFFF & ~USERRIGHT_LOCKED_NICKNAME & ~USERRIGHT_LOCKED_STATUS;

Expand Down
46 changes: 45 additions & 1 deletion Library/TeamTalkJNI/test/dk/bearware/TeamTalkServerTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,10 @@ public void testTransmitUsers() {
useraccount.szUsername = USERNAME;
useraccount.szPassword = PASSWORD;
useraccount.uUserType = UserType.USERTYPE_DEFAULT;
useraccount.uUserRights = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL | UserRight.USERRIGHT_VIEW_ALL_USERS | UserRight.USERRIGHT_TRANSMIT_VOICE;
useraccount.uUserRights = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL |
UserRight.USERRIGHT_VIEW_ALL_USERS |
UserRight.USERRIGHT_TEXTMESSAGE_CHANNEL |
UserRight.USERRIGHT_TRANSMIT_VOICE;
useraccounts.add(useraccount);

TeamTalkSrv server = newServerInstance();
Expand Down Expand Up @@ -2011,6 +2014,47 @@ public void testTextMessagePrivate() {
assertTrue("send text message without rights", waitCmdError(client2, client2.doTextMessage(txtmsg), DEF_WAIT, interleave));
}

@Test
public void testTextMessageChannel() {
UserAccount useraccount = new UserAccount();
useraccount.szUsername = "guest";
useraccount.szPassword = "guest";
useraccount.uUserType = UserType.USERTYPE_DEFAULT;
useraccount.uUserRights = UserRight.USERRIGHT_VIEW_ALL_USERS |
UserRight.USERRIGHT_MULTI_LOGIN | UserRight.USERRIGHT_TEXTMESSAGE_CHANNEL;
useraccounts.add(useraccount);

UserAccount useraccount2 = new UserAccount();
useraccount2.szUsername = "guest2";
useraccount2.szPassword = "guest";
useraccount2.uUserType = UserType.USERTYPE_DEFAULT;
useraccount2.uUserRights = UserRight.USERRIGHT_VIEW_ALL_USERS |
UserRight.USERRIGHT_MULTI_LOGIN;
useraccounts.add(useraccount2);

TeamTalkSrv server = newServerInstance();
TeamTalkBase client1 = newClientInstance();
TeamTalkBase client2 = newClientInstance();

connect(server, client1);
connect(server, client2);

ServerInterleave interleave = new RunServer(server);

login(server, client1, getTestMethodName(), useraccount.szUsername, useraccount.szPassword);
login(server, client2, getTestMethodName(), useraccount2.szUsername, useraccount2.szPassword);
joinRoot(server, client1);
joinRoot(server, client2);

TextMessage txtmsg = new TextMessage();
txtmsg.nMsgType = TextMsgType.MSGTYPE_CHANNEL;
txtmsg.nChannelID = client1.getMyChannelID();
txtmsg.szMessage = "My text message";

assertTrue("send text message with rights", waitCmdSuccess(client1, client1.doTextMessage(txtmsg), DEF_WAIT, interleave));
assertTrue("send text message without rights", waitCmdError(client2, client2.doTextMessage(txtmsg), DEF_WAIT, interleave));
}

@Test
public void testAutoOperatorChannelPassword() {

Expand Down
4 changes: 4 additions & 0 deletions Library/TeamTalkLib/bin/ttsrv/ServerConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ void RunWizard(teamtalk::ServerXML& xmlSettings)
userrights = printGetBool(USERRIGHT_DEFAULT & USERRIGHT_TEXTMESSAGE_USER?true:false)?
(userrights | USERRIGHT_TEXTMESSAGE_USER) : (userrights & ~USERRIGHT_TEXTMESSAGE_USER);

cout << "User can sent channel text messages: ";
userrights = printGetBool(USERRIGHT_DEFAULT & USERRIGHT_TEXTMESSAGE_CHANNEL?true:false)?
(userrights | USERRIGHT_TEXTMESSAGE_CHANNEL) : (userrights & ~USERRIGHT_TEXTMESSAGE_CHANNEL);

cout << "User can broadcast text message to all users: ";
userrights = printGetBool(USERRIGHT_DEFAULT & USERRIGHT_TEXTMESSAGE_BROADCAST?true:false)?
(userrights | USERRIGHT_TEXTMESSAGE_BROADCAST) : (userrights & ~USERRIGHT_TEXTMESSAGE_BROADCAST);
Expand Down
1 change: 1 addition & 0 deletions Library/TeamTalkLib/bin/ttsrv/ServerXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace teamtalk{
UserAccount ua;
GetNextUser(0, ua);
ua.userrights |= USERRIGHT_TEXTMESSAGE_USER;
ua.userrights |= USERRIGHT_TEXTMESSAGE_CHANNEL;
RemoveUser(UnicodeToUtf8(ua.username).c_str());
AddNewUser(ua);
}
Expand Down
8 changes: 5 additions & 3 deletions Library/TeamTalkLib/teamtalk/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ namespace teamtalk {
USERRIGHT_RECORD_VOICE = 0x00100000,
USERRIGHT_VIEW_HIDDEN_CHANNELS = 0x00200000,
USERRIGHT_TEXTMESSAGE_USER = 0x00400000,
USERRIGHT_TEXTMESSAGE_CHANNEL = 0x00800000,

USERRIGHT_DEFAULT = USERRIGHT_MULTI_LOGIN |
USERRIGHT_VIEW_ALL_USERS |
Expand All @@ -221,10 +222,11 @@ namespace teamtalk {
USERRIGHT_TRANSMIT_DESKTOP |
USERRIGHT_TRANSMIT_DESKTOPINPUT |
USERRIGHT_TRANSMIT_MEDIAFILE |
USERRIGHT_TEXTMESSAGE_USER,
USERRIGHT_TEXTMESSAGE_USER |
USERRIGHT_TEXTMESSAGE_CHANNEL,

USERRIGHT_ALL = 0x007FFFFF ^ (USERRIGHT_LOCKED_NICKNAME | USERRIGHT_LOCKED_STATUS),
USERRIGHT_KNOWN_MASK = ~0xFF800000
USERRIGHT_ALL = 0x00FFFFFF ^ (USERRIGHT_LOCKED_NICKNAME | USERRIGHT_LOCKED_STATUS),
USERRIGHT_KNOWN_MASK = ~0xFF000000
};

typedef ACE_UINT32 UserRights;
Expand Down
3 changes: 3 additions & 0 deletions Library/TeamTalkLib/teamtalk/server/ServerNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4089,6 +4089,9 @@ ErrorMsg ServerNode::UserTextMessage(const TextMessage& msg)
}
case TTChannelMsg :
{
if ((from->GetUserRights() & USERRIGHT_TEXTMESSAGE_CHANNEL) == USERRIGHT_NONE)
return ErrorMsg(TT_CMDERR_NOT_AUTHORIZED);

serverchannel_t chan = GetChannel(msg.channelid);
if (!chan)
return ErrorMsg(TT_CMDERR_CHANNEL_NOT_FOUND);
Expand Down
1 change: 1 addition & 0 deletions Library/TeamTalkLib/teamtalk/server/ServerUser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ ErrorMsg ServerUser::HandleNewUserAccount(const mstrings_t& properties)
if (!VersionSameOrLater(GetStreamProtocol(), ACE_TEXT("5.13")))
{
account.userrights |= USERRIGHT_TEXTMESSAGE_USER;
account.userrights |= USERRIGHT_TEXTMESSAGE_CHANNEL;
}

return m_servernode.UserNewUserAccount(GetUserID(), account);
Expand Down
1 change: 1 addition & 0 deletions Library/TeamTalkPy/TeamTalk5.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ class UserRight(UINT32):
USERRIGHT_RECORD_VOICE = 0x00100000
USERRIGHT_VIEW_HIDDEN_CHANNELS = 0x00200000
USERRIGHT_TEXTMESSAGE_USER = 0x00400000
USERRIGHT_TEXTMESSAGE_CHANNEL = 0x00800000

class ServerLogEvent(UINT32):
SERVERLOGEVENT_NONE = 0x00000000
Expand Down
3 changes: 3 additions & 0 deletions Library/TeamTalk_DLL/TeamTalk.h
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,9 @@ extern "C" {
/** @brief User can send private text messages, i.e.
* #MSGTYPE_USER. @see TT_DoTextMessage() */
USERRIGHT_TEXTMESSAGE_USER = 0x00400000,
/** @brief User can send channel text messages, i.e.
* #MSGTYPE_CHANNEL. @see TT_DoTextMessage() */
USERRIGHT_TEXTMESSAGE_CHANNEL = 0x00800000,
} UserRight;

/**
Expand Down

0 comments on commit 892776a

Please sign in to comment.