Tizen 2.1 base
[platform/framework/native/channel-service.git] / inc / FIo_MessagePortService.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_MessagePortService.h
20  * @brief       This is the header file for the _MessagePortService class.
21  *
22  * This file contains the declarations of _MessagePortService.
23  */
24
25 #ifndef _FIO_INTERNAL_MESSAGE_PORT_SERVICE_H_
26 #define _FIO_INTERNAL_MESSAGE_PORT_SERVICE_H_
27
28 #include <FBaseResult.h>
29 #include <FBaseString.h>
30 #include <FBaseColHashMap.h>
31 #include <FBaseColHashMapT.h>
32 #include <FAppTypes.h>
33
34 namespace IPC
35 {
36 class Message;
37 }
38
39 namespace Tizen { namespace Io
40 {
41
42 class _MessagePortStub;
43
44 class _MessagePortService
45 {
46 public:
47         _MessagePortService(void);
48
49         virtual ~_MessagePortService(void);
50
51         virtual result Construct(_MessagePortStub& stub);
52
53         virtual result RegisterMessagePort(const Tizen::Base::String& appId,
54                                                                         const Tizen::Base::String& port,
55                                                                    int clientId,
56                                                                    bool isTrusted);
57
58         virtual result RequestRemotePort(const Tizen::App::AppId& remoteAppId,
59                                                                         const Tizen::Base::String& remotePort,
60                                                                    bool isTrusted);
61
62         result UnregisterMessagePort(int clientId);
63
64         virtual result SendMessage(const Tizen::Base::String& dest,
65                                                         const Tizen::Base::String& destPort,
66                                                         bool isTrusted,
67                                                         const Tizen::Base::Collection::HashMap* pMap);
68
69         virtual result SendMessage(const Tizen::Base::String& src,
70                                                         const Tizen::Base::String& srcPort,
71                                                         bool isTrustedSrc,
72                                                         const Tizen::Base::String& dest,
73                                                         const Tizen::Base::String& destPort,
74                                                         bool isTrustedDest,
75                                                         const Tizen::Base::Collection::HashMap* pMap);
76
77 private:
78         Tizen::Base::String GetKey(const Tizen::Base::String& appId, const Tizen::Base::String& port) const;
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 private:
102         _MessagePortStub* __pStub;
103
104         Tizen::Base::Collection::HashMapT <Tizen::Base::String, int>* __pPorts;
105         Tizen::Base::Collection::HashMapT <Tizen::Base::String, int>* __pTrustedPorts;
106 }; // _MessagePortService
107
108 } } // Tizen::Io
109
110 #endif // _FIO_INTERNAL_MESSAGE_PORT_SERVICE_H_