mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-24 07:08:07 +00:00
41 lines
1.4 KiB
C++
41 lines
1.4 KiB
C++
#include <QtDebug>
|
|
|
|
#include "../../app/App.hpp"
|
|
|
|
#include "ContactModel.hpp"
|
|
|
|
using namespace std;
|
|
|
|
// =============================================================================
|
|
|
|
const char *ContactModel::NAME = "contact-model";
|
|
|
|
ContactModel::ContactModel (shared_ptr<linphone::Friend> linphone_friend) {
|
|
m_linphone_friend = linphone_friend;
|
|
m_linphone_friend->setData(NAME, *this);
|
|
m_vcard = make_shared<VcardModel>(linphone_friend->getVcard());
|
|
|
|
App::getInstance()->getEngine()->setObjectOwnership(m_vcard.get(), QQmlEngine::CppOwnership);
|
|
QObject::connect(m_vcard.get(), &VcardModel::vcardUpdated, this, &ContactModel::contactUpdated);
|
|
}
|
|
|
|
ContactModel::ContactModel (VcardModel *vcard) {
|
|
QQmlEngine *engine = App::getInstance()->getEngine();
|
|
if (engine->objectOwnership(vcard) == QQmlEngine::CppOwnership)
|
|
throw std::invalid_argument("A contact is already linked to this vcard.");
|
|
|
|
m_linphone_friend = linphone::Friend::newFromVcard(vcard->m_vcard);
|
|
m_linphone_friend->setData(NAME, *this);
|
|
m_vcard.reset(vcard);
|
|
|
|
engine->setObjectOwnership(vcard, QQmlEngine::CppOwnership);
|
|
QObject::connect(vcard, &VcardModel::vcardUpdated, this, &ContactModel::contactUpdated);
|
|
}
|
|
|
|
Presence::PresenceStatus ContactModel::getPresenceStatus () const {
|
|
return Presence::PresenceStatus::Offline;
|
|
}
|
|
|
|
Presence::PresenceLevel ContactModel::getPresenceLevel () const {
|
|
return Presence::getPresenceLevel(getPresenceStatus());
|
|
}
|