2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "feature_logic.h"
21 #include <dpl/assert.h>
22 #include <dpl/noncopyable.h>
23 #include <dpl/string.h>
24 #include <dpl/foreach.h>
25 #include <dpl/log/log.h>
26 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
27 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
30 namespace WidgetInstall {
32 FeatureLogic::FeatureLogic(const WrtDB::WidgetPkgName & pkgname)
35 WrtDB::WidgetDAOReadOnly widgetDao(pkgname);
36 WidgetFeatureSet featureSet = widgetDao.getFeaturesList();
37 FOREACH(it, featureSet) {
38 LogInfo("Feature name : " << it->name);
39 WrtDB::DeviceCapabilitySet dcs =
40 WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name);
41 FOREACH (devCap, dcs) {
42 LogInfo("--- dev cap : " << *devCap);
44 Feature feature(*it, dcs);
45 m_featureList.push_back(feature);
47 m_currentFeature = m_featureList.begin();
49 // ok we must set iterator on the first processable node
50 if (!isProcessable()) {
55 bool FeatureLogic::isDone() const
57 return m_currentFeature == m_featureList.end();
60 bool FeatureLogic::next()
63 if (m_currentFeature->currentCap != m_currentFeature->devCapSet.end()) {
64 m_currentFeature->currentCap++;
69 if (isProcessable()) {
77 void FeatureLogic::setAceResponse(bool allowed)
79 Assert(isProcessable() && "Wrong usage");
81 m_currentFeature->rejected = true;
82 if (m_currentFeature->required) {
88 DPL::String FeatureLogic::getDevice() const
90 return *(m_currentFeature->currentCap);
93 bool FeatureLogic::isProcessable() const
99 if (m_currentFeature->currentCap == m_currentFeature->devCapSet.end()) {
106 } // namespace WidgetInstall