namespace common_installer {
+/**
+ * \brief Includes the main “steps” processing mechanisms. It holds
+ * the lists of steps and runs each of the step in the configured
+ * order.
+ */
class AppInstaller {
public:
+ /** Enumeration of possible returned Results */
enum class Result {
OK,
ERROR,
UNKNOWN
};
+ /**
+ * \brief explicit Constructor
+ *
+ * \param package_type package type
+ * \param pkgmgr pointer to PkgMgrInterface object
+ */
explicit AppInstaller(const char* package_type, PkgMgrPtr pkgmgr);
+
+ /** virtual desctructor */
virtual ~AppInstaller();
- // Adds new step to installer by specified type
- // Type of template parameter is used to create requested step class instance.
- // Context of installer is passed to step in this method
- // and is not being exposed outside installer.
- // Step arguments are deduced and forwarded to constructor
+ /**
+ * \brief Adds new step to installer by specified type
+ * Type of template parameter is used to create requested step
+ * class instance.
+ * Context of installer is passed to step in this method
+ * and is not being exposed outside installer.
+ * Step arguments are deduced and forwarded to constructor.
+ *
+ * \tparam StepT Step object to be added to the step list
+ * \tparam Args constructor arguments for StepT object
+ * \param args argument list
+ */
template<class StepT, class... Args>
void AddStep(Args&&... args) {
steps_.push_back(std::unique_ptr<Step>(
new StepT(context_.get(), std::forward<Args>(args)...)));
}
+ /**
+ * \brief runs the steps in the specific sequence
+ *
+ * \return Result of the run (eg Result:OK)
+ */
Result Run();
protected:
namespace common_installer {
+
+/**
+ * \brief Base interface for some helper functionalities used before
+ * configuring app-installer steps.
+ * Eg. it is used to check, if package is to be installed or updated
+ */
class AppQueryInterface {
public:
+ /** virtual destructor (for inheritance) */
virtual ~AppQueryInterface() { }
+
+ /**
+ * \brief abstract method for checking if package is installed based
+ * on argv
+ *
+ * \param argc main() argc argument passed to the backend
+ * \param argv main() argv argument passed to the backend
+ *
+ * \return true if package is installed
+ */
virtual bool IsAppInstalledByArgv(int argc, char** argv) = 0;
};
namespace common_installer {
+/**
+ * \brief Helper function for getting backup path (used for recovery)
+ * based on package path
+ *
+ * \param pkg_path package path
+ *
+ * \return backup path
+ */
boost::filesystem::path GetBackupPathForPackagePath(
const boost::filesystem::path& pkg_path);
+
+/**
+ * \brief Helper function for getting backup path (used for recovery)
+ * based on manifest file path
+ *
+ * \param manifest_path path to manifest file
+ *
+ * \return backup path
+ */
boost::filesystem::path GetBackupPathForManifestFile(
const boost::filesystem::path& manfest_path);
+
+/**
+ * \brief Helper function for getting backup path (used for recovery)
+ * based on icon path
+ *
+ * \param icon_path path to icon file
+ *
+ * \return backup path
+ */
boost::filesystem::path GetBackupPathForIconFile(
const boost::filesystem::path& icon_path);
// TODO(t.iwanek): this structure should be unified for manifest handlers of
// wgt and tpk packages
+
+/**
+ * Used to store information about single account
+ */
struct SingleAccountInfo {
bool multiple_account_support;
std::vector<std::pair<std::string, std::string>> names;
std::string providerid;
};
+
+/**
+ * Holds information about all accounts
+ */
class AccountInfo {
public:
+ /** Constructor */
AccountInfo() {}
+ /**
+ * accounts list getter
+ *
+ * \return accounts list
+ */
const std::vector<SingleAccountInfo>& accounts() const {
return accounts_;
}
+
+ /**
+ * Adds account to the list
+ *
+ * \param single_account account to be added
+ */
void set_account(const SingleAccountInfo& single_account) {
accounts_.push_back(single_account);
}
using ShortcutListInfo = std::vector<ShortcutInfo>;
+
+// TODO(p.sikorski): if that structure holds extra information not covered
+// in manifest_x, maybe it should hold manifest_x as well?
+/**
+ * \brief Structure, that holds additional data retrieved from manifest
+ * and used during generation of platform manifest (for data that are not
+ * available within manifest_x structure
+ */
class ExtraManifestData {
public:
+ /** Constructor */
ExtraManifestData() {}
Property<AccountInfo> account_info;
Property<ShortcutListInfo> shortcut_info;
};
+/**
+ * \brief Base class that is used within specific backends to keep additional
+ * information regarding package
+ */
class BackendData {
public:
+ /** virtual destructor */
virtual ~BackendData() { }
};
+/**
+ * \brief Class represents certificate information
+ */
class CertificateInfo {
public:
+ /** author_certificate */
Property<ValidationCore::CertificatePtr> author_certificate;
};
+/**
+ * \brief Class used for recovery situation.
+ * It holds pointer to RecoveryFile object.
+ */
class RecoveryInfo {
public:
+ /** default constructor */
RecoveryInfo() { }
+
+ /**
+ * Constructor.
+ *
+ * \param rf RecoveryFile object (pointer to object)
+ */
explicit RecoveryInfo(std::unique_ptr<recovery::RecoveryFile> rf)
: recovery_file(std::move(rf)) {
}
+ /** pointer to RecoveryFile */
std::unique_ptr<recovery::RecoveryFile> recovery_file;
};
+/**
+ * Enumeration for Privilege levels
+ */
enum class PrivilegeLevel : int {
UNTRUSTED = 0,
PUBLIC = 1,
PLATFORM = 3
};
+/**
+ * \brief Helper function. Checks (and compares) passed levels
+ *
+ * \param required_level level to compare
+ * \param allowed_level level to compare
+ *
+ * \return true, if required_level <= allowed_level
+ */
bool SatifiesPrivilegeLevel(PrivilegeLevel required_level,
PrivilegeLevel allowed_level);
+
+/**
+ * \brief translates privilege level to string
+ *
+ * \param level privilege level to translate
+ *
+ * \return translated level (to string)
+ */
const char* PrivilegeLevelToString(PrivilegeLevel level);
// TODO(p.sikorski@samsung.com) this class should be divided into:
// CtxUninstall class that inherits from Context
// It is because Uninstallation does not need so many fields.
// similarly, installation may not need some of them
+
+/**
+ * \brief Holds data generated/used by Steps (e.g. pkgid retrieved from
+ * manifest parsing, path to unzipped package).
+ * ContextInstaller is owned by AppInstaller object. Steps holds
+ * “pointers” to ContextInstaller (pointer is initialized in Step
+ * constructor).
+ */
class InstallerContext {
public:
+ /** Constructor */
InstallerContext();
+
+ /** Destructor */
~InstallerContext();
- // package_type
+ /**
+ * \brief package type (string representing name of backend)
+ */
Property<std::string> pkg_type;
- // manifest information used to generate xml file
+ /**
+ * \brief In-memory representation of platform xml manifest file
+ * - contains all information needed by tizen application
+ * framework to handle package management (pkgid, icon,
+ * applications, appcontrol, privileges and more)
+ */
Property<manifest_x*> manifest_data;
- // Pkgmgr-parser plugins data
+ /** Pkgmgr-parser plugins data */
Property<ExtraManifestData> manifest_plugins_data;
- // manifest information used to revert an update
+ /**
+ * \brief In-memory representation of platform xml manifest file
+ * - contains all already stored information needed by tizen
+ * application framework to handle package management (pkgid,
+ * icon, applications, appcontrol, privileges and more)
+ * - this field is set only for update installation
+ * (we need this information for rollback possibility)
+ */
Property<manifest_x*> old_manifest_data;
- // path to manifest xml file used to register data in databases
+ /**
+ * \brief path to xml platform manifest which was generated according
+ * to maniest_data content */
Property<boost::filesystem::path> xml_path;
- // path to old manifest xml while updating
+ /**
+ * \brief path to backup xml platform manifest which was generated
+ * according to old_maniest_data content (needed for rollback
+ * operations)
+ */
Property<boost::filesystem::path> backup_xml_path;
- // pkgid used for update or uninstallation processing
+ /**
+ * \brief path to final location of installed package in filesystem
+ */
Property<std::string> pkgid;
- // package directory path containing app data
+ /**
+ * \brief package directory path containing app data
+ */
Property<boost::filesystem::path> pkg_path;
- // file path used for installation or reinstallation process
+ /**
+ * \brief file path used for installation or reinstallation process
+ */
Property<boost::filesystem::path> file_path;
- // directory path where app data are temporarily extracted
+ /**
+ * \brief path to temporary directory when package files are unpacked
+ * before coping them to final destination
+ */
Property<boost::filesystem::path> unpacked_dir_path;
- // uid of the user that request the operation
+ /**
+ * \brief uid of user which installation was triggered for
+ * (any normal or globaltizenapp)
+ */
Property<uid_t> uid;
- // path for the applications root directory
+ /**
+ * \brief root directory of installation of all packages for user
+ * (/home/${USER}/apps_rw/) or tizenglobalapp user (/usr/apps/)
+ */
Property<boost::filesystem::path> root_application_path;
- // Backend specific data
+ /**
+ * \brief "void*-like" structure to store backend specific
+ * information about installation process
+ */
Property<BackendData*> backend_data;
- // request privilege level of package
+ /**
+ * \brief privilege/visibility level discovered from signature files
+ * - restricts package privileges
+ */
Property<PrivilegeLevel> privilege_level;
- // certificate information
+ /**
+ * \brief certificate information
+ */
Property<CertificateInfo> certificate_info;
- // information for recovery
+ /**
+ * \brief information for recovery
+ */
Property<RecoveryInfo> recovery_info;
- // user type of request (GLOBAL/USER)
+ /**
+ * \brief user type of request (GLOBAL/USER)
+ */
Property<RequestMode> request_mode;
};
class PkgMgrInterface;
typedef std::shared_ptr<PkgMgrInterface> PkgMgrPtr;
-/** Class that covers pkgmgr_installer basic platform calls.
- *
- * PkgMgr covers all pkgmgr_installer platform calls (and manages its
- * creation/destruction.
+/**
+ * \brief Encapsulates pkgmgr API which handles parsing backend options
+ * and returns values/modes for installation process.
*/
class PkgMgrInterface {
public:
- /** Returns Request type passed from pkgmgr_installer
+ /**
+ * Returns Request type passed from pkgmgr_installer
+ *
+ * \return request type retrieved from pkgmgr_installer
*/
RequestType GetRequestType() const;
- /** Returns Request info passed from pkgmgr_installer
+ /**
+ * Returns Request info passed from pkgmgr_installer
+ *
+ * \return request info retrieved from pkgmgr_installer
*/
const char *GetRequestInfo() const;
- /** Creates PkgMgrInterface.
+ /**
+ * Creates PkgMgrInterface
+ *
+ * \param argc main() argc argument passed to the backend
+ * \param argv main() argv argument passed to the backend
+ * \param interface pointer to AppQueryInterface
+ *
+ * \return Smart pointer to the PkgMgrInterface
*/
static PkgMgrPtr Create(int argc, char** argv,
AppQueryInterface* interface = nullptr);
- /** Get Raw pointer to pkgmgr_installer object
+ /**
+ * Get Raw pointer to pkgmgr_installer object
+ * NOTE: It should not be used (PkgMgrInterface can destroy it
*
- * It should not be used (PkgMgrInterface can destroy it
+ * \return raw pkgmgr_installer pointer
*/
DEPRECATED pkgmgr_installer *GetRawPi() const { return pi_; }
- /** PkgMgrInstance destructor.
- *
- */
+ /** PkgMgrInstance destructor. */
~PkgMgrInterface();
private:
explicit PkgMgrInterface(AppQueryInterface* interface)
: pi_(nullptr),
+ is_app_installed_(false),
query_interface_(interface) {}
int InitInternal(int argc, char** argv);
namespace common_installer {
+/**
+ * \brief Adapter interface for external PkgMgr module used for registering
+ * package into pkgmgr
+ *
+ * \param xml_path path to generated xml
+ * \param pkgid package pkgid
+ * \param uid user id
+ * \param request_mode current request mode
+ *
+ * \return true if success
+ */
bool RegisterAppInPkgmgr(const boost::filesystem::path& xml_path,
const std::string& pkgid,
const CertificateInfo& cert_info,
uid_t uid,
RequestMode request_mode);
+
+/**
+ * \brief Adapter interface for external PkgMgr module used for upgrading
+ * package within pkgmgr
+ *
+ * \param xml_path path to generated xml
+ * \param pkgid package pkgid
+ * \param cert_info certifciate info
+ * \param uid user id
+ * \param request_mode current request mode
+ *
+ * \return true if success
+ */
bool UpgradeAppInPkgmgr(const boost::filesystem::path& xml_path,
const std::string& pkgid,
const CertificateInfo& cert_info,
uid_t uid,
RequestMode request_mode);
+
+/**
+ * \brief Adapter interface for external PkgMgr module used for deregistering
+ * package into pkgmgr
+ *
+ * \param xml_path path to generated xml
+ * \param pkgid package pkgid
+ * \param uid user id
+ * \param request_mode current request mode
+ *
+ * \return true if success
+ */
bool UnregisterAppInPkgmgr(const boost::filesystem::path& xml_path,
const std::string& pkgid,
uid_t uid,
RequestMode request_mode);
+
+/**
+ * \brief Adapter interface for external PkgMgr module used for getting
+ * certificate information for given package
+ *
+ * \param pkgid package pkgid
+ * \param uid user id
+ *
+ * \return returns certificate information
+ */
std::string QueryCertificateAuthorCertificate(const std::string& pkgid,
uid_t uid);
+
+/**
+ * \brief Adapter interface for external PkgMgr module used for getting
+ * list of appids for given package
+ *
+ * \param pkg_id[in] package pkgid
+ * \param result[out] Output
+ * \param uid user id
+ *
+ * \return true if success
+ */
bool QueryAppidsForPkgId(const std::string& pkg_id,
std::vector<std::string>* result, uid_t uid);
+
+/**
+ * \brief Adapter interface for external PkgMgr module used for checking
+ * if given package is installed/registered
+ *
+ * \param pkg_id package id
+ * \param request_mode request mode
+ *
+ * \return true if package is installed
+ */
bool IsPackageInstalled(const std::string& pkg_id, RequestMode request_mode);
} // namespace common_installer
namespace common_installer {
-//
-// Utility for sending signal to pkgmgr
+/**
+ * \brief Adapter interface for pkgmgr for sending notification/progress
+ * to pkgmgr.
+ *
+ * Signals are sent using API defined and exposed by pkgmgr (external) module.
+ * Pkgmgr is notified about:
+ * * installation start,
+ * * installation result,
+ * * installation end,
+ * * installation progress.
+ */
class PkgmgrSignal {
public:
enum class State {
FINISHED
};
+ /**
+ * Constructor
+ *
+ * \param pi pointer for pkgmgr_installer structure
+ * \param req_type request type
+ */
explicit PkgmgrSignal(pkgmgr_installer* pi, RequestType req_type);
+ /**
+ * "start" Signal sending
+ *
+ * \param type package type
+ * \param pkgid package pkgid
+ *
+ * \return true if success
+ */
bool SendStarted(
const std::string& type = std::string(),
const std::string& pkgid = std::string());
+
+ /**
+ * "progress" Signal sending
+ *
+ * \param type package type
+ * \param pkgid package pkgid
+ *
+ * \return true if success
+ */
bool SendProgress(int progress,
const std::string& type = std::string(),
const std::string& pkgid = std::string());
+
+ /**
+ * "finished" Signal sending
+ *
+ * \param type package type
+ * \param pkgid package pkgid
+ *
+ * \return true if success
+ */
bool SendFinished(
Step::Status result,
const std::string& type = std::string(),
const std::string& pkgid = std::string());
bool IsFinished() const;
+ /**
+ * Getter of state of the object
+ *
+ *\return current state
+ */
State state() const { return state_; }
private:
namespace recovery {
+/**
+ * Responsible for managing recovery file.
+ *
+ * It dumps information to recover file regarding current status of handled
+ * request.
+ */
class RecoveryFile {
public:
+ /**
+ * Creates new RecoveryFile object for given file
+ *
+ * \param path path to the package/id
+ *
+ * \return new RecoveryFile object
+ */
static std::unique_ptr<RecoveryFile> CreateRecoveryFileForPath(
const boost::filesystem::path& path);
+
+ /**
+ * Opens RecoveryFile object for given request
+ *
+ * \param path path to the package/id
+ *
+ * \return new RecoveryFile object
+ */
static std::unique_ptr<RecoveryFile> OpenRecoveryFileForPath(
const boost::filesystem::path& path);
+
+ /** Desctructor */
~RecoveryFile();
+
+ /** Detaching object from given recovery file */
void Detach();
+
+ /**
+ * Checks if object is detached from file
+ *
+ * \return true if detached
+ *
+ */
bool is_detached() const;
+ /**
+ * setter for unpacked dir
+ *
+ * \param unpacked_dir new unpacked_dir value
+ */
void set_unpacked_dir(const boost::filesystem::path& unpacked_dir);
+
+ /**
+ * setter for pkgid
+ *
+ * \param pkgid new pkgid value
+ */
void set_pkgid(const std::string& pkgid);
+
+ /**
+ * setter for request type
+ *
+ * \param new request type value
+ */
void set_type(RequestType type);
+
+ /**
+ * getter for unpacked dir
+ *
+ * \return current unpacked_dir
+ */
const boost::filesystem::path& unpacked_dir() const;
+
+ /**
+ * getter for pkgid
+ *
+ * * \return current pkgid
+ */
const std::string& pkgid() const;
+
+ /**
+ * getter for request type
+ *
+ * \return current request type
+ */
RequestType type() const;
+ /**
+ * Transaction of current RecoveryFile content into recovery file
+ *
+ * \return true if success
+ */
bool WriteAndCommitFileContent();
private:
GLOBAL
};
-/** Get mode for current request (GLOBAL/USER) */
+/**
+ * Get mode for current request (GLOBAL/USER)
+ *
+ * \return request mode
+ */
RequestMode GetRequestMode();
-/** Get apps root path for current request (GLOBAL/USER) */
+/**
+ * Get apps root path for current request (GLOBAL/USER)
+ *
+ * \return root application path (eg. $HOME/apps_rw/)
+ */
const char *GetRootAppPath();
} // namespace common_installer
namespace common_installer {
+/**
+ * Adapter interface for external Security module.
+ *
+ * Adapter interface for external Security module used for registering
+ * application to security context
+ *
+ * \param pkg_id pkdid of given package
+ * \param path path of installed package
+ * \param manifest pointer to manifest structure
+ *
+ * \return true if success
+ */
bool RegisterSecurityContextForApps(const std::string& pkg_id,
const boost::filesystem::path& path, manifest_x* manifest);
+
+/**
+ * Adapter interface for external Security module.
+ *
+ * Adapter interface for external Security module used for unregistering
+ * application from security context
+ *
+ * \param pkg_id pkdid of given package
+ * \param manifest pointer to manifest structure
+ *
+ * \return true if success
+ */
bool UnregisterSecurityContextForApps(const std::string& pkg_id,
manifest_x* manifest);