KasperskyOS Community Edition 1.3

IPackageManifest interface

This API is defined in the header file sysroot-*-kos/include/component/package_manager/i_package_manifest.h from the KasperskyOS SDK.

The API lets you get the KPA package manifest key values. For more details about the available keys of the KPA package manifest, see "KPA package manifest"

Information about API functions is provided in the table below.

Getting program ID

To get the ID of a program that was installed from a KPA package, call the GetPackageID() function.

Getting information about KPA package components

To get information about KPA package components, call the GetApplicationsInfo() function. Using the applications output parameter, the function returns information about KPA package components as a vector of ApplicationInfo structures.

struct ApplicationInfo { // Name of the KPA package component. std::string name; // Path of the directory relative to the path /<package name>/res // in which the KPA package component is installed. std::string path; // Unused parameter. std::string iconPath; // Unused parameter. std::string containerPath; // Unused parameter. std::string etcPath; // Checksum of the KPA package component file. std::string digest; // Object in JSON format. ManifestType extensions; // Type of KPA package component. std::string type; };

An extensions structure element describes an object in JSON format. ManifestType is an alias of the nlohmann:json type.

Getting program startup configurations

To get information about the startup configurations of a program installed from a KPA package, call the GetRunConfigurationsInfo() function. Using the runConfigurations output parameter, the function returns information about program startup configurations as a vector of RunConfigurationInfo structures.

struct RunConfigurationInfo { // Startup configuration ID that is unique within the specific KPA package. std::string id; // Startup configuration name. std::string name; // Program security class. std::string eiid // Path to the KPA package component file. std::string path; // List of arguments in the form of a string array. std::vector<std::string> args{} // List of environment variables. std::vector<std::string> envs{} // Indicates whether the startup configuration is the primary one during program startup: // true means that it is primary, and false means that it is not primary. bool primary{false}; // Indicates whether this configuration is started automatically: // true means that it is started automatically, and false means that it is not. bool autorun{false}; };

Receiving information about a program

To get information about a program installed from a KPA package, call the GetPackageInfo() function. Using the packageInfo output parameter, the function returns information about startup configurations in the PackageInfo structure.

struct PackageInfo { // Unique ID of the program. std::string id; // Program name. std::string name; // Program version. std::string version; // Unused parameter. std::string title; // Unused parameter. std::string summary; // Program description. std::string description; // Program build number. std::string buildNumber; // Logical value indicating whether the program is a system program: // true means that it is, while false means that it is not. bool systemApplication; // Object of an arbitrary format. ManifestType extensions; };

Getting information about the isolated storage of a program

To get information about the isolated storage of a program, call the GetPrivateStorageInfo() function. Using the packageInfo output parameter, the function returns information about startup configurations in the PrivateStorage structure.

struct PrivateStorage { // Program data storage size in MB. size_t size; // Program data storage file system type. std::string fsType; };

Getting information about objects of an arbitrary format

To get information about objects of an arbitrary format that were added by the KPA package developer (the extensions key from the KPA package manifest), call the Get() function.

i_package_manifest.h functions

Function

Information about the function

GetPackageID()

Purpose

Gets the unique ID of a program installed from a KPA package.

Parameters

  • [out] id – unique ID of the program.

Returned values

If successful, the function returns kos::rtl::Ok, otherwise it returns an error code.

GetApplicationsInfo()

Purpose

Gets information about KPA package components.

Parameters

  • [out] applications – vector of ApplicationInfo structures containing information about KPA package components.

Returned values

If successful, the function returns kos::rtl::Ok, otherwise it returns an error code.

GetRunConfigurationsInfo()

Purpose

Gets information about the startup configurations of a program installed from a KPA package.

Parameters

  • [out] runConfigurations – vector of RunConfigurationInfo structures containing information about startup configurations.

Returned values

If successful, the function returns kos::rtl::Ok, otherwise it returns an error code.

GetPackageInfo()

Purpose

Gets information about a program installed from a KPA package.

Parameters

  • [out] packageInfo – PackageInfo structure containing information about the program.

Returned values

If successful, the function returns kos::rtl::Ok, otherwise it returns an error code.

GetPrivateStorageInfo()

Purpose

Gets information about the isolated storage of a program.

Parameters

  • [out] packageInfo – PrivateStorage structure containing information about the isolated storage of a program.

Returned values

If successful, the function returns kos::rtl::Ok, otherwise it returns an error code.

Get()

Purpose

Gets information about objects of an arbitrary format that were added to the manifest by the KPA package developer.

Parameters

N/A

Returned values

Returns the pointer of an object with the type pkgmgr::IPackageManifest::ManifestType.

Usage example:

client.cpp

#include <component/package_manager/kos_ipc/package_manager_proxy.h> namespace pkgmgr = package_manager; int main(int argc, const char *argv[]) { // ... // Get the pointer to the instance of the IPackageManifest interface // for the KPA package containing the unique ID uid1. pkgmgr::IPackageManifestPtr manifest; if (pkgc->GetManifest(uid1, manifest) != kos::rtl::Ok) return EXIT_FAILURE; // Get unique ID of the program. std::string packageID; if (manifest->GetPackageID(packageID) != kos::rtl::Ok) return EXIT_FAILURE; std::cout << packageID << '\n'; // Get information about KPA package components. std::vector<package_manager::IPackageManifest::ApplicationInfo> infos; manifest->GetApplicationsInfo(infos); for (auto &info: infos) { std::cout << info.name << " " << info.path << "\n"; } // Get information about objects of an arbitrary format. pkgmgr::IPackageManifest::ManifestType jsonManifest = manifest->Get(); std::cout << jsonManifest["package"]["description"] << '\n'; // Get information about the startup configurations of a program installed from a KPA package. std::vector<package_manager::IPackageManifest::RunConfigurationInfo> runConfigurationInfos; manifest->GetRunConfigurationsInfo(runConfigurationInfos); for (auto &runConfigurationInfo : runConfigurationInfos) { std::cout << "RunConfiguration.id = " << runConfigurationInfo.id << ", autorun = " << runConfigurationInfo.autorun << "\n"; } // ... }