Skip to content
Snippets Groups Projects
Commit b50dac4d authored by Adrien Béraud's avatar Adrien Béraud Committed by Guillaume Roguez
Browse files

ringaccount: add experimental account-level text message support

Experimental

Issue: #81125
Change-Id: Id0e579fa0fd70ef152c7e4074ed713730b542923
parent 12ec77a2
No related branches found
No related tags found
No related merge requests found
...@@ -531,6 +531,14 @@ std::map<std::string, std::string> RingAccount::getAccountDetails() const ...@@ -531,6 +531,14 @@ std::map<std::string, std::string> RingAccount::getAccountDetails() const
return a; return a;
} }
std::map<std::string, std::string>
RingAccount::getVolatileAccountDetails() const
{
auto a = SIPAccountBase::getVolatileAccountDetails();
a.emplace(DRing::Account::VolatileProperties::InstantMessaging::OFF_CALL, TRUE_STR);
return a;
}
void void
RingAccount::handleEvents() RingAccount::handleEvents()
{ {
...@@ -865,6 +873,18 @@ RingAccount::doRegister_() ...@@ -865,6 +873,18 @@ RingAccount::doRegister_()
return true; return true;
} }
); );
dht_.listen<dht::ImMessage>(
inboxKey,
[shared](dht::ImMessage&& v) {
auto& this_ = *shared.get();
auto from = v.from.toString();
auto msg = v.im_message;
RING_DBG("Text message received from DHT ! %s -> %s", from.c_str(), msg.c_str());
emitSignal<DRing::ConfigurationSignal::IncomingAccountMessage>(this_.getAccountID(), from, msg);
return true;
}
);
} }
catch (const std::exception& e) { catch (const std::exception& e) {
RING_ERR("Error registering DHT account: %s", e.what()); RING_ERR("Error registering DHT account: %s", e.what());
...@@ -1191,7 +1211,6 @@ RingAccount::getTrustRequests() const ...@@ -1191,7 +1211,6 @@ RingAccount::getTrustRequests() const
return ret; return ret;
} }
bool bool
RingAccount::acceptTrustRequest(const std::string& from) RingAccount::acceptTrustRequest(const std::string& from)
{ {
...@@ -1251,4 +1270,12 @@ RingAccount::connectivityChanged() ...@@ -1251,4 +1270,12 @@ RingAccount::connectivityChanged()
dht_.connectivityChanged(); dht_.connectivityChanged();
} }
void
RingAccount::sendTextMessage(const std::string& to, const std::string& message)
{
dht_.putEncrypted(dht::InfoHash::get("inbox:"+to),
dht::InfoHash(to),
dht::ImMessage(std::string(message)));
}
} // namespace ring } // namespace ring
...@@ -107,6 +107,12 @@ class RingAccount : public SIPAccountBase { ...@@ -107,6 +107,12 @@ class RingAccount : public SIPAccountBase {
*/ */
virtual std::map<std::string, std::string> getAccountDetails() const; virtual std::map<std::string, std::string> getAccountDetails() const;
/**
* Retrieve volatile details such as recent registration errors
* @return std::map< std::string, std::string > The account volatile details
*/
virtual std::map<std::string, std::string> getVolatileAccountDetails() const override;
/** /**
* Actually useless, since config loading is done in init() * Actually useless, since config loading is done in init()
*/ */
...@@ -249,6 +255,7 @@ class RingAccount : public SIPAccountBase { ...@@ -249,6 +255,7 @@ class RingAccount : public SIPAccountBase {
bool discardTrustRequest(const std::string& from); bool discardTrustRequest(const std::string& from);
void sendTrustRequest(const std::string& to, const std::vector<uint8_t>& payload); void sendTrustRequest(const std::string& to, const std::vector<uint8_t>& payload);
virtual void sendTextMessage(const std::string& /* to */, const std::string& /* message */) override;
void connectivityChanged(); void connectivityChanged();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment