Commit 3ae5317f authored by Sébastien Blin's avatar Sébastien Blin

misc: remove unused code from old LRC models

Change-Id: Ida3f87a0c61195e60bc6e8630d9c50edf18f14cc
parent 4beb7fcb
......@@ -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
......
......@@ -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
......
......@@ -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"
......
......@@ -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"
......
......@@ -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"
......
......@@ -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;
......
......@@ -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"
......
/*
* 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
}
}
/*
* 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;
};
......@@ -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 */
......
......@@ -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;
......
......@@ -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
......