From 1f3f9c13d506249da5825c264b9de08bbf4ea72b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Wed, 4 Mar 2020 14:14:09 -0500 Subject: [PATCH] sip: follow API changes (incomingAccountMessage) Change-Id: I55f58a36bb4b5840cba2942eff3922359d1845b6 --- src/api/contactmodel.h | 6 +++++- src/callbackshandler.cpp | 4 +++- src/callbackshandler.h | 6 +++++- src/contactmodel.cpp | 5 ++++- src/conversationmodel.cpp | 16 +++++++++++----- src/qtwrapper/configurationmanager_wrap.h | 6 +++--- 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/api/contactmodel.h b/src/api/contactmodel.h index 8d932a3a..878eea9a 100644 --- a/src/api/contactmodel.h +++ b/src/api/contactmodel.h @@ -139,10 +139,14 @@ Q_SIGNALS: /** * Connect this signal to know when a text message arrives for this account * @param accountId + * @param msgId Interaction's id * @param from peer uri * @param payloads content of the message */ - void newAccountMessage(std::string& accountId, std::string& from, std::map<std::string,std::string> payloads) const; + void newAccountMessage(std::string& accountId, + std::string& msgId, + std::string& from, + std::map<std::string,std::string> payloads) const; /** * Connect this signal to know when a file transfer interaction is incoming * @param dringId Daemon's ID for incoming transfer diff --git a/src/callbackshandler.cpp b/src/callbackshandler.cpp index 3d47dafb..a12a11cd 100644 --- a/src/callbackshandler.cpp +++ b/src/callbackshandler.cpp @@ -246,6 +246,7 @@ CallbacksHandler::subscribeToDebugReceived() void CallbacksHandler::slotNewAccountMessage(const QString& accountId, + const QString& msgId, const QString& from, const QMap<QString,QString>& payloads) { @@ -257,8 +258,9 @@ CallbacksHandler::slotNewAccountMessage(const QString& accountId, auto accountId2 = accountId.toStdString(); auto from2 = QString(from).replace("@ring.dht", "").toStdString(); + auto msgId2 = QString(msgId).toStdString(); - emit newAccountMessage(accountId2, from2, stdPayloads); + emit newAccountMessage(accountId2, msgId2, from2, stdPayloads); } void diff --git a/src/callbackshandler.h b/src/callbackshandler.h index 3a2ef549..9b724d76 100644 --- a/src/callbackshandler.h +++ b/src/callbackshandler.h @@ -59,10 +59,12 @@ Q_SIGNALS: /** * Connect this signal to get incoming text interaction from the DHT. * @param accountId interaction receiver. - * @param from interaction sender. + * @param msgId interaction's id. + * @param from interaction sender. * @param payloads. */ void newAccountMessage(std::string& accountId, + std::string& msgId, std::string& from, std::map<std::string,std::string> payloads); /** @@ -296,10 +298,12 @@ private Q_SLOTS: /** * Emit newAccountMessage * @param accountId + * @param msgId * @param from * @param payloads of the interaction */ void slotNewAccountMessage(const QString& accountId, + const QString& msgId, const QString& from, const QMap<QString,QString>& payloads); /** diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp index ad59ad79..0e9bb5c8 100644 --- a/src/contactmodel.cpp +++ b/src/contactmodel.cpp @@ -166,10 +166,12 @@ public Q_SLOTS: /** * Listen from callbacksHandler for new account interaction and add pending contact if not present * @param accountId + * @param msgId * @param from * @param payloads */ void slotNewAccountMessage(std::string& accountId, + std::string& msgId, std::string& from, std::map<std::string,std::string> payloads); @@ -847,6 +849,7 @@ ContactModelPimpl::slotIncomingCall(const std::string& fromId, const std::string void ContactModelPimpl::slotNewAccountMessage(std::string& accountId, + std::string& msgId, std::string& from, std::map<std::string,std::string> payloads) { @@ -876,7 +879,7 @@ ContactModelPimpl::slotNewAccountMessage(std::string& accountId, if (emitNewTrust) { emit behaviorController.newTrustRequest(linked.owner.id, from); } - emit linked.newAccountMessage(accountId, from, payloads); + emit linked.newAccountMessage(accountId, msgId, from, payloads); } std::string diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp index 2035c546..1d0cbea5 100644 --- a/src/conversationmodel.cpp +++ b/src/conversationmodel.cpp @@ -115,10 +115,11 @@ public: * @param from the author uri * @param body the content of the message * @param timestamp the timestamp of the message + * @return msgId generated (in db) */ - void addIncomingMessage(const std::string& from, - const std::string& body, - const uint64_t& timestamp = 0); + int addIncomingMessage(const std::string& from, + const std::string& body, + const uint64_t& timestamp = 0); /** * Change the status of an interaction. Listen from callbacksHandler * @param accountId, account linked @@ -218,10 +219,12 @@ public Q_SLOTS: /** * Listen from CallbacksHandler for new incoming interactions; * @param accountId + * @param msgId * @param from uri * @param payloads body */ void slotNewAccountMessage(std::string& accountId, + std::string& msgId, std::string& from, std::map<std::string,std::string> payloads); /** @@ -1765,6 +1768,7 @@ ConversationModelPimpl::addOrUpdateCallMessage(const std::string& callId, void ConversationModelPimpl::slotNewAccountMessage(std::string& accountId, + std::string& msgId, std::string& from, std::map<std::string,std::string> payloads) { @@ -1773,7 +1777,8 @@ ConversationModelPimpl::slotNewAccountMessage(std::string& accountId, for (const auto &payload : payloads) { if (payload.first.find("text/plain") != std::string::npos) { - addIncomingMessage(from, payload.second); + auto dbId = addIncomingMessage(from, payload.second); + storage::addDaemonMsgId(db, std::to_string(dbId), msgId); } } } @@ -1801,7 +1806,7 @@ ConversationModelPimpl::slotIncomingCallMessage(const std::string& callId, const } -void +int ConversationModelPimpl::addIncomingMessage(const std::string& from, const std::string& body, const uint64_t& timestamp) @@ -1832,6 +1837,7 @@ ConversationModelPimpl::addIncomingMessage(const std::string& from, emit linked.newInteraction(convIds[0], msgId, msg); sortConversations(); emit linked.modelSorted(); + return msgId; } void diff --git a/src/qtwrapper/configurationmanager_wrap.h b/src/qtwrapper/configurationmanager_wrap.h index 26e61ab5..f384bed4 100644 --- a/src/qtwrapper/configurationmanager_wrap.h +++ b/src/qtwrapper/configurationmanager_wrap.h @@ -141,8 +141,8 @@ public: Q_EMIT this->registeredNameFound(QString(accountId.c_str()), status, QString(address.c_str()), QString(name.c_str())); }), exportable_callback<ConfigurationSignal::IncomingAccountMessage>( - [this] (const std::string& account_id, const std::string& from, const std::map<std::string, std::string>& payloads) { - Q_EMIT this->incomingAccountMessage(QString(account_id.c_str()), QString(from.c_str()), convertMap(payloads)); + [this] (const std::string& account_id, const std::string& msgId, const std::string& from, const std::map<std::string, std::string>& payloads) { + Q_EMIT this->incomingAccountMessage(QString(account_id.c_str()), QString(msgId.c_str()), QString(from.c_str()), convertMap(payloads)); }), exportable_callback<ConfigurationSignal::MediaParametersChanged>( [this] (const std::string& account_id) { @@ -722,7 +722,7 @@ Q_SIGNALS: // SIGNALS void incomingTrustRequest(const QString& accountId, const QString& from, const QByteArray& payload, qulonglong timeStamp); void knownDevicesChanged(const QString& accountId, const MapStringString& devices); void exportOnRingEnded(const QString& accountId, int status, const QString& pin); - void incomingAccountMessage(const QString& accountId, const QString& from, const MapStringString& payloads); + void incomingAccountMessage(const QString& accountId, const QString msgId, const QString& from, const MapStringString& payloads); void mediaParametersChanged(const QString& accountId); void audioDeviceEvent(); void audioMeter(const QString& id, float level); -- GitLab