Commit baf20c86 authored by Nicolas Jager's avatar Nicolas Jager Committed by Guillaume Roguez

check obsolete history at start

- if there is some obsolete history, it will call from lrc
deleteObsoleteHistory.

Change-Id: I8ac9ffad3438f82645f0079e02fc42c23d02f1b2
Reviewed-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent a8804820
......@@ -220,7 +220,7 @@ public:
QMetaObject::Connection newConversationConnection_;
QMetaObject::Connection conversationRemovedConnection_;
QMetaObject::Connection accountStatusChangedConnection_;
QMetaObject::Connection chat_notification_;
QMetaObject::Connection chatNotification_;
private:
CppImpl() = delete;
......@@ -231,6 +231,7 @@ private:
GtkWidget* displayIncomingView(lrc::api::conversation::Info);
GtkWidget* displayCurrentCallView(lrc::api::conversation::Info);
GtkWidget* displayChatView(lrc::api::conversation::Info);
void chatNotifications();
// Callbacks used as LRC Qt slot
void slotAccountAddedFromLrc(const std::string& id);
......@@ -542,6 +543,23 @@ CppImpl::CppImpl(RingMainWindow& widget)
, lrc_ {std::make_unique<lrc::api::Lrc>()}
{}
void
CppImpl::chatNotifications()
{
chatNotification_ = QObject::connect(
&Media::RecordingModel::instance(),
&Media::RecordingModel::newTextMessage,
[this] (Media::TextRecording* t, ContactMethod* cm) {
if ((chatViewConversation_
&& chatViewConversation_->participants[0] == cm->uri().toStdString())
|| not g_settings_get_boolean(widgets->settings, "enable-chat-notifications"))
return;
ring_notify_message(cm, t);
}
);
}
void
CppImpl::init()
{
......@@ -751,6 +769,19 @@ CppImpl::init()
}
}
}
// setup chat notification
chatNotifications();
// delete obsolete history
if (not accountIds.empty()) {
auto days = g_settings_get_int(widgets->settings, "history-limit");
for (auto& accountId : accountIds) {
auto& accountInfo = lrc_->getAccountModel().getAccountInfo(accountId);
accountInfo.conversationModel->deleteObsoleteHistory(days);
}
}
}
CppImpl::~CppImpl()
......@@ -768,7 +799,7 @@ CppImpl::~CppImpl()
QObject::disconnect(showCallViewConnection_);
QObject::disconnect(modelSortedConnection_);
QObject::disconnect(accountStatusChangedConnection_);
QObject::disconnect(chat_notification_);
QObject::disconnect(chatNotification_);
g_clear_object(&widgets->welcome_view);
g_clear_object(&widgets->webkit_chat_container);
......@@ -1417,24 +1448,6 @@ CppImpl::slotShowIncomingCallView(const std::string& id, lrc::api::conversation:
//==============================================================================
static void
chat_notifications(RingMainWindow *win)
{
auto* priv = RING_MAIN_WINDOW_GET_PRIVATE(win);
priv->cpp->chat_notification_ = QObject::connect(
&Media::RecordingModel::instance(),
&Media::RecordingModel::newTextMessage,
[win, priv] (Media::TextRecording* t, ContactMethod* cm) {
if ((priv->cpp->chatViewConversation_
&& priv->cpp->chatViewConversation_->participants[0] == cm->uri().toStdString())
|| not g_settings_get_boolean(priv->settings, "enable-chat-notifications"))
return;
ring_notify_message(cm, t);
}
);
}
static void
ring_main_window_init(RingMainWindow *win)
{
......@@ -1445,8 +1458,6 @@ ring_main_window_init(RingMainWindow *win)
priv->cpp = new details::CppImpl {*win};
priv->cpp->init();
// setup chat notification
chat_notifications(win);
}
static void
......
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