Commit 6c44b839 authored by Sébastien Blin's avatar Sébastien Blin

refacto: remove code to follow LRC cleanup

Change-Id: Ie9c3bf2f0b41df108c77a18b996edab61097d7c6
parent 21e59832
......@@ -33,7 +33,6 @@
#include <api/newcodecmodel.h>
#include <globalinstances.h>
#include <smartinfohub.h>
#include <video/previewmanager.h>
#include <QSize>
// Client
......
......@@ -28,8 +28,6 @@
#include <api/newvideo.h>
#include "video/video_widget.h"
#include <video/previewmanager.h>
#include <video/configurationproxy.h>
namespace { namespace details
{
......
......@@ -22,10 +22,7 @@
#include <QtCore/QSize>
#include <QtCore/QMetaType>
#include <person.h>
#include <memory>
#include <call.h>
#include <contactmethod.h>
#include <string>
#include <algorithm>
......@@ -60,44 +57,6 @@ PixbufManipulator::temporaryItemAvatar() const
return result;
}
std::shared_ptr<GdkPixbuf>
PixbufManipulator::generateAvatar(const ContactMethod* cm) const
{
auto cm_number = QString("0");
QString bestName;
if (cm) {
auto hashName = cm->uri().userinfo();
if (hashName.size() > 0) {
cm_number = hashName.at(0);
}
// Get the bestName to draw
if (!cm->bestName().isEmpty()) {
// Prioritize the name
bestName = cm->bestName().toUpper();
} else if (!cm->bestId().isEmpty()) {
// If the contact has no name, use the id
bestName = cm->bestId().toUpper();
}
}
bool ok;
auto color = cm_number.toUInt(&ok, 16);
if (!ok) color = 0;
// Retrieve first character
auto letter = bestName.isEmpty() ? "" : QString(bestName.at(0)).toStdString();
return std::shared_ptr<GdkPixbuf> {
ring_draw_fallback_avatar(
FALLBACK_AVATAR_SIZE,
letter,
color
),
g_object_unref
};
}
std::shared_ptr<GdkPixbuf>
PixbufManipulator::generateAvatar(const std::string& alias, const std::string& uri) const
{
......@@ -172,46 +131,6 @@ PixbufManipulator::scaleAndFrame(const GdkPixbuf *photo,
return result;
}
QVariant
PixbufManipulator::callPhoto(Call* c, const QSize& size, bool displayInformation)
{
if (c->type() == Call::Type::CONFERENCE) {
/* conferences are always "online" */
return QVariant::fromValue(scaleAndFrame(conferenceAvatar_.get(), size, displayInformation));
}
return callPhoto(c->peerContactMethod(), size, displayInformation);
}
QVariant
PixbufManipulator::callPhoto(const ContactMethod* n, const QSize& size, bool displayInformation)
{
if (n->contact()) {
return contactPhoto(n->contact(), size, displayInformation);
} else {
return QVariant::fromValue(scaleAndFrame(generateAvatar(n).get(), size, displayInformation));
}
}
QVariant
PixbufManipulator::contactPhoto(Person* c, const QSize& size, bool displayInformation)
{
/**
* try to get the photo
* otherwise use the generated avatar
*/
std::shared_ptr<GdkPixbuf> photo;
if (c->photo().isValid())
photo = c->photo().value<std::shared_ptr<GdkPixbuf>>();
else {
auto cm = c->phoneNumbers().size() > 0 ? c->phoneNumbers().first() : nullptr;
photo = generateAvatar(cm);
}
return QVariant::fromValue(scaleAndFrame(photo.get(), size, displayInformation));
}
QVariant PixbufManipulator::personPhoto(const QByteArray& data, const QString& type)
{
Q_UNUSED(type);
......@@ -322,13 +241,6 @@ PixbufManipulator::numberCategoryIcon(const QVariant& p, const QSize& size, bool
return QVariant();
}
QVariant
PixbufManipulator::securityIssueIcon(const QModelIndex& index)
{
Q_UNUSED(index)
return QVariant();
}
QByteArray
PixbufManipulator::toByteArray(const QVariant& pxm)
{
......@@ -356,20 +268,6 @@ PixbufManipulator::toByteArray(const QVariant& pxm)
}
}
QVariant
PixbufManipulator::collectionIcon(const CollectionInterface* interface, PixmapManipulatorI::CollectionIconHint hint) const
{
Q_UNUSED(interface)
Q_UNUSED(hint)
return QVariant();
}
QVariant
PixbufManipulator::securityLevelIcon(const SecurityEvaluationModel::SecurityLevel level) const
{
Q_UNUSED(level)
return QVariant();
}
QVariant
PixbufManipulator::userActionIcon(const UserActionElement& state) const
{
......@@ -383,30 +281,6 @@ QVariant PixbufManipulator::decorationRole(const QModelIndex& index)
return QVariant();
}
QVariant PixbufManipulator::decorationRole(const Call* c)
{
Q_UNUSED(c)
return QVariant();
}
QVariant PixbufManipulator::decorationRole(const ContactMethod* cm)
{
Q_UNUSED(cm)
return QVariant();
}
QVariant PixbufManipulator::decorationRole(const Person* p)
{
Q_UNUSED(p)
return QVariant();
}
QVariant PixbufManipulator::decorationRole(const Account* p)
{
Q_UNUSED(p)
return QVariant();
}
QVariant PixbufManipulator::decorationRole(const lrc::api::conversation::Info& conversation,
const lrc::api::account::Info& accountInfo)
{
......
......@@ -40,32 +40,21 @@ class PixbufManipulator : public PixmapManipulatorI {
public:
PixbufManipulator();
QVariant callPhoto(Call* c, const QSize& size, bool displayInformation = true) override;
QVariant callPhoto(const ContactMethod* n, const QSize& size, bool displayInformation = true) override;
QVariant conversationPhoto(const lrc::api::conversation::Info& conversation,
const lrc::api::account::Info& accountInfo,
const QSize& size,
bool displayInformation = true) override;
QVariant contactPhoto(Person* c, const QSize& size, bool displayInformation = true) override;
QVariant personPhoto(const QByteArray& data, const QString& type = "PNG") override;
QVariant numberCategoryIcon(const QVariant& p, const QSize& size, bool displayInformation = false, bool isPresent = false) override;
QVariant securityIssueIcon(const QModelIndex& index) override;
QByteArray toByteArray(const QVariant& pxm) override;
QVariant collectionIcon(const CollectionInterface* interface, PixmapManipulatorI::CollectionIconHint hint = PixmapManipulatorI::CollectionIconHint::NONE) const override;
QVariant securityLevelIcon(const SecurityEvaluationModel::SecurityLevel level) const override;
QVariant userActionIcon(const UserActionElement& state) const override;
QVariant decorationRole(const QModelIndex& index) override;
QVariant decorationRole(const Call* c) override;
QVariant decorationRole(const ContactMethod* cm) override;
QVariant decorationRole(const Person* p) override;
QVariant decorationRole(const lrc::api::conversation::Info& conversation,
const lrc::api::account::Info& accountInfo) override;
QVariant decorationRole(const Account* p) override;
// Helpers
std::shared_ptr<GdkPixbuf> temporaryItemAvatar() const;
std::shared_ptr<GdkPixbuf> generateAvatar(const ContactMethod* cm) const;
std::shared_ptr<GdkPixbuf> generateAvatar(const std::string& alias, const std::string& uri) const;
std::shared_ptr<GdkPixbuf> scaleAndFrame(const GdkPixbuf *photo, const QSize &size, bool displayInformation = false, IconStatus status = IconStatus::INVALID, uint unreadMessages = 0);
......
......@@ -1029,9 +1029,6 @@ nm_client_cb(G_GNUC_UNUSED GObject *source_object, GAsyncResult *result, RingMa
void
CppImpl::init()
{
try {
lrc_->getAVModel().deactivateOldVideoModels();
} catch (...) {}
widgets->cancellable = g_cancellable_new();
#if USE_LIBNM
// monitor the network using libnm to notify the daemon about connectivity changes
......
......@@ -24,7 +24,6 @@
// LRC
#include <api/newaccountmodel.h>
#include <namedirectory.h>
#include <account.h>
// Ring Client
#include "usernameregistrationbox.h"
......@@ -135,7 +134,7 @@ username_registration_box_init(UsernameRegistrationBox *view)
priv->registered_name_found = QObject::connect(
&NameDirectory::instance(),
&NameDirectory::registeredNameFound,
[=] (const Account*, NameDirectory::LookupStatus status, const QString&, const QString& name) {
[=] (NameDirectory::LookupStatus status, const QString&, const QString& name) {
// g_debug("Name lookup ended");
if (!priv->use_blockchain)
......@@ -244,9 +243,9 @@ lookup_username(UsernameRegistrationBox *view)
if (priv->accountInfo_) {
auto prop = (*priv->accountInfo_)->accountModel->getAccountConfig((*priv->accountInfo_)->id);
NameDirectory::instance().lookupName(nullptr, prop.RingNS.uri.c_str(), username);
NameDirectory::instance().lookupName(prop.RingNS.uri.c_str(), username);
} else {
NameDirectory::instance().lookupName(nullptr, QString(), username);
NameDirectory::instance().lookupName(QString(), username);
}
......
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