Apply ACR comment
[platform/core/api/mtp.git] / src / mtp.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 <stdio.h>
18 #include <unistd.h>
19 #include <glib.h>
20 #include <gio/gio.h>
21 #include <stdlib.h>
22
23 #include <dlog.h>
24
25 #include "mtp.h"
26 #include "mtp_internal.h"
27 #include "mtp_db.h"
28 #include "mtp_debug.h"
29 #include "mtp_private.h"
30
31 #include "mtp_gdbus_manager.h"
32 #include "mtp_gdbus_deviceinfo.h"
33 #include "mtp_gdbus_storageinfo.h"
34 #include "mtp_gdbus_objectinfo.h"
35
36 #define MTP_LOCK \
37 do { \
38         pthread_mutex_lock(&mutex); \
39 } while (0);
40
41 #define MTP_UNLOCK \
42 do { \
43         pthread_mutex_unlock(&mutex); \
44 } while (0);
45
46 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
47
48 #define CHECK_INIT() \
49 do { \
50         MTP_LOCK; \
51                 { \
52                         if (__is_initialized == false) { \
53                                 MTP_UNLOCK; \
54                                 return MTP_ERROR_NOT_INITIALIZED; \
55                         } \
56                 } \
57         MTP_UNLOCK; \
58 } while (0);
59
60 int ref_count = 0;
61 bool __is_initialized = false;
62
63 static bool __is_mtp_supported()
64 {
65         return true;
66 }
67
68 static bool __is_mtp_activated()
69 {
70         return true;
71 }
72
73 /* Device Manager */
74 int mtp_initialize(void)
75 {
76         int ret = MTP_ERROR_NONE;
77
78         _BEGIN();
79
80         /* precondition check start */
81
82         CHECK_SUPPORTED();
83
84         /* precondition check end */
85
86         MTP_LOCK;
87
88         if (__is_initialized == false) {
89                 ret = mtp_gdbus_manager_initialize();
90                 mtp_db_init();
91                 __is_initialized = true;
92         }
93         ref_count++;
94
95         MTP_UNLOCK;
96
97         _END();
98
99         return ret;
100 }
101
102 int mtp_get_raw_devices(mtp_raw_device_h **raw_devices, int *device_count)
103 {
104         int ret = MTP_ERROR_NONE;
105
106         _BEGIN();
107
108         /* precondition check start */
109
110         CHECK_SUPPORTED();
111         CHECK_INIT();
112         CHECK_ACTIVATED();
113         cond_expr_ret(device_count == NULL, MTP_ERROR_INVALID_PARAMETER);
114
115         /* precondition check end */
116         *device_count = 0;
117
118         ret = mtp_gdbus_manager_get_raw_devices((mtp_raw_device ***)raw_devices, device_count);
119
120         _END();
121
122         return ret;
123 }
124
125 int mtp_get_bus_location(mtp_raw_device_h raw_device, int *bus_location)
126 {
127         int ret = MTP_ERROR_NONE;
128
129         _BEGIN();
130
131         /* precondition check start */
132
133         CHECK_SUPPORTED();
134         CHECK_INIT();
135         cond_expr_ret(raw_device == NULL, MTP_ERROR_INVALID_PARAMETER);
136         cond_expr_ret(bus_location == NULL, MTP_ERROR_INVALID_PARAMETER);
137
138         /* precondition check end */
139
140         *bus_location = ((mtp_raw_device *)raw_device)->bus_location;
141
142         _END();
143
144         return ret;
145 }
146
147 int mtp_get_device_number(mtp_raw_device_h raw_device, int *device_number)
148 {
149         int ret = MTP_ERROR_NONE;
150
151         _BEGIN();
152
153         /* precondition check start */
154
155         CHECK_SUPPORTED();
156         CHECK_INIT();
157         cond_expr_ret(raw_device == NULL, MTP_ERROR_INVALID_PARAMETER);
158         cond_expr_ret(device_number == NULL, MTP_ERROR_INVALID_PARAMETER);
159
160         /* precondition check end */
161
162         *device_number = ((mtp_raw_device *)raw_device)->device_number;
163
164         _END();
165
166         return ret;
167 }
168
169 int mtp_get_device_name(mtp_raw_device_h raw_device, char **model_name)
170 {
171         int ret = MTP_ERROR_NONE;
172
173         /* precondition check start */
174
175         CHECK_SUPPORTED();
176         CHECK_INIT();
177         cond_expr_ret(raw_device == NULL, MTP_ERROR_INVALID_PARAMETER);
178         cond_expr_ret(model_name == NULL, MTP_ERROR_INVALID_PARAMETER);
179
180         /* precondition check end */
181
182         *model_name = g_strdup(((mtp_raw_device *)raw_device)->model_name);
183
184         return ret;
185 }
186
187 int mtp_destroy_raw_devices(mtp_raw_device_h *raw_devices)
188 {
189         int i;
190         int ret = MTP_ERROR_NONE;
191         int dev_count;
192         mtp_raw_device *first_device = (mtp_raw_device *)raw_devices[0];
193
194         _BEGIN();
195
196         /* precondition check start */
197
198         CHECK_SUPPORTED();
199         cond_expr_ret(raw_devices == NULL, MTP_ERROR_INVALID_PARAMETER);
200         cond_expr_ret(first_device == NULL, MTP_ERROR_INVALID_PARAMETER);
201
202         /* precondition check end */
203         dev_count = first_device->dev_count;
204         if (dev_count <= 0 || dev_count > 6)
205                 return MTP_ERROR_INVALID_PARAMETER;
206
207         for (i = 0; i < dev_count; i++) {
208                 mtp_raw_device *r_device = (mtp_raw_device *)raw_devices[i];
209
210                 if (r_device != NULL && r_device->model_name != NULL) {
211                         free(r_device->model_name);
212                         free(r_device);
213                 }
214         }
215
216         free(raw_devices);
217
218         _END();
219
220         return ret;
221 }
222
223 int mtp_get_device(int bus_location, int device_number, int *mtp_device)
224 {
225         int ret = MTP_ERROR_NONE;
226
227         _BEGIN();
228
229         /* precondition check start */
230
231         CHECK_SUPPORTED();
232         CHECK_INIT();
233         CHECK_ACTIVATED();
234         cond_expr_ret(bus_location == 0, MTP_ERROR_INVALID_PARAMETER);
235
236         /* precondition check end */
237
238         ret = mtp_gdbus_manager_get_device(bus_location, device_number, mtp_device);
239
240         TC_PRT("mtp_device %d", *mtp_device);
241
242         _END();
243
244         return ret;
245 }
246
247 int mtp_get_storages(int mtp_device, int **mtp_storages, int* storage_num)
248 {
249         int ret = MTP_ERROR_NONE;
250
251         _BEGIN();
252
253         /* precondition check start */
254
255         CHECK_SUPPORTED();
256         CHECK_INIT();
257         CHECK_ACTIVATED();
258         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
259
260         /* precondition check end */
261
262         ret = mtp_gdbus_manager_get_storages(mtp_device, mtp_storages, storage_num);
263
264         TC_PRT("storage number %d", *storage_num);
265
266         _END();
267
268         return ret;
269 }
270
271 int mtp_get_object_handles(int mtp_device, int mtp_storage, mtp_filetype_e file_type,
272         int parent, int **object_handles, int* object_num)
273 {
274         int ret = MTP_ERROR_NONE;
275
276         _BEGIN();
277
278         /* precondition check start */
279
280         CHECK_SUPPORTED();
281         CHECK_INIT();
282         CHECK_ACTIVATED();
283         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
284         cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER);
285
286         /* precondition check end */
287
288         ret = mtp_gdbus_manager_get_object_handles(mtp_device,
289                 mtp_storage, file_type, parent, object_handles, object_num);
290
291         _END();
292
293         return ret;
294 }
295
296 int mtp_delete_object(int mtp_device, int object_handle)
297 {
298         int ret = MTP_ERROR_NONE;
299
300         _BEGIN();
301
302         /* precondition check start */
303
304         CHECK_SUPPORTED();
305         CHECK_INIT();
306         CHECK_ACTIVATED();
307         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
308         cond_expr_ret(object_handle == 0, MTP_ERROR_INVALID_PARAMETER);
309
310         /* precondition check end */
311
312         ret = mtp_gdbus_manager_delete_object(mtp_device, object_handle);
313
314         _END();
315
316         return ret;
317 }
318
319 int mtp_get_object(int mtp_device, int object_handle, char *dest_path)
320 {
321         int ret = MTP_ERROR_NONE;
322
323         _BEGIN();
324
325         /* precondition check start */
326
327         CHECK_SUPPORTED();
328         CHECK_INIT();
329         CHECK_ACTIVATED();
330         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
331         cond_expr_ret(dest_path == NULL, MTP_ERROR_INVALID_PARAMETER);
332
333         /* precondition check end */
334
335         ret = mtp_gdbus_manager_get_object(mtp_device, object_handle, dest_path);
336
337         _END();
338
339         return ret;
340 }
341
342 int mtp_get_thumbnail(int mtp_device, int object_handle, char *dest_path)
343 {
344         int ret = MTP_ERROR_NONE;
345
346         _BEGIN();
347
348         /* precondition check start */
349
350         CHECK_SUPPORTED();
351         CHECK_INIT();
352         CHECK_ACTIVATED();
353         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
354         cond_expr_ret(dest_path == NULL, MTP_ERROR_INVALID_PARAMETER);
355
356         /* precondition check end */
357
358         ret = mtp_gdbus_manager_get_thumbnail(mtp_device, object_handle, dest_path);
359
360         _END();
361
362         return ret;
363 }
364
365 int mtp_set_mtp_event_cb(mtp_event_cb callback, void *user_data)
366 {
367         int ret = MTP_ERROR_NONE;
368
369         _BEGIN();
370
371         /* precondition check start */
372
373         CHECK_SUPPORTED();
374         CHECK_INIT();
375         cond_expr_ret(callback == NULL, MTP_ERROR_INVALID_PARAMETER);
376
377         /* precondition check end */
378
379         ret = mtp_gdbus_manager_set_event_cb(callback, user_data);
380
381         _END();
382
383         return ret;
384 }
385
386 int mtp_unset_mtp_event_cb(void)
387 {
388         int ret = MTP_ERROR_NONE;
389
390         _BEGIN();
391
392         /* precondition check start */
393
394         CHECK_SUPPORTED();
395         CHECK_INIT();
396
397         /* precondition check end */
398
399         ret = mtp_gdbus_manager_unset_event_cb();
400
401         _END();
402
403         return ret;
404 }
405
406 int mtp_deinitialize(void)
407 {
408         int ret = MTP_ERROR_NONE;
409
410         _BEGIN();
411
412         /* precondition check start */
413
414         CHECK_SUPPORTED();
415
416         /* precondition check end */
417
418         MTP_LOCK;
419
420         if (ref_count > 0)
421                 ref_count--;
422
423         if (__is_initialized == true && ref_count == 0) {
424                 mtp_db_deinit();
425                 ret = mtp_gdbus_manager_deinitialize();
426                 __is_initialized = false;
427         }
428
429         MTP_UNLOCK;
430
431         _END();
432
433         return ret;
434 }
435
436 /* Device Info */
437 int mtp_deviceinfo_get_manufacturer_name(int mtp_device, char **manufacturer_name)
438 {
439         int ret = MTP_ERROR_NONE;
440
441         _BEGIN();
442
443         /* precondition check start */
444
445         CHECK_SUPPORTED();
446         CHECK_INIT();
447         CHECK_ACTIVATED();
448         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
449
450         /* precondition check end */
451
452         ret = mtp_gdbus_deviceinfo_get_manufacturername(mtp_device, manufacturer_name);
453
454         TC_PRT("manufacturername %s", *manufacturer_name);
455
456         _END();
457
458         return ret;
459 }
460
461 int mtp_deviceinfo_get_model_name(int mtp_device, char **model_name)
462 {
463         int ret = MTP_ERROR_NONE;
464
465         _BEGIN();
466
467         /* precondition check start */
468
469         CHECK_SUPPORTED();
470         CHECK_INIT();
471         CHECK_ACTIVATED();
472         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
473
474         /* precondition check end */
475
476         ret = mtp_gdbus_deviceinfo_get_modelname(mtp_device, model_name);
477
478         TC_PRT("modelname %s", *model_name);
479
480         _END();
481
482         return ret;
483 }
484
485 int mtp_deviceinfo_get_serial_number(int mtp_device, char **serial_number)
486 {
487         int ret = MTP_ERROR_NONE;
488
489         _BEGIN();
490
491         /* precondition check start */
492
493         CHECK_SUPPORTED();
494         CHECK_INIT();
495         CHECK_ACTIVATED();
496         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
497
498         /* precondition check end */
499
500         ret = mtp_gdbus_deviceinfo_get_serialnumber(mtp_device, serial_number);
501
502         TC_PRT("serialnumber %s", *serial_number);
503
504         _END();
505
506         return ret;
507 }
508
509 int mtp_deviceinfo_get_device_version(int mtp_device, char **device_version)
510 {
511         int ret = MTP_ERROR_NONE;
512
513         _BEGIN();
514
515         /* precondition check start */
516
517         CHECK_SUPPORTED();
518         CHECK_INIT();
519         CHECK_ACTIVATED();
520         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
521
522         /* precondition check end */
523
524         ret = mtp_gdbus_deviceinfo_get_deviceversion(mtp_device, device_version);
525
526         TC_PRT("deviceversion %s", *device_version);
527
528         _END();
529
530         return ret;
531 }
532
533 /* Storage Info */
534 int mtp_storageinfo_get_description(int mtp_device, int mtp_storage, char **description)
535 {
536         int ret = MTP_ERROR_NONE;
537
538         _BEGIN();
539
540         /* precondition check start */
541
542         CHECK_SUPPORTED();
543         CHECK_INIT();
544         CHECK_ACTIVATED();
545         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
546         cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER);
547
548         /* precondition check end */
549
550         ret = mtp_gdbus_storageinfo_get_description(mtp_device, mtp_storage, description);
551
552         TC_PRT("description %s", *description);
553
554         _END();
555
556         return ret;
557 }
558
559 int mtp_storageinfo_get_free_space(int mtp_device, int mtp_storage, unsigned long long *free_space)
560 {
561         int ret = MTP_ERROR_NONE;
562
563         _BEGIN();
564
565         /* precondition check start */
566
567         CHECK_SUPPORTED();
568         CHECK_INIT();
569         CHECK_ACTIVATED();
570         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
571         cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER);
572
573         /* precondition check end */
574
575         ret = mtp_gdbus_storageinfo_get_freespace(mtp_device, mtp_storage, (guint64 *)free_space);
576
577         TC_PRT("freespace %llu", *free_space);
578
579         _END();
580
581         return ret;
582 }
583
584 int mtp_storageinfo_get_max_capacity(int mtp_device, int mtp_storage, unsigned long long *max_capacity)
585 {
586         int ret = MTP_ERROR_NONE;
587
588         _BEGIN();
589
590         /* precondition check start */
591
592         CHECK_SUPPORTED();
593         CHECK_INIT();
594         CHECK_ACTIVATED();
595         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
596         cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER);
597
598         /* precondition check end */
599
600         ret = mtp_gdbus_storageinfo_get_maxcapacity(mtp_device, mtp_storage, (guint64 *)max_capacity);
601
602         TC_PRT("maxcapacity %llu", *max_capacity);
603
604         _END();
605
606         return ret;
607 }
608
609 int mtp_storageinfo_get_storage_type(int mtp_device, int mtp_storage, mtp_storage_type_e *storage_type)
610 {
611         int ret = MTP_ERROR_NONE;
612
613         _BEGIN();
614
615         /* precondition check start */
616
617         CHECK_SUPPORTED();
618         CHECK_INIT();
619         CHECK_ACTIVATED();
620         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
621         cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER);
622
623         /* precondition check end */
624
625         ret = mtp_gdbus_storageinfo_get_storagetype(mtp_device, mtp_storage, (int *)storage_type);
626
627         TC_PRT("storagetype %d", *storage_type);
628
629         _END();
630
631         return ret;
632 }
633
634 int mtp_storageinfo_get_volume_identifier(int mtp_device, int mtp_storage, char **volume_identifier)
635 {
636         int ret = MTP_ERROR_NONE;
637
638         _BEGIN();
639
640         /* precondition check start */
641
642         CHECK_SUPPORTED();
643         CHECK_INIT();
644         CHECK_ACTIVATED();
645         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
646         cond_expr_ret(mtp_storage == 0, MTP_ERROR_INVALID_PARAMETER);
647
648         /* precondition check end */
649
650         ret = mtp_gdbus_storageinfo_get_volumeidentifier(mtp_device, mtp_storage, volume_identifier);
651
652         TC_PRT("volumeidentifier %s", *volume_identifier);
653
654         _END();
655
656         return ret;
657 }
658
659 /* Object Info */
660 int mtp_objectinfo_get_parent_object_handle(int mtp_device, int object_handle,
661         int *parent_object_handle)
662 {
663         int ret = MTP_ERROR_NONE;
664
665         _BEGIN();
666
667         /* precondition check start */
668
669         CHECK_SUPPORTED();
670         CHECK_INIT();
671         CHECK_ACTIVATED();
672         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
673
674         /* precondition check end */
675
676         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
677                 object_handle, MTP_PROPERTY_PARENT_OBJECT_HANDLE, parent_object_handle);
678
679         TC_PRT("parent object id %d", *parent_object_handle);
680
681         _END();
682
683         return ret;
684 }
685
686 int mtp_objectinfo_get_storage(int mtp_device, int object_handle,
687         int *mtp_storage)
688 {
689         int ret = MTP_ERROR_NONE;
690
691         _BEGIN();
692
693         /* precondition check start */
694
695         CHECK_SUPPORTED();
696         CHECK_INIT();
697         CHECK_ACTIVATED();
698         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
699
700         /* precondition check end */
701
702         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
703                 object_handle, MTP_PROPERTY_STORAGE, mtp_storage);
704
705         _END();
706
707         return ret;
708 }
709
710 int mtp_objectinfo_get_association_desc(int mtp_device,
711         int object_handle, int *asso_desc)
712 {
713         int ret = MTP_ERROR_NONE;
714
715         _BEGIN();
716
717         /* precondition check start */
718
719         CHECK_SUPPORTED();
720         CHECK_INIT();
721         CHECK_ACTIVATED();
722         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
723
724         /* precondition check end */
725
726         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
727                 object_handle, MTP_PROPERTY_ASSOCIATION_DESC, asso_desc);
728
729         _END();
730
731         return ret;
732 }
733
734 int mtp_objectinfo_get_association_type(int mtp_device,
735         int object_handle, int *asso_type)
736 {
737         int ret = MTP_ERROR_NONE;
738
739         _BEGIN();
740
741         /* precondition check start */
742
743         CHECK_SUPPORTED();
744         CHECK_INIT();
745         CHECK_ACTIVATED();
746         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
747
748         /* precondition check end */
749
750         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
751                 object_handle, MTP_PROPERTY_ASSOCIATION_TYPE, asso_type);
752
753         _END();
754
755         return ret;
756 }
757
758 int mtp_objectinfo_get_size(int mtp_device, int object_handle, int *size)
759 {
760         int ret = MTP_ERROR_NONE;
761
762         _BEGIN();
763
764         /* precondition check start */
765
766         CHECK_SUPPORTED();
767         CHECK_INIT();
768         CHECK_ACTIVATED();
769         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
770
771         /* precondition check end */
772
773         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
774                 object_handle, MTP_PROPERTY_SIZE, size);
775
776         _END();
777
778         return ret;
779 }
780
781 int mtp_objectinfo_get_date_created(int mtp_device,
782         int object_handle, int *data_created)
783 {
784         int ret = MTP_ERROR_NONE;
785
786         _BEGIN();
787
788         /* precondition check start */
789
790         CHECK_SUPPORTED();
791         CHECK_INIT();
792         CHECK_ACTIVATED();
793         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
794
795         /* precondition check end */
796
797         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
798                 object_handle, MTP_PROPERTY_DATE_CREATED, data_created);
799
800         _END();
801
802         return ret;
803 }
804
805 int mtp_objectinfo_get_date_modified(int mtp_device,
806         int object_handle, int *data_modified)
807 {
808         int ret = MTP_ERROR_NONE;
809
810         _BEGIN();
811
812         /* precondition check start */
813
814         CHECK_SUPPORTED();
815         CHECK_INIT();
816         CHECK_ACTIVATED();
817         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
818
819         /* precondition check end */
820
821         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
822                 object_handle, MTP_PROPERTY_DATE_MODIFIED, data_modified);
823
824         _END();
825
826         return ret;
827 }
828
829 int mtp_objectinfo_get_file_type(int mtp_device, int object_handle, mtp_filetype_e *file_type)
830 {
831         int ret = MTP_ERROR_NONE;
832
833         _BEGIN();
834
835         /* precondition check start */
836
837         CHECK_SUPPORTED();
838         CHECK_INIT();
839         CHECK_ACTIVATED();
840         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
841
842         /* precondition check end */
843
844         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
845                 object_handle, MTP_PROPERTY_FORMAT, (int*)file_type);
846
847         _END();
848
849         return ret;
850 }
851
852 int mtp_objectinfo_get_image_bit_depth(int mtp_device,
853         int object_handle, int *depth)
854 {
855         int ret = MTP_ERROR_NONE;
856
857         _BEGIN();
858
859         /* precondition check start */
860
861         CHECK_SUPPORTED();
862         CHECK_INIT();
863         CHECK_ACTIVATED();
864         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
865
866         /* precondition check end */
867
868         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
869                 object_handle, MTP_PROPERTY_IMAGE_BIT_DEPTH, depth);
870
871         _END();
872
873         return ret;
874 }
875
876 int mtp_objectinfo_get_image_pix_width(int mtp_device,
877         int object_handle, int *width)
878 {
879         int ret = MTP_ERROR_NONE;
880
881         _BEGIN();
882
883         /* precondition check start */
884
885         CHECK_SUPPORTED();
886         CHECK_INIT();
887         CHECK_ACTIVATED();
888         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
889
890         /* precondition check end */
891
892         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
893                 object_handle, MTP_PROPERTY_IMAGE_PIX_WIDTH, width);
894
895         _END();
896
897         return ret;
898 }
899
900 int mtp_objectinfo_get_image_pix_height(int mtp_device,
901         int object_handle, int *height)
902 {
903         int ret = MTP_ERROR_NONE;
904
905         _BEGIN();
906
907         /* precondition check start */
908
909         CHECK_SUPPORTED();
910         CHECK_INIT();
911         CHECK_ACTIVATED();
912         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
913
914         /* precondition check end */
915
916         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
917                 object_handle, MTP_PROPERTY_IMAGE_PIX_HEIGHT, height);
918
919         _END();
920
921         return ret;
922 }
923
924 int mtp_objectinfo_get_thumbnail_size(int mtp_device,
925         int object_handle, int *size)
926 {
927         int ret = MTP_ERROR_NONE;
928
929         _BEGIN();
930
931         /* precondition check start */
932
933         CHECK_SUPPORTED();
934         CHECK_INIT();
935         CHECK_ACTIVATED();
936         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
937
938         /* precondition check end */
939
940         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
941                 object_handle, MTP_PROPERTY_THUMBNAIL_SIZE, size);
942
943         _END();
944
945         return ret;
946 }
947
948 int mtp_objectinfo_get_thumbnail_file_type(int mtp_device,
949         int object_handle, mtp_filetype_e *file_type)
950 {
951         int ret = MTP_ERROR_NONE;
952
953         _BEGIN();
954
955         /* precondition check start */
956
957         CHECK_SUPPORTED();
958         CHECK_INIT();
959         CHECK_ACTIVATED();
960         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
961
962         /* precondition check end */
963
964         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
965                 object_handle, MTP_PROPERTY_THUMBNAIL_FORMAT, (int*)file_type);
966
967         _END();
968
969         return ret;
970 }
971
972 int mtp_objectinfo_get_thumbnail_pix_height(int mtp_device,
973         int object_handle, int *height)
974 {
975         int ret = MTP_ERROR_NONE;
976
977         _BEGIN();
978
979         /* precondition check start */
980
981         CHECK_SUPPORTED();
982         CHECK_INIT();
983         CHECK_ACTIVATED();
984         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
985
986         /* precondition check end */
987
988         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
989                 object_handle, MTP_PROPERTY_THUMBNAIL_HEIGHT, height);
990
991         _END();
992
993         return ret;
994 }
995
996 int mtp_objectinfo_get_thumbnail_pix_width(int mtp_device,
997         int object_handle, int *width)
998 {
999         int ret = MTP_ERROR_NONE;
1000
1001         _BEGIN();
1002
1003         /* precondition check start */
1004
1005         CHECK_SUPPORTED();
1006         CHECK_INIT();
1007         CHECK_ACTIVATED();
1008         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
1009
1010         /* precondition check end */
1011
1012         ret = mtp_gdbus_objectinfo_get_property(mtp_device,
1013                 object_handle, MTP_PROPERTY_THUMBNAIL_WIDTH, width);
1014
1015         _END();
1016
1017         return ret;
1018 }
1019
1020 int mtp_objectinfo_get_file_name(int mtp_device,
1021         int object_handle, char **filename)
1022 {
1023         int ret = MTP_ERROR_NONE;
1024
1025         _BEGIN();
1026
1027         /* precondition check start */
1028
1029         CHECK_SUPPORTED();
1030         CHECK_INIT();
1031         CHECK_ACTIVATED();
1032         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
1033
1034         /* precondition check end */
1035
1036         ret = mtp_gdbus_objectinfo_get_property_string(mtp_device,
1037                 object_handle, MTP_PROPERTY_FILENAME, filename);
1038
1039         _END();
1040
1041         return ret;
1042 }
1043
1044 int mtp_objectinfo_get_keywords(int mtp_device,
1045         int object_handle, char **keywords)
1046 {
1047         int ret = MTP_ERROR_NONE;
1048
1049         _BEGIN();
1050
1051         /* precondition check start */
1052
1053         CHECK_SUPPORTED();
1054         CHECK_INIT();
1055         CHECK_ACTIVATED();
1056         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
1057
1058         /* precondition check end */
1059
1060         ret = mtp_gdbus_objectinfo_get_property_string(mtp_device,
1061                 object_handle, MTP_PROPERTY_KEYWORDS, keywords);
1062
1063         _END();
1064
1065         return ret;
1066 }
1067
1068 int mtp_objectinfo_get_object_info(int mtp_device,
1069         int object_handle, mtp_object_info **object_info)
1070 {
1071         int ret = MTP_ERROR_NONE;
1072
1073         _BEGIN();
1074
1075         /* precondition check start */
1076
1077         CHECK_SUPPORTED();
1078         CHECK_INIT();
1079         CHECK_ACTIVATED();
1080         cond_expr_ret(mtp_device == 0, MTP_ERROR_INVALID_PARAMETER);
1081
1082         /* precondition check end */
1083
1084         ret = mtp_db_get_object_info(mtp_device, object_handle, object_info);
1085
1086         _END();
1087
1088         return ret;
1089 }
1090