4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
33 #include <libxml/parser.h>
34 #include <libxml/xmlreader.h>
35 #include <libxml/xmlschemas.h>
39 #include "pkgmgr_parser_plugin.h"
40 #include "pkgmgr-info.h"
41 #include "pkgmgrinfo_debug.h"
46 #define LOG_TAG "PKGMGR_PLUGIN"
48 #define ASCII(s) (const char *)s
49 #define XMLCHAR(s) (const xmlChar *)s
51 #define PLLUGIN_LIST "/usr/etc/package-manager/parserlib/pkgmgr_parser_plugin_list.txt"
53 #define TOKEN_TYPE_STR "type="
54 #define TOKEN_NAME_STR "name="
55 #define TOKEN_FLAG_STR "flag="
56 #define TOKEN_PATH_STR "path="
58 #define SEPERATOR_START '"'
59 #define SEPERATOR_END '"'
61 #define PKG_PARSER_CONF_PATH "/usr/etc/package-manager/parser_path.conf"
62 #define TAG_PARSER_NAME "parserlib:"
64 typedef struct pkgmgr_parser_plugin_info_x {
76 } pkgmgr_parser_plugin_info_x;
78 #define E_PKGMGR_PARSER_PLUGIN_MAX 0xFFFFFFFF
80 #define QUERY_CREATE_TABLE_PACKAGE_PLUGIN_INFO "create table if not exists package_plugin_info " \
81 "(pkgid text primary key not null, " \
82 "enabled_plugin INTEGER DEFAULT 0)"
85 #define PKGMGR_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
86 sqlite3 *pkgmgr_parser_db;
97 static void __str_trim(char *input)
99 char *trim_str = input;
104 while (*input != 0) {
105 if (!isspace(*input)) {
116 static char *__get_parser_plugin_path(const char *type, char *plugin_name)
119 char buffer[1024] = { 0 };
120 char temp_path[1024] = { 0 };
124 _LOGE("invalid argument\n");
128 fp = fopen(PKG_PARSER_CONF_PATH, "r");
130 _LOGE("no matching backendlib\n");
134 while (fgets(buffer, sizeof(buffer), fp) != NULL) {
135 if (buffer[0] == '#')
140 if ((path = strstr(buffer, plugin_name)) != NULL) {
141 path = path + strlen(plugin_name);
145 memset(buffer, 0x00, 1024);
152 _LOGE("no matching backendlib\n");
156 snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
158 return strdup(temp_path);
161 static void __metadata_parser_clear_dir_list(GList* dir_list)
164 __metadata_t* detail = NULL;
167 list = g_list_first(dir_list);
169 detail = (__metadata_t *)list->data;
171 FREE_AND_NULL(detail->key);
172 FREE_AND_NULL(detail->value);
173 FREE_AND_NULL(detail);
175 list = g_list_next(list);
177 g_list_free(dir_list);
181 static void __category_parser_clear_dir_list(GList* dir_list)
184 __category_t* detail = NULL;
187 list = g_list_first(dir_list);
189 detail = (__category_t *)list->data;
191 FREE_AND_NULL(detail->name);
192 FREE_AND_NULL(detail);
194 list = g_list_next(list);
196 g_list_free(dir_list);
200 static int __parser_send_tag(void *lib_handle, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
203 int (*plugin_install) (const char *);
206 if (process == PLUGIN_PRE_PROCESS) {
209 ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
212 ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
214 case ACTION_UNINSTALL:
215 ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
218 _LOGE("PRE_PROCESS : action type error[%d]\n", action);
221 } else if (process == PLUGIN_POST_PROCESS) {
224 ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
227 ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
229 case ACTION_UNINSTALL:
230 ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
233 _LOGE("POST_PROCESS : action type error[%d]\n", action);
237 _LOGE("process type error[%d]\n", process);
241 if ((plugin_install = dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
245 ret = plugin_install(pkgid);
249 int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
250 ACTION_TYPE action, const char *pkgid)
252 char *lib_path = NULL;
253 void *lib_handle = NULL;
254 int (*plugin_install) (xmlDocPtr, const char *);
260 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
263 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
265 case ACTION_UNINSTALL:
266 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
272 lib_path = __get_parser_plugin_path(tag, TAG_PARSER_NAME);
278 if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
279 _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
282 if ((plugin_install =
283 dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
284 _LOGE("can not find symbol[%s] \n", ac);
288 ret = plugin_install(docPtr, pkgid);
290 _LOGD("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path);
292 _LOGD("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path);
295 FREE_AND_NULL(lib_path);
301 static int __ps_get_enabled_plugin(const char *pkgid)
304 sqlite3_stmt *stmt = NULL;
305 const char *tail = NULL;
307 int enabled_plugin = 0;
309 query = sqlite3_mprintf("select * from package_plugin_info where pkgid LIKE %Q", pkgid);
311 if (SQLITE_OK != sqlite3_prepare(pkgmgr_parser_db, query, strlen(query), &stmt, &tail)) {
312 _LOGE("sqlite3_prepare error\n");
314 return E_PKGMGR_PARSER_PLUGIN_MAX;
317 rc = sqlite3_step(stmt);
318 if (rc != SQLITE_ROW || rc == SQLITE_DONE) {
319 _LOGE("No records found");
323 enabled_plugin = (int)sqlite3_column_int(stmt, 1);
325 // _LOGD("enabled_plugin ===> %d", enabled_plugin);
327 if (SQLITE_OK != sqlite3_finalize(stmt)) {
328 _LOGE("error : sqlite3_finalize\n");
333 return enabled_plugin;
336 rc = sqlite3_finalize(stmt);
337 if (rc != SQLITE_OK) {
338 _LOGE(" sqlite3_finalize failed - %d", rc);
341 return E_PKGMGR_PARSER_PLUGIN_MAX;
344 static char *__getvalue(const char* pBuf, const char* pKey)
346 const char* p = NULL;
347 const char* pStart = NULL;
348 const char* pEnd = NULL;
350 p = strstr(pBuf, pKey);
354 pStart = p + strlen(pKey) + 1;
355 pEnd = strchr(pStart, SEPERATOR_END);
359 size_t len = pEnd - pStart;
363 char *pRes = (char*)malloc(len + 1);
367 strncpy(pRes, pStart, len);
373 static int __get_plugin_info_x(const char*buf, pkgmgr_parser_plugin_info_x *plugin_info)
378 if (strstr(buf, TOKEN_TYPE_STR) == NULL)
381 plugin_info->type = __getvalue(buf, TOKEN_TYPE_STR);
382 if (plugin_info->type == NULL)
385 plugin_info->name = __getvalue(buf, TOKEN_NAME_STR);
386 plugin_info->flag = __getvalue(buf, TOKEN_FLAG_STR);
387 plugin_info->path = __getvalue(buf, TOKEN_PATH_STR);
392 void __clean_plugin_info(pkgmgr_parser_plugin_info_x *plugin_info)
394 if(plugin_info == NULL)
397 FREE_AND_NULL(plugin_info->filename);
398 FREE_AND_NULL(plugin_info->pkgid);
399 FREE_AND_NULL(plugin_info->appid);
400 FREE_AND_NULL(plugin_info);
404 static void __check_enabled_plugin(pkgmgr_parser_plugin_info_x *plugin_info)
406 int enabled_plugin = 0x0000001;
408 enabled_plugin = (int)strtol( plugin_info->flag, NULL, 16 );
410 _LOGD( "[%s] flag = 0x%x done[action=%d]!! \n", plugin_info->pkgid, enabled_plugin, plugin_info->action);
412 plugin_info->enabled_plugin = plugin_info->enabled_plugin | enabled_plugin;
415 static void __run_metadata_parser(pkgmgr_parser_plugin_info_x *plugin_info, GList *md_list, const char *appid)
417 int (*metadata_parser_plugin) (const char *, const char *, GList *);
421 switch (plugin_info->action) {
423 ac = "PKGMGR_MDPARSER_PLUGIN_INSTALL";
426 ac = "PKGMGR_MDPARSER_PLUGIN_UPGRADE";
428 case ACTION_UNINSTALL:
429 ac = "PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
435 if ((metadata_parser_plugin =
436 dlsym(plugin_info->lib_handle, ac)) == NULL || dlerror() != NULL) {
437 _LOGE("can not find symbol[%s] \n",ac);
441 ret = metadata_parser_plugin(plugin_info->pkgid, appid, md_list);
442 _LOGD("Plugin = %s, appid = %s, result=%d\n", plugin_info->name, appid, ret);
444 __check_enabled_plugin(plugin_info);
450 static void __run_category_parser(pkgmgr_parser_plugin_info_x *plugin_info, GList *category_list, const char *appid)
452 int (*category_parser_plugin) (const char *, const char *, GList *);
456 switch (plugin_info->action) {
458 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL";
461 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE";
463 case ACTION_UNINSTALL:
464 ac = "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL";
470 if ((category_parser_plugin =
471 dlsym(plugin_info->lib_handle, ac)) == NULL || dlerror() != NULL) {
472 _LOGE("can not find symbol[%s] \n",ac);
476 ret = category_parser_plugin(plugin_info->pkgid, appid, category_list);
477 _LOGD("Plugin = %s, appid = %s, result=%d\n", plugin_info->name, appid, ret);
479 __check_enabled_plugin(plugin_info);
486 static void __run_tag_parser(pkgmgr_parser_plugin_info_x *plugin_info, xmlDocPtr docPtr)
488 int (*plugin_install) (xmlDocPtr, const char *);
492 switch (plugin_info->action) {
494 ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
497 ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
499 case ACTION_UNINSTALL:
500 ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
506 if ((plugin_install =
507 dlsym(plugin_info->lib_handle, ac)) == NULL || dlerror() != NULL) {
508 _LOGE("can not find symbol[%s] \n", ac);
512 ret = plugin_install(docPtr, plugin_info->pkgid);
513 _LOGD("Plugin = %s, appid = %s, result=%d\n", plugin_info->name, plugin_info->pkgid, ret);
515 __check_enabled_plugin(plugin_info);
520 static int __run_tag_parser_prestep(pkgmgr_parser_plugin_info_x *plugin_info, xmlTextReaderPtr reader)
524 if (xmlTextReaderDepth(reader) != 1) {
525 _LOGE("Node depth is not 1");
529 if (xmlTextReaderNodeType(reader) != 1) {
530 _LOGE("Node type is not 1");
534 const xmlChar *value;
535 name = xmlTextReaderConstName(reader);
537 _LOGE("TEST TEST TES\n");
538 name = BAD_CAST "--";
541 value = xmlTextReaderConstValue(reader);
543 if (xmlStrlen(value) > 40) {
544 _LOGD(" %.40s...", value);
550 name = xmlTextReaderConstName(reader);
552 _LOGE("TEST TEST TES\n");
553 name = BAD_CAST "--";
556 xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
557 xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
558 if (copyDocPtr == NULL)
560 xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
561 if (rootElement == NULL)
563 xmlNode *cur_node = xmlFirstElementChild(rootElement);
564 if (cur_node == NULL)
566 xmlNode *temp = xmlTextReaderExpand(reader);
569 xmlNode *next_node = NULL;
570 while(cur_node != NULL) {
571 if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
572 (temp->line == cur_node->line) ) {
576 next_node = xmlNextElementSibling(cur_node);
577 xmlUnlinkNode(cur_node);
578 xmlFreeNode(cur_node);
579 cur_node = next_node;
582 if (cur_node == NULL)
584 next_node = xmlNextElementSibling(cur_node);
586 cur_node->next = NULL;
587 next_node->prev = NULL;
588 xmlFreeNodeList(next_node);
589 xmlSetTreeDoc(cur_node, copyDocPtr);
591 xmlSetTreeDoc(cur_node, copyDocPtr);
594 __run_tag_parser(plugin_info, copyDocPtr);
601 __process_tag_xml(pkgmgr_parser_plugin_info_x *plugin_info, xmlTextReaderPtr reader)
603 switch (xmlTextReaderNodeType(reader)) {
604 case XML_READER_TYPE_END_ELEMENT:
608 case XML_READER_TYPE_ELEMENT:
610 // Elements without closing tag don't receive
611 const xmlChar *elementName =
612 xmlTextReaderLocalName(reader);
613 if (elementName == NULL) {
617 if (strcmp(plugin_info->name, ASCII(elementName)) == 0) {
618 __run_tag_parser_prestep(plugin_info, reader);
620 if(elementName != NULL){
621 xmlFree((void*)elementName);
632 static void __process_tag_parser(pkgmgr_parser_plugin_info_x *plugin_info)
634 xmlTextReaderPtr reader;
635 xmlDocPtr docPtr = NULL;
638 if (access(plugin_info->filename, R_OK) != 0) {
639 __run_tag_parser(plugin_info, NULL);
641 docPtr = xmlReadFile(plugin_info->filename, NULL, 0);
642 reader = xmlReaderWalker(docPtr);
643 if (reader != NULL) {
644 ret = xmlTextReaderRead(reader);
646 __process_tag_xml(plugin_info, reader);
647 ret = xmlTextReaderRead(reader);
649 xmlFreeTextReader(reader);
652 _LOGS("%s : failed to parse", plugin_info->filename);
655 _LOGS("%s : failed to read", plugin_info->filename);
665 static void __process_category_parser(pkgmgr_parser_plugin_info_x *plugin_info)
668 char buffer[1024] = { 0, };
669 category_x *category = NULL;
670 GList *category_list = NULL;
671 __category_t *category_detail = NULL;
673 if (plugin_info->mfx == NULL) {
674 __run_category_parser(plugin_info, NULL, plugin_info->appid);
678 uiapplication_x *up = plugin_info->mfx->uiapplication;
681 category = up->category;
682 while (category != NULL)
684 //get glist of category key and value combination
685 memset(buffer, 0x00, 1024);
686 snprintf(buffer, 1024, "%s/", plugin_info->name);
687 if ((category->name) && (strncmp(category->name, plugin_info->name, strlen(plugin_info->name)) == 0)) {
688 category_detail = (__category_t*) calloc(1, sizeof(__category_t));
689 if (category_detail == NULL) {
690 _LOGD("Memory allocation failed\n");
694 category_detail->name = (char*) calloc(1, sizeof(char)*(strlen(category->name)+2));
695 if (category_detail->name == NULL) {
696 _LOGD("Memory allocation failed\n");
697 FREE_AND_NULL(category_detail);
700 snprintf(category_detail->name, (strlen(category->name)+1), "%s", category->name);
702 category_list = g_list_append(category_list, (gpointer)category_detail);
705 category = category->next;
708 //send glist to parser when tags for metadata plugin parser exist.
710 __run_category_parser(plugin_info, category_list, up->appid);
713 __category_parser_clear_dir_list(category_list);
714 category_list = NULL;
720 __category_parser_clear_dir_list(category_list);
725 static void __process_metadata_parser(pkgmgr_parser_plugin_info_x *plugin_info)
728 char buffer[1024] = { 0, };
729 metadata_x *md = NULL;
730 GList *md_list = NULL;
731 __metadata_t *md_detail = NULL;
733 if (plugin_info->mfx == NULL) {
734 __run_metadata_parser(plugin_info, NULL, plugin_info->appid);
738 uiapplication_x *up = plugin_info->mfx->uiapplication;
744 //get glist of metadata key and value combination
745 memset(buffer, 0x00, 1024);
746 snprintf(buffer, 1024, "%s/", plugin_info->name);
747 if ((md->key && md->value) && (strncmp(md->key, plugin_info->name, strlen(plugin_info->name)) == 0)) {
748 md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
749 if (md_detail == NULL) {
750 _LOGD("Memory allocation failed\n");
754 md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
755 if (md_detail->key == NULL) {
756 _LOGD("Memory allocation failed\n");
757 FREE_AND_NULL(md_detail);
760 snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
762 md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
763 if (md_detail->value == NULL) {
764 _LOGD("Memory allocation failed\n");
765 FREE_AND_NULL(md_detail->key);
766 FREE_AND_NULL(md_detail);
769 snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
771 md_list = g_list_append(md_list, (gpointer)md_detail);
777 //send glist to parser when tags for metadata plugin parser exist.
779 __run_metadata_parser(plugin_info, md_list, up->appid);
782 __metadata_parser_clear_dir_list(md_list);
790 __metadata_parser_clear_dir_list(md_list);
794 void __process_plugin_db(pkgmgr_parser_plugin_info_x *plugin_info)
797 char *error_message = NULL;
799 query = sqlite3_mprintf("delete from package_plugin_info where pkgid LIKE %Q", plugin_info->pkgid);
800 if (SQLITE_OK == sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
801 _LOGS("pkgid [%s] plugin[0x%x] deleted", plugin_info->pkgid, plugin_info->enabled_plugin);
806 if (plugin_info->action == ACTION_UNINSTALL)
809 query = sqlite3_mprintf("insert into package_plugin_info(pkgid,enabled_plugin) values (%Q,'%d')", plugin_info->pkgid, plugin_info->enabled_plugin);
810 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
811 _LOGE("Don't execute query = %s, error message = %s\n", query, error_message);
817 _LOGS("pkgid [%s] plugin[0x%x] inserted", plugin_info->pkgid, plugin_info->enabled_plugin);
822 static void __process_each_plugin(pkgmgr_parser_plugin_info_x *plugin_info)
826 plugin_info->lib_handle = dlopen(plugin_info->path, RTLD_LAZY);
827 retm_if(plugin_info->lib_handle == NULL, "dlopen is failed lib_path");
829 ret = __parser_send_tag(plugin_info->lib_handle, plugin_info->action, PLUGIN_PRE_PROCESS, plugin_info->pkgid);
830 _LOGS("PLUGIN_PRE_PROCESS : [%s] result=[%d]\n", plugin_info->name, ret);
832 if (strcmp(plugin_info->type,PKGMGR_PARSER_PLUGIN_TAG) == 0) {
833 __process_tag_parser(plugin_info);
834 } else if (strcmp(plugin_info->type,PKGMGR_PARSER_PLUGIN_METADATA) == 0) {
835 __process_metadata_parser(plugin_info);
836 } else if (strcmp(plugin_info->type,PKGMGR_PARSER_PLUGIN_CATEGORY) == 0) {
837 __process_category_parser(plugin_info);
840 ret =__parser_send_tag(plugin_info->lib_handle, plugin_info->action, PLUGIN_POST_PROCESS, plugin_info->pkgid);
841 _LOGS("PLUGIN_POST_PROCESS : [%s] result=[%d]\n", plugin_info->name, ret);
843 dlclose(plugin_info->lib_handle);
846 void __process_all_plugins(pkgmgr_parser_plugin_info_x *plugin_info)
850 char buf[PKG_STRING_LEN_MAX] = {0};
852 fp = fopen(PLLUGIN_LIST, "r");
853 retm_if(fp == NULL, "Fail get : %s", PLLUGIN_LIST);
855 while (fgets(buf, PKG_STRING_LEN_MAX, fp) != NULL) {
858 ret = __get_plugin_info_x(buf, plugin_info);
862 __process_each_plugin(plugin_info);
864 memset(buf, 0x00, PKG_STRING_LEN_MAX);
865 FREE_AND_NULL(plugin_info->type);
866 FREE_AND_NULL(plugin_info->name);
867 FREE_AND_NULL(plugin_info->flag);
868 FREE_AND_NULL(plugin_info->path);
878 int _pkgmgr_parser_plugin_open_db()
880 char *error_message = NULL;
884 fp = fopen(PKGMGR_PARSER_DB_FILE, "r");
887 ret = db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db, DB_UTIL_REGISTER_HOOK_METHOD);
888 if (ret != SQLITE_OK) {
889 _LOGE("package info DB initialization failed\n");
895 ret = db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db, DB_UTIL_REGISTER_HOOK_METHOD);
896 if (ret != SQLITE_OK) {
897 _LOGE("package info DB initialization failed\n");
901 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_PLUGIN_INFO, NULL, NULL, &error_message)) {
902 _LOGE("Don't execute query = %s, error message = %s\n", QUERY_CREATE_TABLE_PACKAGE_PLUGIN_INFO, error_message);
906 _LOGE("db_initialize_done\n");
911 void _pkgmgr_parser_plugin_close_db()
913 sqlite3_close(pkgmgr_parser_db);
916 void _pkgmgr_parser_plugin_process_plugin(manifest_x *mfx, const char *filename, ACTION_TYPE action)
920 pkgmgr_parser_plugin_info_x *plugin_info = NULL;
922 retm_if(mfx == NULL, "manifest pointer is NULL\n");
923 retm_if(filename == NULL, "filename pointer is NULL\n");
925 /*initialize plugin_info_x*/
926 plugin_info = malloc(sizeof(pkgmgr_parser_plugin_info_x));
927 retm_if(plugin_info == NULL, "malloc fail");
929 memset(plugin_info, '\0', sizeof(pkgmgr_parser_plugin_info_x));
931 /*initialize pkgmgr_paser db*/
932 ret = _pkgmgr_parser_plugin_open_db();
934 _LOGE("_pkgmgr_parser_plugin_open_db failed\n");
936 /*save plugin_info_x*/
937 plugin_info->mfx = mfx;
938 plugin_info->pkgid = strdup(mfx->package);
939 plugin_info->filename = strdup(filename);
940 plugin_info->action = action;
942 /*get plugin list from list-file, and process each plugin*/
943 __process_all_plugins(plugin_info);
945 /*update finished info to pkgmgr_parser db*/
946 __process_plugin_db(plugin_info);
948 /*close pkgmgr_paser db*/
949 _pkgmgr_parser_plugin_close_db();
951 /*clean plugin_info_x*/
952 __clean_plugin_info(plugin_info);
955 void _pkgmgr_parser_plugin_uninstall_plugin(const char *plugin_type, const char *pkgid, const char *appid)
959 char buf[PKG_STRING_LEN_MAX] = {0};
962 int enabled_plugin = 0;
963 pkgmgr_parser_plugin_info_x *plugin_info = NULL;
965 retm_if(plugin_type == NULL, "plugin_type is null");
966 retm_if(pkgid == NULL, "pkgid is null");
967 retm_if(appid == NULL, "appid is null");
969 /*initialize plugin_info_x*/
970 plugin_info = malloc(sizeof(pkgmgr_parser_plugin_info_x));
971 retm_if(plugin_info == NULL, "malloc fail");
973 memset(plugin_info, '\0', sizeof(pkgmgr_parser_plugin_info_x));
975 /*save plugin_info_x*/
976 enabled_plugin = __ps_get_enabled_plugin(pkgid);
977 plugin_info->pkgid = strdup(pkgid);
978 plugin_info->appid = strdup(appid);
979 plugin_info->action = ACTION_UNINSTALL;
981 /*get plugin list from list-file*/
982 fp = fopen(PLLUGIN_LIST, "r");
985 _LOGE("Fail get : %s", PLLUGIN_LIST);
986 __clean_plugin_info(plugin_info);
990 while (fgets(buf, PKG_STRING_LEN_MAX, fp) != NULL) {
993 ret = __get_plugin_info_x(buf, plugin_info);
997 /*process uninstallation for given plugin type*/
998 if (strcmp(plugin_info->type, plugin_type) == 0) {
1000 plugin_flag = (int)strtol(plugin_info->flag, NULL, 16);
1002 /*if there is a plugin that is saved in db, it need to uninstall*/
1003 if (enabled_plugin & plugin_flag) {
1004 __process_each_plugin(plugin_info);
1008 memset(buf, 0x00, PKG_STRING_LEN_MAX);
1009 FREE_AND_NULL(plugin_info->type);
1010 FREE_AND_NULL(plugin_info->name);
1011 FREE_AND_NULL(plugin_info->flag);
1012 FREE_AND_NULL(plugin_info->path);
1018 /*clean plugin_info_x*/
1019 __clean_plugin_info(plugin_info);