Update the spec file
[platform/framework/native/channel-service.git] / inc / FIo_ChannelService.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_ChannelService.h
20  * @brief       This is the header file for the _ChannelService class.
21  *
22  * This file contains the declarations of _ChannelService.
23  */
24
25 #ifndef _FIO_INTERNAL_CHANNEL_SERVICE_H_
26 #define _FIO_INTERNAL_CHANNEL_SERVICE_H_
27
28 #include <vector>
29
30 #include <FBaseResult.h>
31 #include <FBaseObject.h>
32 #include <FBaseColIList.h>
33 #include <FBaseColHashMapT.h>
34 #include <FOspConfig.h>
35 #include "FIo_IChannelService.h"
36 #include "FIo_IChannelServiceEventListener.h"
37
38 namespace IPC
39 {
40 class Message;
41 }
42
43 namespace Tizen { namespace Io
44 {
45 class _IChannelServiceStub;
46 class _ChannelCAppStub;
47
48 enum _ChannelType
49 {
50         OSPAPP_CHANNEL = 0,
51         CAPP_CHANNEL,
52         WEBAPP_CHANNEL
53 };
54
55 class _OSP_EXPORT_ _ChannelService
56         : public Tizen::Base::Object
57         , public Tizen::Io::_IChannelService
58 {
59 public:
60         _ChannelService(void);
61
62         virtual ~_ChannelService(void);
63
64         virtual result Construct(_IChannelServiceStub& stub);
65
66         // _IChannelService
67         virtual result RegisterChannel(const Tizen::Base::String& channelId, const _IChannelServiceEventListener& listener);
68         virtual result UnregisterChannel(const Tizen::Base::String& channelId);
69
70         virtual result SendRequest(const Tizen::Base::String& src, const Tizen::Base::String& dest, const Tizen::Base::Collection::ArrayList& args, int messageId);
71         virtual result SendNullRequest(const Tizen::Base::String& src, const Tizen::Base::String& dest, int messageId);
72
73         virtual result SendResponse(const Tizen::Base::String& src, const Tizen::Base::String& dest, const Tizen::Base::Collection::ArrayList& args, int messageId);
74         virtual result SendNullResponse(const Tizen::Base::String& src, const Tizen::Base::String& dest, int messageId);
75
76
77         bool IsChannelRegistered(const Tizen::Base::String& channelId);
78
79         result RegisterChannel(const Tizen::Base::String& channelId, int clientId, unsigned int type = OSPAPP_CHANNEL);
80
81         result RegisterChannel(const Tizen::Base::String& channelId, int clientId, void* pGIOChannel);
82
83         result UnregisterChannel(int clientId);
84
85 private:
86
87         struct _ChannelInfo
88         {
89                 Tizen::Base::String channelId;
90                 int clientId;
91                 void* pGIOChannel;
92                 unsigned int type;
93         };
94
95         class _StringHashProvider
96                 : public Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>
97         {
98         public:
99                 virtual int GetHashCode(const Tizen::Base::String& value) const
100                 {
101                         return value.GetHashCode();
102                 }
103         };
104
105         class _StringComparer
106                 : public Tizen::Base::Collection::IComparerT<Tizen::Base::String>
107         {
108         public:
109                 virtual result Compare(const Tizen::Base::String& string1, const Tizen::Base::String& string2, int& cmp) const
110                 {
111                         cmp = string1.CompareTo(string2);
112                         return E_SUCCESS;
113                 }
114         };
115 private:
116         _IChannelServiceStub* __pIChannelServiceStub;
117         Tizen::Base::Collection::HashMapT <Tizen::Base::String, _ChannelInfo*> __channels;
118
119 }; // _ChannelService
120
121
122 } } // Tizen::Io
123
124 #endif // _FIO_INTERNAL_CHANNEL_SERVICE_STUB_H_