30#if (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
33#if defined(__x86_64__)
34#define ABI "x86_64-apple-Darwin"
36#define ABI "arm64-apple-Darwin"
40#if defined(__ARM_ARCH_7A__)
41#define ABI "armeabi-v7a"
45#elif defined(__i386__)
49#define ABI "x86-linux-gnu"
51#elif defined(__x86_64__)
55#define ABI "x86_64-linux-gnu"
57#elif defined(__aarch64__)
58#define ABI "arm64-v8a"
60#define ABI "x64-windows"
80std::map<std::string, std::string>
89 return soPath.parent_path();
98std::map<std::string, std::string>
101 std::string name =
root.get(
"name",
"").asString();
102 std::string
id =
root.get(
"id", name).asString();
103 std::string description =
root.get(
"description",
"").asString();
104 std::string
version =
root.get(
"version",
"").asString();
105 std::string
iconPath =
root.get(
"iconPath",
"icon.png").asString();
106 std::string
background =
root.get(
"backgroundPath",
"background.jpg").asString();
107 if (!name.empty() || !
version.empty()) {
111 {
"description", description},
117 throw std::runtime_error(
"plugin manifest file: bad format");
121std::map<std::string, std::string>
125 Json::CharReaderBuilder rbuilder;
126 rbuilder[
"collectComments"] =
false;
129 if (Json::parseFromStream(rbuilder, stream, &
root, &
errs)) {
132 throw std::runtime_error(
"failed to parse the plugin manifest file");
136std::map<std::string, std::string>
140 std::unique_ptr<Json::CharReader>
json_Reader(Json::CharReaderBuilder {}.newCharReader());
144 reinterpret_cast<const char*
>(
vec.data() +
vec.size()),
151 throw std::runtime_error(
"failed to parse the plugin manifest file");
155std::map<std::string, std::string>
164 }
catch (
const std::exception&
e) {
179 std::regex
pattern(R
"(\{\{([^}]+)\}\})");
183 if (matches.size() == 2) {
203std::map<std::string, std::string>
208 }
catch (
const std::exception&
e) {
214std::unique_ptr<dht::crypto::Certificate>
220 return std::make_unique<dht::crypto::Certificate>(
cert);
221 }
catch (
const std::exception&
e) {
227std::unique_ptr<dht::crypto::Certificate>
232 const std::string& name =
manifest[
"id"];
238 }
catch (
const std::exception&
e) {
244std::map<std::string, std::vector<uint8_t>>
249 msgpack::object_handle
oh = msgpack::unpack(
reinterpret_cast<const char*
>(
vec.data()),
251 msgpack::object
obj =
oh.get();
252 return obj.as<std::map<std::string, std::vector<uint8_t>>>();
253 }
catch (
const std::exception&
e) {
265std::pair<bool, std::string_view>
274 return std::make_pair(
false, std::string_view {});
286 if (
auto*
envLang = std::getenv(
"JAMI_LANG"))
289 JAMI_INFO() <<
"Error getting JAMI_LANG env, attempting to get system language";
329std::map<std::string, std::string>
335 std::map<std::string, std::string>
locales = {};
350std::map<std::string, std::string>
359 Json::CharReaderBuilder rbuilder;
360 rbuilder[
"collectComments"] =
false;
362 std::map<std::string, std::string>
locales {};
365 if (Json::parseFromStream(rbuilder,
file, &
root, &
errs)) {
367 for (
const auto& key :
keys) {
#define DIR_SEPARATOR_STR_ESC
This namespace provides auxiliary functions to the Plugin System.
std::unique_ptr< dht::crypto::Certificate > readPluginCertificate(const std::string &rootPath, const std::string &pluginId)
Read the plugin's certificate.
std::string getLanguage()
Returns the language of the current locale.
std::map< std::string, std::string > checkManifestJsonContentValidity(const Json::Value &root)
Check if manifest.json has minimum format and parses its content to a map<string, string>.
std::map< std::string, std::string > readPluginManifestFromArchive(const std::string &jplPath)
Reads the manifest file content without uncompressing the whole archive and return a map with manifes...
std::filesystem::path dataPath(const std::filesystem::path &pluginSoPath)
Returns data path given a plugin's library path.
std::map< std::string, std::string > getPlatformInfo()
Returns a map with platform information.
std::filesystem::path getRootPathFromSoPath(const std::filesystem::path &soPath)
Returns installation path given a plugin's library path.
std::vector< uint8_t > readSignatureFileFromArchive(const std::string &jplPath)
Read the signature of the file signature without uncompressing the whole archive.
const std::regex SO_REGEX(DIR_SEPARATOR_STR_ESC "(.*)" DIR_SEPARATOR_STR_ESC "([a-zA-Z0-9]+.(dylib|so|dll|lib).*)")
bool checkPluginValidity(const std::filesystem::path &rootPath)
Validates a plugin based on its manifest.json file.
std::filesystem::path manifestPath(const std::filesystem::path &rootPath)
Returns complete manifest.json file path given a installation path.
std::unique_ptr< dht::crypto::Certificate > readPluginCertificateFromArchive(const std::string &jplPath)
Read plugin certificate without uncompressing the whole archive.and return an object Certificate.
std::map< std::string, std::string > processLocaleFile(const std::string &preferenceLocaleFilePath)
Returns the available keys and translations for a given file.
std::pair< bool, std::string_view > uncompressJplFunction(std::string_view relativeFileName)
Function used by archiver to extract files from plugin jpl to the plugin installation path.
std::map< std::string, std::string > getLocales(const std::string &rootPath, const std::string &lang)
Returns the available keys and translations for a given plugin.
std::map< std::string, std::string > parseManifestFile(const std::filesystem::path &manifestFilePath, const std::string &rootPath)
Parses the manifest file of an installed plugin if it's valid.
std::map< std::string, std::vector< uint8_t > > readPluginSignatureFromArchive(const std::string &jplPath)
Reads signature file content without uncompressing the whole archive and.
const std::regex DATA_REGEX("^data" DIR_SEPARATOR_STR_ESC ".+")
std::string parseManifestTranslation(const std::string &rootPath, std::ifstream &manifestFile)
Parses the manifest file of an installed plugin if it's valid.
std::map< std::string, std::string > checkManifestValidity(std::istream &stream)
Reads manifest.json stream and checks if it's valid.
std::vector< uint8_t > readFileFromArchive(const std::string &archivePath, const std::string &fileRelativePathName)
readFileFromArchive read a file from an archive without uncompressing the whole archive
std::vector< uint8_t > loadFile(const std::filesystem::path &path, const std::filesystem::path &default_dir)
Read the full content of a file at path.
static constexpr int version
void emitSignal(Args... args)
void string_replace(std::string &str, const std::string &from, const std::string &to)
match_results< string_view::const_iterator > svmatch
constexpr string_view svsub_match_view(const svsub_match &submatch) noexcept
bool regex_search(string_view sv, svmatch &m, const regex &e, regex_constants::match_flag_type flags=regex_constants::match_default)