+++ /dev/null
-# 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.
-#
-#
-# @file CMakeLists.txt
-# @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
-# @version 1.0
-#
-
-INCLUDE(FindPkgConfig)
-
-PKG_CHECK_MODULES(CONFIG_GEN_DEPS
- libxml-2.0
- dpl-efl
- REQUIRED)
-
-SET(CONFIG_GEN_SOURCES
- config_generator.cpp)
-
-INCLUDE_DIRECTORIES(${CONFIG_GEN_DEPS_INCLUDE_DIRS})
-
-ADD_LIBRARY(${TARGET_CONFIG_GEN_LIB} SHARED
- ${CONFIG_GEN_SOURCES})
-
-SET_TARGET_PROPERTIES(${TARGET_CONFIG_GEN_LIB} PROPERTIES
- SOVERSION ${CMAKE_PACKAGE_VERSION})
-
-SET_TARGET_PROPERTIES(${TARGET_CONFIG_GEN_LIB} PROPERTIES
- COMPILE_FLAGS -fPIC)
-
-TARGET_LINK_LIBRARIES(${TARGET_CONFIG_GEN_LIB}
- ${CONFIG_GEN_DEPS_LIBRARIES})
-
-INSTALL(TARGETS ${TARGET_CONFIG_GEN_LIB}
- DESTINATION lib
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-
-INSTALL(FILES
- config_generator.h
- DESTINATION include/config_generator)
\ No newline at end of file
+++ /dev/null
-/*
- * 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.
- */
-/*
- * @file config_generator.cpp
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @version 1.0
- */
-
-#include "config_generator.h"
-#include <sstream>
-#include <dpl/binary_queue.h>
-#include <dpl/log/log.h>
-#include <dpl/foreach.h>
-#include <libxml/xmlversion.h>
-#include <libxml/xmlstring.h>
-#include <libxml/tree.h>
-
-namespace ConfigXml {
-
-class XmlDocWrapper {
-public:
- XmlDocWrapper(xmlDocPtr doc) : m_doc(doc) {}
- ~XmlDocWrapper() { xmlFreeDoc(m_doc); }
- xmlDocPtr get() const { return m_doc; }
-
-private:
- xmlDocPtr m_doc;
-};
-
-class XmlNodeWrapper {
-public:
- XmlNodeWrapper(xmlNodePtr node) : m_node(node) {}
- xmlNodePtr get() const { return m_node; }
-
-private:
- // not owned
- xmlNodePtr m_node;
-};
-
-namespace {
-
-// helper strings
-const xmlChar* _DOC_VERSION_ = BAD_CAST "1.0";
-const xmlChar* _WIDGET_ = BAD_CAST "widget";
-const xmlChar* _SRC_ = BAD_CAST "src";
-const xmlChar* _REQUIRED_ = BAD_CAST "required";
-const xmlChar* _TRUE_ = BAD_CAST "true";
-const xmlChar* _FALSE_ = BAD_CAST "false";
-const xmlChar* _NAME_ = BAD_CAST "name";
-const xmlChar* _VALUE_ = BAD_CAST "value";
-const xmlChar* _XMLNS_ = BAD_CAST "xmlns";
-const xmlChar* _NAMESPACE_ = BAD_CAST "http://www.w3.org/ns/widgets";
-const xmlChar* _ID_ = BAD_CAST "id";
-const xmlChar* _VERSION_ = BAD_CAST "version";
-const xmlChar* _HEIGHT_ = BAD_CAST "height";
-const xmlChar* _WIDTH_ = BAD_CAST "width";
-const xmlChar* _VIEWMODES_ = BAD_CAST "viewmodes";
-const xmlChar* _ORIGIN_ = BAD_CAST "origin";
-const xmlChar* _SUBDOMAINS_ = BAD_CAST "subdomains";
-const xmlChar* _HREF_ = BAD_CAST "href";
-const xmlChar* _EMAIL_ = BAD_CAST "email";
-const xmlChar* _READONLY_ = BAD_CAST "readonly";
-
-struct TagInfo {
- const xmlChar* name; // Tag name
- const Tag parent; // Tag parent
-};
-
-const TagInfo TAG[TAG_COUNT] = {
- {BAD_CAST "widget", INVALID},
- {BAD_CAST "name", WIDGET},
- {BAD_CAST "icon", WIDGET},
- {BAD_CAST "content", WIDGET},
- {BAD_CAST "author", WIDGET},
- {BAD_CAST "license", WIDGET},
- {BAD_CAST "feature", WIDGET},
- {BAD_CAST "param", FEATURE},
- {BAD_CAST "description", WIDGET},
- {BAD_CAST "preference", WIDGET},
- {BAD_CAST "access", WIDGET},
- {BAD_CAST "tizen:setting", WIDGET}
-};
-
-// helper functions
-xmlNodePtr NewNode(xmlNodePtr parent, Tag tagId)
-{
- LogDebug("Adding node " << TAG[tagId].name);
-
- // check parent
- Assert(0==xmlStrcmp(parent->name,TAG[TAG[tagId].parent].name) &&
- "Wrong parent");
-
- xmlNodePtr node = xmlNewNode(NULL, TAG[tagId].name);
- if (NULL == node) {
- Throw(NodeCreationError);
- }
- if (NULL == xmlAddChild(parent,node)) {
- Throw(ChildCreationError);
- }
- return node;
-}
-
-void AddProperty(xmlNodePtr node, const xmlChar* name, const xmlChar* value)
-{
- if (!xmlNewProp(node, name, value)) {
- Throw(PropertyCreationError);
- }
-}
-
-void AddBoolProp(xmlNodePtr node, const xmlChar* name, bool value)
-{
- AddProperty(node, name, (value ? _TRUE_ : _FALSE_));
-
-}
-
-void AddCharProp(xmlNodePtr node, const xmlChar* name, const char* value)
-{
- if (value) {
- AddProperty(node, name, BAD_CAST value);
- }
-}
-
-void AddCharProp(xmlNodePtr node, const char* name, const char* value)
-{
- if (value) {
- AddProperty(node, BAD_CAST name, BAD_CAST value);
- }
-}
-
-void AddNameAndValue(xmlNodePtr node, const char* name, const char* value)
-{
- AddCharProp(node, _NAME_, name);
- AddCharProp(node, _VALUE_, value);
-}
-
-} // namespace
-
-// ELEMENT ///////////////////////////////////////////////////////////////
-
-// <tag>value</tag>
-#define DECLARE_HANDLER_CONTENT(tag) \
-template <> \
-XmlNodeWrapperPtr Element::Handler<tag, const char*>::CreateNode( \
- const char* value) \
-{ \
- xmlNodePtr node = NewNode(m_parent->get(), tag); \
- xmlNodeSetContent(node, BAD_CAST value); \
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node)); \
- return ret; \
-}
-
-// <tag src="value"></tag>
-#define DECLARE_HANDLER_SRC_ATTRIBUTE(tag) \
-template <> \
-XmlNodeWrapperPtr Element::Handler<tag, const char*>::CreateNode( \
- const char* value) \
-{ \
- xmlNodePtr node = NewNode(m_parent->get(), tag); \
- AddCharProp(node, _SRC_, value); \
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node)); \
- return ret; \
-}
-
-DECLARE_HANDLER_CONTENT(NAME);
-DECLARE_HANDLER_CONTENT(DESCRIPTION);
-DECLARE_HANDLER_SRC_ATTRIBUTE(ICON);
-DECLARE_HANDLER_SRC_ATTRIBUTE(CONTENT);
-
-// <author href="href" email="email">author</author>
-template <>
-XmlNodeWrapperPtr Element::
- Handler<AUTHOR, const char*, const char*, const char*>::
- CreateNode(const char* href, const char* email, const char* author)
-{
- xmlNodePtr node = NewNode(m_parent->get(), AUTHOR);
- AddCharProp(node, _HREF_, href);
- AddCharProp(node, _EMAIL_, email);
- xmlNodeSetContent(node, BAD_CAST author);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <license href="href">license</license>
-template <>
-XmlNodeWrapperPtr Element::Handler<LICENSE, const char*, const char*>::
- CreateNode(const char* href, const char* license)
-{
- xmlNodePtr node = NewNode(m_parent->get(), LICENSE);
- AddCharProp(node, _HREF_, href);
- xmlNodeSetContent(node, BAD_CAST license);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <feature name="value" required="true"></feature>
-template <>
-XmlNodeWrapperPtr Element::Handler<FEATURE, const char*, bool>::CreateNode(
- const char* value,
- bool required)
-{
- xmlNodePtr node = NewNode(m_parent->get(), FEATURE);
- AddCharProp(node, _NAME_, value);
- AddBoolProp(node, _REQUIRED_, required);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <param name="name" value="true"></param>
-template <>
-XmlNodeWrapperPtr Element::Handler<PARAM, const char*, bool>::CreateNode(
- const char* name,
- bool value)
-{
- xmlNodePtr node = NewNode(m_parent->get(), PARAM);
- AddCharProp(node, _NAME_, name);
- AddBoolProp(node, _VALUE_, value);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <param name="name" value="value"></param>
-template <>
-XmlNodeWrapperPtr Element::Handler<PARAM, const char*, const char*>::CreateNode(
- const char* name,
- const char* value)
-{
- xmlNodePtr node = NewNode(m_parent->get(), PARAM);
- AddNameAndValue(node, name, value);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <preference name="name" value="value"></preference>
-template <>
-XmlNodeWrapperPtr Element::Handler<PREFERENCE, const char*, const char*>::
- CreateNode(const char* name, const char* value)
-{
- xmlNodePtr node = NewNode(m_parent->get(), PREFERENCE);
- AddNameAndValue(node, name, value);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <preference name="name" value="value" readonly="true"></preference>
-template <>
-XmlNodeWrapperPtr Element::Handler<PREFERENCE, const char*, const char*, bool>::
- CreateNode(const char* name, const char* value, bool readonly)
-{
- xmlNodePtr node = NewNode(m_parent->get(), PREFERENCE);
- AddNameAndValue(node, name, value);
- AddBoolProp(node, _READONLY_, readonly);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <access name="value"></access>
-template <>
-XmlNodeWrapperPtr Element::Handler<ACCESS, const char*>::CreateNode(
- const char* value)
-{
- xmlNodePtr node = NewNode(m_parent->get(), ACCESS);
- AddCharProp(node, _ORIGIN_, value);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <access name="value" subdomains="true"></access>
-template <>
-XmlNodeWrapperPtr Element::Handler<ACCESS, const char*, bool>::CreateNode(
- const char* value,
- bool required)
-{
- xmlNodePtr node = NewNode(m_parent->get(), ACCESS);
- AddCharProp(node, _ORIGIN_, value);
- AddBoolProp(node, _SUBDOMAINS_, required);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// <tizen:setting name="value"></tizen:setting>
-template <>
-XmlNodeWrapperPtr Element::Handler<TIZEN_SETTING, const char*, const char*>::
- CreateNode(const char* name, const char* value)
-{
- xmlNodePtr node = NewNode(m_parent->get(), TIZEN_SETTING);
- AddCharProp(node, name, value);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(node));
- return ret;
-}
-
-// DOCUMENT //////////////////////////////////////////////////////////////
-
-// <widget xmlns="value" id="id" viewmodes="viewmodes"></widget>
-template <>
-XmlNodeWrapperPtr Document::
- Handler<WIDGET, const char*, const char*, const char*>::
- CreateRoot(const char* id, const char* version, const char* viewmodes)
-{
- Assert(NULL == xmlDocGetRootElement(m_document->get()) &&
- "The document already has root node");
-
- // root
- xmlNodePtr root = xmlNewNode(NULL, _WIDGET_);
- if (NULL == root) {
- Throw(NodeCreationError);
- }
- xmlDocSetRootElement(m_document->get(), root);
- AddProperty(root, _XMLNS_, _NAMESPACE_ );
- AddCharProp(root, _ID_, id);
- AddCharProp(root, _VERSION_, version);
- AddCharProp(root, _VIEWMODES_, viewmodes);
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(root));
- return ret;
-}
-
-/*
- * <widget xmlns="value" id="id" height="height" width="width"
- * viewmodes="viewmodes"></widget>
- */
-template <>
-XmlNodeWrapperPtr Document::
- Handler<WIDGET, const char*, const char*, int, int>::
- CreateRoot(const char* id, const char* version, int height, int width)
-{
- // root
- xmlNodePtr root = xmlNewNode(NULL, _WIDGET_);
- if (NULL == root) {
- Throw(NodeCreationError);
- }
- xmlDocSetRootElement(m_document->get(), root);
- AddProperty(root, _XMLNS_, _NAMESPACE_ );
- AddCharProp(root, _ID_, id);
- AddCharProp(root, _VERSION_, version);
- std::ostringstream hstream;
- hstream << height;
- AddProperty(root, _HEIGHT_, BAD_CAST hstream.str().c_str());
- std::ostringstream wstream;
- wstream << width;
- AddProperty(root, _WIDTH_, BAD_CAST wstream.str().c_str());
- XmlNodeWrapperPtr ret(new XmlNodeWrapper(root));
- return ret;
-}
-
-DocumentPtr Document::Create()
-{
- // check libxml version
- LIBXML_TEST_VERSION;
-
- xmlDocPtr xmlDoc = xmlNewDoc(_DOC_VERSION_);
- if( NULL == xmlDoc) {
- Throw(DocCreationError);
- }
-
- // document
- XmlDocWrapperPtr document(new XmlDocWrapper(xmlDoc));
-
- DocumentPtr doc(new Document(document));
- return doc;
-}
-
-Document::~Document()
-{
-}
-
-void Document::Write(DPL::AbstractOutput& output)
-{
- // write
- xmlChar* buffer = NULL;
-
- int size;
- xmlDocDumpFormatMemory(m_document->get(), &buffer, &size, 1);
- std::unique_ptr<xmlChar, xmlFreeFunc> bufferPtr(buffer, xmlFree);
-
- DPL::BinaryQueue bq;
- bq.AppendCopy(static_cast<unsigned char*>(buffer), size);
- output.Write(bq, bq.Size());
-}
-
-} // ConfigXml
+++ /dev/null
-/*
- * 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.
- */
-/*
- * @file config_generator.h
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @version 1.0
- */
-
-#ifndef CONFIG_GENERATOR_H_
-#define CONFIG_GENERATOR_H_
-
-#include <dpl/abstract_output.h>
-#include <dpl/assert.h>
-#include <dpl/exception.h>
-#include <list>
-#include <memory>
-
-namespace ConfigXml {
-
-enum Tag {
- WIDGET = 0,
- NAME,
- ICON,
- CONTENT,
- AUTHOR,
- LICENSE,
- FEATURE,
- PARAM,
- DESCRIPTION,
- PREFERENCE,
- ACCESS,
- TIZEN_SETTING,
-
- TAG_COUNT,
- INVALID
-};
-
-/*
- * TODO
- * -Global attributes support xml:lang, dir
- * -Children cardinality
- * -Other...
- */
-
-DECLARE_EXCEPTION_TYPE(DPL::Exception, Base);
-DECLARE_EXCEPTION_TYPE(Base, NodeCreationError);
-DECLARE_EXCEPTION_TYPE(Base, DocCreationError);
-DECLARE_EXCEPTION_TYPE(Base, ChildCreationError);
-DECLARE_EXCEPTION_TYPE(Base, PropertyCreationError);
-
-// ELEMENT ///////////////////////////////////////////////////////////
-
-class Element;
-typedef std::shared_ptr<Element> ElementPtr;
-
-class XmlNodeWrapper;
-typedef std::shared_ptr<XmlNodeWrapper> XmlNodeWrapperPtr;
-
-class Element {
-public:
- template <Tag TagId, typename... Params>
- ElementPtr Add(Params... parameters);
-
-private:
- friend class Document;
-
- // helper class for handling nodes
- template <Tag TagId,typename... Params>
- class Handler {
- public:
- explicit Handler(XmlNodeWrapperPtr parent) : m_parent(parent) {}
-
- XmlNodeWrapperPtr CreateNode(Params... parameters);
- private:
- // not owned!
- XmlNodeWrapperPtr m_parent;
- };
-
- explicit Element(XmlNodeWrapperPtr node) : m_node(node)
- {
- Assert(m_node);
- }
-
- // not owned!
- XmlNodeWrapperPtr m_node;
-};
-
-template <Tag TagId, typename... Params>
-ElementPtr Element::Add(Params... parameters)
-{
- Handler<TagId,Params...> eh(m_node);
- ElementPtr e(new Element(eh.CreateNode(parameters...)));
- return e;
-}
-
-
-// DOCUMENT //////////////////////////////////////////////////////////
-
-class Document;
-typedef std::shared_ptr<Document> DocumentPtr;
-
-class XmlDocWrapper;
-typedef std::shared_ptr<XmlDocWrapper> XmlDocWrapperPtr;
-
-class Document {
-public:
- static DocumentPtr Create();
-
- void Write(DPL::AbstractOutput& output);
-
- template <Tag TagId, typename... Params>
- ElementPtr Add(Params... parameters);
-
- ~Document();
-
-private:
- explicit Document(XmlDocWrapperPtr document) :
- m_document(document)
- {
- Assert(m_document);
- }
-
- // helper class for handling root node
- template <Tag TagId,typename... Params>
- class Handler {
- public:
- explicit Handler(XmlDocWrapperPtr document) : m_document(document) {}
-
- XmlNodeWrapperPtr CreateRoot(const Params... parameters);
- private:
- // not owned!
- XmlDocWrapperPtr m_document;
- };
-
- XmlDocWrapperPtr m_document;
-};
-
-template <Tag TagId, typename... Params>
-ElementPtr Document::Add(Params... parameters)
-{
- Handler<TagId,Params...> dh(m_document);
- ElementPtr e(new Element(dh.CreateRoot(parameters...)));
- return e;
-}
-
-}; // ConfigXml
-
-#endif /* CONFIG_GENERATOR_H_ */
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file powder_parser.cpp
- * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
- * @version 0.1
- * @brief Parser for WAC defined POWDER
- */
-
-#include <algorithm>
-#include <cstdio>
-#include <cerrno>
-#include <ewk_main.h>
-#include <dpl/log/log.h>
-#include <dpl/sstream.h>
-#include <dpl/foreach.h>
-#include "powder_parser.h"
-#include "ignoring_parser.h"
-#include "deny_all_parser.h"
-
-namespace {
-void MergeDescriptions(WrtDB::Powder::Description* dest,
- const WrtDB::Powder::Description& src)
-{
- Assert(dest);
-// LogInfo("MergeDescriptions dest: " << *dest <<
-// " src: " << src);
- if (!dest->ageRating) {
- dest->ageRating = src.ageRating;
- } else {
- if (!!src.ageRating) {
- if (*dest->ageRating > *src.ageRating) {
- dest->ageRating = src.ageRating;
- }
- }
- }
- FOREACH(catIter, src.categories)
- {
- FOREACH(levelIter, catIter->second.levels)
- {
- dest->categories[catIter->first].levels.push_back(*levelIter);
- }
- }
-// LogInfo("MergeDescriptions result:" << *dest);
-}
-
-//TODO::Check if list of delimiters is valid
-const DPL::String constPowderDelimiters = DPL::FromUTF32String(L" ,;\n\r\t");
-} //anonymous namespace
-
-std::ostream & operator<<(std::ostream& aStream,
- const StringSet& aContainer)
-{
- if (!aContainer.empty()) {
- StringSet::const_iterator iter = aContainer.begin();
- aStream << "{[" << *iter;
- ++iter;
- for (/*empty*/; iter != aContainer.end(); ++iter) {
- aStream << "] [" << *iter;
- }
- aStream << "]}";
- }
- return aStream;
-}
-
-#define DEFINE_ELEMENT_FUNC(element, myClass) \
- m_map[DPL::FromUTF32String(L"" # element)] = \
- DPL::MakeDelegate(this, &myClass::OnElement_ ## element);
-
-class DenyUnknownTagsParser : public ElementParser
-{
- public:
- DenyUnknownTagsParser() : ElementParser()
- {
- }
-
- void Accept(const XmlAttribute& /*attribute*/)
- {
- }
-
- void Accept(const Element& /*element*/)
- {
- }
-
- void Accept(const Text& /*text*/)
- {
- }
-
- ElementParserPtr OnDenyElement()
- {
- return ElementParserPtr(new DenyAllParser());
- }
-
- ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return DPL::MakeDelegate(this, &DenyUnknownTagsParser::OnDenyElement);
- }
-
- protected:
- FuncMap m_map;
-};
-
-StringSet TokenizeTag(const DPL::String& buffer)
-{
- StringSet data;
- DPL::Tokenize(buffer, constPowderDelimiters,
- std::insert_iterator<StringSet>(data, data.begin()), true);
- return data;
-}
-
-class SetOfTextValuesParser : public DenyUnknownTagsParser
-{
- public:
- explicit SetOfTextValuesParser(std::set<DPL::String>* data) :
- DenyUnknownTagsParser(),
- m_data(data)
- {
- Assert(m_data);
- }
-
- virtual void Accept(const Text& text)
- {
- LogDebug("text");
- m_buffer += text.value;
- }
- void Verify()
- {
- *m_data = TokenizeTag(m_buffer);
- }
-
- private:
- DPL::String m_buffer;
- StringSet* m_data;
-};
-
-// It is data structure used by iriset parser to match IRI's
-// and preserve processing result
-struct IrisetParserData
-{
- const DPL::String* m_host;
- const DPL::String* m_path;
- bool m_matched;
- IrisetParserData(const DPL::String& host,
- const DPL::String& path) :
- m_host(&host),
- m_path(&path),
- m_matched(false)
- {
- }
-};
-
-class IrisetParser : public DenyUnknownTagsParser
-{
- public:
- explicit IrisetParser(IrisetParserData* data) :
- DenyUnknownTagsParser(),
- m_data(data),
- m_hostsDetected(0),
- m_pathsDetected(0)
- {
- Assert(m_data);
- DEFINE_ELEMENT_FUNC(includehosts, IrisetParser);
- DEFINE_ELEMENT_FUNC(includeexactpaths, IrisetParser);
- }
-
- ElementParserPtr OnElement_includehosts()
- {
- m_hostsDetected++;
- return ElementParserPtr(new SetOfTextValuesParser(&m_hosts));
- }
-
- ElementParserPtr OnElement_includeexactpaths()
- {
- m_pathsDetected++;
- return ElementParserPtr(new SetOfTextValuesParser(&m_paths));
- }
-
- void Verify()
- {
- if (m_hostsDetected <= 1 && m_pathsDetected <= 1) {
- LogInfo("Matching iriset for host [" <<
- *m_data->m_host << "] path [" <<
- *m_data->m_path << "]");
- LogInfo("hosts: " << m_hosts <<
- " paths: " << m_paths);
- m_data->m_matched =
- m_hosts.find(*m_data->m_host) != m_hosts.end() &&
- m_paths.find(*m_data->m_path) != m_paths.end();
- } else {
- ThrowMsg(PowderParserException::ParserFailed,
- "Invalid iriset contents");
- }
- }
-
- private:
- IrisetParserData* m_data;
- typedef StringSet Container;
- Container m_hosts;
- Container m_paths;
- size_t m_hostsDetected;
- size_t m_pathsDetected;
-};
-
-class WacCategoryParser : public DenyUnknownTagsParser
-{
- public:
- WacCategoryParser(WrtDB::Powder::Description::LevelEntry* data) :
- DenyUnknownTagsParser(),
- m_data(data)
- {
- Assert(m_data);
- }
-
- virtual void Accept(const Text& text)
- {
- LogDebug("text");
- m_buffer += text.value;
- }
-
- static StringSet GetAllowedAttributes()
- {
- StringSet allowed;
- allowed.insert(DPL::FromUTF32String(L"xa"));
- allowed.insert(DPL::FromUTF32String(L"xb"));
- allowed.insert(DPL::FromUTF32String(L"xc"));
- allowed.insert(DPL::FromUTF32String(L"xd"));
- allowed.insert(DPL::FromUTF32String(L"xe"));
- return allowed;
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- static StringSet allowed = GetAllowedAttributes();
- if (allowed.find(attribute.name) != allowed.end()) {
- if (DPL::FromUTF32String(L"1") == attribute.value) {
- m_data->context.insert(attribute.name);
- } else if (DPL::FromUTF32String(L"0") != attribute.value) {
- ThrowMsg(PowderParserException::ParserFailed,
- "Invalid attribute for WAC category tag");
- }
- } else {
- ThrowMsg(PowderParserException::ParserFailed,
- "Invalid tag in descriptionset");
- }
- }
-
- virtual void Verify()
- {
- StringSet values = TokenizeTag(m_buffer);
- bool numberFound = false;
-
- FOREACH(wordIter, values) {
- DPL::IStringStream str(*wordIter);
- int rating;
- str >> rating;
- if (str.fail()) {
- ThrowMsg(PowderParserException::ParserFailed,
- "WAC category level is not number");
- } else {
- if (numberFound) {
- ThrowMsg(PowderParserException::ParserFailed,
- "Too many WAC category levels");
- } else {
- if (rating >= MIN_AGE_RATING && rating <= MAX_AGE_RATING) {
- m_data->level =
- static_cast<WrtDB::Powder::Description::LevelEnum>(
- rating);
- numberFound = true;
- } else {
- ThrowMsg(PowderParserException::ParserFailed,
- "WAC category level is out of range ");
- }
- }
- }
- }
- if (!numberFound) {
- ThrowMsg(PowderParserException::ParserFailed,
- "WAC category level is not present in tag");
- }
- }
-
- private:
- WrtDB::Powder::Description::LevelEntry* m_data;
- DPL::String m_buffer;
- static const int MIN_AGE_RATING = 0;
- static const int MAX_AGE_RATING = 5;
-};
-
-class DescriptorSetParser : public DenyUnknownTagsParser
-{
- public:
- typedef WrtDB::Powder::Description::CategoryEntries::iterator CatIter;
- explicit DescriptorSetParser(WrtDB::Powder::Description* data) :
- DenyUnknownTagsParser(),
- m_data(data)
- {
- Assert(m_data);
-#define ELEM(tag) DEFINE_ELEMENT_FUNC(tag, DescriptorSetParser)
- ELEM(aa);
- ELEM(nu);
- ELEM(se);
- ELEM(vi);
- ELEM(la);
- ELEM(dr);
- ELEM(ga);
- ELEM(ha);
- ELEM(ug);
-#undef ELEM
- m_map[DPL::FromUTF32String(L"displayicon")] =
- DPL::MakeDelegate(this, &DescriptorSetParser::OnIgnoredElement);
- }
-
- ElementParserPtr OnElement_aa()
- {
- m_ages.push_back(StringSet());
- return ElementParserPtr(new SetOfTextValuesParser(&m_ages.back()));
- }
-
-#define GENERATE_ELEMENT_FUNC(element) \
- ElementParserPtr OnElement_ ## element() \
- { \
- LogInfo("WAC category tag detected: " << # element); \
- CatIter category = \
- m_data->categories.find(DPL::FromUTF32String(L"" # element)); \
- if (m_data->categories.end() == category) \
- { \
- std::pair<CatIter, bool> result = \
- m_data->categories.insert(std::make_pair( \
- DPL::FromUTF32String(L"" # \
- element), \
- WrtDB::Powder::Description:: \
- CategoryEntry())); \
- category = result.first; \
- } \
- category->second.levels.push_back( \
- WrtDB::Powder::Description::LevelEntry()); \
- return ElementParserPtr(new \
- WacCategoryParser( \
- &category->second.levels.back())); \
- } \
-
- GENERATE_ELEMENT_FUNC(nu)
- GENERATE_ELEMENT_FUNC(se)
- GENERATE_ELEMENT_FUNC(vi)
- GENERATE_ELEMENT_FUNC(la)
- GENERATE_ELEMENT_FUNC(dr)
- GENERATE_ELEMENT_FUNC(ga)
- GENERATE_ELEMENT_FUNC(ha)
- GENERATE_ELEMENT_FUNC(ug)
-
-#undef GENERATE_ELEMENT_FUNC
-
- ElementParserPtr OnIgnoredElement()
- {
- return ElementParserPtr(new IgnoringParser());
- }
-
- void Verify()
- {
- if (m_ages.size() > 1) {
- ThrowMsg(PowderParserException::ParserFailed,
- "More than one aa tags: not implemented");
- } else if (m_ages.size() == 1) {
- if (!m_ages.at(0).empty() && m_ages.at(0).size() <= 1) {
- DPL::IStringStream str(*m_ages.at(0).begin());
- int rating = 12;
- str >> rating;
- if (str.fail()) {
- ThrowMsg(PowderParserException::ParserFailed,
- "Invalid number in age rating");
- } else {
- m_data->ageRating = rating;
- }
- } else {
- ThrowMsg(PowderParserException::ParserFailed,
- "Not valid age value in aa tag ");
- }
- }
-// LogInfo("Descriptionset verified: " << *m_data);
- }
-
- private:
- typedef std::vector<StringSet> AgesTags;
- AgesTags m_ages;
- WrtDB::Powder::Description* m_data;
-};
-
-class DrParser : public DenyUnknownTagsParser
-{
- public:
- DrParser(WrtDB::Powder::Description* data,
- const DPL::String& host,
- const DPL::String& path) :
- DenyUnknownTagsParser(),
- m_data(data),
- m_host(host),
- m_path(path)
- {
- Assert(m_data);
- DEFINE_ELEMENT_FUNC(iriset, DrParser);
- DEFINE_ELEMENT_FUNC(descriptorset, DrParser);
- }
-
- ElementParserPtr OnElement_iriset()
- {
- m_iriSetOutcomes.push_back(IrisetParserData(m_host, m_path));
- return ElementParserPtr(new IrisetParser(&m_iriSetOutcomes.back()));
- }
-
- ElementParserPtr OnElement_descriptorset()
- {
- m_descriptions.push_back(WrtDB::Powder::Description());
- return ElementParserPtr(new
- DescriptorSetParser(&m_descriptions.back()));
- }
-
- void Verify()
- {
- if (m_iriSetOutcomes.empty() || m_descriptions.empty()) {
- ThrowMsg(
- PowderParserException::ParserFailed,
- "dr tag don't contain at lease one iriset and descriptionset ");
- } else {
- IriSetOutcomes::const_iterator outIter;
- for (outIter = m_iriSetOutcomes.begin();
- outIter != m_iriSetOutcomes.end() && !outIter->m_matched;
- ++outIter) {
- }
- if (outIter != m_iriSetOutcomes.end()) {
- LogInfo("Matching iriset found");
- typedef PowderDescriptions::const_iterator DescIter;
- for (DescIter descIter = m_descriptions.begin();
- descIter != m_descriptions.end(); ++descIter) {
- MergeDescriptions(m_data, *descIter);
- }
- } else {
- LogWarning("No matching iriset found");
- }
- }
-// LogInfo("dr tag verified" << *m_data);
- }
- private:
- typedef std::vector<WrtDB::Powder::Description> PowderDescriptions;
- PowderDescriptions m_descriptions;
- typedef std::vector<IrisetParserData> IriSetOutcomes;
- IriSetOutcomes m_iriSetOutcomes;
- WrtDB::Powder::Description* m_data;
- const DPL::String& m_host;
- const DPL::String& m_path;
-};
-
-PowderParser::PowderParser(PowderParserData* data) :
- ElementParser(),
- m_data(data->description),
- m_host(data->host),
- m_path(data->path)
-{
- Assert(m_data);
- m_map[DPL::FromUTF32String(L"attribution")] =
- DPL::MakeDelegate(this, &PowderParser::OnIgnoredElement);
- DEFINE_ELEMENT_FUNC(dr, PowderParser);
-}
-
-ElementParserPtr PowderParser::OnIgnoredElement()
-{
- return ElementParserPtr(new IgnoringParser());
-}
-
-ElementParserPtr PowderParser::OnElement_dr()
-{
- return ElementParserPtr(new DrParser(m_data, m_host, m_path));
-}
-
-void PowderParser::Accept(const Element& /*element*/)
-{
-}
-
-void PowderParser::Accept(const XmlAttribute& /*attribute*/)
-{
-}
-
-void PowderParser::Accept(const Text& /*text*/)
-{
-}
-
-void PowderParser::Verify()
-{
-// LogInfo("powder tag verified " << *m_data);
-}
-
-ElementParserPtr PowderParser::OnDenyElement()
-{
- return ElementParserPtr(new DenyAllParser());
-}
-
-ElementParser::ActionFunc PowderParser::GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
-{
- FuncMap::const_iterator it = m_map.find(name);
- if (it != m_map.end()) {
- return it->second;
- } else {
- return DPL::MakeDelegate(this, &PowderParser::OnDenyElement);
- }
-}
-
-#undef DEFINE_ELEMENT_FUNC
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file powder_parser.h
- * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
- * @version 0.1
- * @brief Parser for WAC defined POWDER
- */
-
-#ifndef _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_POWDER_PARSER_H_
-#define _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_POWDER_PARSER_H_
-
-#include <dpl/exception.h>
-#include "element_parser.h"
-#include <dpl/wrt-dao-ro/common_dao_types.h>
-
-//TODO: Move to separate header
-namespace PowderParserException {
-DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
-DECLARE_EXCEPTION_TYPE(Base, ParserFailed)
-}
-
-struct PowderParserData
-{
- WrtDB::Powder::Description* description;
- const DPL::String& host;
- const DPL::String& path;
- PowderParserData(WrtDB::Powder::Description* a_description,
- const DPL::String& a_host,
- const DPL::String& a_path) :
- description(a_description),
- host(a_host),
- path(a_path)
- {
- }
-};
-//TODO: Move to other header
-typedef std::set<DPL::String> StringSet;
-
-class PowderParser : public ElementParser
-{
- public:
- //Typedef used by RootParser
- typedef PowderParserData* Data;
-
- explicit PowderParser(PowderParserData* data);
-
- ElementParserPtr OnNameElement();
-
- //TODO: Remove not implemented methods
- virtual ActionFunc GetElementParser(const DPL::String& ns,
- const DPL::String& name);
- virtual void Accept(const Element& /*element*/);
- virtual void Accept(const XmlAttribute& attribute);
- virtual void Accept(const Text& text);
- virtual void Verify();
-
- ElementParserPtr OnIgnoredElement();
- ElementParserPtr OnElement_dr();
- ElementParserPtr OnDenyElement();
-
- private:
- WrtDB::Powder::Description* m_data;
- const DPL::String& m_host;
- const DPL::String& m_path;
- FuncMap m_map;
-};
-#endif // _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_POWDER_PARSER_H_
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file task_db_update.cpp
- * @author Lukasz Wrzosek(l.wrzosek@samsung.com)
- * @version 1.0
- * @brief Implementation file for installer task database updating
- */
-#include <time.h>
-#include <sys/stat.h>
-#include <widget_install/task_db_update.h>
-#include <widget_install/job_widget_install.h>
-#include <widget_install/widget_install_errors.h>
-#include <widget_install/widget_install_context.h>
-#include <dpl/wrt-dao-ro/config_parser_data.h>
-#include <dpl/utils/wrt_utility.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <dpl/ace-dao-rw/AceDAO.h>
-#include <string>
-#include <dpl/assert.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-//#include <widget_controller.h>
-#include <Ecore_File.h>
-#include <sstream>
-#include <dpl/localization/localization_utils.h>
-
-using namespace LocalizationUtils;
-using namespace WrtDB;
-
-namespace Jobs {
-namespace WidgetInstall {
-TaskDbUpdate::TaskDbUpdate(InstallerContext& context) :
- DPL::TaskDecl<TaskDbUpdate>(this),
- m_context(context)
-{
- AddStep(&TaskDbUpdate::StepDbUpdate);
- AddStep(&TaskDbUpdate::StepSetPkgName);
- AddStep(&TaskDbUpdate::StepCreateDirs);
- AddStep(&TaskDbUpdate::StepRenamePath);
-
-
- AddAbortStep(&TaskDbUpdate::StepAbortDBUpdate);
- AddAbortStep(&TaskDbUpdate::StepAbortRenamePath);
-}
-
-void TaskDbUpdate::StepSetPkgName()
-{
- // We shoud send to backend installer widget id and package name of
- // installed widget so that backend installer can send two information
- // to menuscreen. This work is needed for menuscreen to update installation
- // of widget normally from samsung appstore client.
- Assert(!!m_context.widgetHandle && "Widget Handle should be initialized");
- std::string l_pkgname;
-
- if (!!m_context.widgetConfig.pkgname) {
- l_pkgname =
- DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
- } else {
- LogInfo("package name is generated by WRT");
- std::ostringstream pkgname_stream;
-
- pkgname_stream << WrtDB::GlobalConfig::GetPkgnamePrefix() <<
- *m_context.widgetHandle;
-
- DPL::String pkgname = DPL::FromUTF8String(pkgname_stream.str());
- m_context.widgetConfig.pkgname = pkgname;
- l_pkgname = pkgname_stream.str();
- }
-
-
- LogInfo("package name : " << l_pkgname);
- LogInfo("GUID : " << m_context.widgetConfig.guid);
-
- WrtDB::WidgetDAO widgetDao(*m_context.widgetHandle);
- widgetDao.setPkgName(m_context.widgetConfig.pkgname);
-}
-
-
-void TaskDbUpdate::StepCreateDirs()
-{
- std::ostringstream widgetPath;
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- widgetPath << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- widgetPath << pkgname << "/";
-
- std::string widgetBinPath = widgetPath.str();
- std::string widgetIconPath = widgetPath.str();
- std::string widgetSrcPath = widgetPath.str();
-
- _WrtMakeDir(widgetPath.str().c_str(), 0755, WRT_FILEUTILS_RECUR);
-
- widgetBinPath += GlobalConfig::GetUserWidgetExecPath();
- _WrtMakeDir(widgetBinPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
-
- widgetIconPath += GlobalConfig::GetUserWidgetDesktopIconPath();
- _WrtMakeDir(widgetIconPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
-
- widgetSrcPath += GlobalConfig::GetWidgetSrcPath();
- _WrtMakeDir(widgetSrcPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
-}
-
-void TaskDbUpdate::StepDbUpdate()
-{
- Try
- {
- // If there is existing model, remove its database data
- if (true == m_context.existingWidgetInfo.isExist) {
- WidgetHandle old = m_context.existingWidgetInfo.existingHandle;
- LogInfo("Unregistering widget...: " << old);
- WidgetDAO::unregisterWidget(old);
- LogInfo("Widget unregistered");
- }
-
- /* Set install Time */
- time(&m_context.widgetConfig.installedTime);
-
- LogInfo("Registering widget...");
-
- m_context.widgetHandle = WidgetDAO::registerWidget(
- m_context.widgetConfig,
- m_context.wacSecurity,
- GetUserAgentLanguageTags());
-
- AceDB::AceDAO::setStaticDevCapPermissions(
- *(m_context.widgetHandle),
- m_context.staticPermittedDevCaps);
-
- LogInfo("Widget registered");
- }
- Catch(WidgetDAO::Exception::DatabaseError)
- {
- LogWarning("Database failure!");
- ReThrowMsg(Exceptions::DatabaseFailure, "Database failure!");
- }
- Catch(DPL::DB::SqlConnection::Exception::Base)
- {
- LogDebug("Database failure!");
- ReThrowMsg(Exceptions::DatabaseFailure, "Database failure!");
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_DB_UPDATE,
- "Widget DB UPDATE Finished");
-}
-
-void TaskDbUpdate::StepRenamePath()
-{
- std::ostringstream instDir;
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- instDir << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- instDir << pkgname << "/";
- instDir << GlobalConfig::GetWidgetSrcPath();
-
- LogDebug("Copy file from temp directory to " << instDir.str());
- if (!_WrtUtilRemoveDir(instDir.str().c_str())) {
- _WrtUtilChangeDir(GlobalConfig::GetUserInstalledWidgetPath());
- ThrowMsg(Exceptions::RemovingFolderFailure,
- "Error occurs during removing existing folder");
- }
-
- if (rename(m_context.tempWidgetPath.c_str(), instDir.str().c_str()) < 0) {
- ThrowMsg(Exceptions::UnknownError,
- "Error occurs during renaming widget folder");
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_RENAME_PATH,
- "Widget Rename path Finished");
-}
-
-void TaskDbUpdate::StepAbortDBUpdate()
-{
- LogWarning("[DB Update Task] Aborting... (DB Clean)");
- Assert(!!m_context.widgetHandle);
- Try
- {
- WidgetDAO::unregisterWidget(*m_context.widgetHandle);
-
- LogDebug("Cleaning DB successful!");
- }
- Catch(DPL::DB::SqlConnection::Exception::Base)
- {
- //TODO What should happen here?
- LogError("Failed to handle StepAbortDBClean!");
- // ReThrowMsg(Exceptions::DbStepFailed, "Failed to handle StepAbortDBClean!");
- }
-}
-
-void TaskDbUpdate::StepAbortRenamePath()
-{
- Assert(!!m_context.widgetHandle);
- std::ostringstream widgetPath;
- widgetPath << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- widgetPath << *m_context.widgetHandle;
-
- struct stat fileInfo;
- if (stat(widgetPath.str().c_str(), &fileInfo) != 0) {
- return;
- }
-
- if (rename(widgetPath.str().c_str(),
- m_context.tempWidgetPath.c_str()) < 0) {
- LogError("Failed to rename");
- //Ignoring failures in Abort
- }
-}
-} //namespace WidgetInstall
-} //namespace Jobs
+++ /dev/null
-/*
- * 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.
- */
-/*
- * @file task_db_update.h
- * @author Lukasz Wrzosek(l.wrzosek@samsung.com)
- * @version 1.0
- * @brief Header file for installer task database updating
- */
-#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DB_UPDATE_H
-#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DB_UPDATE_H
-
-#include <dpl/task.h>
-
-class InstallerContext;
-
-namespace Jobs {
-namespace WidgetInstall {
-class TaskDbUpdate :
- public DPL::TaskDecl<TaskDbUpdate>
-{
- private:
- InstallerContext& m_context;
-
- void StepCreateDirs();
- void StepDbUpdate();
- void StepRenamePath();
-
- void StepAbortDBUpdate();
- void StepAbortRenamePath();
-
- void StepSetPkgName();
-
- public:
- TaskDbUpdate(InstallerContext& context);
-};
-} //namespace WidgetInstall
-} //namespace Jobs
-
-#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DB_UPDATE_H
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file task_desktop_file.cpp
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @version
- * @brief
- */
-
-//SYSTEM INCLUDES
-#include <string>
-#include <dpl/assert.h>
-
-//WRT INCLUDES
-#include <widget_install/task_desktop_file.h>
-#include <widget_install/job_widget_install.h>
-#include <widget_install/widget_install_errors.h>
-#include <widget_install/widget_install_context.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include <dpl/log/log.h>
-#include <dpl/file_input.h>
-#include <dpl/file_output.h>
-#include <dpl/copy.h>
-#include <dpl/exception.h>
-#include <dpl/foreach.h>
-#include <dpl/sstream.h>
-#include <dpl/string.h>
-#include <dpl/optional.h>
-#include <map>
-
-using namespace WrtDB;
-
-namespace {
-typedef std::map<DPL::String, DPL::String> LanguageTagMap;
-
-LanguageTagMap getLanguageTagMap()
-{
- LanguageTagMap map;
-
-#define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag));
-#include "languages.def"
-#undef ADD
-
- return map;
-}
-
-DPL::OptionalString getLangTag(const DPL::String& tag)
-{
- static LanguageTagMap TagsMap =
- getLanguageTagMap();
-
- DPL::String langTag = tag;
-
- LogDebug("Trying to map language tag: " << langTag);
- size_t pos = langTag.find_first_of(L'_');
- if (pos != DPL::String::npos) {
- langTag.erase(pos);
- }
- DPL::OptionalString ret;
-
- LanguageTagMap::iterator it = TagsMap.find(langTag);
- if (it != TagsMap.end()) {
- ret = it->second;
- }
- LogDebug("Mapping IANA Language tag to language tag: " <<
- langTag << " -> " << ret);
-
- return ret;
-}
-}
-
-namespace Jobs {
-namespace WidgetInstall {
-TaskDesktopFile::TaskDesktopFile(InstallerContext &inCont) :
- DPL::TaskDecl<TaskDesktopFile>(this),
- m_context(inCont)
-{
- AddStep(&TaskDesktopFile::stepCopyIconFiles);
- AddStep(&TaskDesktopFile::stepCreateDesktopFile);
- AddStep(&TaskDesktopFile::stepCreateExecFile);
- AddStep(&TaskDesktopFile::stepFinalize);
-}
-
-TaskDesktopFile::~TaskDesktopFile()
-{
-}
-
-void TaskDesktopFile::stepCreateDesktopFile()
-{
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- desktop_name << pkgname << ".desktop";
- desktop_file << "/tmp/" << desktop_name.str();
- LogInfo("desktop file : " << desktop_file.str());
- std::ofstream file(desktop_file.str().c_str());
-
- saveWidgetType(file);
- saveWidgetExecPath(file);
- saveWidgetName(file);
- saveWidgetIcons(file);
- saveWidgetVersion(file);
- saveWidgetOtherInfo(file);
- saveAppServiceInfo(file);
-
- file.close();
-
- moveDesktopFile();
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_CREATE_DESKTOP,
- "Widget Desktop Creation Finished");
-}
-
-void TaskDesktopFile::stepCreateExecFile()
-{
- //ln -s /usr/bin/wrt-client {widget-handle}
-
- std::ostringstream real_path;
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- real_path << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- real_path << pkgname << "/";
- real_path << GlobalConfig::GetUserWidgetExecPath() << "/" <<
- m_context.widgetHandle;
- std::string wrt_client = GlobalConfig::GetWrtClientExec();
-
- LogInfo("link -s " << wrt_client << " " << real_path.str());
- symlink(wrt_client.c_str(), real_path.str().c_str());
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_CREATE_EXECFILE,
- "Widget execfile creation Finished");
-}
-
-void TaskDesktopFile::stepCopyIconFiles()
-{
- LogDebug("CopyIconFiles");
-
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- Assert(!!m_context.widgetHandle);
- WidgetDAO dao(*m_context.widgetHandle);
- WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
- WidgetDAO::WidgetIconList list = dao.getIconList();
- FOREACH(it, locList)
- {
- DPL::String i = it->widgetLocale;
- DPL::OptionalString src;
- FOREACH(icon, list)
- {
- if (icon->iconId == it->iconId) {
- src = icon->iconSrc;
- }
- }
- LogDebug("Icon for locale: " << i << "is : " << src);
-
- std::ostringstream sourceFile;
- std::ostringstream targetFile;
-
- if (!!src) {
- sourceFile << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- sourceFile << pkgname << "/";
- sourceFile << GlobalConfig::GetWidgetSrcPath() << "/";
-
- targetFile << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- targetFile << pkgname << "/";
- targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
-
- if (!i.empty()) {
- sourceFile << "locales/" << i << "/";
- }
- sourceFile << *src;
- targetFile << getIconTargetFilename(i);
-
- } else {
- //Use WRT default (not from the widget) only if widget default (not
- // localized) doesn't exist.
- if (i.empty()) {
- LogError("Using Default Icon for widget");
- sourceFile << GlobalConfig::GetUserWidgetDefaultIconFile();
- } else {
- continue;
- }
- }
-
- LogDebug("Copying icon: " << sourceFile.str() <<
- " -> " << targetFile.str());
-
- Try
- {
- DPL::FileInput input(sourceFile.str());
- DPL::FileOutput output(targetFile.str());
- DPL::Copy(&input, &output);
- }
-
- Catch(DPL::FileInput::Exception::Base)
- {
- // Error while opening or closing source file
- //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
- LogError(
- "Copying widget's icon failed. Widget's icon will not be"\
- "available from Main Screen");
- }
-
- Catch(DPL::FileOutput::Exception::Base)
- {
- // Error while opening or closing target file
- //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
- LogError(
- "Copying widget's icon failed. Widget's icon will not be"\
- "available from Main Screen");
- }
-
- Catch(DPL::CopyFailed)
- {
- // Error while copying
- //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
- LogError(
- "Copying widget's icon failed. Widget's icon will not be"\
- "available from Main Screen");
- }
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_COPY_ICONFILE,
- "Widget iconfile copy Finished");
-}
-
-void TaskDesktopFile::moveDesktopFile()
-{
- std::ostringstream destFile;
- destFile << GlobalConfig::GetUserWidgetDesktopPath() << "/";
- destFile << desktop_name.str();
- LogInfo("cp " << desktop_file.str() << " " << destFile.str());
- Try
- {
- DPL::FileInput input(desktop_file.str());
- DPL::FileOutput output(destFile.str());
- DPL::Copy(&input, &output);
- }
-
- Catch(DPL::FileInput::Exception::Base)
- {
- // Error while opening or closing source file
- // ReThrowMsg(InstallerException::CopyIconFailed,
- // desktop_file.str());
- LogError(
- "Creating Desktop File Failed. Widget's icon will not be available"\
- "from Main Screen");
- }
-
- Catch(DPL::FileOutput::Exception::Base)
- {
- // Error while opening or closing target file
- // ReThrowMsg(InstallerException::CopyIconFailed,
- // destFile.str());
- LogError(
- "Creating Desktop File Failed. Widget's icon will not be available"\
- "from Main Screen");
- }
-
- Catch(DPL::CopyFailed)
- {
- // Error while copying
- // ReThrowMsg(InstallerException::CopyIconFailed,
- // destFile.str());
- LogError(
- "Creating Desktop File Failed. Widget's icon will not be available"\
- "from Main Screen");
- }
-
- //removing temp file
- unlink(desktop_file.str().c_str());
-}
-
-void TaskDesktopFile::saveWidgetType(std::ofstream &file)
-{
- file << "Type=" << "Application" << std::endl;
-}
-
-void TaskDesktopFile::saveWidgetExecPath(std::ofstream &file)
-{
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- file << "Exec=";
- file << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- file << pkgname << "/";
- file << GlobalConfig::GetUserWidgetExecPath() << "/";
- file << m_context.widgetHandle << std::endl;
-}
-
-void TaskDesktopFile::saveWidgetVersion(std::ofstream &file)
-{
- DPL::OptionalString widget_version = m_context.widgetConfig.version;
- file << "Version=" << widget_version << std::endl;
-}
-
-void TaskDesktopFile::saveWidgetName(std::ofstream &file)
-{
- Assert(!!m_context.widgetHandle);
- WidgetDAO dao(*m_context.widgetHandle);
- LanguageTagsList languageTags(dao.getLanguageTags());
- FOREACH(i, languageTags)
- {
- DPL::OptionalString tag = getLangTag(*i);// translate en -> en_US etc
- if (tag.IsNull()) { tag = *i; }
-
- saveLocalizedKey(file, L"Name", *tag);
-
- DPL::OptionalString name = dao.getLocalizedInfo(*i).name;
- if (!!name) {
- file << *name;
- } else {
- file << "Widget " << *m_context.widgetHandle;
- }
- file << std::endl;
- }
-}
-
-void TaskDesktopFile::saveWidgetIcons(std::ofstream &file)
-{
- //TODO this file will need to be updated when user locale preferences
- //changes.
- Assert(!!m_context.widgetHandle);
- WidgetDAO dao(*m_context.widgetHandle);
-
- WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
- WidgetDAO::WidgetIconList list = dao.getIconList();
-
- LanguageTagsList languageTags(dao.getLanguageTags());
- FOREACH(it, locList)
- {
- DPL::String i = it->widgetLocale;
- DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
- if (tag.IsNull()) { tag = i; }
-
- saveLocalizedKey(file, L"Icon", *tag);
-
- DPL::OptionalString src;
- FOREACH(icon, list)
- {
- if (icon->iconId == it->iconId) {
- src = icon->iconSrc;
- }
- }
- if (!!src) {
- //If menuscreen need use absolute path of widget's icon, comment out
- //the following lines.
- //file << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- //file << WRT_WIDGET_PKGNAME_PREFIX << m_context.widgetHandle
- // << "/";
- //file << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
- file << getIconTargetFilename(i) << std::endl;
- }
- }
-}
-
-DPL::String TaskDesktopFile::getIconTargetFilename(
- const DPL::String& languageTag) const
-{
- DPL::OStringStream filename;
- DPL::Optional<DPL::String> pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- filename << DPL::ToUTF8String(*pkgname).c_str();
-
- if (!languageTag.empty()) {
- DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
- if (tag.IsNull()) { tag = languageTag; }
- DPL::String locale =
- LocalizationUtils::BCP47LanguageTagToLocale(*tag);
-
- if(locale.empty()) {
- filename << L"." << languageTag;
- } else {
- filename << L"." << locale;
- }
- }
-
- filename << L".png";
- return filename.str();
-}
-
-void TaskDesktopFile::saveWidgetOtherInfo(std::ofstream &file)
-{
- DPL::Optional<DPL::String> widgetID = m_context.widgetConfig.guid;
-
- // /* network */
- // strncat(desktop, format_network, strlen(format_network));
- // //TODO -- get the network value from the widget
- // strncat(desktop, "True", 4);
- // strncat(desktop, line, strlen(line));
-
- /* Comment */
- file << "Comment=Widget application" << std::endl;
-
- /* bg_schedule */
- //file << "BG_SCHEDULE=True" << std::endl;
-
- /* visible */
- file << "Visible=True" << std::endl;
-
- file << "X-SLP-BaseLayoutWidth=720" << std::endl;
- file << "X-SLP-BaseLayoutHeight=1280" << std::endl;
- file << "X-SLP-IsHorizontalScale=True" << std::endl;
- file << "X-SLP-PackageType=wgt" << std::endl;
- if (!widgetID.IsNull()) {
- file << "X-SLP-PackageID=" << DPL::ToUTF8String(*widgetID).c_str() << std::endl;
- }
-}
-
-void TaskDesktopFile::saveAppServiceInfo(std::ofstream &file)
-{
- Assert(!!m_context.widgetHandle);
- WidgetDAOReadOnly dao(*m_context.widgetHandle);
- WidgetApplicationServiceList appServiceList;
- dao.getAppServiceList(appServiceList);
-
- if (appServiceList.empty()) {
- LogInfo("Widget doesn't contain application service");
- return;
- }
-
- // X-SLP-SVC=operation:scheme:mime;
- file << "X-SLP-SVC=";
- FOREACH(it, appServiceList) {
- file << DPL::ToUTF8String(it->operation).c_str() << ":";
- if (it->scheme.empty()) {
- file << "NULL" << ":";
- } else {
- file << DPL::ToUTF8String(it->scheme).c_str() << ":";
- }
- if (it->mime.empty()) {
- file << "NULL" << ";";
- } else {
- file << DPL::ToUTF8String(it->mime).c_str() << ";";
- }
- }
-}
-
-void TaskDesktopFile::stepFinalize()
-{
- LogInfo("Finished DesktopFile step");
-}
-
-void TaskDesktopFile::saveLocalizedKey(std::ofstream &file,
- const DPL::String& key,
- const DPL::String& languageTag)
-{
- DPL::String locale =
- LocalizationUtils::BCP47LanguageTagToLocale(languageTag);
-
- file << key;
- if (!locale.empty()) {
- file << "[" << locale << "]";
- }
- file << "=";
-}
-} //namespace WidgetInstall
-} //namespace Jobs
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file task_desktop_file.h
- * @author Pawel Sikorski (p.sikorski@samgsung.com)
- * @version
- * @brief
- */
-
-#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DESKTOP_FILE_H
-#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DESKTOP_FILE_H
-
-//SYSTEM INCLUDES
-#include <fstream>
-
-//WRT INCLUDES
-#include <dpl/task.h>
-#include <dpl/localization/localization_utils.h>
-
-class InstallerContext;
-
-namespace Jobs {
-namespace WidgetInstall {
-class TaskDesktopFile :
- public DPL::TaskDecl<TaskDesktopFile>
-{
- public:
- TaskDesktopFile(InstallerContext &inCont);
- virtual ~TaskDesktopFile();
-
- private:
- //context data
- InstallerContext &m_context;
-
- //TODO stepAbort
- //steps
- void stepCreateDesktopFile();
- void stepCreateExecFile();
- void stepFinalize();
- void stepCopyIconFiles();
-
- //private data
- std::ostringstream desktop_name;
- std::ostringstream desktop_file;
-
- //private methods
- void moveDesktopFile();
- void saveWidgetType(std::ofstream &file);
- void saveWidgetExecPath(std::ofstream &file);
- void saveWidgetName(std::ofstream &file);
- void saveWidgetIcons(std::ofstream &file);
- void saveWidgetVersion(std::ofstream &file);
- void saveWidgetOtherInfo(std::ofstream &file);
- void saveAppServiceInfo(std::ofstream &file);
-
- static void saveLocalizedKey(std::ofstream &file,
- const DPL::String& key,
- const DPL::String& languageTag);
- DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
-};
-} //namespace WidgetInstall
-} //namespace Jobs
-
-#endif /* INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DESKTOP_FILE_H */
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file task_parental_mode.cpp
- * @author Janusz Majnert (j.majnert@samsung.com)
- * @version 1.0
- * @brief Implementation for parental mode check installer task
- */
-#include <widget_install/task_parental_mode.h>
-#include <widget_install/widget_install_errors.h>
-#include <widget_install/widget_install_context.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include <dpl/log/log.h>
-
-namespace Jobs {
-namespace WidgetInstall {
-TaskParentalMode::TaskParentalMode(InstallerContext &installerContext) :
- DPL::TaskDecl<TaskParentalMode>(this),
- m_installerContext(installerContext)
-{
- AddStep(&TaskParentalMode::StepCheckParentalMode);
-}
-
-TaskParentalMode::~TaskParentalMode()
-{
- //Nothing to do for now
-}
-
-void TaskParentalMode::StepCheckParentalMode()
-{
- LogInfo("Step: Checking parental mode status");
-
- using namespace WrtDB;
- if (GlobalDAOReadOnly::GetParentalMode()) {
- Throw(Exceptions::ParentalModeActive);
- }
-}
-} //namespace WidgetInstall
-} //namespace Jobs
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file task_parental_mode.h
- * @author Janusz Majnert (j.majnert@samsung.com)
- * @version 1.0
- * @brief Implementation for parental mode check installer task
- */
-#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PARENTAL_MODE_H
-#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PARENTAL_MODE_H
-
-#include <dpl/task.h>
-
-class InstallerContext;
-
-namespace Jobs {
-namespace WidgetInstall {
-class TaskParentalMode :
- public DPL::TaskDecl<TaskParentalMode>
-{
- private:
- // Installation context
- InstallerContext &m_installerContext;
-
- // Steps
- void StepCheckParentalMode();
-
- public:
- explicit TaskParentalMode(InstallerContext &installerContext);
- virtual ~TaskParentalMode();
-};
-} //namespace WidgetInstall
-} //namespace Jobs
-
-#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PARENTAL_MODE_H
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file installer_task_private_storage.cpp
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @version 1.0
- * @brief Implementation file for installer task private storage.
- */
-#include "task_private_storage.h"
-
-#include <pwd.h>
-#include <grp.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string>
-
-#include <dpl/log/log.h>
-#include <dpl/errno_string.h>
-
-#include <dpl/wrt-dao-ro/widget_config.h>
-#include <dpl/utils/file_utils.h>
-#include <widget_install/job_widget_install.h>
-#include <widget_install/widget_install_context.h>
-#include <widget_install/widget_install_errors.h>
-
-#define WEBAPP_DEFAULT_UID 5000
-#define WEBAPP_DEFAULT_GID 5000
-
-namespace {
-const mode_t PRIVATE_STORAGE_MODE = 0700;
-}
-
-namespace Jobs {
-namespace WidgetInstall {
-TaskPrivateStorage::TaskPrivateStorage(InstallerContext& context) :
- DPL::TaskDecl<TaskPrivateStorage>(this),
- m_context(context)
-{
- AddStep(&TaskPrivateStorage::StepCreateDirectory);
-}
-
-void TaskPrivateStorage::StepCreateDirectory()
-{
- using namespace WrtDB;
-
- LogInfo("Step: Creating private storage directory.");
-
- m_context.installStep =
- InstallerContext::INSTALL_CREATE_PRIVATE_STORAGE;
-
- std::ostringstream widgetPath;
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if(!pkgname.IsNull()) {
- widgetPath << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- widgetPath << pkgname << "/";
- } else {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- if (access(widgetPath.str().c_str(), W_OK | X_OK) != 0) {
- ThrowMsg(Exceptions::InternalError, DPL::GetErrnoString());
- }
-
- std::ostringstream storagePath;
- storagePath << widgetPath.str().c_str()
- << GlobalConfig::GetWidgetPrivateStoragePath();
-
- if (access(storagePath.str().c_str(), F_OK) != 0) {
- FileUtils::MakePath(storagePath.str(), PRIVATE_STORAGE_MODE);
- // '5000' is default uid, gid for applications.
- // So installed applications should be launched as process of uid '5000'.
- // the process can access private directory 'data' of itself.
- if(chown(storagePath.str().c_str(),
- WEBAPP_DEFAULT_UID,
- WEBAPP_DEFAULT_GID) != 0)
- {
- ThrowMsg(Exceptions::InternalError,
- "Chown to invaild user");
- }
- } else if (access(storagePath.str().c_str(), W_OK | R_OK | X_OK) == 0) {
- LogInfo("Private storage already exists.");
- } else {
- ThrowMsg(Exceptions::InternalError,
- "No access to private storage.");
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_CREATE_PRIVATE_STORAGE,
- "Private storage created."
- );
-}
-} //namespace WidgetInstall
-} //namespace Jobs
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file task_private_storage.h
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @version 1.0
- * @brief Header file for installer task private storage.
- */
-#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PRIVATESTORAGE_H
-#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PRIVATESTORAGE_H
-
-#include <dpl/task.h>
-
-class InstallerContext;
-
-namespace Jobs {
-namespace WidgetInstall {
-class TaskPrivateStorage : public DPL::TaskDecl<TaskPrivateStorage>
-{
- public:
- explicit TaskPrivateStorage(InstallerContext& context);
-
- private:
- void StepCreateDirectory();
-
- private:
- InstallerContext& m_context;
-};
-} //namespace WidgetInstall
-} //namespace Jobs
-
-#endif
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file wrt_powder_info_util.h
- * @author Justyna Mejzner (j.kwiatkowsk@samsung.com)
- * @version 1.0
- */
-
-#include "wrt_powder_info_util.h"
-#include <dpl/singleton_impl.h>
-IMPLEMENT_SINGLETON(PowderInfoUtil)
-
-PowderInfoUtil::PowderInfoUtil()
-{
- m_categories[DPL::FromUTF8String("nu")] = "Nudity";
- m_categories[DPL::FromUTF8String("se")] = "Sex";
- m_categories[DPL::FromUTF8String("vi")] = "Violence";
- m_categories[DPL::FromUTF8String("la")] = "Potentially offensive language";
- m_categories[DPL::FromUTF8String("dr")] = "Drug use";
- m_categories[DPL::FromUTF8String("ga")] = "Gambling";
- m_categories[DPL::FromUTF8String("ha")] = "Hate or harmful activities";
- m_categories[DPL::FromUTF8String("ug")] = "Use of user-generated content";
-
- m_contexts[DPL::FromUTF8String("xa")] = "This material appears in"
- " an artistic conteaxt";
- m_contexts[DPL::FromUTF8String("xb")] = "This material appears in"
- " an educational context";
- m_contexts[DPL::FromUTF8String("xc")] = "This material appears in"
- " a medical context";
- m_contexts[DPL::FromUTF8String("xd")] = "This material appears in"
- " a sports context";
- m_contexts[DPL::FromUTF8String("xe")] = "This material appears in"
- " a violent context";
-}
-
-std::string PowderInfoUtil::getCategoryLabel(const DPL::String &category) const
-{
- CategoryMap::const_iterator categoryIterator = m_categories.find(category);
- if (categoryIterator == m_categories.end()) {
- ThrowMsg(PowderException::IncorrectTypeError,
- "Wrong type of category.");
- }
- return categoryIterator->second;
-}
-
-std::string PowderInfoUtil::getContextLabel(const DPL::String &context) const
-{
- ContextMap::const_iterator contextIterator = m_contexts.find(context);
- if (contextIterator == m_contexts.end()) {
- ThrowMsg(PowderException::IncorrectTypeError, "Wrong type of context.");
- }
- return contextIterator->second;
-}
-
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file wrt_powder_info_util.h
- * @author Justyna Mejzner (j.kwiatkowsk@samsung.com)
- * @version 1.0
- */
-
-#ifndef _WRT_SRC_INSTALLERCORE_POWDERINFOUTIL_H_
-#define _WRT_SRC_INSTALLERCORE_POWDERINFOUTIL_H_
-
-#include <map>
-
-#include <dpl/string.h>
-#include <dpl/singleton.h>
-
-class PowderInfoUtil
-{
- public:
- class PowderException
- {
- public:
- DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
- DECLARE_EXCEPTION_TYPE(Base, IncorrectTypeError)
- };
-
- std::string getCategoryLabel(const DPL::String &category) const;
- std::string getContextLabel(const DPL::String &context) const;
-
- private:
- PowderInfoUtil();
- friend class DPL::Singleton<PowderInfoUtil>;
-
- typedef std::map<DPL::String, std::string> CategoryMap;
- typedef std::map<DPL::String, std::string> ContextMap;
- CategoryMap m_categories;
- ContextMap m_contexts;
-};
-
-typedef DPL::Singleton<PowderInfoUtil> PowderInfoUtilSingleton;
-
-#endif /* _WRT_SRC_INSTALLERCORE_POWDERINFOUTIL_H_ */
-
+++ /dev/null
-/*
- * 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.
- */
-/*
- * @file ace_settings_logic.cpp
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This is an implementation of server of ACE user preferences
- */
-#include <ace_settings_logic.h>
-#include <ace_settings_server_factory.h>
-#include <dpl/foreach.h>
-#include <dpl/assert.h>
-#include <dpl/log/log.h>
-//#include <widget_controller.h>
-#include <dpl/localization/w3c_file_localization.h>
-#include <dpl/ace/PolicyEnforcementPoint.h>
-#include <dpl/ace/PolicyEvaluator.h>
-#include <dpl/ace/Preference.h>
-#include <dpl/wrt-dao-rw/feature_dao.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <vector>
-#include <map>
-
-#include <dpl/ace-dao-rw/AceDAO.h>
-#include <dpl/ace/SettingsLogic.h>
-#include <dpl/wrt-dao-rw/global_dao.h>
-
-using namespace WrtDB;
-
-namespace // anonymous
-{
-struct SubjectResource
-{
- WidgetHandle subject; // app_id
- std::string resource;
-
- SubjectResource(WidgetHandle subjectArg,
- const std::string& resourceArg) :
- subject(subjectArg),
- resource(resourceArg)
- {
- }
-
- bool operator < (const SubjectResource& subjectResource) const
- {
- if (subject != subjectResource.subject) {
- return subject < subjectResource.subject;
- } else {
- return resource < subjectResource.resource;
- }
- }
-};
-
-typedef std::map<SubjectResource, Preference> WidgetResourcePreferenceMap;
-} // namespace anonymous
-
-AceSettingsLogic::AceSettingsLogic(
- PolicyEnforcementPoint *policyEnforcementPoint) :
- m_policyEnforcementPoint(policyEnforcementPoint)
-{
- // Acquire ACE settings server from factory
- m_server = AceSettingsServerFactory::Create(this);
-}
-
-AceSettings::WidgetsPreferences AceSettingsLogic::getWidgetsPreferences() const
-{
- AceSettings::WidgetsPreferences widgetsPreferences;
- WidgetHandleList widgetHandleList = WidgetDAOReadOnly::getHandleList();
-
- DPL::ScopedPtr<WidgetResourcePreferenceMap> preferenceMap;
-
- PermissionList permissionTriple;
- SettingsLogic::getWidgetDevCapSettings(&permissionTriple);
-
- preferenceMap.Reset(new WidgetResourcePreferenceMap());
-
- FOREACH(permission, permissionTriple)
- {
- LogInfo("In db: " << permission->appId <<
- " " << permission->devCap);
- SubjectResource sb(permission->appId,
- permission->devCap);
- preferenceMap->insert(std::make_pair(sb, permission->access));
- }
-
- LogInfo("Sending Widget Resources");
-
- FOREACH(handle, widgetHandleList)
- {
- AceSettings::SubjectResourcePreferences subjectResourcePreferences;
- WidgetDAOReadOnly widget(*handle);
-
- //This has to be redesigned how to gather localized name of widget
-// auto lang = widget.getDefaultlocale();
-// if (!lang) lang = DPL::FromASCIIString("en");
-// WidgetLocalizedInfo info =
-// widget.getLocalizedInfo(*lang);
-//
-// DPL::Optional<DPL::String> optionalName = info.name;
-//
-// if (!!optionalName) {
-// LogDebug("optional name: " << (*optionalName));
-// subjectResourcePreferences.subject =
-// DPL::ToUTF8String(*optionalName);
-// } else {
-// subjectResourcePreferences.subject = "";
-// }
-
- WidgetFeatureSet featureSet = widget.getFeaturesList();
- SubjectResource subjectResource(*handle, "");
-
- DeviceCapabilitySet deviceCaps;
-
- FOREACH(feature, featureSet)
- {
- DeviceCapabilitySet thisFeatureDeviceCaps =
- GlobalDAO::GetDeviceCapability(feature->name);
- deviceCaps.insert(thisFeatureDeviceCaps.begin(),
- thisFeatureDeviceCaps.end());
- }
-
- FOREACH(deviceCap, deviceCaps)
- {
- AceSettings::ResourcePreference resourcePreferences;
- resourcePreferences.resource = DPL::ToUTF8String(*deviceCap);
-
- subjectResource.resource = resourcePreferences.resource;
- LogInfo("Looking for: " << subjectResource.subject <<
- " " << subjectResource.resource);
-
- if (preferenceMap) {
- WidgetResourcePreferenceMap::const_iterator preference =
- preferenceMap->find(subjectResource);
-
- if (preference != preferenceMap->end()) {
- LogInfo("Found not default preference!!");
- resourcePreferences.preference = preference->second;
- } else {
- resourcePreferences.preference = Preference::PREFERENCE_DEFAULT;
- }
- } else {
- resourcePreferences.preference = Preference::PREFERENCE_DEFAULT;
- }
-
- LogInfo("Pushing back resource preference");
-
- subjectResourcePreferences.resourcesPreference.
- push_back(resourcePreferences);
- }
-
- widgetsPreferences.subjectsResourcePreferences.push_back(
- subjectResourcePreferences);
- }
-
- return widgetsPreferences;
-}
-
-AceSettings::ResourcesPreferences AceSettingsLogic::getResourcesPreferences()
-const
-{
- AceSettings::ResourcesPreferences resourcesPreferences;
- PreferenceMap preferenceMap;
-
- SettingsLogic::getDevCapSettings(&preferenceMap);
-
- FeatureHandleList featureList = FeatureDAOReadOnly::GetHandleList();
-
- FOREACH(featureName, featureList)
- {
- FeatureDAOReadOnly featureDao(*featureName);
-
- AceSettings::ResourcePreference resourcePreference;
- resourcePreference.resource = featureDao.GetName();
-
- PreferenceMap::const_iterator preference =
- preferenceMap.find(resourcePreference.resource);
-
- if (preference != preferenceMap.end()) {
- resourcePreference.preference = preference->second;
- } else {
- resourcePreference.preference = Preference::PREFERENCE_DEFAULT;
- }
-
- resourcesPreferences.resourcesPreference.push_back(resourcePreference);
- }
-
- return resourcesPreferences;
-}
-
-void AceSettingsLogic::setWidgetPreference(const std::string &resource,
- WidgetHandle handler,
- const Preference &preference)
-{
- SettingsLogic::setWidgetDevCapSetting(resource, handler, preference);
-}
-
-void AceSettingsLogic::setResourcePreference(const std::string &resource,
- const Preference &preference)
-{
- SettingsLogic::setDevCapSetting(resource, preference);
-}
-
-bool AceSettingsLogic::getWidgetsSecure() const
-{
- return GlobalDAO::GetSecureByDefault();
-}
-
-void AceSettingsLogic::setWidgetsSecure(bool widgetSecure)
-{
- GlobalDAO::SetSecureByDefault(widgetSecure);
-}
-
-void AceSettingsLogic::resetWidgetsPreferences()
-{
- AceDB::AceDAO::clearWidgetDevCapSettings();
-}
-
-void AceSettingsLogic::resetResourcesPreferences()
-{
- AceDB::AceDAO::clearDevCapSettings();
-}
+++ /dev/null
-/*
- * 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.
- */
-/*
- * @file ace_settings_logic.h
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This is a header of server of ACE user preferences
- */
-#ifndef WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_ACE_SETTINGS_LOGIC_H_
-#define WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_ACE_SETTINGS_LOGIC_H_
-
-#include <dpl/shared_ptr.h>
-#include <i_ace_settings_server.h>
-#include <i_ace_settings_client.h>
-#include <string>
-
-#include <dpl/ace-dao-ro/wrt_db_types.h>
-
-class PolicyEnforcementPoint;
-
-class AceSettingsLogic
-{
- public:
- void setWidgetPreference(const std::string &resource,
- WidgetHandle handler,
- const AceDB::PreferenceTypes &preference);
-
- void setResourcePreference(const std::string &resource,
- const AceDB::PreferenceTypes &preference);
-
- AceSettings::WidgetsPreferences getWidgetsPreferences() const;
-
- AceSettings::ResourcesPreferences getResourcesPreferences() const;
-
- bool getWidgetsSecure() const;
-
- void setWidgetsSecure(bool widgetSecure);
-
- void resetWidgetsPreferences();
- void resetResourcesPreferences();
-
- private:
- AceSettingsLogic(PolicyEnforcementPoint *policyEnforcementPoint);
-
- friend class SecurityLogic;
- friend class PolicyEnforcementPoint;
-
- // PEP
- PolicyEnforcementPoint *m_policyEnforcementPoint;
-
- // Ace settings server (may be null)
- DPL::SharedPtr<IAceSettingsServer> m_server;
-};
-
-#endif // WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_ACE_SETTINGS_LOGIC_H_
+++ /dev/null
-/*
- * 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.
- */
-/**
- *
- * This file contains classes that implement WRT_INTERFACE.h interfaces,
- * so that ACE could access WRT specific and other information during
- * the decision making.
- *
- * @file attribute_.cpp
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Ming Jin(ming79.jin@samsung.com)
- * @version 1.0
- * @brief Implementation file for attributes obtaining.
- */
-
-#include <dpl/exception.h>
-#include <sstream>
-#include <algorithm>
-#include <list>
-#include <string>
-#include <sstream>
-#include <stdexcept>
-#include <map>
-#include <cstdlib>
-#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <dpl/wrt-dao-rw/feature_dao.h>
-#include <dpl/ace/WRT_INTERFACE.h>
-#include <map>
-#include <dpl/log/log.h>
-#include <attribute_facade.h>
-#include <dpl/ace/Request.h>
-#include <simple_roaming_agent.h>
-
-using namespace WrtDB;
-
-namespace // anonymous
-{
-typedef std::list<std::string> AttributeHandlerResponse;
-
-typedef AttributeHandlerResponse (*AttributeHandler)(
- const WidgetExecutionPhase &phase,
- const WidgetHandle &widgetHandle);
-typedef AttributeHandlerResponse (*ResourceAttributeHandler)(
- const WidgetExecutionPhase &phase,
- const WidgetHandle &widgetHandle,
- const Request &request);
-
-AttributeHandlerResponse AttributeClassHandler(const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle & /*widgetHandle*/)
-{
- AttributeHandlerResponse response;
- response.push_back("widget");
- return response;
-}
-
-AttributeHandlerResponse AttributeInstallUriHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- std::string value = dao.getShareHref();
-
- if (!value.empty()) {
- response.push_back(value);
- }
-
- return response;
-}
-
-AttributeHandlerResponse AttributeVersionHandler(const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- DPL::Optional<DPL::String> value = dao.getVersion();
-
- if (!!value) {
- response.push_back(DPL::ToUTF8String(*value));
- }
-
- return response;
-}
-
-AttributeHandlerResponse AttributeDistributorKeyCnHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
- WidgetCertificateData::ENDENTITY);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeDistributorKeyFingerprintHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
- WidgetCertificateData::ENDENTITY);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeDistributorKeyRootCnHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
- WidgetCertificateData::ROOT);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeDistributorKeyRootFingerprintHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
- WidgetCertificateData::ROOT);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeAuthorKeyCnHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyCommonNameList(WidgetCertificateData::AUTHOR,
- WidgetCertificateData::ENDENTITY);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeAuthorKeyFingerprintHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyFingerprints(WidgetCertificateData::AUTHOR,
- WidgetCertificateData::ENDENTITY);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeAuthorKeyRootCnHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyCommonNameList(WidgetCertificateData::AUTHOR,
- WidgetCertificateData::ROOT);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeAuthorKeyRootFingerprintHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- response = dao.getKeyFingerprints(WidgetCertificateData::AUTHOR,
- WidgetCertificateData::ROOT);
-
- return response;
-}
-
-AttributeHandlerResponse AttributeNetworkAccessUriHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle & /*widgetHandle*/)
-{
- AttributeHandlerResponse response;
- return response;
-}
-
-AttributeHandlerResponse AttributeIdHandler(const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
- WidgetGUID wGUID = dao.getGUID();
-
- if (!!wGUID) {
- response.push_back(DPL::ToUTF8String(*wGUID));
- }
- return response;
-}
-
-//AttributeHandlerResponse AttributeNameHandler(const WidgetExecutionPhase & /*phase*/,
-// const WidgetHandle &widgetHandle)
-//{
-// AttributeHandlerResponse response;
-//
-// WidgetLocalizedInfo info =
-// W3CFileLocalization::getLocalizedInfo(widgetHandle);
-//
-// DPL::Optional<DPL::String> val = info.name;
-// std::string value = !!val ? DPL::ToUTF8String(*val) : "";
-//
-// response.push_back(value);
-// return response;
-//}
-//
-//AttributeHandlerResponse AttributeWidgetAttrNameHandler(
-// const WidgetExecutionPhase & /*phase*/,
-// const WidgetHandle &widgetHandle)
-//{
-// AttributeHandlerResponse response;
-//
-// WidgetLocalizedInfo info =
-// W3CFileLocalization::getLocalizedInfo(widgetHandle);
-//
-// DPL::Optional<DPL::String> value = info.name;
-//
-// if (!!value) {
-// response.push_back(DPL::ToUTF8String(*value));
-// }
-//
-// return response;
-//}
-
-AttributeHandlerResponse AttributeAuthorNameHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle)
-{
- AttributeHandlerResponse response;
- WidgetDAOReadOnly dao(widgetHandle);
-
- DPL::Optional<DPL::String> value = dao.getAuthorName();
-
- if (!!value) {
- response.push_back(DPL::ToUTF8String(*value));
- }
-
- return response;
-}
-
-AttributeHandlerResponse AttributeRoamingHandler(
- const WidgetExecutionPhase &phase,
- const WidgetHandle & /*widgetHandle*/)
-{
- AttributeHandlerResponse response;
-
- if (WidgetExecutionPhase_WidgetInstall == phase) {
- // TODO undetermind value
- response.push_back(std::string(""));
- } else if (SimpleRoamingAgentSingleton::Instance().IsRoamingOn()) {
- response.push_back(std::string("true"));
- } else {
- response.push_back(std::string("false"));
- }
-
- return response;
-}
-
-AttributeHandlerResponse AttributeBearerTypeHandler(
- const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle & /*widgetHandle*/)
-{
- AttributeHandlerResponse response;
-
- std::string bearerName = "undefined-bearer-name";
-
- if (bearerName.empty()) {
- LogWarning("Bearer-type is NOT SET or empty");
- } else {
- response.push_back(bearerName);
- }
-
- return response;
-}
-
-struct AttributeHandlerContext
-{
- std::string name;
- WidgetExecutionPhase allowedPhaseMask;
- AttributeHandler handler;
-};
-
-// Private masks
-const WidgetExecutionPhase WidgetExecutionPhase_All =
- static_cast<WidgetExecutionPhase>(
- WidgetExecutionPhase_WidgetInstall |
- WidgetExecutionPhase_WidgetInstantiate |
- WidgetExecutionPhase_WebkitBind |
- WidgetExecutionPhase_Invoke);
-const WidgetExecutionPhase WidgetExecutionPhase_NoWidgetInstall =
- static_cast<WidgetExecutionPhase>(
- WidgetExecutionPhase_WidgetInstantiate |
- WidgetExecutionPhase_WebkitBind |
- WidgetExecutionPhase_Invoke);
-
-#define ALL_PHASE(name, handler) \
- { # name, WidgetExecutionPhase_All, handler },
-
-#define NO_INSTALL(name, handler) \
- { # name, WidgetExecutionPhase_NoWidgetInstall, handler },
-
-AttributeHandlerContext HANDLED_ATTRIBUTES_LIST[] = {
- ALL_PHASE(Class, &AttributeClassHandler)
- ALL_PHASE(install-uri, &AttributeInstallUriHandler)
- ALL_PHASE(version, &AttributeVersionHandler)
- ALL_PHASE(distributor-key-cn, &AttributeDistributorKeyCnHandler)
- ALL_PHASE(distributor-key-fingerprint,
- &AttributeDistributorKeyFingerprintHandler)
- ALL_PHASE(distributor-key-root-cn,
- &AttributeDistributorKeyRootCnHandler)
- ALL_PHASE(distributor-key-root-fingerprint,
- &AttributeDistributorKeyRootFingerprintHandler)
- ALL_PHASE(author-key-cn, &AttributeAuthorKeyCnHandler)
- ALL_PHASE(author-key-fingerprint, &AttributeAuthorKeyFingerprintHandler)
- ALL_PHASE(author-key-root-cn, &AttributeAuthorKeyRootCnHandler)
- ALL_PHASE(author-key-root-fingerprint,
- &AttributeAuthorKeyRootFingerprintHandler)
- ALL_PHASE(network-access-uri, &AttributeNetworkAccessUriHandler)
- ALL_PHASE(id, &AttributeIdHandler)
-// ALL_PHASE(name, &AttributeNameHandler)
-// ALL_PHASE(widget-attr:name, &AttributeWidgetAttrNameHandler)
- ALL_PHASE(author-name, &AttributeAuthorNameHandler)
- /* Enviroment attributes*/
- NO_INSTALL(roaming, &AttributeRoamingHandler)
- NO_INSTALL(bearer-type, &AttributeBearerTypeHandler)
-};
-
-#undef ALL_PHASE
-#undef NO_INSTALL
-
-const size_t HANDLED_ATTRIBUTES_LIST_COUNT =
- sizeof(HANDLED_ATTRIBUTES_LIST) / sizeof(HANDLED_ATTRIBUTES_LIST[0]);
-
-template<class T>
-class lambdaCollectionPusher
-{
- public:
- std::list<T>& m_collection;
- lambdaCollectionPusher(std::list<T>& collection) : m_collection(collection)
- {
- }
- void operator()(const T& element) const
- {
- m_collection.push_back(element);
- }
-};
-
-class lambdaWidgetPrefixEquality :
- public std::binary_function<WidgetFeature, std::string, bool>
-{
- public:
- bool operator()(const WidgetFeature& wFeature,
- const std::string& prefix) const
- {
- return wFeature.name.find(DPL::FromUTF8String(prefix)) !=
- DPL::String::npos;
- }
-};
-
-class lambdaWidgetNameEquality :
- public std::binary_function<WidgetFeature, std::string, bool>
-{
- public:
- bool operator()(const WidgetFeature& wFeature,
- const std::string& prefix) const
- {
- return wFeature.name == DPL::FromUTF8String(prefix);
- }
-};
-
-FeatureHandleList getFeatureHandleList(const WidgetHandle& widgetHandle,
- const std::string& resourceId)
-{
- FeatureHandleList featureHandleList;
- WidgetDAOReadOnly widgetDAO(widgetHandle);
- WidgetFeatureSet wFeatureSet = widgetDAO.getFeaturesList();
- WidgetFeatureSet::iterator foundFeatures =
- std::find_if(wFeatureSet.begin(),
- wFeatureSet.end(),
- std::bind2nd(lambdaWidgetPrefixEquality(), resourceId));
-
- if (foundFeatures != wFeatureSet.end()) {
- FeatureDAOReadOnly featureDAO(resourceId);
- featureHandleList.push_back(featureDAO.GetFeatureHandle());
- }
- return featureHandleList;
-}
-
-AttributeHandlerResponse AttributeDeviceCapHandler(const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle & /*widgetHandle*/,
- const Request &request)
-{
- AttributeHandlerResponse response;
-
- Request::DeviceCapabilitySet capSet = request.getDeviceCapabilitySet();
-
- std::for_each(
- capSet.begin(),
- capSet.end(),
- lambdaCollectionPusher<std::string>(response));
-
- return response;
-
- // We should return list of device-caps required by resourceId.
- // AttributeHandlerResponse response;
- //
- // FeatureHandleList fHandleList =
- // getFeatureHandleList(widgetHandle, resourceId);
- // if( !fHandleList.empty() )
- // {
- // FeatureDAO feature( resourceId );
- // std::set<std::string> deviceCapLast =
- // feature.GetDeviceCapabilities();
- // std::for_each(
- // deviceCapList.begin(),
- // deviceCapList.end(),
- // lambdaCollectionPusher<DeviceCapList::value_type>(
- // response) );
- // }
- // return response;
-}
-
-class lambdaFeatureEquality :
- public std::binary_function<FeatureHandle, int, bool>
-{
- public:
- bool operator()(const FeatureHandle& wFeature,
- const int& resurceId) const
- {
- return wFeature == resurceId;
- }
-};
-
-class lambdaPushFeatureName :
- public std::binary_function<WidgetFeature, AttributeHandlerResponse, void>
-{
- void operator()(const WidgetFeature& wFeature,
- AttributeHandlerResponse& response) const
- {
- response.push_back(DPL::ToUTF8String(wFeature.name));
- }
-};
-
-AttributeHandlerResponse AttributeApiFeatureHandler(
- const WidgetExecutionPhase & /* phase */,
- const WidgetHandle & /* widgetHandle */,
- const Request & /* request */)
-{
- LogDebug("WAC 2.0 does not support api-feature and resource-id in policy.");
- AttributeHandlerResponse response;
- return response;
- // Wrt shouldn't ask about resource which is not listed in
- // (widget) config.xml file
- //
- // AttributeHandlerResponse response;
- // WidgetDAOReadOnly widgetDAO(widgetHandle);
- // WidgetFeatureSet wFeatureSet = widgetDAO.GetFeaturesList();
- // std::string featureName = resourceId;
- // WidgetFeatureSet::iterator foundFeatures =
- // std::find_if(wFeatureSet.begin(),
- // wFeatureSet.end(),
- // std::bind2nd(lambdaWidgetPrefixEquality(),
- // featureName));
- //
- // while( foundFeatures != wFeatureSet.end() )
- // {
- // response.push_back( foundFeatures->name );
- // LogDebug("Found feature: " << foundFeatures->name );
- // foundFeatures++;
- // }
- //
- // return response;
-}
-
-typedef std::string (FeatureDAOReadOnly::*FNMETHOD)() const;
-
-AttributeHandlerResponse GetFeatureAttributeGroup(const WidgetExecutionPhase & /*phase*/,
- const WidgetHandle &widgetHandle,
- const std::string& resourceId,
- FNMETHOD function)
-{
- AttributeHandlerResponse response;
- FeatureHandleList fHandleList =
- getFeatureHandleList(widgetHandle, resourceId);
- if (!fHandleList.empty()) {
- FeatureDAOReadOnly featureDAO(fHandleList.front());
- std::string attribute = (featureDAO.*function)();
- response.push_back(attribute);
- }
- return response;
-}
-
-AttributeHandlerResponse AttributeFeatureInstallUriHandler(
- const WidgetExecutionPhase & /* phase */,
- const WidgetHandle & /* widgetHandle */,
- const Request & /* request */)
-{
- LogDebug("WAC 2.0 does not support feature-install-uri is policy!");
- AttributeHandlerResponse response;
- return response;
-}
-
-AttributeHandlerResponse AttributeFeatureFeatureKeyCnHandler(
- const WidgetExecutionPhase & /* phase */,
- const WidgetHandle & /* widgetHandle */,
- const Request & /* request */)
-{
- LogDebug("WAC 2.0 does not support feature-key-cn is policy!");
- AttributeHandlerResponse response;
- return response;
-}
-
-AttributeHandlerResponse AttributeFeatureKeyRootCnHandler(
- const WidgetExecutionPhase & /* phase */,
- const WidgetHandle & /* widgetHandle */,
- const Request & /* request */)
-{
- LogDebug("WAC 2.0 does not support feature-key-root-cn is policy!");
- AttributeHandlerResponse response;
- return response;
-}
-
-AttributeHandlerResponse AttributeFeatureKeyRootFingerprintHandler(
- const WidgetExecutionPhase & /* phase */,
- const WidgetHandle & /* widgetHandle */,
- const Request & /* request */)
-{
- LogDebug("WAC 2.0 does not support"
- " feature-key-root-fingerprint is policy!");
- AttributeHandlerResponse response;
- return response;
-}
-
-struct ResourceAttributeHandlerContext
-{
- std::string name;
- WidgetExecutionPhase allowedPhaseMask;
- ResourceAttributeHandler handler;
-};
-
-#define ALL_PHASE(name, handler) \
- { # name, WidgetExecutionPhase_All, handler },
-
-ResourceAttributeHandlerContext HANDLED_RESOURCE_ATTRIBUTES_LIST[] = {
- ALL_PHASE(device-cap, &AttributeDeviceCapHandler)
- ALL_PHASE(api-feature, &AttributeApiFeatureHandler)
- // [P.Fatyga] For compatiblity with older policies we tread resource-id
- // identically as api-feature
- ALL_PHASE(resource-id, &AttributeApiFeatureHandler)
-
- ALL_PHASE(feature-install-uri, &AttributeFeatureInstallUriHandler)
- ALL_PHASE(feature-key-cn, &AttributeFeatureFeatureKeyCnHandler)
- ALL_PHASE(feature-key-root-cn, &AttributeFeatureKeyRootCnHandler)
- ALL_PHASE(feature-key-root-fingerprint,
- &AttributeFeatureKeyRootFingerprintHandler)
-};
-
-#undef ALL_PHASE
-
-const size_t HANDLED_RESOURCE_ATTRIBUTES_LIST_COUNT =
- sizeof(HANDLED_RESOURCE_ATTRIBUTES_LIST) /
- sizeof(HANDLED_RESOURCE_ATTRIBUTES_LIST[0]);
-} // namespace anonymous
-
-/*
- * class WebRuntimeImpl
- */
-int WebRuntimeImpl::getAttributesValuesLoop(const Request &request,
- std::list<ATTRIBUTE>* attributes,
- WidgetExecutionPhase executionPhase)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- WidgetHandle widgetHandle = request.getWidgetHandle();
-
- FOREACH(itr, *attributes)
- {
- // Get attribute name
- std::string attribute = *itr->first;
-
- // Search for attribute handler
- bool attributeFound = false;
-
- for (size_t i = 0; i < HANDLED_ATTRIBUTES_LIST_COUNT; ++i) {
- if (HANDLED_ATTRIBUTES_LIST[i].name == attribute) {
- // Check if execution phase is valid
- if ((executionPhase &
- HANDLED_ATTRIBUTES_LIST[i].allowedPhaseMask) == 0) {
- // Attribute found, but execution state
- // forbids to execute handler
- LogWarning(
- "Request for attribute: '" <<
- attribute << "' which is supported " <<
- "but forbidden at widget execution phase: "
- <<
- executionPhase);
- } else {
- // Execution phase allows handler
- AttributeHandlerResponse attributeResponse =
- (*HANDLED_ATTRIBUTES_LIST[i].handler)(
- executionPhase,
- widgetHandle);
- std::copy(attributeResponse.begin(),
- attributeResponse.end(),
- std::back_inserter(*itr->second));
- }
-
- attributeFound = true;
- break;
- }
- }
-
- if (!attributeFound) {
- LogWarning("Request for attribute: '" <<
- attribute << "' which is not supported");
- }
- }
-
- return 0;
- }
- UNHANDLED_EXCEPTION_HANDLER_END
-}
-
-int WebRuntimeImpl::getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- // Get current execution state
- WidgetExecutionPhase executionPhase =
- request.getExecutionPhase();
-
- return getAttributesValuesLoop(request, attributes, executionPhase);
- }
- UNHANDLED_EXCEPTION_HANDLER_END
-}
-
-std::string WebRuntimeImpl::getSessionId(const Request & /* request */)
-{
- std::string result;
- LogError("Not implemented!");
- return result;
-}
-
-WebRuntimeImpl::WebRuntimeImpl()
-{
-}
-
-/*
- * class ResourceInformationImpl
- */
-
-int ResourceInformationImpl::getAttributesValuesLoop(const Request &request,
- std::list<ATTRIBUTE>* attributes,
- WidgetExecutionPhase executionPhase)
-{
- // Currently, we assume widgets have internal representation of integer IDs
- WidgetHandle widgetHandle = request.getWidgetHandle();
- //TODO add resource id string analyzys
- FOREACH(itr, *attributes)
- {
- // Get attribute name
- std::string attribute = *itr->first;
-
- // Search for attribute handler
- bool attributeFound = false;
-
- for (size_t i = 0; i < HANDLED_RESOURCE_ATTRIBUTES_LIST_COUNT; ++i) {
- if (HANDLED_RESOURCE_ATTRIBUTES_LIST[i].name == attribute) {
- // Check if execution phase is valid
- if ((executionPhase &
- HANDLED_RESOURCE_ATTRIBUTES_LIST[i].allowedPhaseMask) ==
- 0) {
- // Attribute found, but execution state
- // forbids to execute handler
- LogDebug(
- "Request for attribute: '" <<
- attribute <<
- "' which is supported but forbidden " <<
- "at widget execution phase: " << executionPhase);
- itr->second = NULL;
- } else {
- // Execution phase allows handler
- AttributeHandlerResponse attributeResponse =
- (*HANDLED_RESOURCE_ATTRIBUTES_LIST[i].handler)(
- executionPhase,
- widgetHandle,
- request);
- std::copy(attributeResponse.begin(),
- attributeResponse.end(),
- std::back_inserter(*itr->second));
-
- std::ostringstream attributeResponseFull;
-
- for (AttributeHandlerResponse::const_iterator
- it = attributeResponse.begin();
- it != attributeResponse.end(); ++it) {
- attributeResponseFull <<
- (it == attributeResponse.begin() ? "" : ", ") <<
- *it;
- }
-
- LogDebug("Attribute(" << attribute << ") = " <<
- attributeResponseFull.str());
- }
-
- attributeFound = true;
- break;
- }
- }
-
- if (!attributeFound) {
- LogWarning("Request for attribute: '" << attribute <<
- "' which is not supported");
- }
- }
- return 0;
-}
-
-int ResourceInformationImpl::getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- // Get current execution state
- WidgetExecutionPhase executionPhase =
- request.getExecutionPhase();
- return getAttributesValuesLoop(request, attributes, executionPhase);
- }
- UNHANDLED_EXCEPTION_HANDLER_END
-}
-
-ResourceInformationImpl::ResourceInformationImpl()
-{
-}
-
-/*
- * class OperationSystemImpl
- */
-
-int OperationSystemImpl::getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
- //FIXME:
- //GetExecution name without widget name
- WidgetExecutionPhase executionPhase =
- request.getExecutionPhase();
-
- FOREACH(itr, *attributes)
- {
- // Get attribute name
- std::string attribute = *itr->first;
-
- // Search for attribute handler
- bool attributeFound = false;
-
- for (size_t i = 0; i < HANDLED_ATTRIBUTES_LIST_COUNT; ++i) {
- if (HANDLED_ATTRIBUTES_LIST[i].name == attribute) {
- // Check if execution phase is valid
- if ((executionPhase &
- HANDLED_ATTRIBUTES_LIST[i].allowedPhaseMask) == 0) {
- // Attribute found, but execution state forbids
- // to execute handler
- LogDebug("Request for attribute: '" << attribute <<
- "' which is supported but forbidden at " <<
- "widget execution phase: " << executionPhase);
- itr->second = NULL;
- } else {
- // Execution phase allows handler
- AttributeHandlerResponse attributeResponse =
- (*HANDLED_ATTRIBUTES_LIST[i].handler)(
- executionPhase,
- 0);
- std::copy(attributeResponse.begin(),
- attributeResponse.end(),
- std::back_inserter(*itr->second));
-
- std::ostringstream attributeResponseFull;
-
- typedef AttributeHandlerResponse::const_iterator Iter;
- FOREACH(it, attributeResponse)
- {
- attributeResponseFull <<
- (it == attributeResponse.begin()
- ? "" : ", ") << *it;
- }
-
- LogDebug("Attribute(" << attribute <<
- ") = " << attributeResponseFull.str());
- }
-
- attributeFound = true;
- break;
- }
- }
-
- if (!attributeFound) {
- LogWarning("Request for attribute: '" << attribute <<
- "' which is not supported");
- }
- }
-
- return 0;
- }
- UNHANDLED_EXCEPTION_HANDLER_END
-}
-
-OperationSystemImpl::OperationSystemImpl()
-{
-}
-
-/*
- * end of class OperationSystemImpl
- */
-
-int FunctionParamImpl::getAttributesValues(const Request & /*request*/,
- std::list<ATTRIBUTE> *attributes)
-{
- FOREACH(iter, *attributes)
- {
- std::string attributeName = *(iter->first);
-
- ParamMap::const_iterator i;
- std::pair<ParamMap::const_iterator, ParamMap::const_iterator> jj =
- paramMap.equal_range(attributeName);
-
- for (i = jj.first; i != jj.second; ++i) {
- iter->second->push_back(i->second);
- LogDebug("Attribute: " << attributeName << " Value: " <<
- i->second);
- }
- }
- return 0;
-}
-
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file attribute_facade.h
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file contains the declaration of WebRuntimeImpl,
- * ResourceInformationImpl, OperationSystemImpl
- */
-
-#ifndef ATTRIBUTE_FACADE_H
-#define ATTRIBUTE_FACADE_H
-
-#include <string>
-#include <map>
-#include <vector>
-
-#include <dpl/ace/WRT_INTERFACE.h>
-
-class Request;
-
-class WebRuntimeImpl : public IWebRuntime
-{
- public:
- // Return current sessionId
- int getAttributesValuesLoop(const Request &request,
- std::list<ATTRIBUTE>* attributes,
- WidgetExecutionPhase executionPhase);
-
- int getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes);
- virtual std::string getSessionId(const Request &request);
- WebRuntimeImpl();
-};
-
-class ResourceInformationImpl : public IResourceInformation
-{
- public:
- int getAttributesValuesLoop(const Request &request,
- std::list<ATTRIBUTE>* attributes,
- WidgetExecutionPhase executionPhase);
- int getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes);
- ResourceInformationImpl();
-};
-
-class OperationSystemImpl : public IOperationSystem
-{
- public:
- /**
- * gather and set attributes values for specified attribute name
- * @param attributes is a list of pairs(
- * first: pointer to attribute name
- * second: list of values for attribute (std::string) -
- * its a list of string (BONDI requirement), but usually there
- * will be only one string
- */
- int getAttributesValues(const Request &request,
- std::list<ATTRIBUTE>* attributes);
- OperationSystemImpl();
-};
-
-class FunctionParamImpl : public IFunctionParam
-{
- public:
- virtual int getAttributesValues(const Request & /*request*/,
- std::list<ATTRIBUTE> *attributes);
- void addAttribute(const std::string &key,
- const std::string &value)
- {
- paramMap.insert(make_pair(key, value));
- }
- virtual ~FunctionParamImpl()
- {
- }
-
- private:
- typedef std::multimap<std::string, std::string> ParamMap;
- ParamMap paramMap;
-};
-
-typedef std::vector <FunctionParamImpl> FunctionParams;
-
-#endif //ATTRIBUTE_FACADE_H
+++ /dev/null
-/*
- * 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.
- */
-/*
- *
- * @file i_ace_settings.h
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @version 1.0
- * @brief This is header file for preference settings interface between
- * security controller and clients
- */
-
-#ifndef WRT_SRC_ACCESS_CONTROL_I_ACE_PERMISSSIONS_H_
-#define WRT_SRC_ACCESS_CONTROL_I_ACE_PERMISSSIONS_H_
-
-#include <vector>
-#include <dpl/ace-dao-ro/PreferenceTypes.h>
-
-namespace AceSettings {
-
-struct ResourcePreference
-{
- std::string resource;
- AceDB::PreferenceTypes preference;
-
- ResourcePreference()
- {
- }
-
- ResourcePreference(const std::string &resourceArg,
- const AceDB::PreferenceTypes &preferenceArg) :
- resource(resourceArg),
- preference(preferenceArg)
- {
- }
-};
-
-struct SubjectResourcePreferences
-{
- std::string subject;
- std::vector<ResourcePreference> resourcesPreference;
-
- SubjectResourcePreferences()
- {
- }
-
- SubjectResourcePreferences(
- const std::string &subjectArg,
- const std::vector<ResourcePreference> &resourcesPreferenceArg) :
- subject(subjectArg),
- resourcesPreference(resourcesPreferenceArg)
- {
- }
-};
-
-struct WidgetsPreferences
-{
- std::vector<SubjectResourcePreferences> subjectsResourcePreferences;
-};
-
-struct ResourcesPreferences
-{
- std::vector<ResourcePreference> resourcesPreference;
-};
-
-} // end of namespace AceSettings
-
-#endif /* WRT_SRC_ACCESS_CONTROL_I_ACE_PERMISSSIONS_H_ */
+++ /dev/null
-/*
- * 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.
- */
-/*
- * @file i_ace_settings_client.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This is a header file for interface of ACE settings client
- */
-#ifndef WRT_SRC_UI_SHARED_GADGET_IACESETTINGSCLIENT_H_
-#define WRT_SRC_UI_SHARED_GADGET_IACESETTINGSCLIENT_H_
-
-#include <dpl/fast_delegate.h>
-#include <dpl/ace-dao-ro/PreferenceTypes.h>
-#include <string>
-#include <vector>
-#include <i_ace_permissions.h>
-
-namespace AceSettings {
-
-class IClient
-{
- public:
- typedef DPL::FastDelegate<void (const WidgetsPreferences &preferences)>
- GetWidgetsPreferencesDelegate;
-
- typedef DPL::FastDelegate<void (const ResourcesPreferences &preferences)>
- GetResourcesPreferencesDelegate;
-
- virtual void setWidgetPreference(const std::string &resource,
- const std::string &widget,
- const AceDB::PreferenceTypes &preference) = 0;
-
- virtual void setResourcePreference(const std::string &resource,
- const AceDB::PreferenceTypes &preference) = 0;
-
- virtual void asyncGetWidgetsPreferences(
- GetWidgetsPreferencesDelegate delegate) = 0;
-
- virtual void asyncGetResourcesPreferences(
- GetResourcesPreferencesDelegate delegate) = 0;
-
- virtual void resetWidgetsPreferences() = 0;
- virtual void resetResourcesPreferences() = 0;
-
- virtual ~IClient()
- {
- }
-};
-} // namespace AceSettings
-
-#endif // WRT_SRC_UI_SHARED_GADGET_IACESETTINGSCLIENT_H_
+++ /dev/null
-/*
- * 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.
- */
-/*
- * @file i_ace_settings_server.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This is a header of server of ACE user preferences
- */
-#ifndef WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_I_ACE_SETTINGS_SERVER_H_
-#define WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_I_ACE_SETTINGS_SERVER_H_
-
-class IAceSettingsServer
-{
- public:
- virtual ~IAceSettingsServer()
- {
- }
-
- protected:
- IAceSettingsServer()
- {
- }
-};
-
-#endif // WRT_SRC_ACCESS_CONTROL_IPC_SETTINGS_I_ACE_SETTINGS_SERVER_H_
+++ /dev/null
-/*
- * 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.
- */
-/**
- * This class simply redirects the access requests to access control engine.
- * The aim is to hide access control engine specific details from WRT modules.
- * It also implements WRT_INTERFACE.h interfaces, so that ACE could access
- * WRT specific and other information during the decision making.
- *
- * @file security_controller.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Ming Jin(ming79.jin@samsung.com)
- * @version 1.0
- * @brief Implementation file for security controller
- */
-#include <security_controller.h>
-
-#include <dpl/ace/PolicyEnforcementPoint.h>
-#include <dpl/ace/WRT_INTERFACE.h>
-#include <dpl/ace/PolicyEvaluatorFactory.h>
-#include <dpl/singleton_impl.h>
-#include <dpl/log/log.h>
-
-#include <attribute_facade.h>
-#include <security_logic.h>
-
-IMPLEMENT_SINGLETON(SecurityController)
-
-struct SecurityController::Impl
-{
- SecurityLogic logic;
-};
-
-SecurityController::SecurityController()
-{
- m_impl.Reset(new Impl);
-}
-
-SecurityController::~SecurityController()
-{
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::InitializeSyncEvent & /* event */)
-{
- m_impl->logic.initialize();
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::TerminateSyncEvent & /*event*/)
-{
- m_impl->logic.terminate();
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::AuthorizeWidgetInstallEvent &event)
-{
- m_impl->logic.authorizeWidgetInstall(event.GetArg0(), event.GetArg1());
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::CheckFunctionCallSyncEvent &ev)
-{
- *ev.GetArg0() = m_impl->logic.checkFunctionCall(ev.GetArg1());
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::SetWidgetPreferenceEvent & /*event*/)
-{
-// m_impl->logic.setWidgetPreference(event.GetArg0(),
-// event.GetArg1(),
-// event.GetArg2());
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::SetResourcePreferenceEvent & /*event*/)
-{
-// m_impl->logic.setResourcePreference(event.GetArg0(), event.GetArg1());
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::GetWidgetsPreferencesSyncEvent & /*event*/)
-{
-// *event.GetArg0() = m_impl->logic.getWidgetsPreferences();
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::GetResourcesPreferencesSyncEvent & /*event*/)
-{
-// *event.GetArg0() = m_impl->logic.getResourcesPreferences();
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::ResetWidgetsPreferencesEvent & /*evt*/)
-{
-// m_impl->logic.resetWidgetsPreferences();
-}
-
-void SecurityController::OnEventReceived(
- const SecurityControllerEvents::ResetResourcesPreferencesEvent & /*evt*/)
-{
-// m_impl->logic.resetResourcesPreferences();
-}
+++ /dev/null
-/*
- * 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.
- */
-/**
- * This class simply redirects the access requests to access control engine.
- * The aim is to hide access control engine specific details from WRT modules.
- * It also implements WRT_INTERFACE.h interfaces, so that ACE could access
- * WRT specific and other information during the decision making.
- *
- * @file security_controller.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Ming Jin(ming79.jin@samsung.com)
- * @version 1.0
- * @brief Header file for security controller
- */
-#ifndef SECURITY_CONTROLLER_H
-#define SECURITY_CONTROLLER_H
-
-#include <dpl/singleton.h>
-#include <dpl/event/controller.h>
-#include <dpl/generic_event.h>
-#include <dpl/scoped_ptr.h>
-#include <dpl/type_list.h>
-#include <string>
-#include <ace_settings_logic.h>
-#include <dpl/ace-dao-ro/PreferenceTypes.h>
-#include <dpl/ace/AbstractPolicyEnforcementPoint.h>
-
-#include <string>
-#include <dpl/event/inter_context_delegate.h>
-
-#include <dpl/ace-dao-ro/wrt_db_types.h>
-
-namespace Jobs {
-class Job;
-}
-
-namespace SecurityControllerEvents {
-DECLARE_GENERIC_EVENT_0(InitializeSyncEvent)
-DECLARE_GENERIC_EVENT_0(TerminateSyncEvent)
-
-DECLARE_GENERIC_EVENT_2(AuthorizeWidgetInstallEvent,
- Request *,
- AbstractPolicyEnforcementPoint::ResponseReceiver)
-
-DECLARE_GENERIC_EVENT_2(CheckFunctionCallSyncEvent,
- PolicyResult *,
- Request *)
-
-DECLARE_GENERIC_EVENT_3(SetWidgetPreferenceEvent,
- std::string, // resource,
- WidgetHandle, // subject
- AceDB::PreferenceTypes) // preference
-
-DECLARE_GENERIC_EVENT_2(SetResourcePreferenceEvent,
- std::string, // resource,
- AceDB::PreferenceTypes) // preference
-
-DECLARE_GENERIC_EVENT_1(GetWidgetsPreferencesSyncEvent,
- AceSettings::WidgetsPreferences *)
-
-DECLARE_GENERIC_EVENT_1(GetResourcesPreferencesSyncEvent,
- AceSettings::ResourcesPreferences *)
-
-DECLARE_GENERIC_EVENT_0(ResetWidgetsPreferencesEvent)
-DECLARE_GENERIC_EVENT_0(ResetResourcesPreferencesEvent)
-} // namespace SecurityControllerEvents
-
-typedef DPL::TypeListDecl<
- SecurityControllerEvents::InitializeSyncEvent,
- SecurityControllerEvents::TerminateSyncEvent,
- SecurityControllerEvents::AuthorizeWidgetInstallEvent,
- SecurityControllerEvents::CheckFunctionCallSyncEvent,
- SecurityControllerEvents::SetWidgetPreferenceEvent,
- SecurityControllerEvents::SetResourcePreferenceEvent,
- SecurityControllerEvents::GetWidgetsPreferencesSyncEvent,
- SecurityControllerEvents::GetResourcesPreferencesSyncEvent,
- SecurityControllerEvents::ResetWidgetsPreferencesEvent,
- SecurityControllerEvents::ResetResourcesPreferencesEvent>::Type
-SecurityControllerEventsTypeList;
-
-class SecurityController :
- public DPL::Event::Controller<SecurityControllerEventsTypeList>
-{
- protected:
- virtual void OnEventReceived(
- const SecurityControllerEvents::InitializeSyncEvent &event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::TerminateSyncEvent &event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::AuthorizeWidgetInstallEvent &event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::CheckFunctionCallSyncEvent &e);
- virtual void OnEventReceived(
- const SecurityControllerEvents::SetWidgetPreferenceEvent &event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::SetResourcePreferenceEvent &event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::GetWidgetsPreferencesSyncEvent &
- event);
- virtual void OnEventReceived(
- const SecurityControllerEvents::GetResourcesPreferencesSyncEvent &
- evt);
- virtual void OnEventReceived(
- const SecurityControllerEvents::ResetWidgetsPreferencesEvent &evt);
- virtual void OnEventReceived(
- const SecurityControllerEvents::ResetResourcesPreferencesEvent &
- evt);
-
- private:
- class Impl;
- DPL::ScopedPtr<Impl> m_impl;
-
- SecurityController();
- //This desctructor must be in implementation file (cannot be autogenerated)
- ~SecurityController();
-
- friend class DPL::Singleton<SecurityController>;
-};
-
-typedef DPL::Singleton<SecurityController> SecurityControllerSingleton;
-
-#endif // SECURITY_CONTROLLER_H
+++ /dev/null
-/*
- * 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.
- */
-/**
- * This class simply redirects the access requests to access control engine.
- * The aim is to hide access control engine specific details from WRT modules.
- * It also implements WRT_INTERFACE.h interfaces, so that ACE could access
- * WRT specific and other information during the decision making.
- *
- * @file security_controller.h
- # @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Ming Jin(ming79.jin@samsung.com)
- * @author Piotr Kozbial (p.kozbial@samsung.com)
- * @version 1.0
- * @brief Header file for security logic
- */
-
-#include <dpl/ace/PromptDecision.h>
-#include <security_logic.h>
-#include <attribute_facade.h>
-#ifdef WRT_SMACK_ENABLED
-#include <privilege-control.h>
-#endif
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-
-void SecurityLogic::initialize() {
- m_policyEnforcementPoint.initialize(new WebRuntimeImpl(),
- new ResourceInformationImpl(),
- new OperationSystemImpl());
-}
-
-void SecurityLogic::terminate() {
- m_policyEnforcementPoint.terminate();
-}
-
-void SecurityLogic::authorizeWidgetInstall(
- Request *request,
- AbstractPolicyEnforcementPoint::ResponseReceiver receiver)
-{
- PolicyResult result = m_policyEnforcementPoint.check(*request);
-
- // this is bad idea, what about context in request ??
- // We could resolve problem with memory allocation by adding default
- // constructor to Request and pass object by value.
- delete request;
-
- receiver(result);
-}
-
-PolicyResult SecurityLogic::checkFunctionCall(Request* request)
-{
- PolicyResult aceResult = m_policyEnforcementPoint.check(*request);
- if (aceResult == PolicyEffect::PERMIT) {
-#ifdef WRT_SMACK_ENABLED
- try {
- WrtDB::WidgetDAOReadOnly dao(request->getWidgetHandle());
- DPL::OptionalString pkgName = dao.getPkgname();
- Assert(!pkgName.IsNull() && "widget doesn't have a pkg name");
- const char *devCap = "";
- int ret = grant_rules_forWAC(DPL::ToUTF8String(*pkgName).c_str(), devCap);
- Assert(ret==PC_OPERATION_SUCCESS && "smack rules couldn't be granted");
- } catch (WrtDB::WidgetDAOReadOnly::Exception) {
- Assert(false && "can't access widget data");
- }
-#endif
- return PolicyEffect::PERMIT;
- } else if (aceResult == PolicyEffect::PROMPT_ONESHOT ||
- aceResult == PolicyEffect::PROMPT_SESSION ||
- aceResult == PolicyEffect::PROMPT_BLANKET)
- {
- // TODO: check stored user answers!!!
- // if necessary, grant SMACK rules
- // return appropriately - the following is a dummy:
- return aceResult;
- } else {
- return PolicyEffect::DENY;
- }
-}
-
-//void SecurityLogic::setWidgetPreference(
-// std::string devCap,
-// WidgetHandle widgetHandle,
-// AceDB::PreferenceTypes preference)
-//{
-// m_aceSettingsLogic.setWidgetPreference(devCap,
-// widgetHandle,
-// preference);
-//}
-//
-//void SecurityLogic::setResourcePreference(
-// std::string devCap,
-// AceDB::PreferenceTypes preference)
-//{
-// m_aceSettingsLogic.setResourcePreference(devCap, preference);
-//}
-//
-//AceSettings::WidgetsPreferences SecurityLogic::getWidgetsPreferences() {
-// return m_aceSettingsLogic.getWidgetsPreferences();
-//}
-//
-//AceSettings::ResourcesPreferences SecurityLogic::getResourcesPreferences() {
-// return m_aceSettingsLogic.getResourcesPreferences();
-//}
-//
-//void SecurityLogic::resetWidgetsPreferences() {
-// m_aceSettingsLogic.resetWidgetsPreferences();
-//}
-//
-//void SecurityLogic::resetResourcesPreferences() {
-// m_aceSettingsLogic.resetResourcesPreferences();
-//}
+++ /dev/null
-/*
- * 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.
- */
-/**
- * This class simply redirects the access requests to access control engine.
- * The aim is to hide access control engine specific details from WRT modules.
- * It also implements WRT_INTERFACE.h interfaces, so that ACE could access
- * WRT specific and other information during the decision making.
- *
- * @file security_logic.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @author Ming Jin(ming79.jin@samsung.com)
- * @author Piotr Kozbial (p.kozbial@samsung.com)
- * @version 1.0
- * @brief Header file for security logic
- */
-#ifndef SECURITY_LOGIC_H
-#define SECURITY_LOGIC_H
-
-#include <dpl/ace/Request.h>
-#include <dpl/ace/PolicyResult.h>
-#include <dpl/ace/AbstractPolicyEnforcementPoint.h>
-#include <dpl/ace/Preference.h>
-#include <i_ace_settings_client.h>
-#include <dpl/ace/PolicyEnforcementPoint.h>
-
-//#include "ace_settings_logic.h"
-
-/* SecurityLogic
- * May only be created and used by SecurityController.
- * There may be only one instance.
- */
-class SecurityLogic {
- public:
- SecurityLogic() {}
- ~SecurityLogic() {}
- // initialize/terminate
- /** */
- void initialize();
- /** */
- void terminate();
- // access control checkpoints
- /** */
- void authorizeWidgetInstall(
- Request *,
- AbstractPolicyEnforcementPoint::ResponseReceiver);
- /** */
- PolicyResult checkFunctionCall(Request*);
- // access control user settings
- /** */
-// void setWidgetPreference(
-// std::string devCap,
-// WidgetHandle widgetHandle,
-// AceDB::PreferenceTypes preference);
-// /** */
-// void setResourcePreference(
-// std::string devCap,
-// AceDB::PreferenceTypes preference);
- /** */
-// AceSettings::WidgetsPreferences getWidgetsPreferences();
- /** */
-// AceSettings::ResourcesPreferences getResourcesPreferences();
- /** */
-// void resetWidgetsPreferences();
- /** */
-// void resetResourcesPreferences();
- private:
- PolicyEnforcementPoint m_policyEnforcementPoint;
-// AceSettingsLogic m_aceSettingsLogic;
-};
-
-#endif // SECURITY_CONTROLLER_H
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file simple_roaming_agent.cpp
- * @author Pawel Sikorski (p.sikorski@samsung.com)
- * @author Lukasz Marek (l.marek@samsung.com)
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 1.0
- * @brief roaming agent
- */
-
-#include "simple_roaming_agent.h"
-#include <vconf.h>
-#include <dpl/fast_delegate.h>
-#include <dpl/log/log.h>
-#include <dpl/singleton_impl.h>
-IMPLEMENT_SINGLETON(SimpleRoamingAgent)
-
-SimpleRoamingAgent::SimpleRoamingAgent()
-{
- if (vconf_notify_key_changed(
- VCONFKEY_TELEPHONY_SVC_ROAM,
- vConfChagedCallback, this) < 0)
- {
- LogError("Cannot add vconf callback [" <<
- VCONFKEY_TELEPHONY_SVC_ROAM << "]");
- Assert(false && "Cannot add vconf callback");
- }
-
- int result = 0;
- if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &result) != 0) {
- LogError("Cannot get current roaming status");
- Assert(false && "Cannot get current roaming status");
- } else {
- bool type = (result == VCONFKEY_TELEPHONY_SVC_ROAM_ON);
- m_networkType = type ? ROAMING : HOME;
- LogInfo("Network type is " << (type ? "ROAMING" : "HOME"));
- }
-
-}
-
-SimpleRoamingAgent::~SimpleRoamingAgent()
-{
- if (vconf_ignore_key_changed(
- VCONFKEY_TELEPHONY_SVC_ROAM,
- vConfChagedCallback) < 0)
- {
- LogError("Cannot rm vconf callback [" <<
- VCONFKEY_TELEPHONY_SVC_ROAM << "]");
- Assert(false && "Cannot remove vconf callback");
- }
-
-}
-
-void SimpleRoamingAgent::vConfChagedCallback(keynode_t *keyNode, void *data)
-{
- LogInfo("SimpleRoamingAgent::vConfChagedCallback ");
- char *key = vconf_keynode_get_name(keyNode);
-
- if (NULL == key) {
- LogWarning("vconf key is null.");
- return;
- }
- SimpleRoamingAgent *agent = static_cast<SimpleRoamingAgent *>(data);
- if (NULL == agent) {
- LogError("Bad user arg from vconf lib");
- Assert(false && "Bad user arg from vconf lib");
- return;
- }
- int result = 0;
- if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &result) != 0) {
- LogError("Cannot get current roaming status");
- Assert(false && "Cannot get current roaming status");
- } else {
- bool type = (result == VCONFKEY_TELEPHONY_SVC_ROAM_ON);
- agent->m_networkType = type ? ROAMING : HOME;
- LogInfo("Network type is " << (type ? "ROAMING" : "HOME"));
- }
-}
+++ /dev/null
-/*
- * 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.
- */
-/**
- * @file simple_roaming_agent.h
- * @author Pawel Sikorski (p.sikorski@samsung.com)
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 1.0
- * @brief simple roaming agent
- */
-
-#ifndef WRT_SRC_ACCESS_CONTROL_COMMON_SIMPLE_ROAMING_AGENT_H_
-#define WRT_SRC_ACCESS_CONTROL_COMMON_SIMPLE_ROAMING_AGENT_H_
-
-#include <string>
-#include <dpl/singleton.h>
-#include <dpl/noncopyable.h>
-#include <vconf.h>
-
-class SimpleRoamingAgent : DPL::Noncopyable
-{
- public:
- bool IsRoamingOn() const
- {
- return ROAMING == m_networkType;
- }
-
- private:
- enum NetworkType {ROAMING, HOME};
-
- NetworkType m_networkType;
-
- SimpleRoamingAgent();
- virtual ~SimpleRoamingAgent();
-
- static void vConfChagedCallback(keynode_t *keyNode, void *userParam);
-
- friend class DPL::Singleton<SimpleRoamingAgent>;
-};
-
-typedef DPL::Singleton<SimpleRoamingAgent> SimpleRoamingAgentSingleton;
-
-#endif//WRT_SRC_ACCESS_CONTROL_COMMON_SIMPLE_ROAMING_AGENT_H_
+++ /dev/null
-# 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.
-#
-# @file CMakeLists.txt
-# @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
-# @version 1.0
-# @brief
-#
-
-#
-# Test files
-#
-# Define all WRT tests sources.
-# Runner is responsible for runnint it all and
-# generating proper output files
-#
-
-ADD_SUBDIRECTORY(config_generator)
\ No newline at end of file
+++ /dev/null
-# 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.
-#
-# @file CMakeLists.txt
-# @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
-# @version 1.0
-# @brief
-#
-
-# TODO create and use common test build framework as in wrt.
-
-PKG_CHECK_MODULES(TEST_DEPS
- dpl-efl
- dpl-test-efl
- libxml-2.0
- REQUIRED
- )
-
-#target
-SET(TARGET_CONFIG_GEN_TEST "wrt-tests-config-gen")
-
-#sources
-FILE(GLOB CONFIG_GEN_TEST_SOURCES
- ${PROJECT_SOURCE_DIR}/tests/config_generator/*.cpp
- )
-
-# includes
-INCLUDE_DIRECTORIES(
- ${PROJECT_SOURCE_DIR}/src/config_generator/
- ${TEST_DEPS_INCLUDE_DIRS}
-)
-
-# executable
-ADD_EXECUTABLE(${TARGET_CONFIG_GEN_TEST} ${CONFIG_GEN_TEST_SOURCES})
-
-#libraries
-TARGET_LINK_LIBRARIES(${TARGET_CONFIG_GEN_TEST}
- ${TARGET_CONFIG_GEN_LIB}
- ${TEST_DEPS_LIBRARIES}
- )
-
-# xml files
-FILE(GLOB CONFIG_GEN_XML_FILES
- ${PROJECT_SOURCE_DIR}/tests/config_generator/xml/*.xml
- )
-
-INSTALL(FILES ${CONFIG_GEN_XML_FILES} DESTINATION /opt/apps/config_gen)
-
-# install
-SET_TARGET_PROPERTIES(${TARGET_CONFIG_GEN_TEST} PROPERTIES
- BUILD_WITH_INSTALL_RPATH ON
- INSTALL_RPATH_USE_LINK_PATH ON
-)
-
-INSTALL(TARGETS ${TARGET_CONFIG_GEN_TEST}
- DESTINATION bin
- PERMISSIONS OWNER_READ
- OWNER_WRITE
- OWNER_EXECUTE
- GROUP_READ
- GROUP_EXECUTE
- WORLD_READ
- WORLD_EXECUTE
-)
\ No newline at end of file
+++ /dev/null
-/*
- * 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.
- */
-/*
- * @file TestCases.cpp
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @version 1.0
- */
-
-#include <dpl/test/test_runner.h>
-#include <dpl/binary_queue.h>
-#include <dpl/file_output.h>
-#include <dpl/file_input.h>
-#include <dpl/log/log.h>
-#include <dpl/foreach.h>
-#include <config_generator.h>
-#include <libxml/parser.h>
-#include <stdio.h>
-#include <list>
-#include <string>
-#include <unistd.h>
-#include <fcntl.h>
-#include <memory>
-
-namespace {
-
-std::string g_expectedFile;
-std::string g_resultFile;
-
-const char* cNull = NULL;
-
-} // namespace
-
-// helper macros
-#define TEST_START(name) \
- RUNNER_TEST(name) \
- { \
- g_expectedFile = "/opt/apps/config_gen/" #name ".xml"; \
- g_resultFile = "/opt/apps/config_gen/" #name "_result.xml";
-
-#define TEST_END }
-
-#define CURRENT_TEST() *g_testnames.rbegin()
-
-namespace {
-
-// Displays the document in logs
-void DisplayResult(ConfigXml::DocumentPtr doc)
-{
- DPL::BinaryQueue bq;
- doc->Write(bq);
-
- std::unique_ptr<char[]> buffer(new char[bq.Size()]);
-
- bq.FlattenConsume(buffer.get(),bq.Size());
- LogInfo("Generated XML:\n\n" << buffer.get());
-}
-
-// Save the document to file
-void SaveResult(ConfigXml::DocumentPtr doc)
-{
- remove(g_resultFile.c_str());
- DPL::FileOutput fo(g_resultFile);
- doc->Write(fo);
- fo.Close();
-}
-
-void closeFile(int* fd)
-{
- close(*fd);
-}
-
-/*
- * Simple XML comparison method. Performs simple character by character
- * comparison (ignores whitespaces). Sensitive to element order and formatting.
- * Does not ignore comments.
- */
-void CompareResult()
-{
- LogDebug("Comparing " << g_expectedFile << " and " << g_resultFile);
-
- typedef std::unique_ptr<int,void (*)(int*)> FilePtr;
-
- // open expected
- int efd = TEMP_FAILURE_RETRY(
- open(g_expectedFile.c_str(), O_RDONLY | O_NONBLOCK));
- RUNNER_ASSERT_MSG(efd != -1, "Failed to open " << g_expectedFile);
- FilePtr efdPtr(&efd, closeFile);
-
- // open result
- int rfd = TEMP_FAILURE_RETRY(
- open(g_resultFile.c_str(), O_RDONLY | O_NONBLOCK));
- RUNNER_ASSERT_MSG(rfd != -1, "Failed to open " << g_resultFile);
- FilePtr rfdPtr(&rfd, closeFile);
-
- bool eEOF = false;
- bool rEOF = false;
- for(;!eEOF && !rEOF;) {
- unsigned char eChar;
- unsigned char rChar;
-
- // read expected
- do {
- if(0 == TEMP_FAILURE_RETRY(read(efd, &eChar, 1))) {
- eEOF = true;
- break;
- }
- } while(!isgraph(eChar));
-
- // read result
- do {
- if(0 == TEMP_FAILURE_RETRY(read(rfd, &rChar, 1))) {
- rEOF = true;
- break;
- }
- } while(!isgraph(rChar));
-
- // compare
- if(!eEOF && !rEOF) {
- RUNNER_ASSERT_MSG(
- eChar == rChar,
- "Difference '" << eChar << "' != '" << rChar << "'");
- }
- }
- RUNNER_ASSERT_MSG(eEOF == rEOF, "Different number of characters");
-
- LogDebug("Finished");
-}
-
-void DisplaySaveAndCompare(ConfigXml::DocumentPtr doc)
-{
- DisplayResult(doc);
- SaveResult(doc);
- CompareResult();
-}
-
-} // namespace
-
-TEST_START(test001_basic)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- doc->Add<ConfigXml::WIDGET>("http://example.org/exampleWidget",
- "2.0 Beta",
- 640,
- 480);
- DisplaySaveAndCompare(doc);
-TEST_END
-
-TEST_START(test002_basic)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- doc->Add<ConfigXml::WIDGET>("http://example.org/exampleWidget",
- "2.0 Beta",
- "fullscreen");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test003_name)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::NAME>(cNull);
- root->Add<ConfigXml::NAME>("example");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test004_description)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::DESCRIPTION>(cNull);
- root->Add<ConfigXml::DESCRIPTION>("description");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test005_author)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::AUTHOR>(cNull, cNull, cNull);
- root->Add<ConfigXml::AUTHOR>(cNull, cNull, "Krzysztof Janiak");
- root->Add<ConfigXml::AUTHOR>(cNull,
- "k.janiak@samsung.com",
- "Krzysztof Janiak");
- root->Add<ConfigXml::AUTHOR>("www.google.pl",
- "k.janiak@samsung.com",
- "Krzysztof Janiak");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test006_license)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::LICENSE>(cNull, cNull);
- root->Add<ConfigXml::LICENSE>(cNull, "Public domain.");
- root->Add<ConfigXml::LICENSE>("www.samsung.com", "Apache 2.0");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test007_icon)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::ICON>(cNull);
- root->Add<ConfigXml::ICON>("icon.png");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test008_content)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::CONTENT>(cNull);
- root->Add<ConfigXml::CONTENT>("index.html");
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test009_feature)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- ConfigXml::ElementPtr feature = root->Add<ConfigXml::FEATURE>(
- "http://tizen.org/api/application",
- true);
-
- feature->Add<ConfigXml::PARAM>(cNull, cNull);
- feature->Add<ConfigXml::PARAM>("accuracy", cNull);
- feature->Add<ConfigXml::PARAM>("accuracy", "low");
- feature->Add<ConfigXml::PARAM>("enabled", false);
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test010_preference)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::PREFERENCE>(cNull, cNull);
- root->Add<ConfigXml::PREFERENCE>("skin", cNull);
- root->Add<ConfigXml::PREFERENCE>("skin", "alien");
- root->Add<ConfigXml::PREFERENCE>("api-key", "f6d3a312f9d742", true);
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test011_access)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::ACCESS>("http://www.wp.pl/*");
- root->Add<ConfigXml::ACCESS>("http://onet.pl", true);
- DisplaySaveAndCompare(doc);
-TEST_END
-
-
-TEST_START(test012_tizen_setting)
- ConfigXml::DocumentPtr doc = ConfigXml::Document::Create();
- ConfigXml::ElementPtr root = doc->Add<ConfigXml::WIDGET>(cNull,cNull,cNull);
-
- root->Add<ConfigXml::TIZEN_SETTING>("rotation-lock","portrait");
- root->Add<ConfigXml::TIZEN_SETTING>("backbutton-presence","disable");
- root->Add<ConfigXml::TIZEN_SETTING>("indicator-presence","disable");
- DisplaySaveAndCompare(doc);
-TEST_END
+++ /dev/null
-/*
- * 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.
- */
-/*
- * @file config_gen_test.cpp
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @version 1.0
- */
-
-#include <dpl/test/test_runner.h>
-
-int main (int argc, char *argv[])
-{
- return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc,
- argv);
-}
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" id="http://example.org/exampleWidget" version="2.0 Beta" height="640" width="480"/>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets" id="http://example.org/exampleWidget" version="2.0 Beta" viewmodes="fullscreen"/>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets">
- <name/>
- <name>example</name>
-</widget>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets">
- <description/>
- <description>description</description>
-</widget>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets">
- <author/>
- <author>Krzysztof Janiak</author>
- <author email="k.janiak@samsung.com">Krzysztof Janiak</author>
- <author href="www.google.pl" email="k.janiak@samsung.com">Krzysztof Janiak</author>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets">
- <license/>
- <license>Public domain.</license>
- <license href="www.samsung.com">Apache 2.0</license>
-</widget>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets">
- <icon/>
- <icon src="icon.png"/>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets">
- <content/>
- <content src="index.html"/>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets">
- <feature name="http://tizen.org/api/application" required="true">
- <param/>
- <param name="accuracy"/>
- <param name="accuracy" value="low"/>
- <param name="enabled" value="false"/>
- </feature>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets">
- <preference/>
- <preference name="skin"/>
- <preference name="skin" value="alien"/>
- <preference name="api-key" value="f6d3a312f9d742" readonly="true"/>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets">
- <access origin="http://www.wp.pl/*"/>
- <access origin="http://onet.pl" subdomains="true"/>
-</widget>
+++ /dev/null
-<?xml version="1.0"?>
-<widget xmlns="http://www.w3.org/ns/widgets">
- <tizen:setting rotation-lock="portrait"/>
- <tizen:setting backbutton-presence="disable"/>
- <tizen:setting indicator-presence="disable"/>
-</widget>