int skip_optimization;
GDBusConnection *conn;
GHashTable *pkg_list;
+ GList *pkgs;
};
typedef struct pkg_signal_info {
return 0;
}
+static void __parse_multiple_pkgs(pkgmgr_installer *pi, int argc, char **argv)
+{
+ while ((optind <= argc) && (*argv[optind - 1] != '-')) {
+ pi->pkgs = g_list_append(pi->pkgs, strdup(argv[optind - 1]));
+ optind++;
+ }
+ optind--;
+}
+
API int
pkgmgr_installer_receive_request(pkgmgr_installer *pi,
const int argc, char **argv)
g_target_uid = pi->target_uid;
g_debug_mode = 0;
g_skip_optimization = 0;
+
+ if (pi->pkgs) {
+ g_list_free_full(pi->pkgs, free);
+ pi->pkgs = NULL;
+ }
+
while (1) {
c = getopt_long(argc, argv, short_opts, long_opts, &opt_idx);
/* printf("c=%d %c\n", c, c); //debug */
if (pi->pkgmgr_info)
free(pi->pkgmgr_info);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
DBG("legacy extimg migration requested");
break;
case OPTVAL_SKIP_CHECK_REFERENCE:
case OPTVAL_RECOVER_DB:
pi->request_type = PKGMGR_REQ_RECOVER_DB;
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
case 'k': /* session id */
if (pi->session_id)
if (pi->pkgmgr_info)
free(pi->pkgmgr_info);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
DBG("option is [i] pkgid[%s]", pi->pkgmgr_info);
if (pi->pkgmgr_info && strlen(pi->pkgmgr_info) == 0) {
free(pi->pkgmgr_info);
if (pi->pkgmgr_info)
free(pi->pkgmgr_info);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
if (pi->pkgmgr_info)
free(pi->pkgmgr_info);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
case 'm': /* move */
if (pi->pkgmgr_info)
free(pi->pkgmgr_info);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
case 'r': /* reinstall */
if (pi->pkgmgr_info)
free(pi->pkgmgr_info);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
case 't': /* move type*/
if (pi->pkgmgr_info)
free(pi->pkgmgr_info);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
case 'o': /* optional data*/
mode = 'y';
pi->request_type = PKGMGR_REQ_MANIFEST_DIRECT_INSTALL;
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
case 'w': /* pkgid for mount installation */
mode = 'w';
pi->request_type = PKGMGR_REQ_MOUNT_INSTALL;
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
case 'b': /* recovery */
if (pi->pkgmgr_info)
free(pi->pkgmgr_info);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
case 'D': /* disable pkg */
if (pi->pkgmgr_info)
free(pi->pkgmgr_info);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
case 'A': /* enable pkg */
if (pi->pkgmgr_info)
free(pi->pkgmgr_info);
pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ __parse_multiple_pkgs(pi, argc, argv);
break;
case 'u': /* uid */
return pi->pkgmgr_info;
}
+API const char *pkgmgr_installer_get_request_info_at(pkgmgr_installer *pi,
+ int at)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return (const char *)g_list_nth_data(pi->pkgs, at);
+}
+
+API int pkgmgr_installer_get_request_info_count(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return g_list_length(pi->pkgs);
+}
+
API const char *pkgmgr_installer_get_tep_path(pkgmgr_installer *pi)
{
CHK_PI_RET(PKGMGR_REQ_INVALID);
*/
const char *pkgmgr_installer_get_request_info(pkgmgr_installer *pi);
+/**
+ @brief Get request info at specific position
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @see pkgmgr_installer_get_request_info_count
+ @param[in] pi pkgmgr_installer object
+ @return Request info. When PKGMGR_REQ_INSTALL, this is a package file path to be installed. When PKGMGR_REQ_UNINSTALL, this is a package name to be uninstalled.
+ @retval NULL on function failure
+ @remark Returned string must not be modified.
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+ char *req_info = NULL;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ req_info = (char *) pkgmgr_installer_get_request_info_at(pi, 1);
+
+ // Do something...
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+ @endcode
+ */
+const char *pkgmgr_installer_get_request_info_at(pkgmgr_installer *pi,
+ int at);
+
+/**
+ @brief Get the number of request info
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return The number of request info.
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+ int n;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ n = pkgmgr_installer_get_request_info_count(pi);
+
+ // Do something...
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+ @endcode
+ */
+int pkgmgr_installer_get_request_info_count(pkgmgr_installer *pi);
+
/**
@brief Get TEP path
@pre pkgmgr_installer_receive_request() must be called.