Fix static analysis issue
[platform/core/appfw/wgt-backend.git] / src / hybrid / step / configuration / step_merge_tpk_config.cc
1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
4
5 #include "hybrid/step/configuration/step_merge_tpk_config.h"
6
7 #include <glib.h>
8 #include <string.h>
9
10 #include <pkgmgrinfo_basic.h>
11
12 #include "common/utils/glist_range.h"
13
14 #include "hybrid/hybrid_backend_data.h"
15
16 namespace hybrid {
17 namespace configuration {
18
19 common_installer::Step::Status StepMergeTpkConfig::process() {
20   HybridBackendData* data =
21       static_cast<HybridBackendData*>(context_->backend_data.get());
22   manifest_x* tpk_data = data->tpk_manifest_data.get();
23   manifest_x* wgt_data = context_->manifest_data.get();
24   // FIXME:api-version of tpk app will have wgt's if modified manifest exists.
25   GList* tpk_list = tpk_data->application;
26   while (tpk_list != nullptr) {
27     GList *next_list = g_list_next(tpk_list);
28     application_x* tpk_app = static_cast<application_x*>(tpk_list->data);
29     bool is_found = false;
30     for (GList* wgt_list = wgt_data->application;
31         wgt_list != nullptr; wgt_list = g_list_next(wgt_list)) {
32       application_x* wgt_app = static_cast<application_x*>(wgt_list->data);
33       if (!strcmp(tpk_app->appid, wgt_app->appid)) {
34         is_found = true;
35         break;
36       }
37     }
38     if (is_found) {
39       tpk_list = next_list;
40       continue;
41     }
42     wgt_data->application = g_list_append(
43         wgt_data->application, tpk_list->data);
44     tpk_data->application = g_list_delete_link(
45         tpk_data->application, tpk_list);
46
47     tpk_list = next_list;
48   }
49
50   return Status::OK;
51 }
52
53 }  // namespace configuration
54 }  // namespace hybrid