Update group in spec file
[platform/framework/native/channel-service.git] / inc / FIo_ChannelCAppStub.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_ChannelCAppStub.h
20  * @brief       This is the header file for the _ChannelCAppStub class.
21  *
22  * This file contains the declarations of _ChannelCAppStub.
23  */
24
25 #ifndef _FIO_INTERNAL_CHANNEL_CAPP_STUB_H_
26 #define _FIO_INTERNAL_CHANNEL_CAPP_STUB_H_
27
28 #include <string>
29 #include <pthread.h>
30 #include <map>
31 #include <glib.h>
32
33 #include <FOspConfig.h>
34 #include <FBaseObject.h>
35 #include <FBaseString.h>
36 #include <FBaseResult.h>
37 #include <FBaseColArrayList.h>
38 #include <FIo_ChannelService.h>
39
40 namespace Tizen { namespace Base { namespace Runtime
41 {
42 class _EventDispatcher;
43 }}}
44
45 namespace Tizen { namespace Io
46 {
47
48 class _IIpcServerEventListener;
49 class _ChannelServiceStub;
50
51 /**
52  * @class _ChannelCAppStub
53  * @brief This class provides methods to handle c-application request messages.
54  * @since 2.1
55  *
56  */
57 class _OSP_EXPORT_ _ChannelCAppStub
58         : public Tizen::Base::Object
59 {
60 public:
61         /**
62          * This is the default constructor for this class.
63          * @since 2.1
64          */
65         _ChannelCAppStub(void);
66
67         /**
68          * This is the destructor for this class.
69          * @since 2.1
70          */
71         virtual ~_ChannelCAppStub(void);
72
73         result Construct(void);
74
75         void SetChannelService(_ChannelService& service);
76
77         static bool SendResponse(int requestId, void* pGIOChannel, const Tizen::Base::Collection::ArrayList& args);
78
79 private:
80         _ChannelCAppStub(const _ChannelCAppStub& rhs);
81
82         _ChannelCAppStub& operator =(const _ChannelCAppStub& rhs);
83
84         static gboolean OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpointer data);
85
86         static gboolean OnReadMessage(GIOChannel* source, GIOCondition condition, gpointer data);
87
88         gboolean HandleReceivedMessage(GIOChannel* source, GIOCondition condition, gpointer data);
89
90         _ChannelService* __pChannelService;
91
92         struct  _ClientInfo;
93
94         struct  _ChannelInfo
95         {
96                 _ChannelInfo(void);
97                 ~_ChannelInfo(void);
98
99                 struct _ClientInfo* pClientInfo;
100                 GIOChannel* pGIOChannel;
101                 GSource* pGSource;
102                 bool destroySource;
103         };
104
105         struct  _ClientInfo
106         {
107                 _ClientInfo(void);
108                 ~_ClientInfo(void);
109
110                 int clientId;                              /**< the client id */
111                 _ChannelCAppStub* pChannelStub;                    /**< the pointer to an _ChannelCAppStub */
112                 std::vector <struct _ChannelInfo*> channels;   /**< the set of channels associated with a client */
113                 Tizen::Base::String appId;
114                 //Tizen::Base::String appExecutableName;
115         };
116
117         GMainContext* __pGMainContext;
118
119         GSource* __pConnectGSource;
120
121         std::map <int, _ClientInfo*> __clients;   // pid of client is used for key
122
123 }; // _ChannelCAppStub
124
125 }} // Tizen::Io
126
127 #endif // _FIO_INTERNAL_CHANNEL_CAPP_STUB_H_
128