Commit 3d2555a9 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Sébastien Blin

refacto: use new lrc database adaptations

Change-Id: Iedda0244d82dd8bdb203fb6f27a7dac115fbca9a
parent e7854ba0
......@@ -416,7 +416,7 @@ print_interaction_to_buffer(ChatView* self, uint64_t interactionId, const lrc::a
ChatViewPrivate *priv = CHAT_VIEW_GET_PRIVATE(self);
if (!priv->conversation_) return;
if (interaction.status == lrc::api::interaction::Status::UNREAD)
if (!interaction.isRead)
(*priv->accountInfo_)->conversationModel->setInteractionRead(priv->conversation_->uid, interactionId);
webkit_chat_container_print_new_interaction(
......@@ -463,7 +463,7 @@ load_participants_images(ChatView *self)
if (!contact.profileInfo.avatar.empty()) {
webkit_chat_container_set_sender_image(
WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
(*priv->accountInfo_)->contactModel->getContactProfileId(contactUri),
contactUri,
contact.profileInfo.avatar
);
}
......@@ -475,7 +475,7 @@ load_participants_images(ChatView *self)
if (!(*priv->accountInfo_)->profileInfo.avatar.empty()) {
webkit_chat_container_set_sender_image(
WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
(*priv->accountInfo_)->contactModel->getContactProfileId((*priv->accountInfo_)->profileInfo.uri),
(*priv->accountInfo_)->profileInfo.uri,
(*priv->accountInfo_)->profileInfo.avatar
);
}
......@@ -490,7 +490,7 @@ print_text_recording(ChatView *self)
// Read interactions
if (!priv->conversation_) return;
for (const auto& it: priv->conversation_->interactions) {
if (it.second.status == lrc::api::interaction::Status::UNREAD)
if (!it.second.isRead)
(*priv->accountInfo_)->conversationModel->setInteractionRead(priv->conversation_->uid, it.first);
}
......@@ -596,7 +596,7 @@ update_chatview_frame(ChatView* self)
webkit_chat_container_set_invitation(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
(contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING),
bestName,
(*priv->accountInfo_)->contactModel->getContactProfileId(contactInfo.profileInfo.uri));
contactInfo.profileInfo.uri);
// hide navbar if we are in call
try {
......
......@@ -212,6 +212,7 @@ public:
lrc::api::AVModel* avModel_;
QMetaObject::Connection state_change_connection;
QMetaObject::Connection update_vcard_connection;
QMetaObject::Connection renderer_connection;
QMetaObject::Connection smartinfo_refresh_connection;
......@@ -661,6 +662,7 @@ CppImpl::CppImpl(CurrentCallView& widget)
CppImpl::~CppImpl()
{
QObject::disconnect(state_change_connection);
QObject::disconnect(update_vcard_connection);
QObject::disconnect(renderer_connection);
QObject::disconnect(smartinfo_refresh_connection);
g_clear_object(&widgets->settings);
......@@ -826,11 +828,21 @@ CppImpl::setCallInfo()
&lrc::api::NewCallModel::callStatusChanged,
[this] (const std::string& callId) {
if (callId == conversation->callId) {
updateState();
updateNameAndPhoto();
}
});
update_vcard_connection = QObject::connect(
&*(*accountInfo)->contactModel,
&lrc::api::ContactModel::contactAdded,
[this] (const std::string& uri) {
if (uri == conversation->participants.front()) {
updateNameAndPhoto();
}
});
// catch double click to make full screen
g_signal_connect(widgets->video_widget, "button-press-event",
G_CALLBACK(on_button_press_in_video_event), self);
......
......@@ -131,6 +131,8 @@ struct RingMainWindowPrivate
gboolean key_pressed = false;
GCancellable *cancellable;
GtkWidget* migratingDialog_;
#if USE_LIBNM
/* NetworkManager */
NMClient *nm_client;
......@@ -981,8 +983,38 @@ on_notification_decline_call(GtkWidget*, gchar *title, RingMainWindow* self)
CppImpl::CppImpl(RingMainWindow& widget)
: self {&widget}
, widgets {RING_MAIN_WINDOW_GET_PRIVATE(&widget)}
, lrc_ {std::make_unique<lrc::api::Lrc>()}
{}
{
lrc_ = std::make_unique<lrc::api::Lrc>([this](){
widgets->migratingDialog_ = gtk_message_dialog_new(
GTK_WINDOW(self), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, nullptr);
gtk_window_set_title(GTK_WINDOW(widgets->migratingDialog_), _("Jami - Migration needed"));
auto* content_area = gtk_dialog_get_content_area(GTK_DIALOG(widgets->migratingDialog_));
GError *error = nullptr;
GdkPixbuf* logo_jami = gdk_pixbuf_new_from_resource_at_scale("/net/jami/JamiGnome/jami-logo-blue",
-1, 128, TRUE, &error);
if (!logo_jami) {
g_debug("Could not load logo: %s", error->message);
g_clear_error(&error);
return;
}
auto* image = gtk_image_new_from_pixbuf(logo_jami);
auto* label = gtk_label_new(_("Migration in progress... please do not close this window."));
gtk_container_add(GTK_CONTAINER(content_area), image);
gtk_container_add(GTK_CONTAINER(content_area), label);
gtk_widget_set_margin_left(content_area, 32);
gtk_widget_set_margin_right(content_area, 32);
gtk_widget_show_all(widgets->migratingDialog_);
gtk_dialog_run(GTK_DIALOG(widgets->migratingDialog_));
},
[this](){
gtk_widget_destroy(widgets->migratingDialog_);
});
}
static void
on_clear_all_history_clicked(RingMainWindow* self)
......@@ -2090,7 +2122,7 @@ CppImpl::slotCallStatusChanged(const std::string& callId)
}
try {
auto call = accountInfo_->callModel->getCall(callId);
auto peer = call.peer;
auto peer = call.peerUri;
if (accountInfo_->profileInfo.type == lrc::api::profile::Type::RING && peer.find("ring:") == 0) {
peer = peer.substr(5);
}
......@@ -2150,7 +2182,7 @@ CppImpl::slotNewIncomingCall(const std::string& callId)
}
try {
auto call = accountInfo_->callModel->getCall(callId);
auto peer = call.peer;
auto peer = call.peerUri;
if (accountInfo_->profileInfo.type == lrc::api::profile::Type::RING && peer.find("ring:") == 0) {
peer = peer.substr(5);
}
......
......@@ -33,6 +33,7 @@
// LRC
#include <globalinstances.h>
#include <api/conversationmodel.h>
#include <api/account.h>
// Ring Client
#include "native/pixbufmanipulator.h"
......@@ -175,6 +176,9 @@ build_interaction_json(lrc::api::ConversationModel& conversation_model,
const lrc::api::interaction::Info& interaction)
{
auto sender = QString(interaction.authorUri.c_str());
if (sender == "") {
sender = QString(conversation_model.owner.profileInfo.uri.c_str());
}
auto timestamp = QString::number(interaction.timestamp);
auto direction = lrc::api::interaction::isOutgoing(interaction) ? QString("out") : QString("in");
......@@ -197,8 +201,7 @@ build_interaction_json(lrc::api::ConversationModel& conversation_model,
case lrc::api::interaction::Type::CONTACT:
interaction_object.insert("type", QJsonValue("contact"));
break;
case lrc::api::interaction::Type::OUTGOING_DATA_TRANSFER:
case lrc::api::interaction::Type::INCOMING_DATA_TRANSFER: {
case lrc::api::interaction::Type::DATA_TRANSFER: {
interaction_object.insert("type", QJsonValue("data_transfer"));
lrc::api::datatransfer::Info info = {};
conversation_model.getTransferInfo(msgId, info);
......@@ -214,15 +217,16 @@ build_interaction_json(lrc::api::ConversationModel& conversation_model,
break;
}
if (interaction.isRead) {
interaction_object.insert("delivery_status", QJsonValue("read"));
}
switch (interaction.status)
{
case lrc::api::interaction::Status::READ:
interaction_object.insert("delivery_status", QJsonValue("read"));
break;
case lrc::api::interaction::Status::SUCCEED:
case lrc::api::interaction::Status::SUCCESS:
interaction_object.insert("delivery_status", QJsonValue("sent"));
break;
case lrc::api::interaction::Status::FAILED:
case lrc::api::interaction::Status::FAILURE:
case lrc::api::interaction::Status::TRANSFER_ERROR:
interaction_object.insert("delivery_status", QJsonValue("failure"));
break;
......@@ -258,7 +262,6 @@ build_interaction_json(lrc::api::ConversationModel& conversation_model,
break;
case lrc::api::interaction::Status::INVALID:
case lrc::api::interaction::Status::UNKNOWN:
case lrc::api::interaction::Status::UNREAD:
default:
interaction_object.insert("delivery_status", QJsonValue("unknown"));
break;
......
......@@ -326,8 +326,9 @@ function showInvitation(contactAlias, contactId) {
if (!inviteImage.classList.contains("sender_image")) {
inviteImage.classList.add("sender_image")
}
if (!inviteImage.classList.contains(`sender_image_${contactId}`)) {
inviteImage.classList.add(`sender_image_${contactId}`)
const className = `sender_image_${contactId}`.replace(/@/g, "_").replace(/\./g, "_")
if (!inviteImage.classList.contains(className)) {
inviteImage.classList.add(className);
}
hasInvitation = true
invitationText.innerHTML = "<b>"
......@@ -1649,7 +1650,7 @@ function printHistory(messages_array)
/* exported setSenderImage */
function setSenderImage(set_sender_image_object)
{
var sender_contact_method = set_sender_image_object["sender_contact_method"],
var sender_contact_method = set_sender_image_object["sender_contact_method"].replace(/@/g, "_").replace(/\./g, "_"),
sender_image = set_sender_image_object["sender_image"],
sender_image_id = "sender_image_" + sender_contact_method,
currentSenderImage = document.getElementById(sender_image_id), // Remove the currently set sender image
......
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