Commit 7f14e58c authored by Sébastien Blin's avatar Sébastien Blin Committed by Philippe Gorley

ringaccount: add the ability to copy the account archive

Add a method for exporting the account's archive in a
file.

This patch updates configurationmanager interfaces and
fix an error with exportOnDHT for nodejs.

Change-Id: I9fdfcd20b66854ca768166e5198b8ae428192305
Reviewed-by: Philippe Gorley's avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent 0da903b2
......@@ -169,6 +169,22 @@
</arg>
</method>
<method name="exportToFile" tp:name-for-bindings="exportToFile">
<tp:added version="5.1.0"/>
<tp:docstring>
Copy the account archive to the path provided in argument.
</tp:docstring>
<arg type="s" name="accountID" direction="in">
</arg>
<arg type="s" name="destinationPath" direction="in">
</arg>
<arg type="b" name="success" direction="out">
<tp:docstring>
True if the operation was initialized successfully.
</tp:docstring>
</arg>
</method>
<signal name="exportOnRingEnded" tp:name-for-bindings="exportOnRingEnded">
<tp:docstring>
Notify clients when the exportOnRing operation ended.
......
......@@ -81,6 +81,12 @@ DBusConfigurationManager::exportOnRing(const std::string& accountID, const std::
return DRing::exportOnRing(accountID, password);
}
auto
DBusConfigurationManager::exportToFile(const std::string& accountID, const std::string& destinationPath) -> decltype(DRing::exportToFile(accountID, destinationPath))
{
return DRing::exportToFile(accountID, destinationPath);
}
auto
DBusConfigurationManager::revokeDevice(const std::string& accountID, const std::string& password, const std::string& device) -> decltype(DRing::revokeDevice(accountID, password, device))
{
......
......@@ -68,6 +68,7 @@ class DBusConfigurationManager :
std::map<std::string, std::string> getAccountTemplate(const std::string& accountType);
std::string addAccount(const std::map<std::string, std::string>& details);
bool exportOnRing(const std::string& accountID, const std::string& password);
bool exportToFile(const std::string& accountID, const std::string& destinationPath);
bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& device);
std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID);
bool changeAccountPassword(const std::string& accountID, const std::string& password_old, const std::string& password_new);
......
......@@ -88,7 +88,8 @@ std::vector<std::string> getSupportedCiphers(const std::string& accountID);
std::map<std::string, std::string> getCodecDetails(const std::string& accountID, const unsigned& codecId);
bool setCodecDetails(const std::string& accountID, const unsigned& codecId, const std::map<std::string, std::string>& details);
std::vector<unsigned> getActiveCodecList(const std::string& accountID);
std::string exportOnRing(const std::string& accountID, const std::string& password);
bool exportOnRing(const std::string& accountID, const std::string& password);
bool exportToFile(const std::string& accountID, const std::string& destinationPath);
std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID);
bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID);
......
......@@ -85,7 +85,8 @@ std::vector<std::string> getSupportedCiphers(const std::string& accountID);
std::map<std::string, std::string> getCodecDetails(const std::string& accountID, const unsigned& codecId);
bool setCodecDetails(const std::string& accountID, const unsigned& codecId, const std::map<std::string, std::string>& details);
std::vector<unsigned> getActiveCodecList(const std::string& accountID);
std::string exportOnRing(const std::string& accountID, const std::string& password);
bool exportOnRing(const std::string& accountID, const std::string& password);
bool exportToFile(const std::string& accountID, const std::string& destinationPath);
std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID);
bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID);
......
......@@ -2,7 +2,7 @@ dnl Ring - configure.ac for automake 1.9 and autoconf 2.59
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65])
AC_INIT([Ring Daemon],[5.0.0],[ring@gnu.org],[ring])
AC_INIT([Ring Daemon],[5.1.0],[ring@gnu.org],[ring])
AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2018]])
AC_REVISION([$Revision$])
......
......@@ -31,7 +31,7 @@ PROJECT_NAME = "Ring Daemon"
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 5.0.0
PROJECT_NUMBER = 5.1.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer
......
......@@ -286,6 +286,15 @@ exportOnRing(const std::string& accountID, const std::string& password)
return false;
}
bool
exportToFile(const std::string& accountID, const std::string& destinationPath)
{
if (const auto account = ring::Manager::instance().getAccount<ring::RingAccount>(accountID)) {
return account->exportArchive(destinationPath);
}
return false;
}
bool
revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID)
{
......
......@@ -50,6 +50,7 @@ void setAccountActive(const std::string& accountID, bool active);
std::map<std::string, std::string> getAccountTemplate(const std::string& accountType);
std::string addAccount(const std::map<std::string, std::string>& details);
bool exportOnRing(const std::string& accountID, const std::string& password);
bool exportToFile(const std::string& accountID, const std::string& destinationPath);
bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID);
std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID);
bool changeAccountPassword(const std::string& accountID, const std::string& password_old, const std::string& password_new);
......
......@@ -1052,6 +1052,22 @@ RingAccount::addDevice(const std::string& password)
});
}
bool
RingAccount::exportArchive(const std::string& destinationPath)
{
try {
auto sourcePath = fileutils::getFullPath(idPath_, archivePath_);
std::ifstream src(sourcePath, std::ios::in | std::ios::binary);
if (!src) return false;
std::ofstream dst(destinationPath, std::ios::out | std::ios::binary);
dst << src.rdbuf();
} catch (const std::runtime_error& ex) {
RING_ERR("[Account %s] Can't export archive: %s", getAccountID().c_str(), ex.what());
return false;
}
return true;
}
bool
RingAccount::revokeDevice(const std::string& password, const std::string& device)
{
......
......@@ -300,6 +300,7 @@ class RingAccount : public SIPAccountBase {
/* Devices */
void addDevice(const std::string& password);
bool exportArchive(const std::string& destinationPath);
bool revokeDevice(const std::string& password, const std::string& device);
std::map<std::string, std::string> getKnownDevices() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment