linphone-desktop/tests/src/components/contact/ContactModel.cpp
Ronan Abhamon e5d9bf20f7 feat(app):
- remove useless smart-search-bar from cpp
  - create a new `SipAddressesModel` component
  - create a `UnregisteredSipAddressesModel` (it uses the previous model)
  - `TimelineModel` uses too this model
  - many fixes and refactoring
  - `mapToSipAddress` moved from `ContactsListModel` to `SipAddressesModel`
  - ...
2016-12-20 17:20:01 +01:00

35 lines
1.3 KiB
C++

#include "../../app/App.hpp"
#include "ContactModel.hpp"
using namespace std;
// =============================================================================
ContactModel::ContactModel (shared_ptr<linphone::Friend> linphone_friend) {
m_linphone_friend = linphone_friend;
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_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());
}