diff --git a/bin/dbus/cx.ring.Ring.ConfigurationManager.xml b/bin/dbus/cx.ring.Ring.ConfigurationManager.xml index 37e3cf65f4af1c1468223f284d64f34551445dc3..d5e99a09c3f26e2f0b5ec3db9ceee7b0b8beb4f0 100644 --- a/bin/dbus/cx.ring.Ring.ConfigurationManager.xml +++ b/bin/dbus/cx.ring.Ring.ConfigurationManager.xml @@ -579,7 +579,7 @@ <arg type="s" name="accountId" direction="in"/> <arg type="s" name="displayName" direction="in"/> <arg type="s" name="avatar" direction="in"/> - <arg type="t" name="flag" direction="in"/> + <arg type="i" name="flag" direction="in"/> <tp:docstring> Update the profile of the account and send it to peers. Flag options : diff --git a/bin/dbus/dbusconfigurationmanager.hpp b/bin/dbus/dbusconfigurationmanager.hpp index c50baf7ac42cf6ac8564efc839c77ea9e196bb60..b5d267a678bfb0582b9ce4d55a076785f2e5bf35 100644 --- a/bin/dbus/dbusconfigurationmanager.hpp +++ b/bin/dbus/dbusconfigurationmanager.hpp @@ -217,7 +217,7 @@ public: } void - updateProfile(const std::string& accountID,const std::string& displayName, const std::string& avatar, const uint64_t& flag) + updateProfile(const std::string& accountID,const std::string& displayName, const std::string& avatar, const int32_t& flag) { libjami::updateProfile(accountID, displayName, avatar, flag); } diff --git a/bin/jni/configurationmanager.i b/bin/jni/configurationmanager.i index 34214d2f39e0042da3307297499f68ca292b5c90..af6e2a87a87e1eb6d1273a0c626b6334b9a05628 100644 --- a/bin/jni/configurationmanager.i +++ b/bin/jni/configurationmanager.i @@ -90,11 +90,11 @@ std::vector<std::map<std::string, std::string>> getConnectionList(const std::str std::vector<std::map<std::string, std::string>> getChannelList(const std::string& accountId, const std::string& connectionId); std::string addAccount(const std::map<std::string, std::string>& details); void removeAccount(const std::string& accountId); -void updateProfile(const std::string& accountId,const std::string& displayName, const std::string& avatar, const uint64_t& flag); +void updateProfile(const std::string& accountId,const std::string& displayName, const std::string& avatar, int32_t flag); std::vector<std::string> getAccountList(); void sendRegister(const std::string& accountId, bool enable); void registerAllAccounts(void); -uint64_t sendAccountTextMessage(const std::string& accountId, const std::string& to, const std::map<std::string, std::string>& message, const int32_t& flag); +uint64_t sendAccountTextMessage(const std::string& accountId, const std::string& to, const std::map<std::string, std::string>& message, int32_t flag); std::vector<libjami::Message> getLastMessages(const std::string& accountId, uint64_t base_timestamp); int getMessageStatus(uint64_t id); int getMessageStatus(const std::string& accountId, uint64_t id); diff --git a/bin/nodejs/configurationmanager.i b/bin/nodejs/configurationmanager.i index c55414e5be0fe0fe370fb47458e26dbb105321b8..8cc261ee5c91b74d1b82e64c977a0c1ee9b2564b 100644 --- a/bin/nodejs/configurationmanager.i +++ b/bin/nodejs/configurationmanager.i @@ -86,11 +86,11 @@ std::vector<std::map<std::string, std::string>> getConnectionList(const std::str std::vector<std::map<std::string, std::string>> getChannelList(const std::string& accountId, const std::string& connectionId); std::string addAccount(const std::map<std::string, std::string>& details); void removeAccount(const std::string& accountId); -void updateProfile(const std::string& accountId,const std::string& displayName, const std::string& avatar, const uint64_t& flag); +void updateProfile(const std::string& accountId,const std::string& displayName, const std::string& avatar, int32_t flag); std::vector<std::string> getAccountList(); void sendRegister(const std::string& accountId, bool enable); void registerAllAccounts(void); -uint64_t sendAccountTextMessage(const std::string& accountId, const std::string& to, const std::map<std::string, std::string>& message, const int32_t& flag); +uint64_t sendAccountTextMessage(const std::string& accountId, const std::string& to, const std::map<std::string, std::string>& message, int32_t flag); std::vector<libjami::Message> getLastMessages(const std::string& accountId, uint64_t base_timestamp); int getMessageStatus(uint64_t id); int getMessageStatus(const std::string& accountId, uint64_t id); diff --git a/src/account.h b/src/account.h index 0a738f7b31d4527d6a3585c90d2f95dce3a64530..c38ab4fa4befcf4a1d7127645d8463dc7c141d93 100644 --- a/src/account.h +++ b/src/account.h @@ -210,7 +210,7 @@ public: virtual std::map<std::string, std::string> getNearbyPeers() const { return {}; } - virtual void updateProfile(const std::string& /*displayName*/, const std::string& /*avatar*/,const uint64_t& /*flag*/) = 0; + virtual void updateProfile(const std::string& /*displayName*/, const std::string& /*avatar*/, int32_t /*flag*/) = 0; std::map<std::string, std::string> getProfileVcard() const; diff --git a/src/client/configurationmanager.cpp b/src/client/configurationmanager.cpp index 076526e7c314104c3e7660fb8d76e4c113f51c61..e46ca3db1884833102f9f38dc190f4f1af71ef78 100644 --- a/src/client/configurationmanager.cpp +++ b/src/client/configurationmanager.cpp @@ -294,7 +294,7 @@ getNearbyPeers(const std::string& accountId) } void -updateProfile(const std::string& accountId,const std::string& displayName, const std::string& avatar,const uint64_t& flag) +updateProfile(const std::string& accountId,const std::string& displayName, const std::string& avatar, int32_t flag) { if (const auto acc = jami::Manager::instance().getAccount(accountId)){ acc->updateProfile(displayName, avatar, flag); diff --git a/src/jami/configurationmanager_interface.h b/src/jami/configurationmanager_interface.h index 2fc988457873402331ef9d543aaa1eda0348ae4f..31a08cff61e582de5cb737d9e7d443b1d4373436 100644 --- a/src/jami/configurationmanager_interface.h +++ b/src/jami/configurationmanager_interface.h @@ -104,7 +104,7 @@ LIBJAMI_PUBLIC bool cancelMessage(const std::string& accountId, uint64_t message LIBJAMI_PUBLIC std::vector<Message> getLastMessages(const std::string& accountId, const uint64_t& base_timestamp); LIBJAMI_PUBLIC std::map<std::string, std::string> getNearbyPeers(const std::string& accountId); -LIBJAMI_PUBLIC void updateProfile(const std::string& accountId,const std::string& displayName, const std::string& avatar, const uint64_t& flag); +LIBJAMI_PUBLIC void updateProfile(const std::string& accountId,const std::string& displayName, const std::string& avatar, int32_t flag); LIBJAMI_PUBLIC int getMessageStatus(uint64_t id); LIBJAMI_PUBLIC int getMessageStatus(const std::string& accountId, uint64_t id); LIBJAMI_PUBLIC void setIsComposing(const std::string& accountId, diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index 8cf817f862c24c2f23e82ab861a7fc0497ecb6c0..18e91d5701c286a152b146167b5f761294c6ef06 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -3395,7 +3395,7 @@ JamiAccount::sendProfileToPeers() void JamiAccount::updateProfile(const std::string& displayName, const std::string& avatar, - const uint64_t& flag) + int32_t flag) { const auto& accountUri = accountManager_->getInfo()->accountId; const auto& path = profilePath(); @@ -3411,7 +3411,6 @@ JamiAccount::updateProfile(const std::string& displayName, } const auto& vCardPath = profiles / fmt::format("{}.vcf", base64::encode(accountUri)); - const std::filesystem::path& tmpPath = vCardPath.string() + ".tmp"; auto profile = getProfileVcard(); if (profile.empty()) { @@ -3440,13 +3439,11 @@ JamiAccount::updateProfile(const std::string& displayName, // nothing happens to the profile photo if the avatarPath is invalid // and not empty. So far it seems to be the best default behavior. - - const std::string& vCard = vCard::utils::toString(profile); - try { + std::filesystem::path tmpPath = vCardPath.string() + ".tmp"; std::ofstream file(tmpPath); if (file.is_open()) { - file << vCard; + file << vCard::utils::toString(profile); file.close(); std::filesystem::rename(tmpPath, vCardPath); fileutils::createFileLink(path, vCardPath); diff --git a/src/jamidht/jamiaccount.h b/src/jamidht/jamiaccount.h index ca36fa26dca1ee9930aebe4ded3e8104ff51db16..d23221611cc713e34f0769a5dd19ee783937a992 100644 --- a/src/jamidht/jamiaccount.h +++ b/src/jamidht/jamiaccount.h @@ -426,7 +426,7 @@ public: * @param avatar Current or new avatar * @param flag 0 for path to avatar, 1 for base64 avatar */ - void updateProfile(const std::string& displayName, const std::string& avatar, const uint64_t& flag); + void updateProfile(const std::string& displayName, const std::string& avatar, int32_t flag) override; #ifdef LIBJAMI_TESTABLE dhtnet::ConnectionManager& connectionManager() { return *connectionManager_; } diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index db928c69c8656c87bf4c54c98100aeac0e8003da..d5778cd9837eaea8f18e985c634a330d81a66198 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -148,7 +148,7 @@ SIPAccount::~SIPAccount() noexcept void SIPAccount::updateProfile(const std::string& displayName, const std::string& avatar, - const uint64_t& flag) + int32_t flag) { auto vCardPath = idPath_ / "profile.vcf"; @@ -162,8 +162,7 @@ SIPAccount::updateProfile(const std::string& displayName, const auto& avatarPath = std::filesystem::path(avatar); if (std::filesystem::exists(avatarPath)) { try { - const auto& base64 = jami::base64::encode(fileutils::loadFile(avatarPath)); - profile["PHOTO;ENCODING=BASE64;TYPE=PNG"] = base64; + profile["PHOTO;ENCODING=BASE64;TYPE=PNG"] = base64::encode(fileutils::loadFile(avatarPath)); } catch (const std::exception& e) { JAMI_ERROR("Failed to load avatar: {}", e.what()); } @@ -176,15 +175,12 @@ SIPAccount::updateProfile(const std::string& displayName, // nothing happens to the profile photo if the avatarPath is invalid // and not empty. So far it seems to be the best default behavior. - - const std::string& vCard = vCard::utils::toString(profile); - try { auto tmpPath = vCardPath; tmpPath += ".tmp"; std::ofstream file(tmpPath); if (file.is_open()) { - file << vCard; + file << vCard::utils::toString(profile); file.close(); std::filesystem::rename(tmpPath, vCardPath); } else { diff --git a/src/sip/sipaccount.h b/src/sip/sipaccount.h index 05cee9a1b4e679f2d9b485658e11a5fef71e493a..ff7927be0e818eba69819905ee05de84fef6fd1e 100644 --- a/src/sip/sipaccount.h +++ b/src/sip/sipaccount.h @@ -130,7 +130,7 @@ public: /** * updates SIP account profile */ - void updateProfile(const std::string& displayName, const std::string& avatar, const uint64_t& flag) override; + void updateProfile(const std::string& displayName, const std::string& avatar, int32_t flag) override; /** * Initialize the SIP voip link with the account parameters and send registration