Change for documentation link change
[platform/core/api/mtp.git] / src / mtp_gdbus_objectinfo.c
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 #include "mtp_gdbus_objectinfo.h"
18
19 mtpgdbuslibObjectinfo *objectinfo_proxy = NULL;
20
21 void mtp_gdbus_objectinfo_proxy_init(void)
22 {
23         objectinfo_proxy = mtp_gdbuslib_objectinfo_proxy_new_for_bus_sync(
24                  G_BUS_TYPE_SYSTEM,
25                  G_DBUS_PROXY_FLAGS_NONE,
26                  MTP_DBUS_SERVICE,
27                  MTP_DBUS_OBJECTINFO_PATH,
28                  NULL,
29                  NULL);
30 }
31
32 void mtp_gdbus_objectinfo_proxy_deinit(void)
33 {
34         objectinfo_proxy = NULL;
35 }
36
37 /* LCOV_EXCL_START */
38 int mtp_gdbus_objectinfo_get_property(int mtp_device,
39         int object_handle, int property, int *property_value)
40 {
41         mtp_error_e result = MTP_ERROR_NONE;
42         GError *error = NULL;
43
44         if (objectinfo_proxy == NULL)
45                         return MTP_ERROR_NOT_COMM_INITIALIZED;
46
47         if (mtp_gdbuslib_objectinfo_call_get_property_sync(
48                         objectinfo_proxy,
49                         mtp_device,
50                         object_handle,
51                         property,
52                         property_value,
53                         &result,
54                         NULL,
55                         &error) == FALSE) {
56                 result = MTP_ERROR_COMM_ERROR;
57                 g_error_free(error);
58         }
59
60         return result;
61 }
62
63 int mtp_gdbus_objectinfo_get_property_string(int mtp_device,
64         int object_handle, int property, char **property_value)
65 {
66         mtp_error_e result = MTP_ERROR_NONE;
67         GError *error = NULL;
68
69         if (objectinfo_proxy == NULL)
70                         return MTP_ERROR_NOT_COMM_INITIALIZED;
71
72         if (mtp_gdbuslib_objectinfo_call_get_property_string_sync(
73                         objectinfo_proxy,
74                         mtp_device,
75                         object_handle,
76                         property,
77                         property_value,
78                         &result,
79                         NULL,
80                         &error) == FALSE) {
81                 result = MTP_ERROR_COMM_ERROR;
82                 g_error_free(error);
83         }
84
85         return result;
86 }
87 /* LCOV_EXCL_STOP */
88