Commit b5e78dcc authored by Amin Bandali's avatar Amin Bandali Committed by Sébastien Blin

conference: allow host to set and unset moderators

GitLab: #1220
Change-Id: I9b7059a1f05079937269bf2c0ddf98a1fc10a268
parent ed0d6a1c
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.3.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
<g id="Icones_Outline">
<g id="Moderator_Black_24dp">
<g>
<path d="M22,19.9H2V4.1l6.7,4.5L12,4.1l3.3,4.5L22,4.1V19.9z M3.4,18.5h17.1V6.8L15,10.5l-3-4l-3,4L3.4,6.8V18.5z"/>
</g>
</g>
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.3.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
<g id="Icones_Outline">
<g id="Moderator_White_24dp" style="fill:#ffffff">
<g>
<path d="M22,19.9H2V4.1l6.7,4.5L12,4.1l3.3,4.5L22,4.1V19.9z M3.4,18.5h17.1V6.8L15,10.5l-3-4l-3,4L3.4,6.8V18.5z"/>
</g>
</g>
</g>
</svg>
......@@ -64,5 +64,7 @@
<file alias="view">view.svg</file>
<file alias="more">more_vert-24px.svg</file>
<file alias="groups">groups-24px.svg</file>
<file alias="moderator">icons_Moderator_Black_24dp.svg</file>
<file alias="moderator_white">icons_Moderator_White_24dp.svg</file>
</gresource>
</gresources>
......@@ -41,6 +41,7 @@
// gnome client
#include "../defines.h"
#include "../utils/drawing.h"
#include "xrectsel.h"
static constexpr int VIDEO_LOCAL_SIZE = 150;
......@@ -392,6 +393,21 @@ on_minimize(GtkButton *button, VideoWidget *self)
} catch (...) {}
}
static void
on_set_moderator(GtkButton *button, VideoWidget *self)
{
g_return_if_fail(IS_VIDEO_WIDGET(self));
VideoWidgetPrivate *priv = VIDEO_WIDGET_GET_PRIVATE(self);
QString uri = QString::fromStdString((gchar*) g_object_get_data(G_OBJECT(button), "uri"));
bool set_moderator = (bool) g_object_get_data(G_OBJECT(button), "set-moderator");
auto conv_opt = (*priv->cpp->accountInfo)->conversationModel->getConversationForCallId(priv->cpp->callId);
if (conv_opt.has_value()) {
auto* conv = &(conv_opt.value().get());
auto confId = conv->getCallId();
(*priv->cpp->accountInfo)->callModel->setModerator(confId, uri, set_moderator);
}
}
static void
on_show_actions_popover(GtkButton *button, VideoWidget *self)
{
......@@ -402,9 +418,12 @@ on_show_actions_popover(GtkButton *button, VideoWidget *self)
priv->actions_popover = gtk_popover_new(GTK_WIDGET(self));
gtk_popover_set_relative_to(GTK_POPOVER(priv->actions_popover), GTK_WIDGET(button));
auto& callModel = (*priv->cpp->accountInfo)->callModel;
auto& conversationModel = (*priv->cpp->accountInfo)->conversationModel;
auto* box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
bool isLocal = (bool)g_object_get_data(G_OBJECT(button), "isLocal");
auto call = (*priv->cpp->accountInfo)->callModel->getCall(priv->cpp->callId);
auto call = callModel->getCall(priv->cpp->callId);
auto isHost = call.type == lrc::api::call::Type::CONFERENCE;
bool active = (bool)g_object_get_data(G_OBJECT(button), "active");
auto* uri = g_object_get_data(G_OBJECT(button), "uri");
......@@ -423,7 +442,7 @@ on_show_actions_popover(GtkButton *button, VideoWidget *self)
g_signal_connect(hangupBtn, "clicked", G_CALLBACK(on_hangup), self);
}
try {
auto call = (*priv->cpp->accountInfo)->callModel->getCall(priv->cpp->callId);
auto call = callModel->getCall(priv->cpp->callId);
if (call.layout != lrc::api::call::Layout::ONE) {
auto* maxBtn = gtk_button_new();
gtk_button_set_label(GTK_BUTTON(maxBtn), _("Maximize"));
......@@ -454,6 +473,37 @@ on_show_actions_popover(GtkButton *button, VideoWidget *self)
g_signal_connect(minBtn, "clicked", G_CALLBACK(on_minimize), self);
}
} catch (...) {}
auto conv_opt = conversationModel->getConversationForCallId(priv->cpp->callId);
if (conv_opt.has_value()) {
auto conv = conv_opt.value();
if (callModel->isConferenceHost(priv->cpp->callId)) {
bool moderator = callModel->isModerator(priv->cpp->callId, (gchar*) uri);
auto* modBtn = gtk_button_new();
gtk_button_set_label(GTK_BUTTON(modBtn), moderator ? _("Unset moderator") : _("Set moderator"));
gtk_box_pack_start(GTK_BOX(box), modBtn, FALSE, TRUE, 0);
g_object_set_data(G_OBJECT(modBtn), "uri", uri);
g_object_set_data(G_OBJECT(modBtn), "set-moderator", (void*) !moderator);
context = gtk_widget_get_style_context(modBtn);
gtk_style_context_add_class(context, "options-btn");
GError *error = nullptr;
auto* icon = gdk_pixbuf_new_from_resource_at_scale(
use_dark_theme(get_ambient_color(gtk_widget_get_toplevel(priv->actions_popover)))
? "/net/jami/JamiGnome/moderator_white"
: "/net/jami/JamiGnome/moderator",
16, -1, TRUE, &error);
if (!icon) {
g_debug("Could not load icon: %s", error->message);
g_clear_error(&error);
} else {
auto* image = gtk_image_new_from_pixbuf(icon);
gtk_button_set_image(GTK_BUTTON(modBtn), image);
}
gtk_button_set_relief(GTK_BUTTON(modBtn), GTK_RELIEF_NONE);
gtk_button_set_alignment(GTK_BUTTON(modBtn), 0, -1);
g_signal_connect(modBtn, "clicked", G_CALLBACK(on_set_moderator), self);
}
}
gtk_container_add(GTK_CONTAINER(GTK_POPOVER(priv->actions_popover)), box);
gtk_widget_set_size_request(priv->actions_popover, -1, -1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment