Commit 8f382619 authored by Amin Bandali's avatar Amin Bandali Committed by Adrien Béraud

swarm: adapt to API changes

Change-Id: Ifeab5a89cd6a1ea33daf66b3af70bca0e81228e2
parent 9cff4934
......@@ -386,7 +386,7 @@ create_account(AccountCreationWizard *view,
priv->username = g_strdup(username);
priv->password = g_strdup(password);
auto accountId = lrc::api::NewAccountModel::createNewAccount(
lrc::api::profile::Type::RING,
lrc::api::profile::Type::JAMI,
display_name? display_name : "",
archivePath? archivePath : "",
password? password : "",
......
......@@ -128,8 +128,8 @@ class CppImpl {
public:
explicit CppImpl(ChatView& widget);
struct Interaction {
std::string conv;
uint64_t id;
const QString& conv;
const QString& id;
lrc::api::interaction::Info info;
};
std::vector<Interaction> interactionsBuffer_;
......@@ -730,7 +730,7 @@ webkit_chat_container_script_dialog(GtkWidget* webview, gchar *interaction, Chat
hide_chat_view(webview, self);
} else if (order.find("SEND:") == 0) {
auto toSend = order.substr(std::string("SEND:").size());
if ((*priv->accountInfo_)->profileInfo.type == lrc::api::profile::Type::RING) {
if ((*priv->accountInfo_)->profileInfo.type == lrc::api::profile::Type::JAMI) {
(*priv->accountInfo_)->conversationModel->sendMessage(priv->conversation_->uid, toSend.c_str());
} else {
// For SIP accounts, we need to wait that the conversation is created to send text
......@@ -744,10 +744,10 @@ webkit_chat_container_script_dialog(GtkWidget* webview, gchar *interaction, Chat
} else if (order.find("ACCEPT_FILE:") == 0) {
if (auto model = (*priv->accountInfo_)->conversationModel.get()) {
try {
auto interactionId = std::stoull(order.substr(std::string("ACCEPT_FILE:").size()));
auto interactionId = QString::fromStdString(order.substr(std::string("ACCEPT_FILE:").size()));
lrc::api::datatransfer::Info info = {};
(*priv->accountInfo_)->conversationModel->getTransferInfo(interactionId, info);
(*priv->accountInfo_)->conversationModel->getTransferInfo(priv->conversation_->uid, interactionId, info);
// get preferred directory destination.
auto* download_directory_variant = g_settings_get_value(priv->settings, "download-folder");
......@@ -780,7 +780,7 @@ webkit_chat_container_script_dialog(GtkWidget* webview, gchar *interaction, Chat
} else if (order.find("REFUSE_FILE:") == 0) {
if (auto model = (*priv->accountInfo_)->conversationModel.get()) {
try {
auto interactionId = std::stoull(order.substr(std::string("REFUSE_FILE:").size()));
auto interactionId = QString::fromStdString(order.substr(std::string("REFUSE_FILE:").size()));
model->cancelTransfer(priv->conversation_->uid, interactionId);
} catch (...) {
// ignore
......@@ -800,7 +800,7 @@ webkit_chat_container_script_dialog(GtkWidget* webview, gchar *interaction, Chat
add_to_conversations_clicked(self);
} else if (order.find("DELETE_INTERACTION:") == 0) {
try {
auto interactionId = std::stoull(order.substr(std::string("DELETE_INTERACTION:").size()));
auto interactionId = QString::fromStdString(order.substr(std::string("DELETE_INTERACTION:").size()));
if (!priv->conversation_) return;
(*priv->accountInfo_)->conversationModel->clearInteractionFromConversation(priv->conversation_->uid, interactionId);
} catch (...) {
......@@ -808,7 +808,7 @@ webkit_chat_container_script_dialog(GtkWidget* webview, gchar *interaction, Chat
}
} else if (order.find("RETRY_INTERACTION:") == 0) {
try {
auto interactionId = std::stoull(order.substr(std::string("RETRY_INTERACTION:").size()));
auto interactionId = QString::fromStdString(order.substr(std::string("RETRY_INTERACTION:").size()));
if (!priv->conversation_) return;
(*priv->accountInfo_)->conversationModel->retryInteraction(priv->conversation_->uid, interactionId);
} catch (...) {
......@@ -942,7 +942,7 @@ chat_view_class_init(ChatViewClass *klass)
}
static void
print_interaction_to_buffer(ChatView* self, uint64_t interactionId, const lrc::api::interaction::Info& interaction)
print_interaction_to_buffer(ChatView* self, const QString& convUid, const QString& interactionId, const lrc::api::interaction::Info& interaction)
{
ChatViewPrivate *priv = CHAT_VIEW_GET_PRIVATE(self);
......@@ -953,25 +953,27 @@ print_interaction_to_buffer(ChatView* self, uint64_t interactionId, const lrc::a
webkit_chat_container_print_new_interaction(
WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
*(*priv->accountInfo_)->conversationModel,
convUid,
interactionId,
interaction
);
}
static void
update_interaction(ChatView* self, uint64_t interactionId, const lrc::api::interaction::Info& interaction)
update_interaction(ChatView* self, const QString& convUid, const QString& interactionId, const lrc::api::interaction::Info& interaction)
{
ChatViewPrivate *priv = CHAT_VIEW_GET_PRIVATE(self);
webkit_chat_container_update_interaction(
WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
*(*priv->accountInfo_)->conversationModel,
convUid,
interactionId,
interaction
);
}
static void
remove_interaction(ChatView* self, uint64_t interactionId)
remove_interaction(ChatView* self, const QString& interactionId)
{
ChatViewPrivate *priv = CHAT_VIEW_GET_PRIVATE(self);
webkit_chat_container_remove_interaction(
......@@ -1064,23 +1066,23 @@ webkit_chat_container_ready(ChatView* self)
priv->ready_ = true;
for (const auto& interaction: priv->cpp->interactionsBuffer_) {
if (interaction.conv == priv->conversation_->uid.toStdString()) {
print_interaction_to_buffer(self, interaction.id, interaction.info);
if (interaction.conv == priv->conversation_->uid) {
print_interaction_to_buffer(self, priv->conversation_->uid, interaction.id, interaction.info);
}
}
priv->update_interaction_connection = QObject::connect(
&*(*priv->accountInfo_)->conversationModel, &lrc::api::ConversationModel::interactionStatusUpdated,
[self, priv](const QString& uid, uint64_t msgId, lrc::api::interaction::Info msg) {
[self, priv](const QString& uid, const QString& msgId, lrc::api::interaction::Info msg) {
if (!priv->conversation_) return;
if (uid == priv->conversation_->uid) {
update_interaction(self, msgId, msg);
update_interaction(self, priv->conversation_->uid, msgId, msg);
}
});
priv->interaction_removed = QObject::connect(
&*(*priv->accountInfo_)->conversationModel, &lrc::api::ConversationModel::interactionRemoved,
[self, priv](const QString& convUid, uint64_t interactionId) {
[self, priv](const QString& convUid, const QString& interactionId) {
if (!priv->conversation_) return;
if (convUid == priv->conversation_->uid) {
remove_interaction(self, interactionId);
......@@ -1329,13 +1331,13 @@ build_chat_view(ChatView* self)
priv->new_interaction_connection = QObject::connect(
&*(*priv->accountInfo_)->conversationModel, &lrc::api::ConversationModel::newInteraction,
[self, priv](const QString& uid, uint64_t interactionId, lrc::api::interaction::Info interaction) {
[self, priv](const QString& uid, const QString& interactionId, lrc::api::interaction::Info interaction) {
if (!priv->conversation_) return;
if (!priv->ready_ && priv->cpp) {
priv->cpp->interactionsBuffer_.emplace_back(CppImpl::Interaction {
uid.toStdString(), interactionId, interaction});
uid, interactionId, interaction});
} else if (uid == priv->conversation_->uid) {
print_interaction_to_buffer(self, interactionId, interaction);
print_interaction_to_buffer(self, uid, interactionId, interaction);
}
});
......
......@@ -27,6 +27,7 @@
// LRC
#include <api/avmodel.h>
#include <api/datatransfermodel.h>
#include <api/newaccountmodel.h>
// Jami Client
#include "utils/files.h"
......@@ -100,19 +101,19 @@ namespace { namespace details {
class CppImpl
{
public:
explicit CppImpl(GeneralSettingsView& widget, lrc::api::AVModel& avModel, lrc::api::DataTransferModel& dtModel);
explicit CppImpl(GeneralSettingsView& widget, lrc::api::AVModel& avModel, lrc::api::NewAccountModel& accountModel);
lrc::api::AVModel* avModel_ = nullptr;
lrc::api::DataTransferModel* dtModel_ = nullptr;
lrc::api::NewAccountModel* accountModel_ = nullptr;
GeneralSettingsView* self = nullptr; // The GTK widget itself
GeneralSettingsViewPrivate* widgets = nullptr;
};
CppImpl::CppImpl(GeneralSettingsView& widget, lrc::api::AVModel& avModel, lrc::api::DataTransferModel& dtModel)
CppImpl::CppImpl(GeneralSettingsView& widget, lrc::api::AVModel& avModel, lrc::api::NewAccountModel& accountModel)
: self(&widget)
, widgets(GENERAL_SETTINGS_VIEW_GET_PRIVATE(&widget))
, avModel_(&avModel)
, dtModel_(&dtModel)
, accountModel_(&accountModel)
{
gtk_switch_set_active(
GTK_SWITCH(widgets->record_preview_button),
......@@ -203,7 +204,7 @@ update_downloads_button_label(GeneralSettingsView *self)
}
static void
change_prefered_directory (gchar * directory, GeneralSettingsView *self, gchar * id, void (*cb)(GeneralSettingsView*))
change_prefered_directory (const gchar *directory, GeneralSettingsView *self, const gchar *id, void (*cb)(GeneralSettingsView*))
{
g_return_if_fail(IS_GENERAL_SETTINGS_VIEW(self));
GeneralSettingsViewPrivate *priv = GENERAL_SETTINGS_VIEW_GET_PRIVATE(self);
......@@ -303,8 +304,8 @@ file_transfer_limit_changed(GtkAdjustment *adjustment, GeneralSettingsView *self
g_return_if_fail(IS_GENERAL_SETTINGS_VIEW(self));
GeneralSettingsViewPrivate *priv = GENERAL_SETTINGS_VIEW_GET_PRIVATE(self);
gdouble limit = gtk_adjustment_get_value(adjustment);
if (priv && priv->cpp && priv->cpp->dtModel_)
priv->cpp->dtModel_->acceptBehindMb = limit;
if (priv && priv->cpp && priv->cpp->accountModel_)
priv->cpp->accountModel_->autoTransferSizeThreshold = limit;
}
static void
......@@ -313,8 +314,8 @@ accept_untrusted_toggled(GtkSwitch *button, GParamSpec* /*spec*/, GeneralSetting
g_return_if_fail(IS_GENERAL_SETTINGS_VIEW(self));
GeneralSettingsViewPrivate *priv = GENERAL_SETTINGS_VIEW_GET_PRIVATE(self);
gboolean accept = gtk_switch_get_active(button);
if (priv && priv->cpp && priv->cpp->dtModel_)
priv->cpp->dtModel_->acceptFromUnstrusted = accept;
if (priv && priv->cpp && priv->cpp->accountModel_)
priv->cpp->accountModel_->autoTransferFromUntrusted = accept;
}
static void
......@@ -324,8 +325,8 @@ accept_transfer_toggled(GtkSwitch *button, GParamSpec* /*spec*/, GeneralSettings
GeneralSettingsViewPrivate *priv = GENERAL_SETTINGS_VIEW_GET_PRIVATE(self);
gboolean accept = gtk_switch_get_active(button);
gtk_widget_set_sensitive(priv->spinbutton_limit_transfer, accept);
if (priv && priv->cpp && priv->cpp->dtModel_) {
priv->cpp->dtModel_->automaticAcceptTransfer = accept;
if (priv && priv->cpp && priv->cpp->accountModel_) {
priv->cpp->accountModel_->autoTransferFromTrusted = accept;
}
}
......@@ -538,12 +539,13 @@ general_settings_view_class_init(GeneralSettingsViewClass *klass)
}
GtkWidget *
general_settings_view_new(GtkWidget* main_window_pointer, lrc::api::AVModel& avModel, lrc::api::DataTransferModel& dtModel)
general_settings_view_new(GtkWidget* main_window_pointer, lrc::api::AVModel& avModel, lrc::api::NewAccountModel& accountModel)
{
auto self = g_object_new(GENERAL_SETTINGS_VIEW_TYPE, NULL);
auto* priv = GENERAL_SETTINGS_VIEW_GET_PRIVATE(GENERAL_SETTINGS_VIEW (self));
priv->cpp = new details::CppImpl(
*(reinterpret_cast<GeneralSettingsView*>(self)), avModel, dtModel
*(reinterpret_cast<GeneralSettingsView*>(self)),
avModel, accountModel
);
// set_up ring main window pointer (needed by modal dialogs)
......
......@@ -25,6 +25,7 @@
namespace lrc { namespace api {
class AVModel;
class DataTransferModel;
class NewAccountModel;
}}
G_BEGIN_DECLS
......@@ -39,7 +40,7 @@ typedef struct _GeneralSettingsView GeneralSettingsView;
typedef struct _GeneralSettingsViewClass GeneralSettingsViewClass;
GType general_settings_view_get_type (void) G_GNUC_CONST;
GtkWidget *general_settings_view_new (GtkWidget* main_window_pnt, lrc::api::AVModel& avModel, lrc::api::DataTransferModel& dtModel);
GtkWidget *general_settings_view_new (GtkWidget* main_window_pnt, lrc::api::AVModel& avModel, lrc::api::NewAccountModel& accountModel);
G_END_DECLS
......
......@@ -348,7 +348,7 @@ public:
AccountInfoPointer accountInfo_ = nullptr;
AccountInfoPointer accountInfoForMigration_ = nullptr;
std::optional<std::reference_wrapper<lrc::api::conversation::Info>> chatViewConversation_;
lrc::api::profile::Type currentTypeFilter_;
lrc::api::FilterType currentFilterType_;
bool show_settings = false;
bool is_fullscreen = false;
bool has_cleared_all_history = false;
......@@ -415,8 +415,8 @@ private:
void slotNewTrustRequest(const std::string& id, const std::string& contactUri);
void slotCloseTrustRequest(const std::string& id, const std::string& contactUri);
void slotNewInteraction(const std::string& accountId, const std::string& conversation,
uint64_t interactionId, const lrc::api::interaction::Info& interaction);
void slotCloseInteraction(const std::string& accountId, const std::string& conversation, uint64_t interactionId);
const QString& interactionId, const lrc::api::interaction::Info& interaction);
void slotCloseInteraction(const std::string& accountId, const std::string& conversation, const QString& interactionId);
void slotProfileUpdated(const std::string& id);
};
......@@ -672,7 +672,7 @@ on_account_changed(MainWindow* self)
priv->cpp->accountInfo_->accountModel->setTopAccount(accountId);
priv->cpp->onAccountSelectionChange(accountId);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(priv->notebook_contacts),
priv->cpp->accountInfo_->contactModel->hasPendingRequests());
priv->cpp->accountInfo_->conversationModel->hasPendingRequests());
}
g_free(accountId);
}
......@@ -874,10 +874,16 @@ on_tab_changed(GtkNotebook* notebook, GtkWidget* page, guint page_num, MainWindo
g_return_if_fail(IS_MAIN_WINDOW(self));
auto* priv = MAIN_WINDOW_GET_PRIVATE(MAIN_WINDOW(self));
auto newType = page_num == 0 ? priv->cpp->accountInfo_->profileInfo.type : lrc::api::profile::Type::PENDING;
if (priv->cpp->currentTypeFilter_ != newType) {
priv->cpp->currentTypeFilter_ = newType;
priv->cpp->accountInfo_->conversationModel->setFilter(priv->cpp->currentTypeFilter_);
lrc::api::FilterType newType;
if (priv->cpp->accountInfo_->profileInfo.type == lrc::api::profile::Type::JAMI)
newType = lrc::api::FilterType::JAMI;
else if (priv->cpp->accountInfo_->profileInfo.type == lrc::api::profile::Type::SIP)
newType = lrc::api::FilterType::SIP;
newType = page_num == 0 ? newType : lrc::api::FilterType::REQUEST;
if (priv->cpp->currentFilterType_ != newType) {
priv->cpp->currentFilterType_ = newType;
priv->cpp->accountInfo_->conversationModel->setFilter(priv->cpp->currentFilterType_);
}
}
......@@ -1204,7 +1210,7 @@ on_clear_all_history_clicked(MainWindow* self)
}
static void
update_data_transfer(lrc::api::DataTransferModel& model, GSettings* settings)
update_data_transfer(lrc::api::NewAccountModel& model, GSettings* settings)
{
char* download_directory_value;
auto* download_directory_variant = g_settings_get_value(settings, "download-folder");
......@@ -1221,7 +1227,7 @@ update_download_folder(MainWindow* self)
auto* priv = MAIN_WINDOW_GET_PRIVATE(MAIN_WINDOW(self));
g_return_if_fail(priv);
update_data_transfer(priv->cpp->lrc_->getDataTransferModel(), priv->window_settings);
update_data_transfer(priv->cpp->lrc_->getAccountModel(), priv->window_settings);
}
#if USE_LIBNM
......@@ -1344,7 +1350,7 @@ CppImpl::init()
if (g_settings_get_boolean(widgets->window_settings, "window-maximized"))
gtk_window_maximize(GTK_WINDOW(self));
update_data_transfer(lrc_->getDataTransferModel(), widgets->window_settings);
update_data_transfer(lrc_->getAccountModel(), widgets->window_settings);
/* search-entry-places-call setting */
on_search_entry_places_call_changed(widgets->window_settings, "search-entry-places-call", self);
......@@ -1401,7 +1407,7 @@ CppImpl::init()
NEW_ACCOUNT_SETTINGS_VIEW_NAME);
}
widgets->general_settings_view = general_settings_view_new(GTK_WIDGET(self), lrc_->getAVModel(), lrc_->getDataTransferModel());
widgets->general_settings_view = general_settings_view_new(GTK_WIDGET(self), lrc_->getAVModel(), lrc_->getAccountModel());
widgets->update_download_folder = g_signal_connect_swapped(
widgets->general_settings_view,
"update-download-folder",
......@@ -1741,7 +1747,7 @@ CppImpl::refreshPendingContactRequestTab()
if (!accountInfo_)
return;
auto hasPendingRequests = accountInfo_->contactModel->hasPendingRequests();
auto hasPendingRequests = accountInfo_->conversationModel->hasPendingRequests();
gtk_widget_set_visible(widgets->scrolled_window_contact_requests, hasPendingRequests);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widgets->notebook_contacts), hasPendingRequests);
......@@ -2130,18 +2136,23 @@ CppImpl::updateLrc(const std::string& id, const std::string& accountIdToFlagFree
slotNewInteraction_ = QObject::connect(&lrc_->getBehaviorController(),
&lrc::api::BehaviorController::newUnreadInteraction,
[this] (const QString& accountId, const QString& conversation,
uint64_t interactionId, const lrc::api::interaction::Info& interaction)
const QString& interactionId, const lrc::api::interaction::Info& interaction)
{ slotNewInteraction(accountId.toStdString(), conversation.toStdString(), interactionId, interaction); });
slotReadInteraction_ = QObject::connect(&lrc_->getBehaviorController(),
&lrc::api::BehaviorController::newReadInteraction,
[this] (const QString& accountId, const QString& conversation, uint64_t interactionId)
[this] (const QString& accountId, const QString& conversation, const QString& interactionId)
{ slotCloseInteraction(accountId.toStdString(), conversation.toStdString(), interactionId); });
const gchar *text = gtk_entry_get_text(GTK_ENTRY(widgets->search_entry));
currentTypeFilter_ = accountInfo_->profileInfo.type;
lrc::api::FilterType newType;
if (accountInfo_->profileInfo.type == lrc::api::profile::Type::JAMI)
currentFilterType_ = lrc::api::FilterType::JAMI;
else if (accountInfo_->profileInfo.type == lrc::api::profile::Type::SIP)
currentFilterType_ = lrc::api::FilterType::SIP;
accountInfo_->conversationModel->setFilter(text);
accountInfo_->conversationModel->setFilter(currentTypeFilter_);
accountInfo_->conversationModel->setFilter(currentFilterType_);
}
void
......@@ -2473,7 +2484,7 @@ void
CppImpl::slotNewConversation(const std::string& uid)
{
gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->notebook_contacts), 0);
accountInfo_->conversationModel->setFilter(lrc::api::profile::Type::RING);
accountInfo_->conversationModel->setFilter(lrc::api::FilterType::JAMI);
gtk_entry_set_text(GTK_ENTRY(widgets->search_entry), "");
accountInfo_->conversationModel->setFilter("");
// Select new conversation if contact added
......@@ -2614,7 +2625,7 @@ CppImpl::slotCloseTrustRequest(const std::string& id, const std::string& contact
void
CppImpl::slotNewInteraction(const std::string& accountId, const std::string& conversation,
uint64_t interactionId, const lrc::api::interaction::Info& interaction)
const QString& interactionId, const lrc::api::interaction::Info& interaction)
{
if (chatViewConversation_ && chatViewConversation_->get().uid == QString::fromStdString(conversation)) {
auto *old_view = gtk_bin_get_child(GTK_BIN(widgets->frame_call));
......@@ -2627,7 +2638,7 @@ CppImpl::slotNewInteraction(const std::string& accountId, const std::string& con
}
try {
auto& accountInfo = lrc_->getAccountModel().getAccountInfo(QString::fromStdString(accountId));
auto notifId = accountInfo.id.toStdString() + ":interaction:" + conversation + ":" + std::to_string(interactionId);
auto notifId = accountInfo.id.toStdString() + ":interaction:" + conversation + ":" + interactionId.toStdString();
auto& contactModel = accountInfo.contactModel;
auto& conversationModel = accountInfo.conversationModel;
for (lrc::api::conversation::Info& conv : conversationModel->allFilteredConversations().get())
......@@ -2666,7 +2677,7 @@ CppImpl::slotNewInteraction(const std::string& accountId, const std::string& con
}
void
CppImpl::slotCloseInteraction(const std::string& accountId, const std::string& conversation, uint64_t interactionId)
CppImpl::slotCloseInteraction(const std::string& accountId, const std::string& conversation, const QString& interactionId)
{
if (!gtk_window_is_active(GTK_WINDOW(self))
|| (chatViewConversation_ && chatViewConversation_->get().uid != QString::fromStdString(conversation))) {
......@@ -2674,7 +2685,7 @@ CppImpl::slotCloseInteraction(const std::string& accountId, const std::string& c
}
try {
auto& accountInfo = lrc_->getAccountModel().getAccountInfo(QString::fromStdString(accountId));
auto notifId = accountInfo.id.toStdString() + ":interaction:" + conversation + ":" + std::to_string(interactionId);
auto notifId = accountInfo.id.toStdString() + ":interaction:" + conversation + ":" + interactionId.toStdString();
hide_notification(NOTIFIER(widgets->notifier), notifId);
} catch (...) {
g_warning("Can't get account %s", accountId.c_str());
......@@ -2748,7 +2759,7 @@ main_window_requests_list(MainWindow *win)
{
g_return_if_fail(IS_MAIN_WINDOW(win));
auto *priv = MAIN_WINDOW_GET_PRIVATE(MAIN_WINDOW(win));
if (!priv->cpp->accountInfo_->contactModel->hasPendingRequests()) return;
if (!priv->cpp->accountInfo_->conversationModel->hasPendingRequests()) return;
auto contactRequestsPageNum = gtk_notebook_page_num(GTK_NOTEBOOK(priv->notebook_contacts),
priv->scrolled_window_contact_requests);
gtk_notebook_set_current_page(GTK_NOTEBOOK(priv->notebook_contacts), contactRequestsPageNum);
......
......@@ -1464,7 +1464,7 @@ set_account_enabled(GObject*, GParamSpec*, NewAccountSettingsView *view)
if (!is_config_ok(view)) return;
auto* priv = NEW_ACCOUNT_SETTINGS_VIEW_GET_PRIVATE(view);
auto newState = false;
if ((*priv->accountInfo_)->profileInfo.type == lrc::api::profile::Type::RING) {
if ((*priv->accountInfo_)->profileInfo.type == lrc::api::profile::Type::JAMI) {
newState = gtk_switch_get_active(GTK_SWITCH(priv->account_enabled));
} else {
newState = gtk_switch_get_active(GTK_SWITCH(priv->sip_account_enabled));
......@@ -2056,7 +2056,7 @@ new_account_settings_view_update(NewAccountSettingsView *view, gboolean reset_vi
bool has_account_manager = !priv->currentProp_->managerUri.isEmpty();
auto label_status = priv->label_status;
if ((*priv->accountInfo_)->profileInfo.type != lrc::api::profile::Type::RING) {
if ((*priv->accountInfo_)->profileInfo.type != lrc::api::profile::Type::JAMI) {
label_status = priv->sip_label_status;
}
......@@ -2084,7 +2084,7 @@ new_account_settings_view_update(NewAccountSettingsView *view, gboolean reset_vi
((*priv->accountInfo_)->status) == lrc::api::account::Status::REGISTERED);
gtk_entry_set_text(GTK_ENTRY(priv->entry_display_name), qUtf8Printable((*priv->accountInfo_)->profileInfo.alias));
if ((*priv->accountInfo_)->profileInfo.type == lrc::api::profile::Type::RING) {
if ((*priv->accountInfo_)->profileInfo.type == lrc::api::profile::Type::JAMI) {
gtk_switch_set_active(GTK_SWITCH(priv->account_enabled), (*priv->accountInfo_)->enabled);
gtk_widget_show_all(priv->vbox_devices);
......
......@@ -173,7 +173,8 @@ webkit_chat_container_execute_js(WebKitChatContainer *view, const gchar* functio
QJsonObject
build_interaction_json(lrc::api::ConversationModel& conversation_model,
const uint64_t msgId,
const QString& convId,
const QString& msgId,
const lrc::api::interaction::Info& interaction)
{
auto sender = interaction.authorUri;
......@@ -185,7 +186,7 @@ build_interaction_json(lrc::api::ConversationModel& conversation_model,
QJsonObject interaction_object = QJsonObject();
interaction_object.insert("text", QJsonValue(interaction.body));
interaction_object.insert("id", QJsonValue(QString::number(msgId)));
interaction_object.insert("id", QJsonValue(msgId));
interaction_object.insert("sender", QJsonValue(sender));
interaction_object.insert("duration", QJsonValue(static_cast<int>(interaction.duration)));
interaction_object.insert("sender_contact_method", QJsonValue(sender));
......@@ -206,7 +207,7 @@ build_interaction_json(lrc::api::ConversationModel& conversation_model,
case lrc::api::interaction::Type::DATA_TRANSFER: {
interaction_object.insert("type", QJsonValue("data_transfer"));
lrc::api::datatransfer::Info info = {};
conversation_model.getTransferInfo(msgId, info);
conversation_model.getTransferInfo(convId, msgId, info);
if (info.status != lrc::api::datatransfer::Status::INVALID) {
interaction_object.insert("totalSize", QJsonValue(qint64(info.totalSize)));
interaction_object.insert("progress", QJsonValue(qint64(info.progress)));
......@@ -273,19 +274,20 @@ build_interaction_json(lrc::api::ConversationModel& conversation_model,
QString
interaction_to_json_interaction_object(lrc::api::ConversationModel& conversation_model,
const uint64_t msgId,
const QString& convId,
const QString& msgId,
const lrc::api::interaction::Info& interaction)
{
auto interaction_object = build_interaction_json(conversation_model, msgId, interaction);
auto interaction_object = build_interaction_json(conversation_model, convId, msgId, interaction);
return QString(QJsonDocument(interaction_object).toJson(QJsonDocument::Compact));
}
QString
interactions_to_json_array_object(lrc::api::ConversationModel& conversation_model,
const std::map<uint64_t, lrc::api::interaction::Info> interactions) {
lrc::api::MessagesList interactions) {
QJsonArray array;
for (const auto& interaction: interactions)
array.append(build_interaction_json(conversation_model, interaction.first, interaction.second));
array.append(build_interaction_json(conversation_model, 0, interaction.first, interaction.second));
return QString(QJsonDocument(array).toJson(QJsonDocument::Compact));
}
......@@ -708,17 +710,18 @@ webkit_chat_container_clear(WebKitChatContainer *view)
void
webkit_chat_container_update_interaction(WebKitChatContainer *view,
lrc::api::ConversationModel& conversation_model,
uint64_t msgId,
const QString& convUid,
const QString& msgId,
const lrc::api::interaction::Info& interaction)
{
auto interaction_object = interaction_to_json_interaction_object(conversation_model, msgId, interaction).toUtf8();
auto interaction_object = interaction_to_json_interaction_object(conversation_model, convUid, msgId, interaction).toUtf8();
gchar* function_call = g_strdup_printf("updateMessage(%s);", interaction_object.constData());
webkit_chat_container_execute_js(view, function_call);
g_free(function_call);
}
void
webkit_chat_container_remove_interaction(WebKitChatContainer *view, uint64_t interactionId)
webkit_chat_container_remove_interaction(WebKitChatContainer *view, const QString& interactionId)
{
gchar* function_call = g_strdup_printf("removeInteraction(%lu);", interactionId);
webkit_chat_container_execute_js(view, function_call);
......@@ -729,10 +732,11 @@ webkit_chat_container_remove_interaction(WebKitChatContainer *view, uint64_t int
void
webkit_chat_container_print_new_interaction(WebKitChatContainer *view,
lrc::api::ConversationModel& conversation_model,
uint64_t msgId,
const QString& convUid,
const QString& msgId,
const lrc::api::interaction::Info& interaction)
{
auto interaction_object = interaction_to_json_interaction_object(conversation_model, msgId, interaction).toUtf8();
auto interaction_object = interaction_to_json_interaction_object(conversation_model, convUid, msgId, interaction).toUtf8();
gchar* function_call = g_strdup_printf("addMessage(%s);", interaction_object.constData());
webkit_chat_container_execute_js(view, function_call);
g_free(function_call);
......@@ -741,7 +745,7 @@ webkit_chat_container_print_new_interaction(WebKitChatContainer *view,
void
webkit_chat_container_print_history(WebKitChatContainer *view,
lrc::api::ConversationModel& conversation_model,
const std::map<uint64_t, lrc::api::interaction::Info> interactions)
lrc::api::MessagesList interactions)
{
auto interactions_str = interactions_to_json_array_object(conversation_model, interactions).toUtf8();
gchar* function_call = g_strdup_printf("printHistory(%s)", interactions_str.constData());
......
......@@ -22,13 +22,13 @@
// Gtk
#include <gtk/gtk.h>
#include <map>
// LRC
#include <api/interaction.h>
namespace lrc { namespace api {
class ConversationModel;
class MessagesList;
}};
G_BEGIN_DECLS
......@@ -46,10 +46,10 @@ GType webkit_chat_container_get_type (void) G_GNUC_CONST;
GtkWidget* webkit_chat_container_new (void);
void webkit_chat_container_clear (WebKitChatContainer *view);
void webkit_chat_container_clear_sender_images (WebKitChatContainer *view);
void webkit_chat_container_print_new_interaction(WebKitChatContainer *view, lrc::api::ConversationModel& conversation_model, uint64_t msgId, const lrc::api::interaction::Info& interaction);
void webkit_chat_container_update_interaction (WebKitChatContainer *view, lrc::api::ConversationModel& conversation_model, uint64_t msgId, const lrc::api::interaction::Info& interaction);
void webkit_chat_container_remove_interaction (WebKitChatContainer *view, uint64_t interactionId);
void webkit_chat_container_print_history (WebKitChatContainer *view, lrc::api::ConversationModel& conversation_model, const std::map<uint64_t, lrc::api::interaction::Info> interactions);
void webkit_chat_container_print_new_interaction(WebKitChatContainer *view, lrc::api::ConversationModel& conversation_model, const QString& convUid, const QString& msgId, const lrc::api::interaction::Info& interaction);
void webkit_chat_container_update_interaction (WebKitChatContainer *view, lrc::api::ConversationModel& conversation_model, const QString& convUid, const QString& msgId, const lrc::api::interaction::Info& interaction);
void webkit_chat_container_remove_interaction (WebKitChatContainer *view, const QString& interactionId);
void webkit_chat_container_print_history (WebKitChatContainer *view, lrc::api::ConversationModel& conversation_model, lrc::api::MessagesList interactions);
void webkit_chat_container_set_sender_image (WebKitChatContainer *view, const std::string& sender, const std::string& senderImage);
gboolean webkit_chat_container_is_ready (WebKitChatContainer *view);
void webkit_chat_container_set_display_links (WebKitChatContainer *view, bool display);
......
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