Popup service initial commit 39/66339/1
authorKyungwook Tak <k.tak@samsung.com>
Tue, 22 Mar 2016 11:30:50 +0000 (20:30 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 18 Apr 2016 11:11:59 +0000 (20:11 +0900)
[Verification]
Run # csr-popup-test and see stdout is the same to the button what you clicked

TODO list
- Add language file when popup text format fixed
- Add more command items when popup related logic fixed
- Integrate to main logic when logic ready

Change-Id: If55574269aea8f77bde920d17b53dc564f94db72
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
50 files changed:
CMakeLists.txt
packaging/csr-framework.spec
packaging/csr-test.manifest.in
packaging/csr.manifest.in
src/CMakeLists.txt
src/framework/CMakeLists.txt
src/framework/client/client-common.cpp
src/framework/client/client-common.h
src/framework/client/content-screening.cpp
src/framework/client/engine-manager.cpp
src/framework/client/error.cpp
src/framework/client/web-protection.cpp
src/framework/common/audit/logger.h
src/framework/common/binary-queue.cpp
src/framework/common/connection.cpp
src/framework/common/connection.h
src/framework/common/mainloop.cpp [moved from src/framework/main/mainloop.cpp with 88% similarity]
src/framework/common/mainloop.h [moved from src/framework/main/mainloop.h with 97% similarity]
src/framework/common/message-buffer.cpp
src/framework/common/message-buffer.h
src/framework/common/serialization.h
src/framework/common/service.cpp [moved from src/framework/service/service.cpp with 84% similarity]
src/framework/common/service.h [moved from src/framework/service/service.h with 71% similarity]
src/framework/common/socket.cpp
src/framework/common/socket.h
src/framework/main/csr-main.cpp
src/framework/service/logic.cpp
src/framework/service/logic.h
src/framework/service/server-service.cpp [new file with mode: 0644]
src/framework/service/server-service.h [new file with mode: 0644]
src/framework/ui/CMakeLists.txt [new file with mode: 0644]
src/framework/ui/askuser.cpp [new file with mode: 0644]
src/framework/ui/askuser.h [new file with mode: 0644]
src/framework/ui/common.cpp [new file with mode: 0644]
src/framework/ui/common.h [new file with mode: 0644]
src/framework/ui/popup/CMakeLists.txt [new file with mode: 0644]
src/framework/ui/popup/logic.cpp [new file with mode: 0644]
src/framework/ui/popup/logic.h [new file with mode: 0644]
src/framework/ui/popup/main.cpp [new file with mode: 0644]
src/framework/ui/popup/popup-service.cpp [new file with mode: 0644]
src/framework/ui/popup/popup-service.h [new file with mode: 0644]
src/framework/ui/popup/popup.cpp [new file with mode: 0644]
src/framework/ui/popup/popup.h [new file with mode: 0644]
systemd/CMakeLists.txt
systemd/csr-popup.service.in [new file with mode: 0644]
systemd/csr-popup.socket.in [new file with mode: 0644]
test/CMakeLists.txt
test/popup/CMakeLists.txt [new file with mode: 0644]
test/popup/test-main.cpp [new file with mode: 0644]
test/popup/test-popup.cpp [new file with mode: 0644]

index 798e49a..c4fffd6 100644 (file)
@@ -50,10 +50,11 @@ ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
 SET(TARGET_CSR_SERVER ${SERVICE_NAME}-server)
 SET(TARGET_CSR_CLIENT ${SERVICE_NAME}-client)
 SET(TARGET_CSR_COMMON ${SERVICE_NAME}-common)
-SET(TARGET_CSR_TEST ${SERVICE_NAME}-test)
+SET(TARGET_CSR_POPUP ${SERVICE_NAME}-popup)
 SET(TARGET_CSR_CS_ENGINE_SAMPLE ${SERVICE_NAME}-cs-engine)
 SET(TARGET_CSR_WP_ENGINE_SAMPLE ${SERVICE_NAME}-wp-engine)
-SET(TARGET_CSR_ENGINE_TEST ${SERVICE_NAME}-engine-test)
+SET(TARGET_CSR_TEST ${SERVICE_NAME}-test)
+SET(TARGET_CSR_POPUP_TEST ${SERVICE_NAME}-popup-test)
 
 CONFIGURE_FILE(packaging/${SERVICE_NAME}.manifest.in ${SERVICE_NAME}.manifest @ONLY)
 CONFIGURE_FILE(packaging/${SERVICE_NAME}-client.manifest.in ${SERVICE_NAME}-client.manifest @ONLY)
index 96b06d8..92e38dc 100644 (file)
@@ -9,6 +9,8 @@ URL: http://tizen.org
 BuildRequires: cmake
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(libsystemd-daemon)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(elementary)
 Requires:      lib%{name}-common = %{version}-%{release}
 %{?systemd_requires}
 
@@ -79,6 +81,7 @@ test program of csr-framework
     -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \
     -DBIN_DIR:PATH=%{bin_dir} \
     -DSYSTEMD_UNIT_DIR=%{_unitdir} \
+    -DSYSTEMD_UNIT_USER_DIR=%{_unitdir_user} \
     -DSAMPLE_ENGINE_WORKING_DIR:PATH=%{sample_engine_working_dir} \
     -DSAMPLE_ENGINE_DIR:PATH=%{sample_engine_dir} \
     -DTEST_DIR:PATH=%{test_dir}
@@ -92,6 +95,11 @@ mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
 ln -s ../%{service_name}.service %{buildroot}%{_unitdir}/multi-user.target.wants/%{service_name}.service
 ln -s ../%{service_name}.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}.socket
 
+mkdir -p %{buildroot}%{_unitdir}/default.target.wants
+mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
+ln -s ../%{service_name}-popup.service %{buildroot}%{_unitdir}/default.target.wants/%{service_name}-popup.service
+ln -s ../%{service_name}-popup.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-popup.socket
+
 mkdir -p %{buildroot}%{ro_data_dir}/license
 cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}
 cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}.BSL-1.0
@@ -105,17 +113,20 @@ systemctl daemon-reload
 if [ $1 = 1 ]; then
     systemctl start %{service_name}.socket
     systemctl start %{service_name}.service
+    systemctl start %{service_name}-popup.socket
 fi
 
 if [ $1 = 2 ]; then
     systemctl restart %{service_name}.socket
     systemctl restart %{service_name}.service
+    systemctl restart %{service_name}-popup.socket
 fi
 
 %preun
 if [ $1 = 0 ]; then
     systemctl stop %{service_name}.service
     systemctl stop %{service_name}.socket
+    systemctl stop %{service_name}-popup.socket
 fi
 
 %postun
@@ -134,10 +145,15 @@ fi
 %{ro_data_dir}/license/%{name}
 %{ro_data_dir}/license/%{name}.BSL-1.0
 %{bin_dir}/%{service_name}-server
+%{bin_dir}/%{service_name}-popup
 %{_unitdir}/multi-user.target.wants/%{service_name}.service
 %{_unitdir}/%{service_name}.service
 %{_unitdir}/sockets.target.wants/%{service_name}.socket
 %{_unitdir}/%{service_name}.socket
+%{_unitdir}/default.target.wants/%{service_name}-popup.service
+%{_unitdir}/%{service_name}-popup.service
+%{_unitdir}/sockets.target.wants/%{service_name}-popup.socket
+%{_unitdir}/%{service_name}-popup.socket
 
 # sample engine related files
 %{sample_engine_dir}/lib%{service_name}-cs-engine.so
@@ -174,5 +190,6 @@ fi
 %{ro_data_dir}/license/%{name}-test
 %{ro_data_dir}/license/%{name}-test.BSL-1.0
 %{bin_dir}/%{service_name}-test
+%{bin_dir}/%{service_name}-popup-test
 # test resources
 %{test_dir}
index 7aa1942..0db171d 100644 (file)
@@ -7,8 +7,10 @@
                        <smack request="sys-assert::core" type="rwxat" />
                        <smack request="systemd" type="rx" />
                        <smack request="csr" type="rwxat" />
+                       <smack request="sdbd" type="rx" />
                </request>
                <permit>
+                       <smack permit="_" type="rx" />
                </permit>
        </define>
        <request>
index 7b06d77..c6dd74c 100644 (file)
@@ -6,8 +6,20 @@
                        <smack request="device::app_logging" type="rw" />
                        <smack request="sys-assert::core" type="rwxat" />
                        <smack request="systemd" type="rx" />
+                       <smack request="xorg" type="rwxat" />
+                       <smack request="system::homedir" type="rx" />
+                       <smack request="tizen::vconf::setting" type="rl" />
+                       <smack request="tizen::vconf::setting::admin" type="rl" />
+                       <smack request="tizen::vconf::public::r::platform::rw" type="rl" />
+                       <smack request="tizen::vconf::camcorder" type="rl" />
+                       <smack request="isf" type="rx" />
+                       <smack request="dbus" type="w" />
+                       <smack request="pulseaudio" type="w" />
+                       <smack request="sdbd" type="rx" />
                </request>
                <permit>
+                       <smack permit="_" type="rx" />
+                       <smack permit="xorg" type="rx" />
                </permit>
        </define>
        <request>
index b2c6d3d..4cce495 100644 (file)
 ###############     SERVER     ###################
 PKG_CHECK_MODULES(${TARGET_CSR_SERVER}_DEP
        REQUIRED
+       libsystemd-daemon
 )
 
 SET(${TARGET_CSR_SERVER}_SRCS
        framework/main/csr-main.cpp
-       framework/main/mainloop.cpp
        framework/service/logic.cpp
-       framework/service/service.cpp
+       framework/service/server-service.cpp
+       framework/ui/askuser.cpp
+
+       # question and response codes needed on both of
+       # csr-server and popup-backend service
+       framework/ui/common.cpp
 )
 
 INCLUDE_DIRECTORIES(
-       framework/common
-       framework/main
-       framework/service
+       framework
+       ${PROJECT_SOURCE_DIR}/src/include
        ${${TARGET_CSR_SERVER}_DEP_INCLUDED_DIRS}
 )
 
@@ -74,8 +78,7 @@ SET(${TARGET_CSR_CLIENT}_SRCS
 )
 
 INCLUDE_DIRECTORIES(
-       framework/common
-       framework/client
+       framework
        ${PROJECT_SOURCE_DIR}/src/include
        ${${TARGET_CSR_CLIENT}_DEP_INCLUDE_DIRS}
 )
index c6ac189..7d97870 100644 (file)
@@ -27,6 +27,8 @@ SET(${TARGET_CSR_COMMON}_SRCS
        common/connection.cpp
        common/message-buffer.cpp
        common/socket.cpp
+       common/service.cpp
+       common/mainloop.cpp
        common/audit/console-sink.cpp
        common/audit/dlog-sink.cpp
        common/audit/logger.cpp
@@ -51,3 +53,5 @@ TARGET_LINK_LIBRARIES(${TARGET_CSR_COMMON}
 )
 
 INSTALL(TARGETS ${TARGET_CSR_COMMON} DESTINATION ${LIB_INSTALL_DIR})
+
+ADD_SUBDIRECTORY(ui)
index b72faa0..ecff1c8 100644 (file)
  * @version     1.0
  * @brief       client common for both of cs / wp
  */
-#include "client-common.h"
+#include "client/client-common.h"
 
 #include <exception>
 
-#include "audit/logger.h"
-#include "raw-buffer.h"
-#include "connection.h"
-#include "socket.h"
+#include "common/audit/logger.h"
+#include "common/raw-buffer.h"
+#include "common/connection.h"
+#include "common/socket.h"
 
 static void init_lib(void) __attribute__((constructor));
 static void init_lib(void)
index 6c45af8..f25712b 100644 (file)
@@ -25,7 +25,7 @@
 #include <string>
 
 #include "csr/error.h"
-#include "message-buffer.h"
+#include "common/message-buffer.h"
 
 
 namespace Csr {
index a560a01..6d32853 100644 (file)
 
 #include <functional>
 
-#include "message-buffer.h"
-#include "command-id.h"
-#include "audit/logger.h"
-#include "client-common.h"
+#include "common/message-buffer.h"
+#include "common/command-id.h"
+#include "common/audit/logger.h"
+#include "client/client-common.h"
 
 #define API __attribute__((visibility("default")))
 
index 147d7c1..f4a3c91 100644 (file)
@@ -21,7 +21,7 @@
  */
 #include "csr/engine-manager.h"
 
-#include "audit/logger.h"
+#include "common/audit/logger.h"
 
 #define API __attribute__((visibility("default")))
 
index 17755ff..ca10a34 100644 (file)
@@ -21,7 +21,7 @@
  */
 #include "csr/error.h"
 
-#include "audit/logger.h"
+#include "common/audit/logger.h"
 
 #define API __attribute__((visibility("default")))
 
index 3db2c50..b3d91e0 100644 (file)
 
 #include <functional>
 
-#include "message-buffer.h"
-#include "command-id.h"
-#include "audit/logger.h"
-#include "client-common.h"
+#include "common/message-buffer.h"
+#include "common/command-id.h"
+#include "common/audit/logger.h"
+#include "client/client-common.h"
 
 #define API __attribute__((visibility("default")))
 
index f2931b1..6ba3336 100644 (file)
@@ -73,13 +73,12 @@ private:
 
 #define ERROR(MESSAGE)  LOG(Error, MESSAGE)
 #define WARN(MESSAGE)   LOG(Warning, MESSAGE)
+#define INFO(MESSAGE)   LOG(Info, MESSAGE)
 
 #if !defined(NDEBUG)
-#define INFO(MESSAGE)   LOG(Info, MESSAGE)
 #define DEBUG(MESSAGE)  LOG(Debug, MESSAGE)
 #define TRACE(MESSAGE)  LOG(Trace, MESSAGE)
 #else
-#define INFO(MESSAGE)  do {} while (false)
 #define DEBUG(MESSAGE) do {} while (false)
 #define TRACE(MESSAGE) do {} while (false)
 #endif //NDEBUG
index 2ccbe23..070516d 100644 (file)
@@ -19,7 +19,7 @@
  * @version     1.0
  * @brief
  */
-#include "binary-queue.h"
+#include "common/binary-queue.h"
 
 #include <cstring>
 #include <cstddef>
index e283e94..578c9aa 100644 (file)
@@ -19,7 +19,7 @@
  * @version     1.0
  * @brief
  */
-#include "connection.h"
+#include "common/connection.h"
 
 #include <utility>
 
index b236d54..1af8f9a 100644 (file)
@@ -25,8 +25,8 @@
 #include <functional>
 #include <memory>
 
-#include "socket.h"
-#include "raw-buffer.h"
+#include "common/socket.h"
+#include "common/raw-buffer.h"
 
 namespace Csr {
 
similarity index 88%
rename from src/framework/main/mainloop.cpp
rename to src/framework/common/mainloop.cpp
index ec17726..5447a51 100644 (file)
@@ -19,7 +19,7 @@
  * @version     1.0
  * @brief       Mainloop of csr-server with epoll
  */
-#include "mainloop.h"
+#include "common/mainloop.h"
 
 #include <exception>
 #include <stdexcept>
 #include <sys/epoll.h>
 #include <unistd.h>
 
-#include "audit/logger.h"
+#include "common/audit/logger.h"
 
 namespace Csr {
 
 Mainloop::Mainloop() :
+       m_isTimedOut(false),
        m_pollfd(::epoll_create1(EPOLL_CLOEXEC))
 {
        if (m_pollfd == -1)
@@ -42,17 +43,22 @@ Mainloop::Mainloop() :
 
 Mainloop::~Mainloop()
 {
-       if (!m_callbacks.empty())
-               throw std::logic_error("m_callbacks shouldn't be empty");
+       if (!m_isTimedOut && !m_callbacks.empty())
+               throw std::logic_error("mainloop registered callbacks should be empty "
+                       "except timed out case");
 
        ::close(m_pollfd);
 }
 
-void Mainloop::run()
+void Mainloop::run(int timeout)
 {
-       while (true) {
-               dispatch(-1);
+       m_isTimedOut = false;
+
+       while (!m_isTimedOut) {
+               dispatch(timeout);
        }
+
+       DEBUG("Mainloop run stopped");
 }
 
 void Mainloop::addEventSource(int fd, uint32_t event, Callback &&callback)
@@ -113,6 +119,12 @@ void Mainloop::dispatch(int timeout)
                        std::error_code(errno, std::generic_category()),
                        "epoll_wait failed!");
 
+       if (nfds == 0) {
+               DEBUG("Mainloop timed out!");
+               m_isTimedOut = true;
+               return;
+       }
+
        for (int i = 0; i < nfds; i++) {
                /* TODO: use scoped-lock to thread safe on member variables */
                int fd = event[i].data.fd;
similarity index 97%
rename from src/framework/main/mainloop.h
rename to src/framework/common/mainloop.h
index ead51ff..46e2782 100644 (file)
@@ -39,7 +39,7 @@ public:
        Mainloop(Mainloop &&) = delete;
        Mainloop &operator=(Mainloop &&) = delete;
 
-       void run(void);
+       void run(int timeout);
 
        void addEventSource(int fd, uint32_t event, Callback &&callback);
        void removeEventSource(int fd);
@@ -47,6 +47,7 @@ public:
 private:
        void dispatch(int timeout);
 
+       bool m_isTimedOut;
        int m_pollfd;
        std::mutex m_mutex;
        std::unordered_map<int, Callback> m_callbacks;
index 328ca98..a06c585 100644 (file)
@@ -20,7 +20,7 @@
  * @version     1.0
  * @brief       Implementation of MessageBuffer.
  */
-#include "message-buffer.h"
+#include "common/message-buffer.h"
 
 #include <exception>
 #include <cstring>
index 0deb2bf..fe9d8e4 100644 (file)
@@ -22,9 +22,9 @@
  */
 #pragma once
 
-#include "raw-buffer.h"
-#include "binary-queue.h"
-#include "serialization.h"
+#include "common/raw-buffer.h"
+#include "common/binary-queue.h"
+#include "common/serialization.h"
 
 namespace Csr {
 
index d68066d..d06d62b 100644 (file)
 #include <vector>
 #include <list>
 #include <map>
+#include <unordered_map>
 #include <memory>
 
-#include "command-id.h"
+#include "common/command-id.h"
 #include "csr/error.h"
 
 namespace Csr {
 
 // Abstract data stream buffer
 class IStream {
-  public:
+public:
        virtual void read(size_t num, void * bytes) = 0;
        virtual void write(size_t num, const void * bytes) = 0;
        virtual ~IStream(){}
@@ -44,11 +45,11 @@ class IStream {
 
 // Serializable interface
 class ISerializable {
-  public:
-       /*    ISerializable(){};
-        *    ISerializable(IStream&){}; */
+public:
+       ISerializable() {}
+       ISerializable(IStream&) {}
        virtual void Serialize(IStream &) const = 0;
-       virtual ~ISerializable(){}
+       virtual ~ISerializable() {}
 };
 
 struct Serialization {
@@ -169,11 +170,10 @@ struct Serialization {
        template <typename T>
        static void Serialize(IStream& stream, const std::list<T>& list)
        {
-               int length = list.size();
+               size_t length = list.size();
                stream.write(sizeof(length), &length);
-               for (typename std::list<T>::const_iterator list_iter = list.begin();
-                        list_iter != list.end(); list_iter++)
-                       Serialize(stream, *list_iter);
+               for (const auto &item : list)
+                       Serialize(stream, item);
        }
        template <typename T>
        static void Serialize(IStream& stream, const std::list<T>* const list)
@@ -228,12 +228,11 @@ struct Serialization {
        template <typename K, typename T>
        static void Serialize(IStream& stream, const std::map<K, T>& map)
        {
-               int length = map.size();
+               size_t length = map.size();
                stream.write(sizeof(length), &length);
-               typename std::map<K, T>::const_iterator it;
-               for (it = map.begin(); it != map.end(); ++it) {
-                       Serialize(stream, (*it).first);
-                       Serialize(stream, (*it).second);
+               for (const auto &item : map) {
+                       Serialize(stream, item.first);
+                       Serialize(stream, item.second);
                }
        }
        template <typename K, typename T>
@@ -242,6 +241,23 @@ struct Serialization {
                Serialize(stream, *map);
        }
 
+       // std::unordered_map
+       template <typename K, typename T>
+       static void Serialize(IStream& stream, const std::unordered_map<K, T>& map)
+       {
+               size_t length = map.size();
+               stream.write(sizeof(length), &length);
+               for (const auto &item : map) {
+                       Serialize(stream, item.first);
+                       Serialize(stream, item.second);
+               }
+       }
+       template <typename K, typename T>
+       static void Serialize(IStream& stream, const std::unordered_map<K, T>* const map)
+       {
+               Serialize(stream, *map);
+       }
+
        // std::unique_ptr
        template <typename T>
        static void Serialize(IStream& stream, const std::unique_ptr<T>& p)
@@ -469,6 +485,28 @@ struct Deserialization {
                map = new std::map<K, T>;
                Deserialize(stream, *map);
        }
+
+       // std::unordered_map
+       template <typename K, typename T>
+       static void Deserialize(IStream& stream, std::unordered_map<K, T>& map)
+       {
+               size_t length;
+               stream.read(sizeof(length), &length);
+               for (size_t i = 0; i < length; ++i) {
+                       K key;
+                       T obj;
+                       Deserialize(stream, key);
+                       Deserialize(stream, obj);
+                       map[key] = std::move(obj);
+               }
+       }
+       template <typename K, typename T>
+       static void Deserialize(IStream& stream, std::unordered_map<K, T>*& map)
+       {
+               map = new std::map<K, T>;
+               Deserialize(stream, *map);
+       }
+
 }; // struct Deserialization
 
 // generic serialization
similarity index 84%
rename from src/framework/service/service.cpp
rename to src/framework/common/service.cpp
index 657754b..e1432bc 100644 (file)
  * @version     1.0
  * @brief
  */
-#include "service.h"
+#include "common/service.h"
 
 #include <sys/types.h>
 #include <sys/epoll.h>
 
-#include "audit/logger.h"
+#include "common/audit/logger.h"
 
 namespace Csr {
 
-Service::Service(const std::string &address) :
-       m_loop(),
-       m_address(address)
+Service::Service(const std::string &address) : m_address(address)
 {
        DEBUG("Service constructed with address[" << address << "]");
 
@@ -42,13 +40,13 @@ Service::~Service()
 {
 }
 
-void Service::start()
+void Service::start(int timeout)
 {
        INFO("Service start!");
 
        Socket socket(m_address);
 
-       DEBUG("Get server socket[" << socket.getFd()
+       DEBUG("Get systemd socket[" << socket.getFd()
                << "] with address[" << m_address << "]");
 
        m_loop.addEventSource(socket.getFd(), EPOLLIN | EPOLLHUP | EPOLLRDHUP,
@@ -59,7 +57,7 @@ void Service::start()
                        m_onNewConnection(std::make_shared<Connection>(socket.accept()));
                });
 
-       m_loop.run();
+       m_loop.run(timeout);
 }
 
 void Service::stop()
@@ -72,7 +70,7 @@ void Service::setNewConnectionCallback(const ConnCallback &/*callback*/)
        /* TODO: scoped-lock */
        m_onNewConnection = [&](const ConnShPtr &connection) {
                if (!connection)
-                       throw std::logic_error("onNewCOnnection called but ConnShPtr is nullptr.");
+                       throw std::logic_error("onNewConnection called but ConnShPtr is nullptr.");
 
                int fd = connection->getFd();
 
@@ -135,18 +133,4 @@ void Service::setCloseConnectionCallback(const ConnCallback &/*callback*/)
        };
 }
 
-void Service::onMessageProcess(const ConnShPtr &connection)
-{
-       DEBUG("let's dispatch it to worker threads.");
-
-       auto process = [&]() {
-               auto reply = m_logic.dispatch(connection->receive());
-
-               connection->send(reply);
-       };
-
-       /* TODO: submit to workqueue */
-       process();
-}
-
 }
similarity index 71%
rename from src/framework/service/service.h
rename to src/framework/common/service.h
index aaa7d5d..1f323b5 100644 (file)
 #pragma once
 
 #include <string>
-#include <memory>
 #include <functional>
 
-#include "connection.h"
-#include "mainloop.h"
-#include "logic.h"
+#include "common/connection.h"
+#include "common/mainloop.h"
 
 namespace Csr {
 
@@ -38,15 +36,20 @@ public:
        Service(const std::string &address);
        virtual ~Service();
 
-       void start(void);
-       void stop(void);
+       Service(const Service &) = delete;
+       Service &operator=(const Service &) = delete;
+       Service(Service &&) = delete;
+       Service &operator=(Service &&) = delete;
+
+       virtual void start(int timeout) final;
+       virtual void stop(void) final;
 
        /* ConnCallback param should throw exception to handle error */
-       void setNewConnectionCallback(const ConnCallback &);
-       void setCloseConnectionCallback(const ConnCallback &);
+       virtual void setNewConnectionCallback(const ConnCallback &) final;
+       virtual void setCloseConnectionCallback(const ConnCallback &) final;
 
 private:
-       void onMessageProcess(const ConnShPtr &);
+       virtual void onMessageProcess(const ConnShPtr &) = 0;
 
        ConnCallback m_onNewConnection;
        ConnCallback m_onCloseConnection;
@@ -54,8 +57,6 @@ private:
        std::unordered_map<int, ConnShPtr> m_connectionRegistry;
        Mainloop m_loop;
        std::string m_address;
-
-       Logic m_logic;
 };
 
 }
index ef03722..6403398 100644 (file)
@@ -19,7 +19,7 @@
  * @version     1.0
  * @brief
  */
-#include "socket.h"
+#include "common/socket.h"
 
 #include <exception>
 #include <system_error>
@@ -31,7 +31,7 @@
 
 #include <systemd/sd-daemon.h>
 
-#include "audit/logger.h"
+#include "common/audit/logger.h"
 
 namespace {
 
index c8c24d0..fcbffe1 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <string>
 
-#include "raw-buffer.h"
+#include "common/raw-buffer.h"
 
 namespace Csr {
 
index 9bb89e1..0ae6536 100644 (file)
  * @version     1.0
  * @brief       Main of csr daemon
  */
-#include "service.h"
+#include "service/server-service.h"
 
-#include "audit/logger.h"
+#include "common/audit/logger.h"
 
 int main(void)
 {
        try {
                INFO("Start csr-server main!");
 
-               Csr::Service service("/tmp/." SERVICE_NAME ".socket");
+               Csr::ServerService service("/tmp/." SERVICE_NAME ".socket");
 
                INFO("Let's start csr-server service!");
 
-               service.start();
+               /* no timeout */
+               service.start(-1);
 
                return 0;
        } catch (const std::exception &e) {
index 803b7ca..8a33898 100644 (file)
  * @version     1.0
  * @brief
  */
-#include "logic.h"
+#include "service/logic.h"
 
 #include <string>
 #include <utility>
 #include <stdexcept>
 
-#include "audit/logger.h"
+#include "common/audit/logger.h"
 #include "csr/error.h"
 
 namespace Csr {
@@ -79,17 +79,15 @@ std::pair<CommandId, MessageBuffer> Logic::getRequestInfo(const RawBuffer &data)
 
 RawBuffer Logic::scanFile(const std::string &filepath)
 {
-       (void) filepath;
+       INFO("Scan file[" << filepath << "] by engine");
 
-       DEBUG("Scan file[" << filepath << "] by engine");
        return MessageBuffer::Serialize(CSR_ERROR_NONE).pop();
 }
 
 RawBuffer Logic::checkUrl(const std::string &url)
 {
-       (void) url;
+       INFO("Check url[" << url << "] by engine");
 
-       DEBUG("CHeck url[" << url << "] by engine");
        return MessageBuffer::Serialize(CSR_ERROR_NONE).pop();
 }
 
index 4f3dbb3..78111f2 100644 (file)
@@ -24,9 +24,9 @@
 #include <string>
 #include <utility>
 
-#include "command-id.h"
-#include "raw-buffer.h"
-#include "message-buffer.h"
+#include "common/command-id.h"
+#include "common/raw-buffer.h"
+#include "common/message-buffer.h"
 
 namespace Csr {
 
diff --git a/src/framework/service/server-service.cpp b/src/framework/service/server-service.cpp
new file mode 100644 (file)
index 0000000..e445b11
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  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        server-service.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#include "service/server-service.h"
+
+#include "common/audit/logger.h"
+
+namespace Csr {
+
+ServerService::ServerService(const std::string &address) : Service(address)
+{
+}
+
+ServerService::~ServerService()
+{
+}
+
+void ServerService::onMessageProcess(const ConnShPtr &connection)
+{
+       DEBUG("let's dispatch it to worker threads.");
+
+       auto process = [&]() {
+               auto reply = m_logic.dispatch(connection->receive());
+
+               connection->send(reply);
+       };
+
+       /* TODO: submit to workqueue */
+       process();
+}
+
+}
diff --git a/src/framework/service/server-service.h b/src/framework/service/server-service.h
new file mode 100644 (file)
index 0000000..790dc42
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *  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        server-service.h
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#pragma once
+
+#include "common/service.h"
+#include "service/logic.h"
+
+namespace Csr {
+
+class ServerService : public Service {
+public:
+       ServerService(const std::string &address);
+       virtual ~ServerService();
+
+private:
+       virtual void onMessageProcess(const ConnShPtr &) override;
+
+       Logic m_logic;
+};
+
+}
diff --git a/src/framework/ui/CMakeLists.txt b/src/framework/ui/CMakeLists.txt
new file mode 100644 (file)
index 0000000..874139c
--- /dev/null
@@ -0,0 +1,19 @@
+# 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        CMakeLists.txt
+# @author      Kyungwook Tak (k.tak@samsung.com)
+# @brief
+#
+ADD_SUBDIRECTORY(popup)
diff --git a/src/framework/ui/askuser.cpp b/src/framework/ui/askuser.cpp
new file mode 100644 (file)
index 0000000..da442a6
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ *  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        askuser.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       Ask user and get response to handle screening result
+ */
+#include "ui/askuser.h"
+
+#include "common/raw-buffer.h"
+#include "common/message-buffer.h"
+#include "common/connection.h"
+#include "common/socket.h"
+#include "common/audit/logger.h"
+
+namespace Csr {
+namespace Ui {
+
+namespace {
+
+inline Csr::Connection makeConnection(const std::string &address)
+{
+       DEBUG("Try to make connection to csr-popup service");
+
+       return Csr::Connection(Csr::Socket::connect(address));
+}
+
+inline Csr::Connection makeConnection(void)
+{
+       return makeConnection("/tmp/." SERVICE_NAME "-popup.socket");
+}
+
+inline Csr::RawBuffer dispatch(const Csr::Connection &connection, const Csr::RawBuffer &buf)
+{
+       DEBUG("Try to dispatch to csr-popup service");
+
+       connection.send(buf);
+
+       DEBUG("Wait for response from csr-popup service");
+
+       return connection.receive();
+}
+
+Response ask(const RawBuffer &buf)
+{
+       auto conn = makeConnection();
+
+       auto reply = dispatch(conn, buf);
+
+       Csr::MessageBuffer msg;
+       msg.push(reply);
+
+       int int_response;
+       msg.Deserialize(int_response);
+       return static_cast<Response>(int_response);
+}
+
+ResponseMap askMultiple(const RawBuffer &buf)
+{
+       auto conn = makeConnection();
+
+       auto reply = dispatch(conn, buf);
+
+       Csr::MessageBuffer msg;
+       msg.push(reply);
+
+       ResponseMap responseMap;
+       msg.Deserialize(responseMap);
+
+       return responseMap;
+}
+
+} // namespace Csr::Ui::anonymous
+
+AskUser::AskUser()
+{
+}
+
+AskUser::~AskUser()
+{
+}
+
+
+Response AskUser::fileSingle(const std::string &message, const FileItem &item) const
+{
+       auto inbuf = Csr::MessageBuffer::Serialize(
+                       static_cast<int>(CommandId::FILE_SINGLE),
+                       message,
+                       item).pop();
+
+       return ask(inbuf);
+}
+
+ResponseMap AskUser::fileMultiple(const std::string &message, const FileItems &items) const
+{
+       auto inbuf = Csr::MessageBuffer::Serialize(
+                       static_cast<int>(CommandId::FILE_MULTIPLE),
+                       message,
+                       items).pop();
+
+       return askMultiple(inbuf);
+}
+
+Response AskUser::urlSingle(const std::string &message, const UrlItem &item) const
+{
+       auto inbuf = Csr::MessageBuffer::Serialize(
+                       static_cast<int>(CommandId::URL_SINGLE),
+                       message,
+                       item).pop();
+
+       return ask(inbuf);
+}
+
+ResponseMap AskUser::urlMultiple(const std::string &message, const UrlItems &items) const
+{
+       auto inbuf = Csr::MessageBuffer::Serialize(
+                       static_cast<int>(CommandId::URL_MULTIPLE),
+                       message,
+                       items).pop();
+
+       return askMultiple(inbuf);
+}
+
+} // namespace Ui
+} // namespace Csr
diff --git a/src/framework/ui/askuser.h b/src/framework/ui/askuser.h
new file mode 100644 (file)
index 0000000..93b63d4
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  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        askuser.h
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       Ask user and get response to handle screening result
+ */
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "ui/common.h"
+#include "csr/content-screening-types.h"
+#include "csr/web-protection-types.h"
+
+namespace Csr {
+namespace Ui {
+
+class AskUser {
+public:
+       AskUser();
+       virtual ~AskUser();
+
+       AskUser(const AskUser &) = delete;
+       AskUser &operator=(const AskUser &) = delete;
+
+       Response fileSingle(const std::string &message, const FileItem &item) const;
+       ResponseMap fileMultiple(const std::string &message, const FileItems &items) const;
+       Response urlSingle(const std::string &message, const UrlItem &item) const;
+       ResponseMap urlMultiple(const std::string &message, const UrlItems &items) const;
+};
+
+}
+}
diff --git a/src/framework/ui/common.cpp b/src/framework/ui/common.cpp
new file mode 100644 (file)
index 0000000..ed024fc
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ *  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        common.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       Common data structs for popup-service and csr-server
+ */
+#include "ui/common.h"
+
+namespace Csr {
+namespace Ui {
+
+FileItem::FileItem(IStream &stream)
+{
+       int int_severity;
+       Deserializer<int>::Deserialize(stream, int_severity);
+       severity = static_cast<csr_cs_severity_level_e>(int_severity);
+
+       int int_threat;
+       Deserializer<int>::Deserialize(stream, int_threat);
+       threat = static_cast<csr_cs_threat_type_e>(int_threat);
+
+       Deserializer<std::string>::Deserialize(stream, filepath);
+}
+
+void FileItem::Serialize(IStream &stream) const
+{
+       Serializer<int>::Serialize(stream, static_cast<int>(severity));
+       Serializer<int>::Serialize(stream, static_cast<int>(threat));
+       Serializer<std::string>::Serialize(stream, filepath);
+}
+
+UrlItem::UrlItem(IStream &stream)
+{
+       int int_risk;
+       Deserializer<int>::Deserialize(stream, int_risk);
+       risk = static_cast<csr_wp_risk_level_e>(int_risk);
+
+       Deserializer<std::string>::Deserialize(stream, url);
+}
+
+void UrlItem::Serialize(IStream &stream) const
+{
+       Serializer<int>::Serialize(stream, static_cast<int>(risk));
+       Serializer<std::string>::Serialize(stream, url);
+}
+
+}
+}
diff --git a/src/framework/ui/common.h b/src/framework/ui/common.h
new file mode 100644 (file)
index 0000000..28618e6
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ *  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        common.h
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       Common data structs for popup-service and csr-server
+ */
+#pragma once
+
+#include <string>
+#include <vector>
+#include <unordered_map>
+
+#include "common/serialization.h"
+
+#include "csr/content-screening-types.h"
+#include "csr/web-protection-types.h"
+
+namespace Csr {
+namespace Ui {
+
+enum class CommandId : int {
+       FILE_SINGLE   = 0x01,
+       FILE_MULTIPLE = 0x02,
+       URL_SINGLE    = 0x03,
+       URL_MULTIPLE  = 0x04
+};
+
+enum class Response : int {
+       /* For url access on web protection */
+       ALLOW   = 0x01,
+       DENY    = 0x02,
+       CONFIRM = 0x03,
+
+       /* For content screening detected item handling */
+       REMOVE  = 0x04,
+       IGNORE  = 0x05,
+       SKIP    = 0x06
+};
+
+struct FileItem : public ISerializable {
+       FileItem() {}
+       virtual ~FileItem() {}
+       FileItem(IStream &);
+       virtual void Serialize(IStream &) const override;
+
+       csr_cs_severity_level_e severity;
+       csr_cs_threat_type_e threat;
+       std::string filepath;
+};
+
+struct UrlItem : public ISerializable {
+       UrlItem() {}
+       virtual ~UrlItem() {}
+       UrlItem(IStream &);
+       virtual void Serialize(IStream &) const override;
+
+       csr_wp_risk_level_e risk;
+       std::string url;
+};
+
+using FileItems = std::vector<FileItem>;
+using UrlItems = std::vector<UrlItem>;
+using ResponseMap = std::unordered_map<std::string, int>;
+
+}
+}
diff --git a/src/framework/ui/popup/CMakeLists.txt b/src/framework/ui/popup/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0e25d17
--- /dev/null
@@ -0,0 +1,54 @@
+# 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     CMakeLists.txt
+# @author   Janusz Kozerski (j.kozerski@samsung.com)
+# @version  1.0
+#
+PKG_CHECK_MODULES(${TARGET_CSR_POPUP}_DEP
+       REQUIRED
+       elementary
+       libsystemd-daemon
+       vconf
+)
+
+INCLUDE_DIRECTORIES(
+       ${${TARGET_CSR_POPUP}_DEP_INCLUDE_DIRS}
+       .
+       ${PROJECT_SOURCE_DIR}/src/framework
+)
+
+SET(${TARGET_CSR_POPUP}_SRCS
+       main.cpp
+       logic.cpp
+       popup.cpp
+       popup-service.cpp
+       ${PROJECT_SOURCE_DIR}/src/framework/ui/common.cpp
+)
+
+SET_SOURCE_FILES_PROPERTIES(${${TARGET_CSR_POPUP}_SRCS}
+       PROPERTIES
+               COMPILE_FLAGS "-D_GNU_SOURCE -fPIE"
+               LINK_FLAGS "-pie"
+)
+
+ADD_EXECUTABLE(${TARGET_CSR_POPUP} ${${TARGET_CSR_POPUP}_SRCS})
+
+TARGET_LINK_LIBRARIES(${TARGET_CSR_POPUP}
+       ${${TARGET_CSR_POPUP}_DEP_LIBRARIES}
+       ${TARGET_CSR_COMMON}
+)
+
+INSTALL(TARGETS ${TARGET_CSR_POPUP} DESTINATION ${BIN_DIR})
diff --git a/src/framework/ui/popup/logic.cpp b/src/framework/ui/popup/logic.cpp
new file mode 100644 (file)
index 0000000..ab74f84
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ *  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        logic.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       Logic for popup service
+ */
+#include "logic.h"
+
+#include <stdexcept>
+#include <functional>
+#include <unordered_map>
+#include <Elementary.h>
+
+#include "common/message-buffer.h"
+#include "common/raw-buffer.h"
+#include "common/audit/logger.h"
+#include "ui/common.h"
+
+namespace Csr {
+namespace Ui {
+
+namespace {
+
+std::unordered_map<int, std::function<void()>> g_callbackRegistry;
+
+void evasCbWrapper(void *data, Evas_Object *, void *)
+{
+       auto response = reinterpret_cast<int *>(data);
+       g_callbackRegistry[*response]();
+}
+
+void registerCb(Evas_Object *button, int *response, std::function<void()> &&func)
+{
+       evas_object_smart_callback_add(button, "clicked", evasCbWrapper, response);
+       g_callbackRegistry[*response] = std::move(func);
+}
+
+void unregisterCb(int response)
+{
+       g_callbackRegistry.erase(response);
+}
+
+} // namespace anonymous
+
+Logic::Logic()
+{
+}
+
+Logic::~Logic()
+{
+}
+
+RawBuffer Logic::dispatch(const RawBuffer &in)
+{
+       auto info = getRequestInfo(in);
+       INFO("Request dispatch on popup-service. CommandId: " << static_cast<int>(info.first));
+
+       switch (info.first) {
+       case CommandId::FILE_SINGLE: {
+               std::string message;
+               FileItem item;
+               info.second.Deserialize(message, item);
+
+               return fileSingle(message, item);
+       }
+
+       case CommandId::FILE_MULTIPLE: {
+               std::string message;
+               FileItems items;
+               info.second.Deserialize(message, items);
+
+               return fileMultiple(message, items);
+       }
+
+       case CommandId::URL_SINGLE: {
+               std::string message;
+               UrlItem item;
+               info.second.Deserialize(message, item);
+
+               return urlSingle(message, item);
+       }
+
+       case CommandId::URL_MULTIPLE: {
+               std::string message;
+               UrlItems items;
+               info.second.Deserialize(message, items);
+
+               return urlMultiple(message, items);
+       }
+
+       default:
+               throw std::logic_error("Protocol error. unknown popup-service command id.");
+       }
+}
+
+std::pair<CommandId, MessageBuffer> Logic::getRequestInfo(const RawBuffer &data)
+{
+       int int_id;
+       MessageBuffer msg;
+       msg.push(data);
+       msg.Deserialize(int_id);
+
+       return std::make_pair(static_cast<CommandId>(int_id), std::move(msg));
+}
+
+RawBuffer Logic::fileSingle(const std::string &message, const FileItem &item) const
+{
+       INFO("fileSingle start with param.. "
+               "message[" << message << "] "
+               "filepath[" << item.filepath << "] "
+               "severity[" << static_cast<int>(item.severity) << "] "
+               "threat[" << static_cast<int>(item.threat) << "]");
+
+       Popup popup;
+
+       popup.fillText("FileSingle title", message.c_str());
+
+       MessageBuffer msg;
+
+       auto respRemove = static_cast<int>(Response::REMOVE);
+       Evas_Object *remove = popup.addButton("button1");
+       elm_object_text_set(remove, "remove");
+       registerCb(remove, &respRemove, [&msg, &respRemove, &popup]() {
+               DEBUG("Remove button clicked!");
+               msg = MessageBuffer::Serialize(respRemove);
+               popup.stop();
+       });
+
+       auto respIgnore = static_cast<int>(Response::IGNORE);
+       Evas_Object *ignore = popup.addButton("button2");
+       elm_object_text_set(ignore, "ignore");
+       registerCb(ignore, &respIgnore, [&msg, &respIgnore, &popup]() {
+               DEBUG("Ignore button clicked!");
+               msg = MessageBuffer::Serialize(respIgnore);
+               popup.stop();
+       });
+
+       auto respSkip = static_cast<int>(Response::SKIP);
+       Evas_Object *skip = popup.addButton("button3");
+       elm_object_text_set(skip, "skip");
+       registerCb(skip, &respSkip, [&msg, &respSkip, &popup]() {
+               DEBUG("Skip button clicked!");
+               msg = MessageBuffer::Serialize(respSkip);
+               popup.stop();
+       });
+
+       popup.start();
+
+       DEBUG("fileSingle done!");
+
+       unregisterCb(respRemove);
+       unregisterCb(respIgnore);
+       unregisterCb(respSkip);
+
+       return msg.pop();
+}
+
+RawBuffer Logic::fileMultiple(const std::string &message, const FileItems &items) const
+{
+       (void) message;
+       (void) items;
+       return RawBuffer();
+}
+
+RawBuffer Logic::urlSingle(const std::string &message, const UrlItem &item) const
+{
+       INFO("urlSingle start with param.. "
+               "message[" << message << "] "
+               "url[" << item.url << "] "
+               "risk level[" << static_cast<int>(item.risk) << "]");
+
+       Popup popup;
+
+       popup.fillText("FileSingle title", message.c_str());
+
+       MessageBuffer msg;
+
+       auto respAllow = static_cast<int>(Response::ALLOW);
+       Evas_Object *allow = popup.addButton("button1");
+       elm_object_text_set(allow, "allow");
+       registerCb(allow, &respAllow, [&msg, &respAllow, &popup]() {
+               DEBUG("Allow button clicked!");
+               msg = MessageBuffer::Serialize(respAllow);
+               popup.stop();
+       });
+
+       auto respDeny = static_cast<int>(Response::DENY);
+       Evas_Object *deny = popup.addButton("button2");
+       elm_object_text_set(deny, "deny");
+       registerCb(deny, &respDeny, [&msg, &respDeny, &popup]() {
+               DEBUG("Deny button clicked!");
+               msg = MessageBuffer::Serialize(respDeny);
+               popup.stop();
+       });
+
+       popup.start();
+
+       DEBUG("urlSingle done!");
+
+       unregisterCb(respAllow);
+       unregisterCb(respDeny);
+
+       return msg.pop();
+}
+
+RawBuffer Logic::urlMultiple(const std::string &message, const UrlItems &items) const
+{
+       (void) message;
+       (void) items;
+       return RawBuffer();
+}
+
+}
+}
diff --git a/src/framework/ui/popup/logic.h b/src/framework/ui/popup/logic.h
new file mode 100644 (file)
index 0000000..f2808b8
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  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        logic.h
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       Logic for popup service
+ */
+#pragma once
+
+#include <string>
+#include <functional>
+#include <utility>
+
+#include "common/raw-buffer.h"
+#include "common/message-buffer.h"
+#include "ui/common.h"
+#include "popup.h"
+
+namespace Csr {
+namespace Ui {
+
+class Logic {
+public:
+       Logic();
+       virtual ~Logic();
+
+       RawBuffer dispatch(const RawBuffer &);
+
+private:
+       std::pair<CommandId, MessageBuffer> getRequestInfo(const RawBuffer &);
+
+       RawBuffer fileSingle(const std::string &message, const FileItem &item) const;
+       RawBuffer fileMultiple(const std::string &message, const FileItems &items) const;
+       RawBuffer urlSingle(const std::string &message, const UrlItem &item) const;
+       RawBuffer urlMultiple(const std::string &message, const UrlItems &items) const;
+};
+
+}
+}
diff --git a/src/framework/ui/popup/main.cpp b/src/framework/ui/popup/main.cpp
new file mode 100644 (file)
index 0000000..b41b263
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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        main.cpp
+ * @author      Janusz Kozerski (j.kozerski@samsung.com)
+ *              Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       Popup service main
+ */
+#include <stdexcept>
+
+#include <vconf.h>
+#include <Elementary.h>
+#include <Ecore.h>
+
+#include "common/audit/logger.h"
+#include "popup-service.h"
+
+namespace {
+
+struct ElmRaii {
+       ElmRaii(int argc, char **argv)
+       {
+               DEBUG("elm_init()");
+               elm_init(argc, argv);
+       }
+
+       virtual ~ElmRaii()
+       {
+               DEBUG("elm_shutdown()");
+               /* TODO: do shutdown.
+                *   shutdown generates segmentation fault by unknown reason.
+                */
+//             elm_shutdown();
+       }
+};
+
+} // namespace anonymous
+
+int main(int argc, char **argv)
+{
+       try {
+               Csr::Audit::Logger::setTag("CSR_POPUP");
+
+               INFO("CSR popup service start!");
+
+               /* init/shutdown elm automatically */
+               ElmRaii elmRaii(argc, argv);
+
+               setlocale(LC_ALL, vconf_get_str(VCONFKEY_LANGSET));
+
+               Csr::Ui::PopupService service("/tmp/." SERVICE_NAME "-popup.socket");
+
+               service.start(0);
+
+               return 0;
+       } catch (const std::exception &e) {
+               ERROR("std exception: " << e.what());
+               return -1;
+       } catch (...) {
+               ERROR("Unhandled exception occured!");
+               return -1;
+       }
+}
diff --git a/src/framework/ui/popup/popup-service.cpp b/src/framework/ui/popup/popup-service.cpp
new file mode 100644 (file)
index 0000000..24f1aea
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  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        popup-service.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#include "popup-service.h"
+
+#include "common/audit/logger.h"
+
+namespace Csr {
+namespace Ui {
+
+PopupService::PopupService(const std::string &address) : Service(address)
+{
+}
+
+PopupService::~PopupService()
+{
+}
+
+void PopupService::onMessageProcess(const ConnShPtr &connection)
+{
+       DEBUG("process message on popup service");
+
+       auto reply = m_logic.dispatch(connection->receive());
+
+       connection->send(reply);
+
+       DEBUG("process done on popup service");
+}
+
+} // namespace Ui
+} // namespace Csr
diff --git a/src/framework/ui/popup/popup-service.h b/src/framework/ui/popup/popup-service.h
new file mode 100644 (file)
index 0000000..4b506d3
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  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        popup-service.h
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#pragma once
+
+#include <string>
+
+#include "common/service.h"
+#include "logic.h"
+
+namespace Csr {
+namespace Ui {
+
+class PopupService : public Service {
+public:
+       PopupService(const std::string &address);
+       virtual ~PopupService();
+
+private:
+       virtual void onMessageProcess(const ConnShPtr &) override;
+       Logic m_logic;
+};
+
+} // namespace Ui
+} // namespace Csr
diff --git a/src/framework/ui/popup/popup.cpp b/src/framework/ui/popup/popup.cpp
new file mode 100644 (file)
index 0000000..fe22457
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ *  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        popup.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#include "popup.h"
+
+#include <stdexcept>
+
+#include "common/audit/logger.h"
+
+namespace Csr {
+namespace Ui {
+
+Popup::Popup()
+{
+       Evas_Object *win = elm_win_add(nullptr, "CSR popup", ELM_WIN_NOTIFICATION);
+       elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_TRANSLUCENT);
+       elm_win_borderless_set(win, EINA_TRUE);
+       elm_win_alpha_set(win, EINA_TRUE);
+
+       Evas_Object *popup = elm_popup_add(win);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       m_win = win;
+       m_popup = popup;
+}
+
+Popup::~Popup()
+{
+}
+
+void Popup::stop()
+{
+       if (m_popup)
+               evas_object_del(m_popup);
+       if (m_win)
+               evas_object_del(m_win);
+       elm_exit();
+}
+
+void Popup::start()
+{
+       evas_object_show(m_win);
+       evas_object_show(m_popup);
+
+       DEBUG("Popup UI event loop start!");
+
+       elm_run();
+}
+
+void Popup::fillText(const char *title, const char *content)
+{
+       elm_object_part_text_set(m_popup, "title,text", title);
+       elm_object_text_set(m_popup, content);
+}
+
+Evas_Object *Popup::addButton(const char *part)
+{
+       Evas_Object *button = elm_button_add(m_popup);
+       elm_object_style_set(button, "bottom");
+       elm_object_part_content_set(m_popup, part, button);
+       evas_object_show(button);
+
+       return button;
+}
+
+}
+}
diff --git a/src/framework/ui/popup/popup.h b/src/framework/ui/popup/popup.h
new file mode 100644 (file)
index 0000000..e4a13e7
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  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        popup.h
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#pragma once
+
+#include <Elementary.h>
+
+namespace Csr {
+namespace Ui {
+
+class Popup {
+public:
+       Popup();
+       virtual ~Popup();
+
+       /* fill text on popup */
+       void fillText(const char *title, const char *content);
+
+       /* add button to popup on given part of */
+       Evas_Object *addButton(const char *part);
+
+       void start(void);
+       void stop(void);
+
+private:
+       Evas_Object *m_win;
+       Evas_Object *m_popup;
+};
+
+}
+}
index 76d6dd3..eecae85 100644 (file)
@@ -1,10 +1,13 @@
 CONFIGURE_FILE(${SERVICE_NAME}.service.in ${SERVICE_NAME}.service @ONLY)
 CONFIGURE_FILE(${SERVICE_NAME}.socket.in ${SERVICE_NAME}.socket @ONLY)
+CONFIGURE_FILE(${SERVICE_NAME}-popup.service.in ${SERVICE_NAME}-popup.service @ONLY)
+CONFIGURE_FILE(${SERVICE_NAME}-popup.socket.in ${SERVICE_NAME}-popup.socket @ONLY)
 
 INSTALL(
        FILES
                ${SERVICE_NAME}.service
                ${SERVICE_NAME}.socket
+               ${SERVICE_NAME}-popup.service
+               ${SERVICE_NAME}-popup.socket
        DESTINATION ${SYSTEMD_UNIT_DIR}
 )
-
diff --git a/systemd/csr-popup.service.in b/systemd/csr-popup.service.in
new file mode 100644 (file)
index 0000000..9e2d6d4
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=CSR popup service for user session
+
+[Service]
+User=app
+Group=app
+Type=simple
+SmackProcessLabel=@SERVICE_NAME@
+EnvironmentFile=/run/tizen-mobile-env
+ExecStart=@BIN_DIR@/@SERVICE_NAME@-popup
+Sockets=@SERVICE_NAME@-popup.socket
+
+[Install]
+WantedBy=default.target
diff --git a/systemd/csr-popup.socket.in b/systemd/csr-popup.socket.in
new file mode 100644 (file)
index 0000000..9fa153d
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description= Csr popup socket
+Wants=@SERVICE_NAME@-popup.service
+Before=@SERVICE_NAME@-popup.service
+
+[Socket]
+ListenStream=/tmp/.@SERVICE_NAME@-popup.socket
+Service=@SERVICE_NAME@-popup.service
+SocketMode=0777
+SmackLabelIPIn=@SERVICE_NAME@
+SmackLabelIPOut=@SERVICE_NAME@
+
+[Install]
+WantedBy=sockets.target
index fa338b9..bea5d44 100644 (file)
@@ -52,3 +52,5 @@ TARGET_LINK_LIBRARIES(${TARGET_CSR_TEST}
 
 INSTALL(TARGETS ${TARGET_CSR_TEST} DESTINATION ${BIN_DIR})
 INSTALL(DIRECTORY resources/ DESTINATION ${TEST_DIR})
+
+ADD_SUBDIRECTORY(popup)
diff --git a/test/popup/CMakeLists.txt b/test/popup/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e2d5a0e
--- /dev/null
@@ -0,0 +1,47 @@
+# 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        CMakeLists.txt
+# @author      Kyungwook Tak (k.tak@samsung.com)
+# @brief       build test program of csr-popup
+#
+PKG_CHECK_MODULES(${TARGET_CSR_POPUP_TEST}_DEP
+       REQUIRED
+)
+
+SET(${TARGET_CSR_POPUP_TEST}_SRCS
+       ${PROJECT_SOURCE_DIR}/src/framework/ui/askuser.cpp
+       ${PROJECT_SOURCE_DIR}/src/framework/ui/common.cpp
+       ${PROJECT_SOURCE_DIR}/test/colour_log_formatter.cpp
+       test-main.cpp
+       test-popup.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${PROJECT_SOURCE_DIR}/src/include
+       ${PROJECT_SOURCE_DIR}/src/framework
+       ${PROJECT_SOURCE_DIR}/test
+       .
+       ${${TARGET_CSR_POPUP_TEST}_DEP_INCLUDE_DIRS}
+)
+
+ADD_EXECUTABLE(${TARGET_CSR_POPUP_TEST} ${${TARGET_CSR_POPUP_TEST}_SRCS})
+
+TARGET_LINK_LIBRARIES(${TARGET_CSR_POPUP_TEST}
+       ${TARGET_CSR_COMMON}
+       boost_unit_test_framework
+       -ldl
+)
+
+INSTALL(TARGETS ${TARGET_CSR_POPUP_TEST} DESTINATION ${BIN_DIR})
diff --git a/test/popup/test-main.cpp b/test/popup/test-main.cpp
new file mode 100644 (file)
index 0000000..7c0a740
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  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       test-main.cpp
+ * @author     Kyungwook Tak(k.tak@samsung.com)
+ * @version    1.0
+ * @brief      CSR popup service test main
+ */
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/unit_test_log.hpp>
+#include <boost/test/results_reporter.hpp>
+#include <colour_log_formatter.h>
+
+struct TestConfig {
+       TestConfig()
+       {
+               boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_test_units);
+               boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);
+               boost::unit_test::unit_test_log.set_formatter(new Csr::Test::colour_log_formatter);
+       }
+};
+
+BOOST_GLOBAL_FIXTURE(TestConfig)
diff --git a/test/popup/test-popup.cpp b/test/popup/test-popup.cpp
new file mode 100644 (file)
index 0000000..7c863dd
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ *  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        test-popup.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       CSR popup service test
+ */
+#define BOOST_TEST_MODULE CSR_POPUP_TEST
+#include "ui/askuser.h"
+#include "ui/common.h"
+
+#include <string>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+using namespace Csr::Ui;
+
+namespace {
+
+void printPressed(Response response)
+{
+       std::cout << "###################################################" << std::endl;
+       std::cout << "###################################################" << std::endl;
+       std::cout << "###################################################" << std::endl;
+
+       bool isValid = true;
+       switch (response) {
+       case Response::ALLOW:
+               std::cout << "##############  ALLOW BUTTON PRESSED  #############" << std::endl;
+               break;
+       case Response::DENY:
+               std::cout << "##############  DENY  BUTTON PRESSED  #############" << std::endl;
+               break;
+       case Response::CONFIRM:
+               std::cout << "############## CONFIRM BUTTON PRESSED #############" << std::endl;
+               break;
+       case Response::REMOVE:
+               std::cout << "############## REMOVE BUTTON PRESSED  #############" << std::endl;
+               break;
+       case Response::IGNORE:
+               std::cout << "############## IGNORE BUTTON PRESSED  #############" << std::endl;
+               break;
+       case Response::SKIP:
+               std::cout << "##############  SKIP  BUTTON PRESSED  #############" << std::endl;
+               break;
+       default:
+               std::cout << "############## Invalid Response!!!    #############" << std::endl;
+               isValid = false;
+               break;
+       }
+
+       std::cout << "###################################################" << std::endl;
+       std::cout << "###################################################" << std::endl;
+       std::cout << "###################################################" << std::endl;
+
+       BOOST_REQUIRE_MESSAGE(isValid, "invalid response from csr-popup!");
+}
+
+}
+
+BOOST_AUTO_TEST_SUITE(POPUP)
+
+BOOST_AUTO_TEST_CASE(file_single)
+{
+       try {
+               AskUser askuser;
+
+               FileItem item;
+               item.severity = CSR_CS_SEVERITY_MEDIUM;
+               item.threat = CSR_CS_THREAT_RISKY;
+               item.filepath = "/opt/apps/csr/test/dummyfile";
+
+               auto response = askuser.fileSingle("Message for file_single tc", item);
+               printPressed(response);
+       } catch (...) {
+               BOOST_REQUIRE_MESSAGE(0, "exception shouldn't be thrown.");
+       }
+}
+
+BOOST_AUTO_TEST_CASE(url_single)
+{
+       try {
+               AskUser askuser;
+
+               UrlItem item;
+               item.risk = CSR_WP_RISK_MEDIUM;
+               item.url = "http://csr.test.dummyurl.com";
+
+               auto response = askuser.urlSingle("Message for url_single tc", item);
+               printPressed(response);
+       } catch (...) {
+               BOOST_REQUIRE_MESSAGE(0, "exception shouldn't be thrown.");
+       }
+}
+
+BOOST_AUTO_TEST_SUITE_END()