Update change log and spec for wrt-plugins-tizen_0.2.73
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Messaging / CallbackMgr.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. 
15 */
16
17
18 /**
19  *
20  *
21  * @file       CallbackMgr.h
22  * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
23  * @version    0.1
24  * @brief
25  */
26
27 #ifndef CALLBACKMGR_H_
28 #define CALLBACKMGR_H_
29
30 #include <map>
31 #include <dpl/singleton.h>
32 #include <dpl/mutex.h>
33
34 extern "C" {
35 #include <msg_types.h>
36 #include <msg_transport_types.h>
37 }
38
39 namespace TizenApis {
40 namespace Platform {
41 namespace Messaging {
42
43 class ISendingObserver;
44
45 /*
46  *
47  */
48 class CallbackMgr
49 {
50   protected:
51     CallbackMgr();
52
53 //    static void sendCallback(MSG_HANDLE_T handle,
54 //            MSG_SENT_STATUS_S *sent_status,
55     static void sendCallback(msg_handle_t handle,
56             msg_struct_t sent_status,
57             void *user_param);
58
59 //    void call(MSG_SENT_STATUS_S *sent_status);
60     void call(msg_struct_t sent_status);
61
62   public:
63     ~CallbackMgr();
64
65 //    typedef int (*SendingFunction)(MSG_HANDLE_T, MSG_REQUEST_S*);
66     typedef int (*SendingFunction)(msg_handle_t, msg_struct_t);
67
68     // register for sending callback
69     msg_error_t registerAndSend(SendingFunction sendingFn,
70 //            const msg_message_t& message,
71             const msg_struct_t& message,
72             ISendingObserver* observer);
73
74     // unregister callback
75     void unregister(int reqId);
76
77   private:
78     DPL::Mutex m_mutex;
79
80     typedef std::map<msg_request_id_t, ISendingObserver*> SendReqMap;
81     SendReqMap m_sendRequests;
82 };
83
84 typedef DPL::Singleton<CallbackMgr> CallbackMgrSingleton;
85 }
86 }
87 }
88 #endif /* CALLBACKMGR_H_ */