Adjust AccessProvider api to current security-server.
[platform/core/test/security-tests.git] / tests / common / dbus_access.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Contact: Bumjin Im <bj.im@samsung.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *   http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License
17  */
18 /*
19  * @file        dbus_access.h
20  * @author      Zbigniew Jasinski (z.jasinski@samsung.com)
21  * @version     1.0
22  * @brief       Functions used in security-tests package for restarting Security Server through
23  *              SystemD DBuS interface.
24  */
25 #ifndef _DBUS_ACCESS_H_
26 #define _DBUS_ACCESS_H_
27
28 #include <dbus/dbus.h>
29 #include <dbus-glib.h>
30 #include <glib-object.h>
31
32 #include <string>
33
34 class DBusAccess {
35 public:
36     DBusAccess();
37
38     void restartSS();
39
40     virtual ~DBusAccess();
41 private:
42     void connect();
43     void requestName();
44     void newMethodCall(const std::string& method);
45     void appendToMsg();
46     void sendMsgWithReply();
47     void getMsgReply();
48     void handleMsgRestartReply();
49     void handleMsgRestartSignal();
50     static DBusHandlerResult signalFilter(DBusConnection *, DBusMessage *message, void *);
51
52     void connectToDBus();
53     void sendRestartToSS();
54     void sendResetFailedToSS();
55
56     DBusConnection *m_conn;
57     DBusMessage *m_msg;
58     DBusError m_err;
59     DBusPendingCall *m_pending;
60     std::string m_jobID;
61
62     std::string m_signal_type;
63     std::string m_signal_interface;
64     std::string m_signal_member;
65     std::string m_signal_path;
66
67     std::string m_signal_match;
68
69     std::string m_dbus_client_name;
70
71     bool m_handled;
72 };
73
74 #endif // _DBUS_ACCESS_H_