Merge "Revert "Fix N_SE-46938 for tz list."" into devel_3.0_main
[platform/framework/native/appfw.git] / src / io / inc / FIo_MessagePortProxy.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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  * @file        FIo_MessagePortProxy.h
19  * @brief       This is the header file for the _MessagePortProxy class.
20  *
21  * This file contains the declarations of _MessagePortProxy.
22  */
23
24
25 #ifndef _FIO_INTERNAL_MESSAGE_PORT_PROXY_H_
26 #define _FIO_INTERNAL_MESSAGE_PORT_PROXY_H_
27
28 #include <bundle.h>
29
30 #include <FBaseResult.h>
31 #include <FBaseObject.h>
32 #include <FBaseString.h>
33 #include <FBaseColHashMap.h>
34 #include <FBaseColHashMapT.h>
35 #include <FAppTypes.h>
36
37 #include "FIo_IMessagePortListener.h"
38
39 namespace Tizen { namespace Io
40 {
41
42 class _MessagePortProxy
43         : public Tizen::Base::Object
44 {
45 public:
46         _MessagePortProxy(void);
47
48         virtual ~_MessagePortProxy(void);
49
50         virtual result Construct(void);
51
52         virtual result RegisterMessagePort(const Tizen::Base::String& localPort,
53                                                                        bool isTrusted,
54                                                                        const _IMessagePortListener& listener);
55
56         virtual result RequestRemotePort(const Tizen::App::AppId& remoteAppId,
57                                                                         const Tizen::Base::String& remotePort,
58                                                                         bool isTrusted);
59
60         virtual result SendMessage(const Tizen::App::AppId& remoteAppId,
61                                                            const Tizen::Base::String& remotePort,
62                                                            bool isTrusted,
63                                                            const Tizen::Base::Collection::HashMap* pMap);
64
65         virtual result SendMessage(const Tizen::Base::String& localPort,
66                                                            bool isTrustedLocal,
67                                                            const Tizen::App::AppId& remoteAppId,
68                                                            const Tizen::Base::String& remotePort,
69                                                            bool isTrustedRemote,
70                                                            const Tizen::Base::Collection::HashMap* pMap);
71
72         static _MessagePortProxy* GetProxy(void);
73
74         bundle* ConvertMapToBundleN(const Tizen::Base::Collection::HashMap* pMap, int* pSize);
75
76 private:
77         result ConvertToResult(int error);
78
79         class _StringHashProvider
80                 : public Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>
81         {
82         public:
83                 virtual int GetHashCode(const Tizen::Base::String& value) const
84                 {
85                         return value.GetHashCode();
86                 }
87         };
88
89         class _StringComparer
90                 : public Tizen::Base::Collection::IComparerT<Tizen::Base::String>
91         {
92         public:
93                 virtual result Compare(const Tizen::Base::String& string1, const Tizen::Base::String& string2, int& cmp) const
94                 {
95                         cmp = string1.CompareTo(string2);
96                         return E_SUCCESS;
97                 }
98         };
99
100 public:
101         Tizen::App::AppId __appId;
102
103         Tizen::Base::Collection::HashMapT <Tizen::Base::String, _IMessagePortListener*> __listeners;
104         Tizen::Base::Collection::HashMapT <Tizen::Base::String, _IMessagePortListener*> __trustedListeners;
105         Tizen::Base::Collection::HashMapT <Tizen::Base::String, int> __ids;
106         Tizen::Base::Collection::HashMapT <Tizen::Base::String, int> __trustedIds;
107 }; // _MessagePortProxy
108
109
110 } } // Tizen::Io
111
112 #endif // _FIO_INTERNAL_MESSAGE_PORT_PROXY_H_