-# Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
url/url_parse_file.cc
net/http/transport_security_state.cpp
src/tpkp_common.cpp
+ src/tpkp_exception.cpp
src/tpkp_parser.cpp
src/tpkp_client_cache.cpp
ui/popup_common.cpp
*/
#pragma once
-#include <sys/types.h>
#include <string>
#include <vector>
#include <memory>
-#include <sstream>
#include <type_traits>
+#include "tpkp_exception.h"
#include "tpkp_error.h"
-#include "tpkp_logger.h"
#define EXPORT_API __attribute__((visibility("default")))
+/*
+ * classes under this header may throw exception which declared in tpkp_exception.h
+ */
+
namespace TPKP {
enum class HashAlgo : int {
using HashValueVector = std::vector<HashValue>;
-class EXPORT_API Exception : public std::exception {
-public:
- explicit Exception(tpkp_e code, const std::string &message);
- virtual const char *what(void) const noexcept;
- tpkp_e code(void) const noexcept;
-
-private:
- tpkp_e m_code;
- std::string m_message;
-};
-
-EXPORT_API
-tpkp_e ExceptionSafe(const std::function<void()> &func) noexcept;
-
class EXPORT_API Context {
public:
Context() = delete;
};
}
-
-#define TPKP_THROW_EXCEPTION(code, message) \
-do { \
- std::ostringstream log; \
- log << message; \
- throw TPKP::Exception(code, log.str()); \
-} while(false)
-
-#define TPKP_CHECK_THROW_EXCEPTION(cond, code, message) \
- if (!(cond)) TPKP_THROW_EXCEPTION(code, message)
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file tpkp_exception.h
+ * @author Kyungwook Tak (k.tak@samsung.com)
+ * @version 1.0
+ * @brief Exceptions for internal use.
+ */
+#pragma once
+
+#include <sstream>
+#include <string>
+#include <exception>
+#include <functional>
+
+#include "tpkp_error.h"
+
+#define EXPORT_API __attribute__((visibility("default")))
+
+namespace TPKP {
+
+EXPORT_API
+tpkp_e ExceptionSafe(const std::function<void()> &func) noexcept;
+
+class EXPORT_API Exception : public std::exception {
+public:
+ explicit Exception(tpkp_e code, const std::string &message);
+ virtual const char *what(void) const noexcept;
+ tpkp_e code(void) const noexcept;
+
+private:
+ tpkp_e m_code;
+ std::string m_message;
+};
+
+}
+
+#define TPKP_THROW_EXCEPTION(code, message) \
+do { \
+ std::ostringstream log; \
+ log << message; \
+ throw TPKP::Exception(code, log.str()); \
+} while(false)
+
+#define TPKP_CHECK_THROW_EXCEPTION(cond, code, message) \
+ if (!(cond)) TPKP_THROW_EXCEPTION(code, message)
#include "net/http/transport_security_state.h"
#include "net/http/transport_security_state_static.h"
+#include "tpkp_logger.h"
#include "tpkp_parser.h"
#include "ui/popup_runner.h"
namespace TPKP {
-Exception::Exception(tpkp_e code, const std::string &message)
- : m_code(code)
- , m_message(message)
-{}
-
-const char *Exception::what(void) const noexcept
-{
- return m_message.c_str();
-}
-
-tpkp_e Exception::code(void) const noexcept
-{
- return m_code;
-}
-
-tpkp_e ExceptionSafe(const std::function<void()> &func)
-{
- try {
- func();
- return TPKP_E_NONE;
- } catch (const Exception &e) {
- SLOGE("Exception: %s", e.what());
- return e.code();
- } catch (const std::bad_alloc &e) {
- SLOGE("bad_alloc std exception: %s", e.what());
- return TPKP_E_MEMORY;
- } catch (const std::exception &e) {
- SLOGE("std exception: %s", e.what());
- return TPKP_E_STD_EXCEPTION;
- } catch (...) {
- SLOGE("Unhandled exception occured!");
- return TPKP_E_INTERNAL;
- }
-}
-
class Context::Impl {
public:
Impl() = delete;
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file tpkp_exception.cpp
+ * @author Kyungwook Tak (k.tak@samsung.com)
+ * @version 1.0
+ * @brief Exceptions for internal uses
+ */
+#include "tpkp_exception.h"
+
+#include "tpkp_logger.h"
+
+namespace TPKP {
+
+Exception::Exception(tpkp_e code, const std::string &message)
+ : m_code(code)
+ , m_message(message)
+{}
+
+const char *Exception::what(void) const noexcept
+{
+ return m_message.c_str();
+}
+
+tpkp_e Exception::code(void) const noexcept
+{
+ return m_code;
+}
+
+tpkp_e ExceptionSafe(const std::function<void()> &func)
+{
+ try {
+ func();
+ return TPKP_E_NONE;
+ } catch (const Exception &e) {
+ SLOGE("Exception: %s", e.what());
+ return e.code();
+ } catch (const std::bad_alloc &e) {
+ SLOGE("bad_alloc std exception: %s", e.what());
+ return TPKP_E_MEMORY;
+ } catch (const std::exception &e) {
+ SLOGE("std exception: %s", e.what());
+ return TPKP_E_STD_EXCEPTION;
+ } catch (...) {
+ SLOGE("Unhandled exception occured!");
+ return TPKP_E_INTERNAL;
+ }
+}
+
+}
#include <systemd/sd-daemon.h>
#include <vconf.h>
-/*
- * TODO(k.tak): Separate TPKP::Exception related codes from tpkp_common
- * not to include "tpkp_common.h" which have lot of dependencies
- */
-#include "tpkp_common.h"
+#include "tpkp_exception.h"
#include "tpkp_logger.h"
#include "ui/popup_common.h"
#include <curl/curl.h>
#include "tpkp_common.h"
+#include "tpkp_logger.h"
#include "tpkp_client_cache.h"
namespace {
#include <gnutls/x509.h>
#include "tpkp_common.h"
+#include "tpkp_logger.h"
#include "tpkp_client_cache.h"
namespace {
${PROJECT_SOURCE_DIR}/src/common/url/url_parse_file.cc
${PROJECT_SOURCE_DIR}/src/common/net/http/transport_security_state.cpp
${PROJECT_SOURCE_DIR}/src/common/src/tpkp_common.cpp
+ ${PROJECT_SOURCE_DIR}/src/common/src/tpkp_exception.cpp
${PROJECT_SOURCE_DIR}/src/common/src/tpkp_parser.cpp
${PROJECT_SOURCE_DIR}/src/common/ui/popup_runner.cpp
${PROJECT_SOURCE_DIR}/src/common/ui/popup_common.cpp