From: Pawel Sikorski Date: Wed, 6 Feb 2013 14:40:10 +0000 (+0100) Subject: Source code formating unification X-Git-Tag: accepted/tizen_2.1/20130425.023916~20^2~15^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc7aa67ff30adf069eb57724628fb35c0d12a261;p=framework%2Fweb%2Fwrt-installer.git Source code formating unification [Issue#] N/A [Problem] Source code was not formatted to any rules. In this situation creating new patches or making review may become uncomfortable. [Cause] No formatting rules/tool used. [Solution] To make implementation and review process more comfortable, whole installer repository source code has been formatted with uncrustify tool. The configuration of the tool is located in the repository (./uncrustify.cfg). Command used (stored in uncrustify.sh): uncrustify -c ./uncrustify.cfg --no-backup `find . -regex "\(.*\.cpp\|.*\.h\|.*\.c\|.*\.cc\)" | grep -v "orm.h\|orm_generator.h\|3rdparty"` [Verification] Build the repository Change-Id: I47893d5d81e495c33d97fc3c8f47be166d265307 --- diff --git a/src/commons/wrt_common_types.h b/src/commons/wrt_common_types.h index 4fe586f..f888c85 100644 --- a/src/commons/wrt_common_types.h +++ b/src/commons/wrt_common_types.h @@ -26,8 +26,8 @@ #include /** -* Widget version is optional -*/ + * Widget version is optional + */ typedef DPL::Optional OptionalWidgetVersion; /* Define db type */ diff --git a/src/commons/wrt_error.h b/src/commons/wrt_error.h index 22599f3..ae4f2de 100644 --- a/src/commons/wrt_error.h +++ b/src/commons/wrt_error.h @@ -126,7 +126,8 @@ enum Type AlreadyRunning, ///< Widget is already running AlreadyStopped, ///< Widget is already stopped InvalidLanguage, ///< Widget is invalid in current locales - StillAuthorizing, ///< Widget is still autorizing and has not yet finished it + StillAuthorizing, ///< Widget is still autorizing and has not yet + // finished it EarlyKilled, ///< Widget was early killed during launch AccessDenied, ///< Access denied from ACE CertificateRevoked, ///< Some certificate was revoked. diff --git a/src/configuration_parser/WidgetConfigurationManager.cpp b/src/configuration_parser/WidgetConfigurationManager.cpp index 94a7c54..6044a5f 100644 --- a/src/configuration_parser/WidgetConfigurationManager.cpp +++ b/src/configuration_parser/WidgetConfigurationManager.cpp @@ -47,10 +47,10 @@ const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml"; } bool WidgetConfigurationManager::locateAndParseConfigurationFile( - const std::string& _currentPath, - WrtDB::WidgetRegisterInfo& pWidgetConfigInfo, - const std::string& baseFolder, - int* pErrCode) + const std::string& _currentPath, + WrtDB::WidgetRegisterInfo& pWidgetConfigInfo, + const std::string& baseFolder, + int* pErrCode) { using namespace WrtDB; @@ -63,7 +63,7 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile( // check if this installation from browser, or not. size_t pos = _currentPath.rfind("/"); std::ostringstream infoPath; - infoPath << _currentPath.substr(pos+1); + infoPath << _currentPath.substr(pos + 1); ParserRunner parser; std::string language = ""; @@ -92,7 +92,8 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile( //TODO why don't we use fopen here bool has_config_xml = false; errno = 0; - while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on its name + while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based + // on its name if (ptr->d_type == DT_REG) { if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) { _WrtUtilSetAbsolutePath(cfgAbsPath, @@ -121,10 +122,15 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile( } // - // WidgetConfigurationParser & parser = WidgetConfigurationParserSingleton::Instance(); - // if (!parser.parseConfigurationFile(cfgAbsPath, configInfo, baseFolder.c_str(), pWidgetConfigInfo.signature_type)) { - // LogDebug("Invalid widget configuration file!"); - // *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE; + // WidgetConfigurationParser & parser = + // WidgetConfigurationParserSingleton::Instance(); + // if + // (!parser.parseConfigurationFile(cfgAbsPath, configInfo, + // baseFolder.c_str(), pWidgetConfigInfo.signature_type)) { + // LogDebug("Invalid widget configuration + // file!"); + // *pErrCode = + // WRT_WM_ERR_INVALID_ARCHIVE; // closedir(dir); // return false; // } @@ -147,11 +153,12 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile( Try { parser.Parse(_currentPath, ElementParserPtr(new - RootParser< - WidgetParser>( - configInfo, - DPL::FromUTF32String( - L"widget")))); + RootParser< + WidgetParser>( + configInfo, + DPL:: + FromUTF32String( + L"widget")))); } Catch(ElementParser::Exception::Base) { @@ -162,7 +169,6 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile( } } - char *tmp_language; if (!_WrtUtilStringToLower(baseFolder.c_str(), &tmp_language)) { *pErrCode = WRT_ERR_UNKNOWN; @@ -217,13 +223,16 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile( return true; } -void WidgetConfigurationManager::processFile(const std::string& path, - WrtDB::WidgetRegisterInfo &widgetConfiguration) +void WidgetConfigurationManager::processFile( + const std::string& path, + WrtDB::WidgetRegisterInfo & + widgetConfiguration) { int pErrCode; if (!locateAndParseConfigurationFile(path, widgetConfiguration, - DEFAULT_LANGUAGE, &pErrCode)) { + DEFAULT_LANGUAGE, &pErrCode)) + { LogWarning("Widget archive: Failed while parsing config file"); ThrowMsg(Exception::ProcessFailed, path); } diff --git a/src/configuration_parser/WidgetConfigurationManager.h b/src/configuration_parser/WidgetConfigurationManager.h index 84ad2f7..7bda14f 100644 --- a/src/configuration_parser/WidgetConfigurationManager.h +++ b/src/configuration_parser/WidgetConfigurationManager.h @@ -53,10 +53,12 @@ class WidgetConfigurationManager private: typedef std::list > StringPairList; - bool locateAndParseConfigurationFile(const std::string& currentPath, - WrtDB::WidgetRegisterInfo& pWidgetConfigInfo, - const std::string& baseFolder, - int* pErrCode); + bool locateAndParseConfigurationFile( + const std::string& currentPath, + WrtDB::WidgetRegisterInfo& + pWidgetConfigInfo, + const std::string& baseFolder, + int* pErrCode); }; typedef DPL::Singleton diff --git a/src/configuration_parser/deny_all_parser.cpp b/src/configuration_parser/deny_all_parser.cpp index cffa56a..e807d5e 100644 --- a/src/configuration_parser/deny_all_parser.cpp +++ b/src/configuration_parser/deny_all_parser.cpp @@ -17,8 +17,7 @@ #include DenyAllParser::DenyAllParser() : ElementParser() -{ -} +{} ElementParserPtr DenyAllParser::Create() { @@ -26,7 +25,7 @@ ElementParserPtr DenyAllParser::Create() } ElementParser::ActionFunc DenyAllParser::GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { ThrowMsg(Exception::ParseError, "There must not be any subelement"); } diff --git a/src/configuration_parser/deny_all_parser.h b/src/configuration_parser/deny_all_parser.h index 2d45707..d9dfe56 100644 --- a/src/configuration_parser/deny_all_parser.h +++ b/src/configuration_parser/deny_all_parser.h @@ -31,10 +31,9 @@ struct DenyAllParser : public ElementParser virtual void Accept(const XmlAttribute& /*attribute*/); virtual void Accept(const Text& /*text*/); virtual void Verify() - { - } + {} virtual ActionFunc GetElementParser(const DPL::String& ns, - const DPL::String& name); + const DPL::String& name); DenyAllParser(); }; diff --git a/src/configuration_parser/element_parser.h b/src/configuration_parser/element_parser.h index 4751672..a44f94a 100644 --- a/src/configuration_parser/element_parser.h +++ b/src/configuration_parser/element_parser.h @@ -79,15 +79,13 @@ class ElementParser : public std::enable_shared_from_this virtual void Accept(const Text&) = 0; virtual void Verify() = 0; virtual ActionFunc GetElementParser(const DPL::String &ns, - const DPL::String &name) = 0; + const DPL::String &name) = 0; virtual ~ElementParser() - { - } + {} protected: ElementParser() - { - } + {} }; #endif // ELEMENT_PARSER_H_ diff --git a/src/configuration_parser/ignoring_parser.cpp b/src/configuration_parser/ignoring_parser.cpp index 9fc90a0..29520d5 100644 --- a/src/configuration_parser/ignoring_parser.cpp +++ b/src/configuration_parser/ignoring_parser.cpp @@ -24,8 +24,7 @@ #include IgnoringParser::IgnoringParser() : ElementParser() -{ -} +{} ElementParserPtr IgnoringParser::Create() { @@ -38,23 +37,19 @@ ElementParserPtr IgnoringParser::Reuse() } ElementParser::ActionFunc IgnoringParser::GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return DPL::MakeDelegate(this, &IgnoringParser::Reuse); } void IgnoringParser::Accept(const Element& /*element*/) -{ -} +{} void IgnoringParser::Accept(const Text& /*text*/) -{ -} +{} void IgnoringParser::Accept(const XmlAttribute& /*attribute*/) -{ -} +{} void IgnoringParser::Verify() -{ -} +{} diff --git a/src/configuration_parser/ignoring_parser.h b/src/configuration_parser/ignoring_parser.h index 9f1f6d5..b14f1ad 100644 --- a/src/configuration_parser/ignoring_parser.h +++ b/src/configuration_parser/ignoring_parser.h @@ -28,7 +28,7 @@ struct IgnoringParser : public ElementParser { static ElementParserPtr Create(); virtual ActionFunc GetElementParser(const DPL::String& ns, - const DPL::String& name); + const DPL::String& name); virtual void Accept(const Element&); virtual void Accept(const Text&); virtual void Accept(const XmlAttribute&); diff --git a/src/configuration_parser/libiriwrapper.cpp b/src/configuration_parser/libiriwrapper.cpp index f429344..6d8de2a 100644 --- a/src/configuration_parser/libiriwrapper.cpp +++ b/src/configuration_parser/libiriwrapper.cpp @@ -27,8 +27,7 @@ namespace LibIri { Wrapper::Wrapper(const char* aIri) : m_Iri(iri_parse(aIri)) -{ -} +{} Wrapper::~Wrapper() { iri_destroy(m_Iri); @@ -52,10 +51,10 @@ bool Wrapper::Validate() } std::ostream & operator<<(std::ostream& a_stream, - const Wrapper& a_wrapper) + const Wrapper& a_wrapper) { iri_t& iri = *a_wrapper.m_Iri; -#define PRINT_FIELD(field) "] " # field " [" << (iri.field ? iri.field : "null") +#define PRINT_FIELD(field) "] " #field " [" << (iri.field ? iri.field : "null") a_stream << " display [" << (iri.display ? iri.display : "null") << PRINT_FIELD(scheme) << diff --git a/src/configuration_parser/libiriwrapper.h b/src/configuration_parser/libiriwrapper.h index 1029059..b0b3e86 100644 --- a/src/configuration_parser/libiriwrapper.h +++ b/src/configuration_parser/libiriwrapper.h @@ -39,7 +39,7 @@ struct Wrapper }; std::ostream & operator<<(std::ostream& a_stream, - const Wrapper& a_wrapper); + const Wrapper& a_wrapper); } //namespace LibIri #endif // _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_LIBIRIWRAPPER_H_ diff --git a/src/configuration_parser/parser_runner.cpp b/src/configuration_parser/parser_runner.cpp index 6de0c0d..cff02f7 100644 --- a/src/configuration_parser/parser_runner.cpp +++ b/src/configuration_parser/parser_runner.cpp @@ -33,14 +33,14 @@ class ParserRunner::Impl { public: void Parse(const std::string& filename, - const ElementParserPtr& root) + const ElementParserPtr& root) { DPL::FileInput input(filename); Parse(&input, root); } void Parse (DPL::AbstractInput *input, - const ElementParserPtr& root) + const ElementParserPtr& root) { Try { @@ -123,8 +123,7 @@ class ParserRunner::Impl Impl() : m_reader(NULL), m_parsingError(false) - { - } + {} ~Impl() { @@ -136,24 +135,24 @@ class ParserRunner::Impl private: static void xmlTextReaderErrorHandler(void* arg, - const char* msg, - xmlParserSeverities /* severity */, - xmlTextReaderLocatorPtr /* locator */) + const char* msg, + xmlParserSeverities /* severity */, + xmlTextReaderLocatorPtr /* locator */) { ParserRunner::Impl* impl = static_cast(arg); impl->ErrorHandler(DPL::FromASCIIString(msg)); } static void xmlTextReaderStructuredErrorHandler(void* arg, - xmlErrorPtr error) + xmlErrorPtr error) { ParserRunner::Impl* impl = static_cast(arg); impl->StructuredErrorHandler(error); } static int XMLCALL IoRead(void *context, - char *buffer, - int len) + char *buffer, + int len) { DPL::AbstractInput *input = static_cast(context); DPL::BinaryQueueAutoPtr data = input->Read(static_cast(len)); @@ -384,17 +383,16 @@ class ParserRunner::Impl ParserRunner::ParserRunner() : m_impl(new ParserRunner::Impl()) -{ -} +{} void ParserRunner::Parse(const std::string& filename, - ElementParserPtr root) + ElementParserPtr root) { m_impl->Parse(filename, root); } void ParserRunner::Parse(DPL::AbstractInput *input, - ElementParserPtr root) + ElementParserPtr root) { m_impl->Parse(input, root); } diff --git a/src/configuration_parser/parser_runner.h b/src/configuration_parser/parser_runner.h index 1176165..80a3208 100644 --- a/src/configuration_parser/parser_runner.h +++ b/src/configuration_parser/parser_runner.h @@ -31,9 +31,9 @@ class ParserRunner : private DPL::Noncopyable { public: void Parse(const std::string& filename, - ElementParserPtr root); + ElementParserPtr root); void Parse(DPL::AbstractInput *input, - ElementParserPtr root); + ElementParserPtr root); ParserRunner(); ~ParserRunner(); diff --git a/src/configuration_parser/root_parser.h b/src/configuration_parser/root_parser.h index 3f4a86b..df7ea6a 100644 --- a/src/configuration_parser/root_parser.h +++ b/src/configuration_parser/root_parser.h @@ -31,7 +31,7 @@ class RootParser : public ElementParser public: typedef typename ta_Parser::Data Data; virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& name) + const DPL::String& name) { if (name == m_tag) { return DPL::MakeDelegate(this, @@ -43,15 +43,13 @@ class RootParser : public ElementParser } RootParser(Data data, - const DPL::String& tag) : + const DPL::String& tag) : m_data(data), m_tag(tag) - { - } + {} virtual ~RootParser() - { - } + {} virtual void Accept(const Element& /*element*/) { diff --git a/src/configuration_parser/widget_parser.cpp b/src/configuration_parser/widget_parser.cpp old mode 100755 new mode 100644 index 10ed283..5f0d6ca --- a/src/configuration_parser/widget_parser.cpp +++ b/src/configuration_parser/widget_parser.cpp @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /** +/** * This file have been implemented in compliance with W3C WARP SPEC. * but there are some patent issue between W3C WARP SPEC and APPLE. * so if you want to use this file, refer to the README file in root directory @@ -68,7 +68,7 @@ Direction ParseDirAttribute(const XmlAttribute& attribute) } void UpdateTextWithDirectionMark(Direction direction, - DPL::String* text) + DPL::String* text) { Assert(text); switch (direction) { @@ -96,14 +96,13 @@ class InnerElementsParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return DPL::MakeDelegate(this, &InnerElementsParser::Other); } virtual void Accept(const Element& /*element*/) - { - } + {} virtual void Accept(const Text& text) { @@ -133,8 +132,7 @@ class InnerElementsParser : public ElementParser InnerElementsParser(ElementParserPtr parent) : m_parentParser(parent), m_textDirection(Unicode::EMPTY) - { - } + {} ElementParserPtr Other() { @@ -153,7 +151,7 @@ class NameParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return DPL::MakeDelegate(this, &NameParser::Other); } @@ -203,11 +201,10 @@ class NameParser : public ElementParser } NameParser(Unicode::Direction direction, - ConfigParserData& data) : + ConfigParserData& data) : m_data(data), m_textDirection(direction) - { - } + {} ElementParserPtr Other() { @@ -235,7 +232,7 @@ class AccessParser : public ElementParser }; virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return DPL::MakeDelegate(this, &AccessParser::Other); } @@ -251,8 +248,7 @@ class AccessParser : public ElementParser } virtual void Accept(const Text& /*text*/) - { - } + {} void AcceptWac(const XmlAttribute& attribute) { @@ -318,8 +314,7 @@ class AccessParser : public ElementParser m_standardType(STANDARD_TYPE_NONE), m_network(false), m_data(data) - { - } + {} ElementParserPtr Other() { @@ -339,7 +334,7 @@ class DescriptionParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return DPL::MakeDelegate(this, &DescriptionParser::Other); } @@ -386,13 +381,12 @@ class DescriptionParser : public ElementParser } DescriptionParser(Unicode::Direction direction, - ConfigParserData& data) : + ConfigParserData& data) : m_data(data), m_lang(), m_description(), m_textDirection(direction) - { - } + {} private: ConfigParserData& m_data; @@ -405,17 +399,16 @@ class AuthorParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return DPL::MakeDelegate(this, &AuthorParser::Other); } AuthorParser(Unicode::Direction direction, - ConfigParserData& data) : + ConfigParserData& data) : m_data(data), m_textDirection(direction) - { - } + {} virtual void Accept(const Element& /*element*/) { @@ -482,18 +475,17 @@ class LicenseParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return DPL::MakeDelegate(this, &LicenseParser::Other); } LicenseParser(Unicode::Direction direction, - ConfigParserData& data) : + ConfigParserData& data) : m_data(data), m_ignore(true), m_textDirection(direction) - { - } + {} virtual void Accept(const Element& element) { @@ -561,19 +553,17 @@ class IconParser : public ElementParser public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return &IgnoringParser::Create; } IconParser(ConfigParserData& data) : ElementParser(), m_data(data) - { - } + {} virtual void Accept(const Element& /*element*/) - { - } + {} virtual void Accept(const XmlAttribute& attribute) { @@ -635,7 +625,8 @@ class IconParser : public ElementParser strtol(DPL::ToUTF8String(value).c_str(), &reterr, 10); if (errno != 0 || std::string(reterr) == DPL::ToUTF8String(value) || - valueInt <= 0) { + valueInt <= 0) + { return DPL::OptionalInt::Null; } else { return valueInt; @@ -645,7 +636,8 @@ class IconParser : public ElementParser } /** - * @brief delocalizePath removes locales folder from relative path if neccessary + * @brief delocalizePath removes locales folder from relative path if + * neccessary * @param source source string * * @throw BadSrcError if string is bad value of src attribute @@ -659,15 +651,11 @@ class IconParser : public ElementParser DPL::String result = source; - if(source.substr(0,index) == localeFolder) - { - size_t pos = result.find_first_of('/',index); - if(pos != std::string::npos && pos + 1 < source.size()) - { - result = result.substr(pos + 1,source.size()); - } - else - { + if (source.substr(0, index) == localeFolder) { + size_t pos = result.find_first_of('/', index); + if (pos != std::string::npos && pos + 1 < source.size()) { + result = result.substr(pos + 1, source.size()); + } else { Throw(BadSrcError); } } @@ -679,7 +667,7 @@ class ContentParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return &IgnoringParser::Create; } @@ -687,16 +675,13 @@ class ContentParser : public ElementParser ContentParser(ConfigParserData& data) : ElementParser(), m_data(data) - { - } + {} virtual void Accept(const Element& /*element*/) - { - } + {} virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Accept(const XmlAttribute& attribute) { @@ -756,7 +741,7 @@ class FeatureParser : public ElementParser struct ParamParser : public ElementParser { virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return &IgnoringParser::Create; } @@ -773,8 +758,7 @@ class FeatureParser : public ElementParser } virtual void Accept(const Element& /*element*/) - { - } + {} virtual void Accept(const Text& /*text*/) { @@ -801,8 +785,7 @@ class FeatureParser : public ElementParser ParamParser(ConfigParserData::Feature& data) : ElementParser(), m_data(data) - { - } + {} private: DPL::OptionalString m_name; @@ -811,7 +794,7 @@ class FeatureParser : public ElementParser }; virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& name) + const DPL::String& name) { if (name == L"param") { return DPL::MakeDelegate(this, &FeatureParser::OnParamElement); @@ -821,12 +804,10 @@ class FeatureParser : public ElementParser } virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Accept(const Element& /*element*/) - { - } + {} virtual void Accept(const XmlAttribute& attribute) { @@ -848,7 +829,8 @@ class FeatureParser : public ElementParser if (m_feature.name != L"") { if (iri.Validate()) { if (m_data.featuresList.find(m_feature) == - m_data.featuresList.end()) { + m_data.featuresList.end()) + { m_data.featuresList.insert(m_feature); } else { LogDebug("Ignoring feature with name" << @@ -872,8 +854,7 @@ class FeatureParser : public ElementParser ElementParser(), m_data(data), m_feature(L"") - { - } + {} private: ConfigParserData& m_data; @@ -884,7 +865,7 @@ class PreferenceParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return &IgnoringParser::Create; } @@ -905,8 +886,7 @@ class PreferenceParser : public ElementParser } virtual void Accept(const Element& /*element*/) - { - } + {} virtual void Accept(const Text& /*text*/) { @@ -924,7 +904,8 @@ class PreferenceParser : public ElementParser ConfigParserData::Preference preference(*m_name, m_required); preference.value = m_value; if (m_data.preferencesList.find(preference) == - m_data.preferencesList.end()) { + m_data.preferencesList.end()) + { m_data.preferencesList.insert(preference); } } @@ -933,8 +914,7 @@ class PreferenceParser : public ElementParser ElementParser(), m_required(false), m_data(data) - { - } + {} private: DPL::OptionalString m_name; @@ -947,7 +927,7 @@ class LinkParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return &DenyAllParser::Create; } @@ -961,8 +941,9 @@ class LinkParser : public ElementParser ThrowMsg(Exception::ParseError, "rel attribute must have describedby value"); } - } else if (attribute.name == L"type") { - } else if (attribute.name == L"href") { + } else if (attribute.name == L"type") {} else if (attribute.name == + L"href") + { LogDebug("here is href"); m_href = attribute.value; } else { @@ -1011,8 +992,7 @@ class LinkParser : public ElementParser m_properNamespace(false), m_data(data), m_href(DPL::OptionalString::Null) - { - } + {} private: bool m_properNamespace; @@ -1024,18 +1004,16 @@ class SettingParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return &IgnoringParser::Create; } virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Accept(const Element& /*element*/) - { - } + {} virtual void Accept(const XmlAttribute& attribute) { @@ -1045,15 +1023,13 @@ class SettingParser : public ElementParser } virtual void Verify() - { - } + {} SettingParser(ConfigParserData& data) : ElementParser(), m_data(data), m_setting(L"", L"") - { - } + {} private: ConfigParserData& m_data; @@ -1087,7 +1063,7 @@ class AppServiceParser : public ElementParser LogWarning("namespace for app service = " << element.ns); if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName) { ThrowMsg(Exception::ParseError, - "Wrong xml namespace for widget element"); + "Wrong xml namespace for widget element"); } } @@ -1114,33 +1090,33 @@ class AppServiceParser : public ElementParser DPL::String wildString(L"*/*"); DPL::String nullString(L""); ConfigParserData::ServiceInfo serviceInfo( - m_src.IsNull() ? nullString:*m_src, - m_operation.IsNull() ? nullString:*m_operation, - m_scheme.IsNull() ? nullString:*m_scheme, - m_mime.IsNull() ? nullString:*m_mime); + m_src.IsNull() ? nullString : *m_src, + m_operation.IsNull() ? nullString : *m_operation, + m_scheme.IsNull() ? nullString : *m_scheme, + m_mime.IsNull() ? nullString : *m_mime); FOREACH(iterator, m_data.appServiceList) { if (iterator->m_operation == serviceInfo.m_operation && // check scheme (iterator->m_scheme == serviceInfo.m_scheme || - // check input scheme is "*/*" case - (iterator->m_scheme == wildString && - serviceInfo.m_scheme != nullString) || - // check iterator scheme is "*/*" case - (serviceInfo.m_scheme == wildString && - iterator->m_scheme != nullString)) && + // check input scheme is "*/*" case + (iterator->m_scheme == wildString && + serviceInfo.m_scheme != nullString) || + // check iterator scheme is "*/*" case + (serviceInfo.m_scheme == wildString && + iterator->m_scheme != nullString)) && (iterator->m_mime == serviceInfo.m_mime || - // check input mime is "*/*" case - (iterator->m_mime == wildString && - serviceInfo.m_mime != nullString) || - // check iterator mime is "*/*" case - (serviceInfo.m_mime == wildString && - iterator->m_mime != nullString))) + // check input mime is "*/*" case + (iterator->m_mime == wildString && + serviceInfo.m_mime != nullString) || + // check iterator mime is "*/*" case + (serviceInfo.m_mime == wildString && + iterator->m_mime != nullString))) { ThrowMsg(Exception::ParseError, - "service operation is duplicated " + - DPL::ToUTF8String(*m_operation)); + "service operation is duplicated " + + DPL::ToUTF8String(*m_operation)); } } m_data.appServiceList.push_back(serviceInfo); @@ -1153,8 +1129,7 @@ class AppServiceParser : public ElementParser m_scheme(DPL::OptionalString::Null), m_mime(DPL::OptionalString::Null), m_data(data) - { - } + {} private: DPL::OptionalString m_src; @@ -1167,231 +1142,221 @@ class AppServiceParser : public ElementParser class AppControlParser : public ElementParser { public: - struct SourceParser : public ElementParser - { - public: - virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) - { - return &IgnoringParser::Create; - } - - virtual void Accept(const Text& /*text*/) - { - } - - virtual void Accept(const Element& /*element*/) - { - } - - virtual void Accept(const XmlAttribute& attribute) - { - if (attribute.name == L"name") { - if (attribute.value.size() > 0) { - m_value = attribute.value; - NormalizeString(m_value); - } - } - } - - virtual void Verify() - { - if (m_value.IsNull() || *m_value== L"") { - return; - } - - m_data.m_src = *m_value; - } - - SourceParser(ConfigParserData::AppControlInfo& data) : - ElementParser(), - m_properNamespace(false), - m_data(data) - { - } - - private: - bool m_properNamespace; - DPL::OptionalString m_value; - ConfigParserData::AppControlInfo& m_data; - }; - - struct OperationParser : public ElementParser - { - public: - virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) - { - return &IgnoringParser::Create; - } - - virtual void Accept(const Text& /*text*/) - { - } - - virtual void Accept(const Element& /*element*/) - { - } - - virtual void Accept(const XmlAttribute& attribute) - { - if (attribute.name == L"name") { - if (attribute.value.size() > 0) { - m_value = attribute.value; - NormalizeString(m_value); - } - } - } - - virtual void Verify() - { - if (m_value.IsNull() || *m_value== L"") { - return; - } - - m_data.m_operation = *m_value; - } - - OperationParser(ConfigParserData::AppControlInfo& data) : - ElementParser(), - m_properNamespace(false), - m_data(data) - { - } - - private: - bool m_properNamespace; - DPL::OptionalString m_value; - ConfigParserData::AppControlInfo& m_data; - }; - - struct UriParser : public ElementParser - { - public: - virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) - { - return &IgnoringParser::Create; - } - - virtual void Accept(const Text& /*text*/) - { - } - - virtual void Accept(const Element& /*element*/) - { - } - - virtual void Accept(const XmlAttribute& attribute) - { - if (attribute.name == L"name") { - if (attribute.value.size() > 0) { - m_value = attribute.value; - NormalizeString(m_value); - } - } - } - - virtual void Verify() - { - if (m_value.IsNull() || *m_value == L"") { - return; - } - - DPL::String wildString(L"*/*"); - if ((m_data.m_uriList.find(wildString) == - m_data.m_uriList.end()) - && (m_data.m_uriList.find(*m_value) == - m_data.m_uriList.end())) { - - m_data.m_uriList.insert(*m_value); - } else { - LogDebug("Ignoring uri with name" << - DPL::ToUTF8String(*m_value)); - } - } - - UriParser(ConfigParserData::AppControlInfo& data) : - ElementParser(), - m_properNamespace(false), - m_data(data) - { - } - - private: - bool m_properNamespace; - DPL::OptionalString m_value; - ConfigParserData::AppControlInfo& m_data; - }; - - struct MimeParser : public ElementParser - { - public: - virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) - { - return &IgnoringParser::Create; - } - - virtual void Accept(const Text& /*text*/) - { - } - - virtual void Accept(const Element& /*element*/) - { - } - - virtual void Accept(const XmlAttribute& attribute) - { - if (attribute.name == L"name") { - if (attribute.value.size() > 0) { - m_value = attribute.value; - NormalizeString(m_value); - } - } - } - - virtual void Verify() - { - if (m_value.IsNull() || *m_value == L"") { - return; - } - - DPL::String wildString(L"*/*"); - if ((m_data.m_mimeList.find(wildString) == - m_data.m_mimeList.end()) - && (m_data.m_mimeList.find(*m_value) == - m_data.m_mimeList.end())) { - m_data.m_mimeList.insert(*m_value); - } else { - LogDebug("Ignoring mime with name" << - DPL::ToUTF8String(*m_value)); - } - } - - MimeParser(ConfigParserData::AppControlInfo& data) : - ElementParser(), - m_properNamespace(false), - m_data(data) - { - } - - private: - bool m_properNamespace; - DPL::OptionalString m_value; - ConfigParserData::AppControlInfo& m_data; - }; + struct SourceParser : public ElementParser + { + public: + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const Text& /*text*/) + {} + + virtual void Accept(const Element& /*element*/) + {} + + virtual void Accept(const XmlAttribute& attribute) + { + if (attribute.name == L"name") { + if (attribute.value.size() > 0) { + m_value = attribute.value; + NormalizeString(m_value); + } + } + } + + virtual void Verify() + { + if (m_value.IsNull() || *m_value == L"") { + return; + } + + m_data.m_src = *m_value; + } + + SourceParser(ConfigParserData::AppControlInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + {} + + private: + bool m_properNamespace; + DPL::OptionalString m_value; + ConfigParserData::AppControlInfo& m_data; + }; + + struct OperationParser : public ElementParser + { + public: + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const Text& /*text*/) + {} + + virtual void Accept(const Element& /*element*/) + {} + + virtual void Accept(const XmlAttribute& attribute) + { + if (attribute.name == L"name") { + if (attribute.value.size() > 0) { + m_value = attribute.value; + NormalizeString(m_value); + } + } + } + + virtual void Verify() + { + if (m_value.IsNull() || *m_value == L"") { + return; + } + + m_data.m_operation = *m_value; + } + + OperationParser(ConfigParserData::AppControlInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + {} + + private: + bool m_properNamespace; + DPL::OptionalString m_value; + ConfigParserData::AppControlInfo& m_data; + }; + + struct UriParser : public ElementParser + { + public: + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const Text& /*text*/) + {} + + virtual void Accept(const Element& /*element*/) + {} + + virtual void Accept(const XmlAttribute& attribute) + { + if (attribute.name == L"name") { + if (attribute.value.size() > 0) { + m_value = attribute.value; + NormalizeString(m_value); + } + } + } + + virtual void Verify() + { + if (m_value.IsNull() || *m_value == L"") { + return; + } + + DPL::String wildString(L"*/*"); + if ((m_data.m_uriList.find(wildString) == + m_data.m_uriList.end()) + && (m_data.m_uriList.find(*m_value) == + m_data.m_uriList.end())) + { + m_data.m_uriList.insert(*m_value); + } else { + LogDebug("Ignoring uri with name" << + DPL::ToUTF8String(*m_value)); + } + } + + UriParser(ConfigParserData::AppControlInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + {} + + private: + bool m_properNamespace; + DPL::OptionalString m_value; + ConfigParserData::AppControlInfo& m_data; + }; + + struct MimeParser : public ElementParser + { + public: + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const Text& /*text*/) + {} + + virtual void Accept(const Element& /*element*/) + {} + + virtual void Accept(const XmlAttribute& attribute) + { + if (attribute.name == L"name") { + if (attribute.value.size() > 0) { + m_value = attribute.value; + NormalizeString(m_value); + } + } + } + + virtual void Verify() + { + if (m_value.IsNull() || *m_value == L"") { + return; + } + + DPL::String wildString(L"*/*"); + if ((m_data.m_mimeList.find(wildString) == + m_data.m_mimeList.end()) + && (m_data.m_mimeList.find(*m_value) == + m_data.m_mimeList.end())) + { + m_data.m_mimeList.insert(*m_value); + } else { + LogDebug("Ignoring mime with name" << + DPL::ToUTF8String(*m_value)); + } + } + + MimeParser(ConfigParserData::AppControlInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + {} + + private: + bool m_properNamespace; + DPL::OptionalString m_value; + ConfigParserData::AppControlInfo& m_data; + }; virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& name) + const DPL::String& name) { if (name == L"src") { return DPL::MakeDelegate(this, &AppControlParser::OnSourceElement); } else if (name == L"operation") { - return DPL::MakeDelegate(this, &AppControlParser::OnOperationElement); + return DPL::MakeDelegate(this, + &AppControlParser::OnOperationElement); } else if (name == L"uri") { return DPL::MakeDelegate(this, &AppControlParser::OnUriElement); - } else if (name == L"mime") { + } else if (name == L"mime") { return DPL::MakeDelegate(this, &AppControlParser::OnMimeElement); } else { return &IgnoringParser::Create; @@ -1399,15 +1364,14 @@ class AppControlParser : public ElementParser } virtual void Accept(const XmlAttribute& attribute) - { - } + {} virtual void Accept(const Element& element) { LogWarning("namespace for app service = " << element.ns); if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName) { ThrowMsg(Exception::ParseError, - "Wrong xml namespace for widget element"); + "Wrong xml namespace for widget element"); } } @@ -1418,24 +1382,24 @@ class AppControlParser : public ElementParser virtual void Verify() { - if (m_appControl.m_src == L""){ + if (m_appControl.m_src == L"") { LogWarning("service element must have src element"); return; } - if (m_appControl.m_operation == L""){ + if (m_appControl.m_operation == L"") { LogWarning("service element must have operation element"); return; } FOREACH(iterator, m_data.appControlList) { if (iterator->m_src == m_appControl.m_src && - iterator->m_operation == m_appControl.m_operation ) + iterator->m_operation == m_appControl.m_operation) { ThrowMsg(Exception::ParseError, - "app control element is duplicated " + - DPL::ToUTF8String(m_appControl.m_src) + ", " + - DPL::ToUTF8String(m_appControl.m_operation)); + "app control element is duplicated " + + DPL::ToUTF8String(m_appControl.m_src) + ", " + + DPL::ToUTF8String(m_appControl.m_operation)); } } m_data.appControlList.push_back(m_appControl); @@ -1465,8 +1429,7 @@ class AppControlParser : public ElementParser ElementParser(), m_data(data), m_appControl(L"") - { - } + {} private: ConfigParserData& m_data; @@ -1477,7 +1440,7 @@ class ApplicationParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return &IgnoringParser::Create; } @@ -1523,16 +1486,16 @@ class ApplicationParser : public ElementParser virtual void Verify() { - if(!m_id) { + if (!m_id) { ThrowMsg(Exception::ParseError, "application element must have id attribute"); } - if(!!m_package) { + if (!!m_package) { m_data.tizenPkgId = m_package; } - if(!m_version) { + if (!m_version) { ThrowMsg(Exception::ParseError, "application element must have required_version attribute"); } @@ -1548,8 +1511,7 @@ class ApplicationParser : public ElementParser m_id(DPL::OptionalString::Null), m_version(DPL::OptionalString::Null), m_properNamespace(false) - { - } + {} private: ConfigParserData& m_data; @@ -1578,17 +1540,16 @@ class SplashParser : public ElementParser } virtual void Accept(const Element& element) - { - } + {} virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Verify() { if (m_src.IsNull()) { - LogWarning("src attribute of splash element is mandatory - ignoring"); + LogWarning( + "src attribute of splash element is mandatory - ignoring"); return; } @@ -1598,8 +1559,7 @@ class SplashParser : public ElementParser SplashParser(ConfigParserData& data) : ElementParser(), m_data(data) - { - } + {} private: DPL::OptionalString m_src; @@ -1625,17 +1585,16 @@ class BackgroundParser : public ElementParser } virtual void Accept(const Element& /*element*/) - { - } + {} virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Verify() { if (m_src.IsNull()) { - LogWarning("src attribute of background element is mandatory - ignoring"); + LogWarning( + "src attribute of background element is mandatory - ignoring"); return; } @@ -1644,8 +1603,7 @@ class BackgroundParser : public ElementParser explicit BackgroundParser(ConfigParserData& data) : m_data(data) - { - } + {} private: DPL::OptionalString m_src; @@ -1656,14 +1614,13 @@ class PrivilegeParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& name) + const DPL::String& name) { return &IgnoringParser::Create; } virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Accept(const Element& element) { @@ -1693,7 +1650,8 @@ class PrivilegeParser : public ElementParser if (m_feature.name != L"") { if (iri.Validate()) { if (m_data.featuresList.find(m_feature) == - m_data.featuresList.end()) { + m_data.featuresList.end()) + { m_data.featuresList.insert(m_feature); } else { LogDebug("Ignoring feature with name" << @@ -1708,7 +1666,8 @@ class PrivilegeParser : public ElementParser if (m_privilege.name != L"") { if (iriPrivilege.Validate()) { if (m_data.privilegeList.find(m_privilege) == - m_data.privilegeList.end()) { + m_data.privilegeList.end()) + { m_data.privilegeList.insert(m_privilege); } else { LogDebug("Ignoring privilege with name" << @@ -1724,8 +1683,7 @@ class PrivilegeParser : public ElementParser m_feature(L""), m_privilege(L""), m_properNamespace(false) - { - } + {} private: ConfigParserData& m_data; @@ -1753,30 +1711,29 @@ class CategoryParser : public ElementParser } virtual void Accept(const Element& /*element*/) - { - } + {} virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Verify() { if (m_name.IsNull()) { - LogWarning("name attribute of category element is mandatory - ignoring"); + LogWarning( + "name attribute of category element is mandatory - ignoring"); return; } if (m_data.categoryList.find(*m_name) == - m_data.categoryList.end()) { + m_data.categoryList.end()) + { m_data.categoryList.insert(*m_name); } } explicit CategoryParser(ConfigParserData& data) : m_data(data) - { - } + {} private: DPL::OptionalString m_name; @@ -1785,24 +1742,23 @@ class CategoryParser : public ElementParser class LiveboxParser : public ElementParser { - public: + public: struct BoxLabelParser : public ElementParser { virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return &IgnoringParser::Create; } virtual void Accept(const XmlAttribute& attribute) - { - } + {} virtual void Accept(const Element& element) { if (element.ns == - ConfigurationNamespace::TizenWebAppNamespaceName) + ConfigurationNamespace::TizenWebAppNamespaceName) { m_properNamespace = true; } @@ -1810,8 +1766,9 @@ class LiveboxParser : public ElementParser virtual void Accept(const Text& text) { - if(m_properNamespace) + if (m_properNamespace) { m_label = text.value; + } } virtual void Verify() @@ -1823,10 +1780,9 @@ class LiveboxParser : public ElementParser ElementParser(), m_properNamespace(false), m_data(data) - { - } + {} - private: + private: DPL::String m_label; bool m_properNamespace; ConfigParserData::LiveboxInfo& m_data; @@ -1835,14 +1791,14 @@ class LiveboxParser : public ElementParser struct BoxIconParser : public ElementParser { virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return &IgnoringParser::Create; } virtual void Accept(const XmlAttribute& attribute) { - if(m_properNamespace) { + if (m_properNamespace) { if (attribute.name == L"src") { m_icon = attribute.value; } @@ -1852,15 +1808,14 @@ class LiveboxParser : public ElementParser virtual void Accept(const Element& element) { if (element.ns == - ConfigurationNamespace::TizenWebAppNamespaceName) + ConfigurationNamespace::TizenWebAppNamespaceName) { m_properNamespace = true; } } virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Verify() { @@ -1871,10 +1826,9 @@ class LiveboxParser : public ElementParser ElementParser(), m_properNamespace(false), m_data(data) - { - } + {} - private: + private: DPL::String m_icon; bool m_properNamespace; ConfigParserData::LiveboxInfo& m_data; @@ -1885,14 +1839,14 @@ class LiveboxParser : public ElementParser struct BoxSizeParser : public ElementParser { virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& /*name*/) + const DPL::String& /*name*/) { return &IgnoringParser::Create; } virtual void Accept(const XmlAttribute& attribute) { - if(m_properNamespace) { + if (m_properNamespace) { if (attribute.name == L"preview") { m_preview = attribute.value; } @@ -1902,7 +1856,7 @@ class LiveboxParser : public ElementParser virtual void Accept(const Element& element) { if (element.ns == - ConfigurationNamespace::TizenWebAppNamespaceName) + ConfigurationNamespace::TizenWebAppNamespaceName) { m_properNamespace = true; } @@ -1910,8 +1864,9 @@ class LiveboxParser : public ElementParser virtual void Accept(const Text& text) { - if(m_properNamespace) + if (m_properNamespace) { m_size = text.value; + } } virtual void Verify() @@ -1922,13 +1877,13 @@ class LiveboxParser : public ElementParser m_data.m_boxSize.push_back(boxSize); } - explicit BoxSizeParser(ConfigParserData::LiveboxInfo::BoxContentInfo& data) : + explicit BoxSizeParser( + ConfigParserData::LiveboxInfo::BoxContentInfo& data) : ElementParser(), m_data(data) - { - } + {} - private: + private: DPL::String m_size; DPL::String m_preview; bool m_properNamespace; @@ -1938,14 +1893,14 @@ class LiveboxParser : public ElementParser struct PdParser : public ElementParser { virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& name) + const DPL::String& name) { return &IgnoringParser::Create; } virtual void Accept(const XmlAttribute& attribute) { - if(m_properNamespace) { + if (m_properNamespace) { if (attribute.name == L"src") { m_src = attribute.value; } else if (attribute.name == L"width") { @@ -1959,15 +1914,14 @@ class LiveboxParser : public ElementParser virtual void Accept(const Element& element) { if (element.ns == - ConfigurationNamespace::TizenWebAppNamespaceName) + ConfigurationNamespace::TizenWebAppNamespaceName) { m_properNamespace = true; } } virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Verify() { @@ -1976,14 +1930,14 @@ class LiveboxParser : public ElementParser m_data.m_pdHeight = m_height; } - explicit PdParser(ConfigParserData::LiveboxInfo::BoxContentInfo& data) : + explicit PdParser( + ConfigParserData::LiveboxInfo::BoxContentInfo& data) : ElementParser(), m_properNamespace(false), m_data(data) - { - } + {} - private: + private: DPL::String m_src; DPL::String m_width; DPL::String m_height; @@ -1993,39 +1947,47 @@ class LiveboxParser : public ElementParser }; virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& name) + const DPL::String& name) { if (name == L"box-size") { - return DPL::MakeDelegate(this, &LiveboxParser::BoxContentParser::OnBoxSizeElement); + return DPL::MakeDelegate( + this, + &LiveboxParser::BoxContentParser:: + OnBoxSizeElement); } else if (name == L"pd") { - return DPL::MakeDelegate(this, &LiveboxParser::BoxContentParser::OnPdElement); - } else{ - ThrowMsg(Exception::ParseError, "No element parser for name: " << name); + return DPL::MakeDelegate( + this, + &LiveboxParser::BoxContentParser:: + OnPdElement); + } else { + ThrowMsg(Exception::ParseError, + "No element parser for name: " << name); } } virtual void Accept(const XmlAttribute& attribute) { if (m_properNamespace) { - if (attribute.name == L"src") + if (attribute.name == L"src") { m_box.m_boxSrc = attribute.value; - if (attribute.name == L"mouse-event") + } + if (attribute.name == L"mouse-event") { m_box.m_boxMouseEvent = attribute.value; + } } } virtual void Accept(const Element& element) { if (element.ns == - ConfigurationNamespace::TizenWebAppNamespaceName) + ConfigurationNamespace::TizenWebAppNamespaceName) { m_properNamespace = true; } } virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Verify() { @@ -2036,8 +1998,7 @@ class LiveboxParser : public ElementParser ElementParser(), m_properNamespace(false), m_data(data) - { - } + {} ElementParserPtr OnBoxSizeElement() { @@ -2049,7 +2010,7 @@ class LiveboxParser : public ElementParser return ElementParserPtr(new PdParser(m_box)); } - private: + private: DPL::String m_src; bool m_properNamespace; ConfigParserData::LiveboxInfo& m_data; @@ -2057,13 +2018,13 @@ class LiveboxParser : public ElementParser }; virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, - const DPL::String& name) + const DPL::String& name) { if (name == L"box-label") { return DPL::MakeDelegate(this, &LiveboxParser::OnBoxLabelElement); } else if (name == L"box-icon") { return DPL::MakeDelegate(this, &LiveboxParser::OnBoxIconElement); - } else if (name == L"box-content") { + } else if (name == L"box-content") { return DPL::MakeDelegate(this, &LiveboxParser::OnBoxContentElement); } else { return &IgnoringParser::Create; @@ -2090,15 +2051,14 @@ class LiveboxParser : public ElementParser virtual void Accept(const Element& element) { if (element.ns == - ConfigurationNamespace::TizenWebAppNamespaceName) + ConfigurationNamespace::TizenWebAppNamespaceName) { m_properNamespace = true; } } virtual void Accept(const Text& /*text*/) - { - } + {} virtual void Verify() { @@ -2149,7 +2109,7 @@ class CspParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& ns, - const DPL::String& name) + const DPL::String& name) { return &IgnoringParser::Create; } @@ -2158,31 +2118,30 @@ class CspParser : public ElementParser ElementParser(), m_data(data), m_properNamespace(false) - { - } + {} virtual void Accept(const Element& element) { - if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) - { + if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) { m_properNamespace = true; } } virtual void Accept(const XmlAttribute& attribute) - { - } + {} virtual void Accept(const Text& text) { - if (m_properNamespace) + if (m_properNamespace) { m_policy = text.value; + } } virtual void Verify() { - if (!m_policy.IsNull()) + if (!m_policy.IsNull()) { m_data.cspPolicy = *m_policy; + } } private: @@ -2191,9 +2150,10 @@ class CspParser : public ElementParser DPL::OptionalString m_policy; }; - -ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/, - const DPL::String& name) +ElementParser::ActionFunc WidgetParser::GetElementParser( + const DPL::String& /*ns*/, + const DPL::String& + name) { FuncMap::const_iterator it = m_map.find(name); if (it != m_map.end()) { @@ -2225,18 +2185,29 @@ WidgetParser::WidgetParser(ConfigParserData& data) : m_map[L"setting"] = DPL::MakeDelegate(this, &WidgetParser::OnSettingElement); // TODO: appservice will be removed - m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnAppServiceElement); - m_map[L"application"] = DPL::MakeDelegate(this, &WidgetParser::OnApplicationElement); + m_map[L"appservice"] = DPL::MakeDelegate(this, + &WidgetParser::OnAppServiceElement); + m_map[L"application"] = DPL::MakeDelegate( + this, + &WidgetParser:: + OnApplicationElement); m_map[L"splash"] = DPL::MakeDelegate(this, &WidgetParser::OnSplashElement); - m_map[L"background"] = DPL::MakeDelegate(this, &WidgetParser::OnBackgroundElement); - m_map[L"privilege"] = DPL::MakeDelegate(this, &WidgetParser::OnPrivilegeElement); - m_map[L"app-control"] = DPL::MakeDelegate(this, - &WidgetParser::OnAppControlElement); + m_map[L"background"] = DPL::MakeDelegate(this, + &WidgetParser::OnBackgroundElement); + m_map[L"privilege"] = DPL::MakeDelegate(this, + &WidgetParser::OnPrivilegeElement); + m_map[L"app-control"] = DPL::MakeDelegate( + this, + &WidgetParser:: + OnAppControlElement); m_map[L"category"] = DPL::MakeDelegate(this, - &WidgetParser::OnCategoryElement); + &WidgetParser::OnCategoryElement); m_map[L"livebox"] = DPL::MakeDelegate(this, &WidgetParser::OnLiveboxElement); #ifdef CSP_ENABLED - m_map[L"Content-Security-Policy"] = DPL::MakeDelegate(this, &WidgetParser::OnCspElement); + m_map[L"Content-Security-Policy"] = DPL::MakeDelegate( + this, + &WidgetParser:: + OnCspElement); #endif } @@ -2430,26 +2401,27 @@ void WidgetParser::Accept(const XmlAttribute& attribute) m_defaultlocale = attribute.value; NormalizeString(m_defaultlocale); if (!LanguageSubtagRstTreeSingleton::Instance().ValidateLanguageTag( - DPL::ToUTF8String(*m_defaultlocale))) { + DPL::ToUTF8String(*m_defaultlocale))) + { LogWarning("Language tag: " << m_defaultlocale << " is not valid"); m_defaultlocale = DPL::OptionalString::Null; - } - else + } else { LogDebug("Default Locale Found " << m_defaultlocale); + } } else { LogWarning("Ignoring subsequent default locale"); } - //Any other value consider as a namespace definition + //Any other value consider as a namespace definition } else if (attribute.name == L"xmlns" || attribute.prefix == L"xmlns") { LogInfo("Namespace domain: " << attribute.name); LogInfo("Namespace value: " << attribute.value); m_nameSpaces[attribute.name] = attribute.value; } else { LogError("Unknown attirbute: namespace=" << attribute.ns << - ", name=" << attribute.name << - ", value=" << attribute.value); + ", name=" << attribute.name << + ", value=" << attribute.value); } } @@ -2458,7 +2430,8 @@ void WidgetParser::Verify() FOREACH(mode, m_windowModes) { if (L"windowed" == *mode || L"floating" == *mode || L"fullscreen" == *mode || L"maximized" == *mode || - L"minimized" == *mode) { + L"minimized" == *mode) + { m_data.windowModes.insert(*mode); } } diff --git a/src/configuration_parser/widget_parser.h b/src/configuration_parser/widget_parser.h old mode 100755 new mode 100644 index 4ee0c14..af39afd --- a/src/configuration_parser/widget_parser.h +++ b/src/configuration_parser/widget_parser.h @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /** +/** * This file have been implemented in compliance with W3C WARP SPEC. * but there are some patent issue between W3C WARP SPEC and APPLE. * so if you want to use this file, refer to the README file in root directory @@ -86,7 +86,7 @@ class WidgetParser : public ElementParser ElementParserPtr OnCspElement(); virtual ActionFunc GetElementParser(const DPL::String& ns, - const DPL::String& name); + const DPL::String& name); virtual void Accept(const Element&); virtual void Accept(const Text&); diff --git a/src/jobs/job.cpp b/src/jobs/job.cpp index 64903b2..a94bc63 100644 --- a/src/jobs/job.cpp +++ b/src/jobs/job.cpp @@ -21,8 +21,7 @@ Job::Job(InstallationType installType) : m_installationType(installType), m_UndoType(false), m_paused(false) -{ -} +{} InstallationType Job::GetInstallationType() const { @@ -88,18 +87,14 @@ JobHandle Job::GetJobHandle() const } void Job::SendProgress() -{ -} +{} void Job::SendFinishedSuccess() -{ -} +{} void Job::SendFinishedFailure() -{ -} +{} void Job::SaveExceptionData(const Jobs::JobExceptionBase&) -{ -} +{} } //namespace Jobs diff --git a/src/jobs/job.h b/src/jobs/job.h index 877a966..c8d35ab 100644 --- a/src/jobs/job.h +++ b/src/jobs/job.h @@ -56,6 +56,7 @@ class Job : virtual void SendFinishedFailure(); virtual void SaveExceptionData(const Jobs::JobExceptionBase&); + private: JobHandle m_handle; InstallationType m_installationType; diff --git a/src/jobs/job_base.h b/src/jobs/job_base.h index 86e1746..c2ed1d8 100644 --- a/src/jobs/job_base.h +++ b/src/jobs/job_base.h @@ -34,8 +34,7 @@ class JobProgressBase public: JobProgressBase() : m_progressFlag(false), m_progresPercent(0.0) - { - } + {} void SetProgressFlag(bool flag) { @@ -57,7 +56,7 @@ class JobProgressBase } void UpdateProgress(T_InstallationStep step, - ProgressDescription const &description) + ProgressDescription const &description) { m_progresPercent = ((static_cast(step) + 1.0) / @@ -72,13 +71,13 @@ class JobContextBase public: JobContextBase(const T_JobStruct& jobStruct) : m_jobStruct(jobStruct) - { - } + {} T_JobStruct getInstallerStruct() const { return m_jobStruct; - } //TODO RENAME + } //TODO + // RENAME protected: T_JobStruct m_jobStruct; @@ -96,17 +95,15 @@ struct JobCallbacksBase finishedCallback(0), progressCallback(0), userParam(0) - { - } + {} JobCallbacksBase(T_finishedCb finished, - T_progressCb progress, - void *param) : + T_progressCb progress, + void *param) : finishedCallback(finished), progressCallback(progress), userParam(param) - { - } + {} }; } //namespace Jobs diff --git a/src/jobs/job_exception_base.h b/src/jobs/job_exception_base.h index 3f12a2d..9612bc2 100644 --- a/src/jobs/job_exception_base.h +++ b/src/jobs/job_exception_base.h @@ -33,24 +33,24 @@ const char *function, \ int line, \ const std::string & message = std::string()) : \ - Base(path, function, line, message) \ - { \ - m_className = # Class; \ - m_param = Param; \ - } \ + Base(path, function, line, message) \ + { \ + m_className = #Class; \ + m_param = Param; \ + } \ \ - Class(const char *path, \ - const char *function, \ - int line, \ - const Exception &reason, \ - const std::string & message = std::string()) : \ - Base(path, function, line, reason, message) \ - { \ - m_className = # Class; \ - m_param = Param; \ - } \ + Class(const char *path, \ + const char *function, \ + int line, \ + const Exception &reason, \ + const std::string & message = std::string()) : \ + Base(path, function, line, reason, message) \ + { \ + m_className = #Class; \ + m_param = Param; \ + } \ \ - virtual int getParam() const \ + virtual int getParam() const \ { \ return m_param; \ } \ @@ -67,24 +67,24 @@ const char *function, \ int line, \ const std::string & message = std::string()) : \ - Base(path, function, line, message) \ - { \ - m_className = # Class; \ - m_param = Param; \ - } \ + Base(path, function, line, message) \ + { \ + m_className = #Class; \ + m_param = Param; \ + } \ \ - Class(const char *path, \ - const char *function, \ - int line, \ - const Exception &reason, \ - const std::string & message = std::string()) : \ - Base(path, function, line, reason, message) \ - { \ - m_className = # Class; \ - m_param = Param; \ - } \ + Class(const char *path, \ + const char *function, \ + int line, \ + const Exception &reason, \ + const std::string & message = std::string()) : \ + Base(path, function, line, reason, message) \ + { \ + m_className = #Class; \ + m_param = Param; \ + } \ \ - virtual int getParam() const \ + virtual int getParam() const \ { \ return m_param; \ } \ diff --git a/src/jobs/plugin_install/job_plugin_install.cpp b/src/jobs/plugin_install/job_plugin_install.cpp index 8bf52ff..ac1642f 100644 --- a/src/jobs/plugin_install/job_plugin_install.cpp +++ b/src/jobs/plugin_install/job_plugin_install.cpp @@ -29,7 +29,8 @@ namespace Jobs { namespace PluginInstall { JobPluginInstall::JobPluginInstall(std::string const &pluginPath, - const PluginInstallerStruct &installerStruct) : + const PluginInstallerStruct &installerStruct) + : Job(PluginInstallation), JobContextBase(installerStruct) { @@ -52,7 +53,8 @@ void JobPluginInstall::SendProgress() if (GetProgressFlag() && getInstallerStruct().progressCallback != NULL) { LogDebug("Call Plugin install progressCallback"); getInstallerStruct().progressCallback(getInstallerStruct().userParam, - GetProgressPercent(), GetProgressDescription()); + GetProgressPercent(), + GetProgressDescription()); } } @@ -65,11 +67,11 @@ void JobPluginInstall::SendFinishedSuccess() { LogDebug("Call Plugin install success finishedCallback"); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, - Exceptions::Success); + Exceptions::Success); } else { LogDebug("Call Plugin install waiting finishedCallback"); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, - Exceptions::InstallationWaiting); + Exceptions::InstallationWaiting); LogInfo("Installation: " << getFilePath() << " NOT possible"); @@ -83,7 +85,7 @@ void JobPluginInstall::SendFinishedFailure() LogDebug("Call Plugin install failure finishedCallback"); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, - m_exceptionCaught); + m_exceptionCaught); } void JobPluginInstall::SaveExceptionData(const Jobs::JobExceptionBase &e) diff --git a/src/jobs/plugin_install/job_plugin_install.h b/src/jobs/plugin_install/job_plugin_install.h index a7fde44..46af82a 100644 --- a/src/jobs/plugin_install/job_plugin_install.h +++ b/src/jobs/plugin_install/job_plugin_install.h @@ -48,7 +48,7 @@ class JobPluginInstall : * @brief Automaticaly sets installation process */ JobPluginInstall(std::string const &pluginPath, - const PluginInstallerStruct &installerStruct); + const PluginInstallerStruct &installerStruct); WrtDB::DbPluginHandle getNewPluginHandle() const { @@ -67,6 +67,7 @@ class JobPluginInstall : void SendFinishedSuccess(); void SendFinishedFailure(); void SaveExceptionData(const Jobs::JobExceptionBase &e); + private: //TODO move somewhere this attribute //(as it is in all Jobs...) diff --git a/src/jobs/plugin_install/plugin_install_task.cpp b/src/jobs/plugin_install/plugin_install_task.cpp index 57d3c0c..b4c30c3 100644 --- a/src/jobs/plugin_install/plugin_install_task.cpp +++ b/src/jobs/plugin_install/plugin_install_task.cpp @@ -53,7 +53,7 @@ const std::string DIRECTORY_SEPARATOR = std::string("/"); PluginInstallerContext::step, desc); #define DISABLE_IF_PLUGIN_WITHOUT_LIB() \ - if(m_pluginInfo.m_libraryName.empty()) \ + if (m_pluginInfo.m_libraryName.empty()) \ { \ LogWarning("Plugin without library."); \ return; \ @@ -61,7 +61,6 @@ const std::string DIRECTORY_SEPARATOR = std::string("/"); namespace Jobs { namespace PluginInstall { - PluginInstallTask::PluginInstallTask(PluginInstallerContext *inCont) : DPL::TaskDecl(this), m_context(inCont), @@ -81,8 +80,7 @@ PluginInstallTask::PluginInstallTask(PluginInstallerContext *inCont) : } PluginInstallTask::~PluginInstallTask() -{ -} +{} void PluginInstallTask::stepCheckPluginPath() { @@ -128,7 +126,7 @@ void PluginInstallTask::stepParseConfigFile() FOREACH(it, m_pluginInfo.m_featureContainer) { LogDebug("Parsed feature : " << it->m_name); - FOREACH (devCap, it->m_deviceCapabilities) { + FOREACH(devCap, it->m_deviceCapabilities) { LogDebug(" | DevCap : " << *devCap); } } @@ -145,25 +143,22 @@ void PluginInstallTask::stepParseConfigFile() void PluginInstallTask::stepFindPluginLibrary() { - if (m_dataFromConfigXML) - { + if (m_dataFromConfigXML) { return; } LogDebug("Plugin installation: step find plugin library"); std::string pluginPath = m_context->pluginFilePath; size_t indexpos = pluginPath.find_last_of('/'); - if (std::string::npos == indexpos) - { + if (std::string::npos == indexpos) { indexpos = 0; - } - else - { + } else { indexpos += 1; // move after '/' } std::string libName = pluginPath.substr(indexpos); - libName = GlobalConfig::GetPluginPrefix() + libName + GlobalConfig::GetPluginSuffix(); + libName = GlobalConfig::GetPluginPrefix() + libName + + GlobalConfig::GetPluginSuffix(); LogDebug("Plugin .so: " << libName); m_pluginInfo.m_libraryName = libName; } @@ -190,10 +185,10 @@ void PluginInstallTask::stepLoadPluginLibrary() LogDebug("Loading plugin: " << filename); void *dlHandle = dlopen(filename.c_str(), RTLD_NOW); - if (dlHandle == NULL ) { + if (dlHandle == NULL) { LogError( - "Failed to load plugin: " << filename << - ". Reason: " << dlerror()); + "Failed to load plugin: " << filename << + ". Reason: " << dlerror()); ThrowMsg(Exceptions::PluginLibraryError, "Library error"); } @@ -202,14 +197,14 @@ void PluginInstallTask::stepLoadPluginLibrary() getWidgetEntityMapProcPtr = reinterpret_cast(dlsym(dlHandle, - PLUGIN_GET_CLASS_MAP_PROC_NAME)); + PLUGIN_GET_CLASS_MAP_PROC_NAME)); if (getWidgetEntityMapProcPtr) { rawEntityList = (*getWidgetEntityMapProcPtr)(); } else { rawEntityList = static_cast(dlsym(dlHandle, - PLUGIN_CLASS_MAP_NAME)); + PLUGIN_CLASS_MAP_NAME)); } if (rawEntityList == NULL) { @@ -218,14 +213,12 @@ void PluginInstallTask::stepLoadPluginLibrary() ThrowMsg(Exceptions::PluginLibraryError, "Library error"); } - if (!m_dataFromConfigXML) - { + if (!m_dataFromConfigXML) { on_widget_init_proc *onWidgetInitProc = reinterpret_cast( dlsym(dlHandle, PLUGIN_WIDGET_INIT_PROC_NAME)); - if (NULL == onWidgetInitProc) - { + if (NULL == onWidgetInitProc) { dlclose(dlHandle); LogError("Failed to read onWidgetInit symbol" << filename); ThrowMsg(Exceptions::PluginLibraryError, "Library error"); @@ -246,25 +239,24 @@ void PluginInstallTask::stepLoadPluginLibrary() LogDebug("Getting mapping from features to device capabilities"); - for (size_t i = 0; i < devcapMapping->featuresCount; ++i) - { + for (size_t i = 0; i < devcapMapping->featuresCount; ++i) { PluginMetafileData::Feature feature; feature.m_name = devcapMapping->features[i].feature_name; LogDebug("Feature: " << feature.m_name); const devcaps_t* dc = - mappingInterface.dcGetter(devcapMapping, - devcapMapping->features[i].feature_name); + mappingInterface.dcGetter( + devcapMapping, + devcapMapping->features[i]. + feature_name); LogDebug("device=cap: " << dc); - if (dc) - { + if (dc) { LogDebug("devcaps count: " << dc->devCapsCount); - for (size_t j = 0; j < dc->devCapsCount; ++j) - { + for (size_t j = 0; j < dc->devCapsCount; ++j) { LogDebug("devcap: " << dc->deviceCaps[j]); feature.m_deviceCapabilities.insert(dc->deviceCaps[j]); } @@ -284,14 +276,14 @@ void PluginInstallTask::stepLoadPluginLibrary() LogInfo("#####"); while (rawEntityListIterator->parent_name != NULL && - rawEntityListIterator->object_name != NULL) + rawEntityListIterator->object_name != NULL) { LogInfo("##### [" << rawEntityListIterator->object_name << "]: "); LogInfo("##### Parent: " << rawEntityListIterator->parent_name); LogInfo("#####"); m_libraryObjects->addObjects(rawEntityListIterator->parent_name, - rawEntityListIterator->object_name); + rawEntityListIterator->object_name); ++rawEntityListIterator; } @@ -367,10 +359,11 @@ void PluginInstallTask::stepResolvePluginDependencies() LogInfo("Plugin installation: step resolve dependencies "); //DISABLE_IF_PLUGIN_WITHOUT_LIB - if(m_pluginInfo.m_libraryName.empty()) - { - PluginDAO::setPluginInstallationStatus(m_pluginHandle, - PluginDAO::INSTALLATION_COMPLETED); + if (m_pluginInfo.m_libraryName.empty()) { + PluginDAO::setPluginInstallationStatus( + m_pluginHandle, + PluginDAO:: + INSTALLATION_COMPLETED); //Installation completed m_context->pluginHandle = m_pluginHandle; m_context->installationCompleted = true; diff --git a/src/jobs/plugin_install/plugin_installer_errors.h b/src/jobs/plugin_install/plugin_installer_errors.h index 35f0353..73132f0 100644 --- a/src/jobs/plugin_install/plugin_installer_errors.h +++ b/src/jobs/plugin_install/plugin_installer_errors.h @@ -55,5 +55,6 @@ DECLARE_JOB_EXCEPTION(Base, UnknownError, Unknown) } //namespace } //namespace -#endif /* WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_ */ +#endif +//WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_ diff --git a/src/jobs/plugin_install/plugin_metafile_reader.cpp b/src/jobs/plugin_install/plugin_metafile_reader.cpp index ac500e8..b65c2e3 100644 --- a/src/jobs/plugin_install/plugin_metafile_reader.cpp +++ b/src/jobs/plugin_install/plugin_metafile_reader.cpp @@ -57,8 +57,7 @@ PluginMetafileReader::PluginMetafileReader() : m_parserSchema(this) } void PluginMetafileReader::blankFunction(PluginMetafileData & /* data */) -{ -} +{} void PluginMetafileReader::tokenEndLibraryName(PluginMetafileData &data) { diff --git a/src/jobs/plugin_install/plugin_objects.cpp b/src/jobs/plugin_install/plugin_objects.cpp index 71e9131..2747f8b 100644 --- a/src/jobs/plugin_install/plugin_objects.cpp +++ b/src/jobs/plugin_install/plugin_objects.cpp @@ -35,7 +35,8 @@ std::string normalizeName(const std::string& objectName) } if (!objectName.compare(0, GLOBAL_OBJECT_NAME.size(), - GLOBAL_OBJECT_NAME)) { + GLOBAL_OBJECT_NAME)) + { return objectName; } @@ -44,7 +45,7 @@ std::string normalizeName(const std::string& objectName) } std::string normalizeName(const std::string& objectName, - const std::string& parentName) + const std::string& parentName) { if (objectName.empty() || parentName.empty()) { LogError("Normalize name, name size or parent name size is 0"); @@ -76,7 +77,7 @@ PluginObjects::ObjectsPtr PluginObjects::getDependentObjects() const } void PluginObjects::addObjects(const std::string& parentName, - const std::string& name) + const std::string& name) { addImplementedObject(normalizeName(name, parentName)); addDependentObject(normalizeName(parentName)); diff --git a/src/jobs/plugin_install/plugin_objects.h b/src/jobs/plugin_install/plugin_objects.h index 4a8ab14..0b27a14 100644 --- a/src/jobs/plugin_install/plugin_objects.h +++ b/src/jobs/plugin_install/plugin_objects.h @@ -43,7 +43,7 @@ class PluginObjects : public WrtDB::PluginObjectsDAO //add object declaration void addObjects(const std::string& parentName, - const std::string& name); + const std::string& name); //check if library implemements object given as name bool hasObject(const std::string& name) const; diff --git a/src/jobs/widget_install/ace_registration.cpp b/src/jobs/widget_install/ace_registration.cpp index 00165f1..faee3ea 100644 --- a/src/jobs/widget_install/ace_registration.cpp +++ b/src/jobs/widget_install/ace_registration.cpp @@ -26,46 +26,44 @@ #include namespace { - char* toAceString(const DPL::OptionalString& os) { - if (!os.IsNull()) + if (!os.IsNull()) { return strdup(DPL::ToUTF8String(*os).c_str()); - else + } else { return NULL; + } } char* toAceString(const std::string& str) { - if (!str.empty()) + if (!str.empty()) { return strdup(str.c_str()); - else + } else { return NULL; + } } - } //anonymous namespace namespace AceApi { - bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle, - const WrtDB::WidgetRegisterInfo& widgetConfig, - const WrtDB::WidgetCertificateDataList& certList) + const WrtDB::WidgetRegisterInfo& widgetConfig, + const WrtDB::WidgetCertificateDataList& certList) { LogDebug("Updating Ace database"); struct widget_info wi; DPL::OptionalString os; - switch(widgetConfig.webAppType.appType) - { - case WrtDB::APP_TYPE_WAC20: - wi.type = WAC20; - break; - case WrtDB::APP_TYPE_TIZENWEBAPP: - wi.type = Tizen; - break; - default: - LogError("Unknown application type"); - return false; + switch (widgetConfig.webAppType.appType) { + case WrtDB::APP_TYPE_WAC20: + wi.type = WAC20; + break; + case WrtDB::APP_TYPE_TIZENWEBAPP: + wi.type = Tizen; + break; + default: + LogError("Unknown application type"); + return false; } wi.id = toAceString(widgetConfig.configInfo.widget_id); @@ -76,7 +74,8 @@ bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle, //one more element for NULL termination LogDebug("Found: " << certList.size() << " certificates"); - ace_certificate_data** certData = new ace_certificate_data*[certList.size() + 1]; + ace_certificate_data** certData = new ace_certificate_data * + [certList.size() + 1]; certData[certList.size()] = NULL; // last element set to NULL int i = 0; @@ -84,39 +83,40 @@ bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle, { certData[i] = new ace_certificate_data; switch (it->owner) { - case WrtDB::WidgetCertificateData::AUTHOR : + case WrtDB::WidgetCertificateData::AUTHOR: certData[i]->owner = AUTHOR; break; - case WrtDB::WidgetCertificateData::DISTRIBUTOR : + case WrtDB::WidgetCertificateData::DISTRIBUTOR: certData[i]->owner = DISTRIBUTOR; break; - default : + default: LogDebug("Unknown owner type of cert"); certData[i]->owner = UNKNOWN; } switch (it->type) { - case WrtDB::WidgetCertificateData::ENDENTITY : - certData[i]->type = ENDENTITY; - break; - case WrtDB::WidgetCertificateData::ROOT : - certData[i]->type = ROOT; - break; - default : - LogError("Unknown type of cert"); - certData[i]->type = ENDENTITY; + case WrtDB::WidgetCertificateData::ENDENTITY: + certData[i]->type = ENDENTITY; + break; + case WrtDB::WidgetCertificateData::ROOT: + certData[i]->type = ROOT; + break; + default: + LogError("Unknown type of cert"); + certData[i]->type = ENDENTITY; } certData[i]->chain_id = it->chainId; certData[i]->md5_fp = toAceString(it->strMD5Fingerprint); certData[i]->sha1_fp = toAceString(it->strSHA1Fingerprint); - certData[i]->common_name = toAceString(DPL::ToUTF8String(it->strCommonName)); + certData[i]->common_name = + toAceString(DPL::ToUTF8String(it->strCommonName)); ++i; } LogDebug("Registerign widget in ace"); ace_return_t retval = ACE_ACE_UNKNOWN_ERROR; retval = ace_register_widget( - static_cast(widgetHandle), &wi, certData); + static_cast(widgetHandle), &wi, certData); //clean up - WidgetInfo free(wi.author); diff --git a/src/jobs/widget_install/ace_registration.h b/src/jobs/widget_install/ace_registration.h index 2f4a3b0..a9e0577 100644 --- a/src/jobs/widget_install/ace_registration.h +++ b/src/jobs/widget_install/ace_registration.h @@ -25,12 +25,10 @@ #include namespace AceApi { - bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle, const WrtDB::WidgetRegisterInfo& widgetConfig, const WrtDB::WidgetCertificateDataList& certList); - } -#endif /* WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ */ +#endif /* WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ */ diff --git a/src/jobs/widget_install/job_widget_install.cpp b/src/jobs/widget_install/job_widget_install.cpp index 4303a56..1337293 100644 --- a/src/jobs/widget_install/job_widget_install.cpp +++ b/src/jobs/widget_install/job_widget_install.cpp @@ -125,19 +125,21 @@ class InstallerTaskFail : const std::string XML_EXTENSION = ".xml"; -bool hasExtension(const std::string& filename, const std::string& extension) { - LogDebug("Looking for extension " << extension << " in: " << filename); +bool hasExtension(const std::string& filename, const std::string& extension) +{ + LogDebug("Looking for extension " << extension << " in: " << filename); size_t fileLen = filename.length(); size_t extLen = extension.length(); if (fileLen < extLen) { LogError("Filename " << filename << " is shorter than extension " - << extension); + << extension); return false; } - return (0 == filename.compare(fileLen-extLen, extLen, extension)); + return (0 == filename.compare(fileLen - extLen, extLen, extension)); } -bool checkTizenPkgIdExist(const std::string& tizenPkgId) { +bool checkTizenPkgIdExist(const std::string& tizenPkgId) +{ std::string installPath = std::string(GlobalConfig::GetUserInstalledWidgetPath()) + "/" + tizenPkgId; @@ -147,7 +149,8 @@ bool checkTizenPkgIdExist(const std::string& tizenPkgId) { struct stat dirStat; if ((stat(installPath.c_str(), &dirStat) == 0) && - (stat(preinstallPath.c_str(), &dirStat) == 0)) { + (stat(preinstallPath.c_str(), &dirStat) == 0)) + { return true; } return false; @@ -156,8 +159,10 @@ bool checkTizenPkgIdExist(const std::string& tizenPkgId) { namespace Jobs { namespace WidgetInstall { -JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, - const WidgetInstallationStruct &installerStruct) : +JobWidgetInstall::JobWidgetInstall( + std::string const &widgetPath, + const WidgetInstallationStruct & + installerStruct) : Job(Installation), JobContextBase(installerStruct), m_exceptionCaught(Exceptions::Success) @@ -178,17 +183,17 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, // Create installation tasks if (m_installerContext.widgetConfig.packagingType != - WrtDB::PKG_TYPE_DIRECTORY_WEB_APP && + WrtDB::PKG_TYPE_DIRECTORY_WEB_APP && m_installerContext.widgetConfig.packagingType != - WrtDB::PKG_TYPE_HOSTED_WEB_APP && + WrtDB::PKG_TYPE_HOSTED_WEB_APP && !m_isDRM) { AddTask(new TaskUnzip(m_installerContext)); } AddTask(new TaskWidgetConfig(m_installerContext)); - if (m_installerContext.widgetConfig.packagingType == - WrtDB::PKG_TYPE_HOSTED_WEB_APP) + if (m_installerContext.widgetConfig.packagingType == + WrtDB::PKG_TYPE_HOSTED_WEB_APP) { AddTask(new TaskPrepareFiles(m_installerContext)); } @@ -208,7 +213,8 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, AddTask(new TaskManifestFile(m_installerContext)); AddTask(new TaskCertificates(m_installerContext)); if (m_installerContext.widgetConfig.packagingType == - PKG_TYPE_HYBRID_WEB_APP) { + PKG_TYPE_HYBRID_WEB_APP) + { AddTask(new TaskInstallOspsvc(m_installerContext)); } AddTask(new TaskPluginsCopy(m_installerContext)); @@ -219,9 +225,9 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, LogInfo("Widget Update"); m_installerContext.job->SetProgressFlag(true); if (m_installerContext.widgetConfig.packagingType != - WrtDB::PKG_TYPE_HOSTED_WEB_APP && + WrtDB::PKG_TYPE_HOSTED_WEB_APP && m_installerContext.widgetConfig.packagingType != - WrtDB::PKG_TYPE_DIRECTORY_WEB_APP && + WrtDB::PKG_TYPE_DIRECTORY_WEB_APP && !m_isDRM) { AddTask(new TaskUnzip(m_installerContext)); @@ -230,7 +236,7 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, AddTask(new TaskWidgetConfig(m_installerContext)); if (m_installerContext.widgetConfig.packagingType == - WrtDB::PKG_TYPE_HOSTED_WEB_APP) + WrtDB::PKG_TYPE_HOSTED_WEB_APP) { AddTask(new TaskPrepareFiles(m_installerContext)); } @@ -247,7 +253,8 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, AddTask(new TaskManifestFile(m_installerContext)); if (m_installerContext.widgetConfig.packagingType == - PKG_TYPE_HYBRID_WEB_APP) { + PKG_TYPE_HYBRID_WEB_APP) + { AddTask(new TaskInstallOspsvc(m_installerContext)); } if (m_installerContext.widgetConfig.packagingType != @@ -261,7 +268,6 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, //TODO: remove widgetHandle from this task and move before database task // by now widget handle is needed in ace check // Any error in acecheck while update will break widget - } else if (result == ConfigureResult::Deferred) { // Installation is deferred LogInfo("Configure installation deferred"); @@ -278,7 +284,7 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, } JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation( - const std::string &widgetPath) + const std::string &widgetPath) { ConfigureResult result; m_needEncryption = false; @@ -291,7 +297,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation( m_isDRM = isDRMWidget(widgetPath); if (true == m_isDRM) { LogDebug("decrypt DRM widget"); - if(DecryptDRMWidget(widgetPath, tempDir)) { + if (DecryptDRMWidget(widgetPath, tempDir)) { LogDebug("Failed decrypt DRM widget"); return ConfigureResult::Failed; } @@ -302,12 +308,12 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation( m_installerContext.widgetConfig.packagingType = checkPackageType(widgetPath, tempDir); ConfigParserData configData = getWidgetDataFromXML( - widgetPath, - tempDir, - m_installerContext.widgetConfig.packagingType, - m_isDRM); + widgetPath, + tempDir, + m_installerContext.widgetConfig.packagingType, + m_isDRM); LogDebug("widget packaging type : " << - m_installerContext.widgetConfig.packagingType.pkgType); + m_installerContext.widgetConfig.packagingType.pkgType); setTizenId(configData); setApplicationType(configData); @@ -327,24 +333,24 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation( } void JobWidgetInstall::setTizenId( - const WrtDB::ConfigParserData &configInfo) + const WrtDB::ConfigParserData &configInfo) { bool shouldMakeAppid = false; using namespace PackageManager; - if(!!configInfo.tizenAppId) { + if (!!configInfo.tizenAppId) { LogDebug("Setting tizenAppId provided in config.xml: " << - configInfo.tizenAppId); + configInfo.tizenAppId); m_installerContext.widgetConfig.tzAppid = *configInfo.tizenAppId; //check package id. - if(!!configInfo.tizenPkgId) { + if (!!configInfo.tizenPkgId) { LogDebug("Setting tizenPkgId provided in config.xml: " << - configInfo.tizenPkgId); + configInfo.tizenPkgId); m_installerContext.widgetConfig.tzPkgid = *configInfo.tizenPkgId; } else { DPL::String appid = *configInfo.tizenAppId; - if(appid.length() > PACKAGE_ID_LENGTH) { + if (appid.length() > PACKAGE_ID_LENGTH) { m_installerContext.widgetConfig.tzPkgid = appid.substr(0, PACKAGE_ID_LENGTH); } else { @@ -370,10 +376,9 @@ void JobWidgetInstall::setTizenId( m_installerContext.widgetConfig.tzPkgid = pkgId; LogInfo("tizen_id name was generated by WRT: " << m_installerContext.widgetConfig.tzPkgid); - } - if(shouldMakeAppid == true) { + if (shouldMakeAppid == true) { DPL::OptionalString name; DPL::OptionalString defaultLocale = configInfo.defaultlocale; @@ -385,27 +390,27 @@ void JobWidgetInstall::setTizenId( name = localizedData->second.name; break; } - } else { name = localizedData->second.name; break; } } regex_t regx; - if(regcomp(®x, REG_NAME_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){ + if (regcomp(®x, REG_NAME_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) { LogDebug("Regcomp failed"); } LogDebug("Name : " << name); if (!name || (regexec(®x, DPL::ToUTF8String(*name).c_str(), - static_cast(0), NULL, 0) != REG_NOERROR)) { + static_cast(0), NULL, 0) != REG_NOERROR)) + { // TODO : generate name move to wrt-commons std::string allowedString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); std::ostringstream genName; genName << "_" << allowedString[rand() % allowedString.length()]; name = DPL::FromUTF8String(genName.str()); - LogDebug("name was generated by WRT" ); + LogDebug("name was generated by WRT"); } regfree(®x); LogDebug("Name : " << name); @@ -420,10 +425,12 @@ void JobWidgetInstall::setTizenId( // send start signal of pkgmgr getInstallerStruct().pkgmgrInterface->setPkgname(DPL::ToUTF8String( - m_installerContext.widgetConfig.tzAppid)); + m_installerContext. + widgetConfig. + tzAppid)); getInstallerStruct().pkgmgrInterface->sendSignal( - PKGMGR_START_KEY, - PKGMGR_START_INSTALL); + PKGMGR_START_KEY, + PKGMGR_START_INSTALL); LogInfo("Tizen App Id : " << m_installerContext.widgetConfig.tzAppid); LogInfo("Tizen Pkg Id : " << m_installerContext.widgetConfig.tzPkgid); @@ -434,41 +441,48 @@ void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath, const std::string& tempPath) { m_installerContext.locations = - WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.tzPkgid), - widgetPath, tempPath, - m_installerContext.widgetConfig.packagingType, - m_installerContext.locationType); + WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig. + tzPkgid), + widgetPath, tempPath, + m_installerContext.widgetConfig.packagingType, + m_installerContext.locationType); m_installerContext.locations->registerAppid( - DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid)); + DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid)); LogInfo("widgetSource " << widgetPath); } JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation( - const std::string &widgetSource, - const WrtDB::ConfigParserData &configData, - const std::string &tempPath) + const std::string &widgetSource, + const WrtDB::ConfigParserData &configData, + const std::string &tempPath) { - WidgetUpdateInfo update = detectWidgetUpdate(configData, - m_installerContext.widgetConfig.webAppType, - m_installerContext.widgetConfig.tzAppid); + WidgetUpdateInfo update = detectWidgetUpdate( + configData, + m_installerContext. + widgetConfig.webAppType, + m_installerContext. + widgetConfig.tzAppid); ConfigureResult result = checkWidgetUpdate(update); // Validate tizenId regex_t reg; - if(regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){ + if (regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) { LogDebug("Regcomp failed"); } if ((regexec(®, - DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid).c_str(), - static_cast(0), NULL, 0) != REG_NOERROR) || - (checkTizenPkgIdExist(DPL::ToUTF8String(m_installerContext.widgetConfig.tzPkgid)) && - result != ConfigureResult::Updated)) + DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid). + c_str(), + static_cast(0), NULL, 0) != REG_NOERROR) || + (checkTizenPkgIdExist(DPL::ToUTF8String(m_installerContext.widgetConfig + .tzPkgid)) && + result != ConfigureResult::Updated)) { //it is true when tizenId does not fit REG_TIZENID_PATTERN LogError("tizen_id provided but not proper or pkgId directory exists"); - //TODO(t.iwanek): appId is unique, what about installation of abcdefghij.test1 and abcdefghij.test2? + //TODO(t.iwanek): appId is unique, what about installation of + // abcdefghij.test1 and abcdefghij.test2? regfree(®); return ConfigureResult::Failed; } @@ -486,7 +500,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation( } JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate( - const WidgetUpdateInfo &update) + const WidgetUpdateInfo &update) { LogInfo( "Widget install/update: incoming guid = '" << @@ -512,7 +526,8 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate( // Check running state int retval = APP_MANAGER_ERROR_NONE; bool isRunning = false; - retval = app_manager_is_running(DPL::ToUTF8String(tzAppid).c_str(), &isRunning); + retval = app_manager_is_running(DPL::ToUTF8String( + tzAppid).c_str(), &isRunning); if (APP_MANAGER_ERROR_NONE != retval) { LogError("Fail to get running state"); return ConfigureResult::Failed; @@ -543,20 +558,20 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate( // Calc proceed flag if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0 || m_jobStruct.updateMode == - WidgetUpdateMode::PolicyDirectoryForceInstall) + WidgetUpdateMode::PolicyDirectoryForceInstall) { LogInfo("Whether widget policy allow proceed ok"); return ConfigureResult::Updated; - } - else + } else { return ConfigureResult::Failed; + } } return ConfigureResult::Ok; } WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy( - const OptionalWidgetVersion &existingVersion, - const OptionalWidgetVersion &incomingVersion) const + const OptionalWidgetVersion &existingVersion, + const OptionalWidgetVersion &incomingVersion) const { // Widget is installed, check versions if (!existingVersion && !incomingVersion) { @@ -588,10 +603,10 @@ WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy( } ConfigParserData JobWidgetInstall::getWidgetDataFromXML( - const std::string &widgetSource, - const std::string &tempPath, - WrtDB::PackagingType pkgType, - bool isDRM) + const std::string &widgetSource, + const std::string &tempPath, + WrtDB::PackagingType pkgType, + bool isDRM) { // Parse config ParserRunner parser; @@ -601,20 +616,20 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML( { if (pkgType == PKG_TYPE_HOSTED_WEB_APP) { parser.Parse(widgetSource, - ElementParserPtr( - new RootParser(configInfo, - DPL::FromUTF32String( - L"widget")))); + ElementParserPtr( + new RootParser(configInfo, + DPL::FromUTF32String( + L"widget")))); } else if (pkgType == PKG_TYPE_DIRECTORY_WEB_APP) { parser.Parse(widgetSource + '/' + WITH_OSP_XML, ElementParserPtr( new RootParser( - configInfo, - DPL::FromUTF32String(L"widget")))); + configInfo, + DPL::FromUTF32String(L"widget")))); } else { if (!isDRM) { std::unique_ptr zipFile( - new DPL::ZipInput(widgetSource)); + new DPL::ZipInput(widgetSource)); std::unique_ptr configFile; @@ -631,10 +646,11 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML( DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer); DPL::Copy(&inputAdapter, &outputAdapter); parser.Parse(&buffer, - ElementParserPtr( - new RootParser(configInfo, - DPL::FromUTF32String( - L"widget")))); + ElementParserPtr( + new RootParser(configInfo, + DPL:: + FromUTF32String( + L"widget")))); } else { // DRM widget std::string configFile; @@ -645,10 +661,11 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML( } parser.Parse(configFile, - ElementParserPtr( - new RootParser(configInfo, - DPL::FromUTF32String( - L"widget")))); + ElementParserPtr( + new RootParser(configInfo, + DPL:: + FromUTF32String( + L"widget")))); } } } @@ -686,9 +703,9 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML( } WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate( - const ConfigParserData &configInfo, - const WrtDB::WidgetType appType, - const WrtDB::TizenAppId &tizenId) + const ConfigParserData &configInfo, + const WrtDB::WidgetType appType, + const WrtDB::TizenAppId &tizenId) { LogInfo("Checking up widget package for config.xml..."); @@ -719,18 +736,18 @@ WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate( // Search widget handle by GUID WidgetDAOReadOnly dao(widgetGUID); return WidgetUpdateInfo( - widgetGUID, - widgetVersion, - WidgetUpdateInfo::ExistingWidgetInfo( - dao.getTzAppId(), dao.getVersion())); + widgetGUID, + widgetVersion, + WidgetUpdateInfo::ExistingWidgetInfo( + dao.getTzAppId(), dao.getVersion())); } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) { // GUID isn't installed return WidgetUpdateInfo( - widgetGUID, - widgetVersion, - WidgetUpdateInfo::ExistingWidgetInfo()); + widgetGUID, + widgetVersion, + WidgetUpdateInfo::ExistingWidgetInfo()); } } else { Try @@ -738,20 +755,19 @@ WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate( // Search widget handle by appId WidgetDAOReadOnly dao(tizenId); return WidgetUpdateInfo( - widgetGUID, - widgetVersion, - WidgetUpdateInfo::ExistingWidgetInfo( - dao.getTzAppId(), dao.getVersion())); + widgetGUID, + widgetVersion, + WidgetUpdateInfo::ExistingWidgetInfo( + dao.getTzAppId(), dao.getVersion())); } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) { // GUID isn't installed return WidgetUpdateInfo( - widgetGUID, - widgetVersion, - WidgetUpdateInfo::ExistingWidgetInfo()); + widgetGUID, + widgetVersion, + WidgetUpdateInfo::ExistingWidgetInfo()); } - } } @@ -764,12 +780,14 @@ void JobWidgetInstall::SendProgress() std::ostringstream percent; percent << static_cast(GetProgressPercent()); getInstallerStruct().pkgmgrInterface->sendSignal( - PKGMGR_PROGRESS_KEY, - percent.str()); + PKGMGR_PROGRESS_KEY, + percent.str()); LogDebug("Call widget install progressCallbak"); - getInstallerStruct().progressCallback(getInstallerStruct().userParam, - GetProgressPercent(),GetProgressDescription()); + getInstallerStruct().progressCallback( + getInstallerStruct().userParam, + GetProgressPercent(), + GetProgressDescription()); } } } @@ -780,7 +798,6 @@ void JobWidgetInstall::SendFinishedSuccess() // TODO : sync should move to separate task. sync(); - if (INSTALL_LOCATION_TYPE_EXTERNAL == m_installerContext.locationType) { if (false == m_installerContext.existingWidgetInfo.isExist) { WidgetInstallToExtSingleton::Instance().postInstallation(true); @@ -800,12 +817,13 @@ void JobWidgetInstall::SendFinishedSuccess() // send signal of pkgmgr getInstallerStruct().pkgmgrInterface->sendSignal( - PKGMGR_END_KEY, - PKGMGR_END_SUCCESS); + PKGMGR_END_KEY, + PKGMGR_END_SUCCESS); LogDebug("Call widget install successfinishedCallback"); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, - DPL::ToUTF8String(tizenId), Exceptions::Success); + DPL::ToUTF8String( + tizenId), Exceptions::Success); } void JobWidgetInstall::SendFinishedFailure() @@ -822,11 +840,12 @@ void JobWidgetInstall::SendFinishedFailure() // send signal of pkgmgr getInstallerStruct().pkgmgrInterface->sendSignal( - PKGMGR_END_KEY, - PKGMGR_END_FAILURE); + PKGMGR_END_KEY, + PKGMGR_END_FAILURE); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, - DPL::ToUTF8String(tizenId), m_exceptionCaught); + DPL::ToUTF8String( + tizenId), m_exceptionCaught); } void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e) @@ -844,31 +863,32 @@ void JobWidgetInstall::displayWidgetInfo() W3CFileLocalization::getLocalizedInfo(dao.getTzAppId()); out << std::endl << - "===================================== INSTALLED WIDGET INFO ========="\ - "============================"; + "===================================== INSTALLED WIDGET INFO =========" \ + "============================"; out << std::endl << "Name: " << localizedInfo.name; out << std::endl << "AppId: " << dao.getTzAppId(); WidgetSize size = dao.getPreferredSize(); out << std::endl << "Width: " << size.width; out << std::endl << "Height: " << size.height; out << std::endl << "Start File: " << - W3CFileLocalization::getStartFile(dao.getTzAppId()); + W3CFileLocalization::getStartFile(dao.getTzAppId()); out << std::endl << "Version: " << dao.getVersion(); out << std::endl << "Licence: " << - localizedInfo.license; + localizedInfo.license; out << std::endl << "Licence Href: " << - localizedInfo.licenseHref; + localizedInfo.licenseHref; out << std::endl << "Description: " << - localizedInfo.description; + localizedInfo.description; out << std::endl << "Widget Id: " << dao.getGUID(); out << std::endl << "Widget recognized: " << dao.isRecognized(); out << std::endl << "Widget wac signed: " << dao.isWacSigned(); out << std::endl << "Widget distributor signed: " << - dao.isDistributorSigned(); + dao.isDistributorSigned(); out << std::endl << "Widget trusted: " << dao.isTrusted(); OptionalWidgetIcon icon = W3CFileLocalization::getIcon(dao.getTzAppId()); - DPL::OptionalString iconSrc = !!icon ? icon->src : DPL::OptionalString::Null; + DPL::OptionalString iconSrc = + !!icon ? icon->src : DPL::OptionalString::Null; out << std::endl << "Icon: " << iconSrc; out << std::endl << "Preferences:"; @@ -877,9 +897,9 @@ void JobWidgetInstall::displayWidgetInfo() FOREACH(it, list) { out << std::endl << " Key: " << - it->key_name; + it->key_name; out << std::endl << " Readonly: " << - it->readonly; + it->readonly; } } @@ -900,11 +920,12 @@ void JobWidgetInstall::displayWidgetInfo() } WrtDB::PackagingType JobWidgetInstall::checkPackageType( - const std::string &widgetSource, - const std::string &tempPath) + const std::string &widgetSource, + const std::string &tempPath) { // Check installation type (direcotory/ or config.xml or widget.wgt) - if (WidgetUpdateMode::PolicyDirectoryForceInstall == m_jobStruct.updateMode) + if (WidgetUpdateMode::PolicyDirectoryForceInstall == + m_jobStruct.updateMode) { LogDebug("Install directly from directory"); return PKG_TYPE_DIRECTORY_WEB_APP; @@ -931,7 +952,6 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType( { // Open zip file zipFile.reset(new DPL::ZipInput(widgetSource)); - } Catch(DPL::ZipInput::Exception::OpenFailed) { @@ -948,7 +968,7 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType( { // Open config.xml file in package root std::unique_ptr configFile( - zipFile->OpenFile(CONFIG_XML)); + zipFile->OpenFile(CONFIG_XML)); return PKG_TYPE_NOMAL_WEB_APP; } Catch(DPL::ZipInput::Exception::OpenFileFailed) @@ -960,7 +980,7 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType( { // Open config.xml file in package root std::unique_ptr configFile( - zipFile->OpenFile(WITH_OSP_XML)); + zipFile->OpenFile(WITH_OSP_XML)); return PKG_TYPE_HYBRID_WEB_APP; } @@ -975,9 +995,8 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType( } void JobWidgetInstall::setApplicationType( - const WrtDB::ConfigParserData &configInfo) + const WrtDB::ConfigParserData &configInfo) { - FOREACH(iterator, configInfo.nameSpaces) { LogInfo("namespace = [" << *iterator << "]"); AppType currentAppType = APP_TYPE_UNKNOWN; @@ -992,15 +1011,18 @@ void JobWidgetInstall::setApplicationType( { currentAppType = APP_TYPE_WAC20; } else if (*iterator == - ConfigurationNamespace::TizenWebAppNamespaceName) { + ConfigurationNamespace::TizenWebAppNamespaceName) + { currentAppType = APP_TYPE_TIZENWEBAPP; } if (m_installerContext.widgetConfig.webAppType == - APP_TYPE_UNKNOWN) { + APP_TYPE_UNKNOWN) + { m_installerContext.widgetConfig.webAppType = currentAppType; } else if (m_installerContext.widgetConfig.webAppType == - currentAppType) { + currentAppType) + { continue; } else { ThrowMsg(Exceptions::WidgetConfigFileInvalid, @@ -1014,15 +1036,18 @@ void JobWidgetInstall::setApplicationType( } LogInfo("type = [" << - m_installerContext.widgetConfig.webAppType.getApptypeToString() << "]"); + m_installerContext.widgetConfig.webAppType.getApptypeToString() << + "]"); } -bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &configData) +bool JobWidgetInstall::detectResourceEncryption( + const WrtDB::ConfigParserData &configData) { FOREACH(it, configData.settingsList) { if (it->m_name == SETTING_VALUE_ENCRYPTION && - it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE) { + it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE) + { LogDebug("resource need encryption"); return true; } @@ -1030,8 +1055,10 @@ bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &c return false; } -void JobWidgetInstall::setInstallLocationType(const - WrtDB::ConfigParserData &configData) +void JobWidgetInstall::setInstallLocationType( + const + WrtDB::ConfigParserData & + configData) { m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL; @@ -1042,8 +1069,9 @@ void JobWidgetInstall::setInstallLocationType(const FOREACH(it, configData.settingsList) { if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME && - it->m_value == - SETTING_VALUE_INSTALLTOEXT_PREPER_EXT) { + it->m_value == + SETTING_VALUE_INSTALLTOEXT_PREPER_EXT) + { LogDebug("This widget will be installed to sd card"); m_installerContext.locationType = INSTALL_LOCATION_TYPE_EXTERNAL; @@ -1055,16 +1083,16 @@ void JobWidgetInstall::setInstallLocationType(const bool JobWidgetInstall::isDRMWidget(std::string widgetPath) { /* TODO : - drm_bool_type_e is_drm_file = DRM_UNKNOWN; - int ret = -1; - - ret = drm_is_drm_file(widgetPath.c_str(), &is_drm_file); - if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file) { - */ + * drm_bool_type_e is_drm_file = DRM_UNKNOWN; + * int ret = -1; + * + * ret = drm_is_drm_file(widgetPath.c_str(), &is_drm_file); + * if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file) { + */ /* blow code temporary code for drm. */ int ret = drm_oem_intel_isDrmFile(const_cast(widgetPath.c_str())); - if ( 1 == ret) { + if (1 == ret) { return true; } else { return false; @@ -1072,34 +1100,34 @@ bool JobWidgetInstall::isDRMWidget(std::string widgetPath) } bool JobWidgetInstall::DecryptDRMWidget(std::string widgetPath, - std::string destPath) + std::string destPath) { /* TODO : - drm_trusted_sapps_decrypt_package_info_s package_info; - - strncpy(package_info.sadcf_filepath, widgetPath.c_str(), - sizeof(package_info.sadcf_filepath)); - strncpy(package_info.decrypt_filepath, destPath.c_str(), - sizeof(package_info.decrypt_filepath)); - - drm_trusted_request_type_e requestType = - DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE; - - int ret = drm_trusted_handle_request(requestType, - (void *)&package_info, NULL); - if (DRM_TRUSTED_RETURN_SUCCESS == ret) { - return true; - } else { - return false; - } - */ + * drm_trusted_sapps_decrypt_package_info_s package_info; + * + * strncpy(package_info.sadcf_filepath, widgetPath.c_str(), + * sizeof(package_info.sadcf_filepath)); + * strncpy(package_info.decrypt_filepath, destPath.c_str(), + * sizeof(package_info.decrypt_filepath)); + * + * drm_trusted_request_type_e requestType = + * DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE; + * + * int ret = drm_trusted_handle_request(requestType, + * (void *)&package_info, NULL); + * if (DRM_TRUSTED_RETURN_SUCCESS == ret) { + * return true; + * } else { + * return false; + * } + */ if (drm_oem_intel_decrypt_package(const_cast(widgetPath.c_str()), - const_cast(destPath.c_str())) != 0) { + const_cast(destPath.c_str())) != 0) + { return true; } else { return false; } } - } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/job_widget_install.h b/src/jobs/widget_install/job_widget_install.h index ec23ef9..a97b8eb 100644 --- a/src/jobs/widget_install/job_widget_install.h +++ b/src/jobs/widget_install/job_widget_install.h @@ -48,8 +48,8 @@ class JobWidgetInstall : Exceptions::Type m_exceptionCaught; std::string m_exceptionMessage; WidgetUpdateInfo m_widgetUpdateInfo; - bool m_needEncryption; - bool m_isDRM; + bool m_needEncryption; + bool m_isDRM; enum class ConfigureResult { @@ -61,28 +61,28 @@ class JobWidgetInstall : &configData, const std::string &tempPath); static WrtDB::ConfigParserData getWidgetDataFromXML( - const std::string &widgetSource, - const std::string &tempPath, - WrtDB::PackagingType pkgType, - bool isDRM); + const std::string &widgetSource, + const std::string &tempPath, + WrtDB::PackagingType pkgType, + bool isDRM); static WidgetUpdateInfo detectWidgetUpdate( - const WrtDB::ConfigParserData &configInfo, - const WrtDB::WidgetType appType, - const WrtDB::TizenAppId &tizenId); + const WrtDB::ConfigParserData &configInfo, + const WrtDB::WidgetType appType, + const WrtDB::TizenAppId &tizenId); WidgetUpdateMode::Type CalcWidgetUpdatePolicy( - const OptionalWidgetVersion &existingVersion, - const OptionalWidgetVersion &incomingVersion) const; + const OptionalWidgetVersion &existingVersion, + const OptionalWidgetVersion &incomingVersion) const; void setTizenId(const WrtDB::ConfigParserData &configInfo); void displayWidgetInfo(); void configureWidgetLocation(const std::string & widgetPath, const std::string &tempPath); WrtDB::PackagingType checkPackageType( - const std::string &widgetSource, - const std::string &tempPath); + const std::string &widgetSource, + const std::string &tempPath); bool detectResourceEncryption(const WrtDB::ConfigParserData &configData); void setInstallLocationType(const WrtDB::ConfigParserData - &configData); + &configData); bool isDRMWidget(std::string widgetPath); bool DecryptDRMWidget(std::string widgetPath, std::string destPath); ConfigureResult PrePareInstallation(const std::string &widgetPath); @@ -94,7 +94,7 @@ class JobWidgetInstall : * @brief Automaticaly sets installation process */ JobWidgetInstall(std::string const & widgetPath, - const WidgetInstallationStruct &installerStruct); + const WidgetInstallationStruct &installerStruct); //overrides void SendProgress(); diff --git a/src/jobs/widget_install/manifest.cpp b/src/jobs/widget_install/manifest.cpp old mode 100755 new mode 100644 index 0c369d9..f11c954 --- a/src/jobs/widget_install/manifest.cpp +++ b/src/jobs/widget_install/manifest.cpp @@ -25,13 +25,12 @@ namespace Jobs { namespace WidgetInstall { - void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body) { int state = xmlTextWriterWriteElement(writer, BAD_CAST name, - BAD_CAST DPL::ToUTF8String(body).c_str()); - if (state < 0) - { + BAD_CAST DPL::ToUTF8String( + body).c_str()); + if (state < 0) { ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteElement failed"); } } @@ -39,9 +38,8 @@ void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body) void writeText(xmlTextWriterPtr writer, DPL::String text) { int state = xmlTextWriterWriteString(writer, - BAD_CAST DPL::ToUTF8String(text).c_str()); - if (state < 0) - { + BAD_CAST DPL::ToUTF8String(text).c_str()); + if (state < 0) { ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteText failed"); } } @@ -49,15 +47,17 @@ void writeText(xmlTextWriterPtr writer, DPL::String text) void writeElement(xmlTextWriterPtr writer, const char * name, const char * body) { int state = xmlTextWriterWriteElement(writer, BAD_CAST name, BAD_CAST body); - if (state < 0) - { + if (state < 0) { ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteElement failed"); } } -void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name, - DPL::String body, const char * nameAttr, DPL::String bodyAttr, - bool condition = true) +void writeElementWithOneAttribute(xmlTextWriterPtr writer, + const char * name, + DPL::String body, + const char * nameAttr, + DPL::String bodyAttr, + bool condition = true) { startElement(writer, name); writeAttribute(writer, nameAttr, bodyAttr, condition); @@ -68,8 +68,7 @@ void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name, void startElement(xmlTextWriterPtr writer, const char * name) { int state = xmlTextWriterStartElement(writer, BAD_CAST name); - if (state < 0) - { + if (state < 0) { ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterStartElement failed"); } } @@ -77,34 +76,42 @@ void startElement(xmlTextWriterPtr writer, const char * name) void endElement(xmlTextWriterPtr writer) { int state = xmlTextWriterEndElement(writer); - if (state < 0) - { + if (state < 0) { ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterEndElement failed"); } } -void writeAttribute(xmlTextWriterPtr writer, const char * name, DPL::String body, - bool condition = true) +void writeAttribute(xmlTextWriterPtr writer, + const char * name, + DPL::String body, + bool condition = true) { - if (!condition) + if (!condition) { return; + } int state = xmlTextWriterWriteAttribute(writer, BAD_CAST name, - BAD_CAST DPL::ToUTF8String(body).c_str()); - if (state < 0) - { - ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteAttribute failed"); + BAD_CAST DPL::ToUTF8String( + body).c_str()); + if (state < 0) { + ThrowMsg(LibxmlUtils::Libxml2Error, + "xmlTextWriterWriteAttribute failed"); } } -void writeAttribute(xmlTextWriterPtr writer, const char * name, const char * body, - bool condition = true) +void writeAttribute(xmlTextWriterPtr writer, + const char * name, + const char * body, + bool condition = true) { - if (!condition) + if (!condition) { return; - int state = xmlTextWriterWriteAttribute(writer, BAD_CAST name, BAD_CAST body); - if (state < 0) - { - ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteAttribute failed"); + } + int state = xmlTextWriterWriteAttribute(writer, + BAD_CAST name, + BAD_CAST body); + if (state < 0) { + ThrowMsg(LibxmlUtils::Libxml2Error, + "xmlTextWriterWriteAttribute failed"); } } @@ -112,28 +119,28 @@ void Manifest::generate(DPL::String filename) { xmlTextWriterPtr writer; int state; - writer = xmlNewTextWriterFilename(DPL::ToUTF8String(filename).c_str(), 0); //compression set to 0 - if (writer == NULL) + + //compression set to 0 + writer = xmlNewTextWriterFilename(DPL::ToUTF8String(filename).c_str(), 0); + + if (writer == NULL) { ThrowMsg(LibxmlUtils::Libxml2Error, "xmlNewTextWriterFilename failed"); - state = xmlTextWriterSetIndent (writer, 1); - if (state < 0) - { + } + state = xmlTextWriterSetIndent(writer, 1); + if (state < 0) { ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterSetIndent failed"); } state = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); - if (state < 0) - { + if (state < 0) { ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterStartDocument failed"); } this->serialize(writer); state = xmlTextWriterEndDocument(writer); - if (state < 0) - { + if (state < 0) { ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterEndDocument failed"); } - if (writer != NULL) - { + if (writer != NULL) { xmlFreeTextWriter(writer); writer = NULL; } @@ -147,19 +154,20 @@ void Manifest::serialize(xmlTextWriterPtr writer) writeAttribute(writer, "package", this->package); writeAttribute(writer, "type", this->type); writeAttribute(writer, "version", this->version); - if (!this->installLocation.IsNull()) + if (!this->installLocation.IsNull()) { writeAttribute(writer, "install-location", (*this->installLocation), - (*this->installLocation).empty()); + (*this->installLocation).empty()); + } FOREACH(l, this->label) { writeElementWithOneAttribute(writer, "label", l->getString(), - "xml:lang", l->getLang(), l->hasLang()); + "xml:lang", l->getLang(), l->hasLang()); } FOREACH(i, this->icon) { writeElementWithOneAttribute(writer, "icon", i->getString(), - "xml:lang", i->getLang(), i->hasLang()); + "xml:lang", i->getLang(), i->hasLang()); } FOREACH(a, this->author) { @@ -168,15 +176,23 @@ void Manifest::serialize(xmlTextWriterPtr writer) FOREACH(d, this->description) { writeElementWithOneAttribute(writer, "description", d->getString(), - "xml:lang", d->getLang(), d->hasLang()); + "xml:lang", d->getLang(), d->hasLang()); } //FOREACH(c, this->compatibility) { c->serialize(writer); } //FOREACH(d, this->deviceProfile) { d->serialize(writer); } - FOREACH(s, this->serviceApplication) { s->serialize(writer); } - FOREACH(u, this->uiApplication) { u->serialize(writer); } - FOREACH(i, this->imeApplication) { i->serialize(writer); } + FOREACH(s, this->serviceApplication) { + s->serialize(writer); + } + FOREACH(u, this->uiApplication) { + u->serialize(writer); + } + FOREACH(i, this->imeApplication) { + i->serialize(writer); + } //FOREACH(f, this->font) { f->serialize(writer); } - FOREACH(l, this->livebox) { l->serialize(writer); } + FOREACH(l, this->livebox) { + l->serialize(writer); + } } endElement(writer); } @@ -195,21 +211,24 @@ void ServiceApplication::serialize(xmlTextWriterPtr writer) { startElement(writer, "service-application"); writeAttribute(writer, "appid", this->appid); - writeAttribute(writer, "auto-restart", (!this->autoRestart.IsNull() && - (*this->autoRestart)) ? "true" : "false"); + writeAttribute(writer, "auto-restart", + (!this->autoRestart.IsNull() && + (*this->autoRestart)) ? "true" : + "false"); writeAttribute(writer, "exec", this->exec); writeAttribute(writer, "on-boot", (!this->onBoot.IsNull() && - (*this->onBoot)) ? "true" : "false"); + (*this->onBoot)) ? "true" : "false"); writeAttribute(writer, "type", this->type); FOREACH(l, this->label) { - writeElementWithOneAttribute(writer, "label", l->getString(), "xml:lang", - l->getLang(), l->hasLang()); + writeElementWithOneAttribute(writer, "label", + l->getString(), "xml:lang", + l->getLang(), l->hasLang()); } FOREACH(i, this->icon) { writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang", - i->getLang(), i->hasLang()); + i->getLang(), i->hasLang()); } FOREACH(a, this->appControl) { @@ -223,25 +242,34 @@ void UiApplication::serialize(xmlTextWriterPtr writer) startElement(writer, "ui-application"); writeAttribute(writer, "appid", this->appid); writeAttribute(writer, "exec", this->exec); - if (!this->multiple.IsNull()) + if (!this->multiple.IsNull()) { writeAttribute(writer, "multiple", (*this->multiple) ? "true" : "false"); - if (!this->nodisplay.IsNull()) - writeAttribute(writer, "nodisplay", (*this->nodisplay) ? "true" : "false"); - if (!this->taskmanage.IsNull()) - writeAttribute(writer, "taskmanage", (*this->taskmanage) ? "true" : "false"); + } + if (!this->nodisplay.IsNull()) { + writeAttribute(writer, + "nodisplay", + (*this->nodisplay) ? "true" : "false"); + } + if (!this->taskmanage.IsNull()) { + writeAttribute(writer, + "taskmanage", + (*this->taskmanage) ? "true" : "false"); + } writeAttribute(writer, "type", this->type); writeAttribute(writer, "extraid", this->extraid); - if (!this->categories.IsNull()) + if (!this->categories.IsNull()) { writeAttribute(writer, "categories", (*this->categories)); + } FOREACH(l, this->label) { - writeElementWithOneAttribute(writer, "label", l->getString(), "xml:lang", - l->getLang(), l->hasLang()); + writeElementWithOneAttribute(writer, "label", + l->getString(), "xml:lang", + l->getLang(), l->hasLang()); } FOREACH(i, this->icon) { writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang", - i->getLang(), i->hasLang()); + i->getLang(), i->hasLang()); } FOREACH(a, this->appControl) { @@ -261,20 +289,25 @@ void ImeApplication::serialize(xmlTextWriterPtr writer) startElement(writer, "ime-application"); writeAttribute(writer, "appid", this->appid); writeAttribute(writer, "exec", this->exec); - if (!this->multiple.IsNull()) + if (!this->multiple.IsNull()) { writeAttribute(writer, "multiple", (*this->multiple) ? "true" : "false"); - if (!this->nodisplay.IsNull()) - writeAttribute(writer, "nodisplay", (*this->nodisplay) ? "true" : "false"); + } + if (!this->nodisplay.IsNull()) { + writeAttribute(writer, + "nodisplay", + (*this->nodisplay) ? "true" : "false"); + } writeAttribute(writer, "type", this->type); FOREACH(l, this->label) { - writeElementWithOneAttribute(writer, "label", l->getString(), "xml:lang", - l->getLang(), l->hasLang()); + writeElementWithOneAttribute(writer, "label", + l->getString(), "xml:lang", + l->getLang(), l->hasLang()); } FOREACH(i, this->icon) { writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang", - i->getLang(), i->hasLang()); + i->getLang(), i->hasLang()); } endElement(writer); } @@ -306,15 +339,15 @@ void AppControl::serialize(xmlTextWriterPtr writer) void LiveBox::serialize(xmlTextWriterPtr writer) { startElement(writer, "livebox"); - if(!this->liveboxId.empty()) { + if (!this->liveboxId.empty()) { writeAttribute(writer, "appid", this->liveboxId); } - if(!this->primary.empty()) { + if (!this->primary.empty()) { writeAttribute(writer, "primary", this->primary); } - if(!this->updatePeriod.empty()) { + if (!this->updatePeriod.empty()) { writeAttribute(writer, "period", this->updatePeriod); } @@ -322,27 +355,27 @@ void LiveBox::serialize(xmlTextWriterPtr writer) writeAttribute(writer, "network", "true"); writeAttribute(writer, "nodisplay", "false"); - if(!this->label.empty()) { + if (!this->label.empty()) { startElement(writer, "label"); writeText(writer, this->label); endElement(writer); } - if(!this->icon.empty()) { + if (!this->icon.empty()) { startElement(writer, "icon"); writeText(writer, this->icon); endElement(writer); } - if(!this->autoLaunch.empty()) { + if (!this->autoLaunch.empty()) { startElement(writer, "launch"); writeText(writer, this->autoLaunch); endElement(writer); } - if(!this->box.boxSrc.empty() && - !this->box.boxMouseEvent.empty() && - !this->box.boxSize.empty()) + if (!this->box.boxSrc.empty() && + !this->box.boxMouseEvent.empty() && + !this->box.boxSize.empty()) { startElement(writer, "box"); writeAttribute(writer, "type", "buffer"); @@ -352,8 +385,9 @@ void LiveBox::serialize(xmlTextWriterPtr writer) { std::pair boxSize = *m; startElement(writer, "size"); - if(!boxSize.second.empty()) + if (!boxSize.second.empty()) { writeAttribute(writer, "preview", boxSize.second); + } writeText(writer, boxSize.first); endElement(writer); } @@ -364,15 +398,16 @@ void LiveBox::serialize(xmlTextWriterPtr writer) endElement(writer); - if(!this->box.pdSrc.empty() && - !this->box.pdWidth.empty() && - !this->box.pdHeight.empty()) + if (!this->box.pdSrc.empty() && + !this->box.pdWidth.empty() && + !this->box.pdHeight.empty()) { startElement(writer, "pd"); writeAttribute(writer, "type", "buffer"); startElement(writer, "size"); - DPL::String pdSize = this->box.pdWidth+DPL::String(L"x")+this->box.pdHeight; + DPL::String pdSize = this->box.pdWidth + DPL::String(L"x") + + this->box.pdHeight; writeText(writer, pdSize); endElement(writer); @@ -386,6 +421,5 @@ void LiveBox::serialize(xmlTextWriterPtr writer) endElement(writer); } - } //namespace Jobs } //namespace WidgetInstall diff --git a/src/jobs/widget_install/manifest.h b/src/jobs/widget_install/manifest.h old mode 100755 new mode 100644 index d09c057..d2b3917 --- a/src/jobs/widget_install/manifest.h +++ b/src/jobs/widget_install/manifest.h @@ -32,20 +32,29 @@ namespace Jobs { namespace WidgetInstall { - /** * @brief string with optional language attribute */ class StringWithLang { -public: + public: StringWithLang() { } - StringWithLang(DPL::String s): string(s) { } - StringWithLang(DPL::String s, DPL::String l): string(s), lang(l) { } - DPL::String getString() { return this->string; } - DPL::String getLang() { return this->lang; } - bool hasLang() { return !this->lang.empty(); } -private: + StringWithLang(DPL::String s) : string(s) { } + StringWithLang(DPL::String s, DPL::String l) : string(s), lang(l) { } + DPL::String getString() + { + return this->string; + } + DPL::String getLang() + { + return this->lang; + } + bool hasLang() + { + return !this->lang.empty(); + } + + private: DPL::String string; DPL::String lang; }; @@ -55,7 +64,8 @@ typedef StringWithLang LabelType, IconType, DescriptionType; /** * These types are basicaly strings but they should allow usage of different * range of characters or words (details in XML spec.). - * For simplicity DPL::Strings are used, although this can lead to XML validation + * For simplicity DPL::Strings are used, although this can lead to XML + * validation * errors (related to usage of not allowed characters in given places). */ typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType; @@ -69,30 +79,34 @@ typedef DPL::String AppCategoryType; void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body); void writeText(xmlTextWriterPtr writer, DPL::String text); void writeElement(xmlTextWriterPtr writer, const char * name, const char * body); -void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name, - const char * body, const char * nameAttr, DPL::String bodyAttr, - bool condition = true); +void writeElementWithOneAttribute(xmlTextWriterPtr writer, + const char * name, + const char * body, + const char * nameAttr, + DPL::String bodyAttr, + bool condition = true); void startElement(xmlTextWriterPtr writer, const char * name); void endElement(xmlTextWriterPtr writer); void writeAttribute(xmlTextWriterPtr writer, const char * name, - DPL::String body, bool condition); + DPL::String body, bool condition); void writeAttribute(xmlTextWriterPtr writer, const char * name, - const char * body, bool condition); + const char * body, bool condition); /** * @brief author element */ class Author { -public: + public: Author() {} Author(AnySimpleType e, - NcnameType h, - LangType l, - DPL::String b) - : email(e), href(h), lang(l), body(b) {} + NcnameType h, + LangType l, + DPL::String b) : + email(e), href(h), lang(l), body(b) {} void serialize(xmlTextWriterPtr writer); -private: + + private: AnySimpleType email; NcnameType href; LangType lang; @@ -106,13 +120,23 @@ typedef Author AuthorType; */ class AppControl { -public: + public: AppControl() {} - void addOperation(const OperationType &x) { this->operation.push_back(x); } - void addUri(const UriType &x) { this->uri.push_back(x); } - void addMime(const MimeType &x) { this->mime.push_back(x); } + void addOperation(const OperationType &x) + { + this->operation.push_back(x); + } + void addUri(const UriType &x) + { + this->uri.push_back(x); + } + void addMime(const MimeType &x) + { + this->mime.push_back(x); + } void serialize(xmlTextWriterPtr writer); -private: + + private: std::list operation; //attr name AnySimpleType std::list uri; //attr name AnySimpleType std::list mime; //attr name AnySimpleType @@ -125,17 +149,39 @@ typedef AppControl AppControlType; */ class ImeApplication { -public: + public: ImeApplication() {} - void setAppid(const NcnameType &x) { this->appid = x; } - void setExec(const NcnameType &x) { this->exec = x; } - void setMultiple(bool x) { this->multiple = x; } - void setNodisplay(bool x) { this->nodisplay = x; } - void setType(const TypeType &x) { this->type = x; } - void addLabel(const LabelType &x) { this->label.push_back(x); } - void addIcon(const IconType &x) { this->icon.push_back(x); } + void setAppid(const NcnameType &x) + { + this->appid = x; + } + void setExec(const NcnameType &x) + { + this->exec = x; + } + void setMultiple(bool x) + { + this->multiple = x; + } + void setNodisplay(bool x) + { + this->nodisplay = x; + } + void setType(const TypeType &x) + { + this->type = x; + } + void addLabel(const LabelType &x) + { + this->label.push_back(x); + } + void addIcon(const IconType &x) + { + this->icon.push_back(x); + } void serialize(xmlTextWriterPtr writer); -private: + + private: NcnameType appid; NcnameType exec; DPL::OptionalBool multiple; @@ -152,21 +198,43 @@ typedef ImeApplication ImeApplicationType; */ class ServiceApplication { -public: + public: ServiceApplication() {} - void setAppid(const NcnameType &x) { this->appid = x; } - void setAutoRestart(bool x) { this->autoRestart = x; } - void setExec(const AnySimpleType &x) { this->exec = x; } - void setOnBoot(bool x) { this->onBoot = x; } - void setType(const TypeType &x) { this->type = x; } - void addLabel(const LabelType &x) { this->label.push_back(x); } - void addIcon(const IconType &x) { this->icon.push_back(x); } + void setAppid(const NcnameType &x) + { + this->appid = x; + } + void setAutoRestart(bool x) + { + this->autoRestart = x; + } + void setExec(const AnySimpleType &x) + { + this->exec = x; + } + void setOnBoot(bool x) + { + this->onBoot = x; + } + void setType(const TypeType &x) + { + this->type = x; + } + void addLabel(const LabelType &x) + { + this->label.push_back(x); + } + void addIcon(const IconType &x) + { + this->icon.push_back(x); + } void addAppControl(const AppControlType &x) { this->appControl.push_back(x); } void serialize(xmlTextWriterPtr writer); -private: + + private: NcnameType appid; DPL::OptionalBool autoRestart; AnySimpleType exec; @@ -184,18 +252,48 @@ typedef ServiceApplication ServiceApplicationType; */ class UiApplication { -public: + public: UiApplication() {} - void setAppid(const NcnameType &x) { this->appid = x; } - void setExtraid(const NcnameType &x) { this->extraid = x; } - void setExec(const AnySimpleType &x) { this->exec = x; } - void setMultiple(bool x) { this->multiple = x; } - void setNodisplay(bool x) { this->nodisplay = x; } - void setTaskmanage(bool x) { this->taskmanage = x; } - void setType(const TypeType &x) { this->type = x; } - void setCategories(const NcnameType &x) { this->categories = x; } - void addLabel(const LabelType &x) { this->label.push_back(x); } - void addIcon(const IconType &x) { this->icon.push_back(x); } + void setAppid(const NcnameType &x) + { + this->appid = x; + } + void setExtraid(const NcnameType &x) + { + this->extraid = x; + } + void setExec(const AnySimpleType &x) + { + this->exec = x; + } + void setMultiple(bool x) + { + this->multiple = x; + } + void setNodisplay(bool x) + { + this->nodisplay = x; + } + void setTaskmanage(bool x) + { + this->taskmanage = x; + } + void setType(const TypeType &x) + { + this->type = x; + } + void setCategories(const NcnameType &x) + { + this->categories = x; + } + void addLabel(const LabelType &x) + { + this->label.push_back(x); + } + void addIcon(const IconType &x) + { + this->icon.push_back(x); + } void addAppControl(const AppControlType &x) { this->appControl.push_back(x); @@ -205,7 +303,8 @@ public: this->appCategory.push_back(x); } void serialize(xmlTextWriterPtr writer); -private: + + private: NcnameType appid; NcnameType extraid; AnySimpleType exec; @@ -225,8 +324,7 @@ typedef UiApplication UiApplicationType; /** * @brief LiveBox element */ -typedef std::list> boxSizeType; - +typedef std::list > boxSizeType; struct BoxInfo { @@ -241,19 +339,40 @@ typedef BoxInfo BoxInfoType; class LiveBox { -public: + public: LiveBox() { } - void setLiveboxId(const NcnameType &x) { this->liveboxId = x; } - void setPrimary(const NcnameType &x) { this->primary = x; } - void setAutoLaunch(const NcnameType &x) { this->autoLaunch = x; } - void setUpdatePeriod(const NcnameType &x) { this->updatePeriod = x; } - void setLabel(const NcnameType &x) { this->label = x; } - void setIcon(const NcnameType &x) { this->icon = x; } - void setBox(const BoxInfoType &x) { this->box = x; } + void setLiveboxId(const NcnameType &x) + { + this->liveboxId = x; + } + void setPrimary(const NcnameType &x) + { + this->primary = x; + } + void setAutoLaunch(const NcnameType &x) + { + this->autoLaunch = x; + } + void setUpdatePeriod(const NcnameType &x) + { + this->updatePeriod = x; + } + void setLabel(const NcnameType &x) + { + this->label = x; + } + void setIcon(const NcnameType &x) + { + this->icon = x; + } + void setBox(const BoxInfoType &x) + { + this->box = x; + } void serialize(xmlTextWriterPtr writer); -private: + private: NcnameType liveboxId; NcnameType primary; NcnameType autoLaunch; @@ -273,26 +392,35 @@ typedef LiveBox LiveBoxInfo; */ class Manifest { -public: + public: Manifest() {} void serialize(xmlTextWriterPtr writer); void generate(DPL::String filename); - void addLabel(const LabelType &x) { this->label.push_back(x); } - void addIcon(const IconType &x) { this->icon.push_back(x); } - void addAuthor(const AuthorType &x) { this->author.push_back(x); }; + void addLabel(const LabelType &x) + { + this->label.push_back(x); + } + void addIcon(const IconType &x) + { + this->icon.push_back(x); + } + void addAuthor(const AuthorType &x) + { + this->author.push_back(x); + } void addDescription(const DescriptionType &x) { this->description.push_back(x); } -// void addCompatibility(const CompatibilityType &x) -// { -// this->compatibility.push_back(x); -// } -// void addDeviceProfile(const DeviceProfileType &x) -// { -// this->deviceProfile.push_back(x); -// } + // void addCompatibility(const CompatibilityType &x) + // { + // this->compatibility.push_back(x); + // } + // void addDeviceProfile(const DeviceProfileType &x) + // { + // this->deviceProfile.push_back(x); + // } void addServiceApplication(const ServiceApplicationType &x) { this->serviceApplication.push_back(x); @@ -305,7 +433,7 @@ public: { this->imeApplication.push_back(x); } -// void addFont(const FontType &x) { this->font.push_back(x); } + // void addFont(const FontType &x) { this->font.push_back(x); } void addLivebox(const LiveBoxInfo &x) { @@ -316,27 +444,36 @@ public: { this->installLocation = x; } - void setPackage(const NcnameType &x) { this->package = x; } - void setType(const PackageType &x) { this->type = x; } - void setVersion(const NmtokenType &x) { this->version = x; } -private: + void setPackage(const NcnameType &x) + { + this->package = x; + } + void setType(const PackageType &x) + { + this->type = x; + } + void setVersion(const NmtokenType &x) + { + this->version = x; + } + + private: std::list label; std::list icon; std::list author; std::list description; -// std::list compatibility; -// std::list deviceProfile; + // std::list compatibility; + // std::list deviceProfile; std::list serviceApplication; std::list uiApplication; std::list imeApplication; -// std::list font; + // std::list font; std::list livebox; InstallLocationType installLocation; NcnameType package; PackageType type; NmtokenType version; }; - } //namespace Jobs } //namespace WidgetInstall diff --git a/src/jobs/widget_install/task_ace_check.cpp b/src/jobs/widget_install/task_ace_check.cpp index 77e35d1..2697a9c 100644 --- a/src/jobs/widget_install/task_ace_check.cpp +++ b/src/jobs/widget_install/task_ace_check.cpp @@ -38,7 +38,6 @@ namespace Jobs { namespace WidgetInstall { - TaskAceCheck::TaskAceCheck(InstallerContext& context) : DPL::TaskDecl(this), m_context(context) @@ -75,18 +74,21 @@ void TaskAceCheck::StepAceCheck() std::string devCapStr = DPL::ToUTF8String(deviceCap); ace_policy_result_t policyResult = ACE_DENY; + + //TODO: remove dao.getHandle() ace_return_t ret = ace_get_policy_result( const_cast(devCapStr.c_str()), - dao.getHandle(), //TODO: remove dao.getHandle() + dao.getHandle(), &policyResult); if (ACE_OK != ret) { ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "ACE check failure"); + "ACE check failure"); } LogInfo("PolicyResult is : " << static_cast(policyResult)); m_context.staticPermittedDevCaps.insert(std::make_pair(deviceCap, - policyResult == ACE_PERMIT)); + policyResult == + ACE_PERMIT)); m_context.featureLogic->setAceResponse(policyResult != ACE_DENY); } @@ -95,7 +97,8 @@ void TaskAceCheck::StepProcessAceResponse() { WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid); if (m_context.widgetConfig.packagingType == - WrtDB::PKG_TYPE_HOSTED_WEB_APP) { + WrtDB::PKG_TYPE_HOSTED_WEB_APP) + { return; } @@ -109,9 +112,9 @@ void TaskAceCheck::StepProcessAceResponse() std::vector devCaps; std::vector devCapsSmack; // Saving static dev cap permissions - FOREACH (cap, m_context.staticPermittedDevCaps) { + FOREACH(cap, m_context.staticPermittedDevCaps) { LogInfo("staticPermittedDevCaps : " << cap->first - << " smack: " << cap->second); + << " smack: " << cap->second); std::string devCapStr = DPL::ToUTF8String(cap->first); devCaps.push_back(devCapStr); devCapsSmack.push_back(cap->second); @@ -122,21 +125,22 @@ void TaskAceCheck::StepProcessAceResponse() for (unsigned int i = 0; i < devCaps.size(); ++i) { list.items[i].device_capability = - const_cast(devCaps[i].c_str()); + const_cast(devCaps[i].c_str()); list.items[i].smack_granted = - devCapsSmack[i] ? ACE_TRUE : ACE_FALSE; + devCapsSmack[i] ? ACE_TRUE : ACE_FALSE; } - ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(), //TODO: remove dao.getHandle() + //TODO: remove dao.getHandle() + ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(), &list); if (ACE_OK != ret) { ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "ACE failure"); + "ACE failure"); } - delete [] list.items; + delete[] list.items; std::set acceptedFeature; auto it = m_context.featureLogic->resultBegin(); - for (;it != m_context.featureLogic->resultEnd(); ++it) { + for (; it != m_context.featureLogic->resultEnd(); ++it) { if (!(it->rejected)) { acceptedFeature.insert(DPL::ToUTF8String(it->name)); } @@ -145,22 +149,24 @@ void TaskAceCheck::StepProcessAceResponse() featureList.count = acceptedFeature.size(); featureList.items = new ace_string_t[featureList.count]; - size_t i=0; + size_t i = 0; for (std::set::const_iterator iter = acceptedFeature.begin(); - iter != acceptedFeature.end(); ++iter) { + iter != acceptedFeature.end(); ++iter) + { LogDebug("Accepted feature item: " << iter->c_str()); featureList.items[i] = const_cast(iter->c_str()); i++; } - ret = ace_set_accepted_feature(dao.getHandle(), &featureList); //TODO: remove dao.getHandle() + //TODO: remove dao.getHandle() + ret = ace_set_accepted_feature(dao.getHandle(), &featureList); - delete [] featureList.items; + delete[] featureList.items; if (ACE_OK != ret) { LogError("Error in ace_set_feature"); ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "ace_set_feature failure."); + "ace_set_feature failure."); } return; } @@ -175,14 +181,18 @@ void TaskAceCheck::StepCheckAceResponse() LogInfo("Checking ACE response"); if (m_context.featureLogic->isRejected()) { LogError("Installation failure. Some devCap was not accepted by ACE."); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " + ThrowMsg( + Exceptions::NotAllowed, + "Instalation failure. " "Some deviceCap was not accepted by ACE."); } LogInfo("Updating \"feature reject status\" in database!"); auto it = m_context.featureLogic->resultBegin(); auto end = m_context.featureLogic->resultEnd(); - for(;it != end; ++it){ - LogInfo(" |- Feature: " << it->name << " has reject status: " << it->rejected); + for (; it != end; ++it) { + LogInfo( + " |- Feature: " << it->name << " has reject status: " << + it->rejected); if (it->rejected) { WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid); dao.updateFeatureRejectStatus(*it); @@ -194,6 +204,5 @@ void TaskAceCheck::StepCheckAceResponse() InstallerContext::INSTALL_ACE_CHECK, "Widget Access Control Check Finished"); } - } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_certificates.cpp b/src/jobs/widget_install/task_certificates.cpp old mode 100755 new mode 100644 index 14395d4..3854ad6 --- a/src/jobs/widget_install/task_certificates.cpp +++ b/src/jobs/widget_install/task_certificates.cpp @@ -37,7 +37,6 @@ using namespace WrtDB; namespace Jobs { namespace WidgetInstall { - TaskCertificates::TaskCertificates(InstallerContext& context) : DPL::TaskDecl(this), m_context(context) @@ -53,19 +52,20 @@ void TaskCertificates::StepSetCertiInfo() if (pkgmgr_installer_create_certinfo_set_handle(&m_pkgHandle) < 0) { LogError("pkgmgrInstallerCreateCertinfoSetHandle fail"); ThrowMsg(Exceptions::SetCertificateInfoFailed, - "Failed to create certificate handle"); + "Failed to create certificate handle"); } SetCertiInfo(SIGNATURE_AUTHOR); SetCertiInfo(SIGNATURE_DISTRIBUTOR); if ((pkgmgr_installer_save_certinfo( - const_cast(DPL::ToUTF8String( - m_context.widgetConfig.tzPkgid).c_str()), - m_pkgHandle)) < 0) { + const_cast(DPL::ToUTF8String( + m_context.widgetConfig.tzPkgid).c_str()), + m_pkgHandle)) < 0) + { LogError("pkgmgrInstallerSaveCertinfo fail"); ThrowMsg(Exceptions::SetCertificateInfoFailed, - "Failed to Installer Save Certinfo"); + "Failed to Installer Save Certinfo"); } else { LogDebug("Succeed to save Certinfo"); } @@ -89,22 +89,22 @@ void TaskCertificates::SetCertiInfo(CertificateSource source) if (false == chain.load(*it)) { LogError("Chain is broken"); ThrowMsg(Exceptions::SetCertificateInfoFailed, - "Failed to Installer Save Certinfo"); + "Failed to Installer Save Certinfo"); } - if (!chain.sort()){ + if (!chain.sort()) { LogError("Chain failed at sorting"); } ValidationCore::CertificateList list = chain.getCertificateList(); - FOREACH(certIt, list) + FOREACH(certIt, list) { pkgmgr_instcert_type instCertType; if (source == SIGNATURE_DISTRIBUTOR) { std::string - Name(DPL::ToUTF8String(*(*certIt)->getOrganizationName())); + Name(DPL::ToUTF8String(*(*certIt)->getOrganizationName())); size_t found = Name.find("Tizen"); if (found != std::string::npos) { @@ -124,7 +124,8 @@ void TaskCertificates::SetCertiInfo(CertificateSource source) instCertType = PM_SET_DISTRIBUTOR2_ROOT_CERT; } else { if ((*certIt)->isCA()) { - instCertType = PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT; + instCertType = + PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT; } else { instCertType = PM_SET_DISTRIBUTOR2_SIGNER_CERT; } @@ -143,13 +144,14 @@ void TaskCertificates::SetCertiInfo(CertificateSource source) } } LogDebug("cert type : " << instCertType); - if((pkgmgr_installer_set_cert_value( - m_pkgHandle, - instCertType, - const_cast(((*certIt)->getBase64()).c_str()))) < 0) { + if ((pkgmgr_installer_set_cert_value( + m_pkgHandle, + instCertType, + const_cast(((*certIt)->getBase64()).c_str()))) < 0) + { LogError("pkgmgrInstallerSetCertValue fail"); ThrowMsg(Exceptions::SetCertificateInfoFailed, - "Failed to Set CertValue"); + "Failed to Set CertValue"); } } } @@ -158,11 +160,12 @@ void TaskCertificates::SetCertiInfo(CertificateSource source) void TaskCertificates::StepAbortCertiInfo() { if ((pkgmgr_installer_delete_certinfo( - const_cast(DPL::ToUTF8String( - m_context.widgetConfig.tzPkgid).c_str()))) < 0) { + const_cast(DPL::ToUTF8String( + m_context.widgetConfig.tzPkgid).c_str()))) < + 0) + { LogError("pkgmgr_installer_delete_certinfo fail"); } } - } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_certificates.h b/src/jobs/widget_install/task_certificates.h old mode 100755 new mode 100644 index 8a377d6..e689cee --- a/src/jobs/widget_install/task_certificates.h +++ b/src/jobs/widget_install/task_certificates.h @@ -34,7 +34,7 @@ class InstallerContext; namespace Jobs { namespace WidgetInstall { -class TaskCertificates: +class TaskCertificates : public DPL::TaskDecl, public DPL::Event::ICDelegateSupport { diff --git a/src/jobs/widget_install/task_certify.cpp b/src/jobs/widget_install/task_certify.cpp index 4d22aca..9b2d1b9 100644 --- a/src/jobs/widget_install/task_certify.cpp +++ b/src/jobs/widget_install/task_certify.cpp @@ -54,8 +54,8 @@ using namespace WrtDB; namespace { const std::string LABEL_NEW_LINE = "
"; const std::string LABEL_NEW_LINE_2 = "

"; -const std::string UNTRUSTED_WIDGET ="It is an Untrusted Widget"; -const char *QUESTION ="Do you wanto to install?"; +const std::string UNTRUSTED_WIDGET = "It is an Untrusted Widget"; +const char *QUESTION = "Do you wanto to install?"; WidgetCertificateData toWidgetCertificateData(const SignatureData &data, bool root) @@ -79,7 +79,7 @@ WidgetCertificateData toWidgetCertificateData(const SignatureData &data, } Assert(certificate && !certificate->getCommonName().IsNull() && - "CommonName is Null"); + "CommonName is Null"); result.strCommonName = *certificate->getCommonName(); @@ -106,7 +106,8 @@ TaskCertify::TaskCertify(InstallerContext &inCont) : // Block until fixed popup issues if (!GlobalSettings::PopupsTestModeEnabled() - && !m_installContext.m_quiet && !isTizenWebApp()) { + && !m_installContext.m_quiet && !isTizenWebApp()) + { AddStep(&TaskCertify::stepWarningPopup); AddStep(&TaskCertify::stepWarningPopupAnswer); AddStep(&TaskCertify::stepAuthorInfoPopup); @@ -130,14 +131,14 @@ void TaskCertify::processDistributorSignature(const SignatureData &data, CertificateCollection collection; collection.load(data.getCertList()); Assert(collection.sort() && - "Certificate collection can't sort"); + "Certificate collection can't sort"); Assert(collection.isChain() && "Certificate collection is not able to create chain. " "It is not possible to verify this signature."); m_contextData.wacSecurity.getCertificateChainListRef().push_back( - collection); + collection); if (first) { m_contextData.wacSecurity.getCertificateListRef().push_back( @@ -174,7 +175,7 @@ void TaskCertify::processAuthorSignature(const SignatureData &data) "It is not possible to verify this signature."); m_contextData.wacSecurity.getAuthorsCertificateChainListRef().push_back( - collection); + collection); FOREACH(it, dnsIdentity){ if (widgetId.matchHost(*it)) { @@ -188,7 +189,8 @@ void TaskCertify::stepSignature() { LogInfo("================ Step: <> ENTER ==============="); - std::string widgetPath = m_contextData.locations->getTemporaryRootDir() + "/"; + std::string widgetPath = m_contextData.locations->getTemporaryRootDir() + + "/"; SignatureFileInfoSet signatureFiles; SignatureFinder signatureFinder(widgetPath); @@ -216,27 +218,31 @@ void TaskCertify::stepSignature() xml.initialize(data, GlobalConfig::GetSignatureXmlSchema()); xml.read(data); - WrtSignatureValidator::AppType appType = WrtSignatureValidator::WAC20; + WrtSignatureValidator::AppType appType = + WrtSignatureValidator::WAC20; - if (m_installContext.widgetConfig.webAppType == APP_TYPE_TIZENWEBAPP) { + if (m_installContext.widgetConfig.webAppType == + APP_TYPE_TIZENWEBAPP) + { appType = WrtSignatureValidator::TIZEN; } WrtSignatureValidator::Result result; if (m_contextData.widgetConfig.packagingType - == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) + == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) { // In directory installation mode, the validation is skipped. result = WrtSignatureValidator::SIGNATURE_VERIFIED; - } - else - { - WrtSignatureValidator validator(appType, - !GlobalSettings::OCSPTestModeEnabled(), - !GlobalSettings::CrlTestModeEnabled(), - complianceMode); + } else { + WrtSignatureValidator validator( + appType, + !GlobalSettings:: + OCSPTestModeEnabled(), + !GlobalSettings:: + CrlTestModeEnabled(), + complianceMode); result = validator.check(data, widgetPath); } @@ -259,7 +265,9 @@ void TaskCertify::stepSignature() m_contextData.wacSecurity.isDistributorSigned()) { processAuthorSignature(data); - } else if (result == WrtSignatureValidator::SIGNATURE_DISREGARD) { + } else if (result == + WrtSignatureValidator::SIGNATURE_DISREGARD) + { continue; } } else { @@ -276,8 +284,7 @@ void TaskCertify::stepSignature() std::string realMEID; TapiHandle *tapiHandle = tel_init(NULL); char *meid = tel_get_misc_me_sn_sync(tapiHandle); - if (meid) - { + if (meid) { realMEID = meid; free(meid); } @@ -329,11 +336,11 @@ void TaskCertify::stepSignature() void TaskCertify::createInstallPopup(PopupType type, const std::string &label) { m_contextData.job->Pause(); - if(m_popup) + if (m_popup) { destroyPopup(); + } bool ret = createPopup(); - if(ret) - { + if (ret) { loadPopup(type, label); showPopup(); } @@ -414,9 +421,9 @@ std::string TaskCertify::createAuthorWidgetInfo() const void TaskCertify::stepAuthorInfoPopup() { LogInfo("Step:: <>"); - std::string label - = createAuthorWidgetInfo() + LABEL_NEW_LINE_2 + QUESTION; - createInstallPopup(PopupType::WIDGET_AUTHOR_INFO, label); + std::string label + = createAuthorWidgetInfo() + LABEL_NEW_LINE_2 + QUESTION; + createInstallPopup(PopupType::WIDGET_AUTHOR_INFO, label); } void TaskCertify::stepFinalize() @@ -428,12 +435,11 @@ void TaskCertify::stepFinalize() "Widget Certification Check Finished"); } - void TaskCertify::stepWarningPopupAnswer() { LogInfo("Step: <>"); if (false == m_contextData.wacSecurity.isDistributorSigned() && - WRT_POPUP_BUTTON_CANCEL == m_installCancel) + WRT_POPUP_BUTTON_CANCEL == m_installCancel) { LogWarning("User does not agreed to install unsigned widgets!"); m_installCancel = WRT_POPUP_BUTTON; @@ -445,7 +451,7 @@ void TaskCertify::stepWarningPopupAnswer() void TaskCertify::stepAuthorInfoPopupAnswer() { LogInfo("Step: <>"); - if ( WRT_POPUP_BUTTON_CANCEL == m_installCancel) { + if (WRT_POPUP_BUTTON_CANCEL == m_installCancel) { LogWarning("User does not agreed to install widget!"); m_installCancel = WRT_POPUP_BUTTON; destroyPopup(); @@ -457,8 +463,10 @@ bool TaskCertify::isTizenWebApp() const { bool ret = FALSE; if (m_installContext.widgetConfig.webAppType.appType - == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) + == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) + { ret = TRUE; + } return ret; } diff --git a/src/jobs/widget_install/task_certify.h b/src/jobs/widget_install/task_certify.h old mode 100755 new mode 100644 index e6ca9ac..8ee7e2b --- a/src/jobs/widget_install/task_certify.h +++ b/src/jobs/widget_install/task_certify.h @@ -60,13 +60,12 @@ class TaskCertify : void createInstallPopup(PopupType type, const std::string &label); void processDistributorSignature(const ValidationCore::SignatureData &data, - bool first); + bool first); void processAuthorSignature(const ValidationCore::SignatureData &data); std::string createAuthorWidgetInfo() const; bool isTizenWebApp() const; - }; } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_commons.cpp b/src/jobs/widget_install/task_commons.cpp index fea9ea1..ff1006a 100644 --- a/src/jobs/widget_install/task_commons.cpp +++ b/src/jobs/widget_install/task_commons.cpp @@ -34,63 +34,60 @@ namespace Jobs { namespace WidgetInstall { - namespace { - const char * const TEMPORARY_PATH_POSTFIX = "temp"; const mode_t TEMPORARY_PATH_MODE = 0775; - } // namespace - std::string createTempPath(bool preload) { LogInfo("Step: Creating temporary path"); - // Temporary path - std::ostringstream tempPathBuilder; - - if (preload) { - tempPathBuilder << WrtDB::GlobalConfig::GetUserPreloadedWidgetPath(); - } else { - tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath(); - } - tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath(); - tempPathBuilder << "/"; - tempPathBuilder << TEMPORARY_PATH_POSTFIX; - tempPathBuilder << "_"; - - timeval tv; - gettimeofday(&tv, NULL); - tempPathBuilder << - (static_cast(tv.tv_sec) * 1000000ULL + - static_cast(tv.tv_usec)); - - std::string tempPath = tempPathBuilder.str(); - - // Remove old path if any - struct stat fileInfo; - - if (stat(tempPath.c_str(), &fileInfo) == 0) { - if(!WrtUtilRemove(tempPath)){ - ThrowMsg(Exceptions::RemovingFolderFailure, - "Failed to to remove temporary directory"); - } - } - // Create new path - if(!WrtUtilMakeDir(tempPath, TEMPORARY_PATH_MODE)){ - ThrowMsg(Exceptions::InternalError, "Failed to create temporary directory"); - } - - return tempPath; + // Temporary path + std::ostringstream tempPathBuilder; + + if (preload) { + tempPathBuilder << WrtDB::GlobalConfig::GetUserPreloadedWidgetPath(); + } else { + tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath(); + } + tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath(); + tempPathBuilder << "/"; + tempPathBuilder << TEMPORARY_PATH_POSTFIX; + tempPathBuilder << "_"; + + timeval tv; + gettimeofday(&tv, NULL); + tempPathBuilder << + (static_cast(tv.tv_sec) * 1000000ULL + + static_cast(tv.tv_usec)); + + std::string tempPath = tempPathBuilder.str(); + + // Remove old path if any + struct stat fileInfo; + + if (stat(tempPath.c_str(), &fileInfo) == 0) { + if (!WrtUtilRemove(tempPath)) { + ThrowMsg(Exceptions::RemovingFolderFailure, + "Failed to to remove temporary directory"); + } + } + // Create new path + if (!WrtUtilMakeDir(tempPath, TEMPORARY_PATH_MODE)) { + ThrowMsg(Exceptions::InternalError, + "Failed to create temporary directory"); + } + + return tempPath; } void createTempPath(const std::string& path) { - if(!WrtUtilMakeDir(path, TEMPORARY_PATH_MODE)){ - ThrowMsg(Exceptions::InternalError, "Failed to create temporary directory"); - } + if (!WrtUtilMakeDir(path, TEMPORARY_PATH_MODE)) { + ThrowMsg(Exceptions::InternalError, + "Failed to create temporary directory"); + } } - } // WidgetInstall } // Jobs diff --git a/src/jobs/widget_install/task_commons.h b/src/jobs/widget_install/task_commons.h index 5193c3d..6a2f223 100644 --- a/src/jobs/widget_install/task_commons.h +++ b/src/jobs/widget_install/task_commons.h @@ -26,16 +26,13 @@ namespace Jobs { namespace WidgetInstall { - //TODO make directory like jobs common? std::string createTempPath(bool preload = false); std::string createTempPath(bool preload); void createTempPath(const std::string& path); - } // WidgetInstall } // Jobs - #endif /* INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_COMMONS_H_ */ diff --git a/src/jobs/widget_install/task_database.cpp b/src/jobs/widget_install/task_database.cpp index ea2cd3c..d5ba2b9 100644 --- a/src/jobs/widget_install/task_database.cpp +++ b/src/jobs/widget_install/task_database.cpp @@ -18,7 +18,8 @@ * @author Lukasz Wrzosek(l.wrzosek@samsung.com) * @author Soyoung kim(sy037.kim@samsung.com) * @version 1.0 - * @brief Implementation file for installer task database updating for widget update + * @brief Implementation file for installer task database updating for widget + * update */ #include #include @@ -46,7 +47,6 @@ using namespace WrtDB; namespace Jobs { namespace WidgetInstall { - TaskDatabase::TaskDatabase(InstallerContext& context) : DPL::TaskDecl(this), m_context(context), @@ -70,40 +70,41 @@ void TaskDatabase::StepWrtDBInsert() /* Set install Time */ time(&m_context.widgetConfig.installedTime); - if (m_context.existingWidgetInfo.isExist) //update - { + if (m_context.existingWidgetInfo.isExist) { //update LogInfo("Registering widget... (update)"); Try { m_handleToRemove = WidgetDAOReadOnly::getHandle( - m_context.widgetConfig.tzAppid); + m_context.widgetConfig.tzAppid); } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) { - LogError("Given tizenId not found for update installation (Same GUID?)"); - ThrowMsg(Exceptions::InvalidPackage, "Given tizenId not found for update installation"); + LogError( + "Given tizenId not found for update installation (Same GUID?)"); + ThrowMsg(Exceptions::InvalidPackage, + "Given tizenId not found for update installation"); } WidgetDAO::registerOrUpdateWidget( - m_context.widgetConfig.tzAppid, - m_context.widgetConfig, - m_context.wacSecurity); + m_context.widgetConfig.tzAppid, + m_context.widgetConfig, + m_context.wacSecurity); m_handle = WidgetDAOReadOnly::getHandle( - m_context.widgetConfig.tzAppid); - } - else //new installation - { + m_context.widgetConfig.tzAppid); + } else { //new installation LogInfo("Registering widget..."); WidgetDAO::registerWidget( - m_context.widgetConfig.tzAppid, - m_context.widgetConfig, - m_context.wacSecurity); + m_context.widgetConfig.tzAppid, + m_context.widgetConfig, + m_context.wacSecurity); m_handle = WidgetDAOReadOnly::getHandle( - m_context.widgetConfig.tzAppid); + m_context.widgetConfig.tzAppid); } - FOREACH (cap, m_context.staticPermittedDevCaps) { - LogInfo("staticPermittedDevCaps : " << cap->first - << " smack status: " << cap->second); + FOREACH(cap, m_context.staticPermittedDevCaps) { + LogInfo( + "staticPermittedDevCaps : " << cap->first + << " smack status: " << + cap->second); } LogInfo("Widget registered"); @@ -128,15 +129,17 @@ void TaskDatabase::StepAceDBInsert() if (ACE_OK != ace_unregister_widget( static_cast(m_handleToRemove))) { - LogWarning("Error while removing ace entry for previous insallation"); - }; + LogWarning( + "Error while removing ace entry for previous insallation"); + } } - if(!AceApi::registerAceWidget(m_handle, m_context.widgetConfig, - m_context.wacSecurity.getCertificateList())) + if (!AceApi::registerAceWidget(m_handle, m_context.widgetConfig, + m_context.wacSecurity.getCertificateList())) { LogError("ace database insert failed"); - ThrowMsg(Exceptions::UpdateFailed, "Update failure. ace_register_widget failed"); + ThrowMsg(Exceptions::UpdateFailed, + "Update failure. ace_register_widget failed"); } LogDebug("Ace data inserted"); @@ -147,16 +150,19 @@ void TaskDatabase::StepAceDBInsert() void TaskDatabase::StepRegisterExternalFiles() { - WrtDB::ExternalLocationList externalLocationsUpdate = m_context.locations->listExternalLocations(); - if (m_context.existingWidgetInfo.isExist) //update - { + WrtDB::ExternalLocationList externalLocationsUpdate = + m_context.locations->listExternalLocations(); + if (m_context.existingWidgetInfo.isExist) { //update Try { WidgetDAO dao(m_context.widgetConfig.tzAppid); - WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations(); + WrtDB::ExternalLocationList externalLocationsDB = + dao.getWidgetExternalLocations(); FOREACH(file, externalLocationsDB) { - if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end()) + if (std::find(externalLocationsUpdate.begin(), + externalLocationsUpdate.end(), + *file) == externalLocationsUpdate.end()) { m_externalLocationsToRemove.push_back(*file); } @@ -164,8 +170,10 @@ void TaskDatabase::StepRegisterExternalFiles() } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) { - LogError("Given tizenId not found for update installation (Same GUID?)"); - ThrowMsg(Exceptions::UpdateFailed, "Given tizenId not found for update installation"); + LogError( + "Given tizenId not found for update installation (Same GUID?)"); + ThrowMsg(Exceptions::UpdateFailed, + "Given tizenId not found for update installation"); } } LogDebug("Registering external files:"); @@ -180,31 +188,25 @@ void TaskDatabase::StepRegisterExternalFiles() void TaskDatabase::StepRemoveExternalFiles() { - if(!m_externalLocationsToRemove.empty()) - { + if (!m_externalLocationsToRemove.empty()) { LogDebug("Removing external files:"); } FOREACH(file, m_externalLocationsToRemove) { - if(WrtUtilFileExists(*file)) - { + if (WrtUtilFileExists(*file)) { LogDebug(" -> " << *file); if (-1 == TEMP_FAILURE_RETRY(remove(file->c_str()))) { ThrowMsg(Exceptions::RemovingFileFailure, "Failed to remove external file"); } - } - else if(WrtUtilDirExists(*file)) - { + } else if (WrtUtilDirExists(*file)) { LogDebug(" -> " << *file); - if(!WrtUtilRemove(*file)){ + if (!WrtUtilRemove(*file)) { ThrowMsg(Exceptions::RemovingFolderFailure, - "Failed to remove external directory"); + "Failed to remove external directory"); } - } - else - { + } else { LogWarning(" -> " << *file << "(no such a path)"); } } @@ -244,7 +246,8 @@ void TaskDatabase::StepCreateVconf() command << " \"" << static_cast((*it).second) << "\""; int ret = system(command.str().c_str()); if (-1 == ret) { - ThrowMsg(Exceptions::CreateVconfFailure, "Failed to create vconf files"); + ThrowMsg(Exceptions::CreateVconfFailure, + "Failed to create vconf files"); } } } @@ -265,8 +268,9 @@ void TaskDatabase::StepAbortDBInsert() ace_unregister_widget(static_cast(m_handle)); // Remove also old one. If it was already updated nothing wrong will happen, // but if not old widget will be removed. - if (INVALID_WIDGET_HANDLE != m_handleToRemove) + if (INVALID_WIDGET_HANDLE != m_handleToRemove) { ace_unregister_widget(static_cast(m_handle)); + } } void TaskDatabase::StepLiveboxDBInsert() @@ -278,7 +282,7 @@ void TaskDatabase::StepLiveboxDBInsert() std::string tizenId = DPL::ToUTF8String(m_context.widgetConfig.tzAppid); for (auto it = m_context.widgetConfig.configInfo.m_livebox.begin(); - it != m_context.widgetConfig.configInfo.m_livebox.end(); ++it) + it != m_context.widgetConfig.configInfo.m_livebox.end(); ++it) { std::string boxId = DPL::ToUTF8String((**it).m_liveboxId); std::string boxType; @@ -292,13 +296,12 @@ void TaskDatabase::StepLiveboxDBInsert() int ret = web_provider_info_insert_box_type( - boxId.c_str(), tizenId.c_str(), boxType.c_str()); + boxId.c_str(), tizenId.c_str(), boxType.c_str()); if (ret < 0) { LogDebug("failed to set type of livebox: " << boxId); } } } - } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_database.h b/src/jobs/widget_install/task_database.h index 5b2c154..608dbfe 100644 --- a/src/jobs/widget_install/task_database.h +++ b/src/jobs/widget_install/task_database.h @@ -32,7 +32,7 @@ class InstallerContext; namespace Jobs { namespace WidgetInstall { -class TaskDatabase: +class TaskDatabase : public DPL::TaskDecl { private: diff --git a/src/jobs/widget_install/task_encrypt_resource.cpp b/src/jobs/widget_install/task_encrypt_resource.cpp index b6fe720..0d61b81 100644 --- a/src/jobs/widget_install/task_encrypt_resource.cpp +++ b/src/jobs/widget_install/task_encrypt_resource.cpp @@ -79,7 +79,7 @@ void TaskEncryptResource::StepEncryptResource() LogDebug("Step Encrypt resource"); m_resEnc = new ResourceEncryptor; m_resEnc->CreateEncryptionKey(DPL::ToUTF8String(m_context. - widgetConfig.tzAppid)); + widgetConfig.tzAppid)); EncryptDirectory(m_context.locations->getTemporaryRootDir()); } @@ -88,52 +88,52 @@ void TaskEncryptResource::EncryptDirectory(std::string path) { FTS *fts; FTSENT *ftsent; - char * const paths[] = {const_cast(path.c_str()), NULL}; + char * const paths[] = { const_cast(path.c_str()), NULL }; - if ((fts = fts_open(paths, FTS_PHYSICAL|FTS_NOCHDIR, NULL)) == NULL) { + if ((fts = fts_open(paths, FTS_PHYSICAL | FTS_NOCHDIR, NULL)) == NULL) { //ERROR int error = errno; LogWarning(__PRETTY_FUNCTION__ << ": fts_open failed with error: " - << strerror(error)); + << strerror(error)); ThrowMsg(Exceptions::InternalError, "Error reading directory: " - << path); + << path); } while ((ftsent = fts_read(fts)) != NULL) { switch (ftsent->fts_info) { - case FTS_DP: - case FTS_DC: - case FTS_D: - case FTS_DEFAULT: - case FTS_SLNONE: - //directories, non-regular files, dangling symbolic links - break; - case FTS_F: - case FTS_NSOK: - case FTS_SL: - //regular files and other objects that can be counted - if (isSupportedForEncryption(ftsent->fts_path)) { - EncryptFile(ftsent->fts_path); - } - break; - case FTS_NS: - case FTS_DOT: - case FTS_DNR: - case FTS_ERR: - default: - LogWarning(__PRETTY_FUNCTION__ - << ": traversal failed on file: " - << ftsent->fts_path - << " with error: " - << strerror(ftsent->fts_errno)); - ThrowMsg(Exceptions::InternalError, "Error reading file"); + case FTS_DP: + case FTS_DC: + case FTS_D: + case FTS_DEFAULT: + case FTS_SLNONE: + //directories, non-regular files, dangling symbolic links + break; + case FTS_F: + case FTS_NSOK: + case FTS_SL: + //regular files and other objects that can be counted + if (isSupportedForEncryption(ftsent->fts_path)) { + EncryptFile(ftsent->fts_path); + } + break; + case FTS_NS: + case FTS_DOT: + case FTS_DNR: + case FTS_ERR: + default: + LogWarning(__PRETTY_FUNCTION__ + << ": traversal failed on file: " + << ftsent->fts_path + << " with error: " + << strerror(ftsent->fts_errno)); + ThrowMsg(Exceptions::InternalError, "Error reading file"); } } if (fts_close(fts) == -1) { int error = errno; LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: " - << strerror(error)); + << strerror(error)); } } @@ -146,11 +146,11 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName) struct stat buf; int ret = stat(fileName.c_str(), &buf); - if(ret == 0) { + if (ret == 0) { size_t fileSize = buf.st_size; FILE* resFp = fopen(fileName.c_str(), "r"); - if ( NULL == resFp) { + if (NULL == resFp) { LogError("Couldnot open file : " << fileName); return; } @@ -164,10 +164,12 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName) memset(outEncBuf, 0, blockSize); ret = fread(readBuf, sizeof(unsigned char), fileSize, resFp); - if (ret!=fileSize){ - LogError("Failed to read ecryption buffer with error: " << strerror(errno) ); + if (ret != fileSize) { + LogError( + "Failed to read ecryption buffer with error: " << + strerror(errno) ); fclose(resFp); - return; + return; } m_resEnc->EncryptChunk(readBuf, outEncBuf, fileSize); @@ -192,8 +194,9 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName) } std::string realPath = fileName; - realPath.replace(0, m_context.locations->getTemporaryRootDir().length(), - m_context.locations->getSourceDir()); + realPath.replace(0, + m_context.locations->getTemporaryRootDir().length(), + m_context.locations->getSourceDir()); WrtDB::EncryptedFileInfo info; info.fileName = DPL::FromUTF8String(realPath); diff --git a/src/jobs/widget_install/task_encrypt_resource.h b/src/jobs/widget_install/task_encrypt_resource.h index de37640..72dac56 100644 --- a/src/jobs/widget_install/task_encrypt_resource.h +++ b/src/jobs/widget_install/task_encrypt_resource.h @@ -31,10 +31,9 @@ class InstallerContext; namespace Jobs { namespace WidgetInstall { - class TaskEncryptResource : public DPL::TaskDecl { -private: + private: // Installation context InstallerContext &m_context; std::string tempInstalledPath; @@ -49,7 +48,6 @@ private: public: explicit TaskEncryptResource(InstallerContext &installerContext); }; - } // namespace WidgetInstall } // namespace Jobs #endif /* SRC_JOBS_WIDGET_INSTALL_TASK_ENCRYPT_RESOURCE_H_ */ diff --git a/src/jobs/widget_install/task_file_manipulation.cpp b/src/jobs/widget_install/task_file_manipulation.cpp index 82aa151..65ccc0f 100644 --- a/src/jobs/widget_install/task_file_manipulation.cpp +++ b/src/jobs/widget_install/task_file_manipulation.cpp @@ -68,7 +68,7 @@ bool _FolderCopy(std::string source, std::string dest) } if (S_ISDIR(statInfo.st_mode)) { - if(("." == fileName) || (".." == fileName)) { + if (("." == fileName) || (".." == fileName)) { continue; } std::string destFolder = dest + "/" + fileName; @@ -87,7 +87,7 @@ bool _FolderCopy(std::string source, std::string dest) outfile.close(); infile.close(); } - } while(dEntry); + } while (dEntry); closedir(dir); return true; } @@ -100,11 +100,12 @@ TaskFileManipulation::TaskFileManipulation(InstallerContext& context) : m_context(context) { if (INSTALL_LOCATION_TYPE_EXTERNAL != - m_context.locationType) { + m_context.locationType) + { AddStep(&TaskFileManipulation::StepCreateDirs); AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir); if (m_context.widgetConfig.packagingType != - WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) + WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) { AddStep(&TaskFileManipulation::StepRenamePath); AddAbortStep(&TaskFileManipulation::StepAbortRenamePath); @@ -149,37 +150,37 @@ void TaskFileManipulation::StepCreatePrivateStorageDir() std::string storagePath = m_context.locations->getPrivateStorageDir(); if (euidaccess(storagePath.c_str(), F_OK) != 0) { - if(!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)){ + if (!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)) { LogError("Failed to create directory for private storage"); ThrowMsg(Exceptions::InternalError, - "Failed to create directory for private storage"); + "Failed to create directory for private storage"); } // '5000' is default uid, gid for applications. - // So installed applications should be launched as process of uid '5000'. + // So installed applications should be launched as process of uid + // '5000'. // the process can access private directory 'data' of itself. - if(chown(storagePath.c_str(), - WEBAPP_DEFAULT_UID, - WEBAPP_DEFAULT_GID) != 0) + if (chown(storagePath.c_str(), + WEBAPP_DEFAULT_UID, + WEBAPP_DEFAULT_GID) != 0) { ThrowMsg(Exceptions::InternalError, - "Chown to invaild user"); + "Chown to invaild user"); } } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) { LogInfo("Private storage already exists."); // Even if private directory already is created, private dircetory // should change owner. - if(chown(storagePath.c_str(), - WEBAPP_DEFAULT_UID, - WEBAPP_DEFAULT_GID) != 0) + if (chown(storagePath.c_str(), + WEBAPP_DEFAULT_UID, + WEBAPP_DEFAULT_GID) != 0) { ThrowMsg(Exceptions::InternalError, - "Chown to invaild user"); + "Chown to invaild user"); } - if(chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) { + if (chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) { ThrowMsg(Exceptions::InternalError, - "chmod to 0700"); + "chmod to 0700"); } - } else { ThrowMsg(Exceptions::InternalError, "No access to private storage."); @@ -199,12 +200,14 @@ void TaskFileManipulation::StepRenamePath() LogDebug("Copy file from temp directory to " << instDir); if (!WrtUtilRemove(instDir)) { ThrowMsg(Exceptions::RemovingFolderFailure, - "Error occurs during removing existing folder"); + "Error occurs during removing existing folder"); } - if (!(rename(m_context.locations->getTemporaryPackageDir().c_str(), instDir.c_str()) == 0)) { + if (!(rename(m_context.locations->getTemporaryPackageDir().c_str(), + instDir.c_str()) == 0)) + { ThrowMsg(Exceptions::UnknownError, - "Error occurs during renaming widget folder"); + "Error occurs during renaming widget folder"); } m_context.job->UpdateProgress( InstallerContext::INSTALL_RENAME_PATH, @@ -219,7 +222,7 @@ void TaskFileManipulation::StepAbortRenamePath() widgetPath = m_context.locations->getPackageInstallationDir(); if (!WrtUtilRemove(widgetPath)) { ThrowMsg(Exceptions::RemovingFolderFailure, - "Error occurs during removing existing folder"); + "Error occurs during removing existing folder"); } } LogDebug("Rename widget path sucessful!"); @@ -242,13 +245,15 @@ void TaskFileManipulation::StepPrepareExternalDir() GList *list = NULL; app2ext_dir_details* dirDetail = NULL; - std::string dirNames[2] = {GLIST_RES_DIR, GLIST_BIN_DIR}; + std::string dirNames[2] = { GLIST_RES_DIR, GLIST_BIN_DIR }; for (int i = 0; i < 2; i++) { dirDetail = (app2ext_dir_details*) calloc(1, - sizeof(app2ext_dir_details)); + sizeof( + app2ext_dir_details)); if (NULL == dirDetail) { - ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "error in app2ext"); + ThrowMsg(Exceptions::ErrorExternalInstallingFailure, + "error in app2ext"); } dirDetail->name = strdup(dirNames[i].c_str()); dirDetail->type = APP2EXT_DIR_RO; @@ -257,17 +262,18 @@ void TaskFileManipulation::StepPrepareExternalDir() if (false == m_context.existingWidgetInfo.isExist) { WidgetInstallToExtSingleton::Instance().preInstallation(list, - folderSize); + folderSize); } else { WidgetInstallToExtSingleton::Instance().preUpgrade(list, - folderSize); + folderSize); } free(dirDetail); g_list_free(list); } - Catch (WidgetInstallToExt::Exception::ErrorInstallToExt) + Catch(WidgetInstallToExt::Exception::ErrorInstallToExt) { - ReThrowMsg(Exceptions::ErrorExternalInstallingFailure, "Error during \ + ReThrowMsg(Exceptions::ErrorExternalInstallingFailure, + "Error during \ create external folder "); } } @@ -276,17 +282,18 @@ void TaskFileManipulation::StepInstallToExternal() { LogDebug("StepInstallExternal"); if (!WrtUtilMakeDir(m_context.locations->getSourceDir())) { - ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "To make src \ + ThrowMsg(Exceptions::ErrorExternalInstallingFailure, + "To make src \ directory failed"); } LogDebug("Resource move to external storage " << - m_context.locations->getSourceDir()); + m_context.locations->getSourceDir()); if (!_FolderCopy(m_context.locations->getTemporaryPackageDir(), - m_context.locations->getSourceDir())) + m_context.locations->getSourceDir())) { ThrowMsg(Exceptions::UnknownError, - "Error occurs during renaming widget folder"); + "Error occurs during renaming widget folder"); } } diff --git a/src/jobs/widget_install/task_install_ospsvc.cpp b/src/jobs/widget_install/task_install_ospsvc.cpp index 150f60f..3fe94ef 100644 --- a/src/jobs/widget_install/task_install_ospsvc.cpp +++ b/src/jobs/widget_install/task_install_ospsvc.cpp @@ -55,7 +55,8 @@ void TaskInstallOspsvc::StepInstallOspService() LogInfo("Step: installation for osp service"); std::ostringstream commStr; - commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.locations->getPackageInstallationDir()); + commStr << OSP_INSTALL_STR << BashUtils::escape_arg( + m_context.locations->getPackageInstallationDir()); //commStr << " 2>&1"; LogDebug("osp install command : " << commStr.str()); @@ -64,7 +65,8 @@ void TaskInstallOspsvc::StepInstallOspService() fd = popen(commStr.str().c_str(), "r"); if (NULL == fd) { LogError("Failed to installtion osp service"); - ThrowMsg(Exceptions::InstallOspsvcFailed, "Error occurs during\ + ThrowMsg(Exceptions::InstallOspsvcFailed, + "Error occurs during\ install osp service"); } fgets(readBuf, MAX_BUF_SIZE, fd); @@ -72,7 +74,8 @@ void TaskInstallOspsvc::StepInstallOspService() int result = atoi(readBuf); if (0 != result) { - ThrowMsg(Exceptions::InstallOspsvcFailed, "Error occurs during\ + ThrowMsg(Exceptions::InstallOspsvcFailed, + "Error occurs during\ install osp service"); } diff --git a/src/jobs/widget_install/task_install_ospsvc.h b/src/jobs/widget_install/task_install_ospsvc.h index 29d6d80..445bfb4 100644 --- a/src/jobs/widget_install/task_install_ospsvc.h +++ b/src/jobs/widget_install/task_install_ospsvc.h @@ -29,10 +29,9 @@ class InstallerContext; namespace Jobs { namespace WidgetInstall { - class TaskInstallOspsvc : public DPL::TaskDecl { -private: + private: // Installation context InstallerContext &m_context; @@ -42,14 +41,13 @@ private: // return callback static int StatusCallback( - int req_id, const char *pkg_type, const char *pkg_name, - const char *key, const char *val, const void *pmsg, - void *priv_data); + int req_id, const char *pkg_type, const char *pkg_name, + const char *key, const char *val, const void *pmsg, + void *priv_data); public: explicit TaskInstallOspsvc(InstallerContext &installerContext); }; - } // namespace WidgetInstall } // namespace Jobs #endif /* SRC_JOBS_WIDGET_INSTALL_TASK_INSTALL_OSPSVC_H_ */ diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp old mode 100755 new mode 100644 index 67a4f4e..92b372c --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -63,7 +63,7 @@ LanguageTagMap getLanguageTagMap() { LanguageTagMap map; -#define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag)); +#define ADD(tag, l_tag) map.insert(std::make_pair(L###tag, L###l_tag)); #include "languages.def" #undef ADD @@ -97,7 +97,6 @@ DPL::OptionalString getLangTag(const DPL::String& tag) namespace Jobs { namespace WidgetInstall { - const char * TaskManifestFile::encoding = "UTF-8"; TaskManifestFile::TaskManifestFile(InstallerContext &inCont) : @@ -113,7 +112,7 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) : AddAbortStep(&TaskManifestFile::stepAbortParseManifest); } else { - // for widget update. + // for widget update. AddStep(&TaskManifestFile::stepBackupIconFiles); AddStep(&TaskManifestFile::stepCopyIconFiles); AddStep(&TaskManifestFile::stepGenerateManifest); @@ -125,8 +124,7 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) : } TaskManifestFile::~TaskManifestFile() -{ -} +{} void TaskManifestFile::stepCreateExecFile() { @@ -149,27 +147,32 @@ void TaskManifestFile::stepCopyIconFiles() //which there is at least one icon in widget for, icon file is copied. //Coping prioritize last positions when coping. If there is several icons //with given locale, the one, that will be copied, will be icon - //which is declared by tag later than the others in config.xml of widget + //which is declared by tag later than the others in config.xml of + // widget std::vector generatedLocales; - WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons; + WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = + m_context.widgetConfig.localizationData.icons; - //reversed: last has highest priority to be copied if it has given locale (TODO: why was that working that way?) - for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++) + //reversed: last has highest priority to be copied if it has given + // locale (TODO: why was that working that way?) + for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator + icon = icons.rbegin(); + icon != icons.rend(); + icon++) { FOREACH(locale, icon->availableLocales) { DPL::String src = icon->src; LogDebug("Icon for locale: " << *locale << "is : " << src); - if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end()) + if (std::find(generatedLocales.begin(), generatedLocales.end(), + *locale) != generatedLocales.end()) { LogDebug("Skipping - has that locale"); continue; - } - else - { + } else { generatedLocales.push_back(*locale); } @@ -187,10 +190,11 @@ void TaskManifestFile::stepCopyIconFiles() targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/"; targetFile << getIconTargetFilename(*locale); - if (m_context.widgetConfig.packagingType == - WrtDB::PKG_TYPE_HOSTED_WEB_APP) { - m_context.locations->setIconTargetFilenameForLocale(targetFile.str()); + WrtDB::PKG_TYPE_HOSTED_WEB_APP) + { + m_context.locations->setIconTargetFilenameForLocale( + targetFile.str()); } LogDebug("Copying icon: " << sourceFile.str() << @@ -208,27 +212,30 @@ void TaskManifestFile::stepCopyIconFiles() Catch(DPL::FileInput::Exception::Base) { // Error while opening or closing source file - //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str()); + //ReThrowMsg(InstallerException::CopyIconFailed, + // sourceFile.str()); LogError( - "Copying widget's icon failed. Widget's icon will not be"\ + "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()); + //ReThrowMsg(InstallerException::CopyIconFailed, + // targetFile.str()); LogError( - "Copying widget's icon failed. Widget's icon will not be"\ + "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()); + //ReThrowMsg(InstallerException::CopyIconFailed, + // targetFile.str()); LogError( - "Copying widget's icon failed. Widget's icon will not be"\ + "Copying widget's icon failed. Widget's icon will not be" \ "available from Main Screen"); } } @@ -286,18 +293,18 @@ void TaskManifestFile::stepAbortIconFiles() Catch(DPL::FileInput::Exception::Base) { LogError("Restoration icon File Failed." << backup_file.str() - << " to " << res_file.str()); + << " to " << res_file.str()); } Catch(DPL::FileOutput::Exception::Base) { LogError("Restoration icon File Failed." << backup_file.str() - << " to " << res_file.str()); + << " to " << res_file.str()); } Catch(DPL::CopyFailed) { LogError("Restoration icon File Failed." << backup_file.str() - << " to " << res_file.str()); + << " to " << res_file.str()); } } } @@ -309,7 +316,7 @@ void TaskManifestFile::stepUpdateFinalize() } DPL::String TaskManifestFile::getIconTargetFilename( - const DPL::String& languageTag) const + const DPL::String& languageTag) const { DPL::OStringStream filename; TizenAppId appid = m_context.widgetConfig.tzAppid; @@ -317,12 +324,15 @@ DPL::String TaskManifestFile::getIconTargetFilename( filename << DPL::ToUTF8String(appid).c_str(); if (!languageTag.empty()) { - DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc - if (tag.IsNull()) { tag = languageTag; } + DPL::OptionalString tag = getLangTag(languageTag); // translate en -> + // en_US etc + if (tag.IsNull()) { + tag = languageTag; + } DPL::String locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag); - if(locale.empty()) { + if (locale.empty()) { filename << L"." << languageTag; } else { filename << L"." << locale; @@ -339,13 +349,12 @@ void TaskManifestFile::stepFinalize() LogInfo("Finished ManifestFile step"); } - void TaskManifestFile::saveLocalizedKey(std::ofstream &file, - const DPL::String& key, - const DPL::String& languageTag) + const DPL::String& key, + const DPL::String& languageTag) { DPL::String locale = - LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag); + LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag); file << key; if (!locale.empty()) { @@ -398,7 +407,8 @@ void TaskManifestFile::backupIconFiles() FOREACH(it, fileList) { if (0 == (strncmp((*it).c_str(), appid.c_str(), - strlen(appid.c_str())))) { + strlen(appid.c_str())))) + { std::ostringstream icon_file, backup_icon; icon_file << GlobalConfig::GetUserWidgetDesktopIconPath(); icon_file << "/" << (*it); @@ -406,7 +416,7 @@ void TaskManifestFile::backupIconFiles() backup_icon << b_icon_dir.str() << "/" << (*it); LogDebug("Backup icon file " << icon_file.str() << " to " << - backup_icon.str()); + backup_icon.str()); Try { DPL::FileInput input(icon_file.str()); @@ -435,7 +445,7 @@ void TaskManifestFile::backupIconFiles() } void TaskManifestFile::getFileList(const char* path, - std::list &list) + std::list &list) { DIR* dir = opendir(path); if (!dir) { @@ -446,17 +456,18 @@ void TaskManifestFile::getFileList(const char* path, struct dirent* d_ent; do { if ((d_ent = readdir(dir))) { - if(strcmp(d_ent->d_name, ".") == 0 || - strcmp(d_ent->d_name, "..") == 0) { + if (strcmp(d_ent->d_name, ".") == 0 || + strcmp(d_ent->d_name, "..") == 0) + { continue; } std::string file_name = d_ent->d_name; list.push_back(file_name); } - }while(d_ent); + } while (d_ent); if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { LogError("Failed to close dir: " << path << " with error: " - << DPL::GetErrnoString()); + << DPL::GetErrnoString()); } } @@ -481,13 +492,13 @@ void TaskManifestFile::stepParseManifest() int code = pkgmgr_parser_parse_manifest_for_installation( DPL::ToUTF8String(manifest_file).c_str(), NULL); - if(code != 0) - { + if (code != 0) { LogError("Manifest parser error: " << code); ThrowMsg(ManifestParsingError, "Parser returncode: " << code); } - // TODO : It will be removed. AIL update is temporary code request by pkgmgr team. + // TODO : It will be removed. AIL update is temporary code request by pkgmgr + // team. updateAilInfo(); m_context.job->UpdateProgress( @@ -501,13 +512,13 @@ void TaskManifestFile::stepParseUpgradedManifest() int code = pkgmgr_parser_parse_manifest_for_upgrade( DPL::ToUTF8String(manifest_file).c_str(), NULL); - if(code != 0) - { + if (code != 0) { LogError("Manifest parser error: " << code); ThrowMsg(ManifestParsingError, "Parser returncode: " << code); } - // TODO : It will be removed. AIL update is temporary code request by pkgmgr team. + // TODO : It will be removed. AIL update is temporary code request by pkgmgr + // team. updateAilInfo(); m_context.job->UpdateProgress( @@ -565,42 +576,44 @@ void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp) { bool defaultNameSaved = false; - DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale; - std::pair defaultLocalizedData; + DPL::OptionalString defaultLocale = + m_context.widgetConfig.configInfo.defaultlocale; + std::pair defaultLocalizedData; //labels FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet) { Locale i = localizedData->first; DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc - if (tag.IsNull()) - { + if (tag.IsNull()) { tag = i; } DPL::OptionalString name = localizedData->second.name; generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved); //store default locale localized data - if(!!defaultLocale && defaultLocale == i) - { + if (!!defaultLocale && defaultLocale == i) { defaultLocalizedData = *localizedData; } } - if (!!defaultLocale && !defaultNameSaved) - { + if (!!defaultLocale && !defaultNameSaved) { DPL::OptionalString name = defaultLocalizedData.second.name; - generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved); + generateWidgetName(manifest, + uiApp, + DPL::OptionalString::Null, + name, + defaultNameSaved); } //appid TizenAppId appid = m_context.widgetConfig.tzAppid; uiApp.setAppid(appid); - //extraid - if(!!m_context.widgetConfig.guid) { + if (!!m_context.widgetConfig.guid) { uiApp.setExtraid(*m_context.widgetConfig.guid); } else { - if(!appid.empty()) { + if (!appid.empty()) { uiApp.setExtraid(DPL::String(L"http://") + appid); } } @@ -610,25 +623,24 @@ void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp) manifest.setType(L"wgt"); } -void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved) +void TaskManifestFile::generateWidgetName(Manifest & manifest, + UiApplication &uiApp, + const DPL::OptionalString& tag, + DPL::OptionalString name, + bool & defaultNameSaved) { if (!!name) { - if (!!tag) - { + if (!!tag) { DPL::String locale = - LanguageTagsProvider::BCP47LanguageTagToLocale(*tag); + LanguageTagsProvider::BCP47LanguageTagToLocale(*tag); if (!locale.empty()) { - uiApp.addLabel(LabelType(*name,*tag)); - } - else - { + uiApp.addLabel(LabelType(*name, *tag)); + } else { uiApp.addLabel(LabelType(*name)); manifest.addLabel(LabelType(*name)); } - } - else - { + } else { defaultNameSaved = true; uiApp.addLabel(LabelType(*name)); manifest.addLabel(LabelType(*name)); @@ -642,62 +654,65 @@ void TaskManifestFile::setWidgetIcons(UiApplication & uiApp) //changes. bool defaultIconSaved = false; - DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale; + DPL::OptionalString defaultLocale = + m_context.widgetConfig.configInfo.defaultlocale; std::vector generatedLocales; - WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons; - - //reversed: last has highest priority to be writen to manifest if it has given locale (TODO: why was that working that way?) - for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++) + WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = + m_context.widgetConfig.localizationData.icons; + + //reversed: last has highest priority to be writen to manifest if it + // has given locale (TODO: why was that working that way?) + for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator + icon = icons.rbegin(); + icon != icons.rend(); + icon++) { FOREACH(locale, icon->availableLocales) { - if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end()) + if (std::find(generatedLocales.begin(), generatedLocales.end(), + *locale) != generatedLocales.end()) { LogDebug("Skipping - has that locale - already in manifest"); continue; - } - else - { + } else { generatedLocales.push_back(*locale); } - DPL::OptionalString tag = getLangTag(*locale); // translate en -> en_US etc - if (tag.IsNull()) { tag = *locale; } + DPL::OptionalString tag = getLangTag(*locale); // translate en -> + // en_US etc + if (tag.IsNull()) { + tag = *locale; + } generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved); } } - if (!!defaultLocale && !defaultIconSaved) - { + if (!!defaultLocale && !defaultIconSaved) { generateWidgetIcon(uiApp, DPL::OptionalString::Null, DPL::String(), defaultIconSaved); } } -void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, - const DPL::String& language, bool & defaultIconSaved) +void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, + const DPL::OptionalString& tag, + const DPL::String& language, + bool & defaultIconSaved) { DPL::String locale; - if (!!tag) - { + if (!!tag) { locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag); - } - else - { + } else { defaultIconSaved = true; } DPL::String iconText; iconText += getIconTargetFilename(language); - if(!locale.empty()) - { + if (!locale.empty()) { uiApp.addIcon(IconType(iconText, locale)); - } - else - { + } else { uiApp.addIcon(IconType(iconText)); } } @@ -706,44 +721,44 @@ void TaskManifestFile::setWidgetManifest(Manifest & manifest) { manifest.setPackage(m_context.widgetConfig.tzPkgid); - if(!!m_context.widgetConfig.version) - { + if (!!m_context.widgetConfig.version) { manifest.setVersion(*m_context.widgetConfig.version); } DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ? - *m_context.widgetConfig.configInfo.authorEmail : L""); + *m_context.widgetConfig.configInfo.authorEmail : L""); DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ? - *m_context.widgetConfig.configInfo.authorHref : L""); + *m_context.widgetConfig.configInfo.authorHref : L""); DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ? - *m_context.widgetConfig.configInfo.authorName : L""); - manifest.addAuthor(Author(email,href,L"",name)); + *m_context.widgetConfig.configInfo.authorName : L""); + manifest.addAuthor(Author(email, href, L"", name)); } void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp) { FOREACH(it, m_context.widgetConfig.configInfo.settingsList) { - if(!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) { - if(!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) { + if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) { + if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) { uiApp.setNodisplay(true); uiApp.setTaskmanage(false); - } - else { + } else { uiApp.setNodisplay(false); uiApp.setTaskmanage(true); } - } - } + } + } //TODO //There is no "X-TIZEN-PackageType=wgt" - //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str() + //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << + // DPL::ToUTF8String(*widgetID).c_str() //There is no Comment in pkgmgr "Comment=Widget application" //that were in desktop file } void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp) { - WrtDB::ConfigParserData::ServiceInfoList appServiceList = m_context.widgetConfig.configInfo.appServiceList; + WrtDB::ConfigParserData::ServiceInfoList appServiceList = + m_context.widgetConfig.configInfo.appServiceList; if (appServiceList.empty()) { LogInfo("Widget doesn't contain application service"); @@ -819,14 +834,12 @@ void TaskManifestFile::stepAbortParseManifest() int code = pkgmgr_parser_parse_manifest_for_uninstallation( DPL::ToUTF8String(manifest_file).c_str(), NULL); - if (0 != code) - { + if (0 != code) { LogWarning("Manifest parser error: " << code); ThrowMsg(ManifestParsingError, "Parser returncode: " << code); } int ret = unlink(DPL::ToUTF8String(manifest_file).c_str()); - if (0 != ret) - { + if (0 != ret) { LogWarning("No manifest file found: " << manifest_file); } } @@ -840,12 +853,12 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest) DPL::String appid = m_context.widgetConfig.tzAppid; size_t found; - if(ConfigInfo->m_liveboxId != L"") { + if (ConfigInfo->m_liveboxId != L"") { found = ConfigInfo->m_liveboxId.find_last_of(L"."); - if(found != std::string::npos) { - if(0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) + if (found != std::string::npos) { + if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) { liveBox.setLiveboxId(ConfigInfo->m_liveboxId); - else { + } else { DPL::String liveboxId = appid + DPL::String(L".") + ConfigInfo->m_liveboxId; liveBox.setLiveboxId(liveboxId); @@ -857,37 +870,47 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest) } } - if(ConfigInfo->m_primary != L"") + if (ConfigInfo->m_primary != L"") { liveBox.setPrimary(ConfigInfo->m_primary); + } - if(ConfigInfo->m_autoLaunch == L"true") + if (ConfigInfo->m_autoLaunch == L"true") { liveBox.setAutoLaunch(appid); + } - if(ConfigInfo->m_updatePeriod != L"") + if (ConfigInfo->m_updatePeriod != L"") { liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod); + } - if(ConfigInfo->m_label != L"") + if (ConfigInfo->m_label != L"") { liveBox.setLabel(ConfigInfo->m_label); + } DPL::String defaultLocale - = DPL::FromUTF8String(m_context.locations->getPackageInstallationDir()) - + DPL::String(L"/res/wgt/"); + = DPL::FromUTF8String( + m_context.locations->getPackageInstallationDir()) + + DPL::String(L"/res/wgt/"); - if(ConfigInfo->m_icon!=L"") { - liveBox.setIcon(defaultLocale+ConfigInfo->m_icon); + if (ConfigInfo->m_icon != L"") { + liveBox.setIcon(defaultLocale + ConfigInfo->m_icon); } - if (ConfigInfo->m_boxInfo.m_boxSrc.empty() || ConfigInfo->m_boxInfo.m_boxSize.empty()) { + if (ConfigInfo->m_boxInfo.m_boxSrc.empty() || + ConfigInfo->m_boxInfo.m_boxSize.empty()) + { LogInfo("Widget doesn't contain box"); return; } else { BoxInfoType box; if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) { - if((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http")) - || (0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https"))) + if ((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http")) + || (0 == + ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https"))) + { box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc; - else + } else { box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc; + } } if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") { @@ -896,18 +919,20 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest) box.boxMouseEvent = L"false"; } - std::list> BoxSizeList + std::list > BoxSizeList = ConfigInfo->m_boxInfo.m_boxSize; FOREACH(im, BoxSizeList) { std::pair boxSize = *im; - if(!boxSize.second.empty()) + if (!boxSize.second.empty()) { boxSize.second = defaultLocale + boxSize.second; + } box.boxSize.push_back(boxSize); } if (!ConfigInfo->m_boxInfo.m_pdSrc.empty() - && !ConfigInfo->m_boxInfo.m_pdWidth.empty() - && !ConfigInfo->m_boxInfo.m_pdHeight.empty()) { + && !ConfigInfo->m_boxInfo.m_pdWidth.empty() + && !ConfigInfo->m_boxInfo.m_pdHeight.empty()) + { box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc; box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth; box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight; @@ -916,8 +941,6 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest) } manifest.addLivebox(liveBox); } - } - } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_manifest_file.h b/src/jobs/widget_install/task_manifest_file.h old mode 100755 new mode 100644 index ec9e12b..de18c42 --- a/src/jobs/widget_install/task_manifest_file.h +++ b/src/jobs/widget_install/task_manifest_file.h @@ -38,7 +38,6 @@ #include - class InstallerContext; namespace Jobs { @@ -77,7 +76,8 @@ class TaskManifestFile : void stepAbortIconFiles(); //private data - std::list icon_list; //TODO: this should be registered as external files + std::list icon_list; //TODO: this should be registered as + // external files std::ostringstream backup_dir; xmlTextWriterPtr writer; DPL::String manifest_name; @@ -100,8 +100,15 @@ class TaskManifestFile : void setAppCategory(UiApplication & uiApp); void setLiveBoxInfo(Manifest& manifest); - void generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved); - void generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, const DPL::String& language, bool & defaultIconSaved); + void generateWidgetName(Manifest & manifest, + UiApplication &uiApp, + const DPL::OptionalString& tag, + DPL::OptionalString name, + bool & defaultNameSaved); + void generateWidgetIcon(UiApplication & uiApp, + const DPL::OptionalString& tag, + const DPL::String& language, + bool & defaultIconSaved); //for widget update void backupIconFiles(); @@ -109,11 +116,10 @@ class TaskManifestFile : DPL::String getIconTargetFilename(const DPL::String& languageTag) const; static void saveLocalizedKey(std::ofstream &file, - const DPL::String& key, - const DPL::String& languageTag); + const DPL::String& key, + const DPL::String& languageTag); static const char * encoding; - }; } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_plugins_copy.cpp b/src/jobs/widget_install/task_plugins_copy.cpp index 528f12e..0e72ced 100644 --- a/src/jobs/widget_install/task_plugins_copy.cpp +++ b/src/jobs/widget_install/task_plugins_copy.cpp @@ -45,14 +45,13 @@ const std::string plugins_dir = "i586"; #endif namespace { - const std::string PackagePluginsDir = "/plugins/"; - const std::string InstallationPluginsDir = "/data/.netscape/plugins/"; - const mode_t InstallationPluginsDirMode = 0755; +const std::string PackagePluginsDir = "/plugins/"; +const std::string InstallationPluginsDir = "/data/.netscape/plugins/"; +const mode_t InstallationPluginsDirMode = 0755; } namespace Jobs { namespace WidgetInstall { - TaskPluginsCopy::TaskPluginsCopy(InstallerContext& context) : DPL::TaskDecl(this), m_context(context) @@ -63,9 +62,9 @@ TaskPluginsCopy::TaskPluginsCopy(InstallerContext& context) : AddStep(&TaskPluginsCopy::StepCopyingFinished); LogDebug("Widget plugins copy task ended"); m_npsource = m_context.locations->getSourceDir() + PackagePluginsDir - + plugins_dir; + + plugins_dir; m_npdestination = m_context.locations->getPackageInstallationDir() - + InstallationPluginsDir; + + InstallationPluginsDir; } void TaskPluginsCopy::StepFindPlugins() @@ -73,9 +72,11 @@ void TaskPluginsCopy::StepFindPlugins() LogDebug("Starting plugins finding step"); /* Check whether plugins directory for actual architecture exists * (plugins for other architectures are omitted even they exists). */ - if(!WrtUtilDirExists(m_npsource)) { - LogDebug("Plugins directory (" <d_name; - if(lstat(tempname.c_str(), &st) != 0) { - LogWarning("Failed to call \"lstat\" (errno:" <d_name, "..", 2)!=0 - && strncmp(entry->d_name, ".", 1)!=0) { + if (S_ISDIR(st.st_mode)) { + if (strncmp(entry->d_name, "..", 2) != 0 + && strncmp(entry->d_name, ".", 1) != 0) + { LogError("Directory detected instead of plugin file: " - << entry->d_name); + << entry->d_name); /* Subdirectories inside plugins/ARCH are not supported */ if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { - LogError("Failed to close dir: " << m_npsource - << " with error: " << DPL::GetErrnoString()); + LogError( + "Failed to close dir: " << m_npsource + << " with error: " << + DPL::GetErrnoString()); } - ThrowMsg(Exceptions::PluginsSubdirectory, - "Subdirectories inside plugins directory are not supported"); - } - else { + ThrowMsg( + Exceptions::PluginsSubdirectory, + "Subdirectories inside plugins directory are not supported"); + } else { continue; } } tempname = std::string(entry->d_name); /* Check whether file extension is ".so" */ - if(tempname.compare(tempname.size()-ext.size(), ext.size(), ext) == 0) { + if (tempname.compare(tempname.size() - ext.size(), ext.size(), + ext) == 0) + { /* Plugin file found */ - LogDebug("Plugin file found: " <::const_iterator it = m_nplugins.begin(); - it != m_nplugins.end(); it++) { + for (std::list::const_iterator it = m_nplugins.begin(); + it != m_nplugins.end(); it++) + { LogDebug("Copying plugin file: " << (*it)); source = m_npsource + "/" + (*it); destination = m_npdestination + (*it); - if(rename(source.c_str(), destination.c_str()) != 0) { - LogError("Failed to move " < { -public: + public: TaskPluginsCopy(InstallerContext &context); -private: + + private: /* Widget installer context */ InstallerContext &m_context; /* Path to plugins directory in unpacked widget*/ diff --git a/src/jobs/widget_install/task_prepare_files.cpp b/src/jobs/widget_install/task_prepare_files.cpp index 9395094..1838887 100644 --- a/src/jobs/widget_install/task_prepare_files.cpp +++ b/src/jobs/widget_install/task_prepare_files.cpp @@ -35,7 +35,6 @@ namespace Jobs { namespace WidgetInstall { - TaskPrepareFiles::TaskPrepareFiles(InstallerContext &installerContext) : DPL::TaskDecl(this), m_installerContext(installerContext) @@ -46,17 +45,19 @@ TaskPrepareFiles::TaskPrepareFiles(InstallerContext &installerContext) : void TaskPrepareFiles::CopyFile(const std::string& source) { - if(source.empty()) { + if (source.empty()) { LogWarning("No source file specified"); return; } std::string filename = source; - size_t last = source.find_last_of( "\\/" ); - if(last != std::string::npos) { - filename = source.substr( last+1 ); + size_t last = source.find_last_of("\\/"); + if (last != std::string::npos) { + filename = source.substr(last + 1); } - std::string target = m_installerContext.locations->getTemporaryPackageDir() + '/' + filename; + std::string target = + m_installerContext.locations->getTemporaryPackageDir() + '/' + + filename; LogDebug("source " << source); LogDebug("target " << target); @@ -90,10 +91,14 @@ void TaskPrepareFiles::StepCopyFiles() { CopyFile(m_installerContext.locations->getWidgetSource()); - size_t last = m_installerContext.locations->getWidgetSource().find_last_of("\\/"); + size_t last = m_installerContext.locations->getWidgetSource().find_last_of( + "\\/"); std::string sourceDir = ""; if (last != std::string::npos) { - sourceDir = m_installerContext.locations->getWidgetSource().substr(0,last+1); + sourceDir = m_installerContext.locations->getWidgetSource().substr( + 0, + last + + 1); } LogDebug("Icons copy..."); @@ -104,6 +109,5 @@ void TaskPrepareFiles::StepCopyFiles() CopyFile(os.str()); } } - } // namespace WidgetInstall } // namespace Jobs diff --git a/src/jobs/widget_install/task_prepare_files.h b/src/jobs/widget_install/task_prepare_files.h index 7db10cf..dd217a5 100644 --- a/src/jobs/widget_install/task_prepare_files.h +++ b/src/jobs/widget_install/task_prepare_files.h @@ -29,10 +29,9 @@ class InstallerContext; namespace Jobs { namespace WidgetInstall { - class TaskPrepareFiles : public DPL::TaskDecl { -private: + private: // Installation context InstallerContext &m_installerContext; @@ -44,7 +43,6 @@ private: public: explicit TaskPrepareFiles(InstallerContext &installerContext); }; - } // namespace WidgetInstall } // namespace Jobs #endif /* SRC_JOBS_WIDGET_INSTALL_TASK_PREPARE_FILES_H_ */ diff --git a/src/jobs/widget_install/task_recovery.cpp b/src/jobs/widget_install/task_recovery.cpp index 7daba5e..bdf2e71 100644 --- a/src/jobs/widget_install/task_recovery.cpp +++ b/src/jobs/widget_install/task_recovery.cpp @@ -58,7 +58,7 @@ void TaskRecovery::StepCreateCheckFile() std::ostringstream infoPath; infoPath << GlobalConfig::GetTempInstallInfoPath(); infoPath << "/"; - infoPath << m_context.locations->getWidgetSource().substr(pos+1); + infoPath << m_context.locations->getWidgetSource().substr(pos + 1); FILE *temp = fopen(infoPath.str().c_str(), "w+"); if (temp != NULL) { diff --git a/src/jobs/widget_install/task_recovery.h b/src/jobs/widget_install/task_recovery.h index 5a5fd54..120c1aa 100644 --- a/src/jobs/widget_install/task_recovery.h +++ b/src/jobs/widget_install/task_recovery.h @@ -29,10 +29,9 @@ class InstallerContext; namespace Jobs { namespace WidgetInstall { - class TaskRecovery : public DPL::TaskDecl { -private: + private: // Installation context InstallerContext &m_context; @@ -41,7 +40,6 @@ private: public: explicit TaskRecovery(InstallerContext &installerContext); }; - } // namespace WidgetInstall } // namespace Jobs #endif /* SRC_JOBS_WIDGET_INSTALL_TASK_RECOVERY_FILES_H_ */ diff --git a/src/jobs/widget_install/task_remove_backup.cpp b/src/jobs/widget_install/task_remove_backup.cpp index bcf7317..8841739 100644 --- a/src/jobs/widget_install/task_remove_backup.cpp +++ b/src/jobs/widget_install/task_remove_backup.cpp @@ -70,6 +70,5 @@ void TaskRemoveBackupFiles::StepRemoveBackupFiles() InstallerContext::INSTALL_REMOVE_BACKUP_FILE, "Backup widget file delete Finished"); } - } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_remove_backup.h b/src/jobs/widget_install/task_remove_backup.h index b12cec7..d269435 100644 --- a/src/jobs/widget_install/task_remove_backup.h +++ b/src/jobs/widget_install/task_remove_backup.h @@ -28,7 +28,7 @@ class InstallerContext; namespace Jobs { namespace WidgetInstall { -class TaskRemoveBackupFiles: +class TaskRemoveBackupFiles : public DPL::TaskDecl { private: diff --git a/src/jobs/widget_install/task_smack.cpp b/src/jobs/widget_install/task_smack.cpp index 1afe3ee..5bbb173 100644 --- a/src/jobs/widget_install/task_smack.cpp +++ b/src/jobs/widget_install/task_smack.cpp @@ -48,22 +48,22 @@ void TaskSmack::Step() FOREACH(it, m_context.staticPermittedDevCaps) { if (it->second) { std::string utf8 = DPL::ToUTF8String(it->first); - if (it != m_context.staticPermittedDevCaps.begin()) + if (it != m_context.staticPermittedDevCaps.begin()) { devcaps << ","; + } devcaps << utf8; } } TizenAppId tzAppid = m_context.widgetConfig.tzAppid; int result = handle_access_control_conf_forWAC( - DPL::ToUTF8String(tzAppid).c_str(), - devcaps.str().c_str(), - OPERATION_INSTALL); - Assert(result==PC_OPERATION_SUCCESS && "access control setup failed"); + DPL::ToUTF8String(tzAppid).c_str(), + devcaps.str().c_str(), + OPERATION_INSTALL); + Assert(result == PC_OPERATION_SUCCESS && "access control setup failed"); m_context.job->UpdateProgress( UninstallerContext::INSTALL_SMACK_ENABLE, "Widget SMACK Enabled"); #endif } - } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_smack.h b/src/jobs/widget_install/task_smack.h index 8d87e04..ce05d29 100644 --- a/src/jobs/widget_install/task_smack.h +++ b/src/jobs/widget_install/task_smack.h @@ -29,7 +29,7 @@ class InstallerContext; namespace Jobs { namespace WidgetInstall { -class TaskSmack: +class TaskSmack : public DPL::TaskDecl, public DPL::Event::ICDelegateSupport { diff --git a/src/jobs/widget_install/task_unzip.cpp b/src/jobs/widget_install/task_unzip.cpp index fb084f6..0ce18cf 100644 --- a/src/jobs/widget_install/task_unzip.cpp +++ b/src/jobs/widget_install/task_unzip.cpp @@ -40,11 +40,10 @@ struct PathAndFilePair std::string file; PathAndFilePair(const std::string &p, - const std::string &f) : + const std::string &f) : path(p), file(f) - { - } + {} }; PathAndFilePair SplitFileAndPath(const std::string &filePath) @@ -76,7 +75,7 @@ TaskUnzip::TaskUnzip(InstallerContext &installerContext) : } void TaskUnzip::ExtractFile(DPL::ZipInput::File *input, - const std::string &destFileName) + const std::string &destFileName) { Try { @@ -101,12 +100,14 @@ void TaskUnzip::StepUnzipPrepare() Try { - m_zip.reset(new DPL::ZipInput(m_installerContext.locations->getWidgetSource())); + m_zip.reset(new DPL::ZipInput(m_installerContext.locations-> + getWidgetSource())); LogInfo("Widget package comment: " << m_zip->GetGlobalComment()); // Widget package must not be empty if (m_zip->empty()) { - ThrowMsg(Exceptions::ZipEmpty, m_installerContext.locations->getWidgetSource()); + ThrowMsg(Exceptions::ZipEmpty, + m_installerContext.locations->getWidgetSource()); } // Set iterator to first file @@ -114,11 +115,13 @@ void TaskUnzip::StepUnzipPrepare() } Catch(DPL::ZipInput::Exception::OpenFailed) { - ReThrowMsg(Exceptions::OpenZipFailed, m_installerContext.locations->getWidgetSource()); + ReThrowMsg(Exceptions::OpenZipFailed, + m_installerContext.locations->getWidgetSource()); } Catch(DPL::ZipInput::Exception::SeekFileFailed) { - ThrowMsg(Exceptions::ExtractFileFailed,"m_installerContext.locations->getWidgetSource()"); + ThrowMsg(Exceptions::ExtractFileFailed, + "m_installerContext.locations->getWidgetSource()"); } } @@ -138,7 +141,8 @@ void TaskUnzip::StepUnzipProgress() if (fileName[fileName.size() - 1] == '/') { // This is path - std::string newPath = m_installerContext.locations->getTemporaryPackageDir() + "/" + + std::string newPath = + m_installerContext.locations->getTemporaryPackageDir() + "/" + fileName.substr(0, fileName.size() - 1); LogPedantic("Path to extract: " << newPath); @@ -147,7 +151,8 @@ void TaskUnzip::StepUnzipProgress() } else { // This is regular file std::string fileExtractPath = - m_installerContext.locations->getTemporaryPackageDir() + "/" + fileName; + m_installerContext.locations->getTemporaryPackageDir() + "/" + + fileName; LogPedantic("File to extract: " << fileExtractPath); @@ -196,6 +201,5 @@ void TaskUnzip::StepUnzipFinished() // Done LogInfo("Unzip finished"); } - } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_unzip.h b/src/jobs/widget_install/task_unzip.h index 3962297..69ce606 100644 --- a/src/jobs/widget_install/task_unzip.h +++ b/src/jobs/widget_install/task_unzip.h @@ -47,7 +47,7 @@ class TaskUnzip : WRTEncryptor::ResourceEncryptor *m_resEnc; void ExtractFile(DPL::ZipInput::File *input, - const std::string &destFileName); + const std::string &destFileName); void EncryptionFile(const std::string &fileName); diff --git a/src/jobs/widget_install/task_update_files.cpp b/src/jobs/widget_install/task_update_files.cpp index 30589a9..c9afcca 100644 --- a/src/jobs/widget_install/task_update_files.cpp +++ b/src/jobs/widget_install/task_update_files.cpp @@ -44,7 +44,6 @@ using namespace WrtDB; namespace { - inline const char* GetWidgetBackupDirPath() { return "backup"; @@ -53,7 +52,6 @@ inline const char* GetWidgetBackupDirPath() namespace Jobs { namespace WidgetInstall { - TaskUpdateFiles::TaskUpdateFiles(InstallerContext& context) : DPL::TaskDecl(this), m_context(context) @@ -74,15 +72,19 @@ void TaskUpdateFiles::StepCreateBackupFolder() std::string srcBuPath = m_context.locations->getBackupSourceDir(); LogDebug("backup resource directory path : " << srcBuPath); - if(!WrtUtilMakeDir(srcBuPath)) { - ThrowMsg(Exceptions::BackupFailed, "Error occurs during create \ + if (!WrtUtilMakeDir(srcBuPath)) { + ThrowMsg( + Exceptions::BackupFailed, + "Error occurs during create \ backup directory."); } std::string binBuPath = m_context.locations->getBackupBinaryDir(); LogDebug("backup execution directory path : " << binBuPath); - if(!WrtUtilMakeDir(binBuPath)) { - ThrowMsg(Exceptions::BackupFailed, "Error occurs during create backup \ + if (!WrtUtilMakeDir(binBuPath)) { + ThrowMsg( + Exceptions::BackupFailed, + "Error occurs during create backup \ directory."); } @@ -92,12 +94,13 @@ void TaskUpdateFiles::StepCreateBackupFolder() } void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list, - size_t subLen) + size_t subLen) { DIR* pkgDir = opendir(dirPath.c_str()); if (!pkgDir) { LogError("Package directory " << dirPath << " doesn't exist"); - ThrowMsg(Exceptions::InternalError, "Error occurs during read \ + ThrowMsg(Exceptions::InternalError, + "Error occurs during read \ directory"); } @@ -112,8 +115,9 @@ void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list, } if (S_ISDIR(statInfo.st_mode)) { - if(strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, - "..") == 0) { + if (strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, + "..") == 0) + { continue; } ReadDirList(absFileName, list, subLen); @@ -121,12 +125,11 @@ void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list, list.insert(absFileName.substr(subLen)); } - } - while(dirent); + } while (dirent); //closing the directory if (-1 == TEMP_FAILURE_RETRY(closedir(pkgDir))) { LogError("Failed to close dir: " << dirPath << " with error: " - << DPL::GetErrnoString()); + << DPL::GetErrnoString()); } } @@ -138,21 +141,21 @@ void TaskUpdateFiles::StepResourceFilesBackup() ExistFileList tempList; std::string pkgSrc = m_context.locations->getSourceDir(); - ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str())+1); - + ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str()) + 1); std::string tempSrc = m_context.locations->getTemporaryPackageDir(); - ReadDirList(tempSrc, tempList, strlen(tempSrc.c_str())+1); + ReadDirList(tempSrc, tempList, strlen(tempSrc.c_str()) + 1); FOREACH(it, tempList) { std::set::iterator res; res = resList.find(*it); std::string resFile = pkgSrc + "/" + (*it); - std::string newFile = tempSrc + "/" +(*it); + std::string newFile = tempSrc + "/" + (*it); if (res != resList.end()) { - std::string backupFile = m_context.locations->getBackupSourceDir() + - "/"+ (*it); + std::string backupFile = + m_context.locations->getBackupSourceDir() + + "/" + (*it); struct stat sInfo; if (stat(resFile.c_str(), &sInfo) != 0) { @@ -161,20 +164,27 @@ void TaskUpdateFiles::StepResourceFilesBackup() if (S_ISDIR(sInfo.st_mode)) { LogDebug(resFile << " is a directory. so create a folder : " << - backupFile); + backupFile); WrtUtilMakeDir(backupFile); } else { if ((rename(resFile.c_str(), backupFile.c_str())) != 0) { - LogError("Failed to rename " << resFile << " to " << backupFile); - ThrowMsg(Exceptions::BackupFailed, "Error occurs during \ + LogError( + "Failed to rename " << resFile << " to " << + backupFile); + ThrowMsg( + Exceptions::BackupFailed, + "Error occurs during \ rename file"); } LogDebug("backup : " << resFile << " to " << backupFile); if ((rename(newFile.c_str(), resFile.c_str())) != 0) { - LogError("Failed to rename " << newFile << " to " << resFile); - ThrowMsg(Exceptions::BackupFailed, "Error occurs during \ + LogError( + "Failed to rename " << newFile << " to " << resFile); + ThrowMsg( + Exceptions::BackupFailed, + "Error occurs during \ rename file"); } LogDebug("copy : " << newFile << " to " << resFile); @@ -183,7 +193,9 @@ void TaskUpdateFiles::StepResourceFilesBackup() } else { if ((rename(newFile.c_str(), resFile.c_str())) != 0) { LogError("Failed to rename " << newFile << " to " << resFile); - ThrowMsg(Exceptions::BackupFailed, "Error occurs during \ + ThrowMsg( + Exceptions::BackupFailed, + "Error occurs during \ rename file"); } LogDebug("only copy : " << newFile << " to " << resFile); @@ -196,7 +208,9 @@ void TaskUpdateFiles::StepResourceFilesBackup() std::string backFile = tempSrc + "/" + (*remain); if ((rename(pkgFile.c_str(), backFile.c_str())) != 0) { LogError("Failed to backup : " << pkgFile << " to " << backFile); - ThrowMsg(Exceptions::BackupFailed, "Error occurs during \ + ThrowMsg( + Exceptions::BackupFailed, + "Error occurs during \ rename file"); } LogDebug("only backup : " << pkgFile << " to " << backFile); @@ -214,13 +228,14 @@ void TaskUpdateFiles::StepExecFileBackup() LogDebug(" source : " << execFile); - std::string tempSource= m_context.locations->getBackupExecFile(); + std::string tempSource = m_context.locations->getBackupExecFile(); LogDebug(" source : " << tempSource); if ((rename(execFile.c_str(), tempSource.c_str())) != 0) { LogError("Failed to rename " << execFile << " to " << - tempSource); - ThrowMsg(Exceptions::BackupFailed, "Error occurs during \ + tempSource); + ThrowMsg(Exceptions::BackupFailed, + "Error occurs during \ rename file"); } LogDebug("Backup : " << execFile << " to " << tempSource); @@ -243,7 +258,7 @@ void TaskUpdateFiles::StepAbortResourceFilesBackup() LogDebug("Backup Folder " << srcBuPath << " to " << srcPath); - if(!WrtUtilRemove(srcPath)) { + if (!WrtUtilRemove(srcPath)) { LogError("Failed to remove " << srcPath); } @@ -257,7 +272,7 @@ void TaskUpdateFiles::StepAbortExecFileBackup() LogDebug("StepAbortExecFileBackup"); std::string binPath = m_context.locations->getBinaryDir(); - if(!WrtUtilRemove(binPath)) { + if (!WrtUtilRemove(binPath)) { LogError("Failed to remove " << binPath); } @@ -275,10 +290,9 @@ void TaskUpdateFiles::StepAbortCreateBackupFolder() path << m_context.locations->getBackupDir(); LogDebug("Remove backup directory : " << path.str()); - if(!WrtUtilRemove(path.str())) { + if (!WrtUtilRemove(path.str())) { LogError("Failed to remove " << path); } } - } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_widget_config.cpp b/src/jobs/widget_install/task_widget_config.cpp index f47357c..13fa549 100644 --- a/src/jobs/widget_install/task_widget_config.cpp +++ b/src/jobs/widget_install/task_widget_config.cpp @@ -46,11 +46,10 @@ #include #include - namespace { // anonymous const DPL::String BR = DPL::FromUTF8String("
"); const std::string WIDGET_NOT_COMPATIBLE = "This widget is " - "not compatible with WRT.

"; + "not compatible with WRT.

"; const std::string QUESTION = "Do you want to install it anyway?"; const char *const DEFAULT_LANGUAGE = "default"; @@ -60,11 +59,10 @@ const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml"; const std::string WINDGET_INSTALL_NETWORK_ACCESS = "network access"; } - namespace Jobs { namespace WidgetInstall { void InstallerTaskWidgetPopupData::PopupData::addWidgetInfo( - const DPL::String &info) + const DPL::String &info) { widgetInfo = info; } @@ -73,7 +71,6 @@ TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) : DPL::TaskDecl(this), WidgetInstallPopup(installContext), m_installContext(installContext) - { AddStep(&TaskWidgetConfig::StepProcessConfigurationFile); AddStep(&TaskWidgetConfig::ReadLocaleFolders); @@ -85,7 +82,9 @@ TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) : AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo); if (!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) { - AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures); + AddStep( + &TaskWidgetConfig:: + StepCancelWidgetInstallationAfterVerifyFeatures); AddStep(&TaskWidgetConfig::StepShowWidgetInfo); AddStep(&TaskWidgetConfig::StepCancelWidgetInstallation); AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion); @@ -119,7 +118,8 @@ void TaskWidgetConfig::ReadLocaleFolders() //Adding default locale m_localeFolders.insert(L""); - std::string localePath = m_installContext.locations->getConfigurationDir() + "/locales"; + std::string localePath = + m_installContext.locations->getConfigurationDir() + "/locales"; DIR* localeDir = opendir(localePath.c_str()); if (!localeDir) { LogDebug("No /locales directory in the widget package."); @@ -148,8 +148,7 @@ void TaskWidgetConfig::ReadLocaleFolders() } } } - } - while (dirent); + } while (dirent); if (errno != 0) { LogError("readdir() failed with " << DPL::GetErrnoString()); @@ -157,7 +156,7 @@ void TaskWidgetConfig::ReadLocaleFolders() if (-1 == TEMP_FAILURE_RETRY(closedir(localeDir))) { LogError("Failed to close dir: " << localePath << " with error: " - << DPL::GetErrnoString()); + << DPL::GetErrnoString()); } } @@ -175,7 +174,8 @@ void TaskWidgetConfig::ProcessLocalizedStartFiles() ProcessStartFile(S(L"index.svg"), S(L"image/svg+xml")); ProcessStartFile(S(L"index.xhtml"), S(L"application/xhtml+xml")); ProcessStartFile(S(L"index.xht"), S(L"application/xhtml+xml")); - // TODO: (l.wrzosek) we need better check if in current locales widget is valid. + // TODO: (l.wrzosek) we need better check if in current locales widget is + // valid. FOREACH(it, m_installContext.widgetConfig.localizationData.startFiles) { if (it->propertiesForLocales.size() > 0) { return; @@ -186,9 +186,9 @@ void TaskWidgetConfig::ProcessLocalizedStartFiles() } void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path, - const DPL::OptionalString& type, - const DPL::OptionalString& encoding, - bool typeForcedInConfig) + const DPL::OptionalString& type, + const DPL::OptionalString& encoding, + bool typeForcedInConfig) { using namespace WrtDB; @@ -204,7 +204,8 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path, DPL::String relativePath = pathPrefix + *path; DPL::String absolutePath = DPL::FromUTF8String( - m_installContext.locations->getConfigurationDir()) + L"/" + relativePath; + m_installContext.locations->getConfigurationDir()) + L"/" + + relativePath; // get property data from packaged app if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) { @@ -225,7 +226,7 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path, } else { MimeTypeUtils::MimeAttributes attributes = MimeTypeUtils::getMimeAttributes( - startFileProperties.type); + startFileProperties.type); if (attributes.count(L"charset") > 0) { startFileProperties.encoding = attributes[L"charset"]; @@ -250,11 +251,14 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path, // set property data for hosted start url // Hosted start url only support TIZEN WebApp if (m_installContext.widgetConfig.webAppType == - APP_TYPE_TIZENWEBAPP) + APP_TYPE_TIZENWEBAPP) { - std::string startPath = DPL::ToUTF8String(startFileData.path); + std::string startPath = DPL::ToUTF8String( + startFileData.path); - if (strstr(startPath.c_str(), "http") == startPath.c_str()) { + if (strstr(startPath.c_str(), + "http") == startPath.c_str()) + { WidgetRegisterInfo::StartFileProperties startFileProperties; if (!!type) { @@ -280,12 +284,12 @@ void TaskWidgetConfig::ProcessBackgroundPageFile() if (!!m_installContext.widgetConfig.configInfo.backgroundPage) { // check whether file exists DPL::String backgroundPagePath = DPL::FromUTF8String( - m_installContext.locations->getConfigurationDir()) + L"/" + + m_installContext.locations->getConfigurationDir()) + L"/" + *m_installContext.widgetConfig.configInfo.backgroundPage; //if no then cancel installation if (!WrtUtilFileExists(DPL::ToUTF8String(backgroundPagePath))) { ThrowMsg(Exceptions::WidgetConfigFileInvalid, - L"Given background page file not found in archive"); + L"Given background page file not found in archive"); } } } @@ -310,7 +314,8 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon) LogInfo("enter"); bool isAnyIconValid = false; //In case a default filename is passed as custom filename in config.xml, we - //need to keep a set of already processed filenames to avoid icon duplication + //need to keep a set of already processed filenames to avoid icon + // duplication //in database. using namespace WrtDB; @@ -331,7 +336,8 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon) DPL::String relativePath = pathPrefix + icon.src; DPL::String absolutePath = DPL::FromUTF8String( - m_installContext.locations->getConfigurationDir()) + L"/" + relativePath; + m_installContext.locations->getConfigurationDir()) + L"/" + + relativePath; if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) { DPL::String type = MimeTypeUtils::identifyFileMimeType(absolutePath); @@ -345,8 +351,7 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon) } } - if(isAnyIconValid) - { + if (isAnyIconValid) { WidgetRegisterInfo::LocalizedIcon localizedIcon(icon, localesAvailableForIcon); m_installContext.widgetConfig.localizationData.icons.push_back( @@ -358,7 +363,8 @@ void TaskWidgetConfig::ProcessWidgetInstalledPath() { LogDebug("ProcessWidgetInstalledPath"); m_installContext.widgetConfig.widgetInstalledPath = - DPL::FromUTF8String(m_installContext.locations->getPackageInstallationDir()); + DPL::FromUTF8String( + m_installContext.locations->getPackageInstallationDir()); } void TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures() @@ -389,16 +395,17 @@ void TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion() } } -void TaskWidgetConfig::createInstallPopup(PopupType type, const std::string &label) +void TaskWidgetConfig::createInstallPopup(PopupType type, + const std::string &label) { m_installContext.job->Pause(); - if (m_popup) + if (m_popup) { destroyPopup(); + } bool ret = createPopup(); - if (ret) - { - loadPopup( type, label); + if (ret) { + loadPopup(type, label); showPopup(); } } @@ -411,8 +418,8 @@ void TaskWidgetConfig::StepDeletePopupWin() void TaskWidgetConfig::StepShowWidgetInfo() { if (!m_popupData.widgetInfo.empty()) { - std::string label = DPL::ToUTF8String(m_popupData.widgetInfo); - createInstallPopup(PopupType::WIDGET_FEATURE_INFO, label); + std::string label = DPL::ToUTF8String(m_popupData.widgetInfo); + createInstallPopup(PopupType::WIDGET_FEATURE_INFO, label); m_installContext.job->UpdateProgress( InstallerContext::INSTALL_WIDGET_CONFIG2, "Show Widget Info Finished"); @@ -422,25 +429,24 @@ void TaskWidgetConfig::StepShowWidgetInfo() void TaskWidgetConfig::StepCheckMinVersionInfo() { if (!isMinVersionCompatible( - m_installContext.widgetConfig.webAppType.appType, - m_installContext.widgetConfig.minVersion)) { - if(!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) - { + m_installContext.widgetConfig.webAppType.appType, + m_installContext.widgetConfig.minVersion)) + { + if (!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) { LogDebug("Platform version to low - launching"); std::string label = WIDGET_NOT_COMPATIBLE + QUESTION; createInstallPopup(PopupType::WIDGET_MIN_VERSION, label); - } - else - { - LogError("Platform version lower than required -> cancelling installation"); + } else { + LogError( + "Platform version lower than required -> cancelling installation"); ThrowMsg(Exceptions::NotAllowed, - "Platform version does not meet requirements"); + "Platform version does not meet requirements"); } } m_installContext.job->UpdateProgress( - InstallerContext::INSTALL_WIDGET_CONFIG2, - "Check MinVersion Finished"); + InstallerContext::INSTALL_WIDGET_CONFIG2, + "Check MinVersion Finished"); } void TaskWidgetConfig::StepVerifyFeatures() @@ -464,12 +470,14 @@ void TaskWidgetConfig::StepVerifyFeatures() ThrowMsg( Exceptions::WidgetConfigFileInvalid, "This app type [" << - m_installContext.widgetConfig.webAppType.getApptypeToString() << + m_installContext.widgetConfig.webAppType.getApptypeToString() + << "] cannot be allowed to use [" << DPL::ToUTF8String(it->name) + "] feature"); } if (!WrtDB::FeatureDAOReadOnly::isFeatureInstalled( - DPL::ToUTF8String(it->name))) { + DPL::ToUTF8String(it->name))) + { LogWarning("Feature not found. Checking if required :[" << DPL::ToUTF8String(it->name) << "]"); @@ -480,11 +488,13 @@ void TaskWidgetConfig::StepVerifyFeatures() * supported. */ std::ostringstream os; - os << "Widget cannot be installed, required feature is missing:[" - << DPL::ToUTF8String(it->name) << "]"; + os << + "Widget cannot be installed, required feature is missing:[" + << DPL::ToUTF8String(it->name) << "]"; if (!GlobalSettings::TestModeEnabled() && !isTizenWebApp()) { std::string label = os.str(); - createInstallPopup(PopupType::WIDGET_WRONG_FEATURE_INFO, label); + createInstallPopup(PopupType::WIDGET_WRONG_FEATURE_INFO, + label); } ThrowMsg(Exceptions::WidgetConfigFileInvalid, os.str()); } @@ -494,7 +504,7 @@ void TaskWidgetConfig::StepVerifyFeatures() featureInfo += DPL::ToUTF8String(BR); } } - if(!data.accessInfoSet.empty()) { + if (!data.accessInfoSet.empty()) { featureInfo += WINDGET_INSTALL_NETWORK_ACCESS; featureInfo += DPL::ToUTF8String(BR); } @@ -544,7 +554,9 @@ bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType, } bool TaskWidgetConfig::parseVersionString(const std::string &version, - long &majorVersion, long &minorVersion, long µVersion) const + long &majorVersion, + long &minorVersion, + long µVersion) const { std::istringstream inputString(version); inputString >> majorVersion; @@ -566,20 +578,22 @@ bool TaskWidgetConfig::parseVersionString(const std::string &version, return true; } -bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType, - const DPL::OptionalString &widgetVersion) const +bool TaskWidgetConfig::isMinVersionCompatible( + WrtDB::AppType appType, + const DPL::OptionalString & + widgetVersion) const { - if (widgetVersion.IsNull() || (*widgetVersion).empty()) - { + if (widgetVersion.IsNull() || (*widgetVersion).empty()) { LogWarning("minVersion attribute is empty. WRT assumes platform " - "supports this widget."); + "supports this widget."); return true; } //Parse widget version long majorWidget = 0, minorWidget = 0, microWidget = 0; if (!parseVersionString(DPL::ToUTF8String(*widgetVersion), majorWidget, - minorWidget, microWidget)) { + minorWidget, microWidget)) + { LogWarning("Invalid format of widget version string."); return true; } @@ -597,15 +611,16 @@ bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType, } if (!parseVersionString(version, - majorSupported, minorSupported, microSupported)) { + majorSupported, minorSupported, microSupported)) + { LogWarning("Invalid format of platform version string."); return true; } if (majorWidget > majorSupported || - (majorWidget == majorSupported && minorWidget > minorSupported) || - (majorWidget == majorSupported && minorWidget == minorSupported - && microWidget > microSupported)) + (majorWidget == majorSupported && minorWidget > minorSupported) || + (majorWidget == majorSupported && minorWidget == minorSupported + && microWidget > microSupported)) { LogInfo("Platform doesn't support this widget."); return false; @@ -617,24 +632,29 @@ bool TaskWidgetConfig::isTizenWebApp() const { bool ret = FALSE; if (m_installContext.widgetConfig.webAppType.appType - == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) + == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) + { ret = TRUE; + } return ret; } -bool TaskWidgetConfig::parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo, - const std::string& _currentPath, int* pErrCode) +bool TaskWidgetConfig::parseConfigurationFileBrowser( + WrtDB::ConfigParserData& configInfo, + const std::string& + _currentPath, + int* pErrCode) { ParserRunner parser; Try { parser.Parse(_currentPath, ElementParserPtr(new - RootParser< - WidgetParser>( - configInfo, - DPL::FromUTF32String( - L"widget")))); + RootParser< + WidgetParser>( + configInfo, + DPL::FromUTF32String( + L"widget")))); } Catch(ElementParser::Exception::Base) { @@ -645,8 +665,11 @@ bool TaskWidgetConfig::parseConfigurationFileBrowser(WrtDB::ConfigParserData& co return true; } -bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo, - const std::string& _currentPath, int* pErrCode) +bool TaskWidgetConfig::parseConfigurationFileWidget( + WrtDB::ConfigParserData& configInfo, + const std::string& + _currentPath, + int* pErrCode) { ParserRunner parser; @@ -662,7 +685,8 @@ bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& con } bool has_config_xml = false; errno = 0; - while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on its name + while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on + // its name if (ptr->d_type == DT_REG) { if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) { std::string dName(ptr->d_name); @@ -688,8 +712,10 @@ bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& con // _rethrown_exception.Dump(); *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE; if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { - LogError("Failed to close dir: " << _currentPath << " with error: " - << DPL::GetErrnoString()); + LogError( + "Failed to close dir: " << _currentPath << + " with error: " + << DPL::GetErrnoString()); } return false; } @@ -701,7 +727,7 @@ bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& con } if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { LogError("Failed to close dir: " << _currentPath << " with error: " - << DPL::GetErrnoString()); + << DPL::GetErrnoString()); } //We must have config.xml so leaveing if we doesn't @@ -714,10 +740,10 @@ bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& con } bool TaskWidgetConfig::locateAndParseConfigurationFile( - const std::string& _currentPath, - WrtDB::WidgetRegisterInfo& pWidgetConfigInfo, - const std::string& baseFolder, - int* pErrCode) + const std::string& _currentPath, + WrtDB::WidgetRegisterInfo& pWidgetConfigInfo, + const std::string& baseFolder, + int* pErrCode) { using namespace WrtDB; @@ -730,7 +756,7 @@ bool TaskWidgetConfig::locateAndParseConfigurationFile( // check if this installation from browser, or not. size_t pos = _currentPath.rfind("/"); std::ostringstream infoPath; - infoPath << _currentPath.substr(pos+1); + infoPath << _currentPath.substr(pos + 1); if (infoPath.str() != WRT_WIDGET_CONFIG_FILE_NAME) { if (_currentPath.empty() || baseFolder.empty()) { @@ -738,28 +764,30 @@ bool TaskWidgetConfig::locateAndParseConfigurationFile( return false; } // in case of general installation using wgt archive - if(!parseConfigurationFileWidget(configInfo, _currentPath, pErrCode)) + if (!parseConfigurationFileWidget(configInfo, _currentPath, + pErrCode)) { return false; } } else { // in case of browser installation - if(!parseConfigurationFileBrowser(configInfo, _currentPath, pErrCode)) + if (!parseConfigurationFileBrowser(configInfo, _currentPath, + pErrCode)) { return false; } } - if(!fillWidgetConfig(pWidgetConfigInfo, configInfo)) - { + if (!fillWidgetConfig(pWidgetConfigInfo, configInfo)) { *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE; return false; } return true; } -bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo, - WrtDB::ConfigParserData& configInfo) +bool TaskWidgetConfig::fillWidgetConfig( + WrtDB::WidgetRegisterInfo& pWidgetConfigInfo, + WrtDB::ConfigParserData& configInfo) { if (!!configInfo.widget_id) { if (!pWidgetConfigInfo.guid) { @@ -772,17 +800,18 @@ bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfig } } if (!!configInfo.tizenAppId) { - if(DPL::ToUTF8String(pWidgetConfigInfo.tzAppid).compare( - DPL::ToUTF8String(*configInfo.tizenAppId)) < 0) { - LogError("Invalid archive - Tizen App ID not same error"); - return false; - } + if (DPL::ToUTF8String(pWidgetConfigInfo.tzAppid).compare( + DPL::ToUTF8String(*configInfo.tizenAppId)) < 0) + { + LogError("Invalid archive - Tizen App ID not same error"); + return false; + } } if (!!configInfo.tizenPkgId) { - if (pWidgetConfigInfo.tzPkgid != *configInfo.tizenPkgId) { - LogError("Invalid archive - Tizen Pkg ID not same error"); - return false; - } + if (pWidgetConfigInfo.tzPkgid != *configInfo.tizenPkgId) { + LogError("Invalid archive - Tizen Pkg ID not same error"); + return false; + } } if (!!configInfo.version) { if (!pWidgetConfigInfo.version) { @@ -802,17 +831,19 @@ bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfig return true; } -void TaskWidgetConfig::processFile(const std::string& path, - WrtDB::WidgetRegisterInfo &widgetConfiguration) +void TaskWidgetConfig::processFile( + const std::string& path, + WrtDB::WidgetRegisterInfo & + widgetConfiguration) { int pErrCode; if (!locateAndParseConfigurationFile(path, widgetConfiguration, - DEFAULT_LANGUAGE, &pErrCode)) { + DEFAULT_LANGUAGE, &pErrCode)) + { LogWarning("Widget archive: Failed while parsing config file"); ThrowMsg(Exception::ConfigParseFailed, path); } } - } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_widget_config.h b/src/jobs/widget_install/task_widget_config.h old mode 100755 new mode 100644 index 9b44559..fe8309c --- a/src/jobs/widget_install/task_widget_config.h +++ b/src/jobs/widget_install/task_widget_config.h @@ -71,10 +71,12 @@ class TaskWidgetConfig : void StepProcessConfigurationFile(); void ReadLocaleFolders(); void ProcessLocalizedStartFiles(); - void ProcessStartFile(const DPL::OptionalString& path, - const DPL::OptionalString& type, - const DPL::OptionalString& encoding = DPL::OptionalString::Null, - bool typeForcedInConfig = false); + void ProcessStartFile( + const DPL::OptionalString& path, + const DPL::OptionalString& type, + const DPL::OptionalString& encoding = + DPL::OptionalString::Null, + bool typeForcedInConfig = false); void ProcessBackgroundPageFile(); void ProcessLocalizedIcons(); void ProcessIcon(const WrtDB::ConfigParserData::Icon& icon); @@ -93,17 +95,17 @@ class TaskWidgetConfig : void createInstallPopup(PopupType type, const std::string &label); DPL::String createAuthorWidgetInfo() const; bool isFeatureAllowed( - WrtDB::AppType appType, DPL::String featureName); + WrtDB::AppType appType, DPL::String featureName); bool isMinVersionCompatible( - WrtDB::AppType appType, - const DPL::OptionalString &widgetVersion) const; + WrtDB::AppType appType, + const DPL::OptionalString &widgetVersion) const; /** * @brief Parses version string in format "major.minor.micro anything" * Returns false if format is invalid */ bool isTizenWebApp() const; bool parseVersionString(const std::string &version, long &majorVersion, - long &minorVersion, long µVersion) const; + long &minorVersion, long µVersion) const; /** * This method is used to process the config.xml of widget, get * the corresponding configuration to pWidgetConfigInfo @@ -114,16 +116,21 @@ class TaskWidgetConfig : void processFile(const std::string& path, WrtDB::WidgetRegisterInfo &wConfig); - bool locateAndParseConfigurationFile(const std::string& currentPath, - WrtDB::WidgetRegisterInfo& pWidgetConfigInfo, - const std::string& baseFolder, - int* pErrCode); + bool locateAndParseConfigurationFile( + const std::string& currentPath, + WrtDB::WidgetRegisterInfo& + pWidgetConfigInfo, + const std::string& baseFolder, + int* pErrCode); bool parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo, - const std::string& _currentPath, int* pErrCode); + const std::string& _currentPath, + int* pErrCode); bool parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo, - const std::string& _currentPath, int* pErrCode); + const std::string& _currentPath, + int* pErrCode); bool fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo, - WrtDB::ConfigParserData& configInfo); + WrtDB::ConfigParserData& configInfo); + public: TaskWidgetConfig(InstallerContext& installTaskContext); }; diff --git a/src/jobs/widget_install/view_mode.h b/src/jobs/widget_install/view_mode.h index 6054388..a4acc39 100644 --- a/src/jobs/widget_install/view_mode.h +++ b/src/jobs/widget_install/view_mode.h @@ -24,7 +24,6 @@ namespace Jobs { namespace WidgetInstall { - enum ViewMode { WINDOWED = 0, @@ -33,7 +32,6 @@ enum ViewMode MAXIMIZED, MINIMIZED }; - } // WidgetInstall } // Jobs diff --git a/src/jobs/widget_install/wac_security.cpp b/src/jobs/widget_install/wac_security.cpp index 6dafd02..447a99f 100644 --- a/src/jobs/widget_install/wac_security.cpp +++ b/src/jobs/widget_install/wac_security.cpp @@ -25,19 +25,17 @@ namespace Jobs { namespace WidgetInstall { - void WacSecurity::getCertificateChainList( - WrtDB::CertificateChainList& list, - WrtDB::CertificateSource source) const + WrtDB::CertificateChainList& list, + WrtDB::CertificateSource source) const { - if (source == WrtDB::CertificateSource::SIGNATURE_DISTRIBUTOR){ + if (source == WrtDB::CertificateSource::SIGNATURE_DISTRIBUTOR) { FOREACH(certIter, mCertificateChainList) - list.push_back(certIter->toBase64String()); + list.push_back(certIter->toBase64String()); } else { FOREACH(certIter, mAuthorsCertificateChainList) - list.push_back(certIter->toBase64String()); + list.push_back(certIter->toBase64String()); } } - } // namespace WidgetInstall } // namespace Jobs diff --git a/src/jobs/widget_install/wac_security.h b/src/jobs/widget_install/wac_security.h index a2095da..b12e067 100644 --- a/src/jobs/widget_install/wac_security.h +++ b/src/jobs/widget_install/wac_security.h @@ -29,7 +29,6 @@ namespace Jobs { namespace WidgetInstall { - class WacSecurity : public WrtDB::IWacSecurity { public: @@ -37,8 +36,7 @@ class WacSecurity : public WrtDB::IWacSecurity mRecognized(false), mDistributorSigned(false), mWacSigned(false) - { - } + {} // from IWacSecurity virtual const WrtDB::WidgetCertificateDataList& getCertificateList() const @@ -46,30 +44,49 @@ class WacSecurity : public WrtDB::IWacSecurity return mCertificateList; } - virtual bool isRecognized() const { return mRecognized; } + virtual bool isRecognized() const + { + return mRecognized; + } - virtual bool isDistributorSigned() const { return mDistributorSigned; } + virtual bool isDistributorSigned() const + { + return mDistributorSigned; + } - virtual bool isWacSigned() const { return mWacSigned; } + virtual bool isWacSigned() const + { + return mWacSigned; + } virtual void getCertificateChainList( - WrtDB::CertificateChainList& list, - WrtDB::CertificateSource source) const; + WrtDB::CertificateChainList& list, + WrtDB::CertificateSource source) const; - void setRecognized(bool recognized) { mRecognized = recognized; } + void setRecognized(bool recognized) + { + mRecognized = recognized; + } void setDistributorSigned(bool distributorSigned) { mDistributorSigned = distributorSigned; } - void setWacSigned(bool wacSigned) { mWacSigned = wacSigned; } + void setWacSigned(bool wacSigned) + { + mWacSigned = wacSigned; + } - ValidationCore::CertificatePtr getAuthorCertificatePtr() const { return mAuthorCertificate;} + ValidationCore::CertificatePtr getAuthorCertificatePtr() const + { + return mAuthorCertificate; + } ValidationCore::CertificateCollectionList& getCertificateChainListRef() { return mCertificateChainList; } - ValidationCore::CertificateCollectionList& getAuthorsCertificateChainListRef() + ValidationCore::CertificateCollectionList& + getAuthorsCertificateChainListRef() { return mAuthorsCertificateChainList; } @@ -98,7 +115,6 @@ class WacSecurity : public WrtDB::IWacSecurity // This authors certificates are used by tizen ValidationCore::CertificateCollectionList mAuthorsCertificateChainList; }; - } // namespace WidgetInstall } // namespace Jobs diff --git a/src/jobs/widget_install/widget_install_context.h b/src/jobs/widget_install/widget_install_context.h old mode 100755 new mode 100644 index 284cc1b..510926c --- a/src/jobs/widget_install/widget_install_context.h +++ b/src/jobs/widget_install/widget_install_context.h @@ -86,19 +86,20 @@ struct InstallerContext // Installation state variables WrtDB::WidgetRegisterInfo widgetConfig; ///< WidgetConfigInfo DPL::Optional locations; - Jobs::WidgetInstall::WacSecurity wacSecurity;///< Widget Domain information. + Jobs::WidgetInstall::WacSecurity wacSecurity; ///< Widget Domain + // information. InstallStep installStep; ///< current step of installation Jobs::WidgetInstall::JobWidgetInstall *job; - ///< pointer of instance of JobWidgetInstall + ///< pointer of instance of JobWidgetInstall WidgetUpdateInfo::ExistingWidgetInfo existingWidgetInfo; - ///< Whether this is an update or normal installation + ///< Whether this is an update or normal installation Jobs::WidgetInstall::FeatureLogicPtr featureLogic; /** List of dev-caps that are requested in widget config file. - * Additional flag tells whether dev cap gets "static" permission - * (will always have PERMIT from ACE Policy). They will therefore receive - * static SMACK permission. (They may be forbidden because - * of ACE User Settings, but for now we do not protect this - * case with SMACK). */ + * Additional flag tells whether dev cap gets "static" permission + * (will always have PERMIT from ACE Policy). They will therefore receive + * static SMACK permission. (They may be forbidden because + * of ACE User Settings, but for now we do not protect this + * case with SMACK). */ RequestedDevCapsMap staticPermittedDevCaps; std::string installInfo; /// bool m_quiet; diff --git a/src/jobs/widget_install/widget_install_errors.h b/src/jobs/widget_install/widget_install_errors.h index 32ef9b0..196ce64 100644 --- a/src/jobs/widget_install/widget_install_errors.h +++ b/src/jobs/widget_install/widget_install_errors.h @@ -42,11 +42,14 @@ enum Type ErrorInvalidPackage, ///< Widget signature is invalid. ErrorAlreadyInstalled, ///< ? ErrorInternal, ///< ? - ErrorNotAllowed, ///< Widget installation or update not allowed + ErrorNotAllowed, ///< Widget installation or update not + // allowed ///< because violation of policy ocurred - ErrorDeferred, ///< Widget installation was deferred and will be continued when possible + ErrorDeferred, ///< Widget installation was deferred and + // will be continued when possible ErrorDatabaseFailure, ///< Failure in database - ErrorRemovingFolderFailure, ///< Failure in removing existing widget folder + ErrorRemovingFolderFailure, ///< Failure in removing existing widget + // folder ErrorCreateVconfFailure, ///< Failure in creating vconf ErrorInstallOspServcie, ///< Failure in installing osp service ErrorUpdateWidget, ///< Failure in widget update. @@ -105,7 +108,6 @@ DECLARE_JOB_EXCEPTION(Base, EmptyPluginsDirectory, ErrorInvalidWidgetPackage) DECLARE_JOB_EXCEPTION(Base, PluginsSubdirectory, ErrorInvalidWidgetPackage) DECLARE_JOB_EXCEPTION(Base, SetCertificateInfoFailed, ErrorUnknown) - } //namespace } //namespace } //namespace diff --git a/src/jobs/widget_install/widget_install_popup.cpp b/src/jobs/widget_install/widget_install_popup.cpp old mode 100755 new mode 100644 index 34c3fa1..bfb6b9f --- a/src/jobs/widget_install/widget_install_popup.cpp +++ b/src/jobs/widget_install/widget_install_popup.cpp @@ -26,19 +26,20 @@ #include namespace { -const char * const EDJFILE ="/usr/share/edje/wrt/widget_install_popup.edj"; +const char * const EDJFILE = "/usr/share/edje/wrt/widget_install_popup.edj"; const char * const EDJGROUP = "widget_install_popup"; -const char * const TITLE_TEXT ="title,text"; -const char * const name ="WidgetInstallPopup"; +const char * const TITLE_TEXT = "title,text"; +const char * const name = "WidgetInstallPopup"; const char * const FEATURE_TITLE = "Widget Feature Info"; const char * const INFO_TITLE = "Widget Info"; const char * const INSTALLATION_FAILURE = "Installation failure"; -const char * const INFO_LEFT_BUTTON ="OK"; +const char * const INFO_LEFT_BUTTON = "OK"; const char * const INFO_RIGHT_BUTTON = "CANCEL "; const char * const WARNING_TITLE = "Widget Warning"; const char * const WARNING_LEFT_BUTTON = "YES"; const char * const WARNING_RIGHT_BUTTON = "NO"; -const char * const QUESTION ="Widget use Device API below.
Do you want to install?"; +const char * const QUESTION = + "Widget use Device API below.
Do you want to install?"; } namespace Jobs { @@ -61,8 +62,7 @@ bool WidgetInstallPopup::addWin(const char *name) { int w, h; m_win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC); - if(!m_win) - { + if (!m_win) { LogError("addWin failed"); return false; } @@ -80,40 +80,42 @@ bool WidgetInstallPopup::addWin(const char *name) bool WidgetInstallPopup::addPopup() { m_popup = elm_popup_add(m_win); - if(!m_popup) + if (!m_popup) { return false; + } evas_object_size_hint_align_set(m_popup, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(m_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_weight_set(m_popup, + EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); return true; } void WidgetInstallPopup::addTitle(PopupType type) { switch (type) { - case PopupType::WIDGET_FEATURE_INFO : + case PopupType::WIDGET_FEATURE_INFO: elm_object_part_text_set(m_popup, TITLE_TEXT, FEATURE_TITLE); - break; - case PopupType::WIDGET_AUTHOR_INFO : + break; + case PopupType::WIDGET_AUTHOR_INFO: elm_object_part_text_set(m_popup, TITLE_TEXT, INFO_TITLE); - break; - case PopupType::WIDGET_MIN_VERSION : - case PopupType::WIDGET_UNRECOGNIZED : + break; + case PopupType::WIDGET_MIN_VERSION: + case PopupType::WIDGET_UNRECOGNIZED: elm_object_part_text_set(m_popup, TITLE_TEXT, WARNING_TITLE); - break; - case PopupType::WIDGET_WRONG_FEATURE_INFO : + break; + case PopupType::WIDGET_WRONG_FEATURE_INFO: elm_object_part_text_set(m_popup, TITLE_TEXT, INSTALLATION_FAILURE); - break; - default : - break; -} + break; + default: + break; + } } void WidgetInstallPopup::addScrollLabel(const std::string &str) { Evas_Object *ly = elm_layout_add(m_popup); - if (!ly) - { + if (!ly) { LogError(" install popup layout add failed"); return; } @@ -124,95 +126,111 @@ void WidgetInstallPopup::addScrollLabel(const std::string &str) elm_object_content_set(m_popup, ly); Evas_Object *question_label = elm_label_add(m_popup); - if(!question_label) + if (!question_label) { return; - evas_object_size_hint_align_set(question_label, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(question_label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + } + evas_object_size_hint_align_set(question_label, + EVAS_HINT_FILL, + EVAS_HINT_FILL); + evas_object_size_hint_weight_set(question_label, + EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); evas_object_show(question_label); elm_object_text_set(question_label, QUESTION); elm_object_part_content_set(ly, "elm.swallow.label", question_label); Evas_Object *scroller = elm_scroller_add(m_popup); - if(!scroller) + if (!scroller) { return; + } evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_weight_set(scroller, + EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE); - elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO); + elm_scroller_policy_set(scroller, + ELM_SCROLLER_POLICY_AUTO, + ELM_SCROLLER_POLICY_AUTO); elm_object_part_content_set(ly, "elm.swallow.scroller", scroller); evas_object_show(scroller); Evas_Object *feature_label = elm_label_add(m_popup); - if(!feature_label) + if (!feature_label) { return; - evas_object_size_hint_align_set(feature_label, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(feature_label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + } + evas_object_size_hint_align_set(feature_label, + EVAS_HINT_FILL, + EVAS_HINT_FILL); + evas_object_size_hint_weight_set(feature_label, + EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); evas_object_show(feature_label); elm_object_text_set(feature_label, str.c_str()); elm_object_content_set(scroller, feature_label); } -void WidgetInstallPopup::addContent(PopupType type, const std::string &str) +void WidgetInstallPopup::addContent(PopupType type, const std::string &str) { switch (type) { - case PopupType::WIDGET_FEATURE_INFO : + case PopupType::WIDGET_FEATURE_INFO: addScrollLabel(str); - break; - default : + break; + default: elm_object_part_text_set(m_popup, "default", str.c_str()); - break; + break; } } -void WidgetInstallPopup::addButton(PopupType type) +void WidgetInstallPopup::addButton(PopupType type) { Evas_Object *lbutton = elm_button_add(m_popup); Evas_Object *rbutton = elm_button_add(m_popup); - if(!lbutton || !rbutton) + if (!lbutton || !rbutton) { return; + } switch (type) { - case PopupType::WIDGET_WRONG_FEATURE_INFO : - elm_object_text_set(lbutton, INFO_LEFT_BUTTON); - elm_object_part_content_set(m_popup, "button1", lbutton); - evas_object_smart_callback_add(lbutton, - "clicked", - userCancelCallback, - this); - return; - case PopupType::WIDGET_FEATURE_INFO : - elm_object_text_set(lbutton, INFO_LEFT_BUTTON); - elm_object_text_set(rbutton, INFO_RIGHT_BUTTON); - break; - default : - elm_object_text_set(lbutton, WARNING_LEFT_BUTTON); - elm_object_text_set(rbutton, WARNING_RIGHT_BUTTON); - break; + case PopupType::WIDGET_WRONG_FEATURE_INFO: + elm_object_text_set(lbutton, INFO_LEFT_BUTTON); + elm_object_part_content_set(m_popup, "button1", lbutton); + evas_object_smart_callback_add(lbutton, + "clicked", + userCancelCallback, + this); + return; + case PopupType::WIDGET_FEATURE_INFO: + elm_object_text_set(lbutton, INFO_LEFT_BUTTON); + elm_object_text_set(rbutton, INFO_RIGHT_BUTTON); + break; + default: + elm_object_text_set(lbutton, WARNING_LEFT_BUTTON); + elm_object_text_set(rbutton, WARNING_RIGHT_BUTTON); + break; } elm_object_part_content_set(m_popup, "button1", lbutton); evas_object_smart_callback_add(lbutton, - "clicked", - userPermitCallback, - this); + "clicked", + userPermitCallback, + this); elm_object_part_content_set(m_popup, "button2", rbutton); evas_object_smart_callback_add(rbutton, - "clicked", - userCancelCallback, - this); + "clicked", + userCancelCallback, + this); } bool WidgetInstallPopup::createPopup() { bool ret = addWin(name); - if(!ret) + if (!ret) { return false; + } evas_object_show(m_win); ret = addPopup(); - if(!ret) - { + if (!ret) { evas_object_del(m_win); m_win = NULL; return false; @@ -223,11 +241,11 @@ bool WidgetInstallPopup::createPopup() void WidgetInstallPopup::destroyPopup() { - if(m_win) { - evas_object_del(m_win); - m_win = NULL; - m_popup = NULL; - } + if (m_win) { + evas_object_del(m_win); + m_win = NULL; + m_popup = NULL; + } } void WidgetInstallPopup::loadPopup(PopupType type, const std::string &label) @@ -243,8 +261,8 @@ void WidgetInstallPopup::showPopup() } void WidgetInstallPopup::userPermitCallback(void * data, - Evas_Object */*obj*/, - void */*event_info*/) + Evas_Object */*obj*/, + void */*event_info*/) { WidgetInstallPopup *This = static_cast(data); This->m_installCancel = WRT_POPUP_BUTTON_OK; @@ -252,8 +270,8 @@ void WidgetInstallPopup::userPermitCallback(void * data, } void WidgetInstallPopup::userCancelCallback(void *data, - Evas_Object */*obj*/, - void */*event_info*/) + Evas_Object */*obj*/, + void */*event_info*/) { WidgetInstallPopup *This = static_cast(data); This->m_installCancel = WRT_POPUP_BUTTON_CANCEL; @@ -262,4 +280,3 @@ void WidgetInstallPopup::userCancelCallback(void *data, } } - diff --git a/src/jobs/widget_install/widget_install_popup.h b/src/jobs/widget_install/widget_install_popup.h old mode 100755 new mode 100644 index d2859f7..bbbe851 --- a/src/jobs/widget_install/widget_install_popup.h +++ b/src/jobs/widget_install/widget_install_popup.h @@ -27,12 +27,10 @@ #include #include - class InstallerContext; namespace Jobs { namespace WidgetInstall { - enum PopupType { WIDGET_INSTALL_POPUP = 0, WIDGET_FEATURE_INFO, //sp-2390 @@ -49,36 +47,35 @@ enum InfoPopupButton WRT_POPUP_BUTTON_CANCEL }; - class WidgetInstallPopup { - public : - explicit WidgetInstallPopup(InstallerContext &installContext); - virtual ~WidgetInstallPopup(); + public: + explicit WidgetInstallPopup(InstallerContext &installContext); + virtual ~WidgetInstallPopup(); - bool createPopup(); - void destroyPopup(); - void loadPopup(PopupType type, const std::string &label); - void showPopup(); - bool addWin(const char *name); - bool addPopup(); - void addTitle(PopupType type); - void addScrollLabel(const std::string &str); - void addContent(PopupType type, const std::string &str); - void addButton(PopupType type); + bool createPopup(); + void destroyPopup(); + void loadPopup(PopupType type, const std::string &label); + void showPopup(); + bool addWin(const char *name); + bool addPopup(); + void addTitle(PopupType type); + void addScrollLabel(const std::string &str); + void addContent(PopupType type, const std::string &str); + void addButton(PopupType type); - static void userPermitCallback(void *data, - Evas_Object *obj, - void *event_info); - static void userCancelCallback(void *data, - Evas_Object *obj, - void *event_info); + static void userPermitCallback(void *data, + Evas_Object *obj, + void *event_info); + static void userCancelCallback(void *data, + Evas_Object *obj, + void *event_info); - protected : - Evas_Object *m_win; - Evas_Object *m_popup; - InstallerContext &m_installContext; - int m_installCancel; + protected: + Evas_Object *m_win; + Evas_Object *m_popup; + InstallerContext &m_installContext; + int m_installCancel; }; } } diff --git a/src/jobs/widget_install/widget_installer_struct.h b/src/jobs/widget_install/widget_installer_struct.h old mode 100755 new mode 100644 index 2a655c8..797aa2d --- a/src/jobs/widget_install/widget_installer_struct.h +++ b/src/jobs/widget_install/widget_installer_struct.h @@ -51,13 +51,13 @@ enum Type Zero = 0, // Bits - NotInstalled = 1 << 0, + NotInstalled = 1 << 0, IncomingVersionNotStd = 1 << 1, ExistingVersionNotStd = 1 << 2, - BothVersionsNotStd = 1 << 3, - ExistingVersionOlder = 1 << 4, - ExistingVersionEqual = 1 << 5, - ExistingVersionNewer = 1 << 6, + BothVersionsNotStd = 1 << 3, + ExistingVersionOlder = 1 << 4, + ExistingVersionEqual = 1 << 5, + ExistingVersionNewer = 1 << 6, // Policies PolicyNeverUpdate = NotInstalled, @@ -78,14 +78,14 @@ enum Type }; inline Type operator | (const Type &a, - const Type &b) + const Type &b) { return static_cast(static_cast(a) | static_cast(b)); } inline Type operator & (const Type &a, - const Type &b) + const Type &b) { return static_cast(static_cast(a) & static_cast(b)); @@ -108,26 +108,26 @@ struct WidgetInstallationStruct : public WidgetInstallCallbackBase // It must be empty-constructible as a parameter of generic event WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero), - m_quiet(true), - m_preload(false) - { - } - - WidgetInstallationStruct(InstallerFinishedCallback finished, - InstallerProgressCallback progress, - void *param, - WidgetUpdateMode::Type mode, - bool quiet, - bool preload, - std::shared_ptr _pkgmgrInterface - ) : + m_quiet(true), + m_preload(false) + {} + + WidgetInstallationStruct( + InstallerFinishedCallback finished, + InstallerProgressCallback progress, + void *param, + WidgetUpdateMode::Type mode, + bool quiet, + bool preload, + std::shared_ptr + _pkgmgrInterface + ) : WidgetInstallCallbackBase(finished, progress, param), updateMode(mode), m_quiet(quiet), m_preload(preload), pkgmgrInterface(_pkgmgrInterface) - { - } + {} }; #endif // WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_ diff --git a/src/jobs/widget_install/widget_update_info.cpp b/src/jobs/widget_install/widget_update_info.cpp index ac42252..de35936 100644 --- a/src/jobs/widget_install/widget_update_info.cpp +++ b/src/jobs/widget_install/widget_update_info.cpp @@ -24,8 +24,7 @@ WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo() : isExist(false) -{ -} +{} WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo( const WrtDB::TizenAppId & appid, @@ -33,8 +32,7 @@ WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo( tzAppid(appid), isExist(true), existingVersion(version) -{ -} +{} WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo( const WrtDB::TizenAppId & appid, @@ -49,8 +47,7 @@ WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo( WidgetUpdateInfo::WidgetUpdateInfo() : existingWidgetInfo() -{ -} +{} WidgetUpdateInfo::WidgetUpdateInfo( const DPL::Optional &guid, @@ -59,5 +56,4 @@ WidgetUpdateInfo::WidgetUpdateInfo( incomingGUID(guid), incomingVersion(version), existingWidgetInfo(widgetInfo) -{ -} +{} diff --git a/src/jobs/widget_uninstall/job_widget_uninstall.cpp b/src/jobs/widget_uninstall/job_widget_uninstall.cpp index e0bc8c4..b28b9e9 100644 --- a/src/jobs/widget_uninstall/job_widget_uninstall.cpp +++ b/src/jobs/widget_uninstall/job_widget_uninstall.cpp @@ -39,9 +39,9 @@ class UninstallerTaskFail : void StepFail() { - if(m_uninstalled) { + if (m_uninstalled) { ThrowMsg(Jobs::WidgetUninstall::Exceptions::WidgetNotExist, - "Widget does not exist"); + "Widget does not exist"); } else { Throw(Jobs::WidgetUninstall::Exceptions::Base); } @@ -59,8 +59,10 @@ class UninstallerTaskFail : namespace Jobs { namespace WidgetUninstall { -JobWidgetUninstall::JobWidgetUninstall(const std::string & tizenAppId, - const WidgetUninstallationStruct &uninstallerStruct) : +JobWidgetUninstall::JobWidgetUninstall( + const std::string & tizenAppId, + const WidgetUninstallationStruct & + uninstallerStruct) : Job(Uninstallation), JobContextBase(uninstallerStruct) { @@ -107,14 +109,15 @@ JobWidgetUninstall::JobWidgetUninstall(const std::string & tizenAppId, AddTask(new TaskDeleteCertificates(m_context)); // send start signal of pkgmgr - if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.tzAppid)) { + if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.tzAppid)) + { getInstallerStruct().pkgmgrInterface->sendSignal( - PKGMGR_START_KEY, - PKGMGR_START_UNINSTALL); + PKGMGR_START_KEY, + PKGMGR_START_UNINSTALL); } - } Catch (WidgetDAOReadOnly::Exception::WidgetNotExist) { + } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) { AddTask(new UninstallerTaskFail(true)); - } Catch (WidgetDAOReadOnly::Exception::Base) { + } Catch(WidgetDAOReadOnly::Exception::Base) { AddTask(new UninstallerTaskFail(false)); } } @@ -138,19 +141,20 @@ void JobWidgetUninstall::SendProgress() { using namespace PackageManager; if (!getRemoveStartedFlag() || - (getRemoveStartedFlag() && getRemoveFinishedFlag())) { + (getRemoveStartedFlag() && getRemoveFinishedFlag())) + { if (NULL != getInstallerStruct().progressCallback) { // send progress signal of pkgmgr std::ostringstream percent; percent << static_cast(GetProgressPercent()); getInstallerStruct().pkgmgrInterface->sendSignal( - PKGMGR_PROGRESS_KEY, - percent.str()); + PKGMGR_PROGRESS_KEY, + percent.str()); LogDebug("Call widget uninstall progressCallback"); getInstallerStruct().progressCallback( - getInstallerStruct().userParam, - GetProgressPercent(), GetProgressDescription()); + getInstallerStruct().userParam, + GetProgressPercent(), GetProgressDescription()); } } } @@ -160,12 +164,13 @@ void JobWidgetUninstall::SendFinishedSuccess() using namespace PackageManager; // send signal of pkgmgr getInstallerStruct().pkgmgrInterface->sendSignal( - PKGMGR_END_KEY, - PKGMGR_END_SUCCESS); + PKGMGR_END_KEY, + PKGMGR_END_SUCCESS); LogDebug("Call widget uninstall success finishedCallback"); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, - getRemovedTizenId(),Exceptions::Success); + getRemovedTizenId(), + Exceptions::Success); } void JobWidgetUninstall::SendFinishedFailure() @@ -176,12 +181,13 @@ void JobWidgetUninstall::SendFinishedFailure() // send signal of pkgmgr getInstallerStruct().pkgmgrInterface->sendSignal( - PKGMGR_END_KEY, - PKGMGR_END_FAILURE); + PKGMGR_END_KEY, + PKGMGR_END_FAILURE); LogDebug("Call widget uninstall failure finishedCallback"); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, - getRemovedTizenId(), m_exceptionCaught); //TODO + getRemovedTizenId(), + m_exceptionCaught); //TODO LogDebug("[JobWidgetUninstall] Asynchronous failure callback status sent"); } @@ -193,14 +199,14 @@ void JobWidgetUninstall::SaveExceptionData(const Jobs::JobExceptionBase &e) bool JobWidgetUninstall::getExternalWidgetFlag() const { - LogDebug("Get external widget"); - if (APP2EXT_SD_CARD == app2ext_get_app_location(m_context.tzAppid.c_str())) { + if (APP2EXT_SD_CARD == + app2ext_get_app_location(m_context.tzAppid.c_str())) + { LogDebug("This widget is in external stroage"); return true; } return false; } - } //namespace WidgetUninstall } //namespace Jobs diff --git a/src/jobs/widget_uninstall/job_widget_uninstall.h b/src/jobs/widget_uninstall/job_widget_uninstall.h index 4b912b8..a76444e 100644 --- a/src/jobs/widget_uninstall/job_widget_uninstall.h +++ b/src/jobs/widget_uninstall/job_widget_uninstall.h @@ -50,7 +50,7 @@ class JobWidgetUninstall : * @param[in] WrtDB::TizenAppId tzAppId - widget to uninstall */ JobWidgetUninstall(const std::string &tizenAppId, - const WidgetUninstallationStruct& uninstallerStruct); + const WidgetUninstallationStruct& uninstallerStruct); std::string getRemovedTizenId() const; bool getRemoveStartedFlag() const; diff --git a/src/jobs/widget_uninstall/task_check.cpp b/src/jobs/widget_uninstall/task_check.cpp index d2ae728..e87a50a 100644 --- a/src/jobs/widget_uninstall/task_check.cpp +++ b/src/jobs/widget_uninstall/task_check.cpp @@ -38,8 +38,7 @@ TaskCheck::TaskCheck(UninstallerContext& context) : } TaskCheck::~TaskCheck() -{ -} +{} void TaskCheck::StepUninstallPreCheck() { @@ -68,6 +67,5 @@ void TaskCheck::StepUninstallPreCheck() m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_PRECHECK, "Uninstall pre-checking Finished"); } - } //namespace WidgetUninstall } //namespace Jobs diff --git a/src/jobs/widget_uninstall/task_db_update.cpp b/src/jobs/widget_uninstall/task_db_update.cpp index 4c88b92..0418ce8 100644 --- a/src/jobs/widget_uninstall/task_db_update.cpp +++ b/src/jobs/widget_uninstall/task_db_update.cpp @@ -42,8 +42,7 @@ TaskDbUpdate::TaskDbUpdate(UninstallerContext& context) : } TaskDbUpdate::~TaskDbUpdate() -{ -} +{} void TaskDbUpdate::StepDbUpdate() { @@ -51,7 +50,10 @@ void TaskDbUpdate::StepDbUpdate() { //TODO: widget handle should not be used any more ace_unregister_widget(static_cast( - WidgetDAOReadOnly::getHandle(DPL::FromUTF8String(m_context.tzAppid)))); + WidgetDAOReadOnly::getHandle(DPL:: + FromUTF8String( + m_context. + tzAppid)))); WidgetDAO::unregisterWidget(DPL::FromUTF8String(m_context.tzAppid)); LogDebug("Unregistered widget successfully!"); @@ -79,6 +81,5 @@ void TaskDbUpdate::StepLiveboxDBDelete() LogInfo("delete box info: " << m_context.tzAppid); } } - } //namespace WidgetUninstall } //namespace Jobs diff --git a/src/jobs/widget_uninstall/task_delete_certificates.cpp b/src/jobs/widget_uninstall/task_delete_certificates.cpp old mode 100755 new mode 100644 index 77e2058..859bcc1 --- a/src/jobs/widget_uninstall/task_delete_certificates.cpp +++ b/src/jobs/widget_uninstall/task_delete_certificates.cpp @@ -38,16 +38,16 @@ TaskDeleteCertificates::TaskDeleteCertificates( } TaskDeleteCertificates::~TaskDeleteCertificates() -{ -} +{} void TaskDeleteCertificates::StepDeleteCertificates() { pkgmgr_instcertinfo_h handle; if ((pkgmgr_installer_delete_certinfo( - const_cast(( - m_context.tzAppid).c_str()))) < 0) { + const_cast(( + m_context.tzAppid).c_str()))) < 0) + { LogError("pkgmgr_installer_delete_certinfo fail"); } } diff --git a/src/jobs/widget_uninstall/task_delete_certificates.h b/src/jobs/widget_uninstall/task_delete_certificates.h index 94efa67..b7b513b 100644 --- a/src/jobs/widget_uninstall/task_delete_certificates.h +++ b/src/jobs/widget_uninstall/task_delete_certificates.h @@ -46,4 +46,5 @@ class TaskDeleteCertificates : } //namespace WidgetUninstall } //namespace Jobs -#endif // WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_DELETE_CERTIFICATES_H_ +#endif +// WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_DELETE_CERTIFICATES_H_ diff --git a/src/jobs/widget_uninstall/task_remove_custom_handlers.cpp b/src/jobs/widget_uninstall/task_remove_custom_handlers.cpp index 5f2b5e5..3717d62 100644 --- a/src/jobs/widget_uninstall/task_remove_custom_handlers.cpp +++ b/src/jobs/widget_uninstall/task_remove_custom_handlers.cpp @@ -30,7 +30,8 @@ namespace Jobs { namespace WidgetUninstall { -TaskRemoveCustomHandlers::TaskRemoveCustomHandlers(UninstallerContext& context) : +TaskRemoveCustomHandlers::TaskRemoveCustomHandlers(UninstallerContext& context) + : DPL::TaskDecl(this), m_context(context) { @@ -45,11 +46,10 @@ void TaskRemoveCustomHandlers::Step() CustomHandlerDB::Interface::attachDatabaseRW(); CustomHandlerDB::CustomHandlerDAO handlersDao( - DPL::FromASCIIString(m_context.tzAppid)); + DPL::FromASCIIString(m_context.tzAppid)); handlersDao.removeWidgetProtocolHandlers(); handlersDao.removeWidgetContentHandlers(); CustomHandlerDB::Interface::detachDatabase(); } - } //namespace WidgetUninstall } //namespace Jobs diff --git a/src/jobs/widget_uninstall/task_remove_custom_handlers.h b/src/jobs/widget_uninstall/task_remove_custom_handlers.h index c0812c1..48d0d92 100644 --- a/src/jobs/widget_uninstall/task_remove_custom_handlers.h +++ b/src/jobs/widget_uninstall/task_remove_custom_handlers.h @@ -28,7 +28,7 @@ class UninstallerContext; namespace Jobs { namespace WidgetUninstall { -class TaskRemoveCustomHandlers: +class TaskRemoveCustomHandlers : public DPL::TaskDecl { private: diff --git a/src/jobs/widget_uninstall/task_remove_files.cpp b/src/jobs/widget_uninstall/task_remove_files.cpp index 2e120fe..5dd82c4 100644 --- a/src/jobs/widget_uninstall/task_remove_files.cpp +++ b/src/jobs/widget_uninstall/task_remove_files.cpp @@ -37,7 +37,6 @@ namespace Jobs { namespace WidgetUninstall { - using namespace WrtDB; namespace { @@ -61,8 +60,7 @@ TaskRemoveFiles::TaskRemoveFiles(UninstallerContext& context) : } TaskRemoveFiles::~TaskRemoveFiles() -{ -} +{} void TaskRemoveFiles::StepRemoveInstallationDirectory() { @@ -71,11 +69,11 @@ void TaskRemoveFiles::StepRemoveInstallationDirectory() m_context.removeStarted = true; std::string widgetDir = m_context.locations->getPackageInstallationDir(); - if(!WrtUtilRemove(widgetDir)){ + if (!WrtUtilRemove(widgetDir)) { LogWarning("Removing widget installation directory failed"); } std::string dataDir = m_context.locations->getUserDataRootDir(); - if(!WrtUtilRemove(dataDir)){ + if (!WrtUtilRemove(dataDir)) { LogWarning(dataDir + " is already removed"); } m_context.job->UpdateProgress( @@ -113,7 +111,7 @@ void TaskRemoveFiles::StepRemoveDesktop() } if (AIL_ERROR_OK == ret) { - if ( 0 > ail_desktop_remove(package)) { + if (0 > ail_desktop_remove(package)) { LogWarning("Failed to remove ail information : " << package); } } @@ -126,22 +124,19 @@ void TaskRemoveFiles::StepRemoveDesktop() void TaskRemoveFiles::StepRemoveManifest() { std::ostringstream manifest_name; - manifest_name << m_context.tzPkgid<< ".xml"; + manifest_name << m_context.tzPkgid << ".xml"; std::ostringstream destFile; destFile << "/opt/share/packages" << "/"; //TODO constant with path destFile << manifest_name.str(); - int ret1 = pkgmgr_parser_parse_manifest_for_uninstallation(destFile.str().c_str(), NULL); + int ret1 = pkgmgr_parser_parse_manifest_for_uninstallation( + destFile.str().c_str(), NULL); int ret2 = unlink(destFile.str().c_str()); - if(ret1 != 0) - { + if (ret1 != 0) { LogWarning("Manifest file failed to parse for uninstallation"); } - if(ret2 != 0) - { + if (ret2 != 0) { LogWarning("No manifest file found: " << destFile.str()); - } - else - { + } else { LogDebug("Manifest file removed: " << destFile.str()); } } @@ -153,23 +148,22 @@ void TaskRemoveFiles::StepRemoveExternalLocations() WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations(); FOREACH(path, externalPaths) { - if(WrtUtilFileExists(*path)) - { + if (WrtUtilFileExists(*path)) { LogDebug(" -> " << *path); int ret = remove(path->c_str()); if (ret != 0) { - LogError("Failed to remove the file: " << path->c_str() << " with error: " << strerror(errno)); + LogError( + "Failed to remove the file: " << path->c_str() << + " with error: " << strerror(errno)); } - } - else if(WrtUtilDirExists(*path)) - { + } else if (WrtUtilDirExists(*path)) { LogDebug(" -> " << *path); - if(!WrtUtilRemove(*path)){ - Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed); + if (!WrtUtilRemove(*path)) { + Throw( + Jobs::WidgetUninstall::TaskRemoveFiles::Exception:: + RemoveFilesFailed); } - } - else - { + } else { LogWarning(" -> " << *path << "(no such a path)"); } } @@ -179,8 +173,9 @@ void TaskRemoveFiles::StepRemoveExternalLocations() void TaskRemoveFiles::StepRemoveVconf() { std::string key = - WrtDB::VconfConfig::GetVconfKeyRootPath(DPL::FromUTF8String(m_context.tzAppid)); - if(vconf_unset_recursive(key.c_str())) { + WrtDB::VconfConfig::GetVconfKeyRootPath(DPL::FromUTF8String(m_context. + tzAppid)); + if (vconf_unset_recursive(key.c_str())) { LogError("Fail to unset vconf file"); } else { LogDebug("vconf file is removed"); @@ -194,11 +189,12 @@ void TaskRemoveFiles::StepRemoveExternalWidget() WidgetInstallToExtSingleton::Instance().uninstallation(); WidgetInstallToExtSingleton::Instance().deinitialize(); } - Catch (WidgetInstallToExt::Exception::ErrorInstallToExt) + Catch(WidgetInstallToExt::Exception::ErrorInstallToExt) { - Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed); + Throw( + Jobs::WidgetUninstall::TaskRemoveFiles::Exception:: + RemoveFilesFailed); } } - } //namespace WidgetUninstall } //namespace Jobs diff --git a/src/jobs/widget_uninstall/task_smack.cpp b/src/jobs/widget_uninstall/task_smack.cpp index 265b364..e104bc4 100644 --- a/src/jobs/widget_uninstall/task_smack.cpp +++ b/src/jobs/widget_uninstall/task_smack.cpp @@ -39,19 +39,20 @@ TaskSmack::TaskSmack(UninstallerContext& context) : void TaskSmack::Step() { - LogInfo("------------------------> SMACK: Jobs::WidgetUninstall::TaskSmack::Step()"); + LogInfo( + "------------------------> SMACK: Jobs::WidgetUninstall::TaskSmack::Step()"); #ifdef WRT_SMACK_ENABLED try { - WrtDB::WidgetDAOReadOnly dao(m_context.widgetConfig.tzAppid); - TizenAppId tzAppid = dao.getTizenAppId(); - const char *devCap = ""; - int result = handle_access_control_conf_forWAC( - DPL::ToUTF8String(tzAppid).c_str(), - NULL, - OPERATION_UNINSTALL); - Assert(result==PC_OPERATION_SUCCESS && "access control setup failed"); + WrtDB::WidgetDAOReadOnly dao(m_context.widgetConfig.tzAppid); + TizenAppId tzAppid = dao.getTizenAppId(); + const char *devCap = ""; + int result = handle_access_control_conf_forWAC( + DPL::ToUTF8String(tzAppid).c_str(), + NULL, + OPERATION_UNINSTALL); + Assert(result == PC_OPERATION_SUCCESS && "access control setup failed"); } catch (WrtDB::WidgetDAOReadOnly::Exception) { - Assert(false && "can't access widget data"); + Assert(false && "can't access widget data"); } m_context.job->UpdateProgress( @@ -59,6 +60,5 @@ void TaskSmack::Step() "Widget SMACK Enabled"); #endif } - } //namespace WidgetUninstall } //namespace Jobs diff --git a/src/jobs/widget_uninstall/task_smack.h b/src/jobs/widget_uninstall/task_smack.h index 35a0355..f9fcda4 100644 --- a/src/jobs/widget_uninstall/task_smack.h +++ b/src/jobs/widget_uninstall/task_smack.h @@ -28,7 +28,7 @@ class UninstallerContext; namespace Jobs { namespace WidgetUninstall { -class TaskSmack: +class TaskSmack : public DPL::TaskDecl { private: diff --git a/src/jobs/widget_uninstall/task_uninstall_ospsvc.cpp b/src/jobs/widget_uninstall/task_uninstall_ospsvc.cpp index bdb3c8f..5d99a11 100644 --- a/src/jobs/widget_uninstall/task_uninstall_ospsvc.cpp +++ b/src/jobs/widget_uninstall/task_uninstall_ospsvc.cpp @@ -45,8 +45,7 @@ TaskUninstallOspsvc::TaskUninstallOspsvc(UninstallerContext& context) : } TaskUninstallOspsvc::~TaskUninstallOspsvc() -{ -} +{} void TaskUninstallOspsvc::StepUninstallOspsvc() { @@ -61,24 +60,25 @@ void TaskUninstallOspsvc::StepUninstallOspsvc() fd = popen(commStr.str().c_str(), "r"); if (NULL == fd) { LogError("Failed to uninstalltion osp service"); - ThrowMsg(Exceptions::UninstallOspSvcFailed, "Error occurs during\ + ThrowMsg(Exceptions::UninstallOspSvcFailed, + "Error occurs during\ uninstall osp service"); } - fgets( readBuf, MAX_BUF_SIZE, fd); + fgets(readBuf, MAX_BUF_SIZE, fd); LogDebug("return value : " << readBuf); int result = atoi(readBuf); if (0 != result) { - ThrowMsg(Exceptions::UninstallOspSvcFailed, "Error occurs during\ + ThrowMsg(Exceptions::UninstallOspSvcFailed, + "Error occurs during\ install osp service"); } pclose(fd); - + LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.tzPkgid); m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_REMOVE_OSPSVC, "Uninstall OSP service finished"); } - } //namespace WidgetUninstall } //namespace Jobs diff --git a/src/jobs/widget_uninstall/widget_uninstall_errors.h b/src/jobs/widget_uninstall/widget_uninstall_errors.h index f08d33d..81de95d 100644 --- a/src/jobs/widget_uninstall/widget_uninstall_errors.h +++ b/src/jobs/widget_uninstall/widget_uninstall_errors.h @@ -47,7 +47,6 @@ DECLARE_JOB_EXCEPTION(Base, AlreadyUninstalling, ErrorAlreadyUninstalling) DECLARE_JOB_EXCEPTION(Base, WidgetNotExist, ErrorWidgetDoesNotExist) DECLARE_JOB_EXCEPTION(Base, UninstallOspSvcFailed, ErrorUninstallOspSvcFailed) DECLARE_JOB_EXCEPTION(Base, PlatformAPIFailure, ErrorPlatformAPI) - } //namespace } //namespace } //namespace diff --git a/src/jobs/widget_uninstall/widget_uninstaller_struct.h b/src/jobs/widget_uninstall/widget_uninstaller_struct.h index ce2d4cc..83714a9 100644 --- a/src/jobs/widget_uninstall/widget_uninstaller_struct.h +++ b/src/jobs/widget_uninstall/widget_uninstaller_struct.h @@ -48,24 +48,23 @@ typedef Jobs::JobCallbacksBase WidgetUninstallCallbackBase; - struct WidgetUninstallationStruct : public WidgetUninstallCallbackBase { std::shared_ptr pkgmgrInterface; // It must be empty-constructible as a parameter of generic event WidgetUninstallationStruct() - { - } + {} - WidgetUninstallationStruct(UninstallerFinishedCallback finished, - UninstallerProgressCallback progress, - void *param, - std::shared_ptr _pkgmgrInterface - ) : + WidgetUninstallationStruct( + UninstallerFinishedCallback finished, + UninstallerProgressCallback progress, + void *param, + std::shared_ptr + _pkgmgrInterface + ) : WidgetUninstallCallbackBase(finished, progress, param), pkgmgrInterface(_pkgmgrInterface) - { - } + {} }; #endif // WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_ diff --git a/src/logic/installer_controller.cpp b/src/logic/installer_controller.cpp index 8995d33..5e65517 100644 --- a/src/logic/installer_controller.cpp +++ b/src/logic/installer_controller.cpp @@ -19,15 +19,12 @@ IMPLEMENT_SINGLETON(Logic::InstallerController) -namespace Logic -{ - +namespace Logic { InstallerController::InstallerController() -{ -} +{} void InstallerController::OnEventReceived( - const InstallerControllerEvents::InstallWidgetEvent &event) + const InstallerControllerEvents::InstallWidgetEvent &event) { std::string fileName = event.GetArg0(); WidgetInstallationStruct installerStruct = event.GetArg1(); @@ -35,7 +32,7 @@ void InstallerController::OnEventReceived( } void InstallerController::OnEventReceived( - const InstallerControllerEvents::InstallPluginEvent &event) + const InstallerControllerEvents::InstallPluginEvent &event) { std::string dirName = event.GetArg0(); PluginInstallerStruct installerStruct = event.GetArg1(); @@ -43,7 +40,7 @@ void InstallerController::OnEventReceived( } void InstallerController::OnEventReceived( - const InstallerControllerEvents::UninstallWidgetEvent &event) + const InstallerControllerEvents::UninstallWidgetEvent &event) { std::string widgetPkgName = event.GetArg0(); WidgetUninstallationStruct uninstallerStruct = event.GetArg1(); @@ -54,13 +51,13 @@ Eina_Bool InstallerController::AddNextStep(void *data) { Jobs::Job* model = static_cast(data); CONTROLLER_POST_EVENT(InstallerController, - InstallerControllerEvents::NextStepEvent(model)); + InstallerControllerEvents::NextStepEvent(model)); return ECORE_CALLBACK_CANCEL; } void InstallerController::OnEventReceived( - const InstallerControllerEvents::NextStepEvent &event) + const InstallerControllerEvents::NextStepEvent &event) { Jobs::Job* model = event.GetArg0(); Assert(model != NULL); @@ -71,24 +68,23 @@ void InstallerController::OnEventReceived( } void InstallerController::OnEventReceived( - const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent & - event) + const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent & + event) { (void)event; m_installerLogic.InstallDeferredWidgetPackages(); } void InstallerController::OnEventReceived( - const InstallerControllerEvents::InitializeEvent & /*event*/) + const InstallerControllerEvents::InitializeEvent & /*event*/) { m_installerLogic.Initialize(); } void InstallerController::OnEventReceived( - const InstallerControllerEvents::TerminateEvent & /*event*/) + const InstallerControllerEvents::TerminateEvent & /*event*/) { m_installerLogic.Terminate(); } - } //Logic diff --git a/src/logic/installer_controller.h b/src/logic/installer_controller.h index 55c68fe..ca4cc6b 100644 --- a/src/logic/installer_controller.h +++ b/src/logic/installer_controller.h @@ -38,8 +38,8 @@ namespace InstallerControllerEvents { * This event holds std::string witch should be path to widget package */ DECLARE_GENERIC_EVENT_2(InstallWidgetEvent, - std::string, - WidgetInstallationStruct) // (zipFileName, installerStruct) + std::string, // zipFileName + WidgetInstallationStruct) // installerStruct /** * @brief Event for iniciating plugin instalation process. @@ -67,12 +67,9 @@ DECLARE_GENERIC_EVENT_0(InstallDeferredWidgetPackagesEvent) DECLARE_GENERIC_EVENT_0(InitializeEvent) DECLARE_GENERIC_EVENT_0(TerminateEvent) - } // namespace InstallerEvents - namespace Logic { - /** * @brief Controls Widget installation * @@ -96,40 +93,41 @@ typedef DPL::TypeListDecl< InstallerControllerEvents::TerminateEvent>::Type InstallerControllerEventsSet; -class InstallerController : public DPL::Event::Controller +class InstallerController : public DPL::Event::Controller< + InstallerControllerEventsSet> { protected: /** * @brief Executed on InstallWidgetEvent received. */ virtual void OnEventReceived( - const InstallerControllerEvents::InstallWidgetEvent &event); + const InstallerControllerEvents::InstallWidgetEvent &event); /** * @brief Executed on InstallPluginEvent received. */ virtual void OnEventReceived( - const InstallerControllerEvents::InstallPluginEvent &event); + const InstallerControllerEvents::InstallPluginEvent &event); /** * @brief Executed on UninstallWidgetEvent received. */ virtual void OnEventReceived( - const InstallerControllerEvents::UninstallWidgetEvent &event); + const InstallerControllerEvents::UninstallWidgetEvent &event); /** * @brief Executed on NextStepEvent received. */ virtual void OnEventReceived( - const InstallerControllerEvents::NextStepEvent &event); + const InstallerControllerEvents::NextStepEvent &event); virtual void OnEventReceived( - const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent - &event); + const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent + &event); virtual void OnEventReceived( - const InstallerControllerEvents::InitializeEvent &event); + const InstallerControllerEvents::InitializeEvent &event); virtual void OnEventReceived( - const InstallerControllerEvents::TerminateEvent &event); + const InstallerControllerEvents::TerminateEvent &event); private: // Embedded logic @@ -143,7 +141,6 @@ class InstallerController : public DPL::Event::Controller InstallerControllerSingleton; - } #endif // INSTALLER_CONTROLLER_H diff --git a/src/logic/installer_logic.cpp b/src/logic/installer_logic.cpp index 2cd734e..f4b202e 100644 --- a/src/logic/installer_logic.cpp +++ b/src/logic/installer_logic.cpp @@ -28,11 +28,9 @@ using namespace WrtDB; namespace Logic { - InstallerLogic::InstallerLogic() : m_NextHandle(0) -{ -} +{} InstallerLogic::~InstallerLogic() { @@ -72,8 +70,10 @@ Jobs::JobHandle InstallerLogic::AddAndStartJob(Jobs::Job *job) //InstallWidget, UninstallWidget InstallPlugin method are almost the same // But each Job has different constructor, so creating new Job is specific -Jobs::JobHandle InstallerLogic::InstallWidget(const std::string & widgetPath, - const WidgetInstallationStruct &installerStruct) +Jobs::JobHandle InstallerLogic::InstallWidget( + const std::string & widgetPath, + const WidgetInstallationStruct & + installerStruct) { LogDebug("New Widget Installation:"); @@ -83,8 +83,10 @@ Jobs::JobHandle InstallerLogic::InstallWidget(const std::string & widgetPath, return AddAndStartJob(job); } -Jobs::JobHandle InstallerLogic::UninstallWidget(const std::string & widgetPkgName, - const WidgetUninstallationStruct &uninstallerStruct) +Jobs::JobHandle InstallerLogic::UninstallWidget( + const std::string & widgetPkgName, + const + WidgetUninstallationStruct &uninstallerStruct) { LogDebug("New Widget Uninstallation"); @@ -95,8 +97,10 @@ Jobs::JobHandle InstallerLogic::UninstallWidget(const std::string & widgetPkgNam return AddAndStartJob(job); } -Jobs::JobHandle InstallerLogic::InstallPlugin(std::string const & pluginPath, - const PluginInstallerStruct &installerStruct) +Jobs::JobHandle InstallerLogic::InstallPlugin( + std::string const & pluginPath, + const PluginInstallerStruct & + installerStruct) { LogDebug("New Plugin Installation"); @@ -148,8 +152,7 @@ bool InstallerLogic::NextStep(Jobs::Job *job) delete job; return false; - } - catch (Jobs::JobExceptionBase &exc) { + } catch (Jobs::JobExceptionBase &exc) { //start revert job LogInfo("Exception occured: " << exc.getParam() << ". Reverting job..."); @@ -176,7 +179,8 @@ void InstallerLogic::InstallDeferredWidgetPackages() LogWarning("Not implemented"); // LogInfo("Installing deferred widget packages..."); // - // WidgetPackageList packages = GlobalDAO::GetDefferedWidgetPackageInstallationList(); + // WidgetPackageList packages = + // GlobalDAO::GetDefferedWidgetPackageInstallationList(); // // LogInfo(packages.size() << " widget package(s) to install"); // @@ -206,8 +210,10 @@ void InstallerLogic::InstallSingleDeferredPackage() // // // Post installation // CONTROLLER_POST_EVENT( - // InstallerController, InstallerControllerEvents::InstallWidgetEvent( - // DPL::ToUTF8String(widgetPackage).c_str(), WidgetInstallationStruct( + // InstallerController, + // InstallerControllerEvents::InstallWidgetEvent( + // DPL::ToUTF8String(widgetPackage).c_str(), + // WidgetInstallationStruct( // &DummyInstallCallback, &DummyProgressCallback, NULL, // WidgetUpdateMode::PolicyWac))); } @@ -258,7 +264,8 @@ bool InstallerLogic::resolvePluginDependencies(PluginHandle handle) PluginDAO::getPluginHandleForImplementedObject(*requiredObject); if (depHandle == - Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE) { + Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE) + { LogError("Library implementing: " << *requiredObject << " NOT FOUND"); @@ -274,6 +281,5 @@ bool InstallerLogic::resolvePluginDependencies(PluginHandle handle) return true; } - } diff --git a/src/logic/installer_logic.h b/src/logic/installer_logic.h index 479313e..5072e39 100644 --- a/src/logic/installer_logic.h +++ b/src/logic/installer_logic.h @@ -25,7 +25,6 @@ #include namespace Logic { - class InstallerLogic { typedef std::map JobsContainer; @@ -44,6 +43,7 @@ class InstallerLogic return m_NextHandle++; } Jobs::JobHandle AddAndStartJob(Jobs::Job *job); + public: virtual ~InstallerLogic(); @@ -51,14 +51,18 @@ class InstallerLogic void Terminate(); - Jobs::JobHandle InstallWidget(const std::string & widgetPath, - const WidgetInstallationStruct &installerStruct); + Jobs::JobHandle InstallWidget( + const std::string & widgetPath, + const WidgetInstallationStruct & + installerStruct); - Jobs::JobHandle UninstallWidget(const std::string & widgetPkgName, - const WidgetUninstallationStruct &uninstallerStruct); + Jobs::JobHandle UninstallWidget( + const std::string & widgetPkgName, + const WidgetUninstallationStruct & + uninstallerStruct); Jobs::JobHandle InstallPlugin(std::string const & pluginPath, - const PluginInstallerStruct &installerStruct); + const PluginInstallerStruct &installerStruct); bool NextStep(Jobs::Job* installModel); @@ -74,7 +78,6 @@ class InstallerLogic friend class InstallerController; }; - } #endif // INSTALLER_LOGIC_H diff --git a/src/misc/feature_logic.cpp b/src/misc/feature_logic.cpp index 726f807..de4b99c 100644 --- a/src/misc/feature_logic.cpp +++ b/src/misc/feature_logic.cpp @@ -28,17 +28,16 @@ namespace Jobs { namespace WidgetInstall { - -FeatureLogic::FeatureLogic(const WrtDB::TizenAppId & tzAppid) - : m_rejected(false) +FeatureLogic::FeatureLogic(const WrtDB::TizenAppId & tzAppid) : + m_rejected(false) { WrtDB::WidgetDAOReadOnly widgetDao(tzAppid); WidgetFeatureSet featureSet = widgetDao.getFeaturesList(); FOREACH(it, featureSet) { LogInfo("Feature name : " << it->name); WrtDB::DeviceCapabilitySet dcs = - WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name); - FOREACH (devCap, dcs) { + WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name); + FOREACH(devCap, dcs) { LogInfo("--- dev cap : " << *devCap); } Feature feature(*it, dcs); @@ -60,7 +59,9 @@ bool FeatureLogic::isDone() const bool FeatureLogic::next() { while (!isDone()) { - if (m_currentFeature->currentCap != m_currentFeature->devCapSet.end()) { + if (m_currentFeature->currentCap != + m_currentFeature->devCapSet.end()) + { m_currentFeature->currentCap++; } else { ++m_currentFeature; @@ -73,7 +74,6 @@ bool FeatureLogic::next() return false; } - void FeatureLogic::setAceResponse(bool allowed) { Assert(isProcessable() && "Wrong usage"); @@ -102,7 +102,6 @@ bool FeatureLogic::isProcessable() const return true; } - } // namespace WidgetInstall } // namespace Jobs diff --git a/src/misc/feature_logic.h b/src/misc/feature_logic.h index 9faf46e..03bb51a 100644 --- a/src/misc/feature_logic.h +++ b/src/misc/feature_logic.h @@ -29,8 +29,8 @@ namespace Jobs { namespace WidgetInstall { - -class FeatureLogic : DPL::Noncopyable { +class FeatureLogic : DPL::Noncopyable +{ public: FeatureLogic(const WrtDB::TizenAppId & tzAppid); @@ -52,9 +52,10 @@ class FeatureLogic : DPL::Noncopyable { WrtDB::DeviceCapabilitySet devCapSet; WrtDB::DeviceCapabilitySet::const_iterator currentCap; - Feature(const WidgetFeature &wf, const WrtDB::DeviceCapabilitySet &set) - : WidgetFeature(wf) - , devCapSet(set) + Feature(const WidgetFeature &wf, + const WrtDB::DeviceCapabilitySet &set) : + WidgetFeature(wf) + , devCapSet(set) { currentCap = devCapSet.begin(); } @@ -65,8 +66,10 @@ class FeatureLogic : DPL::Noncopyable { currentCap = devCapSet.find(*second.currentCap); rejected = second.rejected; } + private: - void operator=(const Feature &second) { + void operator=(const Feature &second) + { name = second.name; devCapSet = second.devCapSet; required = second.required; @@ -80,8 +83,14 @@ class FeatureLogic : DPL::Noncopyable { typedef std::list FeatureList; typedef FeatureList::const_iterator FeatureIterator; - FeatureIterator resultBegin() { return m_featureList.begin(); } - FeatureIterator resultEnd() { return m_featureList.end(); } + FeatureIterator resultBegin() + { + return m_featureList.begin(); + } + FeatureIterator resultEnd() + { + return m_featureList.end(); + } private: bool isProcessable() const; @@ -92,7 +101,6 @@ class FeatureLogic : DPL::Noncopyable { }; typedef std::shared_ptr FeatureLogicPtr; - } // namespace WidgetInstall } // namespace Jobs diff --git a/src/misc/libxml_utils.cpp b/src/misc/libxml_utils.cpp index 61aa5cc..852ab9a 100644 --- a/src/misc/libxml_utils.cpp +++ b/src/misc/libxml_utils.cpp @@ -25,13 +25,11 @@ IMPLEMENT_SINGLETON(LibxmlUtils) LibxmlUtils::LibxmlUtils() : isInitialized(false) -{ -} +{} LibxmlUtils::~LibxmlUtils() { - if(isInitialized) - { + if (isInitialized) { LogDebug("Libxml - cleaning"); // Cleanup function for the XML library. xmlCleanupParser(); @@ -42,13 +40,11 @@ LibxmlUtils::~LibxmlUtils() void LibxmlUtils::init() { - if(!isInitialized) - { + if (!isInitialized) { LIBXML_TEST_VERSION - isInitialized = true; + isInitialized = true; LogDebug("Libxml have been initialized"); } LogDebug("Libxml already initialized"); } - diff --git a/src/misc/libxml_utils.h b/src/misc/libxml_utils.h index d662bc7..5354bda 100644 --- a/src/misc/libxml_utils.h +++ b/src/misc/libxml_utils.h @@ -39,7 +39,7 @@ */ class LibxmlUtils { -public: + public: DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) DECLARE_EXCEPTION_TYPE(Base, Libxml2Error) @@ -47,7 +47,8 @@ public: ~LibxmlUtils(); void init(); -private: + + private: bool isInitialized; friend class DPL::Singleton; diff --git a/src/misc/wac_widget_id.cpp b/src/misc/wac_widget_id.cpp index f6af03f..3fa621e 100644 --- a/src/misc/wac_widget_id.cpp +++ b/src/misc/wac_widget_id.cpp @@ -61,7 +61,7 @@ void WacWidgetId::parse(const char *url) LogDebug("Widget id to parse: " << url); std::unique_ptr > - iri(iri_parse(url), iri_destroy); + iri(iri_parse(url), iri_destroy); if (!iri.get()) { LogError("Error in parsing widget id."); @@ -78,7 +78,8 @@ void WacWidgetId::parse(const char *url) } // should we support HTTP and HTTPS? wac says nothing - // std::transform(m_scheme.begin(), m_scheme.end(), m_scheme.begin(), tolower); + // std::transform(m_scheme.begin(), m_scheme.end(), m_scheme.begin(), + // tolower); // We only match "http" and "https" schemas if ((scheme != SCHEME_HTTP) && (scheme != SCHEME_HTTPS)) { diff --git a/src/misc/widget_install_to_external.cpp b/src/misc/widget_install_to_external.cpp index 3751d60..4f794b6 100644 --- a/src/misc/widget_install_to_external.cpp +++ b/src/misc/widget_install_to_external.cpp @@ -28,12 +28,10 @@ IMPLEMENT_SAFE_SINGLETON(WidgetInstallToExt) WidgetInstallToExt::WidgetInstallToExt() : m_handle(NULL), m_appId("") -{ -} +{} WidgetInstallToExt::~WidgetInstallToExt() -{ -} +{} void WidgetInstallToExt::initialize(std::string appId) { @@ -50,8 +48,9 @@ void WidgetInstallToExt::deinitialize() { LogDebug("WidgetInstallToExt::deinitialize()"); if (NULL != m_handle) { - if ( 0 < app2ext_deinit(m_handle)) { - ThrowMsg(Exception::ErrorInstallToExt, "app2ext deinitialize \ + if (0 < app2ext_deinit(m_handle)) { + ThrowMsg(Exception::ErrorInstallToExt, + "app2ext deinitialize \ failed"); } } @@ -64,7 +63,7 @@ void WidgetInstallToExt::preInstallation(GList *dirList, int dSize) int ret = m_handle->interface.pre_install(m_appId.c_str(), dirList, dSize); - if (APP2EXT_SUCCESS == ret ) { + if (APP2EXT_SUCCESS == ret) { LogDebug("App2Ext pre install success"); } else { postInstallation(false); @@ -79,10 +78,10 @@ void WidgetInstallToExt::postInstallation(bool status) if (status) { m_handle->interface.post_install(m_appId.c_str(), - APP2EXT_STATUS_SUCCESS); + APP2EXT_STATUS_SUCCESS); } else { m_handle->interface.post_install(m_appId.c_str(), - APP2EXT_STATUS_FAILED); + APP2EXT_STATUS_FAILED); } } @@ -92,7 +91,7 @@ void WidgetInstallToExt::preUpgrade(GList *dirList, int dSize) Assert(m_handle); int ret = m_handle->interface.pre_upgrade(m_appId.c_str(), dirList, dSize); - if (APP2EXT_SUCCESS == ret ) { + if (APP2EXT_SUCCESS == ret) { LogDebug("App2Ext pre-upgrade success"); } else { postUpgrade(false); @@ -107,10 +106,10 @@ void WidgetInstallToExt::postUpgrade(bool status) if (status) { m_handle->interface.post_upgrade(m_appId.c_str(), - APP2EXT_STATUS_SUCCESS); + APP2EXT_STATUS_SUCCESS); } else { m_handle->interface.post_upgrade(m_appId.c_str(), - APP2EXT_STATUS_FAILED); + APP2EXT_STATUS_FAILED); } } @@ -121,9 +120,10 @@ void WidgetInstallToExt::uninstallation() Assert(m_handle); int ret = m_handle->interface.pre_uninstall(m_appId.c_str()); - if (APP2EXT_SUCCESS == ret ) { + if (APP2EXT_SUCCESS == ret) { if (APP2EXT_SUCCESS == - m_handle->interface.post_uninstall(m_appId.c_str())) { + m_handle->interface.post_uninstall(m_appId.c_str())) + { LogDebug("App2Ext pre-uninstall success"); } else { ThrowMsg(Exception::ErrorInstallToExt, "post-uninstall failed"); diff --git a/src/misc/widget_install_to_external.h b/src/misc/widget_install_to_external.h index 9f71906..732f70a 100644 --- a/src/misc/widget_install_to_external.h +++ b/src/misc/widget_install_to_external.h @@ -25,10 +25,9 @@ #include #include - class WidgetInstallToExt { -public: + public: class Exception { public: @@ -44,7 +43,7 @@ public: void postUpgrade(bool status); void uninstallation(); -private: + private: app2ext_handle *m_handle; std::string m_appId; diff --git a/src/misc/widget_location.cpp b/src/misc/widget_location.cpp index 80aa476..4bd69f1 100644 --- a/src/misc/widget_location.cpp +++ b/src/misc/widget_location.cpp @@ -28,7 +28,6 @@ #include - WidgetLocation::DirectoryDeletor::DirectoryDeletor() { m_dirpath = Jobs::WidgetInstall::createTempPath(); @@ -41,8 +40,9 @@ WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) WidgetLocation::DirectoryDeletor::~DirectoryDeletor() { - LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str()); - if(!WrtUtilRemove(m_dirpath)){ + LogDebug( + "Removing widget installation temporary directory: " << m_dirpath.c_str()); + if (!WrtUtilRemove(m_dirpath)) { LogError("Fail at removing directory: " << m_dirpath.c_str()); } } @@ -53,26 +53,23 @@ std::string WidgetLocation::DirectoryDeletor::getTempPath() const } WidgetLocation::WidgetLocation() -{ -} +{} WidgetLocation::WidgetLocation(const std::string & widgetname) : - m_pkgid(widgetname) -{ -} + m_pkgid(widgetname) +{} WidgetLocation::~WidgetLocation() -{ -} +{} WidgetLocation::WidgetLocation(const std::string & widgetname, std::string sourcePath, WrtDB::PackagingType t, - InstallLocationType locationType): - m_pkgid(widgetname), - m_widgetSource(sourcePath), - m_type(t), - m_temp(new WidgetLocation::DirectoryDeletor()) + InstallLocationType locationType) : + m_pkgid(widgetname), + m_widgetSource(sourcePath), + m_type(t), + m_temp(new WidgetLocation::DirectoryDeletor()) { if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) { m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath(); @@ -85,12 +82,12 @@ WidgetLocation::WidgetLocation(const std::string & widgetname, std::string sourcePath, std::string dirPath, WrtDB::PackagingType t, - InstallLocationType locationType): - m_pkgid(widgetname), - m_widgetSource(sourcePath), - m_type(t), - m_temp(new - WidgetLocation::DirectoryDeletor(dirPath)) + InstallLocationType locationType) : + m_pkgid(widgetname), + m_widgetSource(sourcePath), + m_type(t), + m_temp(new + WidgetLocation::DirectoryDeletor(dirPath)) { if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) { m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath(); @@ -113,13 +110,13 @@ std::string WidgetLocation::getPackageInstallationDir() const std::string WidgetLocation::getSourceDir() const { return m_installedPath + "/" - + m_pkgid + WrtDB::GlobalConfig::GetWidgetSrcPath(); + + m_pkgid + WrtDB::GlobalConfig::GetWidgetSrcPath(); } std::string WidgetLocation::getBinaryDir() const { return m_installedPath + "/" - + m_pkgid + WrtDB::GlobalConfig::GetUserWidgetExecPath(); + + m_pkgid + WrtDB::GlobalConfig::GetUserWidgetExecPath(); } std::string WidgetLocation::getExecFile() const @@ -150,13 +147,13 @@ std::string WidgetLocation::getBackupExecFile() const std::string WidgetLocation::getUserDataRootDir() const { return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) + - "/" + m_pkgid; + "/" + m_pkgid; } std::string WidgetLocation::getPrivateStorageDir() const { return getUserDataRootDir() + "/" + - WrtDB::GlobalConfig::GetWidgetPrivateStoragePath(); + WrtDB::GlobalConfig::GetWidgetPrivateStoragePath(); } std::string WidgetLocation::getTemporaryPackageDir() const @@ -169,33 +166,25 @@ std::string WidgetLocation::getTemporaryRootDir() const if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) { return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath(); } - if(m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP) - { + if (m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP) { return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath(); - } - else - { + } else { return getTemporaryPackageDir(); } } std::string WidgetLocation::getConfigurationDir() const { - if(m_type == WrtDB::PKG_TYPE_HOSTED_WEB_APP) - { + if (m_type == WrtDB::PKG_TYPE_HOSTED_WEB_APP) { std::string path = "."; int index = m_widgetSource.find_last_of("\\/"); - if (index != std::string::npos) - { + if (index != std::string::npos) { path = m_widgetSource.substr(0, index); } return path; - } - else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) - { + } else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) { return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath(); - } else - { + } else { return getTemporaryRootDir(); } } diff --git a/src/misc/widget_location.h b/src/misc/widget_location.h index 324d8e8..60028bf 100644 --- a/src/misc/widget_location.h +++ b/src/misc/widget_location.h @@ -45,28 +45,31 @@ * \___ [widgets_archive_content] * * 1) Normal Widget - * Developer provides content of res/wgt directory (package contains that directory as root). + * Developer provides content of res/wgt directory (package contains that + * directory as root). * * 2) For OSP Service Hybrid App is actually a bit different: * Root is OSP Service directory, WebApp content is located in [root]/res/wgt * * Temporary directory is directory when widget is placed at the begining - * of installation process. After parsing process of config.xml, destination directory is created. + * of installation process. After parsing process of config.xml, destination + * directory is created. */ class WidgetLocation { class DirectoryDeletor { - public: + public: DirectoryDeletor(); DirectoryDeletor(std::string tempPath); ~DirectoryDeletor(); std::string getTempPath() const; - private: + + private: std::string m_dirpath; }; -public: + public: DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath) /** @@ -76,7 +79,8 @@ public: */ WidgetLocation(); /** - * @brief WidgetLocation Builds paths for widget location during uninstallation + * @brief WidgetLocation Builds paths for widget location during + * uninstallation * * Uninstallation process needs only installed package directory. * @@ -84,7 +88,8 @@ public: */ WidgetLocation(const std::string & widgetname); /** - * @brief WidgetLocation Builds paths for widget location during installation + * @brief WidgetLocation Builds paths for widget location during + * installation * * @param widgetname name of widget * @param sourcePath given source path @@ -95,33 +100,34 @@ public: WidgetLocation(const std::string & widgetname, std::string sourcePath, WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP, InstallLocationType ltype = - INSTALL_LOCATION_TYPE_NOMAL); + INSTALL_LOCATION_TYPE_NOMAL); WidgetLocation(const std::string & widgetname, std::string sourcePath, std::string dirPath, WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP, InstallLocationType ltype = - INSTALL_LOCATION_TYPE_NOMAL); + INSTALL_LOCATION_TYPE_NOMAL); ~WidgetLocation(); // Installed paths - std::string getInstallationDir() const; // /opt/apps or /usr/apps - std::string getPackageInstallationDir() const; // /opt/apps/[package] - std::string getSourceDir() const; // /opt/apps/[package]/res/wgt - std::string getBinaryDir() const; // /opt/apps/[package]/bin - std::string getExecFile() const; // /opt/apps/[package]/bin/[package] - std::string getBackupDir() const; // /opt/apps/[package]/backup - std::string getBackupSourceDir() const; // /opt/apps/[package]/backup/res/wgt - std::string getBackupBinaryDir() const; // /opt/apps/[package]/backup/bin - std::string getBackupExecFile() const; // /opt/apps/[package]/backup/bin/[package] - std::string getUserDataRootDir() const; // /opt/usr/apps/[package] - std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data + std::string getInstallationDir() const; // /opt/apps or /usr/apps + std::string getPackageInstallationDir() const; // /opt/apps/[package] + std::string getSourceDir() const; // /opt/apps/[package]/res/wgt + std::string getBinaryDir() const; // /opt/apps/[package]/bin + std::string getExecFile() const; // /opt/apps/[package]/bin/[package] + std::string getBackupDir() const; // /opt/apps/[package]/backup + std::string getBackupSourceDir() const; // /opt/apps/[pkg]/backup/res/wgt + std::string getBackupBinaryDir() const; // /opt/apps/[pkg]/backup/bin + std::string getBackupExecFile() const; // /opt/apps/[pkg]/backup/bin/[pkg] + std::string getUserDataRootDir() const; // /opt/usr/apps/[package] + std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data // Temporary paths /** * @brief getTemporaryRootDir - * @return value of root for developer's provide package (root of unpacked .wgt file) + * @return value of root for developer's provide package (root of unpacked + * .wgt file) */ std::string getTemporaryPackageDir() const; /** @@ -129,14 +135,17 @@ public: * * Value of this will differs according to type of installed widget. * - * @return value of root for content in temporary directory to be copied into 'res/wgt' + * @return value of root for content in temporary directory to be copied + * into 'res/wgt' */ std::string getTemporaryRootDir() const; /** - * @brief getConfigurationDir Returns rott directory for configuration requirements + * @brief getConfigurationDir Returns rott directory for configuration + * requirements * * 1) For packed widgets it is just root of unpacked sources - * 2) For browser installation it is directory name of widget passed to installer + * 2) For browser installation it is directory name of widget passed to + * installer * * @return configuration directory */ @@ -144,7 +153,8 @@ public: //icons /** - * @brief setIconTargetFilenameForLocale set installed ion path according to locale + * @brief setIconTargetFilenameForLocale set installed ion path according to + * locale * @param icon path of application icon */ void setIconTargetFilenameForLocale(const std::string &icon); @@ -192,8 +202,9 @@ public: */ void registerAppid(const std::string & appid); -private: - std::string m_widgetSource; // Source widget zip file/widget url + private: + std::string m_widgetSource; // Source widget zip + // file/widget url std::string m_appid; //id of app std::string m_pkgid; //id of package std::string m_iconPath; //installed icon path diff --git a/src/pkg-manager/backendlib.cpp b/src/pkg-manager/backendlib.cpp index f843e8c..3eed3f9 100644 --- a/src/pkg-manager/backendlib.cpp +++ b/src/pkg-manager/backendlib.cpp @@ -43,7 +43,7 @@ using namespace WrtDB; #undef FALSE #define TRUE 0 #define FALSE -1 -#define GET_DIRECTORY_SIZE_KB(x) (x)/1024 +#define GET_DIRECTORY_SIZE_KB(x) (x) / 1024 #ifdef __cplusplus extern "C" @@ -53,11 +53,17 @@ extern "C" static void pkg_native_plugin_on_unload(); static int pkg_plugin_app_is_installed(const char *pkg_name); static int pkg_plugin_get_installed_apps_list(const char *category, - const char *option, package_manager_pkg_info_t **list, int *count); -static int pkg_plugin_get_app_detail_info(const char *pkg_name, - package_manager_pkg_detail_info_t *pkg_detail_info); -static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path, - package_manager_pkg_detail_info_t *pkg_detail_info); + const char *option, + package_manager_pkg_info_t **list, + int *count); +static int pkg_plugin_get_app_detail_info( + const char *pkg_name, + package_manager_pkg_detail_info_t * + pkg_detail_info); +static int pkg_plugin_get_app_detail_info_from_package( + const char *pkg_path, + package_manager_pkg_detail_info_t + *pkg_detail_info); static void pkg_native_plugin_on_unload() { @@ -71,7 +77,7 @@ static int pkg_plugin_app_is_installed(const char *pkg_name) WrtDB::WrtDatabase::attachToThreadRO(); bool result = WidgetDAOReadOnly::isWidgetInstalled( - DPL::FromUTF8String(pkg_name)); + DPL::FromUTF8String(pkg_name)); WrtDB::WrtDatabase::detachFromThread(); if (result) { @@ -82,14 +88,15 @@ static int pkg_plugin_app_is_installed(const char *pkg_name) } static int pkg_plugin_get_installed_apps_list(const char * /*category*/, - const char * /*option*/, package_manager_pkg_info_t **list, int *count) + const char * /*option*/, + package_manager_pkg_info_t **list, + int *count) { LogDebug("pkg_plugin_get_installed_apps_list() is called"); package_manager_pkg_info_t *pkg_list = NULL; package_manager_pkg_info_t *pkg_last = NULL; - WrtDB::WrtDatabase::attachToThreadRO(); TizenAppIdList tizenAppidList = WidgetDAOReadOnly::getTizenAppidList(); *count = 0; @@ -110,7 +117,7 @@ static int pkg_plugin_get_installed_apps_list(const char * /*category*/, WidgetDAOReadOnly widget(tzAppid); strncpy(pkg_info->pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX); snprintf(pkg_info->pkg_name, PKG_NAME_STRING_LEN_MAX, "%s", - DPL::ToUTF8String(tzAppid).c_str()); + DPL::ToUTF8String(tzAppid).c_str()); DPL::Optional version = widget.getVersion(); if (!version.IsNull()) { @@ -128,15 +135,16 @@ static int pkg_plugin_get_installed_apps_list(const char * /*category*/, return TRUE; } -static int pkg_plugin_get_app_detail_info(const char *pkg_name, - package_manager_pkg_detail_info_t *pkg_detail_info) +static int pkg_plugin_get_app_detail_info( + const char *pkg_name, + package_manager_pkg_detail_info_t * + pkg_detail_info) { LogDebug("pkg_plugin_get_app_detail_info() is called"); - WrtDB::WrtDatabase::attachToThreadRO(); int handle = WidgetDAOReadOnly::getHandle( - DPL::FromUTF8String(pkg_name)); + DPL::FromUTF8String(pkg_name)); WidgetDAOReadOnly widget(handle); DPL::Optional version = widget.getVersion(); @@ -149,7 +157,7 @@ static int pkg_plugin_get_app_detail_info(const char *pkg_name, PKG_VERSION_STRING_LEN_MAX - 1); } snprintf(pkg_detail_info->optional_id, PKG_NAME_STRING_LEN_MAX, "%d", - handle); + handle); WidgetLocalizedInfo localizedInfo; if (locale.IsNull()) { @@ -197,8 +205,8 @@ static int pkg_plugin_get_app_detail_info(const char *pkg_name, } static int pkg_plugin_get_app_detail_info_from_package( - const char * /*pkg_path*/, - package_manager_pkg_detail_info_t * /*pkg_detail_info*/) + const char * /*pkg_path*/, + package_manager_pkg_detail_info_t * /*pkg_detail_info*/) { LogDebug("pkg_plugin_get_app_detail_info_from_package() is called"); diff --git a/src/pkg-manager/pkgmgr_signal.cpp b/src/pkg-manager/pkgmgr_signal.cpp index 4b48b83..1732b27 100644 --- a/src/pkg-manager/pkgmgr_signal.cpp +++ b/src/pkg-manager/pkgmgr_signal.cpp @@ -23,44 +23,39 @@ #include #include - namespace PackageManager { - PkgmgrSignal::PkgmgrSignal() : m_initialized(false), m_handle(NULL), m_noPopup(false), m_reqType(PKGMGR_REQ_INVALID) -{ -} +{} PkgmgrSignal::~PkgmgrSignal() -{ -} +{} bool PkgmgrSignal::initialize(int argc, char* argv[]) { - if(m_handle) - { + if (m_handle) { LogInfo("Release already allocated pkgmgr handle"); pkgmgr_installer_free(m_handle); m_handle = NULL; } m_handle = pkgmgr_installer_new(); - if(!m_handle) { + if (!m_handle) { LogError("Fail to get pkgmgr installer handle"); return false; } // set information from pkgmgr if (!pkgmgr_installer_receive_request( - m_handle, argc, argv)) + m_handle, argc, argv)) { m_noPopup = pkgmgr_installer_is_quiet(m_handle); m_reqType = pkgmgr_installer_get_request_type(m_handle); if (m_reqType != PKGMGR_REQ_INSTALL && - m_reqType != PKGMGR_REQ_UNINSTALL) + m_reqType != PKGMGR_REQ_UNINSTALL) { LogError("Fail to get request type of pkgmgr"); pkgmgr_installer_free(m_handle); @@ -81,8 +76,7 @@ bool PkgmgrSignal::initialize(int argc, char* argv[]) bool PkgmgrSignal::deinitialize() { - if (!m_initialized) - { + if (!m_initialized) { LogError("PkgmgrSingal not yet intialized"); return false; } @@ -95,14 +89,12 @@ bool PkgmgrSignal::deinitialize() bool PkgmgrSignal::setPkgname(const std::string& name) { - if (!m_initialized) - { + if (!m_initialized) { LogError("PkgmgrSingal not yet intialized"); return false; } - if (name.empty()) - { + if (name.empty()) { LogError("name is empty"); return false; } @@ -113,30 +105,28 @@ bool PkgmgrSignal::setPkgname(const std::string& name) return true; } -bool PkgmgrSignal::sendSignal(const std::string& key, const std::string& value) const +bool PkgmgrSignal::sendSignal(const std::string& key, + const std::string& value) const { - if (!m_initialized) - { + if (!m_initialized) { LogError("PkgmgrSingal not yet intialized"); return false; } - if (key.empty() || value.empty()) - { + if (key.empty() || value.empty()) { LogDebug("key or value is empty"); return false; } - if (m_handle == NULL || m_type.empty() || m_pkgname.empty()) - { + if (m_handle == NULL || m_type.empty() || m_pkgname.empty()) { LogError("Some data of PkgmgrSignal is empty"); return false; } // send pkgmgr signal if (pkgmgr_installer_send_signal( - m_handle, m_type.c_str(), m_pkgname.c_str(), - key.c_str(), value.c_str())) + m_handle, m_type.c_str(), m_pkgname.c_str(), + key.c_str(), value.c_str())) { LogError("Fail to send pkgmgr signal"); return false; @@ -149,8 +139,7 @@ bool PkgmgrSignal::sendSignal(const std::string& key, const std::string& value) std::string PkgmgrSignal::getPkgname() const { - if (!m_initialized) - { + if (!m_initialized) { LogError("PkgmgrSingal not yet intialized"); } @@ -159,8 +148,7 @@ std::string PkgmgrSignal::getPkgname() const int PkgmgrSignal::getRequestedType() const { - if (!m_initialized) - { + if (!m_initialized) { LogError("PkgmgrSingal not yet intialized"); } @@ -169,8 +157,7 @@ int PkgmgrSignal::getRequestedType() const bool PkgmgrSignal::isNoPopupRequired() const { - if (!m_initialized) - { + if (!m_initialized) { LogError("PkgmgrSingal not yet intialized"); } diff --git a/src/pkg-manager/pkgmgr_signal.h b/src/pkg-manager/pkgmgr_signal.h index a939c50..734d77d 100644 --- a/src/pkg-manager/pkgmgr_signal.h +++ b/src/pkg-manager/pkgmgr_signal.h @@ -26,8 +26,7 @@ #include #include -namespace PackageManager{ - +namespace PackageManager { #define PKGMGR_WEBAPP_TYPE "wgt" #define PKGMGR_START_KEY "start" #define PKGMGR_START_INSTALL "install" @@ -39,27 +38,27 @@ namespace PackageManager{ typedef pkgmgr_installer* PkgmgrHandle; -class PkgmgrSignal: public IPkgmgrSignal +class PkgmgrSignal : public IPkgmgrSignal { - public: - bool initialize(int argc, char* argv[]); - bool deinitialize(); - bool setPkgname(const std::string& name); - bool sendSignal(const std::string& key, const std::string& value) const; - std::string getPkgname() const; - int getRequestedType() const; - bool isNoPopupRequired() const; + public: + bool initialize(int argc, char* argv[]); + bool deinitialize(); + bool setPkgname(const std::string& name); + bool sendSignal(const std::string& key, const std::string& value) const; + std::string getPkgname() const; + int getRequestedType() const; + bool isNoPopupRequired() const; - PkgmgrSignal(); - virtual ~PkgmgrSignal(); + PkgmgrSignal(); + virtual ~PkgmgrSignal(); - private: - bool m_initialized; - PkgmgrHandle m_handle; - std::string m_type; - std::string m_pkgname; - bool m_noPopup; - int m_reqType; + private: + bool m_initialized; + PkgmgrHandle m_handle; + std::string m_type; + std::string m_pkgname; + bool m_noPopup; + int m_reqType; }; } // PackageManager diff --git a/src/pkg-manager/pkgmgr_signal_dummy.h b/src/pkg-manager/pkgmgr_signal_dummy.h index f8862ee..34f5837 100644 --- a/src/pkg-manager/pkgmgr_signal_dummy.h +++ b/src/pkg-manager/pkgmgr_signal_dummy.h @@ -25,17 +25,14 @@ #include namespace PackageManager { - -class PkgmgrSignalDummy: public IPkgmgrSignal +class PkgmgrSignalDummy : public IPkgmgrSignal { -public: + public: PkgmgrSignalDummy() - { - } + {} virtual ~PkgmgrSignalDummy() - { - } + {} bool setPkgname(const std::string& name) { return false; @@ -51,7 +48,6 @@ public: return ""; } }; - } // PkgmgrSignalDummy #endif // WRT_PKGMGR_SIGNAL_DUMMY_H_ diff --git a/src/pkg-manager/pkgmgr_signal_interface.h b/src/pkg-manager/pkgmgr_signal_interface.h index 187efb5..1f3946d 100644 --- a/src/pkg-manager/pkgmgr_signal_interface.h +++ b/src/pkg-manager/pkgmgr_signal_interface.h @@ -24,16 +24,15 @@ #include namespace PackageManager { - class IPkgmgrSignal { -public: + public: virtual bool setPkgname(const std::string& name) = 0; - virtual bool sendSignal(const std::string& key, const std::string& value) const = 0; + virtual bool sendSignal(const std::string& key, + const std::string& value) const = 0; virtual std::string getPkgname() const = 0; - virtual ~IPkgmgrSignal(){}; + virtual ~IPkgmgrSignal(){} }; - } // IPkgmgrSignal #endif // WRT_PKGMGR_SIGNAL_INTERFACE_H_ diff --git a/src/wrt-installer/installer_callbacks_translate.cpp b/src/wrt-installer/installer_callbacks_translate.cpp index 8571d68..3a15224 100644 --- a/src/wrt-installer/installer_callbacks_translate.cpp +++ b/src/wrt-installer/installer_callbacks_translate.cpp @@ -58,8 +58,8 @@ WrtErrStatus TranslateError(CommonError::Type status) } void StatusCallback(std::string tizenId, - CommonError::Type result, - void *data) + CommonError::Type result, + void *data) { LogDebug("StatusCallback called " << tizenId << " | " << result); Assert(data != NULL); @@ -81,8 +81,8 @@ void StatusCallback(std::string tizenId, // callback for finished install void installFinishedCallback(void *userParam, - std::string tizenId, - Jobs::WidgetInstall::Exceptions::Type status) + std::string tizenId, + Jobs::WidgetInstall::Exceptions::Type status) { Assert(userParam != NULL); @@ -160,8 +160,8 @@ void installFinishedCallback(void *userParam, // callback for finished install void uninstallFinishedCallback(void *userParam, - std::string tizenId, - Jobs::WidgetUninstall::Exceptions::Type status) + std::string tizenId, + Jobs::WidgetUninstall::Exceptions::Type status) { Assert(userParam != NULL); @@ -210,7 +210,7 @@ void uninstallFinishedCallback(void *userParam, } void pluginInstallFinishedCallback(void *userParam, - Jobs::PluginInstall::Exceptions::Type status) + Jobs::PluginInstall::Exceptions::Type status) { Assert(userParam); @@ -255,8 +255,8 @@ void pluginInstallFinishedCallback(void *userParam, // callback for progress of install OR uninstall void installProgressCallback(void *userParam, - ProgressPercent percent, - const ProgressDescription &description) + ProgressPercent percent, + const ProgressDescription &description) { Assert(userParam != NULL); @@ -273,6 +273,5 @@ void installProgressCallback(void *userParam, LogInfo("installProgressCallback: ignoring NULL callback pointer"); } } - } //namespace diff --git a/src/wrt-installer/installer_callbacks_translate.h b/src/wrt-installer/installer_callbacks_translate.h index c32d253..9b3eb52 100644 --- a/src/wrt-installer/installer_callbacks_translate.h +++ b/src/wrt-installer/installer_callbacks_translate.h @@ -38,13 +38,12 @@ struct StatusCallbackStruct WrtProgressCallback progress_callback; StatusCallbackStruct(void* u, - WrtInstallerStatusCallback s, - WrtProgressCallback p) : + WrtInstallerStatusCallback s, + WrtProgressCallback p) : userdata(u), status_callback(s), progress_callback(p) - { - } + {} }; struct PluginStatusCallbackStruct @@ -54,35 +53,33 @@ struct PluginStatusCallbackStruct WrtProgressCallback progressCallback; PluginStatusCallbackStruct(void* u, - WrtPluginInstallerStatusCallback s, - WrtProgressCallback p) : + WrtPluginInstallerStatusCallback s, + WrtProgressCallback p) : userdata(u), statusCallback(s), progressCallback(p) - { - } + {} }; void StatusCallback(std::string tizenId, - CommonError::Type result, - void *data); + CommonError::Type result, + void *data); void installFinishedCallback(void *userParam, - std::string tizenId, - Jobs::WidgetInstall::Exceptions::Type status); + std::string tizenId, + Jobs::WidgetInstall::Exceptions::Type status); void uninstallFinishedCallback(void *userParam, - std::string tizenId, - Jobs::WidgetUninstall::Exceptions::Type status); + std::string tizenId, + Jobs::WidgetUninstall::Exceptions::Type status); void pluginInstallFinishedCallback(void *userParam, - Jobs::PluginInstall::Exceptions::Type status); + Jobs::PluginInstall::Exceptions::Type status); // callback for progress of install OR uninstall void installProgressCallback(void *userParam, - ProgressPercent percent, - const ProgressDescription &description); - + ProgressPercent percent, + const ProgressDescription &description); } //namespace #endif /* WRT_SRC_API_API_CALLBACKS_TRANSLATE_H_ */ diff --git a/src/wrt-installer/installer_main_thread.cpp b/src/wrt-installer/installer_main_thread.cpp old mode 100755 new mode 100644 index c5d677b..b398d3c --- a/src/wrt-installer/installer_main_thread.cpp +++ b/src/wrt-installer/installer_main_thread.cpp @@ -32,10 +32,10 @@ IMPLEMENT_SINGLETON(InstallerMainThread) using namespace WrtDB; -InstallerMainThread::InstallerMainThread() : m_attached(false) { -} +InstallerMainThread::InstallerMainThread() : m_attached(false) {} -InstallerMainThread::~InstallerMainThread() { +InstallerMainThread::~InstallerMainThread() +{ Assert(!m_attached); } diff --git a/src/wrt-installer/installer_main_thread.h b/src/wrt-installer/installer_main_thread.h old mode 100755 new mode 100644 index 67c1937..bd70b16 --- a/src/wrt-installer/installer_main_thread.h +++ b/src/wrt-installer/installer_main_thread.h @@ -24,7 +24,8 @@ #include -class InstallerMainThread { +class InstallerMainThread +{ public: void AttachDatabases(); void DetachDatabases(); diff --git a/src/wrt-installer/language_subtag_rst_tree.cpp b/src/wrt-installer/language_subtag_rst_tree.cpp index 119d5c6..8bf901f 100644 --- a/src/wrt-installer/language_subtag_rst_tree.cpp +++ b/src/wrt-installer/language_subtag_rst_tree.cpp @@ -43,7 +43,9 @@ bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input) if (token == parts.end()) { return false; } - if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_LANGUAGE)) { + if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, + RECORD_TYPE_LANGUAGE)) + { ++token; } else { return false; @@ -93,7 +95,8 @@ bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input) bool one_or_more = false; while (token != parts.end() && token->size() > 1 && - token->size() <= 8) { + token->size() <= 8) + { one_or_more = true; ++token; } @@ -111,7 +114,8 @@ bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input) bool one_or_more = false; while (token != parts.end() && !token->empty() && - token->size() <= 8) { + token->size() <= 8) + { one_or_more = true; ++token; } @@ -131,7 +135,8 @@ bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input) bool one_or_more = false; while (token != parts.end() && !token->empty() && - token->size() <= 8) { + token->size() <= 8) + { one_or_more = true; ++token; } @@ -143,28 +148,28 @@ bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input) } #define TEST_LANG(str, cond) \ - if (LanguageSubtagRstTreeSingleton::Instance().\ - ValidateLanguageTag(str) == cond) {\ - LogDebug("Good validate status for lang: " << str);\ - } else {\ - LogError("Wrong validate status for lang: " << str\ - << ", should be " << cond);\ + if (LanguageSubtagRstTreeSingleton::Instance(). \ + ValidateLanguageTag(str) == cond) { \ + LogDebug("Good validate status for lang: " << str); \ + } else { \ + LogError("Wrong validate status for lang: " << str \ + << ", should be " << cond); \ } void LanguageSubtagRstTree::Initialize() { /* Temporarily added unit test. Commented out due to performance drop. - TEST_LANG("zh", true); - TEST_LANG("esx-al", true); - TEST_LANG("zh-Hant", true); - TEST_LANG("zh-Hant-CN", true); - TEST_LANG("zh-Hant-CN-x-private1-private2", true); - TEST_LANG("plxxx", false); - TEST_LANG("pl-x-private111", false); - TEST_LANG("x-private1", false); //do not support pure private ones - TEST_LANG("x-private22", false); - TEST_LANG("i-private22", false); //do not support i-* - */ + * TEST_LANG("zh", true); + * TEST_LANG("esx-al", true); + * TEST_LANG("zh-Hant", true); + * TEST_LANG("zh-Hant-CN", true); + * TEST_LANG("zh-Hant-CN-x-private1-private2", true); + * TEST_LANG("plxxx", false); + * TEST_LANG("pl-x-private111", false); + * TEST_LANG("x-private1", false); //do not support pure private ones + * TEST_LANG("x-private22", false); + * TEST_LANG("i-private22", false); //do not support i-* + */ } #undef TEST_LANG diff --git a/src/wrt-installer/option_parser.cpp b/src/wrt-installer/option_parser.cpp index 334fbb4..982d86f 100644 --- a/src/wrt-installer/option_parser.cpp +++ b/src/wrt-installer/option_parser.cpp @@ -34,15 +34,13 @@ DPL::OptionalString OptionParser::QueryOption(int argc, auto it = std::find_if(args.begin(), args.end(), - [&name](const std::string& option){ - return (option == name); + [&name](const std::string & option){ + return (option == name); }); - if (it != args.end()) - { + if (it != args.end()) { std::string value; - while ((++it != args.end()) && !IsOption(*it)) - { + while ((++it != args.end()) && !IsOption(*it)) { value += *it + " "; } result = DPL::FromUTF8String(value); diff --git a/src/wrt-installer/option_parser.h b/src/wrt-installer/option_parser.h index 599bc59..7fa8c3a 100644 --- a/src/wrt-installer/option_parser.h +++ b/src/wrt-installer/option_parser.h @@ -27,12 +27,12 @@ class OptionParser { -public: + public: static DPL::OptionalString QueryOption(int argc, char* argv[], - const std::string& name); + const std::string & name); -private: + private: static bool IsOption(const std::string& name); }; diff --git a/src/wrt-installer/plugin_utils.cpp b/src/wrt-installer/plugin_utils.cpp index 2b6bc3c..3b25cb6 100644 --- a/src/wrt-installer/plugin_utils.cpp +++ b/src/wrt-installer/plugin_utils.cpp @@ -40,10 +40,9 @@ bool lockPluginInstallation() LogInfo("Try to lock for plugins installation."); s_plugin_install_lock_fd = - open(PLUGIN_INSTALL_LOCK_FILE, O_RDONLY|O_CREAT, 0666); + open(PLUGIN_INSTALL_LOCK_FILE, O_RDONLY | O_CREAT, 0666); - if (s_plugin_install_lock_fd == -1) - { + if (s_plugin_install_lock_fd == -1) { LogError("Lock file open failed!"); return false; @@ -51,8 +50,7 @@ bool lockPluginInstallation() ret = flock(s_plugin_install_lock_fd, LOCK_EX); //lock with waiting - if (ret == -1) - { + if (ret == -1) { LogError("Lock failed!"); close(s_plugin_install_lock_fd); @@ -68,14 +66,12 @@ bool unlockPluginInstallation() { LogInfo("Unlock for plugins installation."); - if (s_plugin_install_lock_fd != -1) - { + if (s_plugin_install_lock_fd != -1) { int ret = 0; ret = flock(s_plugin_install_lock_fd, LOCK_UN); //unlock - if (ret == -1) - { + if (ret == -1) { LogError("Unlock failed!"); } @@ -83,9 +79,7 @@ bool unlockPluginInstallation() s_plugin_install_lock_fd = -1; return true; - } - else - { + } else { LogError("Lock file was not created!"); } @@ -101,11 +95,11 @@ bool checkPluginInstallationRequired() checkFile(installRequest); switch (installationRequest) { - case FileState::FILE_EXISTS: - return true; - case FileState::FILE_NOT_EXISTS: - return false; - default: + case FileState::FILE_EXISTS: + return true; + case FileState::FILE_NOT_EXISTS: + return false; + default: LogWarning("Opening installation request file failed"); return false; } diff --git a/src/wrt-installer/plugin_utils.h b/src/wrt-installer/plugin_utils.h old mode 100755 new mode 100644 index 659e627..7b58e56 --- a/src/wrt-installer/plugin_utils.h +++ b/src/wrt-installer/plugin_utils.h @@ -43,6 +43,5 @@ bool checkPluginInstallationRequired(); bool removeInstallationRequiredFlag(); FileState::Type checkFile(const std::string& filename); bool removeFile(const std::string& filename); - } #endif // PLUGIN_UTILS_H diff --git a/src/wrt-installer/wrt_installer.cpp b/src/wrt-installer/wrt_installer.cpp index 92bf7f2..2a558a3 100644 --- a/src/wrt-installer/wrt_installer.cpp +++ b/src/wrt-installer/wrt_installer.cpp @@ -50,8 +50,6 @@ #include #include - - #define NOFILE_CNT_FOR_INSTALLER 9999 using namespace WrtDB; @@ -68,7 +66,10 @@ const char * const CONFIG_XML = "config.xml"; struct free_deleter { - void operator()(void* x) { free(x); } + void operator()(void* x) + { + free(x); + } }; struct PluginInstallerData @@ -124,11 +125,12 @@ void WrtInstaller::OnCreate() std::string arg = m_argv[0]; - pkgmgrSignalInterface = std::static_pointer_cast( - std::shared_ptr( - new PackageManager::PkgmgrSignalDummy() - ) - ); + pkgmgrSignalInterface = + std::static_pointer_cast( + std::shared_ptr( + new PackageManager::PkgmgrSignalDummy() + ) + ); if (arg.empty()) { return showHelpAndQuit(); @@ -136,8 +138,7 @@ void WrtInstaller::OnCreate() installNewPlugins(); - if (arg.find("wrt-installer") != std::string::npos) - { + if (arg.find("wrt-installer") != std::string::npos) { if (m_argc <= 1) { return showHelpAndQuit(); } @@ -168,9 +169,7 @@ void WrtInstaller::OnCreate() if (-1 != stat(m_argv[2], &info) && S_ISDIR(info.st_mode)) { LogInfo("Installing package directly from directory"); m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL; - } - else - { + } else { LogInfo("Installing from regular location"); m_installPolicy = WRT_WIM_POLICY_WAC; } @@ -214,50 +213,49 @@ void WrtInstaller::OnCreate() } else { return showHelpAndQuit(); } - } else if (arg.find("backend") != std::string::npos) { using namespace PackageManager; m_installByPkgmgr = true; - auto pkgmgrSignal = std::shared_ptr( - new PackageManager::PkgmgrSignal() - ); + auto pkgmgrSignal = std::shared_ptr( + new PackageManager::PkgmgrSignal() + ); pkgmgrSignal->initialize(m_argc, m_argv); m_quiet = pkgmgrSignal->isNoPopupRequired(); - LogDebug("backend m_quiet"<getRequestedType(); pkgmgrSignalInterface = - std::static_pointer_cast(pkgmgrSignal); + std::static_pointer_cast( + pkgmgrSignal); switch (reqType) { - case PKGMGR_REQ_INSTALL: - m_packagePath = m_argv[4]; - struct stat info; - if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) { - LogInfo("Installing package directly from directory"); - m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL; - } - else - { - LogInfo("Installing from regular location"); - m_installPolicy = WRT_WIM_POLICY_WAC; - } - AddStep(&WrtInstaller::installStep); - break; - case PKGMGR_REQ_UNINSTALL: - m_name = m_argv[4]; - AddStep(&WrtInstaller::uninstallPkgNameStep); - break; - default: - LogDebug("Not available type"); - break; + case PKGMGR_REQ_INSTALL: + m_packagePath = m_argv[4]; + struct stat info; + if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) { + LogInfo("Installing package directly from directory"); + m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL; + } else { + LogInfo("Installing from regular location"); + m_installPolicy = WRT_WIM_POLICY_WAC; + } + AddStep(&WrtInstaller::installStep); + break; + case PKGMGR_REQ_UNINSTALL: + m_name = m_argv[4]; + AddStep(&WrtInstaller::uninstallPkgNameStep); + break; + default: + LogDebug("Not available type"); + break; } } AddStep(&WrtInstaller::shutdownStep); - DPL::Event::ControllerEventHandler::PostEvent( + DPL::Event::ControllerEventHandler:: + PostEvent( WRTInstallerNS::NextStepEvent()); } @@ -324,7 +322,8 @@ void WrtInstaller::OnEventReceived(const WRTInstallerNS::QuitEvent& /*event*/) if (m_initialized) { LogDebug("Wrt Shutdown now"); SwitchToStep(&WrtInstaller::shutdownStep); - DPL::Event::ControllerEventHandler::PostEvent( + DPL::Event::ControllerEventHandler:: + PostEvent( WRTInstallerNS::NextStepEvent()); } else { LogDebug("Quiting application"); @@ -350,9 +349,9 @@ void WrtInstaller::OnEventReceived( (*m_pluginsPaths).pop_front(); wrt_install_plugin(privateData->pluginPath.c_str(), - static_cast(privateData), - &staticWrtPluginInstallationCallback, - &staticWrtPluginInstallProgressCb); + static_cast(privateData), + &staticWrtPluginInstallationCallback, + &staticWrtPluginInstallProgressCb); } else { delete privateData; } @@ -367,7 +366,7 @@ void WrtInstaller::installStep() { LogDebug("Installing widget ..."); std::unique_ptr packagePath(canonicalize_file_name( - m_packagePath.c_str())); + m_packagePath.c_str())); wrt_install_widget(packagePath ? packagePath.get() : m_packagePath.c_str(), this, &staticWrtStatusCallback, @@ -382,15 +381,15 @@ void WrtInstaller::installStep() void WrtInstaller::installPluginsStep() { LogDebug("Installing plugins ..."); - fprintf(stderr,"Installing plugins ...\n"); + fprintf(stderr, "Installing plugins ...\n"); if (m_startupPluginInstallation) { LogInfo("Plugin installation started because new plugin package found"); } else if (!PluginUtils::lockPluginInstallation()) { LogError("Failed to open plugin installation lock file" - " Plugins are currently installed by other process"); + " Plugins are currently installed by other process"); staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK, - this); + this); return; } @@ -448,7 +447,7 @@ void WrtInstaller::installPluginsStep() if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { LogError("Failed to close dir: " << PLUGIN_PATH << " with error: " - << DPL::GetErrnoString()); + << DPL::GetErrnoString()); } } @@ -457,9 +456,9 @@ void WrtInstaller::uninstallPkgNameStep() LogDebug("Uninstalling widget ..."); LogDebug("Package name : " << m_name); wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback, - (!m_quiet || m_installByPkgmgr) - ? &staticWrtUninstallProgressCallback : NULL, - pkgmgrSignalInterface); + (!m_quiet || m_installByPkgmgr) + ? &staticWrtUninstallProgressCallback : NULL, + pkgmgrSignalInterface); } void WrtInstaller::uninstallGuidStep() @@ -469,14 +468,17 @@ void WrtInstaller::uninstallGuidStep() WrtErrStatus status = wrt_get_widget_by_guid(appid, m_name); if (status == WRT_SUCCESS) { LogDebug("Guid : " << m_name); - wrt_uninstall_widget(appid.c_str(), this, &staticWrtStatusCallback, - !m_quiet ? &staticWrtUninstallProgressCallback : NULL, - pkgmgrSignalInterface); + wrt_uninstall_widget( + appid.c_str(), this, &staticWrtStatusCallback, + !m_quiet ? &staticWrtUninstallProgressCallback : + NULL, + pkgmgrSignalInterface); } else { printf("failed: can not uninstall widget\n"); LogError("Fail to uninstalling widget... "); m_returnStatus = -1; - DPL::Event::ControllerEventHandler::PostEvent( + DPL::Event::ControllerEventHandler:: + PostEvent( WRTInstallerNS::QuitEvent()); } } @@ -492,11 +494,11 @@ void WrtInstaller::unistallWgtFileStep() // Open zip file std::unique_ptr zipFile( - new DPL::ZipInput(m_packagePath)); + new DPL::ZipInput(m_packagePath)); // Open config.xml file std::unique_ptr configFile( - zipFile->OpenFile(CONFIG_XML)); + zipFile->OpenFile(CONFIG_XML)); // Extract config DPL::BinaryQueue buffer; @@ -504,10 +506,10 @@ void WrtInstaller::unistallWgtFileStep() DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer); DPL::Copy(&inputAdapter, &outputAdapter); parser.Parse(&buffer, - ElementParserPtr( - new RootParser(configInfo, - DPL::FromUTF32String( - L"widget")))); + ElementParserPtr( + new RootParser(configInfo, + DPL::FromUTF32String( + L"widget")))); DPL::OptionalString widgetGUID = configInfo.widget_id; @@ -517,14 +519,17 @@ void WrtInstaller::unistallWgtFileStep() WrtErrStatus status = wrt_get_widget_by_guid(appid, guid); if (status == WRT_SUCCESS) { LogDebug("Appid from packagePath : " << appid); - wrt_uninstall_widget(appid.c_str(), this, &staticWrtStatusCallback, - !m_quiet ? &staticWrtUninstallProgressCallback : NULL, - pkgmgrSignalInterface); + wrt_uninstall_widget( + appid.c_str(), this, &staticWrtStatusCallback, + !m_quiet ? &staticWrtUninstallProgressCallback + : NULL, + pkgmgrSignalInterface); } else { LogError("Fail to uninstalling widget... "); m_returnStatus = -1; - DPL::Event::ControllerEventHandler::PostEvent( - WRTInstallerNS::QuitEvent()); + DPL::Event::ControllerEventHandler:: + PostEvent( + WRTInstallerNS::QuitEvent()); } } Catch(DPL::ZipInput::Exception::OpenFailed) @@ -532,24 +537,27 @@ void WrtInstaller::unistallWgtFileStep() LogError("Failed to open widget package"); printf("failed: widget package does not exist\n"); m_returnStatus = -1; - DPL::Event::ControllerEventHandler::PostEvent( - WRTInstallerNS::QuitEvent()); + DPL::Event::ControllerEventHandler:: + PostEvent( + WRTInstallerNS::QuitEvent()); } Catch(DPL::ZipInput::Exception::OpenFileFailed) { printf("failed: widget config file does not exist\n"); LogError("Failed to open config.xml file"); m_returnStatus = -1; - DPL::Event::ControllerEventHandler::PostEvent( - WRTInstallerNS::QuitEvent()); + DPL::Event::ControllerEventHandler:: + PostEvent( + WRTInstallerNS::QuitEvent()); } Catch(ElementParser::Exception::ParseError) { printf("failed: can not parse config file\n"); LogError("Failed to parse config.xml file"); m_returnStatus = -1; - DPL::Event::ControllerEventHandler::PostEvent( - WRTInstallerNS::QuitEvent()); + DPL::Event::ControllerEventHandler:: + PostEvent( + WRTInstallerNS::QuitEvent()); } } @@ -559,13 +567,14 @@ void WrtInstaller::shutdownStep() if (m_initialized) { wrt_installer_shutdown(); m_initialized = false; - DPL::Event::ControllerEventHandler::PostEvent( + DPL::Event::ControllerEventHandler:: + PostEvent( WRTInstallerNS::QuitEvent()); } } void WrtInstaller::staticWrtInitCallback(WrtErrStatus status, - void* userdata) + void* userdata) { WrtInstaller *This = static_cast(userdata); Assert(This); @@ -585,7 +594,8 @@ void WrtInstaller::staticWrtInitCallback(WrtErrStatus status, } else { LogError("Init unsuccesfull"); This->m_returnStatus = -1; - This->DPL::Event::ControllerEventHandler::PostEvent( + This->DPL::Event::ControllerEventHandler:: + PostEvent( WRTInstallerNS::QuitEvent()); } } @@ -601,13 +611,12 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId, DPL::String resultMsg; std::string printMsg; - if (current == &WrtInstaller::installStep) - { + if (current == &WrtInstaller::installStep) { resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG); printMsg = "installation"; } else if (current == &WrtInstaller::uninstallPkgNameStep || - current == &WrtInstaller::uninstallGuidStep || - current == &WrtInstaller::unistallWgtFileStep) + current == &WrtInstaller::uninstallGuidStep || + current == &WrtInstaller::unistallWgtFileStep) { resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG); printMsg = "uninstallation"; @@ -619,7 +628,7 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId, This->m_returnStatus = -1; if (This->popupsEnabled()) { - resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE); + resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE); This->m_popup->showPopup(This, resultMsg, failResultCallback); } else { This->DPL::Event::ControllerEventHandler @@ -627,89 +636,123 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId, } switch (status) { - case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - invalid widget package\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST: - fprintf(stderr, "## wrt-installer : %s %s has failed - widget package does not exist\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING: - fprintf(stderr, "## wrt-installer : %s %s has failed - already uninstalling\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE: - fprintf(stderr,"## wrt-installer : %s %s has failed - out of disk space\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE: - fprintf(stderr,"## wrt-installer : %s %s has failed - invalid certificate\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_ALREADY_INSTALLED: - fprintf(stderr,"## wrt-installer : %s %s has failed - already installed\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_INTERNAL: - fprintf(stderr,"## wrt-installer : %s %s has failed - internal error\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_NOT_ALLOWED: - fprintf(stderr,"## wrt-installer : %s %s has failed - installation or update not allowed; invalid" - " mode\n", tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_DEFERRED: - fprintf(stderr,"## wrt-installer : deferred: widget update will continue after the widget" - " has been stopped\n"); - break; - - case WRT_INSTALLER_ERROR_DATABASE_FAILURE: - fprintf(stderr,"## wrt-installer : %s %s has failed - database failure\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_OSPSVC: - fprintf(stderr,"## wrt-installer : %s %s has failed - during installation or" - " uninstallation osp service\n", tizenId.c_str(), - printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_UNKNOWN: - fprintf(stderr,"## wrt-installer : %s %s has failed - unknown error\n", - tizenId.c_str(), printMsg.c_str()); - break; - - default: - break; - + case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE: + This->m_returnStatus = 1; //this status is specific + fprintf( + stderr, + "## wrt-installer : %s %s has failed - invalid widget package\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST: + fprintf( + stderr, + "## wrt-installer : %s %s has failed - widget package does not exist\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING: + fprintf( + stderr, + "## wrt-installer : %s %s has failed - already uninstalling\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE: + fprintf(stderr, + "## wrt-installer : %s %s has failed - out of disk space\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE: + fprintf( + stderr, + "## wrt-installer : %s %s has failed - invalid certificate\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_ALREADY_INSTALLED: + fprintf(stderr, + "## wrt-installer : %s %s has failed - already installed\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_INTERNAL: + fprintf(stderr, + "## wrt-installer : %s %s has failed - internal error\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_NOT_ALLOWED: + fprintf( + stderr, + "## wrt-installer : %s %s has failed - installation or update not allowed; invalid" + " mode\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_DEFERRED: + fprintf( + stderr, + "## wrt-installer : deferred: widget update will continue after the widget" + " has been stopped\n"); + break; + + case WRT_INSTALLER_ERROR_DATABASE_FAILURE: + fprintf(stderr, + "## wrt-installer : %s %s has failed - database failure\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_OSPSVC: + fprintf( + stderr, + "## wrt-installer : %s %s has failed - during installation or" + " uninstallation osp service\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_UNKNOWN: + fprintf(stderr, + "## wrt-installer : %s %s has failed - unknown error\n", + tizenId.c_str(), + printMsg.c_str()); + break; + + default: + break; } } else { - fprintf(stderr, "## wrt-installer : %s %s was successful.\n", tizenId.c_str(), printMsg.c_str()); + fprintf(stderr, + "## wrt-installer : %s %s was successful.\n", + tizenId.c_str(), + printMsg.c_str()); LogDebug("Status succesfull"); This->m_returnStatus = 0; - resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS); + resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS); if (This->popupsEnabled()) { This->m_popup->showPopup(This, resultMsg, showResultCallback); } else { - This->DPL::Event::ControllerEventHandler + This->DPL::Event::ControllerEventHandler ::PostEvent(WRTInstallerNS::NextStepEvent()); } } } void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status, - void* userdata) + void* userdata) { Assert(userdata); @@ -725,7 +768,7 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status, if (This->m_numPluginsToInstall < 1) { LogDebug("All plugins installation completed"); - fprintf(stderr,"All plugins installation completed.\n"); + fprintf(stderr, "All plugins installation completed.\n"); //remove installation request if (!PluginUtils::removeInstallationRequiredFlag()) { @@ -748,18 +791,23 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status, } else { if (This->popupsEnabled()) { This->m_popup->init(); - float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins; + float percent = + (This->m_totalPlugins - + This->m_numPluginsToInstall) / (float)This->m_totalPlugins; elm_progressbar_value_set(This->m_popup->m_progressbar, percent); evas_object_show(This->m_popup->m_popup); } - This->DPL::Event::ControllerEventHandler::PostEvent( - WRTInstallerNS::InstallPluginEvent()); + This->DPL::Event::ControllerEventHandler:: + PostEvent( + WRTInstallerNS::InstallPluginEvent()); } if (WRT_SUCCESS == status) { This->m_returnStatus = 0; - fprintf(stderr, "## wrt-installer : plugin installation successfull [%s]\n", + fprintf(stderr, + "## wrt-installer : plugin installation successfull [%s]\n", path.c_str()); LogDebug("One plugin Installation succesfull: " << path); return; @@ -814,7 +862,8 @@ void WrtInstaller::staticWrtPluginInstallProgressCb(float percent, } void WrtInstaller::staticWrtInstallProgressCallback(float percent, - const char* description, void* userdata) + const char* description, + void* userdata) { WrtInstaller *This = static_cast(userdata); std::stringstream percentStr; @@ -823,12 +872,13 @@ void WrtInstaller::staticWrtInstallProgressCallback(float percent, if (This->popupsEnabled()) { This->m_popup->init(); - elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0); + elm_progressbar_value_set(This->m_popup->m_progressbar, percent / 100.0); evas_object_show(This->m_popup->m_popup); } } void WrtInstaller::staticWrtUninstallProgressCallback(float percent, - const char* description, void* userdata) + const char* description, + void* userdata) { WrtInstaller *This = static_cast(userdata); std::stringstream percentStr; @@ -837,7 +887,7 @@ void WrtInstaller::staticWrtUninstallProgressCallback(float percent, if (This->popupsEnabled()) { This->m_popup->init(); - elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0); + elm_progressbar_value_set(This->m_popup->m_progressbar, percent / 100.0); evas_object_show(This->m_popup->m_popup); } } @@ -846,8 +896,7 @@ WrtInstaller::InstallerPopup::InstallerPopup() : m_win(NULL), m_popup(NULL), m_progressbar(NULL) -{ -} +{} WrtInstaller::InstallerPopup::~InstallerPopup() { @@ -870,9 +919,9 @@ void WrtInstaller::InstallerPopup::init() elm_object_style_set(m_progressbar, "list_progress"); elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE); evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL, - EVAS_HINT_FILL); + EVAS_HINT_FILL); evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); + EVAS_HINT_EXPAND); elm_object_content_set(m_popup, m_progressbar); elm_progressbar_value_set(m_progressbar, 0.0); evas_object_show(m_progressbar); @@ -888,8 +937,9 @@ Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name) win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC); int w, h; - if(!win) + if (!win) { return NULL; + } elm_win_alpha_set(win, EINA_TRUE); elm_win_title_set(win, name); @@ -907,14 +957,14 @@ void WrtInstaller::InstallerPopup::showPopup(void* userdata, { Evas_Object *btn; - LogDebug("Result Popup Created"); evas_object_del(m_popup); m_popup = NULL; m_popup = elm_popup_add(m_win); - if (!m_popup) + if (!m_popup) { return; + } btn = elm_button_add(m_popup); if (!btn) { @@ -929,7 +979,6 @@ void WrtInstaller::InstallerPopup::showPopup(void* userdata, evas_object_show(m_popup); evas_object_show(m_win); - } void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/, @@ -991,8 +1040,8 @@ int main(int argc, char *argv[]) // Check and re-set the file open limitation struct rlimit rlim; if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) { - LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" ); - LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" ); + LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")"); + LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")"); if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) { rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER; diff --git a/src/wrt-installer/wrt_installer.h b/src/wrt-installer/wrt_installer.h index 723236f..29e9835 100644 --- a/src/wrt-installer/wrt_installer.h +++ b/src/wrt-installer/wrt_installer.h @@ -53,35 +53,35 @@ enum ReturnValue }; class WrtInstaller : - public DPL::Application, - private DPL::Event::Controller::Type>, - public DPL::TaskDecl + public DPL::Application, + private DPL::Event::Controller:: + Type>, + public DPL::TaskDecl { public: WrtInstaller(int argc, - char **argv); + char **argv); virtual ~WrtInstaller(); - int getReturnStatus() const; class InstallerPopup { - public: - InstallerPopup(); - virtual ~InstallerPopup(); - - void init(); - Evas_Object* createWin(const char* name); - void showPopup(void* userdata, const DPL::String& pkgMsg, - ShowResultCallback callback); - - Evas_Object* m_win; - Evas_Object* m_popup; - Evas_Object* m_progressbar; + public: + InstallerPopup(); + virtual ~InstallerPopup(); + + void init(); + Evas_Object* createWin(const char* name); + void showPopup(void* userdata, const DPL::String& pkgMsg, + ShowResultCallback callback); + + Evas_Object* m_win; + Evas_Object* m_popup; + Evas_Object* m_progressbar; }; protected: @@ -96,7 +96,8 @@ class WrtInstaller : // Events virtual void OnEventReceived(const WRTInstallerNS::QuitEvent &event); virtual void OnEventReceived(const WRTInstallerNS::NextStepEvent& event); - virtual void OnEventReceived(const WRTInstallerNS::InstallPluginEvent& event); + virtual void OnEventReceived( + const WRTInstallerNS::InstallPluginEvent& event); // Installation steps void initStep(); @@ -110,7 +111,6 @@ class WrtInstaller : void registerCallbackStep(); void queryListStep(); - // Static callbacks static void staticWrtInitCallback(WrtErrStatus status, void* userdata); @@ -123,12 +123,12 @@ class WrtInstaller : const char* description, void* userdata); static void staticWrtInstallProgressCallback(float percent, - const char* description, - void* userdata); + const char* description, + void* userdata); static void staticWrtUninstallProgressCallback(float percent, - const char* description, - void* userdata); + const char* description, + void* userdata); static void showResultCallback(void *data, Evas_Object *obj, void *event_info); diff --git a/src/wrt-installer/wrt_installer_api.cpp b/src/wrt-installer/wrt_installer_api.cpp old mode 100755 new mode 100644 index 1230599..9ef38e9 --- a/src/wrt-installer/wrt_installer_api.cpp +++ b/src/wrt-installer/wrt_installer_api.cpp @@ -59,561 +59,549 @@ using namespace WrtDB; extern "C" { #endif - inline WidgetUpdateMode::Type translateWidgetUpdateMode( - wrt_widget_update_mode_t updateMode) - { - if (updateMode == WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL) - return WidgetUpdateMode::PolicyDirectoryForceInstall; - - WidgetUpdateMode::Type result = WidgetUpdateMode::Zero; - if (updateMode & WRT_WIM_NOT_INSTALLED) { - result = result | WidgetUpdateMode::NotInstalled; - } - - if (updateMode & WRT_WIM_INCOMING_VERSION_NOT_STD) { - result = result | WidgetUpdateMode::IncomingVersionNotStd; - } - - if (updateMode & WRT_WIM_EXISTING_VERSION_NOT_STD) { - result = result | WidgetUpdateMode::ExistingVersionNotStd; - } - - if (updateMode & WRT_WIM_BOTH_VERSIONS_NOT_STD) { - result = result | WidgetUpdateMode::BothVersionsNotStd; - } - - if (updateMode & WRT_WIM_EXISTING_VERSION_OLDER) { - result = result | WidgetUpdateMode::ExistingVersionOlder; - } +inline WidgetUpdateMode::Type translateWidgetUpdateMode( + wrt_widget_update_mode_t updateMode) +{ + if (updateMode == WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL) { + return WidgetUpdateMode::PolicyDirectoryForceInstall; + } - if (updateMode & WRT_WIM_EXISTING_VERSION_EQUAL) { - result = result | WidgetUpdateMode::ExistingVersionEqual; - } + WidgetUpdateMode::Type result = WidgetUpdateMode::Zero; + if (updateMode & WRT_WIM_NOT_INSTALLED) { + result = result | WidgetUpdateMode::NotInstalled; + } - if (updateMode & WRT_WIM_EXISTING_VERSION_NEWER) { - result = result | WidgetUpdateMode::ExistingVersionNewer; - } + if (updateMode & WRT_WIM_INCOMING_VERSION_NOT_STD) { + result = result | WidgetUpdateMode::IncomingVersionNotStd; + } - return result; + if (updateMode & WRT_WIM_EXISTING_VERSION_NOT_STD) { + result = result | WidgetUpdateMode::ExistingVersionNotStd; } - const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock"; - static int wrt_count_plugin; + if (updateMode & WRT_WIM_BOTH_VERSIONS_NOT_STD) { + result = result | WidgetUpdateMode::BothVersionsNotStd; + } - static std::string cutOffFileName(const std::string& path) - { - size_t found = path.find_last_of("/"); - if (found == std::string::npos) { - return path; - } else { - return path.substr(0, found); - } + if (updateMode & WRT_WIM_EXISTING_VERSION_OLDER) { + result = result | WidgetUpdateMode::ExistingVersionOlder; } - static bool checkPath(const std::string& path) - { - struct stat st; - if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) { - return true; - } - LogError("Cannot access directory [ " << path << " ]"); - return false; + if (updateMode & WRT_WIM_EXISTING_VERSION_EQUAL) { + result = result | WidgetUpdateMode::ExistingVersionEqual; } - static bool checkPaths() - { - bool if_ok = true; - if_ok &= (checkPath(cutOffFileName( - GlobalConfig::GetWrtDatabaseFilePath()))); - if (!if_ok) { - LogError( - "Path <" << GlobalConfig::GetWrtDatabaseFilePath() << - "> does not exist."); - } + if (updateMode & WRT_WIM_EXISTING_VERSION_NEWER) { + result = result | WidgetUpdateMode::ExistingVersionNewer; + } - if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath())); - if (!if_ok) { - LogError( - "Path <" << GlobalConfig::GetDevicePluginPath() << - "> does not exist."); - } + return result; +} - if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath())); - if (!if_ok) { - LogError( - "Path <" << GlobalConfig::GetUserInstalledWidgetPath() << - "> does not exist."); - } +const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock"; +static int wrt_count_plugin; - if_ok &= (checkPath(GlobalConfig::GetUserPreloadedWidgetPath())); - if (!if_ok) { - LogError( - "Path <" << GlobalConfig::GetUserPreloadedWidgetPath() << - "> does not exist."); - } - return if_ok; +static std::string cutOffFileName(const std::string& path) +{ + size_t found = path.find_last_of("/"); + if (found == std::string::npos) { + return path; + } else { + return path.substr(0, found); } +} - void plugin_install_status_cb(WrtErrStatus status, - void* userparam) - { - Assert(userparam); - - wrt_plugin_data *plugin_data = static_cast(userparam); +static bool checkPath(const std::string& path) +{ + struct stat st; + if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) { + return true; + } + LogError("Cannot access directory [ " << path << " ]"); + return false; +} - if (--wrt_count_plugin < 1) { - LogDebug("All plugins installation completed"); +static bool checkPaths() +{ + bool if_ok = true; + if_ok &= (checkPath(cutOffFileName( + GlobalConfig::GetWrtDatabaseFilePath()))); + if (!if_ok) { + LogError( + "Path <" << GlobalConfig::GetWrtDatabaseFilePath() << + "> does not exist."); + } - LogDebug("Call SetAllinstallpluginsCallback"); - plugin_data->plugin_installed_cb(plugin_data->user_data); - } + if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath())); + if (!if_ok) { + LogError( + "Path <" << GlobalConfig::GetDevicePluginPath() << + "> does not exist."); + } - if (status == WRT_SUCCESS) { - LogInfo( - "plugin installation is successful: " << - plugin_data->plugin_path); - return; - } + if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath())); + if (!if_ok) { + LogError( + "Path <" << GlobalConfig::GetUserInstalledWidgetPath() << + "> does not exist."); + } - LogError("Fail to install plugin : " << plugin_data->plugin_path); - - switch (status) { - case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH: - LogError("Failed : Plugin install path is wrong"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_METAFILE: - LogError("Failed : Plugin Metafile Error"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED: - LogError("Failed : This Plugin is already installed"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR: - LogError("Failed : Library Error. Missing symbol or structures"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_WAITING: - LogError("Failed : Waiting for plugin dependencies"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_LOCK: - LogError("Failed : Lock Error"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN: - LogError("Failed : Unkown Error"); - break; - default: - break; - } + if_ok &= (checkPath(GlobalConfig::GetUserPreloadedWidgetPath())); + if (!if_ok) { + LogError( + "Path <" << GlobalConfig::GetUserPreloadedWidgetPath() << + "> does not exist."); } + return if_ok; +} - void plugin_install_progress_cb(float percent, - const char* description, - void* userdata) - { - char *plugin_path = static_cast(userdata); +void plugin_install_status_cb(WrtErrStatus status, + void* userparam) +{ + Assert(userparam); - LogInfo("Install plugin : " << plugin_path << - ", Progress : " << percent << - ", Description : " << description); - } + wrt_plugin_data *plugin_data = static_cast(userparam); - EXPORT_API int wrt_installer_init(void *userdata, - WrtInstallerInitCallback callback) - { - // Set DPL/LOG MID - DPL::Log::LogSystemSingleton::Instance().SetTag("WRT"); + if (--wrt_count_plugin < 1) { + LogDebug("All plugins installation completed"); - try - { - LogInfo("[WRT-API] INITIALIZING WRT INSTALLER..."); - LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__); - - // Touch InstallerController Singleton - InstallerMainThreadSingleton::Instance().TouchArchitecture(); - - // Check paths - if (!checkPaths()) { - if (callback) { - callback(WRT_ERROR_NO_PATH, userdata); - } - return TRUE; - } + LogDebug("Call SetAllinstallpluginsCallback"); + plugin_data->plugin_installed_cb(plugin_data->user_data); + } - // Initialize ValidationCore - this must be done before AttachDatabases - ValidationCore::VCoreInit( - std::string(GlobalConfig::GetFingerprintListFile()), - std::string(GlobalConfig::GetFingerprintListSchema()), - std::string(GlobalConfig::GetVCoreDatabaseFilePath())); + if (status == WRT_SUCCESS) { + LogInfo( + "plugin installation is successful: " << + plugin_data->plugin_path); + return; + } - InstallerMainThreadSingleton::Instance().AttachDatabases(); + LogError("Fail to install plugin : " << plugin_data->plugin_path); + + switch (status) { + case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH: + LogError("Failed : Plugin install path is wrong"); + break; + case WRT_PLUGIN_INSTALLER_ERROR_METAFILE: + LogError("Failed : Plugin Metafile Error"); + break; + case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED: + LogError("Failed : This Plugin is already installed"); + break; + case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR: + LogError("Failed : Library Error. Missing symbol or structures"); + break; + case WRT_PLUGIN_INSTALLER_ERROR_WAITING: + LogError("Failed : Waiting for plugin dependencies"); + break; + case WRT_PLUGIN_INSTALLER_ERROR_LOCK: + LogError("Failed : Lock Error"); + break; + case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN: + LogError("Failed : Unkown Error"); + break; + default: + break; + } +} - //checking for correct DB version -// if (!WrtDB::WrtDatabase::CheckTableExist(DB_CHECKSUM_STR)) { -// LogError("WRONG VERSION OF WRT DATABASE"); -// Assert(false && "WRONG VERSION OF WRT DATABASE"); -// return FALSE; -// } - LogWarning("Database check not implemented!"); +void plugin_install_progress_cb(float percent, + const char* description, + void* userdata) +{ + char *plugin_path = static_cast(userdata); - LogInfo("Prepare libxml2 to work in multithreaded program."); - xmlInitParser(); + LogInfo("Install plugin : " << plugin_path << + ", Progress : " << percent << + ", Description : " << description); +} - // Initialize Language Subtag registry - LanguageSubtagRstTreeSingleton::Instance().Initialize(); +EXPORT_API int wrt_installer_init(void *userdata, + WrtInstallerInitCallback callback) +{ + // Set DPL/LOG MID + DPL::Log::LogSystemSingleton::Instance().SetTag("WRT"); - // Installer init - CONTROLLER_POST_SYNC_EVENT( - Logic::InstallerController, - InstallerControllerEvents:: - InitializeEvent()); + try { + LogInfo("[WRT-API] INITIALIZING WRT INSTALLER..."); + LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__); - // Install deferred widget packages - CONTROLLER_POST_EVENT( - Logic::InstallerController, - InstallerControllerEvents:: - InstallDeferredWidgetPackagesEvent()); + // Touch InstallerController Singleton + InstallerMainThreadSingleton::Instance().TouchArchitecture(); + // Check paths + if (!checkPaths()) { if (callback) { - LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK"); - callback(WRT_SUCCESS, userdata); - } - } - catch (const DPL::Exception& ex) - { - LogError("Internal Error during Init:"); - DPL::Exception::DisplayKnownException(ex); - if (callback) { - callback(WRT_ERROR_INTERNAL, userdata); + callback(WRT_ERROR_NO_PATH, userdata); } - return FALSE; + return TRUE; } - // OK - return TRUE; - } - - EXPORT_API void wrt_installer_shutdown() - { - try - { - LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER..."); - - // Installer termination - CONTROLLER_POST_SYNC_EVENT( - Logic::InstallerController, - InstallerControllerEvents:: - TerminateEvent()); - - InstallerMainThreadSingleton::Instance().DetachDatabases(); - - // This must be done after DetachDatabase - ValidationCore::VCoreDeinit(); - - // Global deinit check - LogInfo("Cleanup libxml2 global values."); - xmlCleanupParser(); + // Initialize ValidationCore - this must be done before AttachDatabases + ValidationCore::VCoreInit( + std::string(GlobalConfig::GetFingerprintListFile()), + std::string(GlobalConfig::GetFingerprintListSchema()), + std::string(GlobalConfig::GetVCoreDatabaseFilePath())); + + InstallerMainThreadSingleton::Instance().AttachDatabases(); + + //checking for correct DB version + // if (!WrtDB::WrtDatabase::CheckTableExist(DB_CHECKSUM_STR)) + // { + // LogError("WRONG VERSION OF WRT DATABASE"); + // Assert(false && "WRONG VERSION OF WRT DATABASE"); + // return FALSE; + // } + LogWarning("Database check not implemented!"); + + LogInfo("Prepare libxml2 to work in multithreaded program."); + xmlInitParser(); + + // Initialize Language Subtag registry + LanguageSubtagRstTreeSingleton::Instance().Initialize(); + + // Installer init + CONTROLLER_POST_SYNC_EVENT( + Logic::InstallerController, + InstallerControllerEvents:: + InitializeEvent()); + + // Install deferred widget packages + CONTROLLER_POST_EVENT( + Logic::InstallerController, + InstallerControllerEvents:: + InstallDeferredWidgetPackagesEvent()); + + if (callback) { + LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK"); + callback(WRT_SUCCESS, userdata); } - catch (const DPL::Exception& ex) - { - LogError("Internal Error during Shutdown:"); - DPL::Exception::DisplayKnownException(ex); + } catch (const DPL::Exception& ex) { + LogError("Internal Error during Init:"); + DPL::Exception::DisplayKnownException(ex); + if (callback) { + callback(WRT_ERROR_INTERNAL, userdata); } + return FALSE; } + // OK + return TRUE; +} + +EXPORT_API void wrt_installer_shutdown() +{ + try { + LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER..."); + + // Installer termination + CONTROLLER_POST_SYNC_EVENT( + Logic::InstallerController, + InstallerControllerEvents:: + TerminateEvent()); + + InstallerMainThreadSingleton::Instance().DetachDatabases(); + + // This must be done after DetachDatabase + ValidationCore::VCoreDeinit(); + + // Global deinit check + LogInfo("Cleanup libxml2 global values."); + xmlCleanupParser(); + } catch (const DPL::Exception& ex) { + LogError("Internal Error during Shutdown:"); + DPL::Exception::DisplayKnownException(ex); + } +} - EXPORT_API void wrt_install_widget(const char *path, - void* userdata, - WrtInstallerStatusCallback status_cb, - WrtProgressCallback progress_cb, - wrt_widget_update_mode_t update_mode, - bool quiet, - bool preload, - std::shared_ptr pkgmgrInterface - ) +EXPORT_API void wrt_install_widget( + const char *path, + void* userdata, + WrtInstallerStatusCallback status_cb, + WrtProgressCallback progress_cb, + wrt_widget_update_mode_t update_mode, + bool quiet, + bool preload, + std::shared_ptr pkgmgrInterface + ) +{ + UNHANDLED_EXCEPTION_HANDLER_BEGIN { - UNHANDLED_EXCEPTION_HANDLER_BEGIN - { - LogInfo("[WRT-API] INSTALL WIDGET: " << path); - // Post installation event - CONTROLLER_POST_EVENT( - Logic::InstallerController, - InstallerControllerEvents::InstallWidgetEvent( - path, WidgetInstallationStruct( - InstallerCallbacksTranslate::installFinishedCallback, - InstallerCallbacksTranslate::installProgressCallback, - new InstallerCallbacksTranslate::StatusCallbackStruct( - userdata, status_cb, progress_cb), - translateWidgetUpdateMode(update_mode), - quiet, - preload, - pkgmgrInterface))); - } - UNHANDLED_EXCEPTION_HANDLER_END + LogInfo("[WRT-API] INSTALL WIDGET: " << path); + // Post installation event + CONTROLLER_POST_EVENT( + Logic::InstallerController, + InstallerControllerEvents::InstallWidgetEvent( + path, WidgetInstallationStruct( + InstallerCallbacksTranslate::installFinishedCallback, + InstallerCallbacksTranslate::installProgressCallback, + new InstallerCallbacksTranslate::StatusCallbackStruct( + userdata, status_cb, progress_cb), + translateWidgetUpdateMode(update_mode), + quiet, + preload, + pkgmgrInterface))); } + UNHANDLED_EXCEPTION_HANDLER_END +} - EXPORT_API void wrt_uninstall_widget(const char * const tzAppid, - void* userdata, - WrtInstallerStatusCallback status_cb, - WrtProgressCallback progress_cb, - std::shared_ptr pkgmgrSignalInterface) +EXPORT_API void wrt_uninstall_widget( + const char * const tzAppid, + void* userdata, + WrtInstallerStatusCallback status_cb, + WrtProgressCallback progress_cb, + std::shared_ptr pkgmgrSignalInterface) +{ + UNHANDLED_EXCEPTION_HANDLER_BEGIN { - UNHANDLED_EXCEPTION_HANDLER_BEGIN - { - std::string tizenAppid(tzAppid); - LogInfo("[WRT-API] UNINSTALL WIDGET: " << tizenAppid); - // Post uninstallation event - CONTROLLER_POST_EVENT( - Logic::InstallerController, - InstallerControllerEvents::UninstallWidgetEvent( - tizenAppid, - WidgetUninstallationStruct( - InstallerCallbacksTranslate::uninstallFinishedCallback, - InstallerCallbacksTranslate::installProgressCallback, - new InstallerCallbacksTranslate::StatusCallbackStruct( - userdata, status_cb, progress_cb), - pkgmgrSignalInterface - ) + std::string tizenAppid(tzAppid); + LogInfo("[WRT-API] UNINSTALL WIDGET: " << tizenAppid); + // Post uninstallation event + CONTROLLER_POST_EVENT( + Logic::InstallerController, + InstallerControllerEvents::UninstallWidgetEvent( + tizenAppid, + WidgetUninstallationStruct( + InstallerCallbacksTranslate::uninstallFinishedCallback, + InstallerCallbacksTranslate::installProgressCallback, + new InstallerCallbacksTranslate::StatusCallbackStruct( + userdata, status_cb, progress_cb), + pkgmgrSignalInterface ) + ) ); - } - UNHANDLED_EXCEPTION_HANDLER_END } + UNHANDLED_EXCEPTION_HANDLER_END +} - EXPORT_API void wrt_install_plugin( - const char *pluginDir, - void *user_param, - WrtPluginInstallerStatusCallback status_cb, - WrtProgressCallback progress_cb) +EXPORT_API void wrt_install_plugin( + const char *pluginDir, + void *user_param, + WrtPluginInstallerStatusCallback status_cb, + WrtProgressCallback progress_cb) +{ + UNHANDLED_EXCEPTION_HANDLER_BEGIN { - UNHANDLED_EXCEPTION_HANDLER_BEGIN - { - LogInfo("[WRT-API] INSTALL PLUGIN: " << pluginDir); - //Private data for status callback - //Resource is free in pluginInstallFinishedCallback - InstallerCallbacksTranslate::PluginStatusCallbackStruct* - callbackStruct = - new InstallerCallbacksTranslate::PluginStatusCallbackStruct( - user_param, status_cb, progress_cb); - - CONTROLLER_POST_EVENT( - Logic::InstallerController, - InstallerControllerEvents::InstallPluginEvent( - std::string(pluginDir), - PluginInstallerStruct( - InstallerCallbacksTranslate:: + LogInfo("[WRT-API] INSTALL PLUGIN: " << pluginDir); + //Private data for status callback + //Resource is free in pluginInstallFinishedCallback + InstallerCallbacksTranslate::PluginStatusCallbackStruct* + callbackStruct = + new InstallerCallbacksTranslate::PluginStatusCallbackStruct( + user_param, status_cb, progress_cb); + + CONTROLLER_POST_EVENT( + Logic::InstallerController, + InstallerControllerEvents::InstallPluginEvent( + std::string(pluginDir), + PluginInstallerStruct( + InstallerCallbacksTranslate:: pluginInstallFinishedCallback, - InstallerCallbacksTranslate:: + InstallerCallbacksTranslate:: installProgressCallback, callbackStruct))); - } - UNHANDLED_EXCEPTION_HANDLER_END } + UNHANDLED_EXCEPTION_HANDLER_END +} - EXPORT_API void wrt_install_all_plugins( - WrtAllPluginInstalledCallback installed_cb, - void *user_param) +EXPORT_API void wrt_install_all_plugins( + WrtAllPluginInstalledCallback installed_cb, + void *user_param) +{ + UNHANDLED_EXCEPTION_HANDLER_BEGIN { - UNHANDLED_EXCEPTION_HANDLER_BEGIN - { - std::string installRequest = - std::string(GlobalConfig::GetPluginInstallInitializerName()); - - LogDebug("Install new plugins"); - - Try { - DPL::Semaphore lock(PLUGIN_INSTALL_SEMAPHORE); - } - Catch(DPL::Semaphore::Exception::Base){ - LogError("Failed to create installation lock"); - return; - } + std::string installRequest = + std::string(GlobalConfig::GetPluginInstallInitializerName()); - struct stat tmp; + LogDebug("Install new plugins"); - if (-1 == stat(installRequest.c_str(), &tmp) || - !S_ISREG(tmp.st_mode)) - { - if (ENOENT == errno) { - LogDebug("Plugin installation not required"); + Try { + DPL::Semaphore lock(PLUGIN_INSTALL_SEMAPHORE); + } + Catch(DPL::Semaphore::Exception::Base){ + LogError("Failed to create installation lock"); + return; + } - LogDebug("Call SetAllinstallPluginCallback"); - installed_cb(user_param); + struct stat tmp; - DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE); - return; - } - LogWarning("Opening installation request file failed"); - } + if (-1 == stat(installRequest.c_str(), &tmp) || + !S_ISREG(tmp.st_mode)) + { + if (ENOENT == errno) { + LogDebug("Plugin installation not required"); - std::string PLUGIN_PATH = - std::string(GlobalConfig::GetDevicePluginPath()); + LogDebug("Call SetAllinstallPluginCallback"); + installed_cb(user_param); - DIR *dir; - dir = opendir(PLUGIN_PATH.c_str()); - if (!dir) { DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE); return; } + LogWarning("Opening installation request file failed"); + } - LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH); - struct dirent* libdir; + std::string PLUGIN_PATH = + std::string(GlobalConfig::GetDevicePluginPath()); - errno = 0; + DIR *dir; + dir = opendir(PLUGIN_PATH.c_str()); + if (!dir) { + DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE); + return; + } - std::list pluginsPaths; + LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH); + struct dirent* libdir; - while ((libdir = readdir(dir)) != 0) { - if (strcmp(libdir->d_name, ".") == 0 || - strcmp(libdir->d_name, "..") == 0) - { - continue; - } + errno = 0; - std::string path = PLUGIN_PATH; - path += "/"; - path += libdir->d_name; + std::list pluginsPaths; - struct stat tmp; + while ((libdir = readdir(dir)) != 0) { + if (strcmp(libdir->d_name, ".") == 0 || + strcmp(libdir->d_name, "..") == 0) + { + continue; + } - if (stat(path.c_str(), &tmp) == -1) { - LogError("Failed to open file" << path); - continue; - } + std::string path = PLUGIN_PATH; + path += "/"; + path += libdir->d_name; - if (!S_ISDIR(tmp.st_mode)) { - LogError("Not a directory" << path); - continue; - } + struct stat tmp; - pluginsPaths.push_back(path); + if (stat(path.c_str(), &tmp) == -1) { + LogError("Failed to open file" << path); + continue; } - wrt_count_plugin = pluginsPaths.size(); + if (!S_ISDIR(tmp.st_mode)) { + LogError("Not a directory" << path); + continue; + } - FOREACH(it, pluginsPaths) { - wrt_plugin_data *plugin_data = new wrt_plugin_data; + pluginsPaths.push_back(path); + } - plugin_data->plugin_installed_cb = installed_cb; - plugin_data->plugin_path = const_cast(it->c_str()); - plugin_data->user_data = user_param; + wrt_count_plugin = pluginsPaths.size(); - wrt_install_plugin( - it->c_str(), static_cast(plugin_data), - plugin_install_status_cb, - plugin_install_progress_cb); - } + FOREACH(it, pluginsPaths) { + wrt_plugin_data *plugin_data = new wrt_plugin_data; - if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { - LogError("Failed to close dir: " << PLUGIN_PATH << " with error: " - << DPL::GetErrnoString()); - } + plugin_data->plugin_installed_cb = installed_cb; + plugin_data->plugin_path = const_cast(it->c_str()); + plugin_data->user_data = user_param; - if (0 != unlink(installRequest.c_str())) { - LogError("Failed to remove file initializing plugin " - "installation"); - } + wrt_install_plugin( + it->c_str(), static_cast(plugin_data), + plugin_install_status_cb, + plugin_install_progress_cb); + } - Try { - DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE); - } - Catch(DPL::Semaphore::Exception::Base){ - LogInfo("Failed to remove installation lock"); - } + if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { + LogError("Failed to close dir: " << PLUGIN_PATH << " with error: " + << DPL::GetErrnoString()); + } + + if (0 != unlink(installRequest.c_str())) { + LogError("Failed to remove file initializing plugin " + "installation"); + } + + Try { + DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE); + } + Catch(DPL::Semaphore::Exception::Base){ + LogInfo("Failed to remove installation lock"); } - UNHANDLED_EXCEPTION_HANDLER_END } + UNHANDLED_EXCEPTION_HANDLER_END +} - EXPORT_API int wrt_installer_init_for_tests(void *userdata, - WrtInstallerInitCallback callback) - { - // Set DPL/LOG MID - DPL::Log::LogSystemSingleton::Instance().SetTag("WRT"); +EXPORT_API int wrt_installer_init_for_tests(void *userdata, + WrtInstallerInitCallback callback) +{ + // Set DPL/LOG MID + DPL::Log::LogSystemSingleton::Instance().SetTag("WRT"); - try - { - LogInfo("[WRT-API] INITIALIZING WRT INSTALLER..."); - LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__); - - // Touch InstallerController Singleton - InstallerMainThreadSingleton::Instance(). - TouchArchitectureOnlyInstaller(); - - // Check paths - if (!checkPaths()) { - if (callback) { - callback(WRT_ERROR_NO_PATH, userdata); - } - return TRUE; - } + try { + LogInfo("[WRT-API] INITIALIZING WRT INSTALLER..."); + LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__); - CONTROLLER_POST_SYNC_EVENT( - Logic::InstallerController, - InstallerControllerEvents:: - InitializeEvent()); + // Touch InstallerController Singleton + InstallerMainThreadSingleton::Instance(). + TouchArchitectureOnlyInstaller(); + // Check paths + if (!checkPaths()) { if (callback) { - LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK"); - callback(WRT_SUCCESS, userdata); + callback(WRT_ERROR_NO_PATH, userdata); } - } - catch (const DPL::Exception& ex) - { - LogError("Internal Error during Init:"); - DPL::Exception::DisplayKnownException(ex); - if (callback) { - callback(WRT_ERROR_INTERNAL, userdata); - } - return FALSE; + return TRUE; } - // OK - return TRUE; - } + CONTROLLER_POST_SYNC_EVENT( + Logic::InstallerController, + InstallerControllerEvents:: + InitializeEvent()); - EXPORT_API void wrt_installer_shutdown_for_tests() - { - try - { - LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER..."); - - // Installer termination - CONTROLLER_POST_SYNC_EVENT( - Logic::InstallerController, - InstallerControllerEvents:: - TerminateEvent()); - - // Global deinit check - LogInfo("Cleanup libxml2 global values."); - xmlCleanupParser(); + if (callback) { + LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK"); + callback(WRT_SUCCESS, userdata); } - catch (const DPL::Exception& ex) - { - LogError("Internal Error during Shutdown:"); - DPL::Exception::DisplayKnownException(ex); + } catch (const DPL::Exception& ex) { + LogError("Internal Error during Init:"); + DPL::Exception::DisplayKnownException(ex); + if (callback) { + callback(WRT_ERROR_INTERNAL, userdata); } + return FALSE; } - EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & tzAppid, - const std::string guid) - { - try - { - LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : " - << guid); + // OK + return TRUE; +} - WidgetGUID widget_guid = DPL::FromUTF8String(guid); - WrtDB::WidgetDAOReadOnly dao(widget_guid); - tzAppid = DPL::ToUTF8String(dao.getTzAppId()); - return WRT_SUCCESS; - } - catch (WidgetDAOReadOnly::Exception::WidgetNotExist) - { - LogError("Error package name is not found"); - return WRT_ERROR_PKGNAME_NOT_FOUND; - } - catch (const DPL::Exception& ex) - { - LogError("Internal Error during get widget id by package name"); - DPL::Exception::DisplayKnownException(ex); - return WRT_ERROR_INTERNAL; - } +EXPORT_API void wrt_installer_shutdown_for_tests() +{ + try { + LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER..."); + + // Installer termination + CONTROLLER_POST_SYNC_EVENT( + Logic::InstallerController, + InstallerControllerEvents:: + TerminateEvent()); + + // Global deinit check + LogInfo("Cleanup libxml2 global values."); + xmlCleanupParser(); + } catch (const DPL::Exception& ex) { + LogError("Internal Error during Shutdown:"); + DPL::Exception::DisplayKnownException(ex); } +} + +EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & tzAppid, + const std::string guid) +{ + try { + LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : " + << guid); + + WidgetGUID widget_guid = DPL::FromUTF8String(guid); + WrtDB::WidgetDAOReadOnly dao(widget_guid); + tzAppid = DPL::ToUTF8String(dao.getTzAppId()); + return WRT_SUCCESS; + } catch (WidgetDAOReadOnly::Exception::WidgetNotExist) { + LogError("Error package name is not found"); + return WRT_ERROR_PKGNAME_NOT_FOUND; + } catch (const DPL::Exception& ex) { + LogError("Internal Error during get widget id by package name"); + DPL::Exception::DisplayKnownException(ex); + return WRT_ERROR_INTERNAL; + } +} #ifdef __cplusplus } #endif diff --git a/src/wrt-installer/wrt_installer_api.h b/src/wrt-installer/wrt_installer_api.h old mode 100755 new mode 100644 index 7ef5893..4710d17 --- a/src/wrt-installer/wrt_installer_api.h +++ b/src/wrt-installer/wrt_installer_api.h @@ -44,7 +44,7 @@ extern "C" { * Callback function type invoked after async init function */ typedef void (*WrtInstallerInitCallback)(WrtErrStatus status, - void *data); + void *data); /** * Callback function type invoked after async functions @@ -56,8 +56,8 @@ typedef void (*WrtPluginInstallerStatusCallback)(WrtErrStatus status, * Callback function type invoked after async functions */ typedef void (*WrtInstallerStatusCallback)(std::string tizenId, - WrtErrStatus status, - void *data); + WrtErrStatus status, + void *data); /** * Callback function type invoked after async functions @@ -160,7 +160,7 @@ typedef enum wrt_widget_install_mode_e } wrt_widget_update_mode_t; int wrt_installer_init(void *userdata, - WrtInstallerInitCallback callback); + WrtInstallerInitCallback callback); /** * @fn void wrt_installer_shutdown(void) @@ -237,15 +237,17 @@ void wrt_installer_shutdown(void); * * @see wrt_installer_uninstall_widget */ -void wrt_install_widget(const char *path, - void *user_parameter, - WrtInstallerStatusCallback status_callback, - WrtProgressCallback progress_callback, - wrt_widget_update_mode_t update_mode, - bool quiet, - bool preload, - std::shared_ptr pkgmgrInterface - ); +void wrt_install_widget( + const char *path, + void *user_parameter, + WrtInstallerStatusCallback status_callback, + WrtProgressCallback progress_callback, + wrt_widget_update_mode_t update_mode, + bool quiet, + bool preload, + std::shared_ptr + pkgmgrInterface + ); /** * @fn void wrt_installer_uninstall_widget (const char * const tizenAppid, @@ -261,7 +263,7 @@ void wrt_install_widget(const char *path, * @param [in] status_cb - Call to this one will be done at the end of * operation * The callback is called in the context of the - application's + * application's * @param [in] progress_cb - Callback function to get data of install progress * If you don't want to get progress data, this * should be NULL @@ -275,11 +277,13 @@ void wrt_install_widget(const char *path, * * @see wrt_installer_install_widget */ -void wrt_uninstall_widget (const char * const tzAppid, - void* userdata, - WrtInstallerStatusCallback status_cb, - WrtProgressCallback progress_cb, - std::shared_ptr pkgmgrSignalInterface); +void wrt_uninstall_widget ( + const char * const tzAppid, + void* userdata, + WrtInstallerStatusCallback status_cb, + WrtProgressCallback progress_cb, + std::shared_ptr + pkgmgrSignalInterface); /** * @fn void wrt_install_plugin(const char *pluginDirectory, @@ -308,9 +312,9 @@ void wrt_uninstall_widget (const char * const tzAppid, * @see wrt_install_plugin */ void wrt_install_plugin(const char *pluginDirectory, - void *userData, - WrtPluginInstallerStatusCallback statusCallback, - WrtProgressCallback progressCallback); + void *userData, + WrtPluginInstallerStatusCallback statusCallback, + WrtProgressCallback progressCallback); /** * @brief To install plugins for first excution @@ -320,7 +324,7 @@ void wrt_install_plugin(const char *pluginDirectory, * @return nothing */ void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb, - void *user_param); + void *user_param); /** * @brief To initialize for tests @@ -330,7 +334,7 @@ void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb, * @return int */ int wrt_installer_init_for_tests(void *userdata, - WrtInstallerInitCallback callback); + WrtInstallerInitCallback callback); /** * @brief To shutdown for tests @@ -347,7 +351,8 @@ void wrt_installer_shutdown_for_tests(); * @param guid guid that we look for * @return error code */ -WrtErrStatus wrt_get_widget_by_guid(std::string &tzAppid, const std::string guid); +WrtErrStatus wrt_get_widget_by_guid(std::string &tzAppid, + const std::string guid); #ifdef __cplusplus } #endif diff --git a/src/wrt-installer/wrt_type.h b/src/wrt-installer/wrt_type.h old mode 100755 new mode 100644 index 8e5abb7..2163cfe --- a/src/wrt-installer/wrt_type.h +++ b/src/wrt-installer/wrt_type.h @@ -54,47 +54,47 @@ typedef enum /* Error result */ WRT_ERROR_INTERNAL = -128, /*< Internal library error. - Should never occur */ + * Should never occur */ WRT_ERROR_INVALID_PARAMETER, /*< Invalid parameter value was given - (eg. NULL) */ + * (eg. NULL) */ WRT_ERROR_HANDLE_NOT_FOUND, /*< Widget handle was not found */ WRT_ERROR_ID_NOT_FOUND, /*< Widget id was not found */ WRT_ERROR_PKGNAME_NOT_FOUND, /*< package name was not found */ WRT_ERROR_ALREADY_RUNNING, /*< Widget is already running */ WRT_ERROR_ALREADY_STOPPED, /*< Widget is already stopped */ WRT_ERROR_STILL_AUTHORIZING, /*< Widget is still autorizing and has not - yet finished it */ + * yet finished it */ WRT_ERROR_EARLY_KILLED, /*< Widget was early killed during launch */ WRT_ERROR_ACCESS_DENIED, /*< Access denied from ACE */ WRT_ERROR_NOT_INITIALIZED, /*