Implementation of IPC Asynchronous Message Support.
[platform/framework/web/wrt-plugins-common.git] / src / plugins-ipc-message / ipc_message_support.h
index fa96e3f..d2c5384 100644 (file)
 #ifndef WRT_SRC_IPC_MESSAGE_SUPPORT
 #define WRT_SRC_IPC_MESSAGE_SUPPORT
 
+#include <memory>
+#include <map>
 #include <string>
 #include <WKBundle.h>
+#include <EWebKit2.h>
+
+typedef void (*AsyncReplyCallback)(unsigned int, void*, const char*);
 
 namespace IPCMessageSupport {
+
+static const char * const REPLY_ASYNC = "ToInjectedBundle::REPLY_ASYNC";
+static const char * const TIZEN_CHANGE_USERAGENT = "tizen://changeUA";
+static const char * const TIZEN_DELETE_ALL_COOKIES = "tizen://deleteAllCookies";
+
+class AsyncConnection
+{
+  public:
+    AsyncReplyCallback replyCallback;
+    void* data;
+
+    AsyncConnection(AsyncReplyCallback r, void* d) :
+        replyCallback(r),
+        data(d)
+    {
+    }
+};
+
+typedef std::shared_ptr<AsyncConnection> AsyncConnectionPtr;
+typedef std::map<unsigned int, AsyncConnectionPtr> AsyncConnectionMap;
+
+class AsyncConnectionManager
+{
+  private:
+    AsyncConnectionMap m_connectionMap;
+
+  public:
+    ~AsyncConnectionManager();
+
+    // Singleton
+    static AsyncConnectionManager &instance();
+
+    int addConnection(AsyncConnectionPtr connection);
+    bool removeConnection(int handle);
+    AsyncConnectionPtr getConnection(int handle);
+
+};
+
 void setWKBundleRef(WKBundleRef bundleRef);
 void setXwindowHandle(unsigned int handle);
 const char* sendMessageToUiProcess(const char* name, const char* body);
+int  sendAsyncMessageToUiProcess(const char* name, const char* body, AsyncReplyCallback replyCallback, void* data);
+void* ignoreAsyncMessageReply(int handle);
+void replyAsyncMessageToWebProcess(Ewk_Context* ewkContext, int handle, const char* body);
 }
 
 #endif // WRT_SRC_IPC_MESSAGE_SUPPORT
\ No newline at end of file