fix installer args bug for -r option, add metadata filter pkgcmd for testing
authorjunsuk77.oh <junsuk77.oh@samsung.com>
Mon, 1 Apr 2013 09:22:06 +0000 (18:22 +0900)
committerjunsuk77.oh <junsuk77.oh@samsung.com>
Mon, 1 Apr 2013 09:22:51 +0000 (18:22 +0900)
Change-Id: I8ef01c1e05ad3f33f06ba48d66f3a6c690c0f2e7
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
comm/pkgmgr_installer_config.h
packaging/pkgmgr.spec
tool/pkg_info.c

index 2b82ad3..aee7291 100755 (executable)
@@ -32,7 +32,7 @@ extern "C" {
 #endif
 
 /* Supported options */
-const char *short_opts = "k:l:i:d:c:m:t:o:rq";
+const char *short_opts = "k:l:i:d:c:m:t:o:r:q";
 const struct option long_opts[] = {
        { "session-id", 1, NULL, 'k' },
        { "license-path", 1, NULL, 'l' },
index f421208..43b082c 100755 (executable)
@@ -1,8 +1,8 @@
 #sbs-git:slp/pkgs/s/slp-pkgmgr pkgmgr 0.1.103 29b53909a5d6e8728429f0a188177eac691cb6ce
 Name:       pkgmgr
 Summary:    Packager Manager client library package
-Version:    0.2.66
-Release:    2
+Version:    0.2.68
+Release:    1
 Group:      System/Libraries
 License:    Apache License, Version 2.0
 Source0:    %{name}-%{version}.tar.gz
index 3e8cad3..b468619 100755 (executable)
@@ -133,12 +133,69 @@ static void __print_usage()
        printf("\tpkginfo --app-flt\n\n");
        printf("To add package filter values [Multiple values can be added]\n");
        printf("\tpkginfo --pkg-flt\n\n");
+       printf("To add metadata filter values\n");
+       printf("\tpkginfo --metadata-flt\n\n");
        printf("To get guest mode visibility of a particular application\n");
        printf("\tpkginfo --getvisibility <appid>\n\n");
        printf("To set guest mode visibility of a particular application\n");
        printf("\tpkginfo --setvisibility <appid>\n\n");
 }
 
+static int __app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+       char *appid = NULL;
+       pkgmgrinfo_appinfo_get_appid(handle, &appid);
+       printf("appid : %s\n", appid);
+       return 0;
+}
+
+static int __add_metadata_filter()
+{
+       int ret = 0;
+       pkgmgrinfo_appinfo_metadata_filter_h handle;
+       char *key = NULL;
+       char *value = NULL;
+
+       ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
+       if (ret != PMINFO_R_OK){
+               printf("pkgmgrinfo_appinfo_metadata_filter_create() failed\n");
+               return ret;
+       }
+
+       printf("enter metadata - key\n");
+       key = __get_string_input_data();
+       printf("enter metadata - value\n");
+       value = __get_string_input_data();
+       if(strlen(value) == 0)
+               value = NULL;
+
+       printf("filter condition : key=[%s], value=[%s]\n", key, value);
+
+       ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, key, value);
+       if (ret != PMINFO_R_OK){
+               printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
+               goto err;
+       }
+
+       ret = pkgmgrinfo_appinfo_metadata_filter_foreach(handle, __app_list_cb, NULL);
+       if (ret != PMINFO_R_OK){
+               printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
+               goto err;
+       }
+
+err:
+       pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
+       if (key) {
+               free(key);
+               key = NULL;
+       }
+       if (value) {
+               free(value);
+               value = NULL;
+       }
+       return ret;
+}
+
 static int __add_app_filter()
 {
        int ret = 0;
@@ -1831,6 +1888,14 @@ int main(int argc, char *argv[])
                        } else {
                                goto end;
                        }
+               } else if (strcmp(argv[1], "--metadata-flt") == 0) {
+                       ret = __add_metadata_filter();
+                       if (ret == -1) {
+                               printf("Adding pkg filter failed\n");
+                               goto end;
+                       } else {
+                               goto end;
+                       }
                } else if (strcmp(argv[1], "--listapp") == 0) {
                        ret = __get_installed_app_list();
                        if (ret == -1) {