/* * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "feature_logic.h" #include #include #include #include #include #include #include #include namespace Jobs { namespace WidgetInstall { FeatureLogic::FeatureLogic(WidgetHandle handle) : m_rejected(false) { WrtDB::WidgetDAOReadOnly widgetDao(handle); WidgetFeatureSet featureSet = widgetDao.getFeaturesList(); FOREACH(it, featureSet) { LogInfo("Feature name : " << it->name); WrtDB::DeviceCapabilitySet dcs = WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name); FOREACH (devCap, dcs) { LogInfo("--- dev cap : " << *devCap); } Feature feature(*it, dcs); m_featureList.push_back(feature); } m_currentFeature = m_featureList.begin(); // ok we must set iterator on the first processable node if (!isProcessable()) { next(); } } bool FeatureLogic::isDone() const { return m_currentFeature == m_featureList.end(); } bool FeatureLogic::next() { while (!isDone()) { if (m_currentFeature->currentCap != m_currentFeature->devCapSet.end()) { m_currentFeature->currentCap++; } else { ++m_currentFeature; } // we moved pointer if (isProcessable()) { return true; } } return false; } void FeatureLogic::setAceResponse(bool allowed) { Assert(isProcessable() && "Wrong usage"); if (!allowed) { m_currentFeature->rejected = true; if (m_currentFeature->required) { m_rejected = true; } } } DPL::String FeatureLogic::getDevice() const { return *(m_currentFeature->currentCap); } bool FeatureLogic::isProcessable() const { if (isDone()) { return false; } if (m_currentFeature->currentCap == m_currentFeature->devCapSet.end()) { return false; } return true; } } // namespace WidgetInstall } // namespace Jobs