More changes about using gdbus
[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 #ifdef USE_GDBUS
21 #include <glib.h>
22
23 #include "smartcard-service-gdbus.h"
24
25 namespace smartcard_service_api
26 {
27         class ServerGDBus
28         {
29         public :
30                 GDBusProxy *dbus_proxy;
31
32                 static ServerGDBus &getInstance();
33
34                 bool init();
35                 void deinit();
36
37                 /* connect to dbus daemon */
38                 bool _init();
39                 void _deinit();
40                 pid_t getPID(const char *name);
41
42                 void emitReaderInserted(unsigned int reader_id,
43                         const char *reader_name);
44                 void emitReaderRemoved(unsigned int reader_id,
45                         const char *reader_name);
46
47         private :
48
49                 GDBusConnection *connection;
50
51                 SmartcardServiceSeService *seService;
52                 SmartcardServiceReader *reader;
53                 SmartcardServiceSession *session;
54                 SmartcardServiceChannel *channel;
55
56                 ServerGDBus();
57                 ~ServerGDBus();
58
59                 static void name_owner_changed(GDBusProxy *proxy,
60                         const gchar *name, const gchar *old_owner,
61                         const gchar *new_owner, void *user_data);
62
63                 bool initSEService();
64                 void deinitSEService();
65
66                 bool initReader();
67                 void deinitReader();
68
69                 bool initSession();
70                 void deinitSession();
71
72                 bool initChannel();
73                 void deinitChannel();
74         };
75 } /* namespace smartcard_service_api */
76 #endif
77 #endif /* SERVERGDBUS_H_ */