archiver.h 2.36 KB
Newer Older
1
/*
2
 *  Copyright (C) 2016-2019 Savoir-faire Linux Inc.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 *
 *  Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
 */

#pragma once

#include "noncopyable.h"

#include <string>
#include <vector>
#include <map>

Adrien Béraud's avatar
Adrien Béraud committed
29
namespace jami {
30 31 32 33

/**
 * Archiver is used to generate/read encrypted archives
 */
34
namespace archiver {
35

36 37 38 39 40 41 42
/**
 * Create a protected archive containing a list of accounts
 * @param accountIDs The accounts to exports
 * @param filepath The filepath where to put the resulting archive
 * @param password The mandatory password to set on the archive
 * @returns 0 for OK, error code otherwise
 */
Adrien Béraud's avatar
Adrien Béraud committed
43 44 45
int exportAccounts(const std::vector<std::string>& accountIDs,
                    const std::string& filepath,
                    const std::string& password);
46

47 48 49 50 51 52 53
/**
 * Read a protected archive and add accounts found in it
 * Warning: this function must be called from a registered pjsip thread
 * @param archivePath The path to the archive file
 * @param password The password to read the archive
 * @returns 0 for OK, error code otherwise
 */
Adrien Béraud's avatar
Adrien Béraud committed
54
int importAccounts(const std::string& archivePath, const std::string& password);
55

56 57 58 59 60
/**
 * Compress a STL string using zlib with given compression level and return
 * the binary data.
 */
std::vector<uint8_t> compress(const std::string& str);
61

62 63 64 65
/**
 * Decompress an STL string using zlib and return the original data.
 */
std::vector<uint8_t> decompress(const std::vector<uint8_t>& dat);
66

67 68 69 70 71 72 73 74 75 76
/**
 * Compress string to a Gzip file
 */
void compressGzip(const std::string& str, const std::string& path);

/**
 * Decompress Gzip file to bytes
 */
std::vector<uint8_t> decompressGzip(const std::string& path);

77
}
78

Adrien Béraud's avatar
Adrien Béraud committed
79
} // namespace jami