Fix serious bug that causes crash on CKM exit.
[platform/core/security/key-manager.git] / src / manager / service / ckm-service.h
index 770e954..b8b6c55 100644 (file)
  * @file        ckm-service.h
  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
  * @version     1.0
- * @brief       Sample service implementation.
+ * @brief       CKM service implementation.
  */
 #pragma once
 
-#include <service-thread.h>
-#include <generic-socket-manager.h>
-#include <connection-info.h>
+#include <thread-service.h>
 #include <message-buffer.h>
+#include <dpl/exception.h>
 
 namespace CKM {
 
 class CKMLogic;
 
-class CKMService
-  : public CKM::GenericSocketService
-  , public CKM::ServiceThread<CKMService>
+class CKMService : public CKM::ThreadService
 {
 public:
     CKMService();
@@ -40,32 +37,32 @@ public:
     CKMService(CKMService &&) = delete;
     CKMService& operator=(const CKMService &) = delete;
     CKMService& operator=(CKMService &&) = delete;
+
+    virtual void Start(void);
+    virtual void Stop(void);
+
     virtual ~CKMService();
 
     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(
+    class Exception {
+    public:
+        DECLARE_EXCEPTION_TYPE(CKM::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, BrokenProtocol)
+    };
+
+    bool ProcessOne(
         const ConnectionID &conn,
         ConnectionInfo &info);
 
-    RawBuffer processControl(
+    RawBuffer ProcessControl(
         MessageBuffer &buffer);
 
-    RawBuffer processStorage(
+    RawBuffer ProcessStorage(
         Credentials &cred,
         MessageBuffer &buffer);
 
-    ConnectionInfoMap m_connectionInfoMap;
     CKMLogic *m_logic;
 };