Ring Daemon 16.0.0
Loading...
Searching...
No Matches
pluginsutils.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <json/json.h>
20#include <opendht/crypto.h>
21
22#include <map>
23#include <vector>
24#include <filesystem>
25
26namespace jami {
27
35namespace PluginUtils {
40std::filesystem::path manifestPath(const std::filesystem::path& rootPath);
41
46std::filesystem::path getRootPathFromSoPath(const std::filesystem::path& soPath);
47
52std::filesystem::path dataPath(const std::filesystem::path& pluginSoPath);
53
60std::map<std::string, std::string> checkManifestJsonContentValidity(const Json::Value& root);
61
67std::map<std::string, std::string> checkManifestValidity(std::istream& stream);
68
74std::map<std::string, std::string> checkManifestValidity(const std::vector<uint8_t>& vec);
75
80std::map<std::string, std::string> getPlatformInfo();
81
87std::map<std::string, std::string> parseManifestFile(const std::filesystem::path& manifestFilePath, const std::string& rootPath);
88
95std::string parseManifestTranslation(const std::string& rootPath, std::ifstream& manifestFile);
96
102bool checkPluginValidity(const std::filesystem::path& rootPath);
103
110std::map<std::string, std::string> readPluginManifestFromArchive(const std::string& jplPath);
111
118std::unique_ptr<dht::crypto::Certificate> readPluginCertificate(const std::string& rootPath, const std::string& pluginId);
125std::unique_ptr<dht::crypto::Certificate> readPluginCertificateFromArchive(const std::string& jplPath);
126
132std::map<std::string, std::vector<uint8_t>> readPluginSignatureFromArchive(const std::string& jplPath);
133
139std::vector<uint8_t> readSignatureFileFromArchive(const std::string& jplPath);
140
147std::pair<bool, std::string_view> uncompressJplFunction(std::string_view relativeFileName);
148
153std::string getLanguage();
154
162std::map<std::string, std::string> getLocales(const std::string& rootPath,
163 const std::string& lang);
164
171std::map<std::string, std::string> processLocaleFile(const std::string& localeFilePath);
172} // namespace PluginUtils
173} // namespace jami
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.
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.
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.
void emitSignal(Args... args)
Definition ring_signal.h:64