Commit 64540c38 authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Andreas Traczyk

misc: expose lrc models to qml

- lrc api headers added to shared library
- metadata declaration outside namespace
- compiler warnings

Change-Id: I58bca6cc645e1e7ccc31ab31798de94b216c967d
parent 798f0130
......@@ -534,7 +534,7 @@ ENDIF()
if (ENABLE_SHARED)
message(STATUS "Configuring as shared lib")
add_library(ringclient SHARED ${libringclient_LIB_SRCS} ${LIB_HEADER_MOC} )
add_library(ringclient SHARED ${libringclient_LIB_SRCS} ${libringclient_api_LIB_HDRS} ${LIB_HEADER_MOC} )
target_link_libraries(ringclient Qt5::Core Qt5::Gui)
endif()
......@@ -780,4 +780,4 @@ ENDIF()
IF (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /U_MBCS /DUNICODE")
ENDIF()
\ No newline at end of file
ENDIF()
......@@ -213,7 +213,7 @@ struct ConfProperties_t {
// Possible account export status
enum class ExportOnRingStatus {
SUCCESS = 0,
WRONG_PASSWORD = 1 ,
WRONG_PASSWORD = 1,
NETWORK_ERROR = 2,
INVALID
};
......@@ -256,7 +256,7 @@ struct Info
std::unique_ptr<lrc::api::NewDeviceModel> deviceModel;
std::unique_ptr<lrc::api::NewCodecModel> codecModel;
std::unique_ptr<lrc::api::PeerDiscoveryModel> peerDiscoveryModel;
NewAccountModel* accountModel {nullptr};
NewAccountModel* accountModel{ nullptr };
// daemon config
QString id;
......
This diff is collapsed.
......@@ -35,12 +35,12 @@ class Lrc;
namespace conversation
{
struct Info;
struct Info;
}
namespace interaction
{
struct Info;
struct Info;
}
/**
......@@ -87,17 +87,19 @@ Q_SIGNALS:
/**
* Emitted when the unread interaction is now read
*/
void newReadInteraction(const QString& accountId, const QString& conversation, uint64_t interactionId) const;
/**
* Emitted debugMessageReceived
*/
void debugMessageReceived(const QString& message);
/**
* Emitted audioMeter
*/
void audioMeter(const QString& id, float level);
void newReadInteraction(const QString& accountId, const QString& conversation, uint64_t interactionId) const;
/**
* Emitted debugMessageReceived
*/
void debugMessageReceived(const QString& message);
/**
* Emitted audioMeter
*/
void audioMeter(const QString& id, float level);
};
} // namespace api
} // namespace lrc
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
Q_DECLARE_METATYPE(lrc::api::BehaviorController*)
#endif
......@@ -52,9 +52,9 @@ public:
const account::Info& owner;
ContactModel(const account::Info& owner,
Database& db,
const CallbacksHandler& callbacksHandler,
const BehaviorController& behaviorController);
Database& db,
const CallbacksHandler& callbacksHandler,
const BehaviorController& behaviorController);
~ContactModel();
/**
......@@ -67,7 +67,7 @@ public:
* @param contactUri
* @param banned
*/
void removeContact(const QString& contactUri, bool banned=false);
void removeContact(const QString& contactUri, bool banned = false);
/**
* get contact information.
* @param contactUri
......@@ -79,7 +79,7 @@ public:
* get list of banned contacts.
* @return list of banned contacts uris as string
*/
const QList<QString>& getBannedContacts() const;
Q_INVOKABLE const QList<QString>& getBannedContacts() const;
/**
* @return all contacts for this account.
*/
......@@ -109,7 +109,7 @@ Q_SIGNALS:
/**
* Connect this signal to know when this model was updated.
*/
void modelUpdated(const QString& uri, bool needsSorted=true) const;
void modelUpdated(const QString& uri, bool needsSorted = true) const;
/**
* Connect this signal to know when a contact was added.
* @param contactUri
......@@ -139,9 +139,9 @@ Q_SIGNALS:
* @param payloads content of the message
*/
void newAccountMessage(const QString& accountId,
const QString& msgId,
const QString& from,
const MapStringString& payloads) const;
const QString& msgId,
const QString& from,
const MapStringString& payloads) const;
/**
* Connect this signal to know when a file transfer interaction is incoming
* @param dringId Daemon's ID for incoming transfer
......@@ -158,6 +158,8 @@ Q_SIGNALS:
private:
std::unique_ptr<ContactModelPimpl> pimpl_;
};
} // namespace api
} // namespace lrc
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
Q_DECLARE_METATYPE(lrc::api::ContactModel*)
#endif
This diff is collapsed.
......@@ -46,27 +46,27 @@ class Info;
*/
class LIB_EXPORT DataTransferModel : public QObject {
Q_OBJECT
Q_PROPERTY(QString downloadDirectory_qml MEMBER downloadDirectory)
public:
DataTransferModel();
~DataTransferModel();
void sendFile(const QString& account_id, const QString& peer_uri,
const QString& file_path, const QString& display_name);
Q_INVOKABLE void sendFile(const QString& account_id, const QString& peer_uri,
const QString& file_path, const QString& display_name);
void transferInfo(long long ringId, datatransfer::Info& lrc_info);
Q_INVOKABLE void transferInfo(long long ringId, datatransfer::Info& lrc_info);
void bytesProgress(int interactionId, int64_t& total, int64_t& progress);
Q_INVOKABLE void bytesProgress(int interactionId, int64_t& total, int64_t& progress);
QString accept(int interactionId, const QString& file_path, std::size_t offset);
Q_INVOKABLE QString accept(int interactionId, const QString& file_path, std::size_t offset);
void cancel(int interactionId);
Q_INVOKABLE void cancel(int interactionId);
void registerTransferId(long long dringId, int interactionId);
Q_INVOKABLE void registerTransferId(long long dringId, int interactionId);
int getInteractionIdFromDringId(long long dringId);
Q_INVOKABLE int getInteractionIdFromDringId(long long dringId);
long long getDringIdFromInteractionId(int interactionId);
Q_INVOKABLE long long getDringIdFromInteractionId(int interactionId);
/**
* Used when images < 20 Mb are automatically accepted and downloaded
......@@ -77,22 +77,22 @@ public:
/**
* Creates APPDATA/received and return the path
*/
static QString createDefaultDirectory();
Q_INVOKABLE static QString createDefaultDirectory();
/**
* Accept transfer from untrusted contacts
*/
bool acceptFromUnstrusted {false};
bool acceptFromUnstrusted{ false };
/**
* Accept transfer from trusted contacts
*/
bool automaticAcceptTransfer {true};
bool automaticAcceptTransfer{ true };
/**
* Automatically accept transfer under
*/
unsigned acceptBehindMb {20} /* Mb */;
unsigned acceptBehindMb{ 20 } /* Mb */;
Q_SIGNALS:
/**
......@@ -111,5 +111,8 @@ private:
class Impl;
std::unique_ptr<Impl> pimpl_;
};
}} // namespace lrc::api
}
} // namespace lrc::api
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
Q_DECLARE_METATYPE(lrc::api::DataTransferModel*)
#endif
......@@ -51,49 +51,45 @@ class LIB_EXPORT NewAccountModel : public QObject {
Q_OBJECT
public:
NewAccountModel(Lrc& lrc,
const CallbacksHandler& callbackHandler,
const api::BehaviorController& behaviorController,
MigrationCb& willMigrateCb,
MigrationCb& didMigrateCb);
const CallbacksHandler& callbackHandler,
const api::BehaviorController& behaviorController,
MigrationCb& willMigrateCb,
MigrationCb& didMigrateCb);
~NewAccountModel();
/**
* @return a list of all acountId.
*/
QStringList getAccountList() const;
Q_INVOKABLE QStringList getAccountList() const;
/**
* get account informations associated to an accountId.
* @param accountId.
* @return a const account::Info& structure.
*/
const account::Info& getAccountInfo(const QString& accountId) const;
Q_INVOKABLE const account::Info& getAccountInfo(const QString& accountId) const;
/**
* flag account corresponding to passed id as freeable.
*/
void flagFreeable(const QString& accountId) const;
/**
* set account enable/disable, save config and do unregister for account
* @param accountId.
* @param enabled.
*/
void setAccountEnabled(const QString& accountID, bool enabled) const;
Q_INVOKABLE void flagFreeable(const QString& accountId) const;
/**
* set account enable/disable, save config and do unregister for account
* @param accountId.
* @param enabled.
*/
Q_INVOKABLE void setAccountEnabled(const QString& accountID, bool enabled) const;
/**
* saves account config to .yml
* @param accountId.
* @param reference to the confProperties
*/
void setAccountConfig(const QString& accountID,
const account::ConfProperties_t& confProperties) const;
Q_INVOKABLE void setAccountConfig(const QString& accountID,
const account::ConfProperties_t& confProperties) const;
/**
* gets a copy of the accounts config
* @param accountId.
* @return an account::Info::ConfProperties_t structure.
*/
account::ConfProperties_t getAccountConfig(const QString& accountId) const;
Q_INVOKABLE account::ConfProperties_t getAccountConfig(const QString& accountId) const;
/**
* Call exportToFile from the daemon
* @param accountId
......@@ -101,20 +97,20 @@ public:
* @param password
* @return if the file is exported with success
*/
bool exportToFile(const QString& accountId, const QString& path, const QString& password = {}) const;
Q_INVOKABLE bool exportToFile(const QString& accountId, const QString& path, const QString& password = {}) const;
/**
* Call exportOnRing from the daemon
* @param accountId
* @param password
* @return if the export is initialized
*/
bool exportOnRing(const QString& accountId, const QString& password) const;
Q_INVOKABLE bool exportOnRing(const QString& accountId, const QString& password) const;
/**
* Call removeAccount from the daemon
* @param accountId to remove
* @note will emit accountRemoved
*/
void removeAccount(const QString& accountId) const;
Q_INVOKABLE void removeAccount(const QString& accountId) const;
/**
* Call changeAccountPassword from the daemon
* @param accountId
......@@ -122,23 +118,23 @@ public:
* @param newPassword
* @return if the password has been changed
*/
bool changeAccountPassword(const QString& accountId,
const QString& currentPassword,
const QString& newPassword) const;
Q_INVOKABLE bool changeAccountPassword(const QString& accountId,
const QString& currentPassword,
const QString& newPassword) const;
/**
* Change the avatar of an account
* @param accountId
* @param avatar
* @throws out_of_range exception if account is not found
*/
void setAvatar(const QString& accountId, const QString& avatar);
Q_INVOKABLE void setAvatar(const QString& accountId, const QString& avatar);
/**
* Change the alias of an account
* @param accountId
* @param alias
* @throws out_of_range exception if account is not found
*/
void setAlias(const QString& accountId, const QString& alias);
Q_INVOKABLE void setAlias(const QString& accountId, const QString& alias);
/**
* Try to register a name
* @param accountId
......@@ -146,8 +142,7 @@ public:
* @param username
* @return if operation started
*/
bool registerName(const QString& accountId, const QString& password, const QString& username);
Q_INVOKABLE bool registerName(const QString& accountId, const QString& password, const QString& username);
/**
* Connect to JAMS to retrieve the account
* @param username
......@@ -156,11 +151,10 @@ public:
* @param config
* @return the account id
*/
static QString connectToAccountManager(const QString& username,
const QString& password,
const QString& serverUri,
const MapStringString& config = MapStringString());
Q_INVOKABLE static QString connectToAccountManager(const QString& username,
const QString& password,
const QString& serverUri,
const MapStringString& config = MapStringString());
/**
* Create a new Ring or SIP account
* @param type determine if the new account will be a Ring account or a SIP one
......@@ -173,25 +167,23 @@ public:
* @param config
* @return the created account
*/
static QString createNewAccount(profile::Type type,
const QString& displayName = "",
const QString& archivePath = "",
const QString& password = "",
const QString& pin = "",
const QString& uri = "",
const MapStringString& config = MapStringString());
Q_INVOKABLE static QString createNewAccount(profile::Type type,
const QString& displayName = "",
const QString& archivePath = "",
const QString& password = "",
const QString& pin = "",
const QString& uri = "",
const MapStringString& config = MapStringString());
/**
* Set an account to the first position
*/
void setTopAccount(const QString& accountId);
Q_INVOKABLE void setTopAccount(const QString& accountId);
/**
* Get the vCard for an account
* @param id
* @return vcard of the account
*/
QString accountVCard(const QString& accountId, bool compressImage = true) const;
Q_INVOKABLE QString accountVCard(const QString& accountId, bool compressImage = true) const;
Q_SIGNALS:
/**
......@@ -254,6 +246,8 @@ Q_SIGNALS:
private:
std::unique_ptr<NewAccountModelPimpl> pimpl_;
};
} // namespace api
} // namespace lrc
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
Q_DECLARE_METATYPE(lrc::api::NewAccountModel*)
#endif
......@@ -70,7 +70,7 @@ public:
* @param isAudioOnly, set to false by default
* @return the call uid created. Empty string is returned if call couldn't be created.
*/
QString createCall(const QString& uri, bool isAudioOnly = false);
Q_INVOKABLE QString createCall(const QString& uri, bool isAudioOnly = false);
/**
* Get the call from its call id
......@@ -78,7 +78,7 @@ public:
* @return the callInfo
* @throw out_of_range exception if not found
*/
const call::Info& getCall(const QString& uid) const;
Q_INVOKABLE const call::Info& getCall(const QString& uid) const;
/**
* Get the call from the peer uri
......@@ -87,7 +87,7 @@ public:
* @return the callInfo
* @throw out_of_range exception if not found
*/
const call::Info& getCallFromURI(const QString& uri, bool notOver = false) const;
Q_INVOKABLE const call::Info& getCallFromURI(const QString& uri, bool notOver = false) const;
/**
* Get conference from a peer uri
......@@ -95,91 +95,91 @@ public:
* @return the callInfo
* @throw out_of_range exception if not found
*/
const call::Info& getConferenceFromURI(const QString& uri) const;
Q_INVOKABLE const call::Info& getConferenceFromURI(const QString& uri) const;
/**
* @param callId to test
* @return true if callId is presend else false.
*/
bool hasCall(const QString& callId) const;
Q_INVOKABLE bool hasCall(const QString& callId) const;
/**
* Send a text message to a SIP call
* @param callId
* @param body of the message
*/
void sendSipMessage(const QString& callId, const QString& body) const;
Q_INVOKABLE void sendSipMessage(const QString& callId, const QString& body) const;
/**
* Accept a call
* @param callId
*/
void accept(const QString& callId) const;
Q_INVOKABLE void accept(const QString& callId) const;
/**
* Hang up a call
* @param callId
*/
void hangUp(const QString& callId) const;
Q_INVOKABLE void hangUp(const QString& callId) const;
/**
* Refuse a call
* @param callId
*/
void refuse(const QString& callId) const;
Q_INVOKABLE void refuse(const QString& callId) const;
/**
* Toggle audio record on a call
* @param callId
*/
void toggleAudioRecord(const QString& callId) const;
Q_INVOKABLE void toggleAudioRecord(const QString& callId) const;
/**
* Play DTMF in a call
* @param callId
* @param value to play
*/
void playDTMF(const QString& callId, const QString& value) const;
Q_INVOKABLE void playDTMF(const QString& callId, const QString& value) const;
/**
* Toggle pause on a call.
* @warn only use this function for SIP calls
* @param callId
*/
void togglePause(const QString& callId) const;
Q_INVOKABLE void togglePause(const QString& callId) const;
/**
* Toggle a media on a call
* @param callId
* @param media {AUDIO, VIDEO}
*/
void toggleMedia(const QString& callId, const NewCallModel::Media media) const;
Q_INVOKABLE void toggleMedia(const QString& callId, const NewCallModel::Media media) const;
/**
* Not implemented yet
*/
void setQuality(const QString& callId, const double quality) const;
Q_INVOKABLE void setQuality(const QString& callId, const double quality) const;
/**
* Blind transfer. Directly transfer a call to a sip number
* @param callId: the call to transfer
* @param to: the sip number (for example: "sip:1412")
*/
void transfer(const QString& callId, const QString& to) const;
Q_INVOKABLE void transfer(const QString& callId, const QString& to) const;
/**
* Perform an attended. Transfer a call to another call
* @param callIdSrc: the call to transfer
* @param callIdDest: the destination's call
*/
void transferToCall(const QString& callIdSrc, const QString& callIdDest) const;
Q_INVOKABLE void transferToCall(const QString& callIdSrc, const QString& callIdDest) const;
/**
* Create a conference from 2 calls.
* @param callIdA uid of the call A
* @param callIdB uid of the call B
*/
void joinCalls(const QString& callIdA, const QString& callIdB) const;
Q_INVOKABLE void joinCalls(const QString& callIdA, const QString& callIdB) const;
/**
* Call a participant and add it to a call
......@@ -188,42 +188,42 @@ public:
* @param audioOnly If the call is audio only
* @return id for a new call
*/
QString callAndAddParticipant(const QString uri, const QString& callId, bool audioOnly);
Q_INVOKABLE QString callAndAddParticipant(const QString uri, const QString& callId, bool audioOnly);
/**
* Not implemented yet
*/
void removeParticipant(const QString& callId, const QString& participant) const;
Q_INVOKABLE void removeParticipant(const QString& callId, const QString& participant) const;
/**
* @param callId
* @return a human readable call duration (M:ss)
*/
QString getFormattedCallDuration(const QString& callId) const;
Q_INVOKABLE QString getFormattedCallDuration(const QString& callId) const;
/**
* Get if a call is recording
* @param callId
* @return true if the call is recording else false
*/
bool isRecording(const QString& callId) const;
Q_INVOKABLE bool isRecording(const QString& callId) const;
/**
* Close all active calls and conferences
*/
static void hangupCallsAndConferences();
Q_INVOKABLE static void hangupCallsAndConferences();
/**
* Extract Status Message From Status Map
* @param statusCode
* @return status message
*/
static QString getSIPCallStatusString(const short& statusCode);
Q_INVOKABLE static QString getSIPCallStatusString(const short& statusCode);
/**
* Set a call as the current call (hold other calls)
*/
void setCurrentCall(const QString& callId) const;
Q_INVOKABLE void setCurrentCall(const QString& callId) const;
/**
* Change the conference layout
......@@ -282,6 +282,8 @@ Q_SIGNALS:
private:
std::unique_ptr<NewCallModelPimpl> pimpl_;
};
} // namespace api
} // namespace lrc
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
Q_DECLARE_METATYPE(lrc::api::NewCallModel*)
#endif
......@@ -116,6 +116,8 @@ public:
private:
std::unique_ptr<NewCodecModelPimpl> pimpl_;
};
} // namespace api
} // namespace lrc
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
Q_DECLARE_METATYPE(lrc::api::NewCodecModel*)
#endif
......@@ -83,7 +83,7 @@ public:
* @param password of the account's archive
* @note will emit deviceRevoked when finished
*/
void revokeDevice(const QString& id, const QString& password);
Q_INVOKABLE void revokeDevice(const QString& id, const QString& password);
/**
* Change the name of the current device
......@@ -91,7 +91,7 @@ public:
* @note will emit deviceUpdated when finished
* @note ring can't change the name of another device
*/
void setCurrentDeviceName(const QString& newName);
Q_INVOKABLE void setCurrentDeviceName(const QString& newName);
Q_SIGNALS:
/**
......@@ -114,6 +114,8 @@ Q_SIGNALS:
private:
std::unique_ptr<NewDeviceModelPimpl> pimpl_;
};
} // namespace api
} // namespace lrc
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
Q_DECLARE_METATYPE(lrc::api::NewDeviceModel*)
#endif
......@@ -17,7 +17,7 @@
***************************************************************************/
#pragma once
// Std
// Std
#include <map>
#include <memory>
#include <string>
......@@ -67,12 +67,12 @@ using Capabilities = QMap<Channel, ResRateList>;
* If shared data is carried, only "ptr" and "size" are set.
*/
struct Frame {
uint8_t* ptr { nullptr };
std::size_t size { 0 };
std::vector<uint8_t> storage { };
// Next variables are currently used with DirectRenderer only
unsigned int height { 0 };
unsigned int width { 0 };
uint8_t* ptr{ nullptr };
std::size_t size{ 0 };
std::vector<uint8_t> storage{ };
// Next variables are currently used with DirectRenderer only
unsigned int height{ 0 };
unsigned int width{ 0 };
};
enum class DeviceType
......@@ -89,7 +89,7 @@ Q_ENUM_NS(DeviceType)
/**
* This class describes the current rendered device
*/
struct RenderedDevice
struct RenderedDevice
{
QString name;
DeviceType type = DeviceType::INVALID;
......
......@@ -18,7 +18,7 @@
#pragma once
// Lrc
// Lrc
#include "typedefs.h"
// Qt
......@@ -74,6 +74,8 @@ Q_SIGNALS:
private:
std::unique_ptr<PeerDiscoveryModelPimpl> pimpl_;
};
} // namespace api
} // namespace lrc
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
Q_DECLARE_METATYPE(lrc::api::PeerDiscoveryModel*)
#endif
......@@ -49,7 +49,7 @@ Q_ENUM_NS(Type)
static inline const QString
to_string(const Type& type)
{
switch(type) {
switch (type) {
case Type::RING:
return "RING";
case Type::SIP:
......
This diff is collapsed.
......@@ -27,7 +27,7 @@ namespace lrc
using namespace api;
BehaviorController::BehaviorController()
: QObject()
: QObject(nullptr)
{
}
......
......@@ -271,7 +271,7 @@ ConversationModel::ConversationModel(const account::Info& owner,
Database& db,
const CallbacksHandler& callbacksHandler,
const BehaviorController& behaviorController)
: QObject()
: QObject(nullptr)
, pimpl_(std::make_unique<ConversationModelPimpl>(*this, lrc, db, callbacksHandler, behaviorController))
, owner(owner)
{
......
......@@ -109,7 +109,7 @@ DataTransferModel::registerTransferId(long long dringId, int interactionId)
}
DataTransferModel::DataTransferModel()
: QObject()
: QObject(nullptr)
, pimpl_ { std::make_unique<Impl>(*this) }
{}
......
......@@ -27,9 +27,11 @@ NameDirectoryPrivate::NameDirectoryPrivate(NameDirectory* q) : q_ptr(q)
ConfigurationManagerInterface& configurationManager = ConfigurationManager::instance();
connect(&configurationManager, &ConfigurationManagerInterface::nameRegistrationEnded, this,
&NameDirectoryPrivate::slotNameRegistrationEnded, Qt::QueuedConnection);
&NameDirectoryPrivate::slotNameRegistrationEnded, Qt::QueuedConnection);
connect(&configurationManager, &ConfigurationManagerInterface::registeredNameFound, this,
&NameDirectoryPrivate::slotRegisteredNameFound, Qt::QueuedConnection);
<