From 3ae5317f05f6cfa5633aad0b42252c908a73b282 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Tue, 24 Jul 2018 10:11:28 -0400
Subject: [PATCH] misc: remove unused code from old LRC models

Change-Id: Ida3f87a0c61195e60bc6e8630d9c50edf18f14cc
---
 CMakeLists.txt                            |   6 -
 src/accountcreationwizard.cpp             |   5 -
 src/accountgeneraltab.cpp                 |   2 +-
 src/avatarmanipulation.cpp                |   3 +-
 src/conversationpopupmenu.cpp             |   7 +-
 src/currentcallview.cpp                   |   5 +-
 src/generalsettingsview.cpp               |   5 -
 src/models/namenumberfilterproxymodel.cpp | 105 ---------------
 src/models/namenumberfilterproxymodel.h   |  32 -----
 src/ring_client.cpp                       | 154 +---------------------
 src/ringmainwindow.cpp                    |  44 +++----
 src/ringnotify.cpp                        |   6 -
 src/ringwelcomeview.cpp                   |   3 -
 src/utils/accounts.cpp                    |  57 --------
 src/utils/accounts.h                      |  46 -------
 src/utils/calling.cpp                     |  55 --------
 src/utils/calling.h                       |  29 ----
 src/video/video_widget.cpp                |   2 +
 18 files changed, 32 insertions(+), 534 deletions(-)
 delete mode 100644 src/models/namenumberfilterproxymodel.cpp
 delete mode 100644 src/models/namenumberfilterproxymodel.h
 delete mode 100644 src/utils/accounts.cpp
 delete mode 100644 src/utils/accounts.h
 delete mode 100644 src/utils/calling.cpp
 delete mode 100644 src/utils/calling.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 91416853..ae62be61 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -290,15 +290,11 @@ SET( SRC_FILES
    src/native/pixbufmanipulator.cpp
    src/utils/models.h
    src/utils/models.cpp
-   src/utils/calling.h
-   src/utils/calling.cpp
    src/ringnotify.h
    src/ringnotify.cpp
    src/utils/files.h
    src/utils/files.cpp
    ${GIT_REVISION_OUTPUT_FILE}
-   src/utils/accounts.h
-   src/utils/accounts.cpp
    src/native/dbuserrorhandler.h
    src/native/dbuserrorhandler.cpp
    src/ringwelcomeview.h
@@ -313,8 +309,6 @@ SET( SRC_FILES
    src/avatarmanipulation.cpp
    src/cc-crop-area.h
    src/cc-crop-area.c
-   src/models/namenumberfilterproxymodel.h
-   src/models/namenumberfilterproxymodel.cpp
    src/conversationsview.h
    src/conversationsview.cpp
    src/conversationpopupmenu.h
diff --git a/src/accountcreationwizard.cpp b/src/accountcreationwizard.cpp
index e1d1e7bf..e6361c06 100644
--- a/src/accountcreationwizard.cpp
+++ b/src/accountcreationwizard.cpp
@@ -23,11 +23,6 @@
 #include <gtk/gtk.h>
 
 // LRC
-#include <account.h>
-#include <profilemodel.h>
-#include <profile.h>
-#include <accountmodel.h>
-#include <personmodel.h>
 #include "api/newaccountmodel.h"
 
 // Ring Client
diff --git a/src/accountgeneraltab.cpp b/src/accountgeneraltab.cpp
index f6465886..6a12d297 100644
--- a/src/accountgeneraltab.cpp
+++ b/src/accountgeneraltab.cpp
@@ -23,7 +23,7 @@
 
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
-#include <account.h>
+
 #include "defines.h"
 #include "utils/models.h"
 #include "usernameregistrationbox.h"
diff --git a/src/avatarmanipulation.cpp b/src/avatarmanipulation.cpp
index 18fb2ce6..e8a94060 100644
--- a/src/avatarmanipulation.cpp
+++ b/src/avatarmanipulation.cpp
@@ -24,8 +24,7 @@
 #include <api/newaccountmodel.h>
 #include <api/avmodel.h>
 #include <globalinstances.h>
-#include <person.h>
-#include <profile.h>
+#include <QSize>
 
 /* client */
 #include "native/pixbufmanipulator.h"
diff --git a/src/conversationpopupmenu.cpp b/src/conversationpopupmenu.cpp
index dd0d74f1..306a36ca 100644
--- a/src/conversationpopupmenu.cpp
+++ b/src/conversationpopupmenu.cpp
@@ -23,12 +23,9 @@
 #include <glib/gi18n.h>
 
 // Lrc
-#include <accountmodel.h>
-#include <bannedcontactmodel.h>
-#include <contactmethod.h>
-#include <api/conversationmodel.h>
-#include <api/contactmodel.h>
 #include <api/contact.h>
+#include <api/contactmodel.h>
+#include <api/conversationmodel.h>
 
 #include "accountinfopointer.h"
 
diff --git a/src/currentcallview.cpp b/src/currentcallview.cpp
index be79502f..9a8aade3 100644
--- a/src/currentcallview.cpp
+++ b/src/currentcallview.cpp
@@ -34,6 +34,7 @@
 #include <globalinstances.h>
 #include <smartinfohub.h>
 #include <video/previewmanager.h>
+#include <QSize>
 
 // Client
 #include "chatview.h"
@@ -43,10 +44,6 @@
 #include "utils/files.h"
 #include "video/video_widget.h"
 
-// std
-#include <memory> // for std::shared_ptr
-#include <string>
-
 namespace { namespace details
 {
 class CppImpl;
diff --git a/src/generalsettingsview.cpp b/src/generalsettingsview.cpp
index 1b26f54b..885642cc 100644
--- a/src/generalsettingsview.cpp
+++ b/src/generalsettingsview.cpp
@@ -24,11 +24,6 @@
 #include <glib/gi18n.h>
 #include <glib.h>
 
-// LRC
-#include <person.h>
-#include <categorizedhistorymodel.h>
-#include <media/recordingmodel.h>
-
 // Ring client
 #include "utils/files.h"
 #include "avatarmanipulation.h"
diff --git a/src/models/namenumberfilterproxymodel.cpp b/src/models/namenumberfilterproxymodel.cpp
deleted file mode 100644
index b32076db..00000000
--- a/src/models/namenumberfilterproxymodel.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- *  Copyright (C) 2016-2018 Savoir-faire Linux Inc.
- *  Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
- */
-
-#include "namenumberfilterproxymodel.h"
-
-// LRC
-#include <itemdataroles.h>
-#include <person.h>
-#include <contactmethod.h>
-#include <call.h>
-
-NameNumberFilterProxy::NameNumberFilterProxy(QAbstractItemModel* sourceModel)
-{
-    setParent(sourceModel);
-    setSourceModel(sourceModel);
-}
-
-bool
-NameNumberFilterProxy::filterAcceptsRow(int source_row, const QModelIndex & source_parent) const
-{
-    // we filter the regex only on Calls, Contacts and ContactMethods; however we don't want to display
-    // the top nodes (Categories) if they have no children
-    if (!source_parent.isValid() && filterRegExp().isEmpty()) {
-        return true;
-    } else if (!source_parent.isValid()) {
-        // check if there are any children, don't display the categroy if not
-        auto idx = sourceModel()->index(source_row, 0, source_parent);
-        if (!idx.isValid())
-            return false;
-
-        for (int row = 0; row <  sourceModel()->rowCount(idx); ++row) {
-            if (filterAcceptsRow(row, idx)) {
-                return true;
-            }
-        }
-        return false;
-    } else {
-        auto idx = sourceModel()->index(source_row, 0, source_parent);
-
-        if (!idx.isValid()) {
-            return false;
-        }
-
-        //we want to filter on name and number; note that Person object may have many numbers
-        if (idx.data(static_cast<int>(Ring::Role::Name)).toString().contains(filterRegExp())) {
-            return true;
-        } else {
-            auto type = idx.data(static_cast<int>(Ring::Role::ObjectType));
-            auto object = idx.data(static_cast<int>(Ring::Role::Object));
-
-            if (!type.isValid() || !object.isValid()) {
-                return false;
-            }
-
-            switch (type.value<Ring::ObjectType>()) {
-                case Ring::ObjectType::Person:
-                {
-                    auto p = object.value<Person *>();
-                    for (auto cm : p->phoneNumbers()) {
-                        if (cm->uri().full().contains(filterRegExp())) {
-                            return true;
-                        }
-                    }
-                    return false;
-                }
-                break;
-                case Ring::ObjectType::ContactMethod:
-                {
-                    auto cm = object.value<ContactMethod *>();
-                    return cm->uri().full().contains(filterRegExp());
-                }
-                break;
-                case Ring::ObjectType::Call:
-                {
-                    auto call = object.value<Call *>();
-                    return call->peerContactMethod()->uri().full().contains(filterRegExp());
-                }
-                break;
-                case Ring::ObjectType::Media:
-                case Ring::ObjectType::Certificate:
-                case Ring::ObjectType::ContactRequest:
-                case Ring::ObjectType::COUNT__:
-                break;
-            }
-
-        }
-        return false; // no matches
-    }
-}
diff --git a/src/models/namenumberfilterproxymodel.h b/src/models/namenumberfilterproxymodel.h
deleted file mode 100644
index b1bdfc91..00000000
--- a/src/models/namenumberfilterproxymodel.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *  Copyright (C) 2016-2018 Savoir-faire Linux Inc.
- *  Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
- */
-
-#pragma once
-
-#include <QtCore/QSortFilterProxyModel>
-
-class NameNumberFilterProxy : public QSortFilterProxyModel
-{
-public:
-    NameNumberFilterProxy(QAbstractItemModel* source_model);
-
-protected:
-    virtual bool filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const override;
-
-};
diff --git a/src/ring_client.cpp b/src/ring_client.cpp
index ec1e9bb9..a4d27b52 100644
--- a/src/ring_client.cpp
+++ b/src/ring_client.cpp
@@ -37,21 +37,8 @@
 #include <QtCore/QStandardPaths>
 
 // LRC
-#include <callmodel.h>
-#include <useractionmodel.h>
-#include <categorizedhistorymodel.h>
-#include <personmodel.h>
-#include <fallbackpersoncollection.h>
-#include <numbercategorymodel.h>
-#include <globalinstances.h>
-#include <profilemodel.h>
-#include <profile.h>
-#include <peerprofilecollection.h>
-#include <localprofilecollection.h>
-#include <accountmodel.h>
 #include <smartinfohub.h>
-#include <media/recordingmodel.h>
-#include <availableaccountmodel.h>
+#include <globalinstances.h>
 
 // Ring client
 #include "ring_client_options.h"
@@ -63,8 +50,6 @@
 #include "config.h"
 #include "utils/files.h"
 #include "revision.h"
-#include "utils/accounts.h"
-#include "utils/calling.h"
 
 #if HAVE_AYATANAAPPINDICATOR
 #include <libayatana-appindicator/app-indicator.h>
@@ -72,10 +57,6 @@
 #include <libappindicator/app-indicator.h>
 #endif
 
-#if USE_LIBNM
-#include <NetworkManager.h>
-#endif
-
 struct _RingClientClass
 {
     GtkApplicationClass parent_class;
@@ -105,18 +86,10 @@ struct _RingClientPrivate {
     std::unique_ptr<QTranslator> translator_lang;
     std::unique_ptr<QTranslator> translator_full;
 
-    GCancellable *cancellable;
-
     gboolean restore_window_state;
 
     gpointer systray_icon;
     GtkWidget *icon_menu;
-
-#if USE_LIBNM
-    /* NetworkManager */
-    NMClient *nm_client;
-    NMActiveConnection *primary_connection;
-#endif
 };
 
 /* this union is used to pass ints as pointers and vice versa for GAction parameters*/
@@ -371,96 +344,18 @@ ring_client_activate(GApplication *app)
     }
 }
 
+// TODO add some args!
 static void
 ring_client_open(GApplication *app, GFile **file, gint /*arg3*/, const gchar* /*arg4*/)
 {
     ring_client_activate(app);
 
-    gchar *file_uri_scheme = g_file_get_uri_scheme(*file);
-    if (strcmp(file_uri_scheme, "ring") == 0) {
-        char * call_id = g_file_get_basename(*file);
-        std::regex format {"^[[:xdigit:]]{40}$"};
-
-        if (std::regex_match(call_id, format)) {
-            auto cm = std::unique_ptr<TemporaryContactMethod>(new TemporaryContactMethod);
-            cm->setUri(URI(QString::fromStdString(call_id)));
-
-            place_new_call(cm.get());
-            cm.release();
-        }
-
-        g_free(call_id);
-    }
-
-    g_free(file_uri_scheme);
-}
-
-#if USE_LIBNM
-
-static void
-log_connection_info(NMActiveConnection *connection)
-{
-    if (connection) {
-        g_debug("primary network connection: %s, default: %s",
-                nm_active_connection_get_uuid(connection),
-                nm_active_connection_get_default(connection) ? "yes" : "no");
-    } else {
-        g_warning("no primary network connection detected, check network settings");
-    }
-}
-
-static void
-primary_connection_changed(NMClient *nm,  GParamSpec*, RingClient *self)
-{
-    auto priv = RING_CLIENT_GET_PRIVATE(self);
-    auto connection = nm_client_get_primary_connection(nm);
-
-    if (priv->primary_connection != connection) {
-        /* make sure the connection really changed
-         * on client start it seems to always emit the notify::primary-connection signal though it
-         * hasn't changed */
-        log_connection_info(connection);
-        priv->primary_connection = connection;
-        AccountModel::instance().slotConnectivityChanged();
-    }
-}
-
-static void
-nm_client_cb(G_GNUC_UNUSED GObject *source_object, GAsyncResult *result, RingClient *self)
-{
-    RingClientPrivate *priv = RING_CLIENT_GET_PRIVATE(self);
-
-    GError* error = nullptr;
-    if (auto nm_client = nm_client_new_finish(result, &error)) {
-        priv->nm_client = nm_client;
-        g_debug("NetworkManager client initialized, version: %s\ndaemon running: %s\nnnetworking enabled: %s",
-                nm_client_get_version(nm_client),
-                nm_client_get_nm_running(nm_client) ? "yes" : "no",
-                nm_client_networking_get_enabled(nm_client) ? "yes" : "no");
-
-        auto connection = nm_client_get_primary_connection(nm_client);
-        log_connection_info(connection);
-        priv->primary_connection = connection;
-
-        /* We monitor the primary connection and notify the daemon to re-load its connections
-         * (accounts, UPnP, ...) when it changes. For example, on most systems, if we have an
-         * ethernet connection and then also connect to wifi, the primary connection will not change;
-         * however it will change in the opposite case because an ethernet connection is preferred.
-         */
-        g_signal_connect(nm_client, "notify::primary-connection", G_CALLBACK(primary_connection_changed), self);
-
-    } else {
-        g_warning("error initializing NetworkManager client: %s", error->message);
-        g_clear_error(&error);
-    }
+    // TODO migrate place call at begining
 }
 
-#endif /* USE_LIBNM */
-
 static void
 ring_client_startup(GApplication *app)
 {
-    // TODO still use old LRC models, in the future, we will init the LRC here.
     RingClient *client = RING_CLIENT(app);
     RingClientPrivate *priv = RING_CLIENT_GET_PRIVATE(client);
 
@@ -482,7 +377,6 @@ ring_client_startup(GApplication *app)
     try {
         priv->qtapp = new QCoreApplication(priv->argc, priv->argv);
         /* the call model will try to connect to dring via dbus */
-        CallModel::instance();
     } catch(const char * msg) {
         exception_dialog(msg);
         exit(1);
@@ -520,24 +414,6 @@ ring_client_startup(GApplication *app)
     GlobalInstances::setPixmapManipulator(std::unique_ptr<Interfaces::PixbufManipulator>(new Interfaces::PixbufManipulator()));
     GlobalInstances::setDBusErrorHandler(std::unique_ptr<Interfaces::DBusErrorHandler>(new Interfaces::DBusErrorHandler()));
 
-    /* make sure all RING accounts have a display name... this basically makes sure
-     * that all accounts created before the display name patch have a display name
-     * set... a bit of a hack as this should maybe be done in LRC */
-    force_ring_display_name();
-
-    /* make sure basic number categories exist, in case user has no contacts
-     * from which these would be automatically created
-     */
-    NumberCategoryModel::instance().addCategory("work", QVariant());
-    NumberCategoryModel::instance().addCategory("home", QVariant());
-
-    /* add backends */
-    PersonModel::instance().addCollection<PeerProfileCollection>(LoadOptions::FORCE_ENABLED);
-    ProfileModel::instance().addCollection<LocalProfileCollection>(LoadOptions::FORCE_ENABLED);
-
-    /* fallback backend for vcards */
-    PersonModel::instance().addCollection<FallbackPersonCollection>(LoadOptions::FORCE_ENABLED);
-
     /* Override theme since we don't have appropriate icons for a dark them (yet) */
     GtkSettings *gtk_settings = gtk_settings_get_default();
     g_object_set(G_OBJECT(gtk_settings), "gtk-application-prefer-dark-theme",
@@ -561,20 +437,6 @@ ring_client_startup(GApplication *app)
     /* add accelerators */
     ring_accelerators(RING_CLIENT(app));
 
-    /* show window on incoming calls (if the option is set)*/
-    QObject::connect(&CallModel::instance(), &CallModel::incomingCall,
-        [app] (G_GNUC_UNUSED Call *call) {
-            RingClient *client = RING_CLIENT(app);
-            RingClientPrivate *priv = RING_CLIENT_GET_PRIVATE(client);
-            if (g_settings_get_boolean(priv->settings, "bring-window-to-front"))
-                ring_window_show(client);
-        }
-    );
-#if USE_LIBNM
-     /* monitor the network using libnm to notify the daemon about connectivity chagnes */
-     nm_client_new_async(priv->cancellable, (GAsyncReadyCallback)nm_client_cb, client);
-#endif
-
     G_APPLICATION_CLASS(ring_client_parent_class)->startup(app);
 }
 
@@ -586,10 +448,6 @@ ring_client_shutdown(GApplication *app)
 
     g_debug("quitting");
 
-    /* cancel any pending cancellable operations */
-    g_cancellable_cancel(priv->cancellable);
-    g_object_unref(priv->cancellable);
-
     QObject::disconnect(priv->uam_updated);
 
     /* free the QCoreApplication, which will destroy all libRingClient models
@@ -604,11 +462,6 @@ ring_client_shutdown(GApplication *app)
 
     g_clear_object(&priv->settings);
 
-#if USE_LIBNM
-    /* clear NetworkManager client if it was used */
-    g_clear_object(&priv->nm_client);
-#endif
-
     /* Chain up to the parent class */
     G_APPLICATION_CLASS(ring_client_parent_class)->shutdown(app);
 }
@@ -620,7 +473,6 @@ ring_client_init(RingClient *self)
 
     priv->win = NULL;
     priv->qtapp = NULL;
-    priv->cancellable = g_cancellable_new();
     priv->settings = g_settings_new_full(get_ring_schema(), NULL, NULL);
 
     /* add custom cmd line options */
diff --git a/src/ringmainwindow.cpp b/src/ringmainwindow.cpp
index d1a134b4..237b9591 100644
--- a/src/ringmainwindow.cpp
+++ b/src/ringmainwindow.cpp
@@ -22,16 +22,17 @@
 
 // GTK+ related
 #include <glib/gi18n.h>
-
 // std
 #include <algorithm>
 
+// Qt
+#include <QSize>
+
 // LRC
-#include <accountmodel.h> // Old lrc but still used
 #include <api/account.h>
 #include <api/avmodel.h>
+#include <api/behaviorcontroller.h>
 #include <api/contact.h>
-#include <api/profile.h>
 #include <api/contactmodel.h>
 #include <api/conversation.h>
 #include <api/conversationmodel.h>
@@ -39,13 +40,11 @@
 #include <api/lrc.h>
 #include <api/newaccountmodel.h>
 #include <api/newcallmodel.h>
-#include <api/behaviorcontroller.h>
-#include "api/account.h"
-#include <media/textrecording.h>
-#include <media/recordingmodel.h>
-#include <media/text.h>
+#include <api/profile.h>
+
 
 // Ring client
+#include "config.h"
 #include "newaccountsettingsview.h"
 #include "accountmigrationview.h"
 #include "accountcreationwizard.h"
@@ -58,13 +57,16 @@
 #include "mediasettingsview.h"
 #include "models/gtkqtreemodel.h"
 #include "ringwelcomeview.h"
-#include "utils/accounts.h"
 #include "utils/files.h"
 #include "ringnotify.h"
 #include "accountinfopointer.h"
 #include "native/pixbufmanipulator.h"
 #include "ringnotify.h"
 
+#if USE_LIBNM
+#include <NetworkManager.h>
+#endif
+
 //==============================================================================
 
 namespace { namespace details
@@ -151,11 +153,11 @@ inline namespace helpers
  * set the column value by printing the alias and the state of an account in combobox_account_selector.
  */
 static void
-print_account_and_state(G_GNUC_UNUSED GtkCellLayout* cell_layout,
+print_account_and_state(GtkCellLayout*,
                         GtkCellRenderer* cell,
                         GtkTreeModel* model,
                         GtkTreeIter* iter,
-                        G_GNUC_UNUSED gpointer* data)
+                        gpointer*)
 {
     gchar *id;
     gchar *alias;
@@ -213,11 +215,11 @@ print_account_and_state(G_GNUC_UNUSED GtkCellLayout* cell_layout,
 }
 
 static void
-render_account_avatar(G_GNUC_UNUSED GtkCellLayout* cell_layout,
+render_account_avatar(GtkCellLayout*,
                       GtkCellRenderer *cell,
                       GtkTreeModel *model,
                       GtkTreeIter *iter,
-                      G_GNUC_UNUSED gpointer data)
+                      gpointer)
 {
     gchar *id;
     gchar* avatar;
@@ -387,7 +389,6 @@ private:
 
 inline namespace gtk_callbacks
 {
-
 static void
 on_video_double_clicked(RingMainWindow* self)
 {
@@ -774,8 +775,7 @@ on_notification_refuse_pending(GtkWidget*, gchar *title, RingMainWindow* self)
 }
 
 static void
-on_notification_accept_call(G_GNUC_UNUSED GtkWidget* notifier,
-                            gchar *title, RingMainWindow* self)
+on_notification_accept_call(GtkWidget*, gchar *title, RingMainWindow* self)
 {
     g_return_if_fail(IS_RING_MAIN_WINDOW(self) && title);
     auto* priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self));
@@ -807,7 +807,7 @@ on_notification_accept_call(G_GNUC_UNUSED GtkWidget* notifier,
 }
 
 static void
-on_notification_decline_call(G_GNUC_UNUSED GtkWidget* notifier, gchar *title, RingMainWindow* self)
+on_notification_decline_call(GtkWidget*, gchar *title, RingMainWindow* self)
 {
     g_return_if_fail(IS_RING_MAIN_WINDOW(self) && title);
     auto* priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self));
@@ -843,7 +843,7 @@ CppImpl::CppImpl(RingMainWindow& widget)
 {}
 
 static gboolean
-on_clear_all_history_foreach(GtkTreeModel *model, G_GNUC_UNUSED GtkTreePath *path, GtkTreeIter *iter, gpointer self)
+on_clear_all_history_foreach(GtkTreeModel *model, GtkTreePath*, GtkTreeIter *iter, gpointer self)
 {
     g_return_val_if_fail(IS_RING_MAIN_WINDOW(self), TRUE);
 
@@ -897,7 +897,7 @@ void
 CppImpl::init()
 {
     lrc_->getAVModel().deactivateOldVideoModels();
-    // Remember the tabs page number for easier selection later
+
     smartviewPageNum = gtk_notebook_page_num(GTK_NOTEBOOK(widgets->notebook_contacts),
                                              widgets->scrolled_window_smartview);
     contactRequestsPageNum = gtk_notebook_page_num(GTK_NOTEBOOK(widgets->notebook_contacts),
@@ -1069,7 +1069,6 @@ CppImpl::init()
     // setup account selector and select the first account
     refreshAccountSelectorWidget(0);
 
-    /* layout */
     auto* renderer = gtk_cell_renderer_pixbuf_new();
     gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widgets->combobox_account_selector), renderer, true);
     gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(widgets->combobox_account_selector),
@@ -1518,8 +1517,6 @@ CppImpl::leaveSettingsView()
     /* hide the settings */
     show_settings = false;
 
-    AccountModel::instance().save();
-
     /* show calls */
     gtk_image_set_from_icon_name(GTK_IMAGE(widgets->image_settings), "emblem-system-symbolic",
                                  GTK_ICON_SIZE_SMALL_TOOLBAR);
@@ -1838,6 +1835,9 @@ CppImpl::slotNewIncomingCall(const std::string& callId)
     if (!accountInfo_) {
         return;
     }
+    if (g_settings_get_boolean(widgets->settings, "bring-window-to-front")) {
+        g_settings_set_boolean(widgets->settings, "show-main-window", TRUE);
+    }
     try {
         auto call = accountInfo_->callModel->getCall(callId);
         auto peer = call.peer;
diff --git a/src/ringnotify.cpp b/src/ringnotify.cpp
index d764c5e5..be1597d9 100644
--- a/src/ringnotify.cpp
+++ b/src/ringnotify.cpp
@@ -32,13 +32,7 @@
 #include <memory>
 #include <globalinstances.h>
 #include "native/pixbufmanipulator.h"
-#include <call.h>
 #include <QtCore/QSize>
-#include <media/text.h>
-#include <callmodel.h>
-#include <media/textrecording.h>
-#include <media/recordingmodel.h>
-#include <recentmodel.h>
 #endif
 
 
diff --git a/src/ringwelcomeview.cpp b/src/ringwelcomeview.cpp
index 05e5b96e..fc81d7e3 100644
--- a/src/ringwelcomeview.cpp
+++ b/src/ringwelcomeview.cpp
@@ -29,9 +29,6 @@
 #include <QObject>
 #include <QItemSelectionModel>
 
-// LRC
-#include "utils/accounts.h"
-
 struct _RingWelcomeView
 {
     GtkScrolledWindow parent;
diff --git a/src/utils/accounts.cpp b/src/utils/accounts.cpp
deleted file mode 100644
index e3a1e516..00000000
--- a/src/utils/accounts.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- *  Copyright (C) 2015-2018 Savoir-faire Linux Inc.
- *  Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
- */
-
-#include "accounts.h"
-
-#include <accountmodel.h>
-#include <availableaccountmodel.h>
-
-// LRC
-#include <QItemSelectionModel>
-
-/**
- * itterates through all existing accounts and make sure all RING accounts have
- * a display name set; if a display name is empty, it is set to the alias of the
- * account
- */
-void
-force_ring_display_name()
-{
-    auto ringaccounts = AccountModel::instance().getAccountsByProtocol(Account::Protocol::RING);
-    for (int i = 0; i < ringaccounts.size(); ++i) {
-        auto account = ringaccounts.at(i);
-        if (account->displayName().isEmpty()) {
-            g_debug("updating RING account display name to: %s", account->alias().toUtf8().constData());
-            account->setDisplayName(account->alias());
-            account << Account::EditAction::SAVE;
-        }
-    }
-}
-
-/**
- * Returns the the user chosen account if it's a ring account, nullptr otherwise.
- */
-Account*
-get_active_ring_account()
-{
-    const auto idx = AvailableAccountModel::instance().selectionModel()->currentIndex();
-    auto account = idx.data(static_cast<int>(Account::Role::Object)).value<Account*>();
-
-    return (account && account->protocol() == Account::Protocol::RING) ? account : nullptr;
-}
diff --git a/src/utils/accounts.h b/src/utils/accounts.h
deleted file mode 100644
index f1fc8b2b..00000000
--- a/src/utils/accounts.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *  Copyright (C) 2015-2018 Savoir-faire Linux Inc.
- *  Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
- */
-
-#ifndef _ACCOUNTS_H
-#define _ACCOUNTS_H
-
-#include <gtk/gtk.h>
-
-class Account;
-
-/**
- * iterates through all existing accounts and make sure all RING accounts have
- * a display name set; if a display name is empty, it is set to the alias of the
- * account
- */
-void
-force_ring_display_name();
-
-/**
- * Finds and returns the first RING account, in order of priority:
- * 1. registered
- * 2. enabled
- * 3. existing
- *
- * Returns a nullptr if no RING acconts exist
- */
-Account*
-get_active_ring_account();
-
-#endif /* _ACCOUNTS_H */
diff --git a/src/utils/calling.cpp b/src/utils/calling.cpp
deleted file mode 100644
index 7be62351..00000000
--- a/src/utils/calling.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *  Copyright (C) 2015-2018 Savoir-faire Linux Inc.
- *  Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
- */
-
-#include "calling.h"
-#include "accounts.h"
-
-#include <contactmethod.h>
-#include <callmodel.h>
-#include <QtCore/QItemSelectionModel>
-
-void
-place_new_call(ContactMethod *n, Account *acc)
-{
-    /* check if this CM already has an ongoing call; likely we want the most recent one, so we
-     * check the CallModel in reverse order
-     */
-    auto call_list = CallModel::instance().getActiveCalls();
-    Call* call = nullptr;
-    for (int i = call_list.size() - 1; i > -1 && call == nullptr; --i) {
-        if (call_list.at(i)->peerContactMethod() == n) {
-            call = call_list.at(i);
-        }
-    }
-
-    /* use the selected account if none was passed to the function */
-    if (not acc) {
-        acc = get_active_ring_account();
-    }
-
-    if (!call) {
-        /* didn't find an existing call, so create a new one */
-        call = CallModel::instance().dialingCall(n);
-        call->setAccount(acc); // force account
-        call->performAction(Call::Action::ACCEPT);
-    }
-
-    /* make this the currently selected call */
-    CallModel::instance().selectCall(call);
-}
diff --git a/src/utils/calling.h b/src/utils/calling.h
deleted file mode 100644
index a4173f52..00000000
--- a/src/utils/calling.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *  Copyright (C) 2015-2018 Savoir-faire Linux Inc.
- *  Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
- */
-
-#ifndef _CALLING_H
-#define _CALLING_H
-
-class ContactMethod;
-class Account;
-
-void
-place_new_call(ContactMethod *n, Account *acc = nullptr);
-
-#endif /* _CALLING_H */
diff --git a/src/video/video_widget.cpp b/src/video/video_widget.cpp
index 4e9d71d9..c31d5c85 100644
--- a/src/video/video_widget.cpp
+++ b/src/video/video_widget.cpp
@@ -25,6 +25,7 @@
 #include <string>
 
 // gtk
+#include <glib/gi18n.h>
 #include <clutter/clutter.h>
 #include <clutter-gtk/clutter-gtk.h>
 #include <glib/gi18n.h>
@@ -32,6 +33,7 @@
 // LRC
 #include <api/avmodel.h>
 #include <smartinfohub.h>
+#include <QSize>
 
 // gnome client
 #include "../defines.h"
-- 
GitLab