Change for documentation link change
[platform/core/api/mtp.git] / src / mtp_gdbus_deviceinfo.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_deviceinfo.h"
18
19 mtpgdbuslibDeviceinfo *deviceinfo_proxy = NULL;
20
21 void mtp_gdbus_deviceinfo_proxy_init(void)
22 {
23         deviceinfo_proxy = mtp_gdbuslib_deviceinfo_proxy_new_for_bus_sync(
24                 G_BUS_TYPE_SYSTEM,
25                 G_DBUS_PROXY_FLAGS_NONE,
26                 MTP_DBUS_SERVICE,
27                 MTP_DBUS_DEVICEINFO_PATH,
28                 NULL,
29                 NULL);
30 }
31
32 void mtp_gdbus_deviceinfo_proxy_deinit(void)
33 {
34         deviceinfo_proxy = NULL;
35 }
36
37 /* LCOV_EXCL_START */
38 mtp_error_e mtp_gdbus_deviceinfo_get_manufacturer_name(int mtp_device, char **manufacturer_name)
39 {
40         mtp_error_e result = MTP_ERROR_NONE;
41         GError *error = NULL;
42
43         if (deviceinfo_proxy == NULL)
44                         return MTP_ERROR_NOT_COMM_INITIALIZED;
45
46         if (mtp_gdbuslib_deviceinfo_call_get_manufacturer_name_sync(
47                         deviceinfo_proxy,
48                         mtp_device,
49                         manufacturer_name,
50                         &result,
51                         NULL,
52                         &error) == FALSE) {
53                 result = MTP_ERROR_COMM_ERROR;
54                 g_error_free(error);
55         }
56
57         return result;
58 }
59
60 mtp_error_e mtp_gdbus_deviceinfo_get_model_name(int mtp_device, char **model_name)
61 {
62         mtp_error_e result = MTP_ERROR_NONE;
63         GError *error = NULL;
64
65         if (deviceinfo_proxy == NULL)
66                         return MTP_ERROR_NOT_COMM_INITIALIZED;
67
68         if (mtp_gdbuslib_deviceinfo_call_get_model_name_sync(
69                         deviceinfo_proxy,
70                         mtp_device,
71                         model_name,
72                         &result,
73                         NULL,
74                         &error) == FALSE) {
75                 result = MTP_ERROR_COMM_ERROR;
76                 g_error_free(error);
77         }
78
79         return result;
80 }
81
82 mtp_error_e mtp_gdbus_deviceinfo_get_serial_number(int mtp_device, char **serial_number)
83 {
84         mtp_error_e result = MTP_ERROR_NONE;
85         GError *error = NULL;
86
87         if (deviceinfo_proxy == NULL)
88                         return MTP_ERROR_NOT_COMM_INITIALIZED;
89
90         if (mtp_gdbuslib_deviceinfo_call_get_serial_number_sync(
91                         deviceinfo_proxy,
92                         mtp_device,
93                         serial_number,
94                         &result,
95                         NULL,
96                         &error) == FALSE) {
97                 result = MTP_ERROR_COMM_ERROR;
98                 g_error_free(error);
99         }
100
101         return result;
102 }
103
104 mtp_error_e mtp_gdbus_deviceinfo_get_device_version(int mtp_device, char **device_version)
105 {
106         mtp_error_e result = MTP_ERROR_NONE;
107         GError *error = NULL;
108
109         if (deviceinfo_proxy == NULL)
110                         return MTP_ERROR_NOT_COMM_INITIALIZED;
111
112         if (mtp_gdbuslib_deviceinfo_call_get_device_version_sync(
113                         deviceinfo_proxy,
114                         mtp_device,
115                         device_version,
116                         &result,
117                         NULL,
118                         &error) == FALSE) {
119                 result = MTP_ERROR_COMM_ERROR;
120                 g_error_free(error);
121         }
122
123         return result;
124 }
125
126 mtp_error_e mtp_gdbus_deviceinfo_get_bus_location(int mtp_device, int *bus_location)
127 {
128         mtp_error_e result = MTP_ERROR_NONE;
129         GError *error = NULL;
130
131         if (deviceinfo_proxy == NULL)
132                         return MTP_ERROR_NOT_COMM_INITIALIZED;
133
134         if (mtp_gdbuslib_deviceinfo_call_get_bus_location_sync(
135                         deviceinfo_proxy,
136                         mtp_device,
137                         bus_location,
138                         &result,
139                         NULL,
140                         &error) == FALSE) {
141                 result = MTP_ERROR_COMM_ERROR;
142                 g_error_free(error);
143         }
144
145         return result;
146 }
147
148 mtp_error_e mtp_gdbus_deviceinfo_get_device_number(int mtp_device, int *device_number)
149 {
150         mtp_error_e result = MTP_ERROR_NONE;
151         GError *error = NULL;
152
153         if (deviceinfo_proxy == NULL)
154                         return MTP_ERROR_NOT_COMM_INITIALIZED;
155
156         if (mtp_gdbuslib_deviceinfo_call_get_device_number_sync(
157                         deviceinfo_proxy,
158                         mtp_device,
159                         device_number,
160                         &result,
161                         NULL,
162                         &error) == FALSE) {
163                 result = MTP_ERROR_COMM_ERROR;
164                 g_error_free(error);
165         }
166
167         return result;
168 }
169
170 mtp_error_e mtp_gdbus_deviceinfo_get_stitching_engine_version(int mtp_device,
171         char **stitching_engine_version)
172 {
173         mtp_error_e result = MTP_ERROR_NONE;
174         GError *error = NULL;
175
176         if (deviceinfo_proxy == NULL)
177                         return MTP_ERROR_NOT_COMM_INITIALIZED;
178
179         if (mtp_gdbuslib_deviceinfo_call_get_stitching_engine_version_sync(
180                         deviceinfo_proxy,
181                         mtp_device,
182                         stitching_engine_version,
183                         &result,
184                         NULL,
185                         &error) == FALSE) {
186                 result = MTP_ERROR_COMM_ERROR;
187                 g_error_free(error);
188         }
189
190         return result;
191 }
192
193 /* LCOV_EXCL_STOP */
194