sensor: re-sample pressure data and perform lazy insertions to reduce DB overhead
[platform/core/context/context-provider.git] / src / sensor / UninstallMonitor.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "ClientInfo.h"
18 #include "UninstallMonitor.h"
19
20 using namespace ctx;
21
22 UninstallMonitor::UninstallMonitor() :
23         __dbusSignalId(-1),
24         __dbusWatcher(DBusType::SYSTEM)
25 {
26         __dbusSignalId = __dbusWatcher.watch(NULL,
27                         "/org/tizen/pkgmgr_status", "org.tizen.pkgmgr_status", "status", this);
28 }
29
30 UninstallMonitor::~UninstallMonitor()
31 {
32         if (__dbusSignalId > 0)
33                 __dbusWatcher.unwatch(__dbusSignalId);
34 }
35
36 void UninstallMonitor::onSignal(const char *sender, const char *path, const char *iface, const char *name, GVariant *param)
37 {
38         const gchar *reqId = NULL;
39         const gchar *pkgType = NULL;
40         const gchar *pkgId = NULL;
41         const gchar *key = NULL;
42         const gchar *val = NULL;
43
44         g_variant_get(param, "(&s&s&s&s&s)", &reqId, &pkgType, &pkgId, &key, &val);
45         _D("%s, %s, %s", pkgId, key, val);
46
47         IF_FAIL_VOID_TAG(pkgId && key && val, _E, "Invalid parameter");
48
49         if (STR_EQ(key, "start")) {
50                 if (STR_EQ(val, "uninstall")) {
51                         __pkgId = pkgId;
52                 } else {
53                         __pkgId.clear();
54                 }
55                 return;
56         }
57
58         if (__pkgId.empty() || !STR_EQ(key, "end") || !STR_EQ(val, "ok"))
59                 return;
60
61         _I("'%s' has been removed", __pkgId.c_str());
62
63         ClientInfo::purgeClient(__pkgId);
64
65         __pkgId.clear();
66 }