50af7cef4317114580ac5e198beff4ce81bfda37
[platform/framework/native/appfw.git] / src / io / inc / FIo_MessagePortProxy.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FIo_MessagePortProxy.h
20  * @brief       This is the header file for the _MessagePortProxy class.
21  *
22  * This file contains the declarations of _MessagePortProxy.
23  */
24
25
26 #ifndef _FIO_INTERNAL_MESSAGE_PORT_PROXY_H_
27 #define _FIO_INTERNAL_MESSAGE_PORT_PROXY_H_
28
29 #include <bundle.h>
30
31 #include <FBaseResult.h>
32 #include <FBaseObject.h>
33 #include <FBaseString.h>
34 #include <FBaseColHashMap.h>
35 #include <FBaseColHashMapT.h>
36 #include <FAppTypes.h>
37
38 #include "FIo_IMessagePortListener.h"
39
40 namespace Tizen { namespace Io
41 {
42
43 class _MessagePortProxy
44         : public Tizen::Base::Object
45 {
46 public:
47         _MessagePortProxy(void);
48
49         virtual ~_MessagePortProxy(void);
50
51         virtual result Construct(void);
52
53         virtual result RegisterMessagePort(const Tizen::Base::String& localPort,
54                                                                        bool isTrusted,
55                                                                        const _IMessagePortListener& listener);
56
57         virtual result RequestRemotePort(const Tizen::App::AppId& remoteAppId,
58                                                                         const Tizen::Base::String& remotePort,
59                                                                         bool isTrusted);
60
61         virtual result SendMessage(const Tizen::App::AppId& remoteAppId,
62                                                            const Tizen::Base::String& remotePort,
63                                                            bool isTrusted,
64                                                            const Tizen::Base::Collection::HashMap* pMap);
65
66         virtual result SendMessage(const Tizen::Base::String& localPort,
67                                                            bool isTrustedLocal,
68                                                            const Tizen::App::AppId& remoteAppId,
69                                                            const Tizen::Base::String& remotePort,
70                                                            bool isTrustedRemote,
71                                                            const Tizen::Base::Collection::HashMap* pMap);
72
73         static _MessagePortProxy* GetProxy(void);
74
75         bundle* ConvertMapToBundleN(const Tizen::Base::Collection::HashMap* pMap);
76
77 private:
78         result ConvertToResult(int error);
79
80         class _StringHashProvider
81                 : public Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>
82         {
83         public:
84                 virtual int GetHashCode(const Tizen::Base::String& value) const
85                 {
86                         return value.GetHashCode();
87                 }
88         };
89
90         class _StringComparer
91                 : public Tizen::Base::Collection::IComparerT<Tizen::Base::String>
92         {
93         public:
94                 virtual result Compare(const Tizen::Base::String& string1, const Tizen::Base::String& string2, int& cmp) const
95                 {
96                         cmp = string1.CompareTo(string2);
97                         return E_SUCCESS;
98                 }
99         };
100
101 public:
102         Tizen::App::AppId __appId;
103
104         Tizen::Base::Collection::HashMapT <Tizen::Base::String, _IMessagePortListener*> __listeners;
105         Tizen::Base::Collection::HashMapT <Tizen::Base::String, _IMessagePortListener*> __trustedListeners;
106         Tizen::Base::Collection::HashMapT <Tizen::Base::String, int> __ids;
107         Tizen::Base::Collection::HashMapT <Tizen::Base::String, int> __trustedIds;
108 }; // _MessagePortProxy
109
110
111 } } // Tizen::Io
112
113 #endif // _FIO_INTERNAL_MESSAGE_PORT_PROXY_H_