Fixed the channel descriptions
This commit is contained in:
parent
988ed00ff6
commit
dbb7c322a2
@ -1 +1 @@
|
||||
Subproject commit 6fa26411e7f38d5697269262bab68c307bd159b1
|
||||
Subproject commit 00eff98160e4c367f2d368246b3eb581bb82dd10
|
@ -198,7 +198,12 @@ namespace ts {
|
||||
virtual bool notifyChannelMoved(const std::shared_ptr<BasicChannel> &channel, ChannelId order, const std::shared_ptr<ConnectedClient> &invoker);
|
||||
virtual bool notifyChannelDescriptionChanged(std::shared_ptr<BasicChannel> channel);
|
||||
virtual bool notifyChannelPasswordChanged(std::shared_ptr<BasicChannel>);
|
||||
virtual bool notifyChannelEdited(std::shared_ptr<BasicChannel>, std::vector<std::string> keys, ConnectedClient* invoker); /* clients channel tree must be at least read locked */
|
||||
virtual bool notifyChannelEdited(
|
||||
const std::shared_ptr<BasicChannel>& /* channel */,
|
||||
const std::vector<property::ChannelProperties>& /* properties */,
|
||||
const std::shared_ptr<ConnectedClient>& /* invoker */,
|
||||
bool /* send channel description */
|
||||
); /* clients channel tree must be at least read locked */
|
||||
|
||||
virtual bool notifyChannelHide(const std::deque<ChannelId> &channels, bool lock_channel_tree);
|
||||
virtual bool notifyChannelShow(const std::shared_ptr<BasicChannel> &channel, ChannelId orderId); /* client channel tree must be unique locked and server channel tree shared locked */
|
||||
|
@ -1672,7 +1672,7 @@ CommandResult ConnectedClient::handleCommandChannelCreate(Command &cmd) {
|
||||
|
||||
if(old_default_channel) {
|
||||
//TODO: Reminder: client channel tree must be at least read locked here!
|
||||
client->notifyChannelEdited(old_default_channel, {"channel_flag_default"}, this);
|
||||
client->notifyChannelEdited(old_default_channel, {property::CHANNEL_FLAG_DEFAULT}, self_lock, false);
|
||||
}
|
||||
});
|
||||
|
||||
@ -2079,6 +2079,7 @@ CommandResult ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
return {findError("channel_name_inuse"), to_string(named_channel->channelId())};
|
||||
}
|
||||
|
||||
auto self_ref = this->ref();
|
||||
shared_ptr<BasicChannel> old_default_channel;
|
||||
deque<shared_ptr<BasicChannel>> child_channel_updated;
|
||||
for(const std::shared_ptr<property::PropertyDescription>& key : keys) {
|
||||
@ -2110,7 +2111,7 @@ CommandResult ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
cl->notifyChannelMoved(action.second->channel(), action.second->previous_channel, this->ref());
|
||||
break;
|
||||
case ClientChannelView::REORDER:
|
||||
cl->notifyChannelEdited(action.second->channel(), {"channel_order"}, this);
|
||||
cl->notifyChannelEdited(action.second->channel(), {property::CHANNEL_ORDER}, self_ref, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2147,10 +2148,11 @@ CommandResult ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
|
||||
if(this->server && !updated_channels.empty()) {
|
||||
std::reverse(updated_channels.begin(), updated_channels.end());
|
||||
auto this_ref = this->ref();
|
||||
this->server->forEachClient([&](const shared_ptr<ConnectedClient>& client) {
|
||||
unique_lock client_channel_lock(client->channel_lock);
|
||||
for(const auto& channel : updated_channels) {
|
||||
client->notifyChannelEdited(channel, {"channel_flag_permanent", "channel_flag_semi_permanent"}, this);
|
||||
client->notifyChannelEdited(channel, {property::CHANNEL_FLAG_PERMANENT, property::CHANNEL_FLAG_SEMI_PERMANENT}, this_ref, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -2192,21 +2194,22 @@ CommandResult ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
channel->properties()[key] = cmd[key->name].string();
|
||||
}
|
||||
if(this->server) {
|
||||
vector<string> key_vector;
|
||||
vector<property::ChannelProperties> key_vector;
|
||||
key_vector.reserve(keys.size());
|
||||
for(const auto& key : keys)
|
||||
key_vector.push_back(key->name);
|
||||
key_vector.push_back((property::ChannelProperties) key->property_index);
|
||||
|
||||
auto self_rev = this->ref();
|
||||
this->server->forEachClient([&](const shared_ptr<ConnectedClient>& client) {
|
||||
unique_lock client_channel_lock(client->channel_lock);
|
||||
|
||||
for(const auto& channel : child_channel_updated)
|
||||
client->notifyChannelEdited(channel, {"channel_flag_permanent", "channel_flag_semi_permanent"}, this);
|
||||
client->notifyChannelEdited(channel, {property::CHANNEL_FLAG_PERMANENT, property::CHANNEL_FLAG_SEMI_PERMANENT}, self_rev, false);
|
||||
|
||||
client->notifyChannelEdited(channel, key_vector, this);
|
||||
client->notifyChannelEdited(channel, key_vector, self_rev, false);
|
||||
|
||||
if(old_default_channel) /* clients need to have one or more defualt channels... */
|
||||
client->notifyChannelEdited(old_default_channel, {"channel_flag_default"}, this);
|
||||
client->notifyChannelEdited(old_default_channel, {property::CHANNEL_FLAG_DEFAULT}, self_rev, false);
|
||||
});
|
||||
}
|
||||
|
||||
@ -2305,10 +2308,11 @@ CommandResult ConnectedClient::handleCommandChannelMove(Command &cmd) {
|
||||
}
|
||||
|
||||
if(this->server) {
|
||||
auto self_rev = this->ref();
|
||||
this->server->forEachClient([&](const shared_ptr<ConnectedClient>& client) {
|
||||
unique_lock channel_lock(client->channel_lock);
|
||||
for(const auto& type_update : channel_type_updates)
|
||||
client->notifyChannelEdited(type_update, {"channel_flag_permanent", "channel_flag_semi_permanent"}, this);
|
||||
client->notifyChannelEdited(type_update, {property::CHANNEL_FLAG_PERMANENT, property::CHANNEL_FLAG_SEMI_PERMANENT}, self_rev, false);
|
||||
|
||||
auto actions = client->channels->change_order(l_channel, l_parent, l_order);
|
||||
std::deque<ChannelId> deletions;
|
||||
@ -2326,7 +2330,7 @@ CommandResult ConnectedClient::handleCommandChannelMove(Command &cmd) {
|
||||
client->notifyChannelMoved(action.second->channel(), action.second->previous_channel, _this.lock());
|
||||
break;
|
||||
case ClientChannelView::REORDER:
|
||||
client->notifyChannelEdited(action.second->channel(), vector<string>{"channel_order"}, _this.lock().get());
|
||||
client->notifyChannelEdited(action.second->channel(), {property::CHANNEL_ORDER}, self_rev, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2462,11 +2466,13 @@ CommandResult ConnectedClient::handleCommandChannelAddPerm(Command &cmd) {
|
||||
update_channel_properties |= channel->permission_require_property_update(permType);
|
||||
|
||||
if (permType == permission::i_icon_id) {
|
||||
if(this->server)
|
||||
if(this->server) {
|
||||
auto self_ref = this->ref();
|
||||
this->server->forEachClient([&](std::shared_ptr<ConnectedClient> cl) {
|
||||
shared_lock client_channel_lock(cl->channel_lock);
|
||||
cl->notifyChannelEdited(channel, {"channel_icon_id"}, this);
|
||||
cl->notifyChannelEdited(channel, {property::CHANNEL_ICON_ID}, self_ref, false);
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -2476,15 +2482,10 @@ CommandResult ConnectedClient::handleCommandChannelAddPerm(Command &cmd) {
|
||||
if(update_channel_properties) {
|
||||
auto updates = channel->update_properties_from_permissions();
|
||||
if(!updates.empty() && this->server){
|
||||
vector<string> keys;
|
||||
keys.reserve(updates.size());
|
||||
|
||||
for(auto& property : updates)
|
||||
keys.push_back(property::info(property)->name);
|
||||
|
||||
auto self_ref = this->ref();
|
||||
this->server->forEachClient([&](std::shared_ptr<ConnectedClient> cl) {
|
||||
shared_lock client_channel_lock(cl->channel_lock);
|
||||
cl->notifyChannelEdited(channel, keys, this);
|
||||
cl->notifyChannelEdited(channel, updates, self_ref, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -2554,15 +2555,10 @@ CommandResult ConnectedClient::handleCommandChannelDelPerm(Command &cmd) {
|
||||
if(update_channel_properties) {
|
||||
auto updates = channel->update_properties_from_permissions();
|
||||
if(!updates.empty() && this->server){
|
||||
vector<string> keys;
|
||||
keys.reserve(updates.size());
|
||||
|
||||
for(auto& property : updates)
|
||||
keys.push_back(property::info(property)->name);
|
||||
|
||||
auto self_ref = this->ref();
|
||||
this->server->forEachClient([&](std::shared_ptr<ConnectedClient> cl) {
|
||||
shared_lock client_channel_lock(cl->channel_lock);
|
||||
cl->notifyChannelEdited(channel, keys, this);
|
||||
cl->notifyChannelEdited(channel, updates, self_ref, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -452,6 +452,8 @@ bool ConnectedClient::notifyChannelCreate(const std::shared_ptr<BasicChannel> &c
|
||||
for (auto &prop : channel->properties().list_properties(property::FLAG_CHANNEL_VARIABLE | property::FLAG_CHANNEL_VIEW, this->getType() == CLIENT_TEAMSPEAK ? property::FLAG_NEW : (uint16_t) 0)) {
|
||||
if(prop.type() == property::CHANNEL_ORDER)
|
||||
notify[prop.type().name] = orderId;
|
||||
else if(prop.type() == property::CHANNEL_DESCRIPTION)
|
||||
continue;
|
||||
else
|
||||
notify[prop.type().name] = prop.value();
|
||||
}
|
||||
@ -513,8 +515,11 @@ bool ConnectedClient::notifyChannelShow(const std::shared_ptr<ts::BasicChannel>
|
||||
} else {
|
||||
Command notify("notifychannelshow");
|
||||
for (auto &prop : channel->properties().list_properties(property::FLAG_CHANNEL_VARIABLE | property::FLAG_CHANNEL_VIEW, this->getType() == CLIENT_TEAMSPEAK ? property::FLAG_NEW : (uint16_t) 0)) {
|
||||
if(prop.type() == property::CHANNEL_ORDER)
|
||||
if(prop.type() == property::CHANNEL_ORDER) {
|
||||
notify[prop.type().name] = orderId;
|
||||
} else if(prop.type() == property::CHANNEL_DESCRIPTION) {
|
||||
continue;
|
||||
}
|
||||
else
|
||||
notify[prop.type().name] = prop.value();
|
||||
}
|
||||
@ -640,33 +645,41 @@ bool ConnectedClient::notifyClientEnterView(const std::deque<std::shared_ptr<Con
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConnectedClient::notifyChannelEdited(std::shared_ptr<BasicChannel> channel, std::vector<std::string> keys, ConnectedClient *invoker) {
|
||||
bool ConnectedClient::notifyChannelEdited(
|
||||
const std::shared_ptr<BasicChannel> &channel,
|
||||
const std::vector<property::ChannelProperties> &properties,
|
||||
const std::shared_ptr<ConnectedClient> &invoker,
|
||||
bool send_description) {
|
||||
auto v_channel = this->channels->find_channel(channel->channelId());
|
||||
if(!v_channel) return false; //Not visible? Important do not remove!
|
||||
|
||||
Command notify("notifychanneledited");
|
||||
bool send_description_change{false};
|
||||
|
||||
auto counter = 0;
|
||||
for (const auto& key : keys) {
|
||||
auto info = property::impl::info<property::ChannelProperties>(key);
|
||||
if(*info == property::CHANNEL_UNDEFINED) {
|
||||
logError(this->getServerId(), "Tried to edit a non existing channel property: " + key);
|
||||
continue;
|
||||
}
|
||||
counter++;
|
||||
if(*info == property::CHANNEL_ORDER) {
|
||||
notify[key] = v_channel->previous_channel;
|
||||
Command notify("notifychanneledited");
|
||||
for(auto prop : properties) {
|
||||
auto prop_info = property::impl::info(prop);
|
||||
|
||||
if(prop == property::CHANNEL_ORDER)
|
||||
notify[prop_info->name] = v_channel->previous_channel;
|
||||
else if(prop == property::CHANNEL_DESCRIPTION && !send_description) {
|
||||
send_description_change = true;
|
||||
} else {
|
||||
notify[key] = channel->properties()[info].as<std::string>();
|
||||
notify[prop_info->name] = channel->properties()[prop].as<string>();
|
||||
}
|
||||
}
|
||||
if(counter == 0) return true;
|
||||
|
||||
notify["cid"] = channel->channelId();
|
||||
INVOKER(notify, invoker);
|
||||
notify["reasonid"] = ViewReasonId::VREASON_EDITED;
|
||||
|
||||
INVOKER(notify, invoker);
|
||||
this->sendCommand(notify);
|
||||
|
||||
if(send_description_change) {
|
||||
Command notify_dchange{"notifychanneldescriptionchanged"};
|
||||
notify_dchange["cid"] = channel->channelId();
|
||||
this->sendCommand(notify_dchange);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -453,3 +453,4 @@ void MusicClient::execute_music_tick(const shared_ptr<ts::music::PlayableSong>&
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,8 @@ namespace ts {
|
||||
const std::shared_ptr<ConnectedClient> &invoker) override;
|
||||
bool notifyChannelDescriptionChanged(std::shared_ptr<BasicChannel> channel) override;
|
||||
bool notifyChannelPasswordChanged(std::shared_ptr<BasicChannel> ) override;
|
||||
bool notifyChannelEdited(std::shared_ptr<BasicChannel> channel, std::vector<std::string> keys, ConnectedClient *invoker) override;
|
||||
|
||||
bool notifyChannelEdited(const std::shared_ptr<BasicChannel> &ptr, const std::vector<property::ChannelProperties> &vector, const std::shared_ptr<ConnectedClient> &sharedPtr, bool b) override;
|
||||
|
||||
bool notifyChannelDeleted(const std::deque<ChannelId> &deque, const std::shared_ptr<ConnectedClient> &ptr) override;
|
||||
|
||||
|
@ -1000,5 +1000,4 @@ CommandResult QueryClient::handleCommandServerNotifyUnregister(Command &cmd) {
|
||||
this->toggleEvent(ev.first, ev.second, false);
|
||||
return CommandResult::Success;
|
||||
}
|
||||
|
||||
#undef XMACRO_LAGACY_EV
|
@ -111,9 +111,9 @@ bool QueryClient::notifyChannelPasswordChanged(std::shared_ptr<BasicChannel> cha
|
||||
return ConnectedClient::notifyChannelPasswordChanged(channel);
|
||||
}
|
||||
|
||||
bool QueryClient::notifyChannelEdited(std::shared_ptr<BasicChannel> channel, std::vector<std::string> keys, ConnectedClient *invoker) {
|
||||
bool QueryClient::notifyChannelEdited(const std::shared_ptr<BasicChannel> &ptr, const std::vector<property::ChannelProperties> &vector, const std::shared_ptr<ConnectedClient> &sharedPtr, bool b) {
|
||||
CHK_EVENT(QEVENTGROUP_CHANNEL, QEVENTSPECIFIER_CHANNEL_EDIT);
|
||||
return ConnectedClient::notifyChannelEdited(channel, keys, invoker);
|
||||
return ConnectedClient::notifyChannelEdited(ptr, vector, sharedPtr, b);
|
||||
}
|
||||
|
||||
bool QueryClient::notifyChannelDeleted(const std::deque<ChannelId> &deque, const std::shared_ptr<ConnectedClient> &ptr) {
|
||||
|
Loading…
Reference in New Issue
Block a user