29 #if (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
32 #if defined(__x86_64__)
33 #define ABI "x86_64-apple-Darwin"
35 #define ABI "arm64-apple-Darwin"
39 #if defined(__ARM_ARCH_7A__)
40 #define ABI "armeabi-v7a"
44#elif defined(__i386__)
48 #define ABI "x86-linux-gnu"
50#elif defined(__x86_64__)
54 #define ABI "x86_64-linux-gnu"
56#elif defined(__aarch64__)
57#define ABI "arm64-v8a"
59#define ABI "x64-windows"
79std::map<std::string, std::string>
90 return soPath.parent_path();
99std::map<std::string, std::string>
102 std::string name =
root.get(
"name",
"").asString();
103 std::string
id =
root.get(
"id", name).asString();
104 std::string description =
root.get(
"description",
"").asString();
105 std::string
version =
root.get(
"version",
"").asString();
106 std::string
iconPath =
root.get(
"iconPath",
"icon.png").asString();
107 std::string
background =
root.get(
"backgroundPath",
"background.jpg").asString();
108 if (!name.empty() || !
version.empty()) {
112 {
"description", description},
118 throw std::runtime_error(
"plugin manifest file: bad format");
122std::map<std::string, std::string>
126 Json::CharReaderBuilder rbuilder;
127 rbuilder[
"collectComments"] =
false;
130 if (Json::parseFromStream(rbuilder, stream, &
root, &
errs)) {
133 throw std::runtime_error(
"failed to parse the plugin manifest file");
137std::map<std::string, std::string>
141 std::unique_ptr<Json::CharReader>
json_Reader(Json::CharReaderBuilder {}.newCharReader());
145 reinterpret_cast<const char*
>(
vec.data() +
vec.size()),
152 throw std::runtime_error(
"failed to parse the plugin manifest file");
156std::map<std::string, std::string>
165 }
catch (
const std::exception&
e) {
180 std::regex
pattern(R
"(\{\{([^}]+)\}\})");
184 if (matches.size() == 2) {
204std::map<std::string, std::string>
209 }
catch (
const std::exception&
e) {
215std::unique_ptr<dht::crypto::Certificate>
221 return std::make_unique<dht::crypto::Certificate>(
cert);
222 }
catch (
const std::exception&
e) {
228std::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>>
248 msgpack::object_handle
oh = msgpack::unpack(
249 reinterpret_cast<const char*
>(
vec.data()),
252 msgpack::object
obj =
oh.get();
253 return obj.as<std::map<std::string, std::vector<uint8_t>>>();
254 }
catch(
const std::exception&
e) {
266std::pair<bool, std::string_view>
275 return std::make_pair(
false, std::string_view {});
287 if (
auto envLang = std::getenv(
"JAMI_LANG"))
290 JAMI_INFO() <<
"Error getting JAMI_LANG env, attempting to get system language";
330std::map<std::string, std::string>
336 std::map<std::string, std::string>
locales = {};
351std::map<std::string, std::string>
360 Json::CharReaderBuilder rbuilder;
361 rbuilder[
"collectComments"] =
false;
363 std::map<std::string, std::string>
locales {};
366 if (Json::parseFromStream(rbuilder,
file, &
root, &
errs)) {
368 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)