revise exported headers and cleanup headers
[platform/core/connectivity/smartcard-service.git] / server / include / ServerGDBus.h
1 /*
2  * Copyright (c) 2012, 2013 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 #ifndef SERVERGDBUS_H_
18 #define SERVERGDBUS_H_
19
20 #include <glib.h>
21 #include <queue>
22 #include <vector>
23
24 #include "Synchronous.h"
25 #include "GDBusHelper.h"
26 #include "smartcard-service-gdbus.h"
27
28 using namespace std;
29
30 namespace smartcard_service_api
31 {
32         typedef void (*dispatcher_cb_t)(vector<void *> &params);
33
34         class GDBusDispatcher : public Synchronous
35         {
36         public :
37                 static GDBusDispatcher &getInstance();
38
39                 /* push to queue */
40                 static void push(dispatcher_cb_t cb, const vector<void *> &params);
41
42         private :
43                 std::queue<pair<dispatcher_cb_t, vector<void *> > > q;
44
45                 GDBusDispatcher();
46                 ~GDBusDispatcher();
47
48                 void _push(dispatcher_cb_t cb, const vector<void *> &params);
49                 static gboolean dispatch(gpointer user_data);
50         };
51
52         class ServerGDBus
53         {
54         public :
55                 GDBusProxy *dbus_proxy;
56
57                 static ServerGDBus &getInstance();
58
59                 bool init();
60                 void deinit();
61
62                 /* connect to dbus daemon */
63                 bool _init();
64                 void _deinit();
65                 pid_t getPID(const char *name);
66
67                 void emitReaderInserted(unsigned int reader_id,
68                         const char *reader_name);
69                 void emitReaderRemoved(unsigned int reader_id,
70                         const char *reader_name);
71
72         private :
73                 GDBusConnection *connection;
74
75                 SmartcardServiceSeService *seService;
76                 SmartcardServiceReader *reader;
77                 SmartcardServiceSession *session;
78                 SmartcardServiceChannel *channel;
79
80                 ServerGDBus();
81                 ~ServerGDBus();
82
83                 bool initSEService();
84                 void deinitSEService();
85
86                 bool initReader();
87                 void deinitReader();
88
89                 bool initSession();
90                 void deinitSession();
91
92                 bool initChannel();
93                 void deinitChannel();
94         };
95 } /* namespace smartcard_service_api */
96
97 #endif /* SERVERGDBUS_H_ */