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