usd: Remove USD 61/61061/2 submit/tizen_common/20160317.155115
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Tue, 1 Mar 2016 15:30:11 +0000 (16:30 +0100)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Thu, 3 Mar 2016 15:38:12 +0000 (16:38 +0100)
USD functionality is moved to deviced. This code is no longer needed.

Change-Id: Iec6f46134df8070d7dafb89b19eff5571e872605
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
70 files changed:
CMakeLists.txt
USD/CMakeLists.txt [deleted file]
USD/src/CMakeLists.txt [deleted file]
USD/src/client/client-common.cpp [deleted file]
USD/src/client/client-common.h [deleted file]
USD/src/client/usb-access-client.cpp [deleted file]
USD/src/client/usb-ask-user-client.cpp [deleted file]
USD/src/common/connection-info.h [deleted file]
USD/src/common/message-buffer.cpp [deleted file]
USD/src/common/message-buffer.h [deleted file]
USD/src/common/protocols.cpp [deleted file]
USD/src/common/protocols.h [deleted file]
USD/src/common/smack-check.cpp [deleted file]
USD/src/common/smack-check.h [deleted file]
USD/src/common/usb-access-map.cpp [deleted file]
USD/src/common/usb-access-map.h [deleted file]
USD/src/dpl/core/include/dpl/assert.h [deleted file]
USD/src/dpl/core/include/dpl/binary_queue.h [deleted file]
USD/src/dpl/core/include/dpl/colors.h [deleted file]
USD/src/dpl/core/include/dpl/exception.h [deleted file]
USD/src/dpl/core/include/dpl/fstream_accessors.h [deleted file]
USD/src/dpl/core/include/dpl/noncopyable.h [deleted file]
USD/src/dpl/core/include/dpl/noreturn.h [deleted file]
USD/src/dpl/core/include/dpl/serialization.h [deleted file]
USD/src/dpl/core/include/dpl/singleton.h [deleted file]
USD/src/dpl/core/include/dpl/singleton_impl.h [deleted file]
USD/src/dpl/core/include/dpl/singleton_safe_impl.h [deleted file]
USD/src/dpl/core/src/assert.cpp [deleted file]
USD/src/dpl/core/src/binary_queue.cpp [deleted file]
USD/src/dpl/core/src/colors.cpp [deleted file]
USD/src/dpl/core/src/exception.cpp [deleted file]
USD/src/dpl/core/src/noncopyable.cpp [deleted file]
USD/src/dpl/core/src/serialization.cpp [deleted file]
USD/src/dpl/core/src/singleton.cpp [deleted file]
USD/src/dpl/log/include/dpl/log/abstract_log_provider.h [deleted file]
USD/src/dpl/log/include/dpl/log/dlog_log_provider.h [deleted file]
USD/src/dpl/log/include/dpl/log/log.h [deleted file]
USD/src/dpl/log/include/dpl/log/old_style_log_provider.h [deleted file]
USD/src/dpl/log/include/dpl/log/sd_journal_provider.h [deleted file]
USD/src/dpl/log/src/abstract_log_provider.cpp [deleted file]
USD/src/dpl/log/src/dlog_log_provider.cpp [deleted file]
USD/src/dpl/log/src/log.cpp [deleted file]
USD/src/dpl/log/src/old_style_log_provider.cpp [deleted file]
USD/src/dpl/log/src/sd_journal_provider.cpp [deleted file]
USD/src/include/usb-security-daemon.h [deleted file]
USD/src/main/dbus-manager.cpp [deleted file]
USD/src/main/dbus-manager.h [deleted file]
USD/src/main/generic-event.h [deleted file]
USD/src/main/generic-socket-manager.cpp [deleted file]
USD/src/main/generic-socket-manager.h [deleted file]
USD/src/main/server2-main.cpp [deleted file]
USD/src/main/service-thread.h [deleted file]
USD/src/main/socket-manager.cpp [deleted file]
USD/src/main/socket-manager.h [deleted file]
USD/src/main/usd-util.cpp [deleted file]
USD/src/main/usd-util.h [deleted file]
USD/src/service/add-permission.cpp [deleted file]
USD/src/service/add-permission.h [deleted file]
USD/src/service/usb-access.cpp [deleted file]
USD/src/service/usb-access.h [deleted file]
USD/src/service/usb-ask-user-service.cpp [deleted file]
USD/src/service/usb-ask-user-service.h [deleted file]
USD/systemd/CMakeLists.txt [deleted file]
USD/systemd/usd-access.socket [deleted file]
USD/systemd/usd-ask-user.socket [deleted file]
USD/systemd/usd.service [deleted file]
packaging/capi-system-usbhost.spec
pc/CMakeLists.txt
pc/USD/CMakeLists.txt [deleted file]
pc/USD/capi-system-usbhost-usd.pc.in [deleted file]

index 82e391f7891a49d48721932268b3634e708494dd..28abf5c2d5a68d4d946683dbf5e30323fa6d25ab 100644 (file)
@@ -87,7 +87,6 @@ IF(BUILD_SHARED_LIBS)
                COMMAND ${CMAKE_COMMAND}
                -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
 
-       ADD_SUBDIRECTORY(USD)
        ADD_SUBDIRECTORY(pc)
 
 ENDIF(BUILD_SHARED_LIBS)
diff --git a/USD/CMakeLists.txt b/USD/CMakeLists.txt
deleted file mode 100644 (file)
index 3935347..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-#
-#    Licensed under the Apache License, Version 2.0 (the "License");
-#    you may not use this file except in compliance with the License.
-#    You may obtain a copy of the License at
-#
-#        http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#    See the License for the specific language governing permissions and
-#    limitations under the License.
-#
-# @file        CMakeLists.txt
-# @author
-# @brief
-#
-
-############################# Check minimum CMake version #####################
-
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT("usb-security-daemon")
-
-############################# cmake packages ##################################
-
-INCLUDE(FindPkgConfig)
-
-############################# compiler flags ##################################
-
-SET(CMAKE_C_FLAGS_PROFILING    "-g -O0 -pg -Wp,-U_FORTIFY_SOURCE")
-SET(CMAKE_CXX_FLAGS_PROFILING  "-g -std=c++0x -O0 -pg -Wp,-U_FORTIFY_SOURCE")
-SET(CMAKE_C_FLAGS_DEBUG        "-g -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
-SET(CMAKE_CXX_FLAGS_DEBUG      "-g -std=c++0x -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
-SET(CMAKE_C_FLAGS_RELEASE      "-g -O2")
-SET(CMAKE_CXX_FLAGS_RELEASE    "-g -std=c++0x -O2")
-SET(CMAKE_C_FLAGS_CCOV         "-g -O2 --coverage")
-SET(CMAKE_CXX_FLAGS_CCOV       "-g -std=c++0x -O2 --coverage")
-
-# If supported for the target machine, emit position-independent code,suitable
-# for dynamic linking and avoiding any limit on the size of the global offset
-# table. This option makes a difference on the m68k, PowerPC and SPARC.
-# (BJ: our ARM too?)
-ADD_DEFINITIONS("-fPIC")
-
-# Set compiler warning flags
-ADD_DEFINITIONS("-Werror")                      # Make all warnings into errors.
-ADD_DEFINITIONS("-Wall")                        # Generate all warnings
-ADD_DEFINITIONS("-Wextra")                      # Generate even more extra warnings
-
-STRING(REGEX MATCH "([^.]*)" API_VERSION "${VERSION}")
-ADD_DEFINITIONS("-DAPI_VERSION=\"$(API_VERSION)\"")
-
-ADD_DEFINITIONS("-DSMACK_ENABLED")
-
-IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
-    ADD_DEFINITIONS("-DTIZEN_DEBUG_ENABLE")
-    ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
-ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
-
-SET(TARGET_USD "usd")
-SET(TARGET_USD_CLIENT "usd-client")
-SET(TARGET_USD_COMMON "usd-commons")
-
-ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(systemd)
diff --git a/USD/src/CMakeLists.txt b/USD/src/CMakeLists.txt
deleted file mode 100644 (file)
index dc280bd..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-PKG_CHECK_MODULES(USD_DEP
-    dlog
-    libsmack
-    libsystemd-daemon
-    libsystemd-journal
-    dbus-1
-    REQUIRED
-    )
-
-SET(USD_PATH ${PROJECT_SOURCE_DIR}/src)
-SET(SERVER2_PATH ${PROJECT_SOURCE_DIR}/src)
-
-SET(USD_SOURCES
-    ${SERVER2_PATH}/main/usd-util.cpp
-    ${SERVER2_PATH}/main/generic-socket-manager.cpp
-    ${SERVER2_PATH}/main/socket-manager.cpp
-    ${SERVER2_PATH}/main/server2-main.cpp
-    ${SERVER2_PATH}/service/usb-access.cpp
-    ${SERVER2_PATH}/main/dbus-manager.cpp
-    ${SERVER2_PATH}/client/usb-access-client.cpp
-    ${SERVER2_PATH}/client/client-common.cpp
-    ${SERVER2_PATH}/service/usb-ask-user-service.cpp
-    ${SERVER2_PATH}/service/add-permission.cpp
-    )
-
-SET_SOURCE_FILES_PROPERTIES(
-    ${USD_SOURCES}
-    PROPERTIES
-        COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden")
-
-INCLUDE_DIRECTORIES(SYSTEM
-    ${USD_DEP_INCLUDE_DIRS}
-    )
-
-INCLUDE_DIRECTORIES(
-    ${USD_PATH}/include
-    ${SERVER2_PATH}/main
-    ${SERVER2_PATH}/common
-    ${SERVER2_PATH}/service
-    ${SERVER2_PATH}/dpl/core/include
-    ${SERVER2_PATH}/dpl/log/include
-    )
-
-ADD_EXECUTABLE(${TARGET_USD} ${USD_SOURCES})
-
-SET_TARGET_PROPERTIES(${TARGET_USD}
-       PROPERTIES
-       COMPILE_FLAGS "-pthread"
-       LINK_FLAGS "-pthread"
-)
-
-TARGET_LINK_LIBRARIES(${TARGET_USD}
-    ${USD_DEP_LIBRARIES}
-    ${TARGET_USD_COMMON}
-    -lcap
-    )
-
-################################################################################
-
-SET(USD_CLIENT_VERSION_MAJOR 1)
-SET(USD_CLIENT_VERSION ${USD_CLIENT_VERSION_MAJOR}.0.1)
-
-INCLUDE_DIRECTORIES(
-    ${SERVER2_PATH}/client
-    ${SERVER2_PATH}/common
-    ${SERVER2_PATH}/dpl/core/include
-    ${SERVER2_PATH}/dpl/log/include
-    )
-
-SET(USD_CLIENT_SOURCES
-    ${SERVER2_PATH}/client/client-common.cpp
-    ${SERVER2_PATH}/client/usb-access-client.cpp
-    ${SERVER2_PATH}/client/usb-ask-user-client.cpp
-    )
-
-ADD_LIBRARY(${TARGET_USD_CLIENT} SHARED ${USD_CLIENT_SOURCES})
-
-SET_TARGET_PROPERTIES(
-    ${TARGET_USD_CLIENT}
-    PROPERTIES
-        COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=hidden" 
-        SOVERSION ${USD_CLIENT_VERSION_MAJOR}
-        VERSION ${USD_CLIENT_VERSION}
-    )
-
-TARGET_LINK_LIBRARIES(${TARGET_USD_CLIENT}
-    ${USD_DEP_LIBRARIES}
-    ${TARGET_USD_COMMON}
-    )
-
-################################################################################
-
-INSTALL(TARGETS ${TARGET_USD_CLIENT} DESTINATION ${LIB_INSTALL_DIR})
-
-INSTALL(TARGETS ${TARGET_USD} DESTINATION bin)
-
-INSTALL(FILES
-    ${USD_PATH}/include/usb-security-daemon.h
-    DESTINATION /usr/include/usd
-    )
-
-################################################################################
-
-#CONFIGURE_FILE(security-server.pc.in security-server.pc @ONLY)
-#INSTALL
-
-################################################################################
-
-
-PKG_CHECK_MODULES(COMMON_DEP
-    dlog
-    libsmack
-    libsystemd-daemon
-    libsystemd-journal
-    REQUIRED
-    )
-
-SET(COMMON_PATH ${PROJECT_SOURCE_DIR}/src)
-
-SET(COMMON_SOURCES
-    ${COMMON_PATH}/common/protocols.cpp
-    ${COMMON_PATH}/common/message-buffer.cpp
-    ${COMMON_PATH}/common/smack-check.cpp
-    ${COMMON_PATH}/common/usb-access-map.cpp
-    ${COMMON_PATH}/dpl/log/src/abstract_log_provider.cpp
-    ${COMMON_PATH}/dpl/log/src/dlog_log_provider.cpp
-    ${COMMON_PATH}/dpl/log/src/sd_journal_provider.cpp
-    ${COMMON_PATH}/dpl/log/src/log.cpp
-    ${COMMON_PATH}/dpl/log/src/old_style_log_provider.cpp
-    ${COMMON_PATH}/dpl/core/src/assert.cpp
-    ${COMMON_PATH}/dpl/core/src/binary_queue.cpp
-    ${COMMON_PATH}/dpl/core/src/colors.cpp
-    ${COMMON_PATH}/dpl/core/src/exception.cpp
-    ${COMMON_PATH}/dpl/core/src/noncopyable.cpp
-    ${COMMON_PATH}/dpl/core/src/serialization.cpp
-    ${COMMON_PATH}/dpl/core/src/singleton.cpp
-    )
-
-INCLUDE_DIRECTORIES(SYSTEM
-    ${COMMON_DEP_INCLUDE_DIRS}
-    )
-
-INCLUDE_DIRECTORIES(
-    ${COMMON_PATH}/common
-    ${COMMON_PATH}/dpl/core/include
-    ${COMMON_PATH}/dpl/log/include
-    )
-
-ADD_LIBRARY(${TARGET_USD_COMMON} SHARED ${COMMON_SOURCES})
-
-SET_TARGET_PROPERTIES(
-    ${TARGET_USD_COMMON}
-    PROPERTIES
-        COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=default"
-        SOVERSION 1.0.0
-        VERSION 1.0.0
-    )
-
-TARGET_LINK_LIBRARIES(${TARGET_USD_COMMON}
-    ${COMMON_DEP_LIBRARIES}
-    )
-
-################################################################################
-
-INSTALL(TARGETS ${TARGET_USD_COMMON} DESTINATION ${LIB_INSTALL_DIR})
-
-
diff --git a/USD/src/client/client-common.cpp b/USD/src/client/client-common.cpp
deleted file mode 100644 (file)
index 103c249..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        client-common.cpp
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       This file is implementation of client-common functions.
- */
-
-#include <fcntl.h>
-#include <poll.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <unistd.h>
-
-#include <dpl/log/log.h>
-#include <dpl/serialization.h>
-#include <dpl/singleton.h>
-#include <dpl/singleton_safe_impl.h>
-
-#include <message-buffer.h>
-
-#include <usb-security-daemon.h>
-/*
-IMPLEMENT_SAFE_SINGLETON(USD::Log::LogSystem);
-*/
-namespace {
-
-const int POLL_TIMEOUT = 60000;
-
-void securityClientEnableLogSystem(void) {
-    USD::Singleton<USD::Log::LogSystem>::Instance().SetTag("USD_CLIENT");
-}
-
-int waitForSocket(int sock, int event, int timeout) {
-    int retval;
-    pollfd desc[1];
-    desc[0].fd = sock;
-    desc[0].events = event;
-
-    while((-1 == (retval = poll(desc, 1, timeout))) && (errno == EINTR)) {
-        timeout >>= 1;
-        errno = 0;
-    }
-
-    if (0 == retval) {
-        LogDebug("Poll timeout");
-    } else if (-1 == retval) {
-        int err = errno;
-        LogError("Error in poll: " << strerror(err));
-    }
-    return retval;
-}
-
-class SockRAII {
-public:
-    SockRAII()
-      : m_sock(-1)
-    {}
-
-    virtual ~SockRAII() {
-        if (m_sock > -1)
-            close(m_sock);
-    }
-
-    int Connect(char const * const interface) {
-        sockaddr_un clientAddr;
-        int flags;
-
-        if (m_sock != -1) // guard
-            close(m_sock);
-
-        m_sock = socket(AF_UNIX, SOCK_STREAM, 0);
-        if (m_sock < 0) {
-            int err = errno;
-            LogError("Error creating socket: " << strerror(err));
-            return USD_API_ERROR_SOCKET;
-        }
-
-        if ((flags = fcntl(m_sock, F_GETFL, 0)) < 0 ||
-            fcntl(m_sock, F_SETFL, flags | O_NONBLOCK) < 0)
-        {
-            int err = errno;
-            LogError("Error in fcntl: " << strerror(err));
-            return USD_API_ERROR_SOCKET;
-        }
-
-        memset(&clientAddr, 0, sizeof(clientAddr));
-
-        clientAddr.sun_family = AF_UNIX;
-
-        if (strlen(interface) >= sizeof(clientAddr.sun_path)) {
-            LogError("Error: interface name " << interface << "is too long. Max len is:" << sizeof(clientAddr.sun_path));
-            return USD_API_ERROR_NO_SUCH_SERVICE;
-        }
-
-        strcpy(clientAddr.sun_path, interface);
-
-        LogDebug("ClientAddr.sun_path = " << interface);
-
-        int retval = TEMP_FAILURE_RETRY(connect(m_sock, (struct sockaddr*)&clientAddr, SUN_LEN(&clientAddr)));
-        if ((retval == -1) && (errno == EINPROGRESS)) {
-            if (0 >= waitForSocket(m_sock, POLLOUT, POLL_TIMEOUT)) {
-                LogError("Error in waitForSocket.");
-                return USD_API_ERROR_SOCKET;
-            }
-            int error = 0;
-            socklen_t len = sizeof(error);
-            retval = getsockopt(m_sock, SOL_SOCKET, SO_ERROR, &error, &len);
-
-            if (-1 == retval) {
-                int err = errno;
-                LogError("Error in getsockopt: " << strerror(err));
-                return USD_API_ERROR_SOCKET;
-            }
-
-            if (error == EACCES) {
-                LogError("Access denied");
-                return USD_API_ERROR_ACCESS_DENIED;
-            }
-
-            if (error != 0) {
-                LogError("Error in connect: " << strerror(error));
-                return USD_API_ERROR_SOCKET;
-            }
-
-            return USD_API_SUCCESS;
-        }
-
-        if (-1 == retval) {
-            int err = errno;
-            LogError("Error connecting socket: " << strerror(err));
-            if (err == EACCES)
-                return USD_API_ERROR_ACCESS_DENIED;
-            if (err == ENOTSOCK)
-                return USD_API_ERROR_NO_SUCH_SERVICE;
-            return USD_API_ERROR_SOCKET;
-        }
-
-        return USD_API_SUCCESS;
-    }
-
-    int Get() {
-        return m_sock;
-    }
-
-private:
-    int m_sock;
-};
-
-} // namespace anonymous
-
-namespace USD {
-
-
-int sendToServer(char const * const interface, const RawBuffer &send, MessageBuffer &recv) {
-    int ret;
-    SockRAII sock;
-    ssize_t done = 0;
-    char buffer[2048];
-
-    if (USD_API_SUCCESS != (ret = sock.Connect(interface))) {
-        LogError("Error in SockRAII");
-        return ret;
-    }
-
-    while ((send.size() - done) > 0) {
-        if (0 >= waitForSocket(sock.Get(), POLLOUT, POLL_TIMEOUT)) {
-            LogError("Error in poll(POLLOUT)");
-            return USD_API_ERROR_SOCKET;
-        }
-        ssize_t temp = TEMP_FAILURE_RETRY(write(sock.Get(), &send[done], send.size() - done));
-        if (-1 == temp) {
-            int err = errno;
-            LogError("Error in write: " << strerror(err));
-            return USD_API_ERROR_SOCKET;
-        }
-        done += temp;
-    }
-
-    do {
-        if (0 >= waitForSocket(sock.Get(), POLLIN, POLL_TIMEOUT)) {
-            LogError("Error in poll(POLLIN)");
-            return USD_API_ERROR_SOCKET;
-        }
-        ssize_t temp = TEMP_FAILURE_RETRY(read(sock.Get(), buffer, 2048));
-        if (-1 == temp) {
-            int err = errno;
-            LogError("Error in read: " << strerror(err));
-            return USD_API_ERROR_SOCKET;
-        }
-
-        if (0 == temp) {
-            LogError("Read return 0/Connection closed by server(?)");
-            return USD_API_ERROR_SOCKET;
-        }
-
-        RawBuffer raw(buffer, buffer+temp);
-        recv.Push(raw);
-    } while(!recv.Ready());
-    return USD_API_SUCCESS;
-}
-
-int sendToServerAncData(char const * const interface, const RawBuffer &send, struct msghdr &hdr) {
-    int ret;
-    SockRAII sock;
-    ssize_t done = 0;
-
-    if (USD_API_SUCCESS != (ret = sock.Connect(interface))) {
-        LogError("Error in SockRAII");
-        return ret;
-    }
-
-    while ((send.size() - done) > 0) {
-        if (0 >= waitForSocket(sock.Get(), POLLOUT, POLL_TIMEOUT)) {
-            LogError("Error in poll(POLLOUT)");
-            return USD_API_ERROR_SOCKET;
-        }
-        ssize_t temp = TEMP_FAILURE_RETRY(write(sock.Get(), &send[done], send.size() - done));
-        if (-1 == temp) {
-            int err = errno;
-            LogError("Error in write: " << strerror(err));
-            return USD_API_ERROR_SOCKET;
-        }
-        done += temp;
-    }
-
-    if (0 >= waitForSocket(sock.Get(), POLLIN, POLL_TIMEOUT)) {
-        LogError("Error in poll(POLLIN)");
-        return USD_API_ERROR_SOCKET;
-    }
-
-    ssize_t temp = TEMP_FAILURE_RETRY(recvmsg(sock.Get(), &hdr, MSG_CMSG_CLOEXEC));
-
-    if (temp < 0) {
-        int err = errno;
-        LogError("Error in recvmsg(): " << strerror(err) << " errno: " << err);
-        return USD_API_ERROR_SOCKET;
-    }
-
-    if (0 == temp) {
-        LogError("Read return 0/Connection closed by server(?)");
-        return USD_API_ERROR_SOCKET;
-    }
-
-    return USD_API_SUCCESS;
-}
-
-int try_catch(const std::function<int()>& func)
-{
-    try {
-        return func();
-    } catch (MessageBuffer::Exception::Base &e) {
-        LogError("USD::MessageBuffer::Exception " << e.DumpToString());
-    } catch (std::exception &e) {
-        LogError("STD exception " << e.what());
-    } catch (...) {
-        LogError("Unknown exception occured");
-    }
-    return USD_API_ERROR_UNKNOWN;
-}
-
-} // namespace USD
-
-static void init_lib(void) __attribute__ ((constructor));
-static void init_lib(void)
-{
-    securityClientEnableLogSystem();
-}
-
-static void fini_lib(void) __attribute__ ((destructor));
-static void fini_lib(void)
-{
-
-}
-
diff --git a/USD/src/client/client-common.h b/USD/src/client/client-common.h
deleted file mode 100644 (file)
index 4094c7a..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        client-common.h
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       This file constains implementation of common types
- *              used in USD.
- */
-
-#ifndef _USD_CLIENT_
-#define _USD_CLIENT_
-
-#include <vector>
-#include <functional>
-
-#include <message-buffer.h>
-
-#define _USD_API_ __attribute__((visibility("default")))
-#define _USD_UNUSED_ __attribute__((unused))
-
-extern "C" {
-    struct msghdr;
-}
-
-namespace USD {
-
-typedef std::vector<unsigned char> RawBuffer;
-
-int sendToServer(char const * const interface, const RawBuffer &send, MessageBuffer &recv);
-
-/*
- * sendToServerAncData is special case when we want to receive file descriptor
- * passed by USD on behalf of calling process. We can't get it with
- * MessageBuffer.
- *
- * This function should be called _ONLY_ in this particular case.
- *
- */
-int sendToServerAncData(char const * const interface, const RawBuffer &send, struct msghdr &hdr);
-
-/*
- * Decorator function that performs frequently repeated exception handling in
- * SS client API functions. Accepts lambda expression as an argument.
- */
-int try_catch(const std::function<int()>& func);
-
-} // namespace USD
-
-#endif // _USD_CLIENT_
diff --git a/USD/src/client/usb-access-client.cpp b/USD/src/client/usb-access-client.cpp
deleted file mode 100644 (file)
index d908346..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*-*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-*/
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Karol Lewandowski <k.lewandowsk@samsung.com>
- *
- *  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        usb-access-client.cpp
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @author      Krzysztof Opasiak <k.opasiak@samsung.com>
- * @version     1.0
- * @brief       This file is implementation of client functions for usb access service.
- */
-
-#include <usb-security-daemon.h>
-#include <usd-util.h>
-#include <cstring>
-#include <dpl/log/log.h>
-#include <dpl/exception.h>
-#include <message-buffer.h>
-#include <client-common.h>
-#include <protocols.h>
-#include <sys/socket.h>
-
-
-namespace {
-
-void create_msghdr(struct msghdr *hdr,
-                   struct iovec *iov,
-                   unsigned char *cmsgbuf,
-                   const size_t cmsgbufSize,
-                   int *retcode)
- {
-        memset(hdr, 0, sizeof(*hdr));
-        memset(cmsgbuf, 0, cmsgbufSize);
-
-        iov->iov_base = retcode;
-        iov->iov_len = sizeof(*retcode);
-        hdr->msg_iov = iov;
-        hdr->msg_iovlen = 1;
-
-        if (NULL != cmsgbuf) {
-            hdr->msg_control = cmsgbuf;
-            hdr->msg_controllen = cmsgbufSize;
-        }
-}
-
-} // namespace anonymous
-
-_USD_API_
-int usd_open_usb_device(const char *devpath, int *fd)
-{
-    LogDebug("devpath: " << devpath);
-    using namespace USD;
-    return try_catch([&] {
-        MessageBuffer send;
-        struct msghdr hdr;
-        struct iovec iov;
-        unsigned char cmsgbuf[CMSG_SPACE(sizeof(int))];
-        int retcode = -1;
-        int result;
-
-        if (nullptr == devpath || nullptr == fd || !strlen(devpath)) {
-            LogError("Error input param.");
-            return USD_API_ERROR_INPUT_PARAM;
-        }
-
-        Serialization::Serialize(send,
-                                 static_cast<int>(USBAccessCall::USB_CALL_TYPE_OPEN));
-        Serialization::Serialize(send, std::string(devpath));
-
-        create_msghdr(&hdr, &iov, &cmsgbuf[0], sizeof(cmsgbuf), &retcode);
-
-        result = sendToServerAncData(SERVICE_SOCKET_USB_ACCESS,
-                                     send.Pop(), hdr);
-        if (result != USD_API_SUCCESS) {
-            *fd = -1;
-            return result;
-        }
-
-        if (hdr.msg_flags & MSG_CTRUNC) {
-            LogError("Not enough space for ancillary element array.");
-            *fd = -1;
-            return USD_API_ERROR_BUFFER_TOO_SMALL;
-        }
-
-        for(cmsghdr *cmsg = CMSG_FIRSTHDR(&hdr);
-            cmsg != NULL;
-            cmsg = CMSG_NXTHDR(&hdr, cmsg)) {
-            if((SOL_SOCKET == cmsg->cmsg_level) &&
-               (SCM_RIGHTS == cmsg->cmsg_type)) {
-                memmove(fd, CMSG_DATA(cmsg), sizeof(int));
-            }
-        }
-        return retcode;
-    });
-}
-
-_USD_API_
-int usd_setup_usb_device_access(const char *topology, const char *smack, bool allow) {
-
-    using namespace USD;
-    return try_catch([&] {
-        MessageBuffer send;
-        struct msghdr hdr;
-        struct iovec iov;
-        int retcode = -1;
-
-        if (nullptr == topology  || !strlen(topology) ||
-                nullptr == smack  || !strlen(smack)) {
-            LogError("Error input param.");
-            return USD_API_ERROR_INPUT_PARAM;
-        }
-        LogDebug(" topology: " << topology << "smack: " << smack << "allow" << allow);
-
-        Serialization::Serialize(send,
-                                 static_cast<int>(USBAccessCall::USB_CALL_TYPE_SETUP_POLICY));
-        Serialization::Serialize(send, std::string(smack));
-        Serialization::Serialize(send, std::string(topology));
-        Serialization::Serialize(send, allow);
-
-        create_msghdr(&hdr, &iov, NULL, 0, &retcode);
-
-        int result = sendToServerAncData(SERVICE_SOCKET_USB_ACCESS, send.Pop(), hdr);
-        if (result != USD_API_SUCCESS)
-            return result;
-
-        if (hdr.msg_flags & MSG_CTRUNC) {
-            LogError("Not enough space for ancillary element array.");
-            return USD_API_ERROR_BUFFER_TOO_SMALL;
-        }
-
-        return retcode;
-    });
-}
diff --git a/USD/src/client/usb-ask-user-client.cpp b/USD/src/client/usb-ask-user-client.cpp
deleted file mode 100644 (file)
index a820253..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Karol Lewandowski <k.lewandowsk@samsung.com>
- *
- *  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        usb-ask-user-client.cpp
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @version     1.0
- * @brief       This file is implementation of client side functions for service
- * which manages popups to user.
- */
-
-#include <stdio.h>
-
-#include <dpl/log/log.h>
-#include <dpl/exception.h>
-
-#include <message-buffer.h>
-#include <client-common.h>
-#include <protocols.h>
-
-#include <usb-security-daemon.h>
-
-_USD_API_
-int usd_ask_user_to_grant_permission(const char *path) {
-    using namespace USD;
-
-    return try_catch([&] {
-        if (NULL == path){
-            LogDebug("path is NULL");
-            return USD_API_ERROR_INPUT_PARAM;
-        }
-
-        MessageBuffer send, recv;
-        Serialization::Serialize(send, std::string(path));
-
-        int retCode = sendToServer(
-          SERVICE_SOCKET_ASK_USER,
-          send.Pop(),
-          recv);
-
-        if (retCode == USD_API_SUCCESS) {
-            Deserialization::Deserialize(recv, retCode);
-        }
-
-        return retCode;
-
-    });
-}
-
diff --git a/USD/src/common/connection-info.h b/USD/src/common/connection-info.h
deleted file mode 100644 (file)
index 8490493..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        connection-info.h
- * @author      Lukasz Kostyra (l.kostyra@partner.samsung.com)
- * @version     1.0
- * @brief       Definition of ConnectionInfo structure and ConnectionInfoMap type.
- */
-
-#ifndef _CONNECTION_INFO_H_
-#define _CONNECTION_INFO_H_
-
-#include <map>
-#include <generic-socket-manager.h>
-#include <message-buffer.h>
-
-namespace USD
-{
-    struct ConnectionInfo {
-        InterfaceID interfaceID;
-        MessageBuffer buffer;
-    };
-
-    typedef std::map<int, ConnectionInfo> ConnectionInfoMap;
-} //namespace USD
-
-#endif //_CONNECTION_INFO_H_
diff --git a/USD/src/common/message-buffer.cpp b/USD/src/common/message-buffer.cpp
deleted file mode 100644 (file)
index da2bffc..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        message-buffer.cpp
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       Implementation of MessageBuffer.
- */
-
-#include <message-buffer.h>
-
-#include <dpl/log/log.h>
-
-namespace USD {
-
-void MessageBuffer::Push(const RawBuffer &data) {
-    m_buffer.AppendCopy(&data[0], data.size());
-}
-
-RawBuffer MessageBuffer::Pop() {
-    size_t size = m_buffer.Size();
-    RawBuffer buffer;
-    buffer.resize(size + sizeof(size_t));
-    memcpy(&buffer[0], &size, sizeof(size_t));
-    m_buffer.FlattenConsume(&buffer[sizeof(size_t)], size);
-    return buffer;
-}
-
-bool MessageBuffer::Ready() {
-    CountBytesLeft();
-    if (m_bytesLeft == 0)
-        return false;
-    if (m_bytesLeft > m_buffer.Size())
-        return false;
-    return true;
-}
-
-void MessageBuffer::Read(size_t num, void *bytes) {
-    CountBytesLeft();
-    if (num > m_bytesLeft) {
-        LogDebug("Protocol broken. OutOfData. Asked for: " << num << " Ready: " << m_bytesLeft << " Buffer.size(): " << m_buffer.Size());
-        Throw(Exception::OutOfData);
-    }
-
-    m_buffer.FlattenConsume(bytes, num);
-    m_bytesLeft -= num;
-}
-
-void MessageBuffer::Write(size_t num, const void *bytes) {
-    m_buffer.AppendCopy(bytes, num);
-}
-
-} // namespace USD
-
diff --git a/USD/src/common/message-buffer.h b/USD/src/common/message-buffer.h
deleted file mode 100644 (file)
index b7fc94e..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        secket-buffer.h
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       Implementatin of MessageBuffer.
- */
-
-#ifndef _USD_SOCKET_BUFFER_
-#define _USD_SOCKET_BUFFER_
-
-#include <vector>
-
-#include <dpl/binary_queue.h>
-#include <dpl/exception.h>
-#include <dpl/serialization.h>
-
-namespace USD {
-
-typedef std::vector<unsigned char> RawBuffer;
-
-class MessageBuffer : public USD::IStream {
-public:
-    class Exception
-    {
-    public:
-        DECLARE_EXCEPTION_TYPE(USD::Exception, Base)
-        DECLARE_EXCEPTION_TYPE(Base, OutOfData)
-    };
-
-    MessageBuffer()
-      : m_bytesLeft(0)
-    {}
-
-    void Push(const RawBuffer &data);
-
-    RawBuffer Pop();
-
-    bool Ready();
-
-    virtual void Read(size_t num, void *bytes);
-
-    virtual void Write(size_t num, const void *bytes);
-
-protected:
-
-    inline void CountBytesLeft() {
-        if (m_bytesLeft > 0)
-            return;  // we already counted m_bytesLeft nothing to do
-
-        if (m_buffer.Size() < sizeof(size_t))
-            return;  // we cannot count m_bytesLeft because buffer is too small
-
-        m_buffer.FlattenConsume(&m_bytesLeft, sizeof(size_t));
-    }
-
-    size_t m_bytesLeft;
-    USD::BinaryQueue m_buffer;
-};
-
-} // namespace USD
-
-#endif // _USD_SOCKET_BUFFER_
diff --git a/USD/src/common/protocols.cpp b/USD/src/common/protocols.cpp
deleted file mode 100644 (file)
index 1c557d8..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        protocols.cpp
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       List of all protocols supported by USD.
- */
-
-#include <protocols.h>
-#include <cstddef>
-
-
-namespace USD {
-
-#define SOCKET_PATH_PREFIX "/run/"
-#define SOCKET_PATH_PREFIX_USD SOCKET_PATH_PREFIX "usd/"
-
-char const * const SERVICE_SOCKET_USB_ACCESS =
-        SOCKET_PATH_PREFIX_USD "usd-api-usb-access.socket";
-
-char const * const SERVICE_SOCKET_ASK_USER =
-        SOCKET_PATH_PREFIX_USD "usd-api-ask-user.socket";
-
-} // namespace USD
-
diff --git a/USD/src/common/protocols.h b/USD/src/common/protocols.h
deleted file mode 100644 (file)
index 072755d..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        protocols.h
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       This file contains list of all protocols suported by USD.
- */
-
-#ifndef _USD_PROTOCOLS_
-#define _USD_PROTOCOLS_
-
-
-namespace USD {
-
-extern char const *const SERVICE_SOCKET_USB_ACCESS;
-extern char const *const SERVICE_SOCKET_ASK_USER;
-
-enum class USBAccessCall
-{
-    USB_CALL_TYPE_OPEN,
-    USB_CALL_TYPE_SETUP_POLICY
-};
-
-} // namespace USD
-
-#endif // _USD_PROTOCOLS_
-
diff --git a/USD/src/common/smack-check.cpp b/USD/src/common/smack-check.cpp
deleted file mode 100644 (file)
index a68fb38..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <smack-check.h>
-
-#include <stdlib.h>
-#include <sys/smack.h>
-
-#include <dpl/log/log.h>
-
-namespace USD {
-
-int smack_runtime_check(void)
-{
-    static int smack_present = -1;
-    if (-1 == smack_present) {
-        if (NULL == smack_smackfs_path()) {
-            LogDebug("no smack found on device");
-            smack_present = 0;
-        } else {
-            LogDebug("found smack on device");
-            smack_present = 1;
-        }
-    }
-    return smack_present;
-}
-
-int smack_check(void)
-{
-#ifndef SMACK_ENABLED
-    return 0;
-#else
-    return smack_runtime_check();
-#endif
-}
-
-} // namespace USD
diff --git a/USD/src/common/smack-check.h b/USD/src/common/smack-check.h
deleted file mode 100644 (file)
index 5094844..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  USB security daemon
- *
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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
- */
-
-#ifndef _SMACK_CHECK_H_
-#define _SMACK_CHECK_H_
-
-namespace USD {
-
-/*
- * A very simple runtime check for SMACK on the platform
- * Returns 1 if SMACK is present, 0 otherwise
- */
-
-int smack_runtime_check(void);
-
-/*
- * A very simple runtime check for SMACK on the platform
- * Returns 1 if SMACK is present, 0 otherwise. If SMACK_ENABLED is not defined
- * It returns 0.
- */
-int smack_check(void);
-
-} // namespace USD
-
-#endif // _SMACK_CHECK_H_
diff --git a/USD/src/common/usb-access-map.cpp b/USD/src/common/usb-access-map.cpp
deleted file mode 100644 (file)
index 812347c..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-/*-*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-*/
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Karol Lewandowski <k.lewandowsk@samsung.com>
- *
- *  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        usb-access-map.cpp
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @author      Krzysztof Opasiak <k.opasiak@samsung.com>
- * @version     1.0
- * @brief       Implementation of classes that gathers information about
- * applications' access rights to usb files for purpose of raw USB usage.
- */
-
-#include <usb-access-map.h>
-#include <usb-security-daemon.h>
-#include <dpl/log/log.h>
-#include <cstring>
-#include <limits.h>
-#include <string>
-#include <cstdlib>
-#include <iostream>
-#include <fstream>
-
-#include <sys/smack.h>
-#include <linux/usb/ch9.h>
-#include <endian.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#define USB_DEVICE_MAJOR 189
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*a))
-
-using namespace std;
-
-namespace USD {
-
-void USBDevicePath::initFromSysFS(const std::string &path)
-{
-    char buf[PATH_MAX];
-    char *ret_chp;
-
-    ret_chp = realpath(path.c_str(), buf);
-    if (!ret_chp)
-        throw USD_API_ERROR_FILE_NOT_EXIST;
-    m_sysPath = string(buf);
-
-    if (m_dev == 0) {
-        /* it is not dev node! */
-        ifstream dev_file(m_sysPath + "/dev");
-        string content;
-        int min, maj;
-        int ret;
-
-        dev_file >> content;
-        ret = sscanf(content.c_str(), "%d:%d", &maj, &min);
-        if (ret != 2)
-            throw USD_API_ERROR_FILE_READ_FAILED;
-
-        if (maj != USB_DEVICE_MAJOR) {
-            LogError("This is not an USB device");
-            throw USD_API_ERROR_ACCESS_DENIED;
-        }
-
-        m_dev = makedev(maj, min);
-    }
-}
-
-void USBDevicePath::initFromTopology(const std::string &path)
-{
-    string usb_path = path;
-    size_t ret;
-
-    ret = path.find_first_of('/');
-    if (ret != string::npos)
-        usb_path = path.substr(0, ret);
-
-    /*
-     * TODO: This is a good vector of attack.
-     * Revisit this function and check if it is really
-     * safe and any malformed path can lead us outside sysfs
-     * For example: path=../../../../tmp/my_fake_dir"
-     * would work without above code
-     */
-    initFromSysFS(string("/sys/bus/usb/devices/") + path);
-}
-
-void USBDevicePath::initFromDev(const std::string &path)
-{
-    struct stat dev_st;
-    char buf[PATH_MAX];
-    string spath;
-    int ret;
-
-    ret = stat(path.c_str(), &dev_st);
-    if (ret < 0)
-        throw USD_API_ERROR_FILE_READ_FAILED;
-
-    if (!S_ISCHR(dev_st.st_mode) ||
-        major(dev_st.st_rdev) != USB_DEVICE_MAJOR) {
-        LogError("This is not an usb device");
-        throw USD_API_ERROR_ACCESS_DENIED;
-    }
-
-    m_dev = dev_st.st_rdev;
-    ret = snprintf(buf, sizeof(buf),
-                   "/sys/dev/char/%d:%d", major(m_dev), minor(m_dev));
-    /*
-     * If this happened we have really big troubles,
-     * probably it end of the world
-     */
-    if ((unsigned)ret >= sizeof(buf))
-        throw USD_API_ERROR_BUFFER_TOO_SMALL;
-
-    initFromSysFS(buf);
-}
-
-USBDevicePath::USBDevicePath(const string &path,
-                             PathType path_type)
-    : m_dev(0)
-{
-    switch (path_type) {
-    case PATH_TYPE_DEV:
-        initFromDev(path);
-        break;
-    case PATH_TYPE_TOPO:
-        initFromTopology(path);
-        break;
-    case PATH_TYPE_SYSFS:
-        initFromSysFS(path);
-        break;
-    }
-}
-
-USBDevicePath::USBDevicePath(std::string min, std::string maj, std::string m_sysPath)
-    : m_sysPath(m_sysPath)
-{
-    int t_maj, t_min;
-    std::stringstream s_maj, s_min;
-
-    s_maj << std::hex << maj;
-    s_min << std::hex << min;
-    s_maj >> t_maj;
-    s_min >> t_min;
-
-    m_dev = makedev(t_min, t_maj);
-}
-
-const std::string &USBDevicePath::getSysFSPath() const
-{
-    return m_sysPath;
-}
-
-const std::string &USBDevicePath::getTopology() const
-{
-    //todo get topology!
-    return m_sysPath;
-}
-
-dev_t USBDevicePath::getDev() const
-{
-    return m_dev;
-}
-
-std::ostream &operator<<(std::ostream &stream,
-                                    const USBDevicePath &path)
-{
-
-    stream << major(path.m_dev) << ';' << minor(path.m_dev) << ";"
-           << path.m_sysPath << ";";
-
-    return stream;
-}
-
-/****** USBDeviceId ******/
-
-USBDeviceId::USBDeviceId(const string &path, USBDevicePath::PathType path_type)
-    : m_path(path, path_type)
-{
-    initDevId(m_path.getSysFSPath());
-}
-
-USBDeviceId::USBDeviceId(std::string values[], USBDevicePath m_path)
-    : m_path(m_path)
-{
-    std::stringstream ssVal[7];
-    int decVal[7];
-    int i;
-    for (i = 0; i < 7; i++){
-        ssVal[i] << values[i+1];
-        ssVal[i] >> std::hex >> decVal[i];
-    }
-
-    m_idVendor = decVal[0];
-    m_idProduct = decVal[1];
-    m_bcdDevice =  decVal[2];
-    m_bDeviceClass = decVal[3];
-    m_bDeviceSubClass = decVal[4];
-    m_bDeviceProtocol  = decVal[5];
-    m_bcdUSB = decVal[6];
-
-}
-
-USBDeviceId::USBDeviceId(const USBDevicePath &path)
-    : m_path(path)
-{
-    initDevId(m_path.getSysFSPath());
-}
-
-void USBDeviceId::initDevId(const std::string &sys_path)
-{
-    int fd;
-    int ret;
-    struct usb_device_descriptor desc;
-    std::string path;
-
-    path += sys_path + "/descriptors";
-
-    fd = open(path.c_str(), O_RDONLY);
-    if (fd < 0) {
-        LogError("Open failed for: " << path);
-        throw USD_API_ERROR_FILE_OPEN_FAILED;
-    }
-
-    ret = read(fd, &desc, sizeof(desc));
-    close(fd);
-    if ((unsigned)ret < sizeof(desc)) {
-        LogError("Read failed for: " << path);
-        throw USD_API_ERROR_FILE_READ_FAILED;
-    }
-
-    m_bcdUSB = le16toh(desc.bcdUSB);
-    m_bDeviceClass = desc.bDeviceClass;
-    m_bDeviceSubClass = desc.bDeviceSubClass;
-    m_bDeviceProtocol = desc.bDeviceProtocol;
-    m_idVendor = le16toh(desc.idVendor);
-    m_idProduct = le16toh(desc.idProduct);
-    m_bcdDevice = le16toh(desc.bcdDevice);
-}
-
-bool USBDeviceId::operator<(const USBDeviceId &r) const
-{
-    int i;
-
-    /*
-     * We don't test major because we know that
-     * all USB devices have the same major
-     */
-#define VALUES(field)                           \
-    { .our = this->field, .other = r.field, }
-
-    struct {
-        int our;
-        int other;
-    } values[] = {
-        {
-            .our = minor(m_path.getDev()),
-            .other = minor(r.m_path.getDev()),
-        },
-        VALUES(m_idVendor),
-        VALUES(m_idProduct),
-        VALUES(m_bcdDevice),
-        VALUES(m_bDeviceClass),
-        VALUES(m_bDeviceSubClass),
-        VALUES(m_bDeviceProtocol),
-        VALUES(m_bcdUSB),
-    };
-
-#undef VALUES
-
-    for (i = 0; (unsigned)i < ARRAY_SIZE(values); ++i)
-        if (values[i].our != values[i].other)
-            return values[i].our < values[i].other;
-
-    return m_path.getSysFSPath() < r.m_path.getSysFSPath();
-}
-
-bool USBDeviceId::operator==(const USBDeviceId &r) const
-{
-#define FIELD_NE(field) (this->field != r.field)
-
-    if (FIELD_NE(m_path.getDev()))
-        return false;
-
-    if (FIELD_NE(m_idVendor))
-        return false;
-
-    if (FIELD_NE(m_idProduct))
-        return false;
-
-    if (FIELD_NE(m_bcdDevice))
-        return false;
-
-    if (FIELD_NE(m_bDeviceClass))
-        return false;
-
-    if (FIELD_NE(m_bDeviceSubClass))
-        return false;
-
-    if (FIELD_NE(m_bDeviceProtocol))
-        return false;
-
-    if (FIELD_NE(m_bcdUSB))
-        return false;
-#undef FIELD_NE
-
-    return m_path.getSysFSPath() == r.m_path.getSysFSPath();
-}
-
-bool USBDeviceId::operator!=(const USBDeviceId &r) const
-{
-    return !(*this == r);
-}
-
-std::ostream &operator<<(std::ostream &stream,
-                                    const USBDeviceId &id)
-{
-#define NAMED_VAL(field) { .name = #field, .val = id.m_##field, }
-    struct {
-        const char *name;
-        int val;
-    } fields[] = {
-        NAMED_VAL(idVendor),
-        NAMED_VAL(idProduct),
-        NAMED_VAL(bcdDevice),
-        NAMED_VAL(bDeviceClass),
-        NAMED_VAL(bDeviceSubClass),
-        NAMED_VAL(bDeviceProtocol),
-        NAMED_VAL(bcdUSB),
-    };
-#undef NAMED_VAL
-    int i = 0;
-
-    for (i = 0; (unsigned)i < ARRAY_SIZE(fields); ++i)
-        stream << ";" << std::hex << fields[i].val;
-
-    stream << ";" << id.m_path;
-
-
-    return stream;
-}
-
-/****** PolicySubjectId ******/
-
-PolicySubjectId::PolicySubjectId(const std::string &smk)
-    : m_smk(smk)
-{
-    /* Nothing to do here */
-}
-
-PolicySubjectId::PolicySubjectId(int socket)
-{
-    char *smk;
-    ssize_t ret;
-
-    ret = smack_new_label_from_socket(socket, &smk);
-    if (ret < 0)
-        throw USD_API_ERROR_GETTING_SOCKET_LABEL_FAILED;
-
-    m_smk = smk;
-    free(smk);
-}
-
-PolicySubjectId::PolicySubjectId(IStream &str)
-{
-    Deserialization::Deserialize(str, m_smk);
-}
-
-bool PolicySubjectId::operator<(const PolicySubjectId &r) const
-{
-    return this->m_smk < r.m_smk;
-}
-
-bool PolicySubjectId::operator==(const PolicySubjectId &r) const
-{
-    return this->m_smk == r.m_smk;
-}
-
-std::ostream& operator<<(std::ostream& stream, const PolicySubjectId& id)
-{
-    return stream << id.m_smk;
-}
-
-/****** USBAccessMapKey ******/
-
-USBAccessMapKey::USBAccessMapKey(const PolicySubjectId &subject,
-                                 const USBDeviceId &device)
-    : m_subject(subject), m_device(device)
-{
-    /* Nothing to do here */
-}
-
-bool USBAccessMapKey::validate() const
-{
-    /* TODO */
-    return true;
-}
-
-bool USBAccessMapKey::operator<(const USBAccessMapKey &r) const
-{
-    if (m_device != r.m_device)
-        return m_device < r.m_device;
-
-    return m_subject < r.m_subject;
-}
-
-bool USBAccessMapKey::operator==(const USBAccessMapKey &r) const
-{
-    if (m_device != r.m_device)
-        return false;
-
-    return m_subject == r.m_subject;
-}
-
-std::ostream& operator<<(std::ostream& stream,
-                                    const USBAccessMapKey& key)
-{
-    stream << key.m_subject << key.m_device;
-    return stream;
-}
-
-} /* namespace USD */
-
diff --git a/USD/src/common/usb-access-map.h b/USD/src/common/usb-access-map.h
deleted file mode 100644 (file)
index 2d61067..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*-*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-*/
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Karol Lewandowski <k.lewandowsk@samsung.com>
- *
- *  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        usb-access.h
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @author      Krzysztof Opasiak <k.opasiak@samsung.com>
- * @version     1.0
- * @brief       Header for classes that gathers information about
- * applications' access rights to usb files for purpose of raw USB usage.
- */
-
-#ifndef USB_ACCESS_MAP_H_
-#define USB_ACCESS_MAP_H_
-
-#include <string>
-#include <iostream>
-#include <dpl/serialization.h>
-
-namespace USD {
-
-class USBDevicePath
-{
-public:
-    enum PathType {
-        PATH_TYPE_DEV,
-        PATH_TYPE_TOPO,
-        PATH_TYPE_SYSFS,
-    };
-
-    /* Never call this constructor with SysFS path received from user! */
-    USBDevicePath(const std::string &path, PathType path_type);
-    USBDevicePath(const std::string min, const std::string maj, std::string m_sysPath);
-    const std::string &getSysFSPath() const;
-    const std::string &getTopology() const;
-    dev_t getDev() const;
-
-    friend std::ostream &operator<<(std::ostream &stream,
-                                    const USBDevicePath &path);
-private:
-    void initFromSysFS(const std::string &path);
-    void initFromTopology(const std::string &path);
-    void initFromDev(const std::string &path);
-    std::string m_sysPath;
-    dev_t m_dev;
-};
-
-/*
- * As for now identifier may be just values from device descriptor,
- * but later this may be changed, so more flexible rules may be
- * introduced.
- */
-class USBDeviceId
-{
-public:
-    USBDeviceId(const USBDevicePath &path);
-    USBDeviceId(std::string values[], USBDevicePath m_path);
-    USBDeviceId(const std::string &path, USBDevicePath::PathType path_type);
-
-    bool operator<(const USBDeviceId &r) const;
-    bool operator==(const USBDeviceId &r) const;
-    bool operator!=(const USBDeviceId &r) const;
-
-    friend std::ostream &operator<<(std::ostream &stream,
-                                    const USBDeviceId &id);
-    const char *getTopology() const {return m_path.getTopology().c_str();}
-
-private:
-    void initDevId(const std::string &sys_path);
-
-    uint16_t m_bcdUSB;
-    uint8_t m_bDeviceClass;
-    uint8_t m_bDeviceSubClass;
-    uint8_t m_bDeviceProtocol;
-    uint16_t m_idVendor;
-    uint16_t m_idProduct;
-    uint16_t m_bcdDevice;
-    /*
-     * We should consider here also strings but it requires device
-     * communication, so should be discussed later.
-     * std::string m_iManufacturer;
-     * std::string m_iProduct;
-     * std::string m_iSerialNumber;
-     */
-
-    USBDevicePath m_path;
-};
-
-/**
- * Application identifier, a subject of policy entry that is
- * unique for a given app.
- *
- * As for now, this may be just smack label.
- * If later this will be used on a multi-user system, we might add
- * here additional field for user identifier. As for now it is not needed.
- */
-class PolicySubjectId
-{
-public:
-    PolicySubjectId(const std::string &smk);
-    PolicySubjectId(int socket);
-    PolicySubjectId(IStream &str);
-
-    bool operator<(const PolicySubjectId &r) const;
-    bool operator==(const PolicySubjectId &r) const;
-
-    friend std::ostream& operator<<(std::ostream& stream,
-                                    const PolicySubjectId& id);
-    const char *getAppData() const {return m_smk.c_str();}
-
-private:
-    std::string m_smk;
-};
-
-/**
- * This is a key for searching in a USBAccessMap structure
- */
-class USBAccessMapKey
-{
-public:
-    USBAccessMapKey(const PolicySubjectId &subject,
-                    const USBDeviceId &device);
-
-    bool validate(void) const;
-    bool operator<(const USBAccessMapKey &r) const;
-    bool operator==(const USBAccessMapKey &r) const;
-    friend std::ostream& operator<<(std::ostream& stream,
-                                    const USBAccessMapKey &key);
-    const char* getDeviceTopology() const {return m_device.getTopology();}
-    const char* getAppData() const {return m_subject.getAppData();}
-
-private:
-    PolicySubjectId m_subject;
-    USBDeviceId m_device;
-};
-
-
-typedef std::map<USBAccessMapKey, bool> USBAccessMap;
-
-} /* namespace USD */
-
-#endif /* USB_ACCESS_MAP_H_ */
diff --git a/USD/src/dpl/core/include/dpl/assert.h b/USD/src/dpl/core/include/dpl/assert.h
deleted file mode 100644 (file)
index 53707d6..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        assert.h
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of assert
- */
-#ifndef USD_ASSERT_H
-#define USD_ASSERT_H
-
-#include <dpl/noreturn.h>
-
-namespace USD {
-// Assertion handler procedure
-// Do not call directly
-// Always use Assert macro
-USD_NORETURN void AssertProc(const char *condition,
-                             const char *file,
-                             int line,
-                             const char *function);
-} // namespace USD
-
-#define Assert(Condition) do { if (!(Condition)) { USD::AssertProc(#Condition, \
-                                                                   __FILE__, \
-                                                                   __LINE__, \
-                                                                   __FUNCTION__); \
-                               } } while (0)
-
-#endif // USD_ASSERT_H
diff --git a/USD/src/dpl/core/include/dpl/binary_queue.h b/USD/src/dpl/core/include/dpl/binary_queue.h
deleted file mode 100644 (file)
index 8447d4d..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        binary_queue.h
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the header file of binary queue
- */
-#ifndef USD_BINARY_QUEUE_H
-#define USD_BINARY_QUEUE_H
-
-//#include <dpl/abstract_input_output.h>
-#include <dpl/exception.h>
-#include <dpl/noncopyable.h>
-#include <memory>
-#include <list>
-
-namespace USD {
-/**
- * Binary queue auto pointer
- */
-class BinaryQueue;
-typedef std::auto_ptr<BinaryQueue> BinaryQueueAutoPtr;
-
-/**
- * Binary stream implemented as constant size bucket list
- *
- * @todo Add optimized implementation for FlattenConsume
- */
-class BinaryQueue
-//  : public AbstractInputOutput
-{
-  public:
-    class Exception
-    {
-      public:
-        DECLARE_EXCEPTION_TYPE(USD::Exception, Base)
-        DECLARE_EXCEPTION_TYPE(Base, OutOfData)
-    };
-
-    typedef void (*BufferDeleter)(const void *buffer, size_t bufferSize,
-                                  void *userParam);
-    static void BufferDeleterFree(const void *buffer,
-                                  size_t bufferSize,
-                                  void *userParam);
-
-    class BucketVisitor
-    {
-      public:
-        /**
-         * Destructor
-         */
-        virtual ~BucketVisitor();
-
-        /**
-         * Visit bucket
-         *
-         * @return none
-         * @param[in] buffer Constant pointer to bucket data buffer
-         * @param[in] bufferSize Number of bytes in bucket
-         */
-        virtual void OnVisitBucket(const void *buffer, size_t bufferSize) = 0;
-    };
-
-  private:
-    struct Bucket :
-        private Noncopyable
-    {
-        const void *buffer;
-        const void *ptr;
-        size_t size;
-        size_t left;
-
-        BufferDeleter deleter;
-        void *param;
-
-        Bucket(const void *buffer,
-               size_t bufferSize,
-               BufferDeleter deleter,
-               void *userParam);
-        virtual ~Bucket();
-    };
-
-    typedef std::list<Bucket *> BucketList;
-    BucketList m_buckets;
-    size_t m_size;
-
-    static void DeleteBucket(Bucket *bucket);
-
-    class BucketVisitorCall
-    {
-      private:
-        BucketVisitor *m_visitor;
-
-      public:
-        BucketVisitorCall(BucketVisitor *visitor);
-        virtual ~BucketVisitorCall();
-
-        void operator()(Bucket *bucket) const;
-    };
-
-  public:
-    /**
-     * Construct empty binary queue
-     */
-    BinaryQueue();
-
-    /**
-     * Construct binary queue via bare copy of other binary queue
-     *
-     * @param[in] other Other binary queue to copy from
-     * @warning One cannot assume that bucket structure is preserved during copy
-     */
-    BinaryQueue(const BinaryQueue &other);
-
-    /**
-     * Destructor
-     */
-    virtual ~BinaryQueue();
-
-    /**
-     * Construct binary queue via bare copy of other binary queue
-     *
-     * @param[in] other Other binary queue to copy from
-     * @warning One cannot assume that bucket structure is preserved during copy
-     */
-    const BinaryQueue &operator=(const BinaryQueue &other);
-
-    /**
-     * Append copy of @a bufferSize bytes from memory pointed by @a buffer
-     * to the end of binary queue. Uses default deleter based on free.
-     *
-     * @return none
-     * @param[in] buffer Pointer to buffer to copy data from
-     * @param[in] bufferSize Number of bytes to copy
-     * @exception std::bad_alloc Cannot allocate memory to hold additional data
-     * @see BinaryQueue::BufferDeleterFree
-     */
-    void AppendCopy(const void *buffer, size_t bufferSize);
-
-    /**
-     * Append @a bufferSize bytes from memory pointed by @a buffer
-     * to the end of binary queue. Uses custom provided deleter.
-     * Responsibility for deleting provided buffer is transfered to BinaryQueue.
-     *
-     * @return none
-     * @param[in] buffer Pointer to data buffer
-     * @param[in] bufferSize Number of bytes available in buffer
-     * @param[in] deleter Pointer to deleter procedure used to free provided
-     * buffer
-     * @param[in] userParam User parameter passed to deleter routine
-     * @exception std::bad_alloc Cannot allocate memory to hold additional data
-     */
-    void AppendUnmanaged(
-        const void *buffer,
-        size_t bufferSize,
-        BufferDeleter deleter =
-            &BinaryQueue::BufferDeleterFree,
-        void *userParam = NULL);
-
-    /**
-     * Append copy of other binary queue to the end of this binary queue
-     *
-     * @return none
-     * @param[in] other Constant reference to other binary queue to copy data
-     * from
-     * @exception std::bad_alloc Cannot allocate memory to hold additional data
-     * @warning One cannot assume that bucket structure is preserved during copy
-     */
-    void AppendCopyFrom(const BinaryQueue &other);
-
-    /**
-     * Move bytes from other binary queue to the end of this binary queue.
-     * This also removes all bytes from other binary queue.
-     * This method is designed to be as fast as possible (only pointer swaps)
-     * and is suggested over making copies of binary queues.
-     * Bucket structure is preserved after operation.
-     *
-     * @return none
-     * @param[in] other Reference to other binary queue to move data from
-     * @exception std::bad_alloc Cannot allocate memory to hold additional data
-     */
-    void AppendMoveFrom(BinaryQueue &other);
-
-    /**
-     * Append copy of binary queue to the end of other binary queue
-     *
-     * @return none
-     * @param[in] other Constant reference to other binary queue to copy data to
-     * @exception std::bad_alloc Cannot allocate memory to hold additional data
-     * @warning One cannot assume that bucket structure is preserved during copy
-     */
-    void AppendCopyTo(BinaryQueue &other) const;
-
-    /**
-     * Move bytes from binary queue to the end of other binary queue.
-     * This also removes all bytes from binary queue.
-     * This method is designed to be as fast as possible (only pointer swaps)
-     * and is suggested over making copies of binary queues.
-     * Bucket structure is preserved after operation.
-     *
-     * @return none
-     * @param[in] other Reference to other binary queue to move data to
-     * @exception std::bad_alloc Cannot allocate memory to hold additional data
-     */
-    void AppendMoveTo(BinaryQueue &other);
-
-    /**
-     * Retrieve total size of all data contained in binary queue
-     *
-     * @return Number of bytes in binary queue
-     */
-    size_t Size() const;
-
-    /**
-     * Remove all data from binary queue
-     *
-     * @return none
-     */
-    void Clear();
-
-    /**
-     * Check if binary queue is empty
-     *
-     * @return true if binary queue is empty, false otherwise
-     */
-    bool Empty() const;
-
-    /**
-     * Remove @a size bytes from beginning of binary queue
-     *
-     * @return none
-     * @param[in] size Number of bytes to remove
-     * @exception BinaryQueue::Exception::OutOfData Number of bytes is larger
-     *            than available bytes in binary queue
-     */
-    void Consume(size_t size);
-
-    /**
-     * Retrieve @a bufferSize bytes from beginning of binary queue and copy them
-     * to user supplied buffer
-     *
-     * @return none
-     * @param[in] buffer Pointer to user buffer to receive bytes
-     * @param[in] bufferSize Size of user buffer pointed by @a buffer
-     * @exception BinaryQueue::Exception::OutOfData Number of bytes to flatten
-     *            is larger than available bytes in binary queue
-     */
-    void Flatten(void *buffer, size_t bufferSize) const;
-
-    /**
-     * Retrieve @a bufferSize bytes from beginning of binary queue, copy them
-     * to user supplied buffer, and remove from binary queue
-     *
-     * @return none
-     * @param[in] buffer Pointer to user buffer to receive bytes
-     * @param[in] bufferSize Size of user buffer pointed by @a buffer
-     * @exception BinaryQueue::Exception::OutOfData Number of bytes to flatten
-     *            is larger than available bytes in binary queue
-     */
-    void FlattenConsume(void *buffer, size_t bufferSize);
-
-    /**
-     * Visit each buffer with data using visitor object
-     *
-     * @return none
-     * @param[in] visitor Pointer to bucket visitor
-     * @see BinaryQueue::BucketVisitor
-     */
-    void VisitBuckets(BucketVisitor *visitor) const;
-
-    /**
-     * IAbstractInput interface
-     */
-    virtual BinaryQueueAutoPtr Read(size_t size);
-
-    /**
-     * IAbstractOutput interface
-     */
-    virtual size_t Write(const BinaryQueue &buffer, size_t bufferSize);
-};
-
-} // namespace USD
-
-#endif // USD_BINARY_QUEUE_H
diff --git a/USD/src/dpl/core/include/dpl/colors.h b/USD/src/dpl/core/include/dpl/colors.h
deleted file mode 100644 (file)
index 9fb30a2..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        colors.h
- * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version     1.0
- * @brief       Some constants with definition of colors for Console
- *              and html output
- */
-
-#ifndef USD_COLORS_H
-#define USD_COLORS_H
-
-namespace USD {
-namespace Colors {
-namespace Text {
-extern const char* BOLD_GREEN_BEGIN;
-extern const char* BOLD_GREEN_END;
-extern const char* PURPLE_BEGIN;
-extern const char* PURPLE_END;
-extern const char* RED_BEGIN;
-extern const char* RED_END;
-extern const char* GREEN_BEGIN;
-extern const char* GREEN_END;
-extern const char* CYAN_BEGIN;
-extern const char* CYAN_END;
-extern const char* BOLD_RED_BEGIN;
-extern const char* BOLD_RED_END;
-extern const char* BOLD_YELLOW_BEGIN;
-extern const char* BOLD_YELLOW_END;
-extern const char* BOLD_GOLD_BEGIN;
-extern const char* BOLD_GOLD_END;
-extern const char* BOLD_WHITE_BEGIN;
-extern const char* BOLD_WHITE_END;
-} //namespace Text
-
-namespace Html {
-extern const char* BOLD_GREEN_BEGIN;
-extern const char* BOLD_GREEN_END;
-extern const char* PURPLE_BEGIN;
-extern const char* PURPLE_END;
-extern const char* RED_BEGIN;
-extern const char* RED_END;
-extern const char* GREEN_BEGIN;
-extern const char* GREEN_END;
-extern const char* CYAN_BEGIN;
-extern const char* CYAN_END;
-extern const char* BOLD_RED_BEGIN;
-extern const char* BOLD_RED_END;
-extern const char* BOLD_YELLOW_BEGIN;
-extern const char* BOLD_YELLOW_END;
-extern const char* BOLD_GOLD_BEGIN;
-extern const char* BOLD_GOLD_END;
-extern const char* BOLD_WHITE_BEGIN;
-extern const char* BOLD_WHITE_END;
-} //namespace Html
-} //namespace Colors
-} //namespace USD
-
-#endif /* USD_COLORS_H */
diff --git a/USD/src/dpl/core/include/dpl/exception.h b/USD/src/dpl/core/include/dpl/exception.h
deleted file mode 100644 (file)
index d76f989..0000000
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file    exception.h
- * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief   Header file for base exception
- */
-#ifndef USD_EXCEPTION_H
-#define USD_EXCEPTION_H
-
-#include <string>
-#include <cstring>
-#include <cstdio>
-#include <exception>
-#include <cstdlib>
-#include <sstream>
-
-namespace USD {
-void LogUnhandledException(const std::string &str);
-void LogUnhandledException(const std::string &str,
-                           const char *filename,
-                           int line,
-                           const char *function);
-}
-
-namespace USD {
-class Exception
-{
-  private:
-    static unsigned int m_exceptionCount;
-    static Exception* m_lastException;
-    static void (*m_terminateHandler)();
-
-    static void AddRef(Exception* exception)
-    {
-        if (!m_exceptionCount) {
-            m_terminateHandler = std::set_terminate(&TerminateHandler);
-        }
-
-        ++m_exceptionCount;
-        m_lastException = exception;
-    }
-
-    static void UnRef(Exception* e)
-    {
-        if (m_lastException == e) {
-            m_lastException = NULL;
-        }
-
-        --m_exceptionCount;
-
-        if (!m_exceptionCount) {
-            std::set_terminate(m_terminateHandler);
-            m_terminateHandler = NULL;
-        }
-    }
-
-    static void TerminateHandler()
-    {
-        if (m_lastException != NULL) {
-            DisplayKnownException(*m_lastException);
-            abort();
-        } else {
-            DisplayUnknownException();
-            abort();
-        }
-    }
-
-    Exception *m_reason;
-    std::string m_path;
-    std::string m_function;
-    int m_line;
-
-  protected:
-    std::string m_message;
-    std::string m_className;
-
-  public:
-    static std::string KnownExceptionToString(const Exception &e)
-    {
-        std::ostringstream message;
-        message <<
-        "\033[1;5;31m\n=== Unhandled USD exception occurred ===\033[m\n\n";
-        message << "\033[1;33mException trace:\033[m\n\n";
-        message << e.DumpToString();
-        message << "\033[1;31m\n=== Will now abort ===\033[m\n";
-
-        return message.str();
-    }
-
-    static std::string UnknownExceptionToString()
-    {
-        std::ostringstream message;
-        message <<
-        "\033[1;5;31m\n=== Unhandled non-USD exception occurred ===\033[m\n\n";
-        message << "\033[1;31m\n=== Will now abort ===\033[m\n";
-
-        return message.str();
-    }
-
-    static void DisplayKnownException(const Exception& e)
-    {
-        LogUnhandledException(KnownExceptionToString(e).c_str());
-    }
-
-    static void DisplayUnknownException()
-    {
-        LogUnhandledException(UnknownExceptionToString().c_str());
-    }
-
-    Exception(const Exception &other)
-    {
-        // Deep copy
-        if (other.m_reason != NULL) {
-            m_reason = new Exception(*other.m_reason);
-        } else {
-            m_reason = NULL;
-        }
-
-        m_message = other.m_message;
-        m_path = other.m_path;
-        m_function = other.m_function;
-        m_line = other.m_line;
-
-        m_className = other.m_className;
-
-        AddRef(this);
-    }
-
-    const Exception &operator =(const Exception &other)
-    {
-        if (this == &other) {
-            return *this;
-        }
-
-        // Deep copy
-        if (other.m_reason != NULL) {
-            m_reason = new Exception(*other.m_reason);
-        } else {
-            m_reason = NULL;
-        }
-
-        m_message = other.m_message;
-        m_path = other.m_path;
-        m_function = other.m_function;
-        m_line = other.m_line;
-
-        m_className = other.m_className;
-
-        AddRef(this);
-
-        return *this;
-    }
-
-    Exception(const char *path,
-              const char *function,
-              int line,
-              const std::string &message) :
-        m_reason(NULL),
-        m_path(path),
-        m_function(function),
-        m_line(line),
-        m_message(message)
-    {
-        AddRef(this);
-    }
-
-    Exception(const char *path,
-              const char *function,
-              int line,
-              const Exception &reason,
-              const std::string &message) :
-        m_reason(new Exception(reason)),
-        m_path(path),
-        m_function(function),
-        m_line(line),
-        m_message(message)
-    {
-        AddRef(this);
-    }
-
-    virtual ~Exception() throw()
-    {
-        if (m_reason != NULL) {
-            delete m_reason;
-            m_reason = NULL;
-        }
-
-        UnRef(this);
-    }
-
-    void Dump() const
-    {
-        // Show reason first
-        if (m_reason != NULL) {
-            m_reason->Dump();
-        }
-
-        // Afterward, dump exception
-        const char *file = strchr(m_path.c_str(), '/');
-
-        if (file == NULL) {
-            file = m_path.c_str();
-        } else {
-            ++file;
-        }
-
-        printf("\033[0;36m[%s:%i]\033[m %s() \033[4;35m%s\033[m: %s\033[m\n",
-               file, m_line,
-               m_function.c_str(),
-               m_className.c_str(),
-               m_message.empty() ? "<EMPTY>" : m_message.c_str());
-    }
-
-    std::string DumpToString() const
-    {
-        std::string ret;
-        if (m_reason != NULL) {
-            ret = m_reason->DumpToString();
-        }
-
-        const char *file = strchr(m_path.c_str(), '/');
-
-        if (file == NULL) {
-            file = m_path.c_str();
-        } else {
-            ++file;
-        }
-
-        char buf[1024];
-        snprintf(buf,
-                 sizeof(buf),
-                 "\033[0;36m[%s:%i]\033[m %s() \033[4;35m%s\033[m: %s\033[m\n",
-                 file,
-                 m_line,
-                 m_function.c_str(),
-                 m_className.c_str(),
-                 m_message.empty() ? "<EMPTY>" : m_message.c_str());
-
-        buf[sizeof(buf) - 1] = '\n';
-        ret += buf;
-
-        return ret;
-    }
-
-    Exception *GetReason() const
-    {
-        return m_reason;
-    }
-
-    std::string GetPath() const
-    {
-        return m_path;
-    }
-
-    std::string GetFunction() const
-    {
-        return m_function;
-    }
-
-    int GetLine() const
-    {
-        return m_line;
-    }
-
-    std::string GetMessage() const
-    {
-        return m_message;
-    }
-
-    std::string GetClassName() const
-    {
-        return m_className;
-    }
-};
-} // namespace USD
-
-#define Try try
-
-#define Throw(ClassName) \
-    throw ClassName(__FILE__, __FUNCTION__, __LINE__)
-
-#define ThrowMsg(ClassName, Message)                                                 \
-    do                                                                               \
-    {                                                                                \
-        std::ostringstream dplLoggingStream;                                         \
-        dplLoggingStream << Message;                                                 \
-        throw ClassName(__FILE__, __FUNCTION__, __LINE__, dplLoggingStream.str());   \
-    } while (0)
-
-#define ReThrow(ClassName) \
-    throw ClassName(__FILE__, __FUNCTION__, __LINE__, _rethrown_exception)
-
-#define ReThrowMsg(ClassName, Message) \
-    throw ClassName(__FILE__, \
-                    __FUNCTION__, \
-                    __LINE__, \
-                    _rethrown_exception, \
-                    Message)
-
-#define Catch(ClassName) \
-    catch (const ClassName &_rethrown_exception)
-
-#define DECLARE_EXCEPTION_TYPE(BaseClass, Class)                                                                                          \
-    class Class :                                                                                                                                 \
-        public BaseClass                                                                                                                \
-    {                                                                                                                                     \
-      public:                                                                                                                               \
-        Class(const char *path, \
-              const char *function, \
-              int line, \
-              const std::string & message = std::string()) :                                                                                                                             \
-            BaseClass(path, function, line, message)                                                                                    \
-        {                                                                                                                                 \
-            BaseClass::m_className = #Class;                                                                                              \
-        }                                                                                                                                 \
-                                                                                                                                          \
-        Class(const char *path, \
-              const char *function, \
-              int line, \
-              const USD::Exception & reason, \
-              const std::string & message = std::string()) :                                                                                                                             \
-            BaseClass(path, function, line, reason, message)                                                                            \
-        {                                                                                                                                 \
-            BaseClass::m_className = #Class;                                                                                              \
-        }                                                                                                                                 \
-    };
-
-#define UNHANDLED_EXCEPTION_HANDLER_BEGIN try
-
-#define UNHANDLED_EXCEPTION_HANDLER_END                                                                   \
-    catch (const USD::Exception &exception)                                                               \
-    {                                                                                                     \
-        std::ostringstream msg;                                                                           \
-        msg << USD::Exception::KnownExceptionToString(exception);                                         \
-        USD::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__);                          \
-        abort();                                                                                          \
-    }                                                                                                     \
-    catch (std::exception& e)                                                                             \
-    {                                                                                                     \
-        std::ostringstream msg;                                                                           \
-        msg << e.what();                                                                                  \
-        msg << "\n";                                                                                      \
-        msg << USD::Exception::UnknownExceptionToString();                                                \
-        USD::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__);                          \
-        abort();                                                                                          \
-    }                                                                                                     \
-    catch (...)                                                                                           \
-    {                                                                                                     \
-        std::ostringstream msg;                                                                           \
-        msg << USD::Exception::UnknownExceptionToString();                                                \
-        USD::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__);                          \
-        abort();                                                                                          \
-    }
-
-namespace USD {
-namespace CommonException {
-/**
- * Internal exception definitions
- *
- * These should normally not happen.
- * Usually, exception trace with internal error includes
- * important messages.
- */
-DECLARE_EXCEPTION_TYPE(Exception, InternalError) ///< Unexpected error from
-                                                 // underlying libraries or
-                                                 // kernel
-}
-}
-
-#endif // USD_EXCEPTION_H
diff --git a/USD/src/dpl/core/include/dpl/fstream_accessors.h b/USD/src/dpl/core/include/dpl/fstream_accessors.h
deleted file mode 100644 (file)
index e8c4310..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        fstream-helper.h
- * @author      Marek Smolinski (m.smolinski@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of fstream-helper
- *
- */
-
-#ifndef USD_FSTREAM_ACCESSORS_H
-#define USD_FSTREAM_ACCESSORS_H
-
-namespace DPL {
-
-/*
- * Bypass lack of public member function to get file
- * descriptor from fstream objects in std
- * This feature is needed for flushing data from kernel space buffer to
- * physical device [fsync(int fd) - syscall] on opened fstream object
-*/
-
-template<typename T>
-class FstreamAccessors : T::__filebuf_type {
-    typedef FstreamAccessors<T> MyType;
-public:
-    static int GetFd(T &strm) {
-        return static_cast<MyType *>(strm.rdbuf())->_M_file.fd();
-    }
-};
-
-} // namespace DPL
-
-#endif // USD_FSTREAM_ACCESSORS_H
diff --git a/USD/src/dpl/core/include/dpl/noncopyable.h b/USD/src/dpl/core/include/dpl/noncopyable.h
deleted file mode 100644 (file)
index 32ef1f4..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        noncopyable
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of noncopyable
- */
-#ifndef USD_NONCOPYABLE_H
-#define USD_NONCOPYABLE_H
-
-namespace USD {
-class Noncopyable
-{
-  private:
-    Noncopyable(const Noncopyable &);
-    const Noncopyable &operator=(const Noncopyable &);
-
-  public:
-    Noncopyable();
-    virtual ~Noncopyable();
-};
-} // namespace USD
-
-#endif // USD_NONCOPYABLE_H
diff --git a/USD/src/dpl/core/include/dpl/noreturn.h b/USD/src/dpl/core/include/dpl/noreturn.h
deleted file mode 100644 (file)
index 675e33f..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        noreturn.h
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of noreturn
- */
-#ifndef USD_NORETURN_H
-#define USD_NORETURN_H
-
-#define USD_NORETURN __attribute__((__noreturn__))
-
-#endif // USD_NORETURN_H
diff --git a/USD/src/dpl/core/include/dpl/serialization.h b/USD/src/dpl/core/include/dpl/serialization.h
deleted file mode 100644 (file)
index e39997d..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file    serialization.h
- * @author  Tomasz Swierczek (t.swierczek@samsung.com)
- * @version 1.0
- * @brief   Interfaces and templates used for data serialization.
- */
-#ifndef SERIALIZATION_H
-#define SERIALIZATION_H
-
-#include <string>
-#include <vector>
-#include <list>
-#include <map>
-#include <memory>
-
-namespace USD {
-// Abstract data stream buffer
-class IStream
-{
-  public:
-    virtual void Read(size_t num, void * bytes) = 0;
-    virtual void Write(size_t num, const void * bytes) = 0;
-    virtual ~IStream(){}
-};
-
-// Serializable interface
-class ISerializable
-{
-  public:
-    /*    ISerializable(){};
-     *    ISerializable(IStream&){}; */
-    virtual void Serialize(IStream &) const = 0;
-    virtual ~ISerializable(){}
-};
-
-struct Serialization {
-    // serialization
-    // normal functions
-
-    // ISerializable objects
-    static void Serialize(IStream& stream, const ISerializable& object)
-    {
-        object.Serialize(stream);
-    }
-    static void Serialize(IStream& stream, const ISerializable* const object)
-    {
-        object->Serialize(stream);
-    }
-
-    // char
-    static void Serialize(IStream& stream, const char value)
-    {
-        stream.Write(sizeof(value), &value);
-    }
-    static void Serialize(IStream& stream, const char* const value)
-    {
-        stream.Write(sizeof(*value), value);
-    }
-
-    // unsigned char
-    static void Serialize(IStream& stream, const unsigned char value)
-    {
-        stream.Write(sizeof(value), &value);
-    }
-    static void Serialize(IStream& stream, const unsigned char* const value)
-    {
-        stream.Write(sizeof(*value), value);
-    }
-
-    // unsigned int
-    static void Serialize(IStream& stream, const unsigned value)
-    {
-        stream.Write(sizeof(value), &value);
-    }
-    static void Serialize(IStream& stream, const unsigned* const value)
-    {
-        stream.Write(sizeof(*value), value);
-    }
-
-    // int
-    static void Serialize(IStream& stream, const int value)
-    {
-        stream.Write(sizeof(value), &value);
-    }
-    static void Serialize(IStream& stream, const int* const value)
-    {
-        stream.Write(sizeof(*value), value);
-    }
-
-    // bool
-    static void Serialize(IStream& stream, const bool value)
-    {
-        stream.Write(sizeof(value), &value);
-    }
-    static void Serialize(IStream& stream, const bool* const value)
-    {
-        stream.Write(sizeof(*value), value);
-    }
-
-    // time_t
-    static void Serialize(IStream& stream, const time_t value)
-    {
-        stream.Write(sizeof(value), &value);
-    }
-    static void Serialize(IStream& stream, const time_t* const value)
-    {
-        stream.Write(sizeof(*value), value);
-    }
-
-    // std::string
-    static void Serialize(IStream& stream, const std::string& str)
-    {
-        int length = str.size();
-        stream.Write(sizeof(length), &length);
-        stream.Write(length, str.c_str());
-    }
-    static void Serialize(IStream& stream, const std::string* const str)
-    {
-        int length = str->size();
-        stream.Write(sizeof(length), &length);
-        stream.Write(length, str->c_str());
-    }
-
-    // STL templates
-
-    // std::list
-    template <typename T>
-    static void Serialize(IStream& stream, const std::list<T>& list)
-    {
-        int 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);
-        }
-    }
-    template <typename T>
-    static void Serialize(IStream& stream, const std::list<T>* const list)
-    {
-        Serialize(stream, *list);
-    }
-
-    // std::vector
-    template <typename T>
-    static void Serialize(IStream& stream, const std::vector<T>& vec)
-    {
-        int length = vec.size();
-        stream.Write(sizeof(length), &length);
-        for (typename std::vector<T>::const_iterator vec_iter = vec.begin();
-             vec_iter != vec.end(); vec_iter++)
-        {
-            Serialize(stream, *vec_iter);
-        }
-    }
-    template <typename T>
-    static void Serialize(IStream& stream, const std::vector<T>* const vec)
-    {
-        Serialize(stream, *vec);
-    }
-
-    // std::pair
-    template <typename A, typename B>
-    static void Serialize(IStream& stream, const std::pair<A, B>& p)
-    {
-        Serialize(stream, p.first);
-        Serialize(stream, p.second);
-    }
-    template <typename A, typename B>
-    static void Serialize(IStream& stream, const std::pair<A, B>* const p)
-    {
-        Serialize(stream, *p);
-    }
-
-    // std::map
-    template <typename K, typename T>
-    static void Serialize(IStream& stream, const std::map<K, T>& map)
-    {
-        int 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);
-        }
-    }
-    template <typename K, typename T>
-    static void Serialize(IStream& stream, const std::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)
-    {
-        Serialize(stream, *p);
-    }
-}; // struct Serialization
-
-struct Deserialization {
-    // deserialization
-    // normal functions
-
-    // ISerializable objects
-    // T instead of ISerializable is needed to call proper constructor
-    template <typename T>
-    static void Deserialize(IStream& stream, T& object)
-    {
-        object = T(stream);
-    }
-    template <typename T>
-    static void Deserialize(IStream& stream, T*& object)
-    {
-        object = new T(stream);
-    }
-
-    // char
-    static void Deserialize(IStream& stream, char& value)
-    {
-        stream.Read(sizeof(value), &value);
-    }
-    static void Deserialize(IStream& stream, char*& value)
-    {
-        value = new char;
-        stream.Read(sizeof(*value), value);
-    }
-
-    // unsigned char
-    static void Deserialize(IStream& stream, unsigned char& value)
-    {
-        stream.Read(sizeof(value), &value);
-    }
-    static void Deserialize(IStream& stream, unsigned char*& value)
-    {
-        value = new unsigned char;
-        stream.Read(sizeof(*value), value);
-    }
-
-    // unsigned int
-    static void Deserialize(IStream& stream, unsigned& value)
-    {
-        stream.Read(sizeof(value), &value);
-    }
-    static void Deserialize(IStream& stream, unsigned*& value)
-    {
-        value = new unsigned;
-        stream.Read(sizeof(*value), value);
-    }
-
-    // int
-    static void Deserialize(IStream& stream, int& value)
-    {
-        stream.Read(sizeof(value), &value);
-    }
-    static void Deserialize(IStream& stream, int*& value)
-    {
-        value = new int;
-        stream.Read(sizeof(*value), value);
-    }
-
-    // bool
-    static void Deserialize(IStream& stream, bool& value)
-    {
-        stream.Read(sizeof(value), &value);
-    }
-    static void Deserialize(IStream& stream, bool*& value)
-    {
-        value = new bool;
-        stream.Read(sizeof(*value), value);
-    }
-
-    // time_t
-    static void Deserialize(IStream& stream, time_t& value)
-    {
-        stream.Read(sizeof(value), &value);
-    }
-    static void Deserialize(IStream& stream, time_t*& value)
-    {
-        value = new time_t;
-        stream.Read(sizeof(*value), value);
-    }
-
-    // std::string
-    static void Deserialize(IStream& stream, std::string& str)
-    {
-        int length;
-        stream.Read(sizeof(length), &length);
-        char * buf = new char[length + 1];
-        stream.Read(length, buf);
-        buf[length] = 0;
-        str = std::string(buf);
-        delete[] buf;
-    }
-    static void Deserialize(IStream& stream, std::string*& str)
-    {
-        int length;
-        stream.Read(sizeof(length), &length);
-        char * buf = new char[length + 1];
-        stream.Read(length, buf);
-        buf[length] = 0;
-        str = new std::string(buf);
-        delete[] buf;
-    }
-
-    // STL templates
-
-    // std::list
-    template <typename T>
-    static void Deserialize(IStream& stream, std::list<T>& list)
-    {
-        int length;
-        stream.Read(sizeof(length), &length);
-        for (int i = 0; i < length; ++i) {
-            T obj;
-            Deserialize(stream, obj);
-            list.push_back(std::move(obj));
-        }
-    }
-    template <typename T>
-    static void Deserialize(IStream& stream, std::list<T>*& list)
-    {
-        list = new std::list<T>;
-        Deserialize(stream, *list);
-    }
-
-    // std::vector
-    template <typename T>
-    static void Deserialize(IStream& stream, std::vector<T>& vec)
-    {
-        int length;
-        stream.Read(sizeof(length), &length);
-        for (int i = 0; i < length; ++i) {
-            T obj;
-            Deserialize(stream, obj);
-            vec.push_back(std::move(obj));
-        }
-    }
-    template <typename T>
-    static void Deserialize(IStream& stream, std::vector<T>*& vec)
-    {
-        vec = new std::vector<T>;
-        Deserialize(stream, *vec);
-    }
-
-    // std::pair
-    template <typename A, typename B>
-    static void Deserialize(IStream& stream, std::pair<A, B>& p)
-    {
-        Deserialize(stream, p.first);
-        Deserialize(stream, p.second);
-    }
-    template <typename A, typename B>
-    static void Deserialize(IStream& stream, std::pair<A, B>*& p)
-    {
-        p = new std::pair<A, B>;
-        Deserialize(stream, *p);
-    }
-
-    // std::map
-    template <typename K, typename T>
-    static void Deserialize(IStream& stream, std::map<K, T>& map)
-    {
-        int length;
-        stream.Read(sizeof(length), &length);
-        for (int 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::map<K, T>*& map)
-    {
-        map = new std::map<K, T>;
-        Deserialize(stream, *map);
-    }
-}; // struct Deserialization
-} // namespace USD
-
-#endif // SERIALIZATION_H
diff --git a/USD/src/dpl/core/include/dpl/singleton.h b/USD/src/dpl/core/include/dpl/singleton.h
deleted file mode 100644 (file)
index c2de5af..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        singleton.h
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of singleton
- */
-#ifndef USD_SINGLETON_H
-#define USD_SINGLETON_H
-
-namespace USD {
-template<typename Class>
-class Singleton :
-    private Class
-{
-    //
-    // Note:
-    //
-    // To remove posibility of instantiating directly Class,
-    // make Class' default constructor protected
-    //
-
-  private:
-    Singleton()
-    {}
-
-    static Singleton &InternalInstance();
-
-  public:
-    virtual ~Singleton()
-    {}
-
-    static Class &Instance();
-};
-} // namespace USD
-
-#endif // USD_SINGLETON_H
diff --git a/USD/src/dpl/core/include/dpl/singleton_impl.h b/USD/src/dpl/core/include/dpl/singleton_impl.h
deleted file mode 100644 (file)
index 3347d5c..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        singleton_impl.h
- * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of singleton
- */
-#ifndef USD_SINGLETON_IMPL_H
-#define USD_SINGLETON_IMPL_H
-
-/*
- * WARNING!
- *
- * If some singleton's implementation uses another singletons implementation,
- * those templates make the second singleton a dubleton. Be warned. Try to use
- * singleton_safe_impl.h if possible.
- */
-
-namespace USD {
-template<typename Class>
-Singleton<Class>& Singleton<Class>::InternalInstance()
-{
-    static Singleton<Class> instance;
-    return instance;
-}
-
-template<typename Class>
-Class &Singleton<Class>::Instance()
-{
-    Singleton<Class>& instance = Singleton<Class>::InternalInstance();
-    return instance;
-}
-} // namespace USD
-
-#define IMPLEMENT_SINGLETON(Type)                                           \
-    template USD::Singleton<Type>&USD::Singleton<Type>::InternalInstance();    \
-    template Type & USD::Singleton<Type>::Instance();                            \
-
-#endif // USD_SINGLETON_IMPL_H
diff --git a/USD/src/dpl/core/include/dpl/singleton_safe_impl.h b/USD/src/dpl/core/include/dpl/singleton_safe_impl.h
deleted file mode 100644 (file)
index 4e80096..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        singleton_safe_impl.h
- * @author      Tomasz Swierczek (t.swierczek@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of singleton
- */
-#ifndef USD_SINGLETON_SAFE_IMPL_H
-#define USD_SINGLETON_SAFE_IMPL_H
-
-#define IMPLEMENT_SAFE_SINGLETON(Class)                                        \
-    namespace USD {                                                                \
-    template<>                                                                     \
-    Singleton<Class>&Singleton<Class>::InternalInstance()                         \
-    {                                                                              \
-        static Singleton<Class> instance;                                          \
-        return instance;                                                           \
-    }                                                                              \
-                                                                               \
-    template<>                                                                     \
-    Class & Singleton<Class>::Instance()                                            \
-    {                                                                              \
-        Singleton<Class>& instance = Singleton<Class>::InternalInstance();         \
-        return instance;                                                           \
-    }                                                                              \
-                                                                               \
-    template Singleton<Class>&Singleton<Class>::InternalInstance();               \
-    template Class & Singleton<Class>::Instance();                                  \
-    } // namespace USD
-
-#endif // USD_SINGLETON_SAFE_IMPL_H
diff --git a/USD/src/dpl/core/src/assert.cpp b/USD/src/dpl/core/src/assert.cpp
deleted file mode 100644 (file)
index 5661fc7..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        assert.cpp
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of assert
- */
-#include <stddef.h>
-#include <dpl/assert.h>
-#include <dpl/colors.h>
-#include <dpl/log/log.h>
-#include <dpl/exception.h>
-#include <cstdlib>
-
-namespace USD {
-void AssertProc(const char *condition,
-                const char *file,
-                int line,
-                const char *function)
-{
-#define INTERNAL_LOG(message)                                          \
-    do                                                                 \
-    {                                                                  \
-        std::ostringstream platformLog;                                \
-        platformLog << message;                                        \
-        USD::Log::LogSystemSingleton::Instance().Pedantic(             \
-            platformLog.str().c_str(),                                 \
-            __FILE__, __LINE__, __FUNCTION__);                         \
-    } \
-    while (0)
-
-    // Try to log failed assertion to log system
-    Try
-    {
-        INTERNAL_LOG(
-            "################################################################################");
-        INTERNAL_LOG(
-            "###                          USD assertion failed!                           ###");
-        INTERNAL_LOG(
-            "################################################################################");
-        INTERNAL_LOG("### Condition: " << condition);
-        INTERNAL_LOG("### File: " << file);
-        INTERNAL_LOG("### Line: " << line);
-        INTERNAL_LOG("### Function: " << function);
-        INTERNAL_LOG(
-            "################################################################################");
-    } catch (Exception) {
-        // Just ignore possible double errors
-    }
-
-    // Fail with c-library abort
-    abort();
-}
-} // namespace USD
diff --git a/USD/src/dpl/core/src/binary_queue.cpp b/USD/src/dpl/core/src/binary_queue.cpp
deleted file mode 100644 (file)
index 6bac603..0000000
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        binary_queue.cpp
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of binary queue
- */
-#include <stddef.h>
-#include <dpl/binary_queue.h>
-#include <dpl/assert.h>
-#include <algorithm>
-#include <malloc.h>
-#include <cstring>
-#include <new>
-
-namespace USD {
-BinaryQueue::BinaryQueue() :
-    m_size(0)
-{}
-
-BinaryQueue::BinaryQueue(const BinaryQueue &other) :
-    m_size(0)
-{
-    AppendCopyFrom(other);
-}
-
-BinaryQueue::~BinaryQueue()
-{
-    // Remove all remainig buckets
-    Clear();
-}
-
-const BinaryQueue &BinaryQueue::operator=(const BinaryQueue &other)
-{
-    if (this != &other) {
-        Clear();
-        AppendCopyFrom(other);
-    }
-
-    return *this;
-}
-
-void BinaryQueue::AppendCopyFrom(const BinaryQueue &other)
-{
-    // To speed things up, always copy as one bucket
-    void *bufferCopy = malloc(other.m_size);
-
-    if (bufferCopy == NULL) {
-        throw std::bad_alloc();
-    }
-
-    try {
-        other.Flatten(bufferCopy, other.m_size);
-        AppendUnmanaged(bufferCopy, other.m_size, &BufferDeleterFree, NULL);
-    } catch (const std::bad_alloc &) {
-        // Free allocated memory
-        free(bufferCopy);
-        throw;
-    }
-}
-
-void BinaryQueue::AppendMoveFrom(BinaryQueue &other)
-{
-    // Copy all buckets
-    std::copy(other.m_buckets.begin(),
-              other.m_buckets.end(), std::back_inserter(m_buckets));
-    m_size += other.m_size;
-
-    // Clear other, but do not free memory
-    other.m_buckets.clear();
-    other.m_size = 0;
-}
-
-void BinaryQueue::AppendCopyTo(BinaryQueue &other) const
-{
-    other.AppendCopyFrom(*this);
-}
-
-void BinaryQueue::AppendMoveTo(BinaryQueue &other)
-{
-    other.AppendMoveFrom(*this);
-}
-
-void BinaryQueue::Clear()
-{
-    std::for_each(m_buckets.begin(), m_buckets.end(), &DeleteBucket);
-    m_buckets.clear();
-    m_size = 0;
-}
-
-void BinaryQueue::AppendCopy(const void* buffer, size_t bufferSize)
-{
-    // Create data copy with malloc/free
-    void *bufferCopy = malloc(bufferSize);
-
-    // Check if allocation succeded
-    if (bufferCopy == NULL) {
-        throw std::bad_alloc();
-    }
-
-    // Copy user data
-    memcpy(bufferCopy, buffer, bufferSize);
-
-    try {
-        // Try to append new bucket
-        AppendUnmanaged(bufferCopy, bufferSize, &BufferDeleterFree, NULL);
-    } catch (const std::bad_alloc &) {
-        // Free allocated memory
-        free(bufferCopy);
-        throw;
-    }
-}
-
-void BinaryQueue::AppendUnmanaged(const void* buffer,
-                                  size_t bufferSize,
-                                  BufferDeleter deleter,
-                                  void* userParam)
-{
-    // Do not attach empty buckets
-    if (bufferSize == 0) {
-        deleter(buffer, bufferSize, userParam);
-        return;
-    }
-
-    // Just add new bucket with selected deleter
-    Bucket *bucket = new Bucket(buffer, bufferSize, deleter, userParam);
-    try {
-        m_buckets.push_back(bucket);
-    } catch (const std::bad_alloc &) {
-        delete bucket;
-        throw;
-    }
-
-    // Increase total queue size
-    m_size += bufferSize;
-}
-
-size_t BinaryQueue::Size() const
-{
-    return m_size;
-}
-
-bool BinaryQueue::Empty() const
-{
-    return m_size == 0;
-}
-
-void BinaryQueue::Consume(size_t size)
-{
-    // Check parameters
-    if (size > m_size) {
-        Throw(Exception::OutOfData);
-    }
-
-    size_t bytesLeft = size;
-
-    // Consume data and/or remove buckets
-    while (bytesLeft > 0) {
-        // Get consume size
-        size_t count = std::min(bytesLeft, m_buckets.front()->left);
-
-        m_buckets.front()->ptr =
-            static_cast<const char *>(m_buckets.front()->ptr) + count;
-        m_buckets.front()->left -= count;
-        bytesLeft -= count;
-        m_size -= count;
-
-        if (m_buckets.front()->left == 0) {
-            DeleteBucket(m_buckets.front());
-            m_buckets.pop_front();
-        }
-    }
-}
-
-void BinaryQueue::Flatten(void *buffer, size_t bufferSize) const
-{
-    // Check parameters
-    if (bufferSize == 0) {
-        return;
-    }
-
-    if (bufferSize > m_size) {
-        Throw(Exception::OutOfData);
-    }
-
-    size_t bytesLeft = bufferSize;
-    void *ptr = buffer;
-    BucketList::const_iterator bucketIterator = m_buckets.begin();
-    Assert(m_buckets.end() != bucketIterator);
-
-    // Flatten data
-    while (bytesLeft > 0) {
-        // Get consume size
-        size_t count = std::min(bytesLeft, (*bucketIterator)->left);
-
-        // Copy data to user pointer
-        memcpy(ptr, (*bucketIterator)->ptr, count);
-
-        // Update flattened bytes count
-        bytesLeft -= count;
-        ptr = static_cast<char *>(ptr) + count;
-
-        // Take next bucket
-        ++bucketIterator;
-    }
-}
-
-void BinaryQueue::FlattenConsume(void *buffer, size_t bufferSize)
-{
-    // FIXME: Optimize
-    Flatten(buffer, bufferSize);
-    Consume(bufferSize);
-}
-
-void BinaryQueue::DeleteBucket(BinaryQueue::Bucket *bucket)
-{
-    delete bucket;
-}
-
-void BinaryQueue::BufferDeleterFree(const void* data,
-                                    size_t dataSize,
-                                    void* userParam)
-{
-    (void)dataSize;
-    (void)userParam;
-
-    // Default free deleter
-    free(const_cast<void *>(data));
-}
-
-BinaryQueue::Bucket::Bucket(const void* data,
-                            size_t dataSize,
-                            BufferDeleter dataDeleter,
-                            void* userParam) :
-    buffer(data),
-    ptr(data),
-    size(dataSize),
-    left(dataSize),
-    deleter(dataDeleter),
-    param(userParam)
-{
-    Assert(data != NULL);
-    Assert(deleter != NULL);
-}
-
-BinaryQueue::Bucket::~Bucket()
-{
-    // Invoke deleter on bucket data
-    deleter(buffer, size, param);
-}
-
-BinaryQueue::BucketVisitor::~BucketVisitor()
-{}
-
-BinaryQueue::BucketVisitorCall::BucketVisitorCall(BucketVisitor *visitor) :
-    m_visitor(visitor)
-{}
-
-BinaryQueue::BucketVisitorCall::~BucketVisitorCall()
-{}
-
-void BinaryQueue::BucketVisitorCall::operator()(Bucket *bucket) const
-{
-    m_visitor->OnVisitBucket(bucket->ptr, bucket->left);
-}
-
-void BinaryQueue::VisitBuckets(BucketVisitor *visitor) const
-{
-    Assert(visitor != NULL);
-
-    // Visit all buckets
-    std::for_each(m_buckets.begin(), m_buckets.end(), BucketVisitorCall(visitor));
-}
-
-BinaryQueueAutoPtr BinaryQueue::Read(size_t size)
-{
-    // Simulate input stream
-    size_t available = std::min(size, m_size);
-
-    std::unique_ptr<void, std::function<void(void*)>>
-        bufferCopy(malloc(available), free);
-
-    if (!bufferCopy.get()) {
-        throw std::bad_alloc();
-    }
-
-    BinaryQueueAutoPtr result(new BinaryQueue());
-
-    Flatten(bufferCopy.get(), available);
-    result->AppendUnmanaged(
-        bufferCopy.release(), available, &BufferDeleterFree, NULL);
-    Consume(available);
-
-    return result;
-}
-
-size_t BinaryQueue::Write(const BinaryQueue &buffer, size_t bufferSize)
-{
-    // Simulate output stream
-    AppendCopyFrom(buffer);
-    return bufferSize;
-}
-} // namespace USD
diff --git a/USD/src/dpl/core/src/colors.cpp b/USD/src/dpl/core/src/colors.cpp
deleted file mode 100644 (file)
index 5791c05..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        colors.cpp
- * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version     1.0
- * @brief       Some constants with definition of colors for Console
- *              and html output
- */
-#include <stddef.h>
-#include <dpl/colors.h>
-
-namespace USD {
-namespace Colors {
-namespace Text {
-const char* BOLD_GREEN_BEGIN = "\033[1;32m";
-const char* BOLD_GREEN_END = "\033[m";
-const char* RED_BEGIN = "\033[0;31m";
-const char* RED_END = "\033[m";
-const char* PURPLE_BEGIN = "\033[0;35m";
-const char* PURPLE_END = "\033[m";
-const char* GREEN_BEGIN = "\033[0;32m";
-const char* GREEN_END = "\033[m";
-const char* CYAN_BEGIN = "\033[0;36m";
-const char* CYAN_END = "\033[m";
-const char* BOLD_RED_BEGIN = "\033[1;31m";
-const char* BOLD_RED_END = "\033[m";
-const char* BOLD_YELLOW_BEGIN = "\033[1;33m";
-const char* BOLD_YELLOW_END = "\033[m";
-const char* BOLD_GOLD_BEGIN = "\033[0;33m";
-const char* BOLD_GOLD_END = "\033[m";
-const char* BOLD_WHITE_BEGIN = "\033[1;37m";
-const char* BOLD_WHITE_END = "\033[m";
-} //namespace Text
-
-namespace Html {
-const char* BOLD_GREEN_BEGIN = "<font color=\"green\"><b>";
-const char* BOLD_GREEN_END = "</b></font>";
-const char* PURPLE_BEGIN = "<font color=\"purple\"><b>";
-const char* PURPLE_END = "</b></font>";
-const char* RED_BEGIN = "<font color=\"red\"><b>";
-const char* RED_END = "</b></font>";
-const char* GREEN_BEGIN = "<font color=\"green\">";
-const char* GREEN_END = "</font>";
-const char* CYAN_BEGIN = "<font color=\"cyan\">";
-const char* CYAN_END = "</font>";
-const char* BOLD_RED_BEGIN = "<font color=\"red\"><b>";
-const char* BOLD_RED_END = "</b></font>";
-const char* BOLD_YELLOW_BEGIN = "<font color=\"yellow\"><b>";
-const char* BOLD_YELLOW_END = "</b></font>";
-const char* BOLD_GOLD_BEGIN = "<font color=\"gold\"><b>";
-const char* BOLD_GOLD_END = "</b></font>";
-const char* BOLD_WHITE_BEGIN = "<font color=\"white\"><b>";
-const char* BOLD_WHITE_END = "</b></font>";
-} //namespace Html
-} //namespace Colors
-} //namespace USD
diff --git a/USD/src/dpl/core/src/exception.cpp b/USD/src/dpl/core/src/exception.cpp
deleted file mode 100644 (file)
index e6f685f..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        exception.cpp
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation of exception system
- */
-#include <stddef.h>
-#include <dpl/exception.h>
-#include <dpl/log/log.h>
-#include <cstdio>
-
-namespace USD {
-Exception* Exception::m_lastException = NULL;
-unsigned int Exception::m_exceptionCount = 0;
-void (*Exception::m_terminateHandler)() = NULL;
-
-void LogUnhandledException(const std::string &str)
-{
-    // Logging to console
-    printf("%s\n", str.c_str());
-
-    // Logging to dlog
-    LogPedantic(str);
-}
-
-void LogUnhandledException(const std::string &str,
-                           const char *filename,
-                           int line,
-                           const char *function)
-{
-    // Logging to console
-    std::ostringstream msg;
-    msg << "\033[1;5;31m\n=== [" << filename << ":" << line << "] " <<
-    function << " ===\033[m";
-    msg << str;
-    printf("%s\n", msg.str().c_str());
-
-    // Logging to dlog
-    USD::Log::LogSystemSingleton::Instance().Error(
-        str.c_str(), filename, line, function);
-}
-} // namespace USD
diff --git a/USD/src/dpl/core/src/noncopyable.cpp b/USD/src/dpl/core/src/noncopyable.cpp
deleted file mode 100644 (file)
index b0ae533..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        noncopyable.cpp
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of noncopyable
- */
-#include <stddef.h>
-#include <dpl/noncopyable.h>
-
-namespace USD {
-Noncopyable::Noncopyable()
-{}
-
-Noncopyable::~Noncopyable()
-{}
-} // namespace USD
diff --git a/USD/src/dpl/core/src/serialization.cpp b/USD/src/dpl/core/src/serialization.cpp
deleted file mode 100644 (file)
index f8f05ff..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file        serialization.cpp
- * @author      Tomasz Swierczek (t.swierczek@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of data serialization.
- */
-#include <stddef.h>
-#include <dpl/serialization.h>
-
-//
-// Note:
-//
-// The file here is left blank to enable precompilation
-// of templates in corresponding header file.
-// Do not remove this file.
-//
diff --git a/USD/src/dpl/core/src/singleton.cpp b/USD/src/dpl/core/src/singleton.cpp
deleted file mode 100644 (file)
index a76e8ac..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        generic_event.cpp
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of singleton
- */
-#include <stddef.h>
-#include <dpl/singleton.h>
-
-//
-// Note:
-//
-// The file here is left blank to enable precompilation
-// of templates in corresponding header file.
-// Do not remove this file.
-//
diff --git a/USD/src/dpl/log/include/dpl/log/abstract_log_provider.h b/USD/src/dpl/log/include/dpl/log/abstract_log_provider.h
deleted file mode 100644 (file)
index d4802d1..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        abstract_log_provider.h
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of abstract log provider
- */
-#ifndef USD_ABSTRACT_LOG_PROVIDER_H
-#define USD_ABSTRACT_LOG_PROVIDER_H
-
-namespace USD {
-namespace Log {
-class AbstractLogProvider
-{
-  public:
-    virtual ~AbstractLogProvider() {}
-
-    virtual void SetTag(const char *tag);
-
-    virtual void Debug(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function) = 0;
-    virtual void Info(const char *message,
-                      const char *fileName,
-                      int line,
-                      const char *function) = 0;
-    virtual void Warning(const char *message,
-                         const char *fileName,
-                         int line,
-                         const char *function) = 0;
-    virtual void Error(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function) = 0;
-    virtual void Pedantic(const char *message,
-                          const char *fileName,
-                          int line,
-                          const char *function) = 0;
-
-  protected:
-    static const char *LocateSourceFileName(const char *filename);
-};
-}
-} // namespace USD
-
-#endif // USD_ABSTRACT_LOG_PROVIDER_H
diff --git a/USD/src/dpl/log/include/dpl/log/dlog_log_provider.h b/USD/src/dpl/log/include/dpl/log/dlog_log_provider.h
deleted file mode 100644 (file)
index f657e24..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        dlog_log_provider.h
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of DLOG log provider
- */
-#ifndef USD_DLOG_LOG_PROVIDER_H
-#define USD_DLOG_LOG_PROVIDER_H
-
-#include <dpl/log/abstract_log_provider.h>
-#include <memory>
-#include <string>
-
-namespace USD {
-namespace Log {
-class DLOGLogProvider :
-    public AbstractLogProvider
-{
-  private:
-    std::unique_ptr<char[]> m_tag;
-
-    static std::string FormatMessage(const char *message,
-                                     const char *filename,
-                                     int line,
-                                     const char *function);
-
-  public:
-    DLOGLogProvider();
-    virtual ~DLOGLogProvider();
-
-    virtual void Debug(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void Info(const char *message,
-                      const char *fileName,
-                      int line,
-                      const char *function);
-    virtual void Warning(const char *message,
-                         const char *fileName,
-                         int line,
-                         const char *function);
-    virtual void Error(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void Pedantic(const char *message,
-                          const char *fileName,
-                          int line,
-                          const char *function);
-    virtual void SecureDebug(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void SecureInfo(const char *message,
-                      const char *fileName,
-                      int line,
-                      const char *function);
-    virtual void SecureWarning(const char *message,
-                         const char *fileName,
-                         int line,
-                         const char *function);
-    virtual void SecureError(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void SmackAudit(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-
-    // Set global Tag according to DLOG
-    void SetTag(const char *tag);
-};
-
-} // namespace Log
-} // namespace USD
-
-#endif // USD_DLOG_LOG_PROVIDER_H
diff --git a/USD/src/dpl/log/include/dpl/log/log.h b/USD/src/dpl/log/include/dpl/log/log.h
deleted file mode 100644 (file)
index e7f93b1..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        log.h
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of log system
- */
-#ifndef USD_LOG_H
-#define USD_LOG_H
-
-#include <dpl/singleton.h>
-#include <dpl/noncopyable.h>
-#include <dpl/log/abstract_log_provider.h>
-#include <sstream>
-#include <list>
-
-namespace USD {
-namespace Log {
-/**
- * USD log system
- *
- * To switch logs into old style, export
- * DPL_USE_OLD_STYLE_LOGS before application start
- */
-class LogSystem :
-    private Noncopyable
-{
-  private:
-    typedef std::list<AbstractLogProvider *> AbstractLogProviderPtrList;
-    AbstractLogProviderPtrList m_providers;
-
-    bool m_isLoggingEnabled;
-
-  public:
-    bool IsLoggingEnabled() const;
-    LogSystem();
-    virtual ~LogSystem();
-
-    /**
-     * Log debug message
-     */
-    void Debug(const char *message,
-               const char *filename,
-               int line,
-               const char *function);
-
-    /**
-     * Log info message
-     */
-    void Info(const char *message,
-              const char *filename,
-              int line,
-              const char *function);
-
-    /**
-     * Log warning message
-     */
-    void Warning(const char *message,
-                 const char *filename,
-                 int line,
-                 const char *function);
-
-    /**
-     * Log error message
-     */
-    void Error(const char *message,
-               const char *filename,
-               int line,
-               const char *function);
-
-    /**
-     * Log pedantic message
-     */
-    void Pedantic(const char *message,
-                  const char *filename,
-                  int line,
-                  const char *function);
-
-    /**
-     * Set default's DLOG provider Tag
-     */
-    void SetTag(const char *tag);
-
-    /**
-     * Add abstract provider to providers list
-     *
-     * @notice Ownership is transfered to LogSystem and deleted upon exit
-     */
-    void AddProvider(AbstractLogProvider *provider);
-
-    /**
-     * Remove abstract provider from providers list
-     */
-    void RemoveProvider(AbstractLogProvider *provider);
-};
-
-/*
- * Replacement low overhead null logging class
- */
-class NullStream
-{
-  public:
-    NullStream() {}
-
-    template <typename T>
-    NullStream& operator<<(const T&)
-    {
-        return *this;
-    }
-};
-
-/**
- * Log system singleton
- */
-typedef Singleton<LogSystem> LogSystemSingleton;
-}
-} // namespace USD
-
-//
-// Log support
-//
-//
-
-/* avoid warnings about unused variables */
-#define DPL_MACRO_DUMMY_LOGGING(message, function)                         \
-    do {                                                                   \
-        USD::Log::NullStream ns;                                \
-        ns << message;                                                     \
-    } while (0)
-
-#define DPL_MACRO_FOR_LOGGING(message, function)                           \
-do                                                                         \
-{                                                                          \
-    if (USD::Log::LogSystemSingleton::Instance().IsLoggingEnabled())   \
-    {                                                                      \
-        std::ostringstream platformLog;                                    \
-        platformLog << message;                                            \
-        USD::Log::LogSystemSingleton::Instance().function(      \
-            platformLog.str().c_str(),                                     \
-            __FILE__, __LINE__, __FUNCTION__);                             \
-    }                                                                      \
-} while (0)
-
-/* Errors must be always logged. */
-#define  LogError(message) DPL_MACRO_FOR_LOGGING(message, Error)
-#define  LogSecureError(message) DPL_MACRO_FOR_LOGGING(message, SecureError)
-
-#define  LogSmackAudit(message) DPL_MACRO_FOR_LOGGING(message, SmackAudit)
-
-#ifdef BUILD_TYPE_DEBUG
-    #define LogDebug(message) DPL_MACRO_FOR_LOGGING(message, Debug)
-    #define LogInfo(message) DPL_MACRO_FOR_LOGGING(message, Info)
-    #define LogWarning(message) DPL_MACRO_FOR_LOGGING(message, Warning)
-    #define LogPedantic(message) DPL_MACRO_FOR_LOGGING(message, Pedantic)
-#else
-    #define LogDebug(message) DPL_MACRO_DUMMY_LOGGING(message, Debug)
-    #define LogInfo(message) DPL_MACRO_DUMMY_LOGGING(message, Info)
-    #define LogWarning(message) DPL_MACRO_DUMMY_LOGGING(message, Warning)
-    #define LogPedantic(message) DPL_MACRO_DUMMY_LOGGING(message, Pedantic)
-#endif // BUILD_TYPE_DEBUG
-
-#endif // USD_LOG_H
diff --git a/USD/src/dpl/log/include/dpl/log/old_style_log_provider.h b/USD/src/dpl/log/include/dpl/log/old_style_log_provider.h
deleted file mode 100644 (file)
index 042dae1..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        old_style_log_provider.h
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of old style log provider
- */
-#ifndef USD_OLD_STYLE_LOG_PROVIDER_H
-#define USD_OLD_STYLE_LOG_PROVIDER_H
-
-#include <dpl/log/abstract_log_provider.h>
-#include <string>
-
-namespace USD {
-namespace Log {
-class OldStyleLogProvider :
-    public AbstractLogProvider
-{
-  private:
-    bool m_showDebug;
-    bool m_showInfo;
-    bool m_showWarning;
-    bool m_showError;
-    bool m_showPedantic;
-    bool m_printStdErr;
-
-    static std::string FormatMessage(const char *message,
-                                     const char *filename,
-                                     int line,
-                                     const char *function);
-
-  public:
-    OldStyleLogProvider(bool showDebug,
-                        bool showInfo,
-                        bool showWarning,
-                        bool showError,
-                        bool showPedantic);
-    OldStyleLogProvider(bool showDebug,
-                        bool showInfo,
-                        bool showWarning,
-                        bool showError,
-                        bool showPedantic,
-                        bool printStdErr);
-    virtual ~OldStyleLogProvider() {}
-
-    virtual void Debug(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void Info(const char *message,
-                      const char *fileName,
-                      int line,
-                      const char *function);
-    virtual void Warning(const char *message,
-                         const char *fileName,
-                         int line,
-                         const char *function);
-    virtual void Error(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void Pedantic(const char *message,
-                          const char *fileName,
-                          int line,
-                          const char *function);
-    virtual void SecureDebug(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void SecureInfo(const char *message,
-                      const char *fileName,
-                      int line,
-                      const char *function);
-    virtual void SecureWarning(const char *message,
-                         const char *fileName,
-                         int line,
-                         const char *function);
-    virtual void SecureError(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void SmackAudit(const char *message,
-                      const char *fileName,
-                      int line,
-                      const char *function);
-};
-}
-} // namespace USD
-
-#endif // USD_OLD_STYLE_LOG_PROVIDER_H
diff --git a/USD/src/dpl/log/include/dpl/log/sd_journal_provider.h b/USD/src/dpl/log/include/dpl/log/sd_journal_provider.h
deleted file mode 100644 (file)
index d3503ed..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2014 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        sd_journal_provider.h
- * @author      Marcin Lis (m.lis@samsung.com)
- * @version     1.0
- * @brief       This file contains the implementation of systemd journal log provider
- */
-
-#ifndef USD_SD_JOURNAL_PROVIDER_H
-#define USD_SD_JOURNAL_PROVIDER_H
-
-#include <dpl/log/abstract_log_provider.h>
-#include <memory>
-#include <string>
-
-namespace USD {
-namespace Log {
-class SdJournalProvider :
-    public AbstractLogProvider
-{
-  private:
-    std::string m_tag;
-
-    static std::string FormatMessage(const char *message,
-                                     const char *filename,
-                                     int line,
-                                     const char *function);
-
-  public:
-    SdJournalProvider();
-    virtual ~SdJournalProvider();
-
-    virtual void Debug(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void Info(const char *message,
-                      const char *fileName,
-                      int line,
-                      const char *function);
-    virtual void Warning(const char *message,
-                         const char *fileName,
-                         int line,
-                         const char *function);
-    virtual void Error(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-
-    // All Pedantic logs are translated to Debug
-    virtual void Pedantic(const char *message,
-                          const char *fileName,
-                          int line,
-                          const char *function);
-    virtual void SecureDebug(const char *message,
-            const char *fileName,
-            int line,
-            const char *function);
-    virtual void SecureInfo(const char *message,
-            const char *fileName,
-            int line,
-            const char *function);
-    virtual void SecureWarning(const char *message,
-            const char *fileName,
-            int line,
-            const char *function);
-    virtual void SecureError(const char *message,
-            const char *fileName,
-            int line,
-            const char *function);
-    virtual void SmackAudit(const char *message,
-            const char *fileName,
-            int line,
-            const char *function);
-
-    // Set global Tag for all USD Logs
-    void SetTag(const char *tag);
-
-}; // class SdJournalProvider
-
-} // namespace Log
-} // namespace USD
-
-#endif // USD_SD_JOURNAL_PROVIDER_H
diff --git a/USD/src/dpl/log/src/abstract_log_provider.cpp b/USD/src/dpl/log/src/abstract_log_provider.cpp
deleted file mode 100644 (file)
index 5221ed8..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        abstract_log_provider.cpp
- * @author      Pawel Sikorski (p.sikorski@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of abstract log provider
- */
-#include <stddef.h>
-#include <dpl/log/abstract_log_provider.h>
-#include <cstring>
-
-#define UNUSED __attribute__((unused))
-
-namespace USD {
-namespace Log {
-
-void AbstractLogProvider::SetTag(const char *tag UNUSED) {}
-
-const char *AbstractLogProvider::LocateSourceFileName(const char *filename)
-{
-    const char *ptr = strrchr(filename, '/');
-    return ptr != NULL ? ptr + 1 : filename;
-}
-}
-}
diff --git a/USD/src/dpl/log/src/dlog_log_provider.cpp b/USD/src/dpl/log/src/dlog_log_provider.cpp
deleted file mode 100644 (file)
index 78a3e52..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        dlog_log_provider.cpp
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of DLOG log provider
- */
-#include <stddef.h>
-#include <dpl/log/dlog_log_provider.h>
-#include <cstring>
-#include <sstream>
-#include <dlog.h>
-
-#define UNUSED __attribute__((unused))
-
-namespace USD {
-namespace Log {
-std::string DLOGLogProvider::FormatMessage(const char *message,
-                                           const char *filename,
-                                           int line,
-                                           const char *function)
-{
-    std::ostringstream val;
-
-    val << std::string("[") <<
-    LocateSourceFileName(filename) << std::string(":") << line <<
-    std::string("] ") << function << std::string("(): ") << message;
-
-    return val.str();
-}
-
-DLOGLogProvider::DLOGLogProvider()
-{}
-
-DLOGLogProvider::~DLOGLogProvider()
-{}
-
-void DLOGLogProvider::SetTag(const char *tag)
-{
-    size_t size = strlen(tag)+1;
-    char *buff = new (std::nothrow) char[size];
-    if (buff)
-        memcpy(buff, tag, size);
-    m_tag.reset(buff);
-}
-
-void DLOGLogProvider::Debug(const char *message,
-                            const char *filename,
-                            int line,
-                            const char *function)
-{
-    SLOG(LOG_DEBUG, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::Info(const char *message,
-                           const char *filename,
-                           int line,
-                           const char *function)
-{
-    SLOG(LOG_INFO, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::Warning(const char *message,
-                              const char *filename,
-                              int line,
-                              const char *function)
-{
-    SLOG(LOG_WARN, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::Error(const char *message,
-                            const char *filename,
-                            int line,
-                            const char *function)
-{
-    SLOG(LOG_ERROR, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::Pedantic(const char *message,
-                               const char *filename,
-                               int line,
-                               const char *function)
-{
-    SLOG(LOG_DEBUG, "USD", "%s", FormatMessage(message,
-                                              filename,
-                                              line,
-                                              function).c_str());
-}
-
-void DLOGLogProvider::SecureDebug(const char *message UNUSED,
-                            const char *filename UNUSED,
-                            int line UNUSED,
-                            const char *function UNUSED)
-{
-    SECURE_SLOG(LOG_DEBUG, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::SecureInfo(const char *message UNUSED,
-                           const char *filename UNUSED,
-                           int line UNUSED,
-                           const char *function UNUSED)
-{
-    SECURE_SLOG(LOG_INFO, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::SecureWarning(const char *message UNUSED,
-                              const char *filename UNUSED,
-                              int line UNUSED,
-                              const char *function UNUSED)
-{
-    SECURE_SLOG(LOG_WARN, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::SecureError(const char *message UNUSED,
-                            const char *filename UNUSED,
-                            int line UNUSED,
-                            const char *function UNUSED)
-{
-    SECURE_SLOG(LOG_ERROR, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::SmackAudit(const char *message UNUSED,
-                           const char *filename UNUSED,
-                           int line UNUSED,
-                           const char *function UNUSED)
-{
-}
-
-} // nemespace Log
-} // namespace USD
diff --git a/USD/src/dpl/log/src/log.cpp b/USD/src/dpl/log/src/log.cpp
deleted file mode 100644 (file)
index 2a9fadd..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        log.cpp
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of log system
- */
-#include <stddef.h>
-#include <string.h>
-
-#include <dpl/log/log.h>
-#include <dpl/singleton_impl.h>
-#include <dpl/log/dlog_log_provider.h>
-#include <dpl/log/sd_journal_provider.h>
-#include <dpl/log/old_style_log_provider.h>
-
-IMPLEMENT_SINGLETON(USD::Log::LogSystem)
-
-namespace USD {
-namespace Log {
-namespace // anonymous
-{
-#ifdef BUILD_TYPE_DEBUG
-const char *OLD_STYLE_LOGS_ENV_NAME = "DPL_USE_OLD_STYLE_LOGS";
-const char *OLD_STYLE_PEDANTIC_LOGS_ENV_NAME =
-    "DPL_USE_OLD_STYLE_PEDANTIC_LOGS";
-const char *OLD_STYLE_LOGS_MASK_ENV_NAME = "DPL_USE_OLD_STYLE_LOGS_MASK";
-#endif // BUILD_TYPE_DEBUG
-const char *USD_LOG_OFF = "DPL_LOG_OFF";
-} // namespace anonymous
-
-bool LogSystem::IsLoggingEnabled() const
-{
-    return m_isLoggingEnabled;
-}
-
-LogSystem::LogSystem() :
-    m_isLoggingEnabled(!getenv(USD_LOG_OFF))
-{
-#ifdef BUILD_TYPE_DEBUG
-    bool oldStyleLogs = false;
-    bool oldStyleDebugLogs = true;
-    bool oldStyleInfoLogs = true;
-    bool oldStyleWarningLogs = true;
-    bool oldStyleErrorLogs = true;
-    bool oldStylePedanticLogs = false;
-
-    // Check environment settings about pedantic logs
-    const char *value = getenv(OLD_STYLE_LOGS_ENV_NAME);
-
-    if (value != NULL && !strcmp(value, "1")) {
-        oldStyleLogs = true;
-    }
-
-    value = getenv(OLD_STYLE_PEDANTIC_LOGS_ENV_NAME);
-
-    if (value != NULL && !strcmp(value, "1")) {
-        oldStylePedanticLogs = true;
-    }
-
-    value = getenv(OLD_STYLE_LOGS_MASK_ENV_NAME);
-
-    if (value != NULL) {
-        size_t len = strlen(value);
-
-        if (len >= 1) {
-            if (value[0] == '0') {
-                oldStyleDebugLogs = false;
-            } else if (value[0] == '1') {
-                oldStyleDebugLogs = true;
-            }
-        }
-
-        if (len >= 2) {
-            if (value[1] == '0') {
-                oldStyleInfoLogs = false;
-            } else if (value[1] == '1') {
-                oldStyleInfoLogs = true;
-            }
-        }
-
-        if (len >= 3) {
-            if (value[2] == '0') {
-                oldStyleWarningLogs = false;
-            } else if (value[2] == '1') {
-                oldStyleWarningLogs = true;
-            }
-        }
-
-        if (len >= 4) {
-            if (value[3] == '0') {
-                oldStyleErrorLogs = false;
-            } else if (value[3] == '1') {
-                oldStyleErrorLogs = true;
-            }
-        }
-    }
-
-    // Setup default DLOG and old style logging
-    if (oldStyleLogs) {
-        // Old style
-        AddProvider(new OldStyleLogProvider(oldStyleDebugLogs,
-                                            oldStyleInfoLogs,
-                                            oldStyleWarningLogs,
-                                            oldStyleErrorLogs,
-                                            oldStylePedanticLogs));
-    } else {
-        // DLOG
-        AddProvider(new DLOGLogProvider());
-        AddProvider(new SdJournalProvider());
-    }
-#else // BUILD_TYPE_DEBUG
-    AddProvider(new DLOGLogProvider());
-    AddProvider(new SdJournalProvider());
-#endif // BUILD_TYPE_DEBUG
-}
-
-LogSystem::~LogSystem()
-{
-    // Delete all providers
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        delete *iterator;
-    }
-
-    m_providers.clear();
-}
-
-void LogSystem::SetTag(const char* tag)
-{
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        (*iterator)->SetTag(tag);
-    }
-}
-
-void LogSystem::AddProvider(AbstractLogProvider *provider)
-{
-    m_providers.push_back(provider);
-}
-
-void LogSystem::RemoveProvider(AbstractLogProvider *provider)
-{
-    m_providers.remove(provider);
-}
-
-void LogSystem::Debug(const char *message,
-                      const char *filename,
-                      int line,
-                      const char *function)
-{
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        (*iterator)->Debug(message, filename, line, function);
-    }
-}
-
-void LogSystem::Info(const char *message,
-                     const char *filename,
-                     int line,
-                     const char *function)
-{
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        (*iterator)->Info(message, filename, line, function);
-    }
-}
-
-void LogSystem::Warning(const char *message,
-                        const char *filename,
-                        int line,
-                        const char *function)
-{
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        (*iterator)->Warning(message, filename, line, function);
-    }
-}
-
-void LogSystem::Error(const char *message,
-                      const char *filename,
-                      int line,
-                      const char *function)
-{
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        (*iterator)->Error(message, filename, line, function);
-    }
-}
-
-void LogSystem::Pedantic(const char *message,
-                         const char *filename,
-                         int line,
-                         const char *function)
-{
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        (*iterator)->Pedantic(message, filename, line, function);
-    }
-}
-
-}
-} // namespace USD
diff --git a/USD/src/dpl/log/src/old_style_log_provider.cpp b/USD/src/dpl/log/src/old_style_log_provider.cpp
deleted file mode 100644 (file)
index 1efed24..0000000
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        old_style_log_provider.cpp
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of old style log provider
- */
-#include <stddef.h>
-#include <dpl/log/old_style_log_provider.h>
-#include <dpl/colors.h>
-#include <cstdio>
-#include <cstring>
-#include <sstream>
-#include <sys/time.h>
-#include <unistd.h>
-#include <dlog.h>
-
-namespace USD {
-namespace Log {
-namespace // anonymous
-{
-using namespace USD::Colors::Text;
-const char *DEBUG_BEGIN = GREEN_BEGIN;
-const char *DEBUG_END = GREEN_END;
-const char *INFO_BEGIN = CYAN_BEGIN;
-const char *INFO_END = CYAN_END;
-const char *ERROR_BEGIN = RED_BEGIN;
-const char *ERROR_END = RED_END;
-const char *WARNING_BEGIN = BOLD_GOLD_BEGIN;
-const char *WARNING_END = BOLD_GOLD_END;
-const char *PEDANTIC_BEGIN = PURPLE_BEGIN;
-const char *PEDANTIC_END = PURPLE_END;
-
-std::string GetFormattedTime()
-{
-    timeval tv;
-    tm localNowTime;
-
-    gettimeofday(&tv, NULL);
-    localtime_r(&tv.tv_sec, &localNowTime);
-
-    char format[64];
-    snprintf(format,
-             sizeof(format),
-             "%02i:%02i:%02i.%03i",
-             localNowTime.tm_hour,
-             localNowTime.tm_min,
-             localNowTime.tm_sec,
-             static_cast<int>(tv.tv_usec / 1000));
-    return format;
-}
-} // namespace anonymous
-
-std::string OldStyleLogProvider::FormatMessage(const char *message,
-                                               const char *filename,
-                                               int line,
-                                               const char *function)
-{
-    std::ostringstream val;
-
-    val << std::string("[") << GetFormattedTime() << std::string("] [") <<
-    static_cast<unsigned long>(pthread_self()) << "/" <<
-    static_cast<int>(getpid()) << std::string("] [") <<
-    LocateSourceFileName(filename) << std::string(":") << line <<
-    std::string("] ") << function << std::string("(): ") << message;
-
-    return val.str();
-}
-
-OldStyleLogProvider::OldStyleLogProvider(bool showDebug,
-                                         bool showInfo,
-                                         bool showWarning,
-                                         bool showError,
-                                         bool showPedantic) :
-    m_showDebug(showDebug),
-    m_showInfo(showInfo),
-    m_showWarning(showWarning),
-    m_showError(showError),
-    m_showPedantic(showPedantic),
-    m_printStdErr(false)
-{}
-
-OldStyleLogProvider::OldStyleLogProvider(bool showDebug,
-                                         bool showInfo,
-                                         bool showWarning,
-                                         bool showError,
-                                         bool showPedantic,
-                                         bool printStdErr) :
-    m_showDebug(showDebug),
-    m_showInfo(showInfo),
-    m_showWarning(showWarning),
-    m_showError(showError),
-    m_showPedantic(showPedantic),
-    m_printStdErr(printStdErr)
-{}
-
-void OldStyleLogProvider::Debug(const char *message,
-                                const char *filename,
-                                int line,
-                                const char *function)
-{
-    if (m_showDebug) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", DEBUG_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), DEBUG_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", DEBUG_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), DEBUG_END);
-        }
-    }
-}
-
-void OldStyleLogProvider::Info(const char *message,
-                               const char *filename,
-                               int line,
-                               const char *function)
-{
-    if (m_showInfo) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", INFO_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), INFO_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", INFO_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), INFO_END);
-        }
-    }
-}
-
-void OldStyleLogProvider::Warning(const char *message,
-                                  const char *filename,
-                                  int line,
-                                  const char *function)
-{
-    if (m_showWarning) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", WARNING_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), WARNING_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", WARNING_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), WARNING_END);
-        }
-    }
-}
-
-void OldStyleLogProvider::Error(const char *message,
-                                const char *filename,
-                                int line,
-                                const char *function)
-{
-    if (m_showError) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", ERROR_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), ERROR_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", ERROR_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), ERROR_END);
-        }
-    }
-}
-
-void OldStyleLogProvider::Pedantic(const char *message,
-                                   const char *filename,
-                                   int line,
-                                   const char *function)
-{
-    if (m_showPedantic) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", PEDANTIC_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), PEDANTIC_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", PEDANTIC_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), PEDANTIC_END);
-        }
-    }
-}
-
-void OldStyleLogProvider::SecureDebug(const char *message,
-                                const char *filename,
-                                int line,
-                                const char *function)
-{
-#ifdef _SECURE_LOG
-    if (m_showDebug) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", DEBUG_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), DEBUG_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", DEBUG_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), DEBUG_END);
-        }
-    }
-#else
-    (void)message;
-    (void)filename;
-    (void)line;
-    (void)function;
-#endif
-}
-
-void OldStyleLogProvider::SecureInfo(const char *message,
-                               const char *filename,
-                               int line,
-                               const char *function)
-{
-#ifdef _SECURE_LOG
-    if (m_showInfo) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", INFO_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), INFO_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", INFO_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), INFO_END);
-        }
-    }
-#else
-    (void)message;
-    (void)filename;
-    (void)line;
-    (void)function;
-#endif
-}
-
-void OldStyleLogProvider::SecureWarning(const char *message,
-                                  const char *filename,
-                                  int line,
-                                  const char *function)
-{
-#ifdef _SECURE_LOG
-    if (m_showWarning) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", WARNING_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), WARNING_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", WARNING_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), WARNING_END);
-        }
-    }
-#else
-    (void)message;
-    (void)filename;
-    (void)line;
-    (void)function;
-#endif
-}
-
-void OldStyleLogProvider::SecureError(const char *message,
-                                const char *filename,
-                                int line,
-                                const char *function)
-{
-#ifdef _SECURE_LOG
-    if (m_showError) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", ERROR_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), ERROR_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", ERROR_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), ERROR_END);
-        }
-    }
-#else
-    (void)message;
-    (void)filename;
-    (void)line;
-    (void)function;
-#endif
-}
-
-void OldStyleLogProvider::SmackAudit(const char *message,
-                               const char *fileName,
-                               int line,
-                               const char *function)
-{
-    (void)message;
-    (void)fileName;
-    (void)line;
-    (void)function;
-}
-
-}
-} // namespace USD
diff --git a/USD/src/dpl/log/src/sd_journal_provider.cpp b/USD/src/dpl/log/src/sd_journal_provider.cpp
deleted file mode 100644 (file)
index 95ef5dc..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2014 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        sd_journal_provider.cpp
- * @author      Marcin Lis (m.lis@samsung.com)
- * @version     1.0
- * @brief       This file contains the implementation of systemd journal log provider
- */
-
-#include <dpl/log/sd_journal_provider.h>
-#include <string>
-#include <sstream>
-#include <systemd/sd-journal.h>
-
-#define UNUSED __attribute__((unused))
-
-namespace USD {
-namespace Log {
-std::string SdJournalProvider::FormatMessage(const char *message,
-                                           const char *filename,
-                                           int line,
-                                           const char *function)
-{
-    std::ostringstream val;
-
-    val << std::string("[") <<
-    LocateSourceFileName(filename) << std::string(":") << line <<
-    std::string("] ") << function << std::string("(): ") << message;
-
-    return val.str();
-}
-
-SdJournalProvider::SdJournalProvider()
-{}
-
-SdJournalProvider::~SdJournalProvider()
-{}
-
-void SdJournalProvider::SetTag(const char *tag)
-{
-    m_tag = std::string(tag);
-}
-
-void SdJournalProvider::Debug(const char *message,
-                            const char *filename,
-                            int line,
-                            const char *function)
-{
-    // sd-journal imports LOG priorities from the syslog, see syslog(3) for details
-    sd_journal_print(LOG_DEBUG, "%s",
-                     (FormatMessage(message, filename, line, function)).c_str());
-}
-
-void SdJournalProvider::Info(const char *message,
-                           const char *filename,
-                           int line,
-                           const char *function)
-{
-    sd_journal_print(LOG_INFO, "%s",
-                     (FormatMessage(message, filename, line, function)).c_str());
-}
-
-void SdJournalProvider::Warning(const char *message,
-                              const char *filename,
-                              int line,
-                              const char *function)
-{
-    sd_journal_print(LOG_WARNING, "%s",
-                     (FormatMessage(message, filename, line, function)).c_str());
-}
-
-void SdJournalProvider::Error(const char *message,
-                            const char *filename,
-                            int line,
-                            const char *function)
-{
-    sd_journal_print(LOG_ERR, "%s",
-                     (FormatMessage(message, filename, line, function)).c_str());
-}
-
-// All Pedantic logs are translated to Debug
-void SdJournalProvider::Pedantic(const char *message,
-                               const char *filename,
-                               int line,
-                               const char *function)
-{
-    Debug(message, filename, line, function);
-}
-
-
-
-/**
- * Log pedantic message with secure macro
- */
-void SdJournalProvider::SecureDebug(const char *message,
-           const char *filename,
-           int line,
-           const char *function)
-{
-    Debug(message, filename, line, function);
-}
-/**
- * Log info message with secure macro
- */
-void SdJournalProvider::SecureInfo(const char *message,
-          const char *filename,
-          int line,
-          const char *function)
-{
-    Info(message, filename, line, function);
-}
-/**
- * Log warning message with secure macro
- */
-void SdJournalProvider::SecureWarning(const char *message,
-             const char *filename,
-             int line,
-             const char *function)
-{
-    Warning(message, filename, line, function);
-}
-/**
- * Log error message with secure macro
- */
-void SdJournalProvider::SecureError(const char *message,
-           const char *filename,
-           int line,
-           const char *function)
-{
-    Error(message, filename, line, function);
-}
-/**
- * Log SS_SMACK into files
- */
- void SdJournalProvider::SmackAudit(const char *message,
-                  const char *fileName,
-                  int line,
-                  const char *function)
- {
-     Debug(message, fileName, line, function);
- }
-
-
-} // namespace Log
-} // namespace USD
diff --git a/USD/src/include/usb-security-daemon.h b/USD/src/include/usb-security-daemon.h
deleted file mode 100644 (file)
index d49b6b6..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- *  USB security daemon
- *
- *  Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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
- *
- */
-
-#ifndef USB_SECURITY_DAEMON_H
-#define USB_SECURITY_DAEMON_H
-
-#include <sys/types.h>
-#include <stdbool.h>
-
-/**
- * @file    usb-security-daemon.h
- * @version 1.0
- * @brief   This file contains APIs of the USD
-*/
-
-/**
- * @defgroup SecurityFW
- * @{
- *
- * @defgroup USD Usb-security-daemon
- * @version  1.0
- * @brief    USD client library functions
- *
-*/
-
-/**
- * @addtogroup USD
- * @{
-*/
-
-/*
- * ====================================================================================================
- * <tt>
- *
- * Revision History:
- *
- *  -- Company Name -- | Modification Date | Description of Changes
- *  -----------------------------------------------------------------------
- *   --- Samsung ------ | --- 2010-07-25 -- | First created
- *
- *    </tt>
- */
-
-/**
- * \name Return Codes
- * exported by the foundation API.
- * result codes begin with the start error code and extend into negative direction.
- * @{
-*/
-
-/*! \brief   indicating the result of the one specific API is successful */
-#define USD_API_SUCCESS 0
-
-/*! \brief   indicating the socket between client and USB Security Daemon has been failed  */
-#define USD_API_ERROR_SOCKET -1
-
-/*! \brief   indicating the response to server is malformed */
-#define USD_API_ERROR_BAD_REQUEST -2
-
-/*! \brief   indicating the response from USB Security Daemon is malformed */
-#define USD_API_ERROR_BAD_RESPONSE -3
-
-/*! \brief   indicating the requested service does not exist */
-#define USD_API_ERROR_NO_SUCH_SERVICE -4
-
-/*! \brief   indicating requesting object is not exist */
-#define USD_API_ERROR_NO_SUCH_OBJECT -6
-
-/*! \brief   indicating the authentication between client and server has been failed */
-#define USD_API_ERROR_AUTHENTICATION_FAILED -7
-
-/*! \brief   indicating the API's input parameter is malformed */
-#define USD_API_ERROR_INPUT_PARAM -8
-
-/*! \brief   indicating the output buffer size which is passed as parameter is too small */
-#define USD_API_ERROR_BUFFER_TOO_SMALL -9
-
-/*! \brief   indicating system  is running out of memory state */
-#define USD_API_ERROR_OUT_OF_MEMORY -10
-
-/*! \brief   indicating the access has been denied by USB Security Daemon */
-#define USD_API_ERROR_ACCESS_DENIED -11
-
-/*! \brief   indicating USB Security Daemon has been failed for some reason */
-#define USD_API_ERROR_SERVER_ERROR -12
-
-/*! \brief   indicating given cookie is not exist in the database  */
-#define USD_API_ERROR_NO_SUCH_COOKIE -13
-
-/*! \brief   indicating there is no phone password set  */
-#define USD_API_ERROR_NO_PASSWORD -14
-
-/*! \brief   indicating password exists in system  */
-#define USD_API_ERROR_PASSWORD_EXIST -15
-
-/*! \brief   indicating password mismatch  */
-#define USD_API_ERROR_PASSWORD_MISMATCH -16
-
-/*! \brief   indicating password retry timeout is not occurred yet  */
-#define USD_API_ERROR_PASSWORD_RETRY_TIMER -17
-
-/*! \brief   indicating password retry timeout is not occurred yet  */
-#define USD_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED -18
-
-/*! \brief   indicating password retry timeout is not occurred yet  */
-#define USD_API_ERROR_PASSWORD_EXPIRED -19
-
-/*! \brief   indicating password retry timeout is not occurred yet  */
-#define USD_API_ERROR_PASSWORD_REUSED -20
-
-/*! \brief   indicating getting smack label from socket failed  */
-#define USD_API_ERROR_GETTING_SOCKET_LABEL_FAILED -21
-
-/*! \brief   indicating getting smack label from file failed  */
-#define USD_API_ERROR_GETTING_FILE_LABEL_FAILED -22
-
-/*! \brief   indicating setting smack label for file failed  */
-#define USD_API_ERROR_SETTING_FILE_LABEL_FAILED -23
-
-/*! \brief   indicating file already exists  */
-#define USD_API_ERROR_FILE_EXIST -24
-
-/*! \brief   indicating file does not exist  */
-#define USD_API_ERROR_FILE_NOT_EXIST -25
-
-/*! \brief   indicating file open error  */
-#define USD_API_ERROR_FILE_OPEN_FAILED -26
-
-/*! \brief   indicating file creation error  */
-#define USD_API_ERROR_FILE_CREATION_FAILED -27
-
-/*! \brief   indicating file deletion error  */
-#define USD_API_ERROR_FILE_DELETION_FAILED -28
-
-/*! \brief   indicating file read error  */
-#define USD_API_ERROR_FILE_READ_FAILED -28
-
-/*! \brief   indicating that there is yet policy set for device*/
-#define USD_API_ERROR_POLICY_UNKNOWN -29
-
-/*! \brief   indicating the error with unknown reason */
-#define USD_API_ERROR_UNKNOWN -255
-/** @}*/
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
-/**
- * This function enables to obtain opened file descriptor to device node which
- * allows to communicate with USB device using raw USB messages.
- *
- * \param[in] devpath - path to a usb device file.
- * \param[out] fd - pointer to where file descriptor will be written to
- *
- * This function checks weather calling process is permitted to communicate with
- * choosen USB device. If it is, USD opens file and passes file descriptor.
- *
- * The policy that gathers information which applications may open a file
- * descriptor must be first injected to USD by function call
- * @ref security_server_setup_usb_device_access.
- *
- * \return USD_API_SUCCESS on success or one of error codes on fail
- * \return USD_API_ERROR_ACCESS_DENIED, when user denies access
- * \return USD_API_ERROR_SOCKET,
- * \return USD_API_ERROR_INPUT_PARAM,
- * \return USD_API_ERROR_AUTHENTICATION_FAILED,
- * \return USD_API_ERROR_FILE_NOT_EXIST.
- *
- */
-int usd_open_usb_device(const char *devpath, int *fd);
-
-
-/**
- * This function enables to add policy entries to a temporary database of USD.
- * This database lasts only as long as USD process is running: it is kept in
- * process' memory.
- *
- * \param[in] topology - topological path to USB device (bus-hub.port etc)
- * (for more details please check /sys/bus/usb/devices)
- * \param[in] smack - smack label that is used to distinguish application
- * \parm[in] allow - bool that indicates weather to allow or deny access between
- *  app that has smack label 'smack' and device that is available under path
- *  'filename'
- *
- * \return USD_API_SUCCESS on success or one of error codes on fail
- *
- */
-int usd_setup_usb_device_access(const char *topology, const char *smack,
-                               bool allow);
-
-int usd_ask_user_to_grant_permission(const char *path);
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
- * @}
-*/
-
-/**
- * @}
-*/
-
-#endif
diff --git a/USD/src/main/dbus-manager.cpp b/USD/src/main/dbus-manager.cpp
deleted file mode 100644 (file)
index ea268ab..0000000
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Karol Lewandowski <k.lewandowsk@samsung.com>
- *
- *  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        dbus-manager.cpp
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @version     1.0
- * @brief       Implementation of dbus communication threads.
- */
-
-
-#include "dbus-manager.h"
-#include <dbus/dbus.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-
-
-#include <thread>
-#include <string>
-#include <dpl/log/log.h>
-#include <add-permission.h>
-
-
-namespace USD {
-
-#define USD_USB_DEVICE_CONFIRM_SIGNAL   "USBDeviceOpenResult"
-#define USD_INTERFACE                   "org.tizen.system.usd"
-#define USD_PATH                        "/Org/Tizen/System/USD"
-
-#define DEST_NAME     "org.tizen.system.popup"
-#define DEST_IFACE    "org.tizen.system.popup.System"
-#define DEST_PATH     "/Org/Tizen/System/Popup/System"
-#define DEST_METHOD   "PopupLaunch"
-
-const std::string CONTENT = "_SYSPOPUP_CONTENT_";
-const std::string POPUP_NAME = "usb_device_confirm";
-
-
-//#define BUS_TYPE          (DBUS_BUS_SESSION)
-#define BUS_TYPE          (DBUS_BUS_SYSTEM)
-
-
-enum button_selected_e {
-    USB_DEVICE_CONFIRM_OK,
-    USB_DEVICE_CONFIRM_NOK,
-  };
-
-int done;
-int get_sender_pid(DBusConnection *conn, const char *sender);
-
-static DBusHandlerResult filter_func(DBusConnection *conn,
-        DBusMessage *msg,
-        void *data)
-{
-    DBusError err;
-    dbus_bool_t handled = FALSE;
-    int result = 0;
-    DbusManager *pDM = (DbusManager *)data;
-
-    LogError("filter_func");
-
-    if (dbus_message_is_signal(msg, USD_INTERFACE, USD_USB_DEVICE_CONFIRM_SIGNAL))
-    {
-        dbus_error_init(&err);
-        dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-        if (dbus_error_is_set(&err))
-        {
-            LogError("dbus_message_get_args failed: " << err.message);
-            dbus_error_free(&err);
-            handled = TRUE;
-            //handle error?
-        }
-        else
-        {
-
-            int recv_pid = get_sender_pid(conn, dbus_message_get_sender(msg));
-            handled = pDM->handlePopup(recv_pid, result);
-            LogDebug("Popup sender pid:" << recv_pid);
-
-        }
-    }
-
-    return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-}
-
-int add_dict_entries(DBusMessage *msg, const char *str1, const char *str2)
-{
-    DBusMessageIter args, array_iter, dict_iter;
-    dbus_message_iter_init_append(msg, &args);
-
-    if (!dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY,
-            DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
-            DBUS_TYPE_STRING_AS_STRING
-            DBUS_TYPE_STRING_AS_STRING
-            DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
-            &array_iter))
-        return 0;
-
-    if (!dbus_message_iter_open_container(&array_iter, DBUS_TYPE_DICT_ENTRY, NULL, &dict_iter))
-        return 0;
-
-    if (!dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING, &str1))
-        return 0;
-
-    if (!dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING, &str2))
-        return 0;
-
-    if (!dbus_message_iter_close_container(&array_iter, &dict_iter))
-        return 0;
-
-    if (!dbus_message_iter_close_container(&args, &array_iter))
-        return 0;
-    return 1;
-}
-
-int get_sender_pid(DBusConnection *conn, const char *sender)
-{
-    int pid = 0;
-    DBusMessage *msg = NULL, *reply = NULL;
-    DBusError err;
-
-    if (!conn || !sender)
-        goto cleanup;
-
-    msg = dbus_message_new_method_call("org.freedesktop.DBus",
-            "/org/freedesktop/DBus",
-            "org.freedesktop.DBus",
-            "GetConnectionUnixProcessID");
-    if (msg == NULL)
-        goto cleanup;
-
-    dbus_message_append_args(msg, DBUS_TYPE_STRING, &sender, DBUS_TYPE_INVALID);
-
-    dbus_error_init(&err);
-    reply = dbus_connection_send_with_reply_and_block(conn, msg, 1000, &err);
-    if (dbus_error_is_set(&err))
-    {
-        LogError("dbus_connection_send_with_reply_and_block: " << err.message);
-        dbus_error_free(&err);
-        goto cleanup;
-    }
-
-    dbus_message_get_args(reply, &err, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
-    if (dbus_error_is_set(&err))
-    {
-        LogError("dbus_message_get_args: " << err.message);
-        dbus_error_free(&err);
-        goto cleanup;
-    }
-
-    cleanup:
-    if (msg)
-        dbus_message_unref(msg);
-    if (reply)
-        dbus_message_unref(reply);
-    return pid;
-}
-
-int request_popup(DBusConnection *conn, PopupData dp)
-{
-    int pid = 0;
-    DBusMessage *msg = NULL, *reply = NULL;
-    DBusError err;
-    (void) dp;/* This should be used to present user with proper data.
-    As for now popup mechanism does not provide functionality allowing to pass
-    additional data to popup to be displayed. Popup prints fixed text.
-    We may and should change it later and construct some text out of "dp"
-    and pass it to popup mechanism.*/
-
-    if (!conn)
-    {
-        LogError("Connection was not setup before");
-        goto cleanup;
-    }
-
-    msg = dbus_message_new_method_call(DEST_NAME, DEST_PATH, DEST_IFACE, DEST_METHOD);
-    if (!msg)
-    {
-        LogError("Method call was not created");
-        goto cleanup;
-    }
-
-    if (!add_dict_entries(msg, CONTENT.c_str(), POPUP_NAME.c_str()))
-    {
-        LogError("add_dict_entries failed");
-        goto cleanup;
-    }
-
-    dbus_error_init(&err);
-    reply = dbus_connection_send_with_reply_and_block(conn, msg, 1000/*one second*/, &err);
-    if (dbus_error_is_set(&err))
-    {
-        LogError("dbus_connection_send_with_reply_and_block failed " << err.message);
-        dbus_error_free(&err);
-        goto cleanup;
-    }
-
-    dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
-    if (dbus_error_is_set(&err))
-    {
-        LogError("dbus_message_get_args failed: " << err.message);
-        dbus_error_free(&err);
-        goto cleanup;
-    }
-
-    cleanup:
-    if (msg)
-        dbus_message_unref(msg);
-    if (reply)
-        dbus_message_unref(reply);
-    LogError("Got answer with pid:" << pid);
-    return pid;
-}
-
-DbusManager::DbusManager(): m_state(State::NoThread), m_quit(false){;}
-
-void DbusManager::Create() {
-    LogDebug("Creating dbus thread");
-    assert(m_state == State::NoThread);
-    m_conn = setupDbusConnection();
-    if (!m_conn) {
-        LogError("Could not setup Dbus Connection");
-        throw -1; //TODO
-    }
-    m_thread = std::thread(ThreadLoopStatic, this);
-    m_state = State::Work;
-}
-
-void DbusManager::notifyPopupHandled(pid_t pid) {
-    LogDebug("Got popup answer notify");
-    m_popupHandleMutex.lock();
-    this->m_popupMap.erase(pid);
-    m_popupHandleMutex.unlock();
-}
-
-bool DbusManager::waitForPopupHandled(pid_t popup_pid) {
-    int delay = 50;
-    while (delay > 0) {
-        delay--;
-        LogDebug("Waiting for popup, popup pid: " << popup_pid);
-        {
-            std::lock_guard<std::mutex> lock(m_popupHandleMutex);
-            if(this->m_popupMap.find(popup_pid) == m_popupMap.end()) {
-                return true;
-            }
-        }
-        std::this_thread::sleep_for(std::chrono::seconds(1));
-    }
-    return false;
-}
-
-
-bool DbusManager::handlePopup(pid_t pid, int popupResult) {
-    std::lock_guard<std::mutex> lock(m_popupHandleMutex);
-
-    USBAddPermission addPerm;
-    auto it = m_popupMap.find(pid);
-    if (it != m_popupMap.end()) {
-        const char *device = getPopupDevice(pid);
-        const char *application = getPopupApp(pid);
-        bool allow = (popupResult == USB_DEVICE_CONFIRM_OK);
-        LogDebug("Got popup answer notify from pid" << pid);
-        this->m_popupMap.erase(pid);
-        addPerm.writePermission(device, application, allow);
-        return true;
-    }
-    LogWarning("Someone tries to fake popup answer data... ");
-    return false;
-
-}
-
-void DbusManager::Join() {
-    LogDebug("Joining dbus thread");
-    assert(m_state != State::NoThread);
-    {
-        std::lock_guard<std::mutex> lock(m_popupHandleMutex);
-        m_quit = true;
-        m_state = State::NoThread;
-
-    }
-    m_thread.join();
-    LogDebug("Joined dbus thread");
-
-}
-
-DBusConnection* DbusManager::setupDbusConnection()
-{
-    DBusError err;
-    DBusConnection *conn;
-
-
-    dbus_error_init(&err);
-    conn = dbus_bus_get(BUS_TYPE, &err);
-    if (dbus_error_is_set(&err))
-    {
-        LogError("Could not get bus" << err.message);
-        dbus_error_free(&err);
-
-        return NULL;
-    }
-    assert(conn != NULL);
-    LogDebug("Bus obtained");
-
-    dbus_bus_add_match(conn,
-            "type='signal',interface='" USD_INTERFACE "'",
-            &err);
-    if (dbus_error_is_set(&err))
-    {
-        dbus_error_free(&err);
-        LogError("Could not add match");
-        return NULL;
-    }
-    LogDebug("Match added");
-
-    if (!dbus_connection_add_filter(conn, filter_func, this, NULL))
-    {
-        LogError("Could not add filter");
-        return NULL;
-    }
-    LogDebug("Filter added");
-    return conn;
-}
-
-
-pid_t DbusManager::addPopupRequest(const PopupData &popupData)
-{
-    LogDebug("Pushing popup request " << popupData);
-    std::lock_guard<std::mutex> lock(m_eventQueueMutex);
-    pid_t newPopupPid = request_popup(this->m_conn, popupData);
-    m_popupMap.insert(std::pair<pid_t, PopupData>(newPopupPid, popupData));
-    return newPopupPid;
-
-}
-
-const char *DbusManager::getPopupDevice(pid_t pid) {
-    return m_popupMap.at(pid).getDeviceTopology();
-}
-const char *DbusManager::getPopupApp(pid_t pid) {
-    return m_popupMap.at(pid).getAppData();
-}
-
-void DbusManager::ThreadLoop() {
-    for (;;) {
-
-        {
-            std::lock_guard<std::mutex> lock(m_eventQueueMutex);
-            if (m_quit) {
-                LogDebug("Quitting dbus loop");
-                return;
-            }
-        }
-        dbus_connection_read_write_dispatch(m_conn, 100);
-
-    }
-}
-
-
-}/*namespace usd*/
diff --git a/USD/src/main/dbus-manager.h b/USD/src/main/dbus-manager.h
deleted file mode 100644 (file)
index f69c746..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Karol Lewandowski <k.lewandowsk@samsung.com>
- *
- *  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        dbus-manager.h
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @version     1.0
- * @brief       Header for dbus communication threads classes.
- */
-
-#ifndef _DBUS_MANAGER_H_
-#define _DBUS_MANAGER_H_
-
-
-#include <service-thread.h>
-#include <generic-socket-manager.h>
-#include <dbus/dbus.h>
-#include <usb-access-map.h>
-#include <usb-security-daemon.h>
-#include <set>
-
-namespace USD {
-
-typedef USBAccessMapKey PopupData;
-
-
-class DbusManager{
-public:
-    pid_t addPopupRequest(const PopupData &popupData);
-    const char *getPopupDevice(pid_t pid);
-    const char *getPopupApp(pid_t pid);
-
-    enum class State {
-        NoThread,
-        Work,
-        Wait,
-    };
-
-    DbusManager();
-    void Create();
-    void Join();
-    virtual ~DbusManager()
-    {
-        if (m_state != State::NoThread)
-            Join();
-    }
-
-    void notifyPopupHandled(pid_t pid);
-    bool waitForPopupHandled(pid_t pid);
-    bool isPidActivePopup(pid_t pid);
-    bool handlePopup(pid_t pid, int popupResult);
-
-    protected:
-        std::mutex m_popupHandleMutex;
-        DBusConnection *m_conn;
-        std::thread m_thread;
-        std::mutex m_eventQueueMutex;
-
-
-      //  std::condition_variable m_waitCondition;
-        std::map<pid_t, PopupData> m_popupMap;
-        std::queue<PopupData> m_popupQueue;
-        State m_state;
-        bool m_quit;
-
-        DBusConnection* setupDbusConnection();
-        static void ThreadLoopStatic(DbusManager *ptr) { ptr->ThreadLoop(); }
-        void ThreadLoop();
-};
-
-}
-
-
-#endif /*_DBUS_MANAGER_H_*/
diff --git a/USD/src/main/generic-event.h b/USD/src/main/generic-event.h
deleted file mode 100644 (file)
index bad23ee..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        protocols.h
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       Implementation of GenericEvent.
- */
-
-#ifndef _USD_GENERIC_EVENT_
-#define _USD_GENERIC_EVENT_
-
-namespace USD {
-
-struct GenericEvent {
-    virtual ~GenericEvent(){}
-};
-
-} // namespace USD
-
-#endif // _USD_GENERIC_EVENT_
diff --git a/USD/src/main/generic-socket-manager.cpp b/USD/src/main/generic-socket-manager.cpp
deleted file mode 100644 (file)
index 38bdb0d..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        generic-socket-manager.cpp
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       Implementation of GenericSocketService and GenericSocketManager.
- */
-
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <generic-socket-manager.h>
-
-namespace USD {
-
-class SendMsgData::Internal {
-public:
-    Internal(int resultCode, int fileDesc)
-      : m_resultCode(resultCode)
-      , m_fileDesc(fileDesc)
-    {
-        memset(&m_hdr, 0, sizeof(msghdr));
-        memset(m_cmsgbuf, 0, CMSG_SPACE(sizeof(int)));
-
-        m_iov.iov_base = &m_resultCode;
-        m_iov.iov_len = sizeof(m_resultCode);
-
-        m_hdr.msg_iov = &m_iov;
-        m_hdr.msg_iovlen = 1;
-
-        if (fileDesc != -1) {
-            m_hdr.msg_control = m_cmsgbuf;
-            m_hdr.msg_controllen = CMSG_SPACE(sizeof(int));
-
-            m_cmsg = CMSG_FIRSTHDR(&m_hdr);
-            m_cmsg->cmsg_len = CMSG_LEN(sizeof(int));
-            m_cmsg->cmsg_level = SOL_SOCKET;
-            m_cmsg->cmsg_type = SCM_RIGHTS;
-
-            memmove(CMSG_DATA(m_cmsg), &m_fileDesc, sizeof(int));
-        }
-    }
-
-    msghdr* data() { return &m_hdr; }
-
-private:
-    msghdr m_hdr;
-    iovec m_iov;
-    cmsghdr *m_cmsg;
-    unsigned char m_cmsgbuf[CMSG_SPACE(sizeof(int))];
-    int m_resultCode;
-    int m_fileDesc;
-};
-
-SendMsgData::SendMsgData()
-  : m_resultCode(0)
-  , m_fileDesc(-1)
-  , m_flags(0)
-  , m_pimpl(NULL)
-{}
-
-SendMsgData::SendMsgData(int resultCode, int fileDesc, int flags)
-  : m_resultCode(resultCode)
-  , m_fileDesc(fileDesc)
-  , m_flags(flags)
-  , m_pimpl(NULL)
-{}
-
-SendMsgData::SendMsgData(const SendMsgData &second)
-  : m_resultCode(second.m_resultCode)
-  , m_fileDesc(second.m_fileDesc)
-  , m_flags(second.m_flags)
-  , m_pimpl(NULL)
-{}
-
-SendMsgData::~SendMsgData() {
-    delete m_pimpl;
-}
-
-SendMsgData& SendMsgData::operator=(const SendMsgData &second) {
-    m_resultCode = second.m_resultCode;
-    m_fileDesc = second.m_fileDesc;
-    m_flags = second.m_flags;
-    delete m_pimpl;
-    m_pimpl = NULL;
-    return *this;
-}
-
-msghdr* SendMsgData::getMsghdr() {
-    if (!m_pimpl)
-        m_pimpl = new Internal(m_resultCode, m_fileDesc);
-    return m_pimpl->data();
-}
-
-int SendMsgData::flags() {
-    return m_flags;
-}
-
-} // namespace USD
-
diff --git a/USD/src/main/generic-socket-manager.h b/USD/src/main/generic-socket-manager.h
deleted file mode 100644 (file)
index fb7d7e8..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        generic-socket-manager.h
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       Implementation of GenericSocketService and GenericSocketManager.
- */
-
-#ifndef _USD_GENERIC_SERVICE_MANAGER_
-#define _USD_GENERIC_SERVICE_MANAGER_
-
-#include <vector>
-#include <string>
-
-#include <dpl/exception.h>
-
-#include <generic-event.h>
-
-extern "C" {
-struct msghdr;
-} // extern "C"
-
-namespace USD {
-
-typedef int InterfaceID;
-
-struct ConnectionID {
-    int sock;                                 // This is decriptor used for connection
-    int counter;                              // Unique handler per socket
-    inline bool operator<(const ConnectionID &second) const {
-        return counter < second.counter;
-    }
-};
-
-typedef std::vector<unsigned char> RawBuffer;
-
-struct GenericSocketManager;
-
-struct GenericSocketService {
-    typedef std::string SmackLabel;
-    typedef std::string ServiceHandlerPath;
-    struct ServiceDescription {
-        ServiceDescription(const char *path,
-            const char *smackLabel,
-            InterfaceID interfaceID = 0,
-            bool useSendMsg = false)
-          : smackLabel(smackLabel)
-          , interfaceID(interfaceID)
-          , serviceHandlerPath(path)
-          , useSendMsg(useSendMsg)
-        {}
-
-        SmackLabel smackLabel;                 // Smack label for socket
-        InterfaceID interfaceID;               // All data from serviceHandlerPath will be marked with this interfaceHandler
-        ServiceHandlerPath serviceHandlerPath; // Path to file
-        bool useSendMsg;
-    };
-
-    typedef std::vector<ServiceDescription> ServiceDescriptionVector;
-
-    struct AcceptEvent : public GenericEvent {
-        ConnectionID connectionID;
-        InterfaceID interfaceID;
-    };
-
-    struct WriteEvent : public GenericEvent {
-        ConnectionID connectionID;
-        size_t size;
-        size_t left;
-    };
-
-    struct ReadEvent : public GenericEvent {
-        ConnectionID connectionID;
-        RawBuffer rawBuffer;
-    };
-
-    struct CloseEvent : public GenericEvent {
-        ConnectionID connectionID;
-    };
-
-    virtual void SetSocketManager(GenericSocketManager *manager) {
-        m_serviceManager = manager;
-    }
-
-    virtual ServiceDescriptionVector GetServiceDescription() = 0;
-    virtual void Event(const AcceptEvent &event) = 0;
-    virtual void Event(const WriteEvent &event) = 0;
-    virtual void Event(const ReadEvent &event) = 0;
-    virtual void Event(const CloseEvent &event) = 0;
-
-    GenericSocketService() : m_serviceManager(NULL) {}
-    virtual ~GenericSocketService(){}
-protected:
-    GenericSocketManager *m_serviceManager;
-};
-
-class SendMsgData {
-public:
-    class Internal;
-
-    SendMsgData();
-    SendMsgData(int resultCode, int fileDesc, int flags = 0);
-    SendMsgData(const SendMsgData &second);
-    SendMsgData& operator=(const SendMsgData &second);
-    virtual ~SendMsgData();
-
-    msghdr* getMsghdr();
-    int flags();
-private:
-    int m_resultCode;
-    int m_fileDesc;
-    int m_flags;
-    Internal *m_pimpl;
-};
-
-struct GenericSocketManager {
-    virtual void MainLoop() = 0;
-    virtual void RegisterSocketService(GenericSocketService *ptr) = 0;
-    virtual void Close(ConnectionID connectionID) = 0;
-    virtual void Write(ConnectionID connectionID, const RawBuffer &rawBuffer) = 0;
-    virtual void Write(ConnectionID connectionID, const SendMsgData &sendMsgData) = 0;
-    virtual ~GenericSocketManager(){}
-};
-
-} // namespace USD
-
-#endif // _USD_GENERIC_SERVICE_MANAGER_
diff --git a/USD/src/main/server2-main.cpp b/USD/src/main/server2-main.cpp
deleted file mode 100644 (file)
index a2d2f7b..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        sever2-main.cpp
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       Implementation of USD
- */
-#include <stdlib.h>
-#include <signal.h>
-
-#include <dpl/log/log.h>
-#include <dpl/singleton.h>
-#include <dpl/singleton_safe_impl.h>
-
-#include <socket-manager.h>
-#include <dbus-manager.h>
-
-
-#include <usb-access.h>
-#include <usb-ask-user-service.h>
-
-IMPLEMENT_SAFE_SINGLETON(USD::Log::LogSystem);
-
-#define REGISTER_SOCKET_SERVICE(manager, service) \
-    registerSocketService<service>(manager, #service)
-
-template<typename T>
-void registerSocketService(USD::SocketManager &manager, const std::string& serviceName)
-{
-    T *service = NULL;
-    try {
-        service = new T();
-        service->Create();
-        manager.RegisterSocketService(service);
-        service = NULL;
-    } catch (const USD::Exception &exception) {
-        LogError("Error in creating service " << serviceName <<
-                 ", details:\n" << exception.DumpToString());
-    } catch (const std::exception& e) {
-        LogError("Error in creating service " << serviceName <<
-                 ", details:\n" << e.what());
-    } catch (...) {
-        LogError("Error in creating service " << serviceName <<
-                 ", unknown exception occured");
-    }
-    if (service)
-        delete service;
-}
-
-
-USD::DbusManager dbusmanager;
-
-int main(void) {
-
-    UNHANDLED_EXCEPTION_HANDLER_BEGIN
-    {
-        USD::Singleton<USD::Log::LogSystem>::Instance().SetTag("USD");
-
-        sigset_t mask;
-        sigemptyset(&mask);
-        sigaddset(&mask, SIGTERM);
-        sigaddset(&mask, SIGPIPE);
-        if (-1 == pthread_sigmask(SIG_BLOCK, &mask, NULL)) {
-            LogError("Error in pthread_sigmask");
-            return 1;
-        }
-
-        LogInfo("Start!");
-        USD::SocketManager manager;
-
-        REGISTER_SOCKET_SERVICE(manager, USD::USBAccessService);
-        REGISTER_SOCKET_SERVICE(manager, USD::UsbAskUserService);
-        dbusmanager.Create();
-        manager.MainLoop();
-        dbusmanager.Join();
-        LogDebug("Quit");
-
-    }
-    UNHANDLED_EXCEPTION_HANDLER_END
-    return 0;
-}
-
diff --git a/USD/src/main/service-thread.h b/USD/src/main/service-thread.h
deleted file mode 100644 (file)
index d230d2f..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        service-thread.h
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       Implementation of threads.
- */
-
-#ifndef _USD_SERVICE_THREAD_
-#define _USD_SERVICE_THREAD_
-
-#include <cassert>
-#include <queue>
-#include <mutex>
-#include <thread>
-#include <memory>
-#include <condition_variable>
-
-#include <cstdio>
-
-#include <dpl/exception.h>
-
-#include "generic-event.h"
-
-#define DEFINE_THREAD_EVENT(eventType)                                \
-    void Event(const eventType &event) {                              \
-        USD::ServiceThread<ParentClassName>::              \
-            Event(event,                                              \
-                  this,                                               \
-                  &ParentClassName::EventInternal##eventType);        \
-    }                                                                 \
-    void EventInternal##eventType(const eventType &event)
-
-#define DECLARE_THREAD_EVENT(eventType, methodName)                   \
-    void Event(const eventType &event) {                              \
-        USD::ServiceThread<ParentClassName>::              \
-            Event(event,                                              \
-                  this,                                               \
-                  &ParentClassName::methodName);                      \
-    }
-
-namespace USD {
-
-template <class Service>
-class ServiceThread {
-public:
-    typedef Service ParentClassName;
-    enum class State {
-        NoThread,
-        Work,
-    };
-
-    ServiceThread()
-      : m_state(State::NoThread)
-      , m_quit(false)
-    {}
-
-    void Create() {
-        assert(m_state == State::NoThread);
-        m_thread = std::thread(ThreadLoopStatic, this);
-        m_state = State::Work;
-    }
-
-    void Join() {
-        assert(m_state != State::NoThread);
-        {
-            std::lock_guard<std::mutex> lock(m_eventQueueMutex);
-            m_quit = true;
-            m_waitCondition.notify_one();
-        }
-        m_thread.join();
-        m_state = State::NoThread;
-    }
-
-    virtual ~ServiceThread()
-    {
-        if (m_state != State::NoThread)
-            Join();
-        while (!m_eventQueue.empty()){
-            auto front = m_eventQueue.front();
-            delete front.eventPtr;
-            m_eventQueue.pop();
-        }
-    }
-
-    template <class T>
-    void Event(const T &event,
-               Service *servicePtr,
-               void (Service::*serviceFunction)(const T &))
-    {
-        EventDescription description;
-        description.serviceFunctionPtr =
-            reinterpret_cast<void (Service::*)(void*)>(serviceFunction);
-        description.servicePtr = servicePtr;
-        description.eventFunctionPtr = &ServiceThread::EventCall<T>;
-        description.eventPtr = new T(event);
-        {
-            std::lock_guard<std::mutex> lock(m_eventQueueMutex);
-            m_eventQueue.push(description);
-        }
-        m_waitCondition.notify_one();
-    }
-
-protected:
-
-    struct EventDescription {
-        void (Service::*serviceFunctionPtr)(void *);
-        Service *servicePtr;
-        void (ServiceThread::*eventFunctionPtr)(const EventDescription &event);
-        GenericEvent* eventPtr;
-    };
-
-    template <class T>
-    void EventCall(const EventDescription &desc) {
-        auto fun = reinterpret_cast<void (Service::*)(const T&)>(desc.serviceFunctionPtr);
-        const T& eventLocale = *(static_cast<T*>(desc.eventPtr));
-        (desc.servicePtr->*fun)(eventLocale);
-    }
-
-    static void ThreadLoopStatic(ServiceThread *ptr) {
-        ptr->ThreadLoop();
-    }
-
-    void ThreadLoop(){
-        for (;;) {
-            EventDescription description = {NULL, NULL, NULL, NULL};
-            {
-                std::unique_lock<std::mutex> ulock(m_eventQueueMutex);
-                if (m_quit)
-                    return;
-                if (!m_eventQueue.empty()) {
-                    description = m_eventQueue.front();
-                    m_eventQueue.pop();
-                } else {
-                    m_waitCondition.wait(ulock);
-                }
-            }
-
-            if (description.eventPtr != NULL) {
-                UNHANDLED_EXCEPTION_HANDLER_BEGIN
-                {
-                    (this->*description.eventFunctionPtr)(description);
-                    delete description.eventPtr;
-                }
-                UNHANDLED_EXCEPTION_HANDLER_END
-            }
-        }
-    }
-
-    std::thread m_thread;
-    std::mutex m_eventQueueMutex;
-    std::queue<EventDescription> m_eventQueue;
-    std::condition_variable m_waitCondition;
-
-    State m_state;
-    bool m_quit;
-};
-
-} // namespace USD
-
-#endif // _USD_SERVICE_THREAD_
diff --git a/USD/src/main/socket-manager.cpp b/USD/src/main/socket-manager.cpp
deleted file mode 100644 (file)
index ce021b7..0000000
+++ /dev/null
@@ -1,747 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        socket-manager.cpp
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       Implementation of SocketManager.
- */
-
-#include <set>
-
-#include <signal.h>
-#include <sys/select.h>
-#include <sys/signalfd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/smack.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-#include <time.h>
-
-#include <systemd/sd-daemon.h>
-
-#include <dpl/log/log.h>
-#include <dpl/assert.h>
-
-#include <smack-check.h>
-#include <socket-manager.h>
-
-namespace {
-
-const time_t SOCKET_TIMEOUT = 60;
-
-} // namespace anonymous
-
-namespace USD {
-
-struct DummyService : public GenericSocketService {
-    ServiceDescriptionVector GetServiceDescription() {
-        return ServiceDescriptionVector();
-    }
-    void Event(const AcceptEvent &event) { (void)event; }
-    void Event(const WriteEvent &event) { (void)event; }
-    void Event(const ReadEvent &event) { (void)event; }
-    void Event(const CloseEvent &event) { (void)event; }
-};
-
-struct SignalService : public GenericSocketService {
-    int GetDescriptor() {
-        LogInfo("set up");
-        sigset_t mask;
-        sigemptyset(&mask);
-        sigaddset(&mask, SIGTERM);
-        if (-1 == pthread_sigmask(SIG_BLOCK, &mask, NULL))
-            return -1;
-        return signalfd(-1, &mask, 0);
-    }
-
-    ServiceDescriptionVector GetServiceDescription() {
-        return ServiceDescriptionVector();
-    }
-
-    void Event(const AcceptEvent &event) { (void)event; } // not supported
-    void Event(const WriteEvent &event) { (void)event; }  // not supported
-    void Event(const CloseEvent &event) { (void)event; }  // not supported
-
-    void Event(const ReadEvent &event) {
-        LogDebug("Get signal information");
-
-        if(sizeof(struct signalfd_siginfo) != event.rawBuffer.size()) {
-            LogError("Wrong size of signalfd_siginfo struct. Expected: "
-                << sizeof(signalfd_siginfo) << " Get: "
-                << event.rawBuffer.size());
-            return;
-        }
-
-        signalfd_siginfo *siginfo = (signalfd_siginfo*)(&(event.rawBuffer[0]));
-
-        if (siginfo->ssi_signo == SIGTERM) {
-            LogInfo("Got signal: SIGTERM");
-            static_cast<SocketManager*>(m_serviceManager)->MainLoopStop();
-            return;
-        }
-
-        LogInfo("This should not happend. Got signal: " << siginfo->ssi_signo);
-    }
-};
-
-SocketManager::SocketDescription&
-SocketManager::CreateDefaultReadSocketDescription(int sock, bool timeout)
-{
-    if ((int)m_socketDescriptionVector.size() <= sock)
-        m_socketDescriptionVector.resize(sock+20);
-
-    auto &desc = m_socketDescriptionVector[sock];
-    desc.isListen = false;
-    desc.isOpen = true;
-    desc.interfaceID = 0;
-    desc.service = NULL;
-    desc.counter = ++m_counter;
-
-    if (timeout) {
-        desc.timeout = time(NULL) + SOCKET_TIMEOUT;
-        if (false == desc.isTimeout) {
-            Timeout tm;
-            tm.time = desc.timeout;
-            tm.sock = sock;
-            m_timeoutQueue.push(tm);
-        }
-    }
-
-    desc.isTimeout = timeout;
-
-    FD_SET(sock, &m_readSet);
-    m_maxDesc = sock > m_maxDesc ? sock : m_maxDesc;
-    return desc;
-}
-
-SocketManager::SocketManager()
-  : m_maxDesc(0)
-  , m_counter(0)
-{
-    FD_ZERO(&m_readSet);
-    FD_ZERO(&m_writeSet);
-    if (-1 == pipe(m_notifyMe)) {
-        int err = errno;
-        ThrowMsg(Exception::InitFailed, "Error in pipe: " << strerror(err));
-    }
-    LogInfo("Pipe: Read desc: " << m_notifyMe[0] << " Write desc: " << m_notifyMe[1]);
-
-    auto &desc = CreateDefaultReadSocketDescription(m_notifyMe[0], false);
-    desc.service = new DummyService;
-
-    // std::thread bases on pthread so this should work fine
-    sigset_t set;
-    sigemptyset(&set);
-    sigaddset(&set, SIGPIPE);
-    pthread_sigmask(SIG_BLOCK, &set, NULL);
-
-    // add support for TERM signal (passed from systemd)
-    auto *signalService = new SignalService;
-    signalService->SetSocketManager(this);
-    int filefd = signalService->GetDescriptor();
-    if (-1 == filefd) {
-        LogError("Error in SignalService.GetDescriptor()");
-        delete signalService;
-    } else {
-        auto &desc2 = CreateDefaultReadSocketDescription(filefd, false);
-        desc2.service = signalService;
-        LogInfo("SignalService mounted on " << filefd << " descriptor");
-    }
-}
-
-SocketManager::~SocketManager() {
-    std::set<GenericSocketService*> serviceMap;
-
-    // Find all services. Set is used to remove duplicates.
-    // In this implementation, services are not able to react in any way.
-    for (size_t i=0; i < m_socketDescriptionVector.size(); ++i)
-        if (m_socketDescriptionVector[i].isOpen)
-            serviceMap.insert(m_socketDescriptionVector[i].service);
-
-    // Time to destroy all services.
-    for(auto it = serviceMap.begin(); it != serviceMap.end(); ++it) {
-        LogDebug("delete " << (void*)(*it));
-        delete *it;
-    }
-
-    for (size_t i = 0; i < m_socketDescriptionVector.size(); ++i)
-        if (m_socketDescriptionVector[i].isOpen)
-            close(i);
-
-    // All socket except one were closed. Now pipe input must be closed.
-    close(m_notifyMe[1]);
-}
-
-void SocketManager::ReadyForAccept(int sock) {
-    struct sockaddr_un clientAddr;
-    unsigned int clientLen = sizeof(clientAddr);
-    int client = accept4(sock, (struct sockaddr*) &clientAddr, &clientLen, SOCK_NONBLOCK);
-//    LogInfo("Accept on sock: " << sock << " Socket opended: " << client);
-    if (-1 == client) {
-        int err = errno;
-        LogDebug("Error in accept: " << strerror(err));
-        return;
-    }
-
-    auto &desc = CreateDefaultReadSocketDescription(client, true);
-    desc.interfaceID = m_socketDescriptionVector[sock].interfaceID;
-    desc.service = m_socketDescriptionVector[sock].service;
-    desc.useSendMsg = m_socketDescriptionVector[sock].useSendMsg;
-
-    GenericSocketService::AcceptEvent event;
-    event.connectionID.sock = client;
-    event.connectionID.counter = desc.counter;
-    event.interfaceID = desc.interfaceID;
-    desc.service->Event(event);
-}
-
-void SocketManager::ReadyForRead(int sock) {
-    if (m_socketDescriptionVector[sock].isListen) {
-        ReadyForAccept(sock);
-        return;
-    }
-
-    GenericSocketService::ReadEvent event;
-    event.connectionID.sock = sock;
-    event.connectionID.counter = m_socketDescriptionVector[sock].counter;
-    event.rawBuffer.resize(4096);
-
-    auto &desc = m_socketDescriptionVector[sock];
-    desc.timeout = time(NULL) + SOCKET_TIMEOUT;
-
-    ssize_t size = read(sock, &event.rawBuffer[0], 4096);
-
-    if (size == 0) {
-        CloseSocket(sock);
-    } else if (size >= 0) {
-        event.rawBuffer.resize(size);
-        desc.service->Event(event);
-    } else if (size == -1) {
-        int err = errno;
-        switch(err) {
-            case EAGAIN:
-            case EINTR:
-                break;
-            default:
-                LogDebug("Reading sock error: " << strerror(err));
-                CloseSocket(sock);
-        }
-    }
-}
-
-void SocketManager::ReadyForSendMsg(int sock) {
-    auto &desc = m_socketDescriptionVector[sock];
-
-    if (desc.sendMsgDataQueue.empty()) {
-         FD_CLR(sock, &m_writeSet);
-         return;
-    }
-
-    auto data = desc.sendMsgDataQueue.front();
-    ssize_t result = sendmsg(sock, data.getMsghdr(), data.flags());
-
-    if (result == -1) {
-        int err = errno;
-        switch(err) {
-        case EAGAIN:
-        case EINTR:
-            break;
-        case EPIPE:
-        default:
-            LogDebug("Error during send: " << strerror(err));
-            CloseSocket(sock);
-            break;
-        }
-        return;
-    } else {
-        desc.sendMsgDataQueue.pop();
-    }
-
-    if (desc.sendMsgDataQueue.empty()) {
-        FD_CLR(sock, &m_writeSet);
-    }
-
-    desc.timeout = time(NULL) + SOCKET_TIMEOUT;
-
-    GenericSocketService::WriteEvent event;
-    event.connectionID.sock = sock;
-    event.connectionID.counter = desc.counter;
-    event.size = result;
-    event.left = desc.sendMsgDataQueue.size();
-
-    desc.service->Event(event);
-}
-
-void SocketManager::ReadyForWriteBuffer(int sock) {
-    auto &desc = m_socketDescriptionVector[sock];
-    size_t size = desc.rawBuffer.size();
-    ssize_t result = write(sock, &desc.rawBuffer[0], size);
-    if (result == -1) {
-        int err = errno;
-        switch(err) {
-        case EAGAIN:
-        case EINTR:
-            // select will trigger write once again, nothing to do
-            break;
-        case EPIPE:
-        default:
-            LogDebug("Error during write: " << strerror(err));
-            CloseSocket(sock);
-            break;
-        }
-        return; // We do not want to propagate error to next layer
-    }
-
-    desc.rawBuffer.erase(desc.rawBuffer.begin(), desc.rawBuffer.begin()+result);
-
-    desc.timeout = time(NULL) + SOCKET_TIMEOUT;
-
-    if (desc.rawBuffer.empty())
-        FD_CLR(sock, &m_writeSet);
-
-    GenericSocketService::WriteEvent event;
-    event.connectionID.sock = sock;
-    event.connectionID.counter = desc.counter;
-    event.size = result;
-    event.left = desc.rawBuffer.size();
-
-    desc.service->Event(event);
-}
-
-void SocketManager::ReadyForWrite(int sock) {
-    m_socketDescriptionVector[sock].useSendMsg ?
-        ReadyForSendMsg(sock) : ReadyForWriteBuffer(sock);
-}
-
-void SocketManager::MainLoop() {
-
-    // Daemon is ready to work.
-    sd_notify(0, "READY=1");
-    m_starting = true;
-    m_working = true;
-    while(m_working) {
-        fd_set readSet = m_readSet;
-        fd_set writeSet = m_writeSet;
-
-        timeval localTempTimeout;
-        timeval *ptrTimeout = &localTempTimeout;
-
-        // I need to extract timeout from priority_queue.
-        // Timeout in priority_queue may be deprecated.
-        // I need to find some actual one.
-        while(!m_timeoutQueue.empty()) {
-            auto &top = m_timeoutQueue.top();
-            auto &desc = m_socketDescriptionVector[top.sock];
-
-            if (top.time == desc.timeout) {
-                // This timeout matches timeout from socket.
-                // It can be used.
-                break;
-            } else {
-                // This socket was used after timeout in priority queue was set up.
-                // We need to update timeout and find some useable one.
-                Timeout tm = { desc.timeout , top.sock};
-                m_timeoutQueue.pop();
-                m_timeoutQueue.push(tm);
-            }
-        }
-        if (m_starting) {
-            ptrTimeout->tv_sec = SOCKET_TIMEOUT;
-            ptrTimeout->tv_usec = 0;
-            m_starting = false;
-        } else {
-            if (m_timeoutQueue.empty()) {
-                LogDebug("No useable timeout found.");
-                ptrTimeout->tv_sec = 0;
-                ptrTimeout->tv_usec = 0;
-                MainLoopStop();
-            } else {
-                time_t currentTime = time(NULL);
-                auto &pqTimeout = m_timeoutQueue.top();
-
-                // 0 means that select won't block and socket will be closed ;-)
-                ptrTimeout->tv_sec =
-                  currentTime < pqTimeout.time ? pqTimeout.time - currentTime : 0;
-                ptrTimeout->tv_usec = 0;
-//                LogDebug("Set up timeout: " << (int)ptrTimeout->tv_sec
-//                    << " seconds. Socket: " << pqTimeout.sock);
-            }
-        }
-        int ret = select(m_maxDesc+1, &readSet, &writeSet, NULL, ptrTimeout);
-
-        if (0 == ret) { // timeout
-            if (m_timeoutQueue.empty()) {
-                LogError("would abort");
-                continue;
-            }
-            Assert(!m_timeoutQueue.empty());
-
-            Timeout pqTimeout = m_timeoutQueue.top();
-            m_timeoutQueue.pop();
-
-            auto &desc = m_socketDescriptionVector[pqTimeout.sock];
-
-            if (!desc.isTimeout || !desc.isOpen) {
-                // Connection was closed. Timeout is useless...
-                desc.isTimeout = false;
-                continue;
-            }
-
-            if (pqTimeout.time < desc.timeout) {
-                // Is it possible?
-                // This socket was used after timeout. We need to update timeout.
-                pqTimeout.time = desc.timeout;
-                m_timeoutQueue.push(pqTimeout);
-                continue;
-            }
-
-            // timeout from m_timeoutQueue matches with socket.timeout
-            // and connection is open. Time to close it!
-            // Putting new timeout in queue here is pointless.
-            desc.isTimeout = false;
-            CloseSocket(pqTimeout.sock);
-
-            // All done. Now we should process next select ;-)
-            continue;
-        }
-
-        if (-1 == ret) {
-            switch(errno) {
-            case EINTR:
-                LogDebug("EINTR in select");
-                break;
-            default:
-                int err = errno;
-                LogError("Error in select: " << strerror(err));
-                return;
-            }
-            continue;
-        }
-        for(int i = 0; i<m_maxDesc+1 && ret; ++i) {
-            if (FD_ISSET(i, &readSet)) {
-                ReadyForRead(i);
-                --ret;
-            }
-            if (FD_ISSET(i, &writeSet)) {
-                ReadyForWrite(i);
-                --ret;
-            }
-        }
-        ProcessQueue();
-    }
-}
-
-void SocketManager::MainLoopStop()
-{
-    LogDebug("I am going to stop main loop");
-    m_working = false;
-    NotifyMe();
-}
-
-int SocketManager::GetSocketFromSystemD(
-    const GenericSocketService::ServiceDescription &desc)
-{
-    int fd;
-
-    // TODO optimalization - do it once in object constructor
-    //                       and remember all information path->sockfd
-    int n = sd_listen_fds(0);
-
-    LogInfo("sd_listen_fds returns: " << n);
-
-    if (n < 0) {
-        LogError("Error in sd_listend_fds");
-        ThrowMsg(Exception::InitFailed, "Error in sd_listend_fds");
-    }
-
-    for(fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START+n; ++fd) {
-        if (0 < sd_is_socket_unix(fd, SOCK_STREAM, 1,
-                                  desc.serviceHandlerPath.c_str(), 0))
-        {
-            LogInfo("Useable socket " << desc.serviceHandlerPath <<
-                " was passed by SystemD under descriptor " << fd);
-            return fd;
-        }
-    }
-    LogInfo("No useable sockets were passed by systemd.");
-    return -1;
-}
-
-int SocketManager::CreateDomainSocketHelp(
-    const GenericSocketService::ServiceDescription &desc)
-{
-    int sockfd;
-
-    if(desc.serviceHandlerPath.size() > sizeof(static_cast<sockaddr_un*>(0)->sun_path) /
-                                        sizeof(decltype(desc.serviceHandlerPath)::value_type)) {
-        LogError("Service handler path too long: " << desc.serviceHandlerPath.size());
-        ThrowMsg(Exception::InitFailed,
-                 "Service handler path too long: " << desc.serviceHandlerPath.size());
-    }
-
-    if (-1 == (sockfd = socket(AF_UNIX, SOCK_STREAM, 0))) {
-        int err = errno;
-        LogError("Error in socket: " << strerror(err));
-        ThrowMsg(Exception::InitFailed, "Error in socket: " << strerror(err));
-    }
-
-    if (smack_check()) {
-        LogInfo("Set up smack label: " << desc.smackLabel);
-
-        if (0 != smack_fsetlabel(sockfd, desc.smackLabel.c_str(), SMACK_LABEL_IPIN)) {
-            LogError("Error in smack_fsetlabel");
-            ThrowMsg(Exception::InitFailed, "Error in smack_fsetlabel");
-        }
-    } else {
-        LogInfo("No smack on platform. Socket won't be securied with smack label!");
-    }
-
-    int flags;
-    if (-1 == (flags = fcntl(sockfd, F_GETFL, 0)))
-        flags = 0;
-
-    if (-1 == fcntl(sockfd, F_SETFL, flags | O_NONBLOCK)) {
-        int err = errno;
-        close(sockfd);
-        LogError("Error in fcntl: " << strerror(err));
-        ThrowMsg(Exception::InitFailed, "Error in fcntl: " << strerror(err));
-    }
-
-    sockaddr_un serverAddress;
-    memset(&serverAddress, 0, sizeof(serverAddress));
-    serverAddress.sun_family = AF_UNIX;
-    strcpy(serverAddress.sun_path, desc.serviceHandlerPath.c_str());
-    unlink(serverAddress.sun_path);
-
-    mode_t originalUmask;
-    originalUmask = umask(0);
-
-    if (-1 == bind(sockfd, (struct sockaddr*)&serverAddress, sizeof(serverAddress))) {
-        int err = errno;
-        close(sockfd);
-        LogError("Error in bind: "  << desc.serviceHandlerPath.c_str() << strerror(err));
-        ThrowMsg(Exception::InitFailed, "Error in bind: " << strerror(err));
-    }
-
-    umask(originalUmask);
-
-    if (-1 == listen(sockfd, 5)) {
-        int err = errno;
-        close(sockfd);
-        LogError("Error in listen: " << strerror(err));
-        ThrowMsg(Exception::InitFailed, "Error in listen: " << strerror(err));
-    }
-
-    return sockfd;
-}
-
-void SocketManager::CreateDomainSocket(
-    GenericSocketService *service,
-    const GenericSocketService::ServiceDescription &desc)
-{
-    int sockfd = GetSocketFromSystemD(desc);
-    if (-1 == sockfd)
-        sockfd = CreateDomainSocketHelp(desc);
-
-    auto &description = CreateDefaultReadSocketDescription(sockfd, false);
-
-    description.isListen = true;
-    description.interfaceID = desc.interfaceID;
-    description.useSendMsg = desc.useSendMsg;
-    description.service = service;
-
-    LogDebug("Listen on socket: " << sockfd <<
-        " Handler: " << desc.serviceHandlerPath.c_str());
-}
-
-void SocketManager::RegisterSocketService(GenericSocketService *service) {
-    service->SetSocketManager(this);
-    auto serviceVector = service->GetServiceDescription();
-    Try {
-        for (auto iter = serviceVector.begin(); iter != serviceVector.end(); ++iter)
-            CreateDomainSocket(service, *iter);
-    } Catch (Exception::Base) {
-        for (int i =0; i < (int)m_socketDescriptionVector.size(); ++i)
-        {
-            auto &desc = m_socketDescriptionVector[i];
-            if (desc.service == service && desc.isOpen) {
-                close(i);
-                desc.isOpen = false;
-            }
-        }
-        ReThrow(Exception::Base);
-    }
-}
-
-void SocketManager::Close(ConnectionID connectionID) {
-    {
-        std::lock_guard<std::mutex> ulock(m_eventQueueMutex);
-        m_closeQueue.push(connectionID);
-    }
-    NotifyMe();
-}
-
-void SocketManager::Write(ConnectionID connectionID, const RawBuffer &rawBuffer) {
-    WriteBuffer buffer;
-    buffer.connectionID = connectionID;
-    buffer.rawBuffer = rawBuffer;
-    {
-        std::lock_guard<std::mutex> ulock(m_eventQueueMutex);
-        m_writeBufferQueue.push(buffer);
-    }
-    NotifyMe();
-}
-
-void SocketManager::Write(ConnectionID connectionID, const SendMsgData &sendMsgData) {
-    WriteData data;
-    data.connectionID = connectionID;
-    data.sendMsgData = sendMsgData;
-    {
-        std::lock_guard<std::mutex> ulock(m_eventQueueMutex);
-        m_writeDataQueue.push(data);
-    }
-    NotifyMe();
-}
-
-void SocketManager::NotifyMe() {
-    TEMP_FAILURE_RETRY(write(m_notifyMe[1], "You have message ;-)", 1));
-}
-
-void SocketManager::ProcessQueue() {
-    WriteBuffer buffer;
-    WriteData data;
-    {
-        std::lock_guard<std::mutex> ulock(m_eventQueueMutex);
-        while (!m_writeBufferQueue.empty()) {
-            buffer = m_writeBufferQueue.front();
-            m_writeBufferQueue.pop();
-
-            auto &desc = m_socketDescriptionVector[buffer.connectionID.sock];
-
-            if (!desc.isOpen) {
-                LogDebug("Received packet for write but connection is closed. Packet ignored!");
-                continue;
-            }
-
-            if (desc.counter != buffer.connectionID.counter)
-            {
-                LogDebug("Received packet for write but counter is broken. Packet ignored!");
-                continue;
-            }
-
-            if (desc.useSendMsg) {
-                LogError("Some service tried to push rawdata to socket that usees sendmsg!");
-                continue;
-            }
-
-            std::copy(
-                buffer.rawBuffer.begin(),
-                buffer.rawBuffer.end(),
-                std::back_inserter(desc.rawBuffer));
-
-            FD_SET(buffer.connectionID.sock, &m_writeSet);
-        }
-
-        while(!m_writeDataQueue.empty()) {
-            data = m_writeDataQueue.front();
-            m_writeDataQueue.pop();
-
-            auto &desc = m_socketDescriptionVector[data.connectionID.sock];
-
-            if (!desc.isOpen) {
-                LogDebug("Received packet for sendmsg but connection is closed. Packet ignored!");
-                continue;
-            }
-
-            if (desc.counter != data.connectionID.counter)
-            {
-                LogDebug("Received packet for write but counter is broken. Packet ignored!");
-                continue;
-            }
-
-            if (!desc.useSendMsg) {
-                LogError("Some service tries to push SendMsgData to socket that uses write!");
-                continue;
-            }
-
-            desc.sendMsgDataQueue.push(data.sendMsgData);
-
-            FD_SET(data.connectionID.sock, &m_writeSet);
-        }
-    }
-
-    while (1) {
-        ConnectionID connection;
-        {
-            std::lock_guard<std::mutex> ulock(m_eventQueueMutex);
-            if (m_closeQueue.empty())
-                return;
-            connection = m_closeQueue.front();
-            m_closeQueue.pop();
-        }
-
-        if (!m_socketDescriptionVector[connection.sock].isOpen)
-            continue;
-
-        if (connection.counter != m_socketDescriptionVector[connection.sock].counter)
-            continue;
-
-        CloseSocket(connection.sock);
-    }
-}
-
-void SocketManager::CloseSocket(int sock) {
-//    LogInfo("Closing socket: " << sock);
-    auto &desc = m_socketDescriptionVector[sock];
-
-    if (!(desc.isOpen)) {
-        // This may happend when some information was waiting for write to the
-        // socket and in the same time socket was closed by the client.
-        LogError("Socket " << sock << " is not open. Nothing to do!");
-        return;
-    }
-
-    GenericSocketService::CloseEvent event;
-    event.connectionID.sock = sock;
-    event.connectionID.counter = desc.counter;
-    auto service = desc.service;
-
-    desc.isOpen = false;
-    desc.service = NULL;
-    desc.interfaceID = -1;
-    desc.rawBuffer.clear();
-    while(!desc.sendMsgDataQueue.empty())
-        desc.sendMsgDataQueue.pop();
-
-    if (service)
-        service->Event(event);
-    else
-        LogError("Critical! Service is NULL! This should never happend!");
-
-    TEMP_FAILURE_RETRY(close(sock));
-    FD_CLR(sock, &m_readSet);
-    FD_CLR(sock, &m_writeSet);
-}
-
-} // namespace USD
diff --git a/USD/src/main/socket-manager.h b/USD/src/main/socket-manager.h
deleted file mode 100644 (file)
index 95abb93..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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        socket-manager.h
- * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
- * @version     1.0
- * @brief       SocketManager implementation.
- */
-
-#ifndef _USD_SOCKET_MANAGER_
-#define _USD_SOCKET_MANAGER_
-
-#include <vector>
-#include <queue>
-#include <string>
-#include <mutex>
-#include <thread>
-
-#include <dpl/exception.h>
-
-#include <generic-socket-manager.h>
-
-namespace USD {
-
-class SocketManager : public GenericSocketManager {
-public:
-    class Exception {
-    public:
-        DECLARE_EXCEPTION_TYPE(USD::Exception, Base)
-        DECLARE_EXCEPTION_TYPE(Base, InitFailed)
-    };
-    SocketManager();
-    virtual ~SocketManager();
-    virtual void MainLoop();
-    virtual void MainLoopStop();
-
-    virtual void RegisterSocketService(GenericSocketService *service);
-    virtual void Close(ConnectionID connectionID);
-    virtual void Write(ConnectionID connectionID, const RawBuffer &rawBuffer);
-    virtual void Write(ConnectionID connectionID, const SendMsgData &sendMsgData);
-
-protected:
-    void CreateDomainSocket(
-        GenericSocketService *service,
-        const GenericSocketService::ServiceDescription &desc);
-    int CreateDomainSocketHelp(
-        const GenericSocketService::ServiceDescription &desc);
-    int GetSocketFromSystemD(
-        const GenericSocketService::ServiceDescription &desc);
-
-    void ReadyForRead(int sock);
-    void ReadyForWrite(int sock);
-    void ReadyForWriteBuffer(int sock);
-    void ReadyForSendMsg(int sock);
-    void ReadyForAccept(int sock);
-    void ProcessQueue(void);
-    void NotifyMe(void);
-    void CloseSocket(int sock);
-
-    struct SocketDescription {
-        bool isListen;
-        bool isOpen;
-        bool isTimeout;
-        bool useSendMsg;
-        InterfaceID interfaceID;
-        GenericSocketService *service;
-        time_t timeout;
-        RawBuffer rawBuffer;
-        std::queue<SendMsgData> sendMsgDataQueue;
-        int counter;
-
-        SocketDescription()
-          : isListen(false)
-          , isOpen(false)
-          , isTimeout(false)
-          , useSendMsg(false)
-          , interfaceID(-1)
-          , service(NULL)
-        {}
-    };
-
-    SocketDescription& CreateDefaultReadSocketDescription(int sock, bool timeout);
-
-    typedef std::vector<SocketDescription> SocketDescriptionVector;
-
-    struct WriteBuffer {
-        ConnectionID connectionID;
-        RawBuffer rawBuffer;
-    };
-
-    struct WriteData {
-        ConnectionID connectionID;
-        SendMsgData sendMsgData;
-    };
-
-    struct Timeout {
-        time_t time;
-        int sock;
-        bool operator<(const Timeout &second) const {
-            return time > second.time; // mininum first!
-        }
-    };
-
-    SocketDescriptionVector m_socketDescriptionVector;
-    fd_set m_readSet;
-    fd_set m_writeSet;
-    int m_maxDesc;
-    bool m_working;
-    bool m_starting;
-    std::mutex m_eventQueueMutex;
-    std::queue<WriteBuffer> m_writeBufferQueue;
-    std::queue<WriteData> m_writeDataQueue;
-    std::queue<ConnectionID> m_closeQueue;
-    int m_notifyMe[2];
-    int m_counter;
-    std::priority_queue<Timeout> m_timeoutQueue;
-};
-
-} // namespace USD
-
-#endif // _USD_SOCKET_MANAGER_
diff --git a/USD/src/main/usd-util.cpp b/USD/src/main/usd-util.cpp
deleted file mode 100644 (file)
index 858d5b1..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- *  USD security daemon
- *
- *  Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/smack.h>
-#include <unistd.h>
-
-#include <limits>
-
-#include <usd-util.h>
-#include <dpl/log/log.h>
-
-namespace {
-const size_t SIZE_T_MAX = std::numeric_limits<size_t>::max();
-} // namespace anonymous
-
-namespace USD {
-
-int util_smack_label_is_valid(const char *smack_label)
-{
-    int i;
-
-    if (!smack_label || smack_label[0] == '\0' || smack_label[0] == '-')
-        goto err;
-
-    for (i = 0; smack_label[i]; ++i) {
-        if (i >= SMACK_LABEL_LEN)
-            return 0;
-        switch (smack_label[i]) {
-            case '~':
-            case ' ':
-            case '/':
-            case '"':
-            case '\\':
-            case '\'':
-                goto err;
-            default:
-                break;
-        }
-    }
-
-    return 1;
-err:
-    LogError("Invalid Smack label: " << (smack_label ? smack_label : ""));
-    return 0;
-}
-
-char *read_exe_path_from_proc(pid_t pid)
-{
-    char link[32];
-    char *exe = NULL;
-    size_t size = 64;
-    ssize_t cnt = 0;
-
-    // get link to executable
-    snprintf(link, sizeof(link), "/proc/%d/exe", pid);
-
-    for (;;)
-    {
-        exe = (char*) malloc(size);
-        if (exe == NULL)
-        {
-            LogError("Out of memory");
-            return NULL;
-        }
-
-        // read link target
-        cnt = readlink(link, exe, size);
-
-        // error
-        if (cnt < 0 || (size_t) cnt > size)
-        {
-            LogError("Can't locate process binary for pid=" << pid);
-            free(exe);
-            return NULL;
-        }
-
-        // read less than requested
-        if ((size_t) cnt < size)
-            break;
-
-        // read exactly the number of bytes requested
-        free(exe);
-        if (size > (SIZE_T_MAX >> 1))
-        {
-            LogError("Exe path too long (more than " << size << " characters)");
-            return NULL;
-        }
-        size <<= 1;
-    }
-    // readlink does not append null byte to buffer.
-    exe[cnt] = '\0';
-    return exe;
-}
-
-} // namespace USD
-
diff --git a/USD/src/main/usd-util.h b/USD/src/main/usd-util.h
deleted file mode 100644 (file)
index bc3ae49..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *  USB security daemon
- *
- *  Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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
- *
- */
-
-#ifndef USD_UTIL_H
-#define USD_UTIL_H
-
-#include <sys/types.h>
-
-namespace USD {
-
-int util_smack_label_is_valid(const char *smack_label);
-char *read_exe_path_from_proc(pid_t pid);
-
-} // namespace USD
-
-#endif /*USD_UTIL_H*/
diff --git a/USD/src/service/add-permission.cpp b/USD/src/service/add-permission.cpp
deleted file mode 100644 (file)
index c7fca54..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-*/
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Stanislaw Wadas <s.wadas@samsung.com>
- *
- *  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        add-permission.cpp
- * @author      Stanislaw Wadas <s.wadas@samsung.com>
- * @version     1.0
- */
-
-#include <dpl/log/log.h>
-#include <dpl/serialization.h>
-
-#include <protocols.h>
-#include <usb-security-daemon.h>
-#include <usd-util.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <add-permission.h>
-#include <usb-access.h>
-#include <usb-access-map.h>
-#include <dbus-manager.h>
-#include <cstdint>
-#include <usb-access.h>
-
-namespace USD {
-
-USBAccessMap m_accessMap;
-
-int USBAddPermission::writePermission(const char *path, const char *smack, bool policy)
-{
-    using namespace USD;
-
-    LogDebug("Processing writePermission");
-
-    int retCode = USD_API_ERROR_SERVER_ERROR;
-
-    try {
-        std::string smack1, path1;
-        bool valid;
-        path1 = std::string(path);
-        smack1 = std::string(smack);
-
-        USBAccessMapKey mk(smack1,
-                           USBDeviceId(path1, USBDevicePath::PATH_TYPE_SYSFS));
-
-        LogDebug("policy: " << policy
-                 << ", smack: " << smack << ", path: " << path1);
-
-        valid = mk.validate();
-        LogDebug("Validation" << (valid ? "ok" : "failed")
-                 <<" on: " << mk << ", policy: " << policy);
-
-        if (valid) {
-            std::lock_guard<std::mutex> lock(m_eventWriteDBMutex);
-            m_accessMap[mk] = policy;
-            storePolicy();
-            retCode = USD_API_SUCCESS;
-        } else {
-            retCode = USD_API_ERROR_ACCESS_DENIED;
-            LogDebug("SD_API_ERROR_ACCESS_DENIED");
-        }
-    } catch(int e) {
-        LogDebug("Error occured on processing: " << e);
-        retCode = e;
-    }
-
-    return retCode;
-}
-
-} // namespace USD
diff --git a/USD/src/service/add-permission.h b/USD/src/service/add-permission.h
deleted file mode 100644 (file)
index 7c55f2b..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-*/
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Stanislaw Wadas <s.wadas@samsung.com>
- *
- *  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        add-permission.h
- * @author      Stanislaw Wadas <s.wadas@samsung.com>
- * @version     1.0
- */
-
-#ifndef USD_ADD_PERMISSION_H_
-#define USD_ADD_PERMISSION_H_
-
-#include <usb-access-map.h>
-#include <usb-access.h>
-#include <service-thread.h>
-#include <generic-socket-manager.h>
-
-#include <dpl/serialization.h>
-#include <message-buffer.h>
-#include <usb-access-map.h>
-#include <mutex>
-
-
-namespace USD {
-
-extern USBAccessMap m_accessMap;
-
-
-class USBAddPermission :
-        public USD::USBAccessService
-
-
-{
-public:
-       int writePermission(const char *topology, const char *smack, bool allow);
-
-private:
-       std::mutex m_eventWriteDBMutex;
-};
-
-} /* namespace USD */
-
-#endif /* USD_USB_ACCESS_H_ */
diff --git a/USD/src/service/usb-access.cpp b/USD/src/service/usb-access.cpp
deleted file mode 100644 (file)
index 08639c5..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-/*-*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-*/
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Karol Lewandowski <k.lewandowski@samsung.com>
- *
- *  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        usb-access.cpp
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @author      Krzysztof Opasiak <k.opasiak@samsung.com>
- * @version     1.0
- * @brief       Implementation of service for granting usb raw data access.
- */
-
-#include <dpl/log/log.h>
-#include <dpl/serialization.h>
-
-#include <protocols.h>
-#include <usb-security-daemon.h>
-#include <usd-util.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <usb-access.h>
-#include <usb-access-map.h>
-#include <dbus-manager.h>
-#include <add-permission.h>
-
-#include <iostream>
-#include <fstream>
-
-namespace {
-// Service may open more than one socket.
-// These ID's will be assigned to sockets
-// and will be used only by service.
-// When new connection arrives, AcceptEvent
-// will be generated with proper ID to inform
-// service about input socket.
-//
-// Please note: SocketManaged does not use it and
-// does not check it in any way.
-//
-// If your service require only one socket
-// (uses only one socket labeled with smack)
-// you may ignore this ID (just pass 0)
-const int SERVICE_SOCKET_ID = 0;
-
-} // namespace anonymous
-
-extern USD::DbusManager dbusmanager;
-
-namespace USD {
-
-GenericSocketService::ServiceDescriptionVector
-USBAccessService::GetServiceDescription()
-{
-    ServiceDescriptionVector description = {
-        {
-            /* service's socket path */
-            .path = SERVICE_SOCKET_USB_ACCESS,
-            /* service's socket smack label */
-            .smackLabel = "usd::api-usb-access",
-            /* service's interface id */
-            .interfaceID = SERVICE_SOCKET_ID,
-            /* service is using sendMsg */
-            .useSendMsg = true,
-        }
-    };
-
-    return description;
-}
-
-void USBAccessService::accept(const AcceptEvent &event)
-{
-    LogDebug("Accept event. "
-             << "ConnectionID.sock: " << event.connectionID.sock
-             << " ConnectionID.counter: " << event.connectionID.counter
-             << " ServiceID: " << event.interfaceID);
-}
-
-void USBAccessService::write(const WriteEvent &event)
-{
-    LogDebug("WriteEvent. "
-             << "ConnectionID: " << event.connectionID.sock
-             << " Size: " << event.size
-             << " Left: " << event.left);
-
-    if (event.left == 0)
-        m_serviceManager->Close(event.connectionID);
-}
-
-int USBAccessService::checkAccessEntry(PolicySubjectId subjectId,
-                                        const USBDeviceId &devId)
-{
-    USBAccessMapKey key(subjectId, devId);
-
-    LogDebug("checkAccessEntry begin");
-    LogDebug("key: " << key);
-
-    auto it = m_accessMap.find(key);
-    if (it == m_accessMap.end()) {
-        LogDebug("There is no entry in the database.");
-        return USD_API_ERROR_POLICY_UNKNOWN;
-    }
-
-    LogDebug("There is an entry in a database. "
-             "Value of policy: " << it->second);
-
-    return it->second ? USD_API_SUCCESS : USD_API_ERROR_ACCESS_DENIED;
-}
-
-static inline int openFileForClient(const char *path, int &fd)
-{
-    fd = TEMP_FAILURE_RETRY(open(path, O_RDWR));
-    if (fd < 0) {
-        LogError("Cannot open file: " << path);
-        return USD_API_ERROR_FILE_NOT_EXIST;
-    }
-
-    LogDebug("Opened file: '" << path << "' fd: " << fd);
-    return USD_API_SUCCESS;
-}
-
-bool USBAccessService::processOpen(const ConnectionID &conn,
-                                   MessageBuffer &buffer)
-{
-    int fd = -1;
-    int retCode = USD_API_ERROR_SERVER_ERROR;
-
-    LogDebug("Processing USB_CALL_TYPE_OPEN");
-
-    try {
-        std::string path;
-        PolicySubjectId peerId(conn.sock);
-
-        Deserialization::Deserialize(buffer, path);
-
-        USBDeviceId devId(path, USBDevicePath::PATH_TYPE_DEV);
-
-        retCode = checkAccessEntry(peerId, devId);
-        if (retCode == USD_API_ERROR_POLICY_UNKNOWN) {
-            USBAccessMapKey mapkey(peerId, devId);
-            pid_t pid = dbusmanager.addPopupRequest(mapkey);
-            if (dbusmanager.waitForPopupHandled(pid))
-                retCode = checkAccessEntry(peerId, devId);
-            else
-                retCode = USD_API_ERROR_POLICY_UNKNOWN;
-        }
-
-        if (retCode == USD_API_SUCCESS) {
-            LogDebug("Access granted for opening: "
-                     << path << " which belongs to: " << devId
-                     << " by: " << peerId);
-            retCode = openFileForClient(path.c_str(), fd);
-        }
-        else {
-            LogDebug("Access denied for opening: "
-                     << path << " which belongs to: " << devId
-                     << " by: " << peerId << " Error code: " << retCode);
-        }
-    } catch(int e) {
-        retCode = e;
-    }
-
-    /* Send the result */
-    SendMsgData sendMsgData(retCode, fd);
-    m_serviceManager->Write(conn, sendMsgData);
-    /* We always return true because we have proccessed this message */
-    return true;
-}
-
-bool USBAccessService::storePolicy(void) {
-    std::ofstream myfile;
-    myfile.open(POLICY_FILE_PATH);
-    for(auto it = m_accessMap.begin(); it != m_accessMap.end(); it++) {
-            // it->first is map key
-            // it->second is map value (policy at key)
-        myfile << it->first << " " << it->second << " \n";
-    }
-    myfile.close();
-    return true;
-}
-
-bool USBAccessService::restorePolicy(void) {
-    LogDebug("Restoring policy from file" << POLICY_FILE_PATH);
-    std::ifstream file (POLICY_FILE_PATH);
-    std::string line;
-    if (file.is_open())
-    {
-        LogDebug("Policy file found");
-
-        while (std::getline(file, line)) {
-
-            std::stringstream ss(line);
-            std::string item;
-            int i = 0;
-            std::string values[12];
-
-            while (std::getline(ss, item, ';'))
-            {
-                values[i++] = item;
-            }
-
-            PolicySubjectId sub_id(values[0]);
-
-            USBDevicePath m_path(values[8], values[9], values[10]);
-
-            USBDeviceId devId(values, m_path);
-
-            USBAccessMapKey key(sub_id, devId);
-
-            bool policy = atoll(values[11].c_str());
-
-            m_accessMap[key] = policy;
-
-            LogDebug("key: " << key << " policy: " << policy);
-
-        }
-
-        file.close();
-        return true;
-    }
-    LogDebug("No policy file found");
-    return false;
-}
-
-bool USBAccessService::processSetupPolicy(const ConnectionID &conn,
-                                          MessageBuffer &buffer)
-{
-    int retCode = USD_API_ERROR_SERVER_ERROR;
-
-    LogDebug("Processing USB_CALL_TYPE_SETUP_POLICY");
-    try {
-        std::string smack, path;
-        bool policy;
-        bool valid;
-
-        Deserialization::Deserialize(buffer, smack);
-        Deserialization::Deserialize(buffer, path);
-
-        USBAccessMapKey mk(smack,
-                           USBDeviceId(path, USBDevicePath::PATH_TYPE_TOPO));
-
-        Deserialization::Deserialize(buffer, policy);
-        LogDebug("policy: " << policy
-                 << ", smack: " << smack << ", path: " << path);
-
-        valid = mk.validate();
-        LogDebug("Validation" << (valid ? "ok" : "failed")
-                 <<" on: " << mk << ", policy: " << policy);
-        if (valid) {
-            std::lock_guard<std::mutex> lock(m_eventWriteDBMutex);
-            m_accessMap[mk] = policy;
-            storePolicy();
-            retCode = USD_API_SUCCESS;
-        } else {
-            retCode = USD_API_ERROR_ACCESS_DENIED;
-        }
-    } catch(int e) {
-        LogDebug("Error occured on processing: " << e);
-        retCode = e;
-    }
-
-    /* Send the result */
-    SendMsgData sendMsgData(retCode, -1);
-    m_serviceManager->Write(conn, sendMsgData);
-
-    /* We always return true because we have proccessed this message */
-    return true;
-}
-
-bool USBAccessService::processOne(const ConnectionID &conn,
-                                  MessageBuffer &buffer)
-{
-    LogDebug("Iteration begin");
-    bool ret = true;
-
-    if (!buffer.Ready())
-        return false;
-
-    Try {
-        USBAccessCall callType;
-        int tmp;
-
-        Deserialization::Deserialize(buffer, tmp);
-        callType = static_cast<USBAccessCall>(tmp);
-
-        switch(callType) {
-        case USBAccessCall::USB_CALL_TYPE_OPEN:
-            ret = processOpen(conn, buffer);
-            break;
-
-        case USBAccessCall::USB_CALL_TYPE_SETUP_POLICY:
-            ret = processSetupPolicy(conn, buffer);
-            break;
-
-        default:
-            LogDebug("Broken protocol. Closing socket.");
-            m_serviceManager->Close(conn);
-            ret = false;
-        }
-    } Catch (MessageBuffer::Exception::Base) {
-        LogDebug("Broken protocol. Closing socket.");
-        m_serviceManager->Close(conn);
-        ret = false;
-    }
-
-    return ret;
-}
-
-void USBAccessService::process(const ReadEvent &event)
-{
-    LogDebug("Read event for counter: " << event.connectionID.counter);
-
-    auto &buffer = m_messageBufferMap[event.connectionID.counter];
-    buffer.Push(event.rawBuffer);
-
-    /*
-     * We can get several requests in one package.
-     * Extract and process them all
-     */
-    while(processOne(event.connectionID, buffer));
-}
-
-void USBAccessService::close(const CloseEvent &event)
-{
-    LogDebug("CloseEvent. ConnectionID: " << event.connectionID.sock);
-    m_messageBufferMap.erase(event.connectionID.counter);
-}
-
-} // namespace USD
-
diff --git a/USD/src/service/usb-access.h b/USD/src/service/usb-access.h
deleted file mode 100644 (file)
index 5b0e2e7..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-*/
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Jan Cybulski <j.cybulski@samsung.com>
- *
- *  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        usb-access.h
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @author      Krzysztof Opasiak <k.opasiak@samsung.com>
- * @version     1.0
- * @brief       Implementation of service for granting usb raw data access.
- */
-
-#ifndef USD_USB_ACCESS_H_
-#define USD_USB_ACCESS_H_
-
-#include <usb-access-map.h>
-#include <service-thread.h>
-#include <generic-socket-manager.h>
-
-#include <dpl/serialization.h>
-#include <message-buffer.h>
-#include <usb-access-map.h>
-
-namespace USD {
-
-class USBAccessService  :
-        public USD::GenericSocketService,
-        public USD::ServiceThread<USBAccessService>
-{
-public:
-    typedef std::map<int, MessageBuffer> MessageBufferMap;
-    const std::string POLICY_FILE_PATH = "/run/usb-security-daemon/usdpolicy";
-
-    ServiceDescriptionVector GetServiceDescription();
-
-    USBAccessService() {restorePolicy();};
-    bool storePolicy(void);
-
-    DECLARE_THREAD_EVENT(AcceptEvent, accept)
-    DECLARE_THREAD_EVENT(WriteEvent, write)
-    DECLARE_THREAD_EVENT(ReadEvent, process)
-    DECLARE_THREAD_EVENT(CloseEvent, close)
-
-    void accept(const AcceptEvent &event);
-    void write(const WriteEvent &event);
-    void process(const ReadEvent &event);
-    void close(const CloseEvent &event);
-
-private:
-    bool restorePolicy(void);
-    bool processOne(const ConnectionID &conn, MessageBuffer &buffer);
-    bool processOpen(const ConnectionID &conn, MessageBuffer &buffer);
-    bool processSetupPolicy(const ConnectionID &conn, MessageBuffer &buffer);
-    int checkAccessEntry(PolicySubjectId subjectId, const USBDeviceId &devId);
-       std::mutex m_eventWriteDBMutex;
-
-    MessageBufferMap m_messageBufferMap;
-};
-
-} /* namespace USD */
-
-#endif /* USD_USB_ACCESS_H_ */
diff --git a/USD/src/service/usb-ask-user-service.cpp b/USD/src/service/usb-ask-user-service.cpp
deleted file mode 100644 (file)
index bd63a14..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Karol Lewandowski <k.lewandowsk@samsung.com>
- *
- *  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        usb-ask-user-service.cpp
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @version     1.0
- * @brief       Implementation of service asking users for access.
- */
-
-#include <sys/smack.h>
-
-#include <dpl/log/log.h>
-#include <dpl/serialization.h>
-#include <dpl/exception.h>
-
-
-#include <protocols.h>
-#include <usb-ask-user-service.h>
-
-#include <usb-security-daemon.h>
-#include <usd-util.h>
-#include <smack-check.h>
-
-#include <usb-access-map.h>
-#include <dbus-manager.h>
-
-
-extern USD::DbusManager dbusmanager;
-
-
-namespace USD {
-
-
-
-UsbAskUserService::ServiceDescriptionVector UsbAskUserService::GetServiceDescription() {
-    return ServiceDescriptionVector
-        {{SERVICE_SOCKET_ASK_USER, "usd::api-ask-user" }};
-}
-
-void UsbAskUserService::accept(const AcceptEvent &event) {
-    LogDebug("Accept event. ConnectionID.sock: " << event.connectionID.sock
-        << " ConnectionID.counter: " << event.connectionID.counter
-        << " ServiceID: " << event.interfaceID);
-}
-
-void UsbAskUserService::write(const WriteEvent &event) {
-    LogDebug("WriteEvent. ConnectionID: " << event.connectionID.sock <<
-        " Size: " << event.size << " Left: " << event.left);
-    if (event.left == 0)
-        m_serviceManager->Close(event.connectionID);
-}
-
-bool UsbAskUserService::processOne(const ConnectionID &conn, MessageBuffer &buffer) {
-    LogDebug("Iteration begin");
-
-    std::string path;
-
-
-    int retCode = USD_API_ERROR_SERVER_ERROR;
-
-
-    if (!buffer.Ready()) {
-        return false;
-    }
-
-    Try {
-        Deserialization::Deserialize(buffer, path);
-        PolicySubjectId subject(conn.sock);
-        USBDeviceId device(path, USBDevicePath::PATH_TYPE_DEV);
-        USBAccessMapKey mk(subject, device);
-        pid_t pid = dbusmanager.addPopupRequest(mk);
-        if (dbusmanager.waitForPopupHandled(pid))
-            retCode = USD_API_SUCCESS;
-        else
-            retCode = USD_API_ERROR_AUTHENTICATION_FAILED;
-    } Catch (MessageBuffer::Exception::Base) {
-        LogError("Broken protocol. Closing socket.");
-        m_serviceManager->Close(conn);
-        return false;
-    } catch (int e) {
-        LogError("Something wrong, ret code: " << e);
-    } catch (...) {
-        LogError("Something wrong.");
-    }
-    LogDebug("Processing finished, returning " << retCode);
-    MessageBuffer sendBuffer;
-    Serialization::Serialize(sendBuffer, retCode);
-    m_serviceManager->Write(conn, sendBuffer.Pop());
-
-    return true;
-}
-
-void UsbAskUserService::process(const ReadEvent &event) {
-    LogDebug("Read event for counter: " << event.connectionID.counter);
-    auto &buffer = m_messageBufferMap[event.connectionID.counter];
-    buffer.Push(event.rawBuffer);
-
-    // We can get several requests in one package.
-    // Extract and process them all
-    while(processOne(event.connectionID, buffer));
-}
-
-void UsbAskUserService::close(const CloseEvent &event) {
-    LogDebug("CloseEvent. ConnectionID: " << event.connectionID.sock);
-    m_messageBufferMap.erase(event.connectionID.counter);
-}
-
-} /* namespace USD */
-
diff --git a/USD/src/service/usb-ask-user-service.h b/USD/src/service/usb-ask-user-service.h
deleted file mode 100644 (file)
index cbe574d..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Karol Lewandowski <k.lewandowsk@samsung.com>
- *
- *  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        usb-ask-user-service.cpp
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @version     1.0
- * @brief       Implementation of service asking users for access.
- */
-
-#ifndef _USD_ASK_USER_SERVICE_
-#define _USD_ASK_USER_SERVICE_
-
-#include <service-thread.h>
-#include <generic-socket-manager.h>
-
-#include <dpl/serialization.h>
-#include <message-buffer.h>
-#include <usb-access-map.h>
-
-
-namespace USD {
-
-class UsbAskUserService  :
-    public USD::GenericSocketService
-  , public USD::ServiceThread<UsbAskUserService>
-{
-public:
-    typedef std::map<int, MessageBuffer> MessageBufferMap;
-
-    ServiceDescriptionVector GetServiceDescription();
-
-    DECLARE_THREAD_EVENT(AcceptEvent, accept)
-    DECLARE_THREAD_EVENT(WriteEvent, write)
-    DECLARE_THREAD_EVENT(ReadEvent, process)
-    DECLARE_THREAD_EVENT(CloseEvent, close)
-
-    void accept(const AcceptEvent &event);
-    void write(const WriteEvent &event);
-    void process(const ReadEvent &event);
-    void close(const CloseEvent &event);
-private:
-    bool processOne(const ConnectionID &conn, MessageBuffer &buffer);
-    MessageBufferMap m_messageBufferMap;
-
-
-};
-
-} /* namespace USD*/
-
-#endif
diff --git a/USD/systemd/CMakeLists.txt b/USD/systemd/CMakeLists.txt
deleted file mode 100644 (file)
index 708bb83..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-INSTALL(FILES
-    ${CMAKE_SOURCE_DIR}/USD/systemd/usd.service
-    ${CMAKE_SOURCE_DIR}/USD/systemd/usd-access.socket
-    ${CMAKE_SOURCE_DIR}/USD/systemd/usd-ask-user.socket
-    DESTINATION
-    ${SYSTEMD_DIR}
-)
-
diff --git a/USD/systemd/usd-access.socket b/USD/systemd/usd-access.socket
deleted file mode 100644 (file)
index eb39775..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-[Socket]
-ListenStream=/run/usd/usd-api-usb-access.socket
-SocketMode=0777
-SmackLabelIPIn=*
-SmackLabelIPOut=@
-
-Service=usd.service
-
-
-[Install]
-WantedBy=sockets.target
diff --git a/USD/systemd/usd-ask-user.socket b/USD/systemd/usd-ask-user.socket
deleted file mode 100644 (file)
index 5b54fce..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-[Socket]
-ListenStream=/run/usd/usd-api-ask-user.socket
-SocketMode=0777
-SmackLabelIPIn=*
-SmackLabelIPOut=@
-
-Service=usd.service
-
-
-[Install]
-WantedBy=sockets.target
diff --git a/USD/systemd/usd.service b/USD/systemd/usd.service
deleted file mode 100644 (file)
index e762902..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=USB security daemon
-
-[Service]
-Type=notify
-ExecStart=/usr/bin/usd
-Sockets=usd-access.socket
-Sockets=usd-ask-user.socket
-
-
-[Install]
-WantedBy=multi-user.target
index 028165cc0cfe579fe1919cfc96a1091b70f5d3b4..580d7877568fe91c1081ec05850df702082376f7 100644 (file)
@@ -7,8 +7,6 @@ Group:          Base/Device Management
 
 Source0:        %{name}-%{version}.tar.gz
 Source1001:     %{name}.manifest
-Source1002:     libUSD-client.manifest
-Source1003:     USD.manifest
 BuildRequires:  pkg-config
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(libusb-1.0)
@@ -39,8 +37,6 @@ compilation of applications which use capi-system-usbhost.
 %prep
 %setup -q
 cp %{SOURCE1001} .
-cp %{SOURCE1002} .
-cp %{SOURCE1003} .
 
 
 %build
@@ -66,16 +62,11 @@ rm -rf %{buildroot}
 mkdir -p %{buildroot}%{_datadir}/license
 mkdir -p %{buildroot}/usr/lib/tmpfiles.d
 cp LICENSE %{buildroot}%{_datadir}/license/%{name}
-cp LICENSE %{buildroot}%{_datadir}/license/libusd-client
-cp usb-security-daemon.conf %{buildroot}/usr/lib/tmpfiles.d
 mkdir -p %{buildroot}%{_sysconfdir}/security/
 %make_install
 
 mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants
 mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
-ln -s ../usd.service %{buildroot}%{_unitdir}/multi-user.target.wants/usd.service
-ln -s ../usd-access.socket %{buildroot}%{_unitdir}/sockets.target.wants/usd-access.socket
-ln -s ../usd-ask-user.socket %{buildroot}%{_unitdir}/sockets.target.wants/usd-ask-user.socket
 
 
 %post -p /sbin/ldconfig
@@ -100,94 +91,7 @@ rm -rf %{buildroot}
 %{_libdir}/lib%{name}.so
 %{_libdir}/pkgconfig/%{name}.pc
 
-%package usd
-Summary:    Usb securit daemon and utilities
-
-%description usd
-USB security Daemon
-
-%package libusd-client
-Summary:    USD (client)
-Group:      Security/Libraries
-Requires:   capi-system-usbhost-usd = %{version}-%{release}
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-
-%description libusd-client
-USD client libraries
-
-%package libusd-client-devel
-Summary:    USD (client-devel)
-Group:      Security/Development
-Requires:   capi-system-usbhost-libusd-client = %{version}-%{release}
-
-%description libusd-client-devel
-Development files needed for using the security client
-
-%package usd-devel
-Summary:    USD (Development)
-Group:      Security/Development
-Requires:   capi-system-usbhost-usd = %{version}-%{release}
-
-%description usd-devel
-Development files for the USB security daemon
-
-%post usd
-ldconfig
-systemctl daemon-reload
-if [ $1 = 1 ]; then
-# installation
-    systemctl start usd.service
-fi
-
-if [ $1 = 2 ]; then
-# update
-    systemctl restart usd.service
-fi
-
-%preun usd
-if [ $1 = 0 ]; then
-# unistall
-    systemctl stop usd.service
-fi
-
-%postun usd
-ldconfig
-if [ $1 = 0 ]; then
-# unistall
-    systemctl daemon-reload
-fi
-
-%post libusd-client -p /sbin/ldconfig
-
-%postun libusd-client -p /sbin/ldconfig
-
-%files usd
-%manifest USD.manifest
-%defattr(-,root,root,-)
-%attr(755,root,root) %{_bindir}/usd
-%{_libdir}/libusd-commons.so.*
-%attr(-,root,root) %{_unitdir}/multi-user.target.wants/usd.service
-%attr(-,root,root) %{_unitdir}/usd.service
-%attr(-,root,root) %{_unitdir}/sockets.target.wants/usd-access.socket
-%attr(-,root,root) %{_unitdir}/sockets.target.wants/usd-ask-user.socket
-%attr(-,root,root) %{_unitdir}/usd-access.socket
-%attr(-,root,root) %{_unitdir}/usd-ask-user.socket
-%attr(-,root,root) /usr/lib/tmpfiles.d/usb-security-daemon.conf
 %{_datadir}/license/%{name}
 
-%files libusd-client
-%manifest libUSD-client.manifest
-%defattr(-,root,root,-)
-%{_libdir}/libusd-client.so.*
-%{_datadir}/license/libusd-client
-
-%files libusd-client-devel
-%manifest %{name}.manifest
-%defattr(-,root,root,-)
-%{_libdir}/libusd-client.so
-%{_libdir}/libusd-commons.so
-%{_includedir}/usd/usb-security-daemon.h
-%{_libdir}/pkgconfig/capi-system-usbhost-usd.pc
 
 %changelog
index 62859b9a8f506ff852dada02d74efa7f38a1079b..356987ab548bc407a53332e01955b66f5d5e184f 100644 (file)
@@ -16,4 +16,3 @@
 # @author      Tomasz Swierczek (t.swierczek@samsung.com)
 #
 
-ADD_SUBDIRECTORY(USD)
diff --git a/pc/USD/CMakeLists.txt b/pc/USD/CMakeLists.txt
deleted file mode 100644 (file)
index a50ebe1..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-#
-#    Licensed under the Apache License, Version 2.0 (the "License");
-#    you may not use this file except in compliance with the License.
-#    You may obtain a copy of the License at
-#
-#        http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#    See the License for the specific language governing permissions and
-#    limitations under the License.
-#
-# @file        CMakeLists.txt
-# @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
-# @brief
-#
-
-CONFIGURE_FILE(capi-system-usbhost-usd.pc.in capi-system-usbhost-usd.pc @ONLY)
-
-INSTALL(FILES
-    ${CMAKE_BINARY_DIR}/pc/USD/capi-system-usbhost-usd.pc
-    DESTINATION
-    ${LIB_INSTALL_DIR}/pkgconfig
-    )
diff --git a/pc/USD/capi-system-usbhost-usd.pc.in b/pc/USD/capi-system-usbhost-usd.pc.in
deleted file mode 100644 (file)
index 96e647c..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-libdir=@LIB_INSTALL_DIR@
-includedir=${prefix}/include
-
-Name: capi-system-usbhost-usd
-Description: USD Package
-Version: 1.1
-Requires: libsmack
-Libs: -L${libdir} -lusd-client
-Cflags: -I${includedir}/usd