diff options
author | Minje Ahn <minje.ahn@samsung.com> | 2017-03-07 09:43:21 +0900 |
---|---|---|
committer | Minje Ahn <minje.ahn@samsung.com> | 2017-03-07 09:50:32 +0900 |
commit | cfd82c3c710d8b72699d2943bfc29a436020fa0e (patch) | |
tree | acf34b800694c61f295a7a76a95526ebc5bf9e48 | |
parent | c80a950bbc7b889d491664d7cc48e39d848ea282 (diff) | |
download | media-content-cfd82c3c710d8b72699d2943bfc29a436020fa0e.tar.gz media-content-cfd82c3c710d8b72699d2943bfc29a436020fa0e.tar.bz2 media-content-cfd82c3c710d8b72699d2943bfc29a436020fa0e.zip |
Refactoring error handling related code
This is a pre-work for package improvement
Change-Id: I1b2a1502abdcade5df45ae30da311a4121499e52
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
32 files changed, 1109 insertions, 1945 deletions
diff --git a/Tizen.Content.MediaContent/Interop/Interop.AudioInformation.cs b/Tizen.Content.MediaContent/Interop/Interop.AudioInformation.cs index 3d8cfc6..b3ea641 100755 --- a/Tizen.Content.MediaContent/Interop/Interop.AudioInformation.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.AudioInformation.cs @@ -16,76 +16,76 @@ internal static partial class Interop internal static partial class AudioInformation { [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_destroy", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Destroy(IntPtr media); + internal static extern MediaContentError Destroy(IntPtr media); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_clone", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Clone(out SafeAudioInformationHandle dst, SafeAudioInformationHandle src); + internal static extern MediaContentError Clone(out SafeAudioInformationHandle dst, SafeAudioInformationHandle src); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_media_id", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetMediaId(SafeAudioInformationHandle audioInformationHandle, out string mediaId); + internal static extern MediaContentError GetMediaId(SafeAudioInformationHandle audioInformationHandle, out string mediaId); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_album", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAlbum(SafeAudioInformationHandle audioInformationHandle, out string albumName); + internal static extern MediaContentError GetAlbum(SafeAudioInformationHandle audioInformationHandle, out string albumName); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_artist", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetArtist(SafeAudioInformationHandle audioInformationHandle, out string artistName); + internal static extern MediaContentError GetArtist(SafeAudioInformationHandle audioInformationHandle, out string artistName); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_album_artist", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAlbumArtist(SafeAudioInformationHandle audioInformationHandle, out string albumArtistName); + internal static extern MediaContentError GetAlbumArtist(SafeAudioInformationHandle audioInformationHandle, out string albumArtistName); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_genre", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetGenre(SafeAudioInformationHandle audioInformationHandle, out string genreName); + internal static extern MediaContentError GetGenre(SafeAudioInformationHandle audioInformationHandle, out string genreName); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_composer", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetComposer(SafeAudioInformationHandle audioInformationHandle, out string composerName); + internal static extern MediaContentError GetComposer(SafeAudioInformationHandle audioInformationHandle, out string composerName); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_year", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetYear(SafeAudioInformationHandle audioInformationHandle, out string year); + internal static extern MediaContentError GetYear(SafeAudioInformationHandle audioInformationHandle, out string year); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_recorded_date", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetRecordedDate(SafeAudioInformationHandle audioInformationHandle, out string recordedDate); + internal static extern MediaContentError GetRecordedDate(SafeAudioInformationHandle audioInformationHandle, out string recordedDate); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_copyright", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetCopyright(SafeAudioInformationHandle audioInformationHandle, out string copyright); + internal static extern MediaContentError GetCopyright(SafeAudioInformationHandle audioInformationHandle, out string copyright); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_track_num", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetTrackNum(SafeAudioInformationHandle audioInformationHandle, out string trackNum); + internal static extern MediaContentError GetTrackNum(SafeAudioInformationHandle audioInformationHandle, out string trackNum); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_bit_rate", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetBitRate(SafeAudioInformationHandle audioInformationHandle, out int bitRate); + internal static extern MediaContentError GetBitRate(SafeAudioInformationHandle audioInformationHandle, out int bitRate); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_bitpersample", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetBitPerSample(SafeAudioInformationHandle audioInformationHandle, out int bitPerSample); + internal static extern MediaContentError GetBitPerSample(SafeAudioInformationHandle audioInformationHandle, out int bitPerSample); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_sample_rate", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetSampleRate(SafeAudioInformationHandle audioInformationHandle, out int sampleRate); + internal static extern MediaContentError GetSampleRate(SafeAudioInformationHandle audioInformationHandle, out int sampleRate); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_channel", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetChannel(SafeAudioInformationHandle audioInformationHandle, out int channel); + internal static extern MediaContentError GetChannel(SafeAudioInformationHandle audioInformationHandle, out int channel); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_duration", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetDuration(SafeAudioInformationHandle audioInformationHandle, out int duration); + internal static extern MediaContentError GetDuration(SafeAudioInformationHandle audioInformationHandle, out int duration); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_played_count", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetPlayedCount(SafeAudioInformationHandle audioInformationHandle, out int playedCount); + internal static extern MediaContentError GetPlayedCount(SafeAudioInformationHandle audioInformationHandle, out int playedCount); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_played_time", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetPlayedTime(SafeAudioInformationHandle audioInformationHandle, out int playedTime); + internal static extern MediaContentError GetPlayedTime(SafeAudioInformationHandle audioInformationHandle, out int playedTime); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_played_position", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetPlayedPosition(SafeAudioInformationHandle audioInformationHandle, out int playedPosition); + internal static extern MediaContentError GetPlayedPosition(SafeAudioInformationHandle audioInformationHandle, out int playedPosition); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_set_played_count", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetPlayedCount(SafeAudioInformationHandle audioInformationHandle, int playedCount); + internal static extern MediaContentError SetPlayedCount(SafeAudioInformationHandle audioInformationHandle, int playedCount); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_set_played_time", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetPlayedTime(SafeAudioInformationHandle audioInformationHandle, int playedTime); + internal static extern MediaContentError SetPlayedTime(SafeAudioInformationHandle audioInformationHandle, int playedTime); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_set_played_position", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetPlayedPosition(SafeAudioInformationHandle audioInformationHandle, int playedPosition); + internal static extern MediaContentError SetPlayedPosition(SafeAudioInformationHandle audioInformationHandle, int playedPosition); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_update_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int UpdateToDB(IntPtr audioInformationHandle); + internal static extern MediaContentError UpdateToDB(IntPtr audioInformationHandle); internal sealed class SafeAudioInformationHandle : SafeHandle { diff --git a/Tizen.Content.MediaContent/Interop/Interop.ImageInformation.cs b/Tizen.Content.MediaContent/Interop/Interop.ImageInformation.cs index 1b55590..3dd5c53 100755 --- a/Tizen.Content.MediaContent/Interop/Interop.ImageInformation.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.ImageInformation.cs @@ -16,49 +16,49 @@ internal static partial class Interop internal static partial class ImageInformation { [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_destroy", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Destroy(IntPtr media); + internal static extern MediaContentError Destroy(IntPtr media); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_clone", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Clone(out SafeImageInformationHandle dst, SafeImageInformationHandle src); + internal static extern MediaContentError Clone(out SafeImageInformationHandle dst, SafeImageInformationHandle src); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_orientation", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetOrientation(SafeImageInformationHandle imageInformationHandle, out MediaContentOrientation orientation); + internal static extern MediaContentError GetOrientation(SafeImageInformationHandle imageInformationHandle, out MediaContentOrientation orientation); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_date_taken", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetDateTaken(SafeImageInformationHandle imageInformationHandle, out string dateTaken); + internal static extern MediaContentError GetDateTaken(SafeImageInformationHandle imageInformationHandle, out string dateTaken); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_burst_id", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetBurstId(SafeImageInformationHandle imageInformationHandle, out string burstId); + internal static extern MediaContentError GetBurstId(SafeImageInformationHandle imageInformationHandle, out string burstId); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_exposure_time", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExposureTime(SafeImageInformationHandle imageInformationHandle, out string exposureTime); + internal static extern MediaContentError GetExposureTime(SafeImageInformationHandle imageInformationHandle, out string exposureTime); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_fnumber", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetFNumber(SafeImageInformationHandle imageInformationHandle, out double fNumber); + internal static extern MediaContentError GetFNumber(SafeImageInformationHandle imageInformationHandle, out double fNumber); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_iso", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetISO(SafeImageInformationHandle imageInformationHandle, out int iso); + internal static extern MediaContentError GetISO(SafeImageInformationHandle imageInformationHandle, out int iso); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_model", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetModel(SafeImageInformationHandle imageInformationHandle, out string model); + internal static extern MediaContentError GetModel(SafeImageInformationHandle imageInformationHandle, out string model); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_is_burst_shot", CallingConvention = CallingConvention.Cdecl)] - internal static extern int IsBurstShot(SafeImageInformationHandle imageInformationHandle, out bool isBurstShot); + internal static extern MediaContentError IsBurstShot(SafeImageInformationHandle imageInformationHandle, out bool isBurstShot); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_set_orientation", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetOrientation(SafeImageInformationHandle imageInformationHandle, MediaContentOrientation orientation); + internal static extern MediaContentError SetOrientation(SafeImageInformationHandle imageInformationHandle, MediaContentOrientation orientation); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_media_id", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetMediaId(SafeImageInformationHandle imageInformationHandle, out string mediaId); + internal static extern MediaContentError GetMediaId(SafeImageInformationHandle imageInformationHandle, out string mediaId); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_width", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetWidth(SafeImageInformationHandle imageInformationHandle, out int width); + internal static extern MediaContentError GetWidth(SafeImageInformationHandle imageInformationHandle, out int width); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_height", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetHeight(SafeImageInformationHandle imageInformationHandle, out int width); + internal static extern MediaContentError GetHeight(SafeImageInformationHandle imageInformationHandle, out int width); [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_update_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int UpdateToDB(IntPtr imageInformationHandle); + internal static extern MediaContentError UpdateToDB(IntPtr imageInformationHandle); internal sealed class SafeImageInformationHandle : SafeHandle { diff --git a/Tizen.Content.MediaContent/Interop/Interop.MediaBookmark.cs b/Tizen.Content.MediaContent/Interop/Interop.MediaBookmark.cs index dd2b4ec..8b03a43 100644..100755 --- a/Tizen.Content.MediaContent/Interop/Interop.MediaBookmark.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.MediaBookmark.cs @@ -1,32 +1,33 @@ using System; using System.Runtime.InteropServices; +using Tizen.Content.MediaContent; internal partial class Interop { internal static partial class MediaBookmark { [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_insert_to_db")] - internal static extern int InsertToDb(string media_id, uint time, string thumbnail_path); + internal static extern MediaContentError InsertToDb(string media_id, uint time, string thumbnail_path); [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_delete_from_db")] - internal static extern int DeleteFromDb(int bookmark_id); + internal static extern MediaContentError DeleteFromDb(int bookmark_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_get_bookmark_count_from_db")] - internal static extern int GetBookmarkCountFromDb(IntPtr filter, out int bookmark_count); + internal static extern MediaContentError GetBookmarkCountFromDb(IntPtr filter, out int bookmark_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_clone")] - internal static extern int Clone(out IntPtr dst, IntPtr src); + internal static extern MediaContentError Clone(out IntPtr dst, IntPtr src); [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_destroy")] - internal static extern int Destroy(IntPtr bookmark); + internal static extern MediaContentError Destroy(IntPtr bookmark); [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_get_bookmark_id")] - internal static extern int GetBookmarkId(IntPtr bookmark, out int bookmark_id); + internal static extern MediaContentError GetBookmarkId(IntPtr bookmark, out int bookmark_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_get_marked_time")] - internal static extern int GetMarkedTime(IntPtr bookmark, out uint marked_time); + internal static extern MediaContentError GetMarkedTime(IntPtr bookmark, out uint marked_time); [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_get_thumbnail_path")] - internal static extern int GetThumbnailPath(IntPtr bookmark, out string filePath); + internal static extern MediaContentError GetThumbnailPath(IntPtr bookmark, out string filePath); } } diff --git a/Tizen.Content.MediaContent/Interop/Interop.MediaContent.cs b/Tizen.Content.MediaContent/Interop/Interop.MediaContent.cs index 5196198..07ee0af 100644..100755 --- a/Tizen.Content.MediaContent/Interop/Interop.MediaContent.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.MediaContent.cs @@ -8,16 +8,16 @@ internal static partial class Interop internal static partial class Content { [DllImport(Libraries.MediaContent, EntryPoint = "media_content_connect")] - internal static extern int Connect(); + internal static extern MediaContentError Connect(); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_disconnect")] - internal static extern int Disconnect(); + internal static extern MediaContentError Disconnect(); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_scan_file")] - internal static extern int ScanFile(string filePath); + internal static extern MediaContentError ScanFile(string filePath); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_cancel_scan_folder")] - internal static extern int CancelScanFolder(string folderPath); + internal static extern MediaContentError CancelScanFolder(string folderPath); // Callback [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -26,18 +26,18 @@ internal static partial class Interop internal delegate void MediaContentDBUpdatedCallback(MediaContentError error, int pid, MediaContentUpdateItemType updateItem, MediaContentDBUpdateType updateType, MediaContentType mediaType, string uuid, string filePath, string mimeType, IntPtr data); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_scan_folder")] - internal static extern int ScanFolder(string folderPath, bool is_recursive, MediaScanCompletedCallback scanCompletedCallback, IntPtr userData); + internal static extern MediaContentError ScanFolder(string folderPath, bool is_recursive, MediaScanCompletedCallback scanCompletedCallback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_set_db_updated_cb")] - internal static extern int SetDbUpdatedCb(MediaContentDBUpdatedCallback mediaContentDBUpdatedCallback, IntPtr userData); + internal static extern MediaContentError SetDbUpdatedCb(MediaContentDBUpdatedCallback mediaContentDBUpdatedCallback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_unset_db_updated_cb")] - internal static extern int UnsetDbUpdatedCb(); + internal static extern MediaContentError UnsetDbUpdatedCb(); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_add_db_updated_cb")] - internal static extern int AddDbUpdatedCb(MediaContentDBUpdatedCallback mediaContentDBUpdatedCallback, IntPtr userData, out IntPtr noti_handle); + internal static extern MediaContentError AddDbUpdatedCb(MediaContentDBUpdatedCallback mediaContentDBUpdatedCallback, IntPtr userData, out IntPtr noti_handle); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_remove_db_updated_cb")] - internal static extern int RemoveDbUpdatedCb(IntPtr noti_handle); + internal static extern MediaContentError RemoveDbUpdatedCb(IntPtr noti_handle); } } diff --git a/Tizen.Content.MediaContent/Interop/Interop.MediaFace.cs b/Tizen.Content.MediaContent/Interop/Interop.MediaFace.cs index a416057..242f2c1 100644..100755 --- a/Tizen.Content.MediaContent/Interop/Interop.MediaFace.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.MediaFace.cs @@ -1,51 +1,51 @@ using System; using System.Runtime.InteropServices; - +using Tizen.Content.MediaContent; internal static partial class Interop { internal static partial class Face { [DllImport(Libraries.MediaContent, EntryPoint = "media_face_clone")] - internal static extern int Clone(out IntPtr dst, IntPtr src); + internal static extern MediaContentError Clone(out IntPtr dst, IntPtr src); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_destroy")] - internal static extern int Destroy(IntPtr face); + internal static extern MediaContentError Destroy(IntPtr face); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_face_id")] - internal static extern int GetFaceId(IntPtr face, out string face_id); + internal static extern MediaContentError GetFaceId(IntPtr face, out string face_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_media_id")] - internal static extern int GetMediaId(IntPtr face, out string media_id); + internal static extern MediaContentError GetMediaId(IntPtr face, out string media_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_face_rect")] - internal static extern int GetFaceRect(IntPtr face, out int rect_x, out int rect_y, out int rect_w, out int IntPtr); + internal static extern MediaContentError GetFaceRect(IntPtr face, out int rect_x, out int rect_y, out int rect_w, out int IntPtr); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_orientation")] - internal static extern int GetOrientation(IntPtr face, out int orientation); + internal static extern MediaContentError GetOrientation(IntPtr face, out int orientation); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_tag")] - internal static extern int GetTag(IntPtr face, out string tag); + internal static extern MediaContentError GetTag(IntPtr face, out string tag); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_create")] - internal static extern int Create(string media_id, out IntPtr face); + internal static extern MediaContentError Create(string media_id, out IntPtr face); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_set_face_rect")] - internal static extern int SetFaceRect(IntPtr face, int rect_x, int rect_y, int rect_w, int IntPtr); + internal static extern MediaContentError SetFaceRect(IntPtr face, int rect_x, int rect_y, int rect_w, int IntPtr); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_set_orientation")] - internal static extern int SetOrientation(IntPtr face, int orientation); + internal static extern MediaContentError SetOrientation(IntPtr face, int orientation); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_set_tag")] - internal static extern int SetTag(IntPtr face, string tag); + internal static extern MediaContentError SetTag(IntPtr face, string tag); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_insert_to_db")] - internal static extern int InsertToDb(IntPtr face); + internal static extern MediaContentError InsertToDb(IntPtr face); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_update_to_db")] - internal static extern int UpdateToDb(IntPtr face); + internal static extern MediaContentError UpdateToDb(IntPtr face); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_delete_from_db")] - internal static extern int DeleteFromDb(string face_id); + internal static extern MediaContentError DeleteFromDb(string face_id); } } diff --git a/Tizen.Content.MediaContent/Interop/Interop.MediaFilter.cs b/Tizen.Content.MediaContent/Interop/Interop.MediaFilter.cs index a0d88d4..b017583 100644..100755 --- a/Tizen.Content.MediaContent/Interop/Interop.MediaFilter.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.MediaFilter.cs @@ -16,33 +16,33 @@ internal static partial class Interop internal static partial class Filter { [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_create")] - internal static extern int Create(out IntPtr filter); + internal static extern MediaContentError Create(out IntPtr filter); [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_destroy")] - internal static extern int Destroy(IntPtr filter); + internal static extern MediaContentError Destroy(IntPtr filter); [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_set_offset")] - internal static extern int SetOffset(IntPtr filter, int offset, int count); + internal static extern MediaContentError SetOffset(IntPtr filter, int offset, int count); [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_set_condition")] - internal static extern int SetCondition(IntPtr filter, string condition, int collate_type); + internal static extern MediaContentError SetCondition(IntPtr filter, string condition, int collate_type); [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_set_order")] - internal static extern int SetOrder(IntPtr filter, ContentOrder order_type, string order_keyword, ContentCollation collate_type); + internal static extern MediaContentError SetOrder(IntPtr filter, ContentOrder order_type, string order_keyword, ContentCollation collate_type); [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_set_storage")] - internal static extern int SetStorage(IntPtr filter, string storage_id); + internal static extern MediaContentError SetStorage(IntPtr filter, string storage_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_offset")] - internal static extern int GetOffset(IntPtr filter, out int offset, out int count); + internal static extern MediaContentError GetOffset(IntPtr filter, out int offset, out int count); [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_condition")] - internal static extern int GetCondition(IntPtr filter, out string condition, out int collate_type); + internal static extern MediaContentError GetCondition(IntPtr filter, out string condition, out int collate_type); [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_order")] - internal static extern int GetOrder(IntPtr filter, out int order_type, out string order_keyword, out int collate_type); + internal static extern MediaContentError GetOrder(IntPtr filter, out int order_type, out string order_keyword, out int collate_type); [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_storage")] - internal static extern int GetStorage(IntPtr filter, out string storage_id); + internal static extern MediaContentError GetStorage(IntPtr filter, out string storage_id); } }
\ No newline at end of file diff --git a/Tizen.Content.MediaContent/Interop/Interop.MediaFolder.cs b/Tizen.Content.MediaContent/Interop/Interop.MediaFolder.cs index 671c205..8d22955 100644..100755 --- a/Tizen.Content.MediaContent/Interop/Interop.MediaFolder.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.MediaFolder.cs @@ -7,53 +7,53 @@ internal static partial class Interop internal static partial class Folder { [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_folder_count_from_db")] - internal static extern int GetFolderCountFromDb(IntPtr filter, out int folder_count); + internal static extern MediaContentError GetFolderCountFromDb(IntPtr filter, out int folder_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_media_count_from_db")] - internal static extern int GetMediaCountFromDb(string folder_id, IntPtr filter, out int media_count); + internal static extern MediaContentError GetMediaCountFromDb(string folder_id, IntPtr filter, out int media_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_clone")] - internal static extern int Clone(out IntPtr dst, IntPtr src); + internal static extern MediaContentError Clone(out IntPtr dst, IntPtr src); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_destroy")] - internal static extern int Destroy(IntPtr folder); + internal static extern MediaContentError Destroy(IntPtr folder); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_folder_id")] - internal static extern int GetFolderId(IntPtr folder, out string folder_id); + internal static extern MediaContentError GetFolderId(IntPtr folder, out string folder_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_parent_folder_id")] - internal static extern int GetParentFolderId(IntPtr folder, out string parent_folder_id); + internal static extern MediaContentError GetParentFolderId(IntPtr folder, out string parent_folder_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_path")] - internal static extern int GetPath(IntPtr folder, out string folderPath); + internal static extern MediaContentError GetPath(IntPtr folder, out string folderPath); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_name")] - internal static extern int GetName(IntPtr folder, out string folder_name); + internal static extern MediaContentError GetName(IntPtr folder, out string folder_name); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_modified_time")] - internal static extern int GetModifiedTime(IntPtr folder, out DateTime date); + internal static extern MediaContentError GetModifiedTime(IntPtr folder, out DateTime date); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_storage_type")] - internal static extern int GetStorageType(IntPtr folder, out int storage_type); + internal static extern MediaContentError GetStorageType(IntPtr folder, out int storage_type); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_storage_id")] - internal static extern int GetStorageId(IntPtr folder, out string storage_id); + internal static extern MediaContentError GetStorageId(IntPtr folder, out string storage_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_order")] - internal static extern int GetOrder(IntPtr folder, out int order); + internal static extern MediaContentError GetOrder(IntPtr folder, out int order); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_folder_from_db")] - internal static extern int GetFolderFromDb(string folder_id, out IntPtr folder); + internal static extern MediaContentError GetFolderFromDb(string folder_id, out IntPtr folder); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_set_name")] - internal static extern int SetName(IntPtr folder, string name); + internal static extern MediaContentError SetName(IntPtr folder, string name); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_set_order")] - internal static extern int SetOrder(IntPtr folder, int order); + internal static extern MediaContentError SetOrder(IntPtr folder, int order); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_update_to_db")] - internal static extern int UpdateToDb(IntPtr folder); + internal static extern MediaContentError UpdateToDb(IntPtr folder); //Callbacks [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -62,9 +62,9 @@ internal static partial class Interop internal delegate bool MediaInfoCallback(IntPtr handle, IntPtr data); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_foreach_folder_from_db")] - internal static extern int ForeachFolderFromDb(IntPtr filter, MediaFolderCallback callback, IntPtr user_data); + internal static extern MediaContentError ForeachFolderFromDb(IntPtr filter, MediaFolderCallback callback, IntPtr user_data); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_foreach_media_from_db")] - internal static extern int ForeachMediaFromDb(string folder_id, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); + internal static extern MediaContentError ForeachMediaFromDb(string folder_id, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); } } diff --git a/Tizen.Content.MediaContent/Interop/Interop.MediaGroup.cs b/Tizen.Content.MediaContent/Interop/Interop.MediaGroup.cs index 286fd84..8e31c57 100644..100755 --- a/Tizen.Content.MediaContent/Interop/Interop.MediaGroup.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.MediaGroup.cs @@ -7,37 +7,37 @@ internal static partial class Interop internal static partial class Group { [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_album_count_from_db")] - internal static extern int MediaAlbumGetAlbumCountFromDb(IntPtr filter, out int album_count); + internal static extern MediaContentError MediaAlbumGetAlbumCountFromDb(IntPtr filter, out int album_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_media_count_from_db")] - internal static extern int MediaAlbumGetMediaCountFromDb(int album_id, IntPtr filter, out int media_count); + internal static extern MediaContentError MediaAlbumGetMediaCountFromDb(int album_id, IntPtr filter, out int media_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_album_destroy")] - internal static extern int MediaAlbumDestroy(IntPtr album); + internal static extern MediaContentError MediaAlbumDestroy(IntPtr album); [DllImport(Libraries.MediaContent, EntryPoint = "media_album_clone")] - internal static extern int MediaAlbumClone(out IntPtr dst, IntPtr src); + internal static extern MediaContentError MediaAlbumClone(out IntPtr dst, IntPtr src); [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_album_id")] - internal static extern int MediaAlbumGetAlbumId(IntPtr album, out int album_id); + internal static extern MediaContentError MediaAlbumGetAlbumId(IntPtr album, out int album_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_name")] - internal static extern int MediaAlbumGetName(IntPtr album, out string album_name); + internal static extern MediaContentError MediaAlbumGetName(IntPtr album, out string album_name); [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_artist")] - internal static extern int MediaAlbumGetArtist(IntPtr album, out string artist); + internal static extern MediaContentError MediaAlbumGetArtist(IntPtr album, out string artist); [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_album_art")] - internal static extern int MediaAlbumGetAlbumArt(IntPtr album, out string album_art); + internal static extern MediaContentError MediaAlbumGetAlbumArt(IntPtr album, out string album_art); [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_album_from_db")] - internal static extern int MediaAlbumGetAlbumFromDb(int album_id, out IntPtr album); + internal static extern MediaContentError MediaAlbumGetAlbumFromDb(int album_id, out IntPtr album); [DllImport(Libraries.MediaContent, EntryPoint = "media_group_get_group_count_from_db")] - internal static extern int GetGroupCountFromDb(IntPtr filter, MediaGroupType group, out int group_count); + internal static extern MediaContentError GetGroupCountFromDb(IntPtr filter, MediaGroupType group, out int group_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_group_get_media_count_from_db")] - internal static extern int GetMediaCountFromDb(string group_name, MediaGroupType group, IntPtr filter, out int media_count); + internal static extern MediaContentError GetMediaCountFromDb(string group_name, MediaGroupType group, IntPtr filter, out int media_count); //Callbacks [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -50,15 +50,15 @@ internal static partial class Interop internal delegate bool MediaAlbumCallback(IntPtr albumHandle, IntPtr data); [DllImport(Libraries.MediaContent, EntryPoint = "media_album_foreach_album_from_db")] - internal static extern int MediaAlbumForeachAlbumFromDb(IntPtr filter, MediaAlbumCallback callback, IntPtr user_data); + internal static extern MediaContentError MediaAlbumForeachAlbumFromDb(IntPtr filter, MediaAlbumCallback callback, IntPtr user_data); [DllImport(Libraries.MediaContent, EntryPoint = "media_album_foreach_media_from_db")] - internal static extern int MediaAlbumForeachMediaFromDb(int albumId, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); + internal static extern MediaContentError MediaAlbumForeachMediaFromDb(int albumId, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); [DllImport(Libraries.MediaContent, EntryPoint = "media_group_foreach_group_from_db")] - internal static extern int ForeachGroupFromDb(IntPtr filter, MediaGroupType group, MediaGroupCallback callback, IntPtr user_data); + internal static extern MediaContentError ForeachGroupFromDb(IntPtr filter, MediaGroupType group, MediaGroupCallback callback, IntPtr user_data); [DllImport(Libraries.MediaContent, EntryPoint = "media_group_foreach_media_from_db")] - internal static extern int ForeachMediaFromDb(string groupName, MediaGroupType group, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); + internal static extern MediaContentError ForeachMediaFromDb(string groupName, MediaGroupType group, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); } } diff --git a/Tizen.Content.MediaContent/Interop/Interop.MediaInformation.cs b/Tizen.Content.MediaContent/Interop/Interop.MediaInformation.cs index bc615be..be4f04c 100755 --- a/Tizen.Content.MediaContent/Interop/Interop.MediaInformation.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.MediaInformation.cs @@ -37,220 +37,220 @@ internal static partial class Interop internal delegate bool MediaInformationCallback(IntPtr mediaInformationHandle, IntPtr UserData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_insert_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Insert(string filePath, out SafeMediaInformationHandle info); + internal static extern MediaContentError Insert(string filePath, out SafeMediaInformationHandle info); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_insert_batch_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int BatchInsert(string[] filePathArray, int arrayLength, MediaInsertCompletedCallback callback, IntPtr userData); + internal static extern MediaContentError BatchInsert(string[] filePathArray, int arrayLength, MediaInsertCompletedCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_insert_burst_shot_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int BurstShotInsert(string[] filePathArray, int arrayLength, MediaInsertBurstShotCompletedCallback callback, IntPtr userData); + internal static extern MediaContentError BurstShotInsert(string[] filePathArray, int arrayLength, MediaInsertBurstShotCompletedCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_delete_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Delete(string mediaId); + internal static extern MediaContentError Delete(string mediaId); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_delete_batch_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int BatchDelete(IntPtr filter); + internal static extern MediaContentError BatchDelete(IntPtr filter); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_destroy", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Destroy(IntPtr mediaInformationHandle); + internal static extern MediaContentError Destroy(IntPtr mediaInformationHandle); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_clone", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Clone(out SafeMediaInformationHandle dst, IntPtr src); + internal static extern MediaContentError Clone(out SafeMediaInformationHandle dst, IntPtr src); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_count_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetMediaCount(IntPtr filter, out int mediaCount); + internal static extern MediaContentError GetMediaCount(IntPtr filter, out int mediaCount); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_media_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAllMedia(IntPtr filter, MediaInformationCallback callback, IntPtr userData); + internal static extern MediaContentError GetAllMedia(IntPtr filter, MediaInformationCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_tag_count_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetTagCount(string mediaId, IntPtr filter, out int tagCount); + internal static extern MediaContentError GetTagCount(string mediaId, IntPtr filter, out int tagCount); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_tag_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAllTags(string mediaId, IntPtr filter, MediaTagCallback callback, IntPtr userData); + internal static extern MediaContentError GetAllTags(string mediaId, IntPtr filter, MediaTagCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_bookmark_count_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetBookmarkCount(string mediaId, IntPtr filter, out int bookmarkCount); + internal static extern MediaContentError GetBookmarkCount(string mediaId, IntPtr filter, out int bookmarkCount); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_bookmark_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAllBookmarks(string mediaId, IntPtr filter, MediaBookmarkCallback callback, IntPtr userData); + internal static extern MediaContentError GetAllBookmarks(string mediaId, IntPtr filter, MediaBookmarkCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_face_count_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetFaceCount(string mediaId, IntPtr filter, out int bookmarkCount); + internal static extern MediaContentError GetFaceCount(string mediaId, IntPtr filter, out int bookmarkCount); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_face_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAllFaces(string mediaId, IntPtr filter, MediaFaceCallback callback, IntPtr userData); + internal static extern MediaContentError GetAllFaces(string mediaId, IntPtr filter, MediaFaceCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_image", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetImage(IntPtr mediaInformationHandle, out Interop.ImageInformation.SafeImageInformationHandle image); + internal static extern MediaContentError GetImage(IntPtr mediaInformationHandle, out Interop.ImageInformation.SafeImageInformationHandle image); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_video", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetVideo(IntPtr mediaInformationHandle, out Interop.VideoInformation.SafeVideoInformationHandle video); + internal static extern MediaContentError GetVideo(IntPtr mediaInformationHandle, out Interop.VideoInformation.SafeVideoInformationHandle video); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_audio", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAudio(IntPtr mediaInformationHandle, out Interop.AudioInformation.SafeAudioInformationHandle audio); + internal static extern MediaContentError GetAudio(IntPtr mediaInformationHandle, out Interop.AudioInformation.SafeAudioInformationHandle audio); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_id", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetMediaId(SafeMediaInformationHandle mediaInformationHandle, out string mediaId); + internal static extern MediaContentError GetMediaId(SafeMediaInformationHandle mediaInformationHandle, out string mediaId); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_file_path", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetFilePath(SafeMediaInformationHandle mediaInformationHandle, out string filePath); + internal static extern MediaContentError GetFilePath(SafeMediaInformationHandle mediaInformationHandle, out string filePath); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_display_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetDisplayName(SafeMediaInformationHandle mediaInformationHandle, out string name); + internal static extern MediaContentError GetDisplayName(SafeMediaInformationHandle mediaInformationHandle, out string name); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_type", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetMediaType(SafeMediaInformationHandle mediaInformationHandle, out MediaContentType type); + internal static extern MediaContentError GetMediaType(SafeMediaInformationHandle mediaInformationHandle, out MediaContentType type); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_mime_type", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetMimeType(SafeMediaInformationHandle mediaInformationHandle, out string mimeType); + internal static extern MediaContentError GetMimeType(SafeMediaInformationHandle mediaInformationHandle, out string mimeType); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_size", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetSize(SafeMediaInformationHandle mediaInformationHandle, out long size); + internal static extern MediaContentError GetSize(SafeMediaInformationHandle mediaInformationHandle, out long size); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_added_time", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAddedTime(SafeMediaInformationHandle mediaInformationHandle, out int addedTime); + internal static extern MediaContentError GetAddedTime(SafeMediaInformationHandle mediaInformationHandle, out int addedTime); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_modified_time", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetModifiedTime(SafeMediaInformationHandle mediaInformationHandle, out int time); + internal static extern MediaContentError GetModifiedTime(SafeMediaInformationHandle mediaInformationHandle, out int time); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_timeline", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetTimeline(SafeMediaInformationHandle mediaInformationHandle, out int time); + internal static extern MediaContentError GetTimeline(SafeMediaInformationHandle mediaInformationHandle, out int time); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_thumbnail_path", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetThumbnailPath(SafeMediaInformationHandle mediaInformationHandle, out string filePath); + internal static extern MediaContentError GetThumbnailPath(SafeMediaInformationHandle mediaInformationHandle, out string filePath); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_description", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetDescription(SafeMediaInformationHandle mediaInformationHandle, out string description); + internal static extern MediaContentError GetDescription(SafeMediaInformationHandle mediaInformationHandle, out string description); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_longitude", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetLongitude(SafeMediaInformationHandle mediaInformationHandle, out double longitude); + internal static extern MediaContentError GetLongitude(SafeMediaInformationHandle mediaInformationHandle, out double longitude); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_latitude", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetLatitude(SafeMediaInformationHandle mediaInformationHandle, out double latitude); + internal static extern MediaContentError GetLatitude(SafeMediaInformationHandle mediaInformationHandle, out double latitude); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_altitude", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAltitude(SafeMediaInformationHandle mediaInformationHandle, out double altitude); + internal static extern MediaContentError GetAltitude(SafeMediaInformationHandle mediaInformationHandle, out double altitude); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_weather", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetWeather(SafeMediaInformationHandle mediaInformationHandle, out string weather); + internal static extern MediaContentError GetWeather(SafeMediaInformationHandle mediaInformationHandle, out string weather); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_rating", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetRating(SafeMediaInformationHandle mediaInformationHandle, out int rating); + internal static extern MediaContentError GetRating(SafeMediaInformationHandle mediaInformationHandle, out int rating); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_favorite", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetFavorite(SafeMediaInformationHandle mediaInformationHandle, out bool favorite); + internal static extern MediaContentError GetFavorite(SafeMediaInformationHandle mediaInformationHandle, out bool favorite); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_author", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAuthor(SafeMediaInformationHandle mediaInformationHandle, out string author); + internal static extern MediaContentError GetAuthor(SafeMediaInformationHandle mediaInformationHandle, out string author); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_provider", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetProvider(SafeMediaInformationHandle mediaInformationHandle, out string provider); + internal static extern MediaContentError GetProvider(SafeMediaInformationHandle mediaInformationHandle, out string provider); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_content_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetContentName(SafeMediaInformationHandle mediaInformationHandle, out string contentName); + internal static extern MediaContentError GetContentName(SafeMediaInformationHandle mediaInformationHandle, out string contentName); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_title", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetTitle(SafeMediaInformationHandle mediaInformationHandle, out string title); + internal static extern MediaContentError GetTitle(SafeMediaInformationHandle mediaInformationHandle, out string title); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_category", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetCategory(SafeMediaInformationHandle mediaInformationHandle, out string category); + internal static extern MediaContentError GetCategory(SafeMediaInformationHandle mediaInformationHandle, out string category); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_location_tag", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetLocationTag(SafeMediaInformationHandle mediaInformationHandle, out string locationTag); + internal static extern MediaContentError GetLocationTag(SafeMediaInformationHandle mediaInformationHandle, out string locationTag); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_age_rating", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAgeRating(SafeMediaInformationHandle mediaInformationHandle, out string ageRating); + internal static extern MediaContentError GetAgeRating(SafeMediaInformationHandle mediaInformationHandle, out string ageRating); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_keyword", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetKeyword(SafeMediaInformationHandle mediaInformationHandle, out string keyword); + internal static extern MediaContentError GetKeyword(SafeMediaInformationHandle mediaInformationHandle, out string keyword); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_storage_id", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetStorageId(SafeMediaInformationHandle mediaInformationHandle, out string storageId); + internal static extern MediaContentError GetStorageId(SafeMediaInformationHandle mediaInformationHandle, out string storageId); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_is_drm", CallingConvention = CallingConvention.Cdecl)] - internal static extern int IsDrm(SafeMediaInformationHandle mediaInformationHandle, out bool isDrm); + internal static extern MediaContentError IsDrm(SafeMediaInformationHandle mediaInformationHandle, out bool isDrm); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_storage_type", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetStorageType(SafeMediaInformationHandle mediaInformationHandle, out ContentStorageType storageType); + internal static extern MediaContentError GetStorageType(SafeMediaInformationHandle mediaInformationHandle, out ContentStorageType storageType); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_played_count", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetPlayedCount(SafeMediaInformationHandle mediaInformationHandle, out int playedCount); + internal static extern MediaContentError GetPlayedCount(SafeMediaInformationHandle mediaInformationHandle, out int playedCount); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_played_time", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetPlayedAt(SafeMediaInformationHandle mediaInformationHandle, out int playedTime); + internal static extern MediaContentError GetPlayedAt(SafeMediaInformationHandle mediaInformationHandle, out int playedTime); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetMediaFromDB(string mediaId, out SafeMediaInformationHandle mediaInformationHandle); + internal static extern MediaContentError GetMediaFromDB(string mediaId, out SafeMediaInformationHandle mediaInformationHandle); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_increase_played_count", CallingConvention = CallingConvention.Cdecl)] - internal static extern int IncreasePlayedCount(SafeMediaInformationHandle mediaInformationHandle); + internal static extern MediaContentError IncreasePlayedCount(SafeMediaInformationHandle mediaInformationHandle); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_played_time", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetPlayedAt(SafeMediaInformationHandle mediaInformationHandle); + internal static extern MediaContentError SetPlayedAt(SafeMediaInformationHandle mediaInformationHandle); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_display_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetDisplayName(SafeMediaInformationHandle mediaInformationHandle, string displayName); + internal static extern MediaContentError SetDisplayName(SafeMediaInformationHandle mediaInformationHandle, string displayName); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_description", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetDescription(SafeMediaInformationHandle mediaInformationHandle, string description); + internal static extern MediaContentError SetDescription(SafeMediaInformationHandle mediaInformationHandle, string description); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_longitude", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetLongitude(SafeMediaInformationHandle mediaInformationHandle, double longitude); + internal static extern MediaContentError SetLongitude(SafeMediaInformationHandle mediaInformationHandle, double longitude); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_latitude", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetLatitude(SafeMediaInformationHandle mediaInformationHandle, double latitude); + internal static extern MediaContentError SetLatitude(SafeMediaInformationHandle mediaInformationHandle, double latitude); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_altitude", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAltitude(SafeMediaInformationHandle mediaInformationHandle, double altitude); + internal static extern MediaContentError SetAltitude(SafeMediaInformationHandle mediaInformationHandle, double altitude); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_weather", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetWeather(SafeMediaInformationHandle mediaInformationHandle, string weather); + internal static extern MediaContentError SetWeather(SafeMediaInformationHandle mediaInformationHandle, string weather); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_rating", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetRating(SafeMediaInformationHandle mediaInformationHandle, int rating); + internal static extern MediaContentError SetRating(SafeMediaInformationHandle mediaInformationHandle, int rating); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_favorite", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetFavorite(SafeMediaInformationHandle mediaInformationHandle, bool favorite); + internal static extern MediaContentError SetFavorite(SafeMediaInformationHandle mediaInformationHandle, bool favorite); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_author", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAuthor(SafeMediaInformationHandle mediaInformationHandle, string author); + internal static extern MediaContentError SetAuthor(SafeMediaInformationHandle mediaInformationHandle, string author); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_provider", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetProvider(SafeMediaInformationHandle mediaInformationHandle, string provider); + internal static extern MediaContentError SetProvider(SafeMediaInformationHandle mediaInformationHandle, string provider); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_content_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetContentName(SafeMediaInformationHandle mediaInformationHandle, string contentName); + internal static extern MediaContentError SetContentName(SafeMediaInformationHandle mediaInformationHandle, string contentName); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_category", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetCategory(SafeMediaInformationHandle mediaInformationHandle, string category); + internal static extern MediaContentError SetCategory(SafeMediaInformationHandle mediaInformationHandle, string category); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_location_tag", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetLocationTag(SafeMediaInformationHandle mediaInformationHandle, string locationTag); + internal static extern MediaContentError SetLocationTag(SafeMediaInformationHandle mediaInformationHandle, string locationTag); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_age_rating", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAgeRating(SafeMediaInformationHandle mediaInformationHandle, string ageRating); + internal static extern MediaContentError SetAgeRating(SafeMediaInformationHandle mediaInformationHandle, string ageRating); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_keyword", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetKeyword(SafeMediaInformationHandle mediaInformationHandle, string keyword); + internal static extern MediaContentError SetKeyword(SafeMediaInformationHandle mediaInformationHandle, string keyword); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_update_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int UpdateToDB(IntPtr mediaInformationHandle); + internal static extern MediaContentError UpdateToDB(IntPtr mediaInformationHandle); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_refresh_metadata_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int RefreshMetadataToDB(string mediaId); + internal static extern MediaContentError RefreshMetadataToDB(string mediaId); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_added_time", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAddedTime(SafeMediaInformationHandle mediaInformationHandle, int addedTime); + internal static extern MediaContentError SetAddedTime(SafeMediaInformationHandle mediaInformationHandle, int addedTime); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_move_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int MoveToDB(SafeMediaInformationHandle mediaInformationHandle, string dstPath); + internal static extern MediaContentError MoveToDB(SafeMediaInformationHandle mediaInformationHandle, string dstPath); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_create_thumbnail", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CreateThumbnail(SafeMediaInformationHandle mediaInformationHandle, MediaThumbnailCompletedCallback callback, IntPtr userData); + internal static extern MediaContentError CreateThumbnail(SafeMediaInformationHandle mediaInformationHandle, MediaThumbnailCompletedCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_cancel_thumbnail", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CancelThumbnail(SafeMediaInformationHandle mediaInformationHandle); + internal static extern MediaContentError CancelThumbnail(SafeMediaInformationHandle mediaInformationHandle); internal sealed class SafeMediaInformationHandle : SafeHandle { diff --git a/Tizen.Content.MediaContent/Interop/Interop.MediaPlaylist.cs b/Tizen.Content.MediaContent/Interop/Interop.MediaPlaylist.cs index 58b7024..d4b4ab3 100644..100755 --- a/Tizen.Content.MediaContent/Interop/Interop.MediaPlaylist.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.MediaPlaylist.cs @@ -7,61 +7,61 @@ internal static partial class Interop internal static partial class Playlist { [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_playlist_count_from_db")] - internal static extern int GetPlaylistCountFromDb(IntPtr filter, out int playlist_count); + internal static extern MediaContentError GetPlaylistCountFromDb(IntPtr filter, out int playlist_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_media_count_from_db")] - internal static extern int GetMediaCountFromDb(int playlist_id, IntPtr filter, out int media_count); + internal static extern MediaContentError GetMediaCountFromDb(int playlist_id, IntPtr filter, out int media_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_insert_to_db")] - internal static extern int InsertToDb(string name, out IntPtr playlist); + internal static extern MediaContentError InsertToDb(string name, out IntPtr playlist); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_delete_from_db")] - internal static extern int DeleteFromDb(int playlist_id); + internal static extern MediaContentError DeleteFromDb(int playlist_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_playlist_from_db")] - internal static extern int GetPlaylistFromDb(int playlist_id, out IntPtr playlist); + internal static extern MediaContentError GetPlaylistFromDb(int playlist_id, out IntPtr playlist); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_destroy")] - internal static extern int Destroy(IntPtr playlist); + internal static extern MediaContentError Destroy(IntPtr playlist); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_clone")] - internal static extern int Clone(out IntPtr dst, IntPtr src); + internal static extern MediaContentError Clone(out IntPtr dst, IntPtr src); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_playlist_id")] - internal static extern int GetPlaylistId(IntPtr playlist, out int playlist_id); + internal static extern MediaContentError GetPlaylistId(IntPtr playlist, out int playlist_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_name")] - internal static extern int GetName(IntPtr playlist, out string playlist_name); + internal static extern MediaContentError GetName(IntPtr playlist, out string playlist_name); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_set_name")] - internal static extern int SetName(IntPtr playlist, string playlist_name); + internal static extern MediaContentError SetName(IntPtr playlist, string playlist_name); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_thumbnail_path")] - internal static extern int GetThumbnailPath(IntPtr playlist, out string filePath); + internal static extern MediaContentError GetThumbnailPath(IntPtr playlist, out string filePath); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_set_thumbnail_path")] - internal static extern int SetThumbnailPath(IntPtr playlist, string filePath); + internal static extern MediaContentError SetThumbnailPath(IntPtr playlist, string filePath); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_set_play_order")] - internal static extern int SetPlayOrder(IntPtr playlist, int playlist_member_id, int play_order); + internal static extern MediaContentError SetPlayOrder(IntPtr playlist, int playlist_member_id, int play_order); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_add_media")] - internal static extern int AddMedia(IntPtr playlist, string media_id); + internal static extern MediaContentError AddMedia(IntPtr playlist, string media_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_remove_media")] - internal static extern int RemoveMedia(IntPtr playlist, int playlist_member_id); + internal static extern MediaContentError RemoveMedia(IntPtr playlist, int playlist_member_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_play_order")] - internal static extern int GetPlayOrder(IntPtr playlist, int playlist_member_id, out int play_order); + internal static extern MediaContentError GetPlayOrder(IntPtr playlist, int playlist_member_id, out int play_order); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_update_to_db")] - internal static extern int UpdateToDb(IntPtr playlist); + internal static extern MediaContentError UpdateToDb(IntPtr playlist); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_import_from_file")] - internal static extern int ImportFromFile(string playlist_name, string filePath, out IntPtr playlist); + internal static extern MediaContentError ImportFromFile(string playlist_name, string filePath, out IntPtr playlist); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_export_to_file")] - internal static extern int ExportToFile(IntPtr playlist, string filePath); + internal static extern MediaContentError ExportToFile(IntPtr playlist, string filePath); //Callbacks [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -71,9 +71,9 @@ internal static partial class Interop internal delegate bool PlaylistMemberCallback(int playListMemberId, IntPtr mediaInformation, IntPtr data); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_foreach_playlist_from_db")] - internal static extern int ForeachPlaylistFromDb(IntPtr filter, MediaPlaylistCallback callback, IntPtr user_data); + internal static extern MediaContentError ForeachPlaylistFromDb(IntPtr filter, MediaPlaylistCallback callback, IntPtr user_data); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_foreach_media_from_db")] - internal static extern int ForeachMediaFromDb(int playlist_id, IntPtr filter, PlaylistMemberCallback callback, IntPtr user_data); + internal static extern MediaContentError ForeachMediaFromDb(int playlist_id, IntPtr filter, PlaylistMemberCallback callback, IntPtr user_data); } } diff --git a/Tizen.Content.MediaContent/Interop/Interop.MediaStorage.cs b/Tizen.Content.MediaContent/Interop/Interop.MediaStorage.cs index 411b5b8..6431a5d 100644..100755 --- a/Tizen.Content.MediaContent/Interop/Interop.MediaStorage.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.MediaStorage.cs @@ -7,31 +7,31 @@ internal static partial class Interop internal static partial class Storage { [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_storage_info_from_db")] - internal static extern int GetStorageInfoFromDb(string storage_id, out IntPtr storage); + internal static extern MediaContentError GetStorageInfoFromDb(string storage_id, out IntPtr storage); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_storage_count_from_db")] - internal static extern int GetStorageCountFromDb(IntPtr filter, out int storage_count); + internal static extern MediaContentError GetStorageCountFromDb(IntPtr filter, out int storage_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_media_count_from_db")] - internal static extern int GetMediaCountFromDb(string storage_id, IntPtr filter, out int media_count); + internal static extern MediaContentError GetMediaCountFromDb(string storage_id, IntPtr filter, out int media_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_destroy")] - internal static extern int Destroy(IntPtr storage); + internal static extern MediaContentError Destroy(IntPtr storage); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_clone")] - internal static extern int Clone(out IntPtr dst, IntPtr src); + internal static extern MediaContentError Clone(out IntPtr dst, IntPtr src); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_id")] - internal static extern int GetId(IntPtr storage, out string storage_id); + internal static extern MediaContentError GetId(IntPtr storage, out string storage_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_name")] - internal static extern int GetName(IntPtr storage, out string storage_name); + internal static extern MediaContentError GetName(IntPtr storage, out string storage_name); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_path")] - internal static extern int GetPath(IntPtr storage, out string storage_path); + internal static extern MediaContentError GetPath(IntPtr storage, out string storage_path); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_type")] - internal static extern int GetType(IntPtr storage, out int storage_type); + internal static extern MediaContentError GetType(IntPtr storage, out int storage_type); //Callbacks [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -41,9 +41,9 @@ internal static partial class Interop internal delegate bool MediaInfoCallback(IntPtr mediaInformation, IntPtr data); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_foreach_storage_from_db")] - internal static extern int ForeachStorageFromDb(IntPtr filter, MediaStorageCallback callback, IntPtr user_data); + internal static extern MediaContentError ForeachStorageFromDb(IntPtr filter, MediaStorageCallback callback, IntPtr user_data); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_foreach_media_from_db")] - internal static extern int ForeachMediaFromDb(string storage_id, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); + internal static extern MediaContentError ForeachMediaFromDb(string storage_id, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); } } diff --git a/Tizen.Content.MediaContent/Interop/Interop.MediaTag.cs b/Tizen.Content.MediaContent/Interop/Interop.MediaTag.cs index f97e270..3740231 100644..100755 --- a/Tizen.Content.MediaContent/Interop/Interop.MediaTag.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.MediaTag.cs @@ -7,43 +7,43 @@ internal static partial class Interop internal static partial class Tag { [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_insert_to_db")] - internal static extern int InsertToDb(string tag_name, out IntPtr tag); + internal static extern MediaContentError InsertToDb(string tag_name, out IntPtr tag); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_delete_from_db")] - internal static extern int DeleteFromDb(int tag_id); + internal static extern MediaContentError DeleteFromDb(int tag_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_get_tag_count_from_db")] - internal static extern int GetTagCountFromDb(IntPtr filter, out int tag_count); + internal static extern MediaContentError GetTagCountFromDb(IntPtr filter, out int tag_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_get_media_count_from_db")] - internal static extern int GetMediaCountFromDb(int tag_id, IntPtr filter, out int media_count); + internal static extern MediaContentError GetMediaCountFromDb(int tag_id, IntPtr filter, out int media_count); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_clone")] - internal static extern int Clone(out IntPtr dst, IntPtr src); + internal static extern MediaContentError Clone(out IntPtr dst, IntPtr src); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_destroy")] - internal static extern int Destroy(IntPtr tag); + internal static extern MediaContentError Destroy(IntPtr tag); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_get_tag_id")] - internal static extern int GetTagId(IntPtr tag, out int tag_id); + internal static extern MediaContentError GetTagId(IntPtr tag, out int tag_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_get_name")] - internal static extern int GetName(IntPtr tag, out string tag_name); + internal static extern MediaContentError GetName(IntPtr tag, out string tag_name); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_get_tag_from_db")] - internal static extern int GetTagFromDb(int tag_id, out IntPtr tag); + internal static extern MediaContentError GetTagFromDb(int tag_id, out IntPtr tag); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_add_media")] - internal static extern int AddMedia(IntPtr tag, string media_id); + internal static extern MediaContentError AddMedia(IntPtr tag, string media_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_remove_media")] - internal static extern int RemoveMedia(IntPtr tag, string media_id); + internal static extern MediaContentError RemoveMedia(IntPtr tag, string media_id); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_set_name")] - internal static extern int SetName(IntPtr tag, string tag_name); + internal static extern MediaContentError SetName(IntPtr tag, string tag_name); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_update_to_db")] - internal static extern int UpdateToDb(IntPtr tag); + internal static extern MediaContentError UpdateToDb(IntPtr tag); //Callbacks [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -53,9 +53,9 @@ internal static partial class Interop internal delegate bool MediaTagCallback(IntPtr tag, IntPtr data); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_foreach_tag_from_db")] - internal static extern int ForeachTagFromDb(IntPtr filter, MediaTagCallback callback, IntPtr user_data); + internal static extern MediaContentError ForeachTagFromDb(IntPtr filter, MediaTagCallback callback, IntPtr user_data); [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_foreach_media_from_db")] - internal static extern int ForeachMediaFromDb(int tag_id, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); + internal static extern MediaContentError ForeachMediaFromDb(int tag_id, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); } }
\ No newline at end of file diff --git a/Tizen.Content.MediaContent/Interop/Interop.VideoInformation.cs b/Tizen.Content.MediaContent/Interop/Interop.VideoInformation.cs index 35d459a..e44c8a8 100755 --- a/Tizen.Content.MediaContent/Interop/Interop.VideoInformation.cs +++ b/Tizen.Content.MediaContent/Interop/Interop.VideoInformation.cs @@ -16,73 +16,73 @@ internal static partial class Interop internal static partial class VideoInformation { [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_destroy", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Destroy(IntPtr media); + internal static extern MediaContentError Destroy(IntPtr media); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_clone", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Clone(out SafeVideoInformationHandle dst, SafeVideoInformationHandle src); + internal static extern MediaContentError Clone(out SafeVideoInformationHandle dst, SafeVideoInformationHandle src); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_media_id", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetMediaId(SafeVideoInformationHandle videoInformationHandle, out string mediaId); + internal static extern MediaContentError GetMediaId(SafeVideoInformationHandle videoInformationHandle, out string mediaId); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_album", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAlbum(SafeVideoInformationHandle videoInformationHandle, out string albumName); + internal static extern MediaContentError GetAlbum(SafeVideoInformationHandle videoInformationHandle, out string albumName); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_artist", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetArtist(SafeVideoInformationHandle videoInformationHandle, out string artistName); + internal static extern MediaContentError GetArtist(SafeVideoInformationHandle videoInformationHandle, out string artistName); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_album_artist", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAlbumArtist(SafeVideoInformationHandle videoInformationHandle, out string albumArtistName); + internal static extern MediaContentError GetAlbumArtist(SafeVideoInformationHandle videoInformationHandle, out string albumArtistName); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_genre", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetGenre(SafeVideoInformationHandle videoInformationHandle, out string genreName); + internal static extern MediaContentError GetGenre(SafeVideoInformationHandle videoInformationHandle, out string genreName); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_composer", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetComposer(SafeVideoInformationHandle videoInformationHandle, out string composerName); + internal static extern MediaContentError GetComposer(SafeVideoInformationHandle videoInformationHandle, out string composerName); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_year", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetYear(SafeVideoInformationHandle videoInformationHandle, out string year); + internal static extern MediaContentError GetYear(SafeVideoInformationHandle videoInformationHandle, out string year); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_recorded_date", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetRecordedDate(SafeVideoInformationHandle videoInformationHandle, out string recordedDate); + internal static extern MediaContentError GetRecordedDate(SafeVideoInformationHandle videoInformationHandle, out string recordedDate); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_copyright", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetCopyright(SafeVideoInformationHandle videoInformationHandle, out string copyright); + internal static extern MediaContentError GetCopyright(SafeVideoInformationHandle videoInformationHandle, out string copyright); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_track_num", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetTrackNum(SafeVideoInformationHandle videoInformationHandle, out string trackNum); + internal static extern MediaContentError GetTrackNum(SafeVideoInformationHandle videoInformationHandle, out string trackNum); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_bit_rate", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetBitRate(SafeVideoInformationHandle videoInformationHandle, out int bitRate); + internal static extern MediaContentError GetBitRate(SafeVideoInformationHandle videoInformationHandle, out int bitRate); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_duration", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetDuration(SafeVideoInformationHandle videoInformationHandle, out int duration); + internal static extern MediaContentError GetDuration(SafeVideoInformationHandle videoInformationHandle, out int duration); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_width", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetWidth(SafeVideoInformationHandle videoInformationHandle, out int width); + internal static extern MediaContentError GetWidth(SafeVideoInformationHandle videoInformationHandle, out int width); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_height", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetHeight(SafeVideoInformationHandle videoInformationHandle, out int width); + internal static extern MediaContentError GetHeight(SafeVideoInformationHandle videoInformationHandle, out int width); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_played_count", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetPlayedCount(SafeVideoInformationHandle videoInformationHandle, out int playedCount); + internal static extern MediaContentError GetPlayedCount(SafeVideoInformationHandle videoInformationHandle, out int playedCount); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_played_time", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetPlayedTime(SafeVideoInformationHandle videoInformationHandle, out int playedTime); + internal static extern MediaContentError GetPlayedTime(SafeVideoInformationHandle videoInformationHandle, out int playedTime); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_played_position", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetPlayedPosition(SafeVideoInformationHandle videoInformationHandle, out int playedPosition); + internal static extern MediaContentError GetPlayedPosition(SafeVideoInformationHandle videoInformationHandle, out int playedPosition); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_set_played_count", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetPlayedCount(SafeVideoInformationHandle videoInformationHandle, int playedCount); + internal static extern MediaContentError SetPlayedCount(SafeVideoInformationHandle videoInformationHandle, int playedCount); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_set_played_time", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetPlayedTime(SafeVideoInformationHandle videoInformationHandle, int playedTime); + internal static extern MediaContentError SetPlayedTime(SafeVideoInformationHandle videoInformationHandle, int playedTime); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_set_played_position", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetPlayedPosition(SafeVideoInformationHandle videoInformationHandle, int playedPosition); + internal static extern MediaContentError SetPlayedPosition(SafeVideoInformationHandle videoInformationHandle, int playedPosition); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_update_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int UpdateToDB(IntPtr videoInformationHandle); + internal static extern MediaContentError UpdateToDB(IntPtr videoInformationHandle); internal sealed class SafeVideoInformationHandle : SafeHandle { diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent.csproj b/Tizen.Content.MediaContent/Tizen.Content.MediaContent.csproj index 5f6c061..380b6b0 100644..100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent.csproj +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent.csproj @@ -1,111 +1,110 @@ -<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{A106C68E-0E2F-4A1F-9E87-113DC4F78787}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Tizen.Content</RootNamespace>
- <AssemblyName>Tizen.Content.MediaContent</AssemblyName>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup>
- <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
- <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>
- <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
- <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
- <NoStdLib>true</NoStdLib>
- <NoWarn>$(NoWarn);1701;1702</NoWarn>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup>
- <SignAssembly>true</SignAssembly>
- </PropertyGroup>
- <PropertyGroup>
- <AssemblyOriginatorKeyFile>Tizen.Content.MediaContent.snk</AssemblyOriginatorKeyFile>
- </PropertyGroup>
- <ItemGroup>
- <Compile Include="Interop\Interop.AudioInformation.cs" />
- <Compile Include="Interop\Interop.Glib.cs" />
- <Compile Include="Interop\Interop.ImageInformation.cs" />
- <Compile Include="Interop\Interop.Libc.cs" />
- <Compile Include="Interop\Interop.Libraries.cs" />
- <Compile Include="Interop\Interop.MediaBookmark.cs" />
- <Compile Include="Interop\Interop.MediaContent.cs" />
- <Compile Include="Interop\Interop.MediaFace.cs" />
- <Compile Include="Interop\Interop.MediaFilter.cs" />
- <Compile Include="Interop\Interop.MediaFolder.cs" />
- <Compile Include="Interop\Interop.MediaGroup.cs" />
- <Compile Include="Interop\Interop.MediaInformation.cs" />
- <Compile Include="Interop\Interop.MediaPlaylist.cs" />
- <Compile Include="Interop\Interop.MediaStorage.cs" />
- <Compile Include="Interop\Interop.MediaTag.cs" />
- <Compile Include="Interop\Interop.VideoInformation.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Tizen.Content.MediaContent\Album.cs" />
- <Compile Include="Tizen.Content.MediaContent\AudioInformation.cs" />
- <Compile Include="Tizen.Content.MediaContent\ContentCollection.cs" />
- <Compile Include="Tizen.Content.MediaContent\ContentDatabase.cs" />
- <Compile Include="Tizen.Content.MediaContent\ContentEventArgs.cs" />
- <Compile Include="Tizen.Content.MediaContent\ContentFilter.cs" />
- <Compile Include="Tizen.Content.MediaContent\ContentManager.cs" />
- <Compile Include="Tizen.Content.MediaContent\FaceRect.cs" />
- <Compile Include="Tizen.Content.MediaContent\Group.cs" />
- <Compile Include="Tizen.Content.MediaContent\ImageInformation.cs" />
- <Compile Include="Tizen.Content.MediaContent\MediaBookmark.cs" />
- <Compile Include="Tizen.Content.MediaContent\MediaContentEnums.cs" />
- <Compile Include="Tizen.Content.MediaContent\MediaContentErrorFactory.cs" />
- <Compile Include="Tizen.Content.MediaContent\MediaContentTypes.cs" />
- <Compile Include="Tizen.Content.MediaContent\MediaFace.cs" />
- <Compile Include="Tizen.Content.MediaContent\MediaFolder.cs" />
- <Compile Include="Tizen.Content.MediaContent\MediaInformation.cs" />
- <Compile Include="Tizen.Content.MediaContent\PlayList.cs" />
- <Compile Include="Tizen.Content.MediaContent\Storage.cs" />
- <Compile Include="Tizen.Content.MediaContent\Tag.cs" />
- <Compile Include="Tizen.Content.MediaContent\VideoInformation.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="Tizen.Content.MediaContent.nuspec">
- <SubType>Designer</SubType>
- </None>
- <None Include="Tizen.Content.MediaContent.project.json" />
- <None Include="Tizen.Content.MediaContent.snk" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
- <PropertyGroup>
- <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and
- https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild
- -->
- <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
- properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
- to prevent it from outputting a warning (MSB3644).
- -->
- <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
- <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
- <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
- </PropertyGroup>
-</Project>
\ No newline at end of file +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{A106C68E-0E2F-4A1F-9E87-113DC4F78787}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Tizen.Content</RootNamespace> + <AssemblyName>Tizen.Content.MediaContent</AssemblyName> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup> + <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier> + <TargetFrameworkVersion>v1.3</TargetFrameworkVersion> + <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker> + <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences> + <NoStdLib>true</NoStdLib> + <NoWarn>$(NoWarn);1701;1702</NoWarn> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup> + <SignAssembly>true</SignAssembly> + </PropertyGroup> + <PropertyGroup> + <AssemblyOriginatorKeyFile>Tizen.Content.MediaContent.snk</AssemblyOriginatorKeyFile> + </PropertyGroup> + <ItemGroup> + <Compile Include="Interop\Interop.AudioInformation.cs" /> + <Compile Include="Interop\Interop.Glib.cs" /> + <Compile Include="Interop\Interop.ImageInformation.cs" /> + <Compile Include="Interop\Interop.Libc.cs" /> + <Compile Include="Interop\Interop.Libraries.cs" /> + <Compile Include="Interop\Interop.MediaBookmark.cs" /> + <Compile Include="Interop\Interop.MediaContent.cs" /> + <Compile Include="Interop\Interop.MediaFace.cs" /> + <Compile Include="Interop\Interop.MediaFilter.cs" /> + <Compile Include="Interop\Interop.MediaFolder.cs" /> + <Compile Include="Interop\Interop.MediaGroup.cs" /> + <Compile Include="Interop\Interop.MediaInformation.cs" /> + <Compile Include="Interop\Interop.MediaPlaylist.cs" /> + <Compile Include="Interop\Interop.MediaStorage.cs" /> + <Compile Include="Interop\Interop.MediaTag.cs" /> + <Compile Include="Interop\Interop.VideoInformation.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Tizen.Content.MediaContent\Album.cs" /> + <Compile Include="Tizen.Content.MediaContent\AudioInformation.cs" /> + <Compile Include="Tizen.Content.MediaContent\ContentCollection.cs" /> + <Compile Include="Tizen.Content.MediaContent\ContentDatabase.cs" /> + <Compile Include="Tizen.Content.MediaContent\ContentEventArgs.cs" /> + <Compile Include="Tizen.Content.MediaContent\ContentFilter.cs" /> + <Compile Include="Tizen.Content.MediaContent\ContentManager.cs" /> + <Compile Include="Tizen.Content.MediaContent\FaceRect.cs" /> + <Compile Include="Tizen.Content.MediaContent\Group.cs" /> + <Compile Include="Tizen.Content.MediaContent\ImageInformation.cs" /> + <Compile Include="Tizen.Content.MediaContent\MediaBookmark.cs" /> + <Compile Include="Tizen.Content.MediaContent\MediaContentEnums.cs" /> + <Compile Include="Tizen.Content.MediaContent\MediaContentError.cs" /> + <Compile Include="Tizen.Content.MediaContent\MediaFace.cs" /> + <Compile Include="Tizen.Content.MediaContent\MediaFolder.cs" /> + <Compile Include="Tizen.Content.MediaContent\MediaInformation.cs" /> + <Compile Include="Tizen.Content.MediaContent\PlayList.cs" /> + <Compile Include="Tizen.Content.MediaContent\Storage.cs" /> + <Compile Include="Tizen.Content.MediaContent\Tag.cs" /> + <Compile Include="Tizen.Content.MediaContent\VideoInformation.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="Tizen.Content.MediaContent.nuspec"> + <SubType>Designer</SubType> + </None> + <None Include="Tizen.Content.MediaContent.project.json" /> + <None Include="Tizen.Content.MediaContent.snk" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> + <PropertyGroup> + <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and + https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild + --> + <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two + properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and + to prevent it from outputting a warning (MSB3644). + --> + <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories> + <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths> + <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences> + </PropertyGroup> +</Project> diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Album.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Album.cs index b5dce8b..12c4ec2 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Album.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Album.cs @@ -37,11 +37,9 @@ namespace Tizen.Content.MediaContent get { int id = 0; - MediaContentError res = (MediaContentError)Interop.Group.MediaAlbumGetAlbumId(_albumHandle, out id); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Id for the Album"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Group.MediaAlbumGetAlbumId(_albumHandle, out id), "Failed to get value"); + return id; } } @@ -54,11 +52,9 @@ namespace Tizen.Content.MediaContent get { string artist = ""; - MediaContentError res = (MediaContentError)Interop.Group.MediaAlbumGetArtist(_albumHandle, out artist); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Artist for the Album"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Group.MediaAlbumGetArtist(_albumHandle, out artist), "Failed to get value"); + return artist; } } @@ -71,12 +67,9 @@ namespace Tizen.Content.MediaContent get { string art = ""; - MediaContentError res = (MediaContentError)Interop.Group.MediaAlbumGetAlbumArt(_albumHandle, out art); - Tizen.Log.Info("TCT", "Album Art Property: " + art); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Album Art for the Album"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Group.MediaAlbumGetAlbumArt(_albumHandle, out art), "Failed to get value"); + return art; } } @@ -89,11 +82,9 @@ namespace Tizen.Content.MediaContent get { string name = ""; - MediaContentError res = (MediaContentError)Interop.Group.MediaAlbumGetArtist(_albumHandle, out name); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Name for the Album"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Group.MediaAlbumGetArtist(_albumHandle, out name), "Failed to get value"); + return name; } } @@ -113,22 +104,19 @@ namespace Tizen.Content.MediaContent { int mediaCount = 0; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res = (MediaContentError)Interop.Group.MediaAlbumGetMediaCountFromDb(Id, handle, out mediaCount); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get media count for the album"); - } + + MediaContentRetValidator.ThrowIfError( + Interop.Group.MediaAlbumGetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count"); + return mediaCount; } public override void Dispose() { - MediaContentError res = (MediaContentError)Interop.Group.MediaAlbumDestroy(_albumHandle); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to dispose the album"); + if (_albumHandle != IntPtr.Zero) { + Interop.Group.MediaAlbumDestroy(_albumHandle); + _albumHandle = IntPtr.Zero; } - _albumHandle = IntPtr.Zero; } /// <summary> @@ -142,26 +130,20 @@ namespace Tizen.Content.MediaContent { var tcs = new TaskCompletionSource<IEnumerable<MediaInformation>>(); List<MediaInformation> mediaContents = new List<MediaInformation>(); - MediaContentError res; + IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; Interop.Group.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) => { Interop.MediaInformation.SafeMediaInformationHandle newHandle; - res = (MediaContentError)Interop.MediaInformation.Clone(out newHandle, mediaHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to clone media"); - } - - MediaInformation info = new MediaInformation(newHandle); - mediaContents.Add(info); + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone"); + + mediaContents.Add(new MediaInformation(newHandle)); return true; }; - res = (MediaContentError)Interop.Group.MediaAlbumForeachMediaFromDb(Id, handle, callback, IntPtr.Zero); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to get media information for the album"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Group.MediaAlbumForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information"); + tcs.TrySetResult(mediaContents); return tcs.Task; } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/AudioInformation.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/AudioInformation.cs index 4436431..110cfed 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/AudioInformation.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/AudioInformation.cs @@ -44,11 +44,9 @@ namespace Tizen.Content.MediaContent get { string mediaId = ""; - int result = Interop.AudioInformation.GetMediaId(_handle, out mediaId); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetMediaId(_handle, out mediaId), "Failed to get value"); + if (mediaId == null) { mediaId = ""; @@ -67,11 +65,9 @@ namespace Tizen.Content.MediaContent get { string album = ""; - int result = Interop.AudioInformation.GetAlbum(_handle, out album); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetAlbum(_handle, out album), "Failed to get value"); + if (album == null) { album = ""; @@ -90,11 +86,9 @@ namespace Tizen.Content.MediaContent get { string artist = ""; - int result = Interop.AudioInformation.GetArtist(_handle, out artist); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetArtist(_handle, out artist), "Failed to get value"); + if (artist == null) { artist = ""; @@ -113,11 +107,9 @@ namespace Tizen.Content.MediaContent get { string albumArtist = ""; - int result = Interop.AudioInformation.GetAlbumArtist(_handle, out albumArtist); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetAlbumArtist(_handle, out albumArtist), "Failed to get value"); + if (albumArtist == null) { albumArtist = ""; @@ -136,11 +128,9 @@ namespace Tizen.Content.MediaContent get { string genre = ""; - int result = Interop.AudioInformation.GetGenre(_handle, out genre); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetGenre(_handle, out genre), "Failed to get value"); + if (genre == null) { genre = ""; @@ -159,11 +149,9 @@ namespace Tizen.Content.MediaContent get { string composer = ""; - int result = Interop.AudioInformation.GetComposer(_handle, out composer); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetComposer(_handle, out composer), "Failed to get value"); + if (composer == null) { composer = ""; @@ -182,11 +170,9 @@ namespace Tizen.Content.MediaContent get { string year = ""; - int result = Interop.AudioInformation.GetYear(_handle, out year); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetYear(_handle, out year), "Failed to get value"); + if (year == null) { year = ""; @@ -203,11 +189,9 @@ namespace Tizen.Content.MediaContent get { string recordedDate = ""; - int result = Interop.AudioInformation.GetRecordedDate(_handle, out recordedDate); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetRecordedDate(_handle, out recordedDate), "Failed to get value"); + if (recordedDate == null) { recordedDate = ""; @@ -225,11 +209,9 @@ namespace Tizen.Content.MediaContent get { string copyright = ""; - int result = Interop.AudioInformation.GetCopyright(_handle, out copyright); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetCopyright(_handle, out copyright), "Failed to get value"); + if (copyright == null) { copyright = ""; @@ -247,11 +229,9 @@ namespace Tizen.Content.MediaContent get { string trackNumber = ""; - int result = Interop.AudioInformation.GetTrackNum(_handle, out trackNumber); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetTrackNum(_handle, out trackNumber), "Failed to get value"); + if (trackNumber == null) { trackNumber = ""; @@ -268,11 +248,9 @@ namespace Tizen.Content.MediaContent get { int bitrate = 0; - int result = Interop.AudioInformation.GetBitRate(_handle, out bitrate); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetBitRate(_handle, out bitrate), "Failed to get value"); + return bitrate; } } @@ -285,11 +263,9 @@ namespace Tizen.Content.MediaContent get { int bitPerSample = 0; - int result = Interop.AudioInformation.GetBitPerSample(_handle, out bitPerSample); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetBitPerSample(_handle, out bitPerSample), "Failed to get value"); + return bitPerSample; } } @@ -302,11 +278,9 @@ namespace Tizen.Content.MediaContent get { int sampleRate = 0; - int result = Interop.AudioInformation.GetSampleRate(_handle, out sampleRate); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetSampleRate(_handle, out sampleRate), "Failed to get value"); + return sampleRate; } } @@ -319,11 +293,9 @@ namespace Tizen.Content.MediaContent get { int channel = 0; - int result = Interop.AudioInformation.GetChannel(_handle, out channel); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetChannel(_handle, out channel), "Failed to get value"); + return channel; } } @@ -336,11 +308,9 @@ namespace Tizen.Content.MediaContent get { int duration = 0; - int result = Interop.AudioInformation.GetDuration(_handle, out duration); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.AudioInformation.GetDuration(_handle, out duration), "Failed to get value"); + return duration; } } @@ -356,11 +326,9 @@ namespace Tizen.Content.MediaContent { int count = 0; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError result = (MediaContentError)Interop.MediaInformation.GetBookmarkCount(MediaId, handle, out count); - if (result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(result, "Error Occured with error code: "); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetBookmarkCount(MediaId, handle, out count), "Failed to get count"); + return count; } @@ -375,26 +343,21 @@ namespace Tizen.Content.MediaContent public Task<IEnumerable<MediaBookmark>> GetMediaBookmarksAsync(ContentFilter filter) { var task = new TaskCompletionSource<IEnumerable<MediaBookmark>>(); - MediaContentError result; + Collection<MediaBookmark> coll = new Collection<MediaBookmark>(); IntPtr filterHandle = (filter != null) ? filter.Handle : IntPtr.Zero; - Interop.MediaInformation.MediaBookmarkCallback bookmarksCallback = (IntPtr handle, IntPtr userData) => + Interop.MediaInformation.MediaBookmarkCallback callback = (IntPtr handle, IntPtr userData) => { IntPtr newHandle; - result = (MediaContentError)Interop.MediaBookmark.Clone(out newHandle, handle); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Failed to clone Tag"); - } - MediaBookmark bookmark = new MediaBookmark(newHandle); - coll.Add(bookmark); + MediaContentRetValidator.ThrowIfError( + Interop.MediaBookmark.Clone(out newHandle, handle), "Failed to clone"); + + coll.Add(new MediaBookmark(newHandle)); return true; }; - result = (MediaContentError)Interop.MediaInformation.GetAllBookmarks(MediaId, filterHandle, bookmarksCallback, IntPtr.Zero); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetAllBookmarks(MediaId, filterHandle, callback, IntPtr.Zero), "Failed to get value"); + task.SetResult(coll); return task.Task; } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentDatabase.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentDatabase.cs index 5813e96..b6b6892 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentDatabase.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentDatabase.cs @@ -51,11 +51,8 @@ namespace Tizen.Content.MediaContent { if (!_isConnected) { - MediaContentError err = (MediaContentError)Interop.Content.Connect(); - if (err != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(err, "failed to connect to db."); - } + MediaContentRetValidator.ThrowIfError(Interop.Content.Connect(), "Connect failed"); + _isConnected = true; } } @@ -63,11 +60,8 @@ namespace Tizen.Content.MediaContent { if (_isConnected) { - MediaContentError err = (MediaContentError)Interop.Content.Disconnect(); - if (err != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(err, "failed to disconnect to db."); - } + MediaContentRetValidator.ThrowIfError(Interop.Content.Disconnect(), "Disconnect failed"); + _isConnected = false; } } @@ -89,11 +83,8 @@ namespace Tizen.Content.MediaContent { if (s_contentUpdated == null) { - MediaContentError ret = (MediaContentError)Interop.Content.SetDbUpdatedCb(s_contentUpdatedCallback, IntPtr.Zero); - if (ret != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(ret, "Error in callback handling"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Content.SetDbUpdatedCb(s_contentUpdatedCallback, IntPtr.Zero), "Failed to set callback"); } s_contentUpdated += value; } @@ -103,11 +94,8 @@ namespace Tizen.Content.MediaContent s_contentUpdated -= value; if (s_contentUpdated == null) { - MediaContentError ret = (MediaContentError)Interop.Content.UnsetDbUpdatedCb(); - if (ret != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(ret, "Error in callback handling"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Content.UnsetDbUpdatedCb(), "Failed to unset callback"); } } } @@ -165,10 +153,8 @@ namespace Tizen.Content.MediaContent res = MediaContentError.InvalidParameter; } - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to get count for the content"); - } + MediaContentRetValidator.ThrowIfError(res, "Failed to get count for the content"); + return count; } @@ -179,15 +165,12 @@ namespace Tizen.Content.MediaContent /// <returns>MediaInformation instance for the associated id.It throws Exception for invalid Id.</returns> public MediaInformation Select(string id) { - MediaContentError error = MediaContentError.None; ConnectToDB(); MediaInformation result; Interop.MediaInformation.SafeMediaInformationHandle mediaHandle; - error = (MediaContentError)Interop.MediaInformation.GetMediaFromDB(id, out mediaHandle); - if (error != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(error, "Failed to get the media information from the database"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetMediaFromDB(id, out mediaHandle), "Failed to get information"); + result = new MediaInformation(mediaHandle); return result; } @@ -200,28 +183,23 @@ namespace Tizen.Content.MediaContent /// <returns>ContentCollection instance for the associated id.It throws Exception for invalid Id.</returns> public T Select<T>(string id) where T : ContentCollection { - MediaContentError error = MediaContentError.None; ConnectToDB(); ContentCollection result = null; if (typeof(T) == typeof(MediaFolder)) { IntPtr handle = IntPtr.Zero; - error = (MediaContentError)Interop.Folder.GetFolderFromDb(id, out handle); - if (error != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(error, "Failed to get the content collection"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.GetFolderFromDb(id, out handle), "Failed to get information"); + if (handle != IntPtr.Zero) result = new MediaFolder(handle); } else if (typeof(T) == typeof(Storage)) { IntPtr handle = IntPtr.Zero; - error = (MediaContentError)Interop.Storage.GetStorageInfoFromDb(id, out handle); - if (error != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(error, "Failed to get the content collection"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Storage.GetStorageInfoFromDb(id, out handle), "Failed to get information"); + if (handle != IntPtr.Zero) { result = new Storage(handle); @@ -240,39 +218,29 @@ namespace Tizen.Content.MediaContent public T Select<T>(int id) where T : ContentCollection { ConnectToDB(); - MediaContentError res = MediaContentError.None; ContentCollection contentCollection = null; IntPtr _handle; if (typeof(T) == typeof(PlayList)) { - res = (MediaContentError)Interop.Playlist.GetPlaylistFromDb(id, out _handle); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to get the content collection"); - throw MediaContentErrorFactory.CreateException(res, "Failed to get the content collection"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.GetPlaylistFromDb(id, out _handle), "Failed to get information"); + if (_handle != IntPtr.Zero) contentCollection = new PlayList(_handle); } else if (typeof(T) == typeof(Album)) { - res = (MediaContentError)Interop.Group.MediaAlbumGetAlbumFromDb(id, out _handle); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to get the content collection"); - throw MediaContentErrorFactory.CreateException(res, "Failed to get the content collection"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Group.MediaAlbumGetAlbumFromDb(id, out _handle), "Failed to get information"); + if (_handle != IntPtr.Zero) contentCollection = new Album(_handle); } else if (typeof(T) == typeof(Tag)) { - res = (MediaContentError)Interop.Tag.GetTagFromDb(id, out _handle); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to get the content collection"); - throw MediaContentErrorFactory.CreateException(res, "Failed to get the content collection"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.GetTagFromDb(id, out _handle), "Failed to get information"); + if (_handle != IntPtr.Zero) contentCollection = new Tag(_handle); } @@ -281,54 +249,39 @@ namespace Tizen.Content.MediaContent private static IEnumerable<MediaFolder> ForEachFolder(ContentFilter filter) { - MediaContentError res = MediaContentError.None; List<MediaFolder> folderCollections = new List<MediaFolder>(); Interop.Folder.MediaFolderCallback folderCallback = (IntPtr folderHandle, IntPtr data) => { IntPtr newHandle; - res = (MediaContentError)Interop.Folder.Clone(out newHandle, folderHandle); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get path for the MediaFolder " + res); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.Clone(out newHandle, folderHandle), "Failed to clone"); - MediaFolder folder = new MediaFolder(newHandle); - folderCollections.Add(folder); + folderCollections.Add(new MediaFolder(newHandle)); return true; }; IntPtr filterHandle = filter != null ? filter.Handle : IntPtr.Zero; - res = (MediaContentError)Interop.Folder.ForeachFolderFromDb(filterHandle, folderCallback, IntPtr.Zero); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to get content collections from the database"); - throw MediaContentErrorFactory.CreateException(res, "Failed to get content collections from the database"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.ForeachFolderFromDb(filterHandle, folderCallback, IntPtr.Zero), "Failed to get information"); + return folderCollections; } private static IEnumerable<Album> ForEachAlbum(ContentFilter filter) { - MediaContentError res = MediaContentError.None; List<Album> albumCollections = new List<Album>(); Interop.Group.MediaAlbumCallback albumCallback = (IntPtr albumHandle, IntPtr data) => { - IntPtr newHandle; - res = (MediaContentError)Interop.Group.MediaAlbumClone(out newHandle, albumHandle); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get path for the MediaFolder " + res); - } + IntPtr newHandle = IntPtr.Zero; + MediaContentRetValidator.ThrowIfError( + Interop.Group.MediaAlbumClone(out newHandle, albumHandle), "Failed to clone"); albumCollections.Add(new Album(newHandle)); return true; }; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - res = (MediaContentError)Interop.Group.MediaAlbumForeachAlbumFromDb(handle, albumCallback, IntPtr.Zero); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to get content collections from the database"); - throw MediaContentErrorFactory.CreateException(res, "Failed to get content collections from the database"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Group.MediaAlbumForeachAlbumFromDb(handle, albumCallback, IntPtr.Zero), "Failed to get information"); + return albumCollections; } @@ -340,100 +293,79 @@ namespace Tizen.Content.MediaContent { groupType = MediaGroupType.DisplayName; } - else { + else + { groupType = filter.GroupType; } - MediaContentError res = MediaContentError.None; + List<Group> groupCollections = new List<Group>(); Interop.Group.MediaGroupCallback groupCallback = (string groupName, IntPtr data) => { groupCollections.Add(new Group(groupName, groupType)); return true; }; - res = (MediaContentError)Interop.Group.ForeachGroupFromDb(handle, groupType, groupCallback, IntPtr.Zero); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to get content collections from the database"); - throw MediaContentErrorFactory.CreateException(res, "Failed to get content collections from the database"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Group.ForeachGroupFromDb(handle, groupType, groupCallback, IntPtr.Zero), "Failed to get information"); + return groupCollections; } private static IEnumerable<Storage> ForEachStorage(ContentFilter filter) { IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res = MediaContentError.None; List<Storage> storageCollections = new List<Storage>(); Interop.Storage.MediaStorageCallback storageCallback = (IntPtr storageHandle, IntPtr data) => { IntPtr newHandle; - res = (MediaContentError)Interop.Storage.Clone(out newHandle, storageHandle); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to clone storage handle"); - throw MediaContentErrorFactory.CreateException(res, "Failed to clone storage handle"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Storage.Clone(out newHandle, storageHandle), "Failed to clone"); + storageCollections.Add(new Storage(newHandle)); return true; }; - res = (MediaContentError)Interop.Storage.ForeachStorageFromDb(handle, storageCallback, IntPtr.Zero); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to get content collections from the database"); - throw MediaContentErrorFactory.CreateException(res, "Failed to get content collections from the database"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Storage.ForeachStorageFromDb(handle, storageCallback, IntPtr.Zero), "Failed to get information"); + return storageCollections; } private static IEnumerable<Tag> ForEachTag(ContentFilter filter) { IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res = MediaContentError.None; + List<Tag> tagCollections = new List<Tag>(); Interop.Tag.MediaTagCallback tagCallback = (IntPtr tagHandle, IntPtr data) => { IntPtr newHandle; - res = (MediaContentError)Interop.Tag.Clone(out newHandle, tagHandle); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get path for the MediaFolder " + res); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.Clone(out newHandle, tagHandle), "Failed to clone"); tagCollections.Add(new Tag(newHandle)); return true; }; - res = (MediaContentError)Interop.Tag.ForeachTagFromDb(handle, tagCallback, IntPtr.Zero); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to get content collections from the database"); - throw MediaContentErrorFactory.CreateException(res, "Failed to get content collections from the database"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.ForeachTagFromDb(handle, tagCallback, IntPtr.Zero), "Failed to get information"); + return tagCollections; } private static IEnumerable<PlayList> ForEachPlayList(ContentFilter filter) { IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res = MediaContentError.None; + List<PlayList> playListCollections = new List<PlayList>(); Interop.Playlist.MediaPlaylistCallback playListCallback = (IntPtr playListHandle, IntPtr data) => { IntPtr newHandle; - res = (MediaContentError)Interop.Tag.Clone(out newHandle, playListHandle); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get path for the MediaFolder " + res); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.Clone(out newHandle, playListHandle), "Failed to clone"); playListCollections.Add(new PlayList(newHandle)); return true; }; - res = (MediaContentError)Interop.Playlist.ForeachPlaylistFromDb(handle, playListCallback, IntPtr.Zero); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to get content collections from the database"); - throw MediaContentErrorFactory.CreateException(res, "Failed to get content collections from the database"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.ForeachPlaylistFromDb(handle, playListCallback, IntPtr.Zero), "Failed to get information"); + return playListCollections; } @@ -496,86 +428,49 @@ namespace Tizen.Content.MediaContent private IEnumerable<MediaInformation> GetMediaInformations(ContentFilter filter) { ConnectToDB(); - MediaContentError result; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; List<MediaInformation> mediaInformationList = new List<MediaInformation>(); Interop.MediaInformation.MediaInformationCallback callback = (IntPtr mediaHandle, IntPtr userData) => { Interop.MediaInformation.SafeMediaInformationHandle newHandle; - result = (MediaContentError)Interop.MediaInformation.Clone(out newHandle, mediaHandle); - if (result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(result, "Failed to clone media"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone"); MediaContentType type; Interop.MediaInformation.GetMediaType(newHandle, out type); if (type == MediaContentType.Image) { Interop.ImageInformation.SafeImageInformationHandle imageInfo; - result = (MediaContentError)Interop.MediaInformation.GetImage(mediaHandle, out imageInfo); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } - if (imageInfo != null) - { - MediaInformation info = new ImageInformation(imageInfo, newHandle); - mediaInformationList.Add(info); - } - else - { - throw MediaContentErrorFactory.CreateException(MediaContentError.InvalidParameter, "Could not find the Image Information"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetImage(mediaHandle, out imageInfo), "Failed to get image information"); + + mediaInformationList.Add(new ImageInformation(imageInfo, newHandle)); } else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound)) { Interop.AudioInformation.SafeAudioInformationHandle audioInfo; - result = (MediaContentError)Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } - if (audioInfo != null) - { - MediaInformation info = new AudioInformation(audioInfo, newHandle); - mediaInformationList.Add(info); - } - else - { - throw MediaContentErrorFactory.CreateException(MediaContentError.InvalidParameter, "Could not find the Audio Information"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo), "Failed to get audio information"); + + mediaInformationList.Add(new AudioInformation(audioInfo, newHandle)); } else if (type == MediaContentType.Video) { - Interop.VideoInformation.SafeVideoInformationHandle audioInfo; - result = (MediaContentError)Interop.MediaInformation.GetVideo(mediaHandle, out audioInfo); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } - if (audioInfo != null) - { - MediaInformation info = new VideoInformation(audioInfo, newHandle); - mediaInformationList.Add(info); - } - else - { - throw MediaContentErrorFactory.CreateException(MediaContentError.InvalidParameter, "Could not find the Audio Information"); - } + Interop.VideoInformation.SafeVideoInformationHandle videoInfo; + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetVideo(mediaHandle, out videoInfo), "Failed to get video information"); + + mediaInformationList.Add(new VideoInformation(videoInfo, newHandle)); } else if (type == MediaContentType.Others) { - MediaInformation info = new MediaInformation(newHandle); - mediaInformationList.Add(info); + mediaInformationList.Add(new MediaInformation(newHandle)); } return true; }; - result = (MediaContentError)Interop.MediaInformation.GetAllMedia(handle, callback, IntPtr.Zero); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Failed to get media information from the database"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetAllMedia(handle, callback, IntPtr.Zero), "Failed to get media information"); + return mediaInformationList; } @@ -586,9 +481,8 @@ namespace Tizen.Content.MediaContent public void Delete(MediaInformation mediaInfo) { ConnectToDB(); - MediaContentError result = (MediaContentError)Interop.MediaInformation.Delete(mediaInfo.MediaId); - if (result != MediaContentError.None) - throw MediaContentErrorFactory.CreateException(result, "failed to Delete bookmark from DB"); + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.Delete(mediaInfo.MediaId), "Failed to remove information"); } @@ -602,39 +496,35 @@ namespace Tizen.Content.MediaContent { ConnectToDB(); Type type = contentcollection.GetType(); - MediaContentError result = MediaContentError.None; + if (type == typeof(Tag)) { - result = (MediaContentError)Interop.Tag.DeleteFromDb(((Tag)contentcollection).Id); + MediaContentRetValidator.ThrowIfError( + Interop.Tag.DeleteFromDb(((Tag)contentcollection).Id), "Failed to remove information"); } else if (type == typeof(PlayList)) { - result = (MediaContentError)Interop.Playlist.DeleteFromDb(((PlayList)contentcollection).Id); + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.DeleteFromDb(((PlayList)contentcollection).Id), "Failed to remove information"); } else { - result = MediaContentError.InvalidParameter; + throw new ArgumentException("The type of content collection is wrong"); } - if (result != MediaContentError.None) - throw MediaContentErrorFactory.CreateException(result, "failed to Delete ContentCollection from DB"); } internal void Delete(MediaBookmark bookmark) { ConnectToDB(); - MediaContentError result = MediaContentError.None; - result = (MediaContentError)Interop.MediaBookmark.DeleteFromDb(bookmark.Id); - if (result != MediaContentError.None) - throw MediaContentErrorFactory.CreateException(result, "failed to Delete bookmark from DB"); + MediaContentRetValidator.ThrowIfError( + Interop.MediaBookmark.DeleteFromDb(bookmark.Id), "Failed to remove information"); } internal void Delete(MediaFace face) { ConnectToDB(); - MediaContentError result = MediaContentError.None; - result = (MediaContentError)Interop.Face.DeleteFromDb(face.Id); - if (result != MediaContentError.None) - throw MediaContentErrorFactory.CreateException(result, "failed to Delete face from DB"); + MediaContentRetValidator.ThrowIfError( + Interop.Face.DeleteFromDb(face.Id), "Failed to remove face information"); } /// <summary> @@ -664,8 +554,7 @@ namespace Tizen.Content.MediaContent result = MediaContentError.InvalidParameter; } - if (result != MediaContentError.None) - throw MediaContentErrorFactory.CreateException(result, "Failed to update DB"); + MediaContentRetValidator.ThrowIfError(result, "Failed to update DB"); } /// <summary> @@ -698,17 +587,14 @@ namespace Tizen.Content.MediaContent result = MediaContentError.InvalidOperation; } - if (result != MediaContentError.None) - throw MediaContentErrorFactory.CreateException(result, "Failed to update DB"); + MediaContentRetValidator.ThrowIfError(result, "Failed to update DB"); } internal void Update(MediaFace face) { ConnectToDB(); - MediaContentError result = (MediaContentError)Interop.Face.UpdateToDb(face.Handle); - if (result != MediaContentError.None) - throw MediaContentErrorFactory.CreateException(result, "Failed to update DB"); + MediaContentRetValidator.ThrowIfError(Interop.Face.UpdateToDb(face.Handle), "Failed to update DB"); } /// <summary> @@ -738,30 +624,21 @@ namespace Tizen.Content.MediaContent Console.WriteLine("Inalid insert"); result = MediaContentError.InvalidParameter; } - if (result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(result, "Failed to insert collection to the database"); - } + MediaContentRetValidator.ThrowIfError(result, "Failed to insert collection to the database"); } internal void Insert(string mediaId, uint offset, string thumbnailPath) { ConnectToDB(); - MediaContentError result = (MediaContentError)Interop.MediaBookmark.InsertToDb(mediaId, offset, thumbnailPath); - if (result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(result, "Failed to insert bookmark to the database"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaBookmark.InsertToDb(mediaId, offset, thumbnailPath), "Failed to insert information"); } internal void Insert(MediaFace face) { ConnectToDB(); - MediaContentError result = (MediaContentError)Interop.Face.InsertToDb(((MediaFace)face).Handle); - if (result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(result, "Failed to insert collection to the database"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Face.InsertToDb(((MediaFace)face).Handle), "Failed to insert information"); } } } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentFilter.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentFilter.cs index 653e717..7e09f23 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentFilter.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentFilter.cs @@ -120,34 +120,21 @@ namespace Tizen.Content.MediaContent { int offset; int count; - MediaContentError res; - res = (MediaContentError)Interop.Filter.GetOffset(_filterHandle, out offset, out count); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to Get offset"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to Get offset"); + return offset; } set { - //TOD: check if we can convert this as method to club offset and count. - MediaContentError res; - res = (MediaContentError)Interop.Filter.SetOffset(_filterHandle, value, this.Count); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to Setoffset"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.SetOffset(_filterHandle, value, this.Count), "Failed to Set offset"); } } public ContentFilter() { - MediaContentError res; - res = (MediaContentError)Interop.Filter.Create(out _filterHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to Create Filter handle."); - } - //res = (MediaContentError)Interop.Filter.SetOrder(_filterHandle,(int) _order, _orderKey, (int) _collationType); + MediaContentRetValidator.ThrowIfError( + Interop.Filter.Create(out _filterHandle), "Failed to Create Filter handle."); } /// <summary> /// The number of items to be searched with respect to the offset @@ -158,23 +145,15 @@ namespace Tizen.Content.MediaContent { int offset; int count; - MediaContentError res; - res = (MediaContentError)Interop.Filter.GetOffset(_filterHandle, out offset, out count); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to Getoffset/count"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to Getoffset/count"); + return count; } set { - //TOD: check if we can convert this as method to club offset and count. - MediaContentError res; - res = (MediaContentError)Interop.Filter.SetOffset(_filterHandle, this.Offset, value); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to Setoffset/Count"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.SetOffset(_filterHandle, this.Offset, value), "Failed to Setoffset/Count"); } } /// <summary> @@ -187,12 +166,9 @@ namespace Tizen.Content.MediaContent int orderType; string orderKey; int collatetType; - MediaContentError res; - res = (MediaContentError)Interop.Filter.GetOrder(_filterHandle, out orderType, out orderKey, out collatetType); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to GetOrder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.GetOrder(_filterHandle, out orderType, out orderKey, out collatetType), "Failed to GetOrder"); + return (ContentOrder)orderType; } } @@ -203,28 +179,18 @@ namespace Tizen.Content.MediaContent { get { - //check If we can create multiple variables in a property itself.. - //Guess.. This might be need to change as method. string condition; int collatetType; - MediaContentError res; - res = (MediaContentError)Interop.Filter.GetCondition(_filterHandle, out condition, out collatetType); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to GetCondition for CollationType"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.GetCondition(_filterHandle, out condition, out collatetType), "Failed to GetCondition for CollationType"); + return (ContentCollation)collatetType; } set { _collationType = value; - //TOD: check if we can convert this as method to club offset and count. - MediaContentError res; - res = (MediaContentError)Interop.Filter.SetCondition(_filterHandle, this.Condition, (int)value); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to SetCondition for CollationType"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.SetCondition(_filterHandle, this.Condition, (int)value), "Failed to SetCondition for CollationType"); } } /// <summary> @@ -235,25 +201,16 @@ namespace Tizen.Content.MediaContent get { string conditionVal = ""; - MediaContentError res; int collatetType; - res = (MediaContentError)Interop.Filter.GetCondition(_filterHandle, out conditionVal, out collatetType); - _collationType = (ContentCollation)collatetType; - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to GetCondition"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.GetCondition(_filterHandle, out conditionVal, out collatetType), "Failed to GetCondition"); + return conditionVal; } set { - //TOD: check if we can convert this as method to club offset and count. - MediaContentError res; - res = (MediaContentError)Interop.Filter.SetCondition(_filterHandle, value, (int)_collationType); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to SetCondition"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.SetCondition(_filterHandle, value, (int)_collationType), "Failed to SetCondition"); } } /// <summary> @@ -264,26 +221,16 @@ namespace Tizen.Content.MediaContent { get { - //check If we can create multiple variables in a property itself.. - //Guess.. This might be need to change as method. string storageId; - MediaContentError res; - res = (MediaContentError)Interop.Filter.GetStorage(_filterHandle, out storageId); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to GetCondition"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.GetStorage(_filterHandle, out storageId), "Failed to GetCondition"); + return storageId; } set { - //TOD: check if we can convert this as method to club offset and count. - MediaContentError res; - res = (MediaContentError)Interop.Filter.SetStorage(_filterHandle, value); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to SetCondition"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.SetStorage(_filterHandle, value), "Failed to SetCondition"); } } /// <summary> @@ -296,12 +243,9 @@ namespace Tizen.Content.MediaContent int orderType; string orderKey; int collatetType; - MediaContentError res; - res = (MediaContentError)Interop.Filter.GetOrder(_filterHandle, out orderType, out orderKey, out collatetType); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to GetOrder for OrderKey"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.GetOrder(_filterHandle, out orderType, out orderKey, out collatetType), "Failed to GetOrder for OrderKey"); + return orderKey; } } @@ -317,11 +261,8 @@ namespace Tizen.Content.MediaContent /// </summary> public void SetOrderProperties(ContentOrder order, string oderKey) { - MediaContentError res = (MediaContentError)Interop.Filter.SetOrder(_filterHandle, order, oderKey, CollationType); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to SetOrder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Filter.SetOrder(_filterHandle, order, oderKey, CollationType), "Failed to SetOrder"); } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentManager.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentManager.cs index 19e6f09..8853246 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentManager.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentManager.cs @@ -73,11 +73,8 @@ namespace Tizen.Content.MediaContent public static void Scan(string filePath) { Database.ConnectToDB(); - MediaContentError result = (MediaContentError)Interop.Content.ScanFile(filePath); - if (result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(result, "Failed scan"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Content.ScanFile(filePath), "Failed scan"); } /// <summary> @@ -86,17 +83,12 @@ namespace Tizen.Content.MediaContent /// <param name="filePath">File path of the media to be inserted</param> public static MediaInformation AddMediaInformation(string filePath) { - MediaInformation mediaInformation = null; Database.ConnectToDB(); Interop.MediaInformation.SafeMediaInformationHandle mediaInformationHandle; - //TODO: verify the usage of MediaInformation._handle.DangerousGetHandle() - MediaContentError result = (MediaContentError)Interop.MediaInformation.Insert(filePath, out mediaInformationHandle); - if (result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(result, "Failed to Insert MediaInformation to DB"); - } - mediaInformation = new MediaInformation(mediaInformationHandle); - return mediaInformation; + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.Insert(filePath, out mediaInformationHandle), "Failed to Insert MediaInformation to DB"); + + return new MediaInformation(mediaInformationHandle); } /// <summary> @@ -115,27 +107,11 @@ namespace Tizen.Content.MediaContent Interop.Content.MediaScanCompletedCallback scanCompleted = (MediaContentError scanResult, IntPtr data) => { - if (scanResult != MediaContentError.None) - { - task.SetException(MediaContentErrorFactory.CreateException(scanResult, "Failed scan")); - } + MediaContentRetValidator.ThrowIfError(scanResult, "Failed to scan"); task.SetResult((int)scanResult); }; - DirectoryInfo dir = new DirectoryInfo(Path.GetFullPath(folderPath)); - MediaContentError result = MediaContentError.None; - if (dir.Exists) - { - result = (MediaContentError)Interop.Content.ScanFolder(folderPath, recursive, scanCompleted, IntPtr.Zero); - } - else - { - result = MediaContentError.InvalidParameter; - task.SetException(MediaContentErrorFactory.CreateException(result, "Scan directory does not exist")); - } - if (result != MediaContentError.None) - { - task.SetException(MediaContentErrorFactory.CreateException(result, "Failed scan")); - } + MediaContentRetValidator.ThrowIfError(Interop.Content.ScanFolder(folderPath, recursive, scanCompleted, IntPtr.Zero), "Failed to scan"); + return task.Task; } @@ -159,78 +135,33 @@ namespace Tizen.Content.MediaContent cancellationToken.Register(() => { - Tizen.Log.Info("TCT", "Register ThreadId: " + Thread.CurrentThread.ManagedThreadId); - lock (l) { - Tizen.Log.Info("TCT", "Cancellation delegate: Taking Lock on l"); if (!taskCompleted) { taskCompleted = true; - Log.Info("TCT", "Cancellation requested, Trying to stop scan"); - MediaContentError res = (MediaContentError)Interop.Content.CancelScanFolder(folderPath); - Log.Info("TCT", "CancelScanFolder executed. "); + MediaContentRetValidator.ThrowIfError( + Interop.Content.CancelScanFolder(folderPath), "Failed CancelScanFolder"); - if (res != MediaContentError.None) - { - Tizen.Log.Info("TCT", "Failed CancelScanFolder. Error: " + res); - } - else { - Tizen.Log.Info("TCT", "Folder scan was successfully cancelled. CancelScanFolder was successfully executed."); - task.SetCanceled(); - } - } - else { - Tizen.Log.Info("TCT", "Request rejected. FolderScan already completed"); + task.SetCanceled(); } - Tizen.Log.Info("TCT", "Cancellation delegate: Releasing lock on l"); } }); scanCompletedWithToken = (MediaContentError scanResult, IntPtr data) => { - Tizen.Log.Info("TCT", "Scan Callback ScanResult: " + scanResult); - Tizen.Log.Info("TCT", "Scan Callback ThreadId: " + Thread.CurrentThread.ManagedThreadId); lock (l) { - Tizen.Log.Info("TCT", "Scan completed cb: Taking Lock on l"); if (!taskCompleted) { taskCompleted = true; - Tizen.Log.Info("TCT", "Scan folder callback recieved."); - if (scanResult != MediaContentError.None) - { - Tizen.Log.Info("TCT", "Scan folder callback got error in scanResult. Error: " + scanResult); - task.SetException(MediaContentErrorFactory.CreateException(scanResult, "Failed scan")); - } - Tizen.Log.Info("TCT", "Scan folder callback does not have any error"); - + MediaContentRetValidator.ThrowIfError(scanResult, "Failed scan"); task.SetResult((int)scanResult); } - else { - Tizen.Log.Info("TCT", "ScanFolder task already cancelled/completed"); - } - Tizen.Log.Info("TCT", "Scan completed cb: Releasing Lock on l"); } }; - DirectoryInfo dir = new DirectoryInfo(Path.GetFullPath(folderPath)); - MediaContentError result = MediaContentError.None; - if (dir.Exists) - { - Tizen.Log.Info("TCT", "Scan folder start"); - result = (MediaContentError)Interop.Content.ScanFolder(folderPath, recursive, scanCompletedWithToken, IntPtr.Zero); - Tizen.Log.Info("TCT", "Scan folder end"); - } - else - { - result = MediaContentError.InvalidParameter; - task.SetException(MediaContentErrorFactory.CreateException(result, "Scan directory does not exist")); - } - if (result != MediaContentError.None) - { - task.SetException(MediaContentErrorFactory.CreateException(result, "Failed scan: " + result)); - } - Tizen.Log.Info("TCT", "Before task return"); + MediaContentRetValidator.ThrowIfError( + Interop.Content.ScanFolder(folderPath, recursive, scanCompletedWithToken, IntPtr.Zero), "Failed to scan"); return task.Task; @@ -246,20 +177,14 @@ namespace Tizen.Content.MediaContent Database.ConnectToDB(); var task = new TaskCompletionSource<int>(); string[] paths = ((List<string>)filePaths).ToArray(); - MediaContentError res = MediaContentError.None; Interop.MediaInformation.MediaInsertCompletedCallback callback = (MediaContentError error, IntPtr userData) => { - if (error != MediaContentError.None) - { - task.SetException(MediaContentErrorFactory.CreateException(error, "Failed to add batch media")); - } + MediaContentRetValidator.ThrowIfError(error, "Failed to batch insert"); task.SetResult((int)error); }; - res = (MediaContentError)Interop.MediaInformation.BatchInsert(paths, paths.Length, callback, IntPtr.Zero); - if (res != MediaContentError.None) - { - task.SetException(MediaContentErrorFactory.CreateException(res, "Failed to add batch media")); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.BatchInsert(paths, paths.Length, callback, IntPtr.Zero), "Failed to add batch media"); + return task.Task; } @@ -273,20 +198,14 @@ namespace Tizen.Content.MediaContent Database.ConnectToDB(); var task = new TaskCompletionSource<int>(); string[] paths = ((List<string>)filePaths).ToArray(); - MediaContentError res = MediaContentError.None; Interop.MediaInformation.MediaInsertBurstShotCompletedCallback callback = (MediaContentError error, IntPtr userData) => { - if (error != MediaContentError.None) - { - task.SetException(MediaContentErrorFactory.CreateException(error, "Failed to add burst shots to db")); - } + MediaContentRetValidator.ThrowIfError(error, "Failed to add burstshot"); task.SetResult((int)error); }; - res = (MediaContentError)Interop.MediaInformation.BurstShotInsert(paths, paths.Length, callback, IntPtr.Zero); - if (res != MediaContentError.None) - { - task.SetException(MediaContentErrorFactory.CreateException(res, "Failed to add burst shots to db")); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.BurstShotInsert(paths, paths.Length, callback, IntPtr.Zero), "Failed to add burst shots to db"); + return task.Task; } @@ -301,13 +220,8 @@ namespace Tizen.Content.MediaContent { Database.ConnectToDB(); var task = new TaskCompletionSource<int>(); - MediaContentError res = MediaContentError.None; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - res = (MediaContentError)Interop.MediaInformation.BatchDelete(handle); - if (res != MediaContentError.None) - { - task.SetException(MediaContentErrorFactory.CreateException(res, "Failed to delete batch media from db")); - } + MediaContentError res = Interop.MediaInformation.BatchDelete(handle); task.SetResult((int)res); return task.Task; } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Group.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Group.cs index 1d6c7a5..beca4e9 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Group.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Group.cs @@ -68,11 +68,9 @@ namespace Tizen.Content.MediaContent { int mediaCount = 0; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res = (MediaContentError)Interop.Group.GetMediaCountFromDb(Name, _groupType, handle, out mediaCount); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to GetMediaCountFromDb"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Group.GetMediaCountFromDb(Name, _groupType, handle, out mediaCount), "Failed to GetMediaCountFromDb"); + return mediaCount; } @@ -89,24 +87,18 @@ namespace Tizen.Content.MediaContent var tcs = new TaskCompletionSource<IEnumerable<MediaInformation>>(); List<MediaInformation> mediaContents = new List<MediaInformation>(); IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res = MediaContentError.None; Interop.Group.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) => { Interop.MediaInformation.SafeMediaInformationHandle newHandle; - res = (MediaContentError)Interop.MediaInformation.Clone(out newHandle, mediaHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to clone MediaInformation instance"); - } - MediaInformation info = new MediaInformation(newHandle); - mediaContents.Add(info); + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone MediaInformation instance"); + + mediaContents.Add(new MediaInformation(newHandle)); return true; }; - res = (MediaContentError)Interop.Group.ForeachMediaFromDb(Name, _groupType, handle, callback, IntPtr.Zero); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to get media information for the group"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Group.ForeachMediaFromDb(Name, _groupType, handle, callback, IntPtr.Zero), "Failed to get media information for the group"); + tcs.TrySetResult(mediaContents); return tcs.Task; } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ImageInformation.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ImageInformation.cs index 189f0d5..3059a09 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ImageInformation.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ImageInformation.cs @@ -39,11 +39,9 @@ namespace Tizen.Content.MediaContent get { string mediaId = ""; - int result = Interop.ImageInformation.GetMediaId(_handle, out mediaId); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.GetMediaId(_handle, out mediaId), "Failed to get value"); + if (mediaId == null) { mediaId = ""; @@ -60,11 +58,9 @@ namespace Tizen.Content.MediaContent get { int width = 0; - int result = Interop.ImageInformation.GetWidth(_handle, out width); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.GetWidth(_handle, out width), "Failed to get value"); + return width; } } @@ -77,11 +73,9 @@ namespace Tizen.Content.MediaContent get { int height = 0; - int result = Interop.ImageInformation.GetHeight(_handle, out height); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.GetHeight(_handle, out height), "Failed to get value"); + return height; } } @@ -94,21 +88,15 @@ namespace Tizen.Content.MediaContent get { MediaContentOrientation orientation = MediaContentOrientation.NotAvailable; - int result = Interop.ImageInformation.GetOrientation(_handle, out orientation); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } - Tizen.Log.Info(Globals.LogTag, "Orientation Recieved " + orientation); + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.GetOrientation(_handle, out orientation), "Failed to get value"); + return orientation; } set { - int result = Interop.ImageInformation.SetOrientation(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "Failed to Setorientation"); - } + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.SetOrientation(_handle, value), "Failed to set value"); } } @@ -120,11 +108,9 @@ namespace Tizen.Content.MediaContent get { string takenDate = ""; - int result = Interop.ImageInformation.GetDateTaken(_handle, out takenDate); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.GetDateTaken(_handle, out takenDate), "Failed to get value"); + if (takenDate == null) { takenDate = ""; @@ -142,11 +128,9 @@ namespace Tizen.Content.MediaContent get { string burstId = ""; - int result = Interop.ImageInformation.GetBurstId(_handle, out burstId); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.GetBurstId(_handle, out burstId), "Failed to get value"); + if (burstId == null) { burstId = ""; @@ -163,11 +147,9 @@ namespace Tizen.Content.MediaContent get { string exposureTime = ""; - int result = Interop.ImageInformation.GetExposureTime(_handle, out exposureTime); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.GetExposureTime(_handle, out exposureTime), "Failed to get value"); + if (exposureTime == null) { exposureTime = ""; @@ -184,12 +166,9 @@ namespace Tizen.Content.MediaContent get { double fNumber = 0.0; - int result = Interop.ImageInformation.GetFNumber(_handle, out fNumber); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } - Tizen.Log.Info(Globals.LogTag, "Received fnumber:" + fNumber); + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.GetFNumber(_handle, out fNumber), "Failed to get value"); + return fNumber; } } @@ -202,12 +181,9 @@ namespace Tizen.Content.MediaContent get { int iso = 0; - int result = Interop.ImageInformation.GetISO(_handle, out iso); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } - Tizen.Log.Info(Globals.LogTag, "Received iso:" + iso); + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.GetISO(_handle, out iso), "Failed to get value"); + return iso; } } @@ -220,11 +196,9 @@ namespace Tizen.Content.MediaContent get { string model = ""; - int result = Interop.ImageInformation.GetModel(_handle, out model); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.GetModel(_handle, out model), "Failed to get value"); + if (model == null) { model = ""; @@ -243,12 +217,9 @@ namespace Tizen.Content.MediaContent get { bool isBurst = false; - int result = Interop.ImageInformation.IsBurstShot(_handle, out isBurst); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } - Tizen.Log.Info(Globals.LogTag, "Received isBurst:" + isBurst); + MediaContentRetValidator.ThrowIfError( + Interop.ImageInformation.IsBurstShot(_handle, out isBurst), "Failed to get value"); + return isBurst; } } @@ -264,31 +235,19 @@ namespace Tizen.Content.MediaContent { var task = new TaskCompletionSource<IEnumerable<MediaFace>>(); Collection<MediaFace> coll = new Collection<MediaFace>(); - MediaContentError result; + Interop.MediaInformation.MediaFaceCallback faceCallback = (IntPtr facehandle, IntPtr userData) => { - IntPtr newHandle; - result = (MediaContentError)Interop.Face.Clone(out newHandle, facehandle); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Failed to clone Tag"); - } - MediaFace face = new MediaFace(newHandle); - Tizen.Log.Info("TCT", "GetMediaFacesAsync: Got Media Face"); - Tizen.Log.Info("TCT", "GetMediaFacesAsync: Face.Id " + face.Id); - Tizen.Log.Info("TCT", "GetMediaFacesAsync: Face.MediaInformationId " + face.MediaInformationId); - Tizen.Log.Info("TCT", "GetMediaFacesAsync: Face.Orientation " + face.Orientation); - Tizen.Log.Info("TCT", "GetMediaFacesAsync: Face.Rect " + face.Rect); - Tizen.Log.Info("TCT", "GetMediaFacesAsync: Face.Tag " + face.Tag); - coll.Add(face); + IntPtr newHandle = IntPtr.Zero; + MediaContentRetValidator.ThrowIfError( + Interop.Face.Clone(out newHandle, facehandle), "Failed to clone Tag"); + + coll.Add(new MediaFace(newHandle)); return true; }; IntPtr filterHandle = (filter != null) ? filter.Handle : IntPtr.Zero; - result = (MediaContentError)Interop.MediaInformation.GetAllFaces(MediaId, filterHandle, faceCallback, IntPtr.Zero); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetAllFaces(MediaId, filterHandle, faceCallback, IntPtr.Zero), "Failed to get value"); task.SetResult(coll); return task.Task; } @@ -303,12 +262,9 @@ namespace Tizen.Content.MediaContent { int count = 0; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - int result = Interop.MediaInformation.GetFaceCount(MediaId, handle, out count); - Tizen.Log.Info("TCT", "GetMediaFaceCount: " + count); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetFaceCount(MediaId, handle, out count), "Failed to get value"); + return count; } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaBookmark.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaBookmark.cs index 5056825..dfb8ab7 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaBookmark.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaBookmark.cs @@ -36,16 +36,11 @@ namespace Tizen.Content.MediaContent internal MediaBookmark(IntPtr handle) { _bookmarkHandle = handle; - MediaContentError res = (MediaContentError)Interop.MediaBookmark.GetMarkedTime(_bookmarkHandle, out _offset); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to Get Offset"); - } - res = (MediaContentError)Interop.MediaBookmark.GetThumbnailPath(_bookmarkHandle, out _thumbnailPath); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to Get Thumbnail Path"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaBookmark.GetMarkedTime(_bookmarkHandle, out _offset), "Failed to Get Offset"); + + MediaContentRetValidator.ThrowIfError( + Interop.MediaBookmark.GetThumbnailPath(_bookmarkHandle, out _thumbnailPath), "Failed to Get Thumbnail Path"); } ~MediaBookmark() @@ -60,11 +55,9 @@ namespace Tizen.Content.MediaContent get { int id; - MediaContentError res = (MediaContentError)Interop.MediaBookmark.GetBookmarkId(_bookmarkHandle, out id); - if (res != MediaContentError.None) - { - Log.Warn(Globals.LogTag, "Failed to get bookmark id"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaBookmark.GetBookmarkId(_bookmarkHandle, out id), "Failed to get bookmark id"); + return id; } } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaContentError.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaContentError.cs new file mode 100755 index 0000000..51b069d --- /dev/null +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaContentError.cs @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the License); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an AS IS BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +using System; +using System.IO; +using Tizen.Internals.Errors; + +namespace Tizen.Content.MediaContent +{ + /// <summary> + /// Enumeration for media content's error code + /// </summary> + /// <remarks><paramref name="NotSupported"/> error occurs when the device does not support the function.</remarks> + public enum MediaContentError + { + None = ErrorCode.None, + InvalidParameter = ErrorCode.InvalidParameter, + OutOfMemory = ErrorCode.OutOfMemory, + InvalidOperation = ErrorCode.InvalidOperation, + FileNoSpaceOnDevice = ErrorCode.FileNoSpaceOnDevice, + PermissionDenied = ErrorCode.PermissionDenied, + TizenMediaContentError = -0x01610000, + DatabaseFailed = TizenMediaContentError | 0x01, + DatabaseBusy = TizenMediaContentError | 0x02, + NetworkFailed = TizenMediaContentError | 0x03, + UnsupportedContent = TizenMediaContentError | 0x04, + NotSupported = ErrorCode.NotSupported, + } + internal class MediaContentRetValidator + { + internal const string LogTag = "Tizen.Content.MediaContent"; + + internal static void ThrowIfError(MediaContentError err, string msg) + { + switch (err) + { + case MediaContentError.InvalidParameter: + throw new ArgumentException(msg); + case MediaContentError.OutOfMemory: + throw new OutOfMemoryException(msg); + case MediaContentError.InvalidOperation: + throw new InvalidOperationException(msg); + case MediaContentError.FileNoSpaceOnDevice: + throw new IOException(msg); + case MediaContentError.PermissionDenied: + throw new UnauthorizedAccessException(msg); + case MediaContentError.DatabaseFailed: + throw new InvalidOperationException("[DB Failed]" + msg); + case MediaContentError.DatabaseBusy: + throw new InvalidOperationException("[DB Busy]" + msg); + case MediaContentError.NetworkFailed: + throw new InvalidOperationException("[Network Error]" + msg); + case MediaContentError.UnsupportedContent: + throw new PlatformNotSupportedException(msg); + } + } + } +} diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaContentErrorFactory.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaContentErrorFactory.cs deleted file mode 100755 index f10d2d5..0000000 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaContentErrorFactory.cs +++ /dev/null @@ -1,87 +0,0 @@ -/* -* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -using System; -using Tizen; - -namespace Tizen.Content.MediaContent -{ - internal class MediaContentErrorFactory - { - internal const string LogTag = "Tizen.Content.MediaContent"; - - internal static Exception CreateException(MediaContentError err, string msg) - { - Log.Info(Globals.LogTag, "Got Error " + err + " throwing Exception with msg " + msg); - Exception exp; - switch (err) - { - case MediaContentError.InvalidParameter: - { - exp = new ArgumentException(msg + " Invalid Parameters Provided"); - break; - } - case MediaContentError.OutOfMemory: - { - exp = new InvalidOperationException(msg + " Out Of Memory"); - break; - } - case MediaContentError.InvalidOperation: - { - exp = new InvalidOperationException(msg + " Inavlid operation"); - break; - } - case MediaContentError.NoSpaceOnDevice: - { - exp = new InvalidOperationException(msg + " No Space Left on Device"); - break; - } - case MediaContentError.PermissionDenied: - { - exp = new InvalidOperationException(msg + " Permission Denied"); - break; - } - case MediaContentError.DBFailed: - { - exp = new InvalidOperationException(msg + " DataBase Failed"); - break; - } - case MediaContentError.DBBusy: - { - exp = new InvalidOperationException(msg + " DataBase Busy"); - break; - } - case MediaContentError.NetworkError: - { - exp = new InvalidOperationException(msg + " Network Error"); - break; - } - case MediaContentError.UnsupportedContent: - { - exp = new ArgumentException(msg + " Content Not Supported"); - break; - } - default: - { - exp = new InvalidOperationException(msg); - break; - } - } - return exp; - } - } -} diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaContentTypes.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaContentTypes.cs deleted file mode 100755 index 640f958..0000000 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaContentTypes.cs +++ /dev/null @@ -1,80 +0,0 @@ -/* -* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - - -using System; - -namespace Tizen.Content.MediaContent -{ - internal static class Globals - { - internal const string LogTag = "Tizen.Content.MediaContent"; - } - internal static class FixMe - { - //TODO: Fix the below constant by a suitable constant in csapi-tizen - internal const int MediaContentErrorClass = -0x01610000; - } - /// <summary> - /// Enum to give the type of error occured, if any.</summary> - public enum MediaContentError : int - { - /// <summary> - /// Successful. - /// </summary> - None = Tizen.Internals.Errors.ErrorCode.None, - /// <summary> - /// Invalid parameter. - /// </summary> - InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, - /// <summary> - /// Out of memory. - /// </summary> - OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, - /// <summary> - /// Invalid Operation. - /// </summary> - InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation, - /// <summary> - /// No space left on device. - /// </summary> - NoSpaceOnDevice = Tizen.Internals.Errors.ErrorCode.FileNoSpaceOnDevice, - /// <summary> - /// Permission denied. - /// </summary> - PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, - AlreadyInProgress = Tizen.Internals.Errors.ErrorCode.AlreadyInProgress, - NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, - ResourceBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy, - /// <summary> - /// DB operation failed. - /// </summary> - DBFailed = FixMe.MediaContentErrorClass | 0x01, - /// <summary> - /// DB operation BUSY. - /// </summary> - DBBusy = FixMe.MediaContentErrorClass | 0x02, - /// <summary> - /// Network Fail. - /// </summary> - NetworkError = FixMe.MediaContentErrorClass | 0x03, - /// <summary> - /// Unsupported Content. - /// </summary> - UnsupportedContent = FixMe.MediaContentErrorClass | 0x04 - }; -} diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFace.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFace.cs index 3b04214..17abc93 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFace.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFace.cs @@ -52,16 +52,11 @@ namespace Tizen.Content.MediaContent ///</param> internal MediaFace(MediaInformation image, FaceRect rect) { - MediaContentError res = (MediaContentError)Interop.Face.Create(image.MediaId, out _faceHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to create MediaFace"); - } - res = (MediaContentError)Interop.Face.SetFaceRect(_faceHandle, rect.X, rect.Y, rect.Width, rect.Height); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to set Rect to MediaFace"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Face.Create(image.MediaId, out _faceHandle), "Failed to create MediaFace"); + + MediaContentRetValidator.ThrowIfError( + Interop.Face.SetFaceRect(_faceHandle, rect.X, rect.Y, rect.Width, rect.Height), "Failed to set Rect to MediaFace"); } ~MediaFace() @@ -80,21 +75,16 @@ namespace Tizen.Content.MediaContent int y; int width; int height; - MediaContentError res = (MediaContentError)Interop.Face.GetFaceRect(_faceHandle, out x, out y, out width, out height); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Rect for the Face"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Face.GetFaceRect(_faceHandle, out x, out y, out width, out height), "Failed to get Rect for the Face"); + return new FaceRect(x, y, width, height); } set { FaceRect rect = (FaceRect)value; - MediaContentError res = (MediaContentError)Interop.Face.SetFaceRect(_faceHandle, rect.X, rect.Y, rect.Width, rect.Height); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to set Rect for the Face"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Face.SetFaceRect(_faceHandle, rect.X, rect.Y, rect.Width, rect.Height), "Failed to set Rect for the Face"); } } @@ -106,11 +96,9 @@ namespace Tizen.Content.MediaContent get { string id; - MediaContentError res = (MediaContentError)Interop.Face.GetFaceId(_faceHandle, out id); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Id for the Face"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Face.GetFaceId(_faceHandle, out id), "Failed to get value"); + return id; } } @@ -123,11 +111,9 @@ namespace Tizen.Content.MediaContent get { string mediaId; - MediaContentError res = (MediaContentError)Interop.Face.GetMediaId(_faceHandle, out mediaId); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get media Id for the Face"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Face.GetMediaId(_faceHandle, out mediaId), "Failed to get value"); + return mediaId; } } @@ -139,20 +125,15 @@ namespace Tizen.Content.MediaContent get { string tag; - MediaContentError res = (MediaContentError)Interop.Face.GetTag(_faceHandle, out tag); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Tag for the Face"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Face.GetTag(_faceHandle, out tag), "Failed to get value"); + return tag; } set { - MediaContentError res = (MediaContentError)Interop.Face.SetTag(_faceHandle, value); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to set Tag for the Face"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Face.SetTag(_faceHandle, value), "Failed to set value"); } } @@ -164,20 +145,15 @@ namespace Tizen.Content.MediaContent get { int orientation; - MediaContentError res = (MediaContentError)Interop.Face.GetOrientation(_faceHandle, out orientation); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to GetOrientation for the Face"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Face.GetOrientation(_faceHandle, out orientation), "Failed to value"); + return (MediaContentOrientation)orientation; } set { - MediaContentError res = (MediaContentError)Interop.Face.SetOrientation(_faceHandle, (int)value); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to SetOrientation for the Face"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Face.SetOrientation(_faceHandle, (int)value), "Failed to set value"); } } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFolder.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFolder.cs index 38d95d8..f2506de 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFolder.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFolder.cs @@ -50,11 +50,9 @@ namespace Tizen.Content.MediaContent get { string id; - MediaContentError res = (MediaContentError)Interop.Folder.GetFolderId(_folderHandle, out id); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Id for the MediaFolder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.GetFolderId(_folderHandle, out id), "Failed to get value"); + return id; } } @@ -67,11 +65,8 @@ namespace Tizen.Content.MediaContent get { string parentId; - MediaContentError res = (MediaContentError)Interop.Folder.GetParentFolderId(_folderHandle, out parentId); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get parents folder Id for the MediaFolder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.GetParentFolderId(_folderHandle, out parentId), "Failed to get value"); return parentId; } } @@ -84,11 +79,8 @@ namespace Tizen.Content.MediaContent get { string path; - MediaContentError res = (MediaContentError)Interop.Folder.GetPath(_folderHandle, out path); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get path for the MediaFolder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.GetPath(_folderHandle, out path), "Failed to get value"); return path; } } @@ -101,20 +93,14 @@ namespace Tizen.Content.MediaContent get { string name; - MediaContentError res = (MediaContentError)Interop.Folder.GetName(_folderHandle, out name); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get name for the MediaFolder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.GetName(_folderHandle, out name), "Failed to get value"); return name; } set { - MediaContentError res = (MediaContentError)Interop.Folder.SetName(_folderHandle, value); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to set name for the MediaFolder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.SetName(_folderHandle, value), "Failed to set value"); } } @@ -127,11 +113,9 @@ namespace Tizen.Content.MediaContent get { int type; - MediaContentError res = (MediaContentError)Interop.Folder.GetStorageType(_folderHandle, out type); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get storage type for the MediaFolder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.GetStorageType(_folderHandle, out type), "Failed to get value"); + return (ContentStorageType)type; } } @@ -144,11 +128,9 @@ namespace Tizen.Content.MediaContent get { string storageId; - MediaContentError res = (MediaContentError)Interop.Folder.GetStorageId(_folderHandle, out storageId); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get storage Id for the MediaFolder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.GetStorageId(_folderHandle, out storageId), "Failed to get value"); + return storageId; } } @@ -161,11 +143,9 @@ namespace Tizen.Content.MediaContent get { DateTime date; - MediaContentError res = (MediaContentError)Interop.Folder.GetModifiedTime(_folderHandle, out date); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get modified date for the MediaFolder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.GetModifiedTime(_folderHandle, out date), "Failed to get value"); + return date; } } @@ -180,20 +160,15 @@ namespace Tizen.Content.MediaContent get { int order; - MediaContentError res = (MediaContentError)Interop.Folder.GetOrder(_folderHandle, out order); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get modified date for the MediaFolder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.GetOrder(_folderHandle, out order), "Failed to get value"); + return order; } set { - MediaContentError res = (MediaContentError)Interop.Folder.SetOrder(_folderHandle, value); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to set viewing order for the MediaFolder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.SetOrder(_folderHandle, value), "Failed to set value"); } } @@ -212,11 +187,9 @@ namespace Tizen.Content.MediaContent { int mediaCount; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res = (MediaContentError)Interop.Folder.GetMediaCountFromDb(Id, handle, out mediaCount); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get media count for the folder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count"); + return mediaCount; } @@ -256,24 +229,19 @@ namespace Tizen.Content.MediaContent var tcs = new TaskCompletionSource<IEnumerable<MediaInformation>>(); List<MediaInformation> mediaContents = new List<MediaInformation>(); IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res; + Interop.Folder.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) => { Interop.MediaInformation.SafeMediaInformationHandle newHandle; - res = (MediaContentError)Interop.MediaInformation.Clone(out newHandle, mediaHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to clone media information in folder"); - } - MediaInformation info = new MediaInformation(newHandle); - mediaContents.Add(info); + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone"); + + mediaContents.Add(new MediaInformation(newHandle)); return true; }; - res = (MediaContentError)Interop.Folder.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to get media information for the folder"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Folder.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information"); + tcs.TrySetResult(mediaContents); return tcs.Task; } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInformation.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInformation.cs index 53b4592..0ba324c 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInformation.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInformation.cs @@ -47,11 +47,9 @@ namespace Tizen.Content.MediaContent { int count = 0; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - int result = Interop.MediaInformation.GetTagCount(MediaId, handle, out count); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetTagCount(MediaId, handle, out count), "Failed to get count"); + return count; } @@ -63,11 +61,8 @@ namespace Tizen.Content.MediaContent /// <param name="destination">The Destination path</param> public void Move(string destination) { - int result = Interop.MediaInformation.MoveToDB(_handle, destination); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to move"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.MoveToDB(_handle, destination), "Failed to move"); } /// <summary> @@ -77,11 +72,8 @@ namespace Tizen.Content.MediaContent /// void </returns> public void Refresh() { - int result = Interop.MediaInformation.RefreshMetadataToDB(MediaId); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to move"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.RefreshMetadataToDB(MediaId), "Failed to refresh"); } /// <summary> @@ -95,23 +87,12 @@ namespace Tizen.Content.MediaContent var task = new TaskCompletionSource<string>(); Interop.MediaInformation.MediaThumbnailCompletedCallback thumbnailResult = (MediaContentError createResult, string path, IntPtr userData) => { - Log.Info(Globals.LogTag, "Thumbnail Callback Received "); - if (createResult == MediaContentError.None) - { - Log.Info(Globals.LogTag, "Thumbnail Callback Received with path " + path); - task.SetResult(path); - } - else - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)createResult); - task.SetException(MediaContentErrorFactory.CreateException((MediaContentError)createResult, "Failed to create Thumbnail")); - } + MediaContentRetValidator.ThrowIfError(createResult, "Failed to create thumbnail"); + task.SetResult(path); }; - int result = Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero), "Failed to create thumbnail"); + return await task.Task; } @@ -126,37 +107,18 @@ namespace Tizen.Content.MediaContent { var task = new TaskCompletionSource<string>(); cancellationToken.Register(() => { - Log.Info(Globals.LogTag, "Cancel thumbnail Called"); - int resultCancel = Interop.MediaInformation.CancelThumbnail(_handle); - Log.Info(Globals.LogTag, "After CAPI CancelThumbnail"); - if ((MediaContentError)resultCancel != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Cancel thumbnail failed with error code: " + (MediaContentError)resultCancel); - } - else - { - task.SetCanceled(); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.CancelThumbnail(_handle), "Failed to cancel"); + task.SetCanceled(); }); Interop.MediaInformation.MediaThumbnailCompletedCallback thumbnailResult = (MediaContentError createResult, string path, IntPtr userData) => { - Log.Info(Globals.LogTag, "Thumbnail Callback Received"); - if (createResult == MediaContentError.None) - { - task.SetResult(path); - } - else - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)createResult); - task.SetException(MediaContentErrorFactory.CreateException((MediaContentError)createResult, "Failed to create Thumbnail")); - } + MediaContentRetValidator.ThrowIfError(createResult, "Failed to create thumbnail"); + task.SetResult(path); }; - int result = Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - task.SetException(MediaContentErrorFactory.CreateException((MediaContentError)result, "Creating Thumbnail Fail")); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero), "Failed to create thumbnail"); + return await task.Task; } @@ -170,25 +132,20 @@ namespace Tizen.Content.MediaContent { var task = new TaskCompletionSource<IEnumerable<Tag>>(); Collection<Tag> coll = new Collection<Tag>(); - MediaContentError result; + IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; Interop.MediaInformation.MediaTagCallback tagsCallback = (IntPtr tagHandle, IntPtr userData) => { IntPtr newHandle; - result = (MediaContentError)Interop.Tag.Clone(out newHandle, tagHandle); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Failed to clone Tag"); - } - Tag tag = new Tag(newHandle); - coll.Add(tag); + MediaContentRetValidator.ThrowIfError( + Interop.Tag.Clone(out newHandle, tagHandle), "Failed to clone"); + coll.Add(new Tag(newHandle)); + return true; }; - result = (MediaContentError)Interop.MediaInformation.GetAllTags(MediaId, handle, tagsCallback, IntPtr.Zero); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetAllTags(MediaId, handle, tagsCallback, IntPtr.Zero), "Failed to get information"); + task.SetResult(coll); return task.Task; } @@ -201,12 +158,8 @@ namespace Tizen.Content.MediaContent get { string mediaId = ""; - int result = Interop.MediaInformation.GetMediaId(_handle, out mediaId); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - //Log.Error() - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetMediaId(_handle, out mediaId), "Failed to get value"); if (mediaId == null) { mediaId = ""; @@ -223,11 +176,8 @@ namespace Tizen.Content.MediaContent get { string path = ""; - int result = Interop.MediaInformation.GetFilePath(_handle, out path); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetFilePath(_handle, out path), "Failed to get value"); if (path == null) { path = ""; @@ -244,11 +194,9 @@ namespace Tizen.Content.MediaContent get { string displayname = ""; - int result = Interop.MediaInformation.GetDisplayName(_handle, out displayname); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetDisplayName(_handle, out displayname), "Failed to get value"); + if (displayname == null) { displayname = ""; @@ -257,11 +205,8 @@ namespace Tizen.Content.MediaContent } set { - int result = Interop.MediaInformation.SetDisplayName(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set displayname"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetDisplayName(_handle, value), "failed to set value"); } } @@ -273,11 +218,9 @@ namespace Tizen.Content.MediaContent get { MediaContentType contentType = MediaContentType.Others; - int result = Interop.MediaInformation.GetMediaType(_handle, out contentType); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetMediaType(_handle, out contentType), "Failed to get value"); + return contentType; } } @@ -290,11 +233,9 @@ namespace Tizen.Content.MediaContent get { string mimeType = ""; - int result = Interop.MediaInformation.GetMimeType(_handle, out mimeType); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetMimeType(_handle, out mimeType), "Failed to get value"); + if (mimeType == null) { mimeType = ""; @@ -311,11 +252,9 @@ namespace Tizen.Content.MediaContent get { long size; - int result = Interop.MediaInformation.GetSize(_handle, out size); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetSize(_handle, out size), "Failed to get value"); + return size; } } @@ -329,21 +268,17 @@ namespace Tizen.Content.MediaContent { DateTime addedAt; int time; - int result = Interop.MediaInformation.GetAddedTime(_handle, out time); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetAddedTime(_handle, out time), "Failed to get value"); + DateTime utc; if (time != 0) { - Tizen.Log.Info(Globals.LogTag, "Ticks received: " + time); utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc); addedAt = utc.ToLocalTime(); } else { - Tizen.Log.Info(Globals.LogTag, "No Date received"); addedAt = DateTime.Now; } return addedAt; @@ -351,11 +286,8 @@ namespace Tizen.Content.MediaContent set { - int result = Interop.MediaInformation.SetAddedTime(_handle, (int)value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set time"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetAddedTime(_handle, (int)value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds), "failed to set time"); } } @@ -368,21 +300,17 @@ namespace Tizen.Content.MediaContent { DateTime modifiedAt; int time; - int result = Interop.MediaInformation.GetModifiedTime(_handle, out time); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetModifiedTime(_handle, out time), "Failed to get value"); + DateTime utc; if (time != 0) { - Tizen.Log.Info(Globals.LogTag, "Ticks received: " + time); utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc); modifiedAt = utc.ToLocalTime(); } else { - Tizen.Log.Info(Globals.LogTag, "No Date received"); modifiedAt = DateTime.Now; } return modifiedAt; @@ -398,21 +326,17 @@ namespace Tizen.Content.MediaContent { DateTime timeline; int time; - int result = Interop.MediaInformation.GetTimeline(_handle, out time); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetTimeline(_handle, out time), "Failed to get value"); + DateTime utc; if (time != 0) { - Tizen.Log.Info(Globals.LogTag, "Ticks received: " + time); utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc); timeline = utc.ToLocalTime(); } else { - Tizen.Log.Info(Globals.LogTag, "No Date received"); timeline = DateTime.Now; } return timeline; @@ -427,11 +351,9 @@ namespace Tizen.Content.MediaContent get { string thumbnailPath = ""; - int result = Interop.MediaInformation.GetThumbnailPath(_handle, out thumbnailPath); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetThumbnailPath(_handle, out thumbnailPath), "Failed to get value"); + if (thumbnailPath == null) { thumbnailPath = ""; @@ -449,11 +371,9 @@ namespace Tizen.Content.MediaContent get { string description = ""; - int result = Interop.MediaInformation.GetDescription(_handle, out description); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetDescription(_handle, out description), "Failed to get value"); + if (description == null) { description = ""; @@ -462,11 +382,8 @@ namespace Tizen.Content.MediaContent } set { - int result = Interop.MediaInformation.SetDescription(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set description"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetDescription(_handle, value), "failed to set value"); } } @@ -479,20 +396,15 @@ namespace Tizen.Content.MediaContent get { double longitude = 0.0; - int result = Interop.MediaInformation.GetLongitude(_handle, out longitude); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetLongitude(_handle, out longitude), "Failed to get value"); + return longitude; } set { - int result = Interop.MediaInformation.SetLongitude(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set langitude"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetLongitude(_handle, value), "failed to set value"); } } @@ -505,20 +417,15 @@ namespace Tizen.Content.MediaContent get { double latitude = 0.0; - int result = Interop.MediaInformation.GetLatitude(_handle, out latitude); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetLatitude(_handle, out latitude), "Failed to get value"); + return latitude; } set { - int result = Interop.MediaInformation.SetLatitude(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set latitude"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetLatitude(_handle, value), "failed to set value"); } } @@ -531,20 +438,15 @@ namespace Tizen.Content.MediaContent get { double altitude = 0.0; - int result = Interop.MediaInformation.GetAltitude(_handle, out altitude); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetAltitude(_handle, out altitude), "Failed to get value"); + return altitude; } set { - int result = Interop.MediaInformation.SetAltitude(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set altitude"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetAltitude(_handle, value), "failed to set value"); } } @@ -557,11 +459,9 @@ namespace Tizen.Content.MediaContent get { string weather = ""; - int result = Interop.MediaInformation.GetWeather(_handle, out weather); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetWeather(_handle, out weather), "Failed to get value"); + if (weather == null) { weather = ""; @@ -570,11 +470,8 @@ namespace Tizen.Content.MediaContent } set { - int result = Interop.MediaInformation.SetWeather(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set weather"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetWeather(_handle, value), "failed to set value"); } } @@ -586,20 +483,14 @@ namespace Tizen.Content.MediaContent get { int rating = 0; - int result = Interop.MediaInformation.GetRating(_handle, out rating); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetRating(_handle, out rating), "Failed to get value"); return rating; } set { - int result = Interop.MediaInformation.SetRating(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set rating"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetRating(_handle, value), "failed to set value"); } } @@ -612,20 +503,15 @@ namespace Tizen.Content.MediaContent get { bool isFavourtite = false; - int result = Interop.MediaInformation.GetFavorite(_handle, out isFavourtite); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetFavorite(_handle, out isFavourtite), "Failed to get value"); + return isFavourtite; } set { - int result = Interop.MediaInformation.SetFavorite(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set favorite"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetFavorite(_handle, value), "failed to set value"); } } @@ -637,11 +523,9 @@ namespace Tizen.Content.MediaContent get { string author = ""; - int result = Interop.MediaInformation.GetAuthor(_handle, out author); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetAuthor(_handle, out author), "Failed to get value"); + if(author == null) { author = ""; @@ -650,11 +534,8 @@ namespace Tizen.Content.MediaContent } set { - int result = Interop.MediaInformation.SetAuthor(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set author"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetAuthor(_handle, value), "failed to set value"); } } @@ -666,11 +547,9 @@ namespace Tizen.Content.MediaContent get { string provider = ""; - int result = Interop.MediaInformation.GetProvider(_handle, out provider); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetProvider(_handle, out provider), "Failed to get value"); + if (provider == null) { provider = ""; @@ -679,11 +558,8 @@ namespace Tizen.Content.MediaContent } set { - int result = Interop.MediaInformation.SetProvider(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set provider"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetProvider(_handle, value), "failed to set value"); } } @@ -695,11 +571,9 @@ namespace Tizen.Content.MediaContent get { string contentName = ""; - int result = Interop.MediaInformation.GetContentName(_handle, out contentName); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetContentName(_handle, out contentName), "Failed to get value"); + if (contentName == null) { contentName = ""; @@ -708,11 +582,8 @@ namespace Tizen.Content.MediaContent } set { - int result = Interop.MediaInformation.SetContentName(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set content name"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetContentName(_handle, value), "failed to set value"); } } @@ -724,11 +595,9 @@ namespace Tizen.Content.MediaContent get { string title = ""; - int result = Interop.MediaInformation.GetTitle(_handle, out title); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetTitle(_handle, out title), "Failed to get value"); + if (title == null) { title = ""; @@ -745,11 +614,9 @@ namespace Tizen.Content.MediaContent get { string category = ""; - int result = Interop.MediaInformation.GetCategory(_handle, out category); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetCategory(_handle, out category), "Failed to get value"); + if (category == null) { category = ""; @@ -758,11 +625,8 @@ namespace Tizen.Content.MediaContent } set { - int result = Interop.MediaInformation.SetCategory(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set category"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetCategory(_handle, value), "failed to set value"); } } @@ -774,11 +638,9 @@ namespace Tizen.Content.MediaContent get { string loationTag = ""; - int result = Interop.MediaInformation.GetLocationTag(_handle, out loationTag); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetLocationTag(_handle, out loationTag), "Failed to get value"); + if (loationTag == null) { loationTag = ""; @@ -787,11 +649,8 @@ namespace Tizen.Content.MediaContent } set { - int result = Interop.MediaInformation.SetLocationTag(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set location tag"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetLocationTag(_handle, value), "failed to set value"); } } @@ -803,11 +662,9 @@ namespace Tizen.Content.MediaContent get { string ageRating = ""; - int result = Interop.MediaInformation.GetAgeRating(_handle, out ageRating); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetAgeRating(_handle, out ageRating), "Failed to get value"); + if (ageRating == null) { ageRating = ""; @@ -816,11 +673,8 @@ namespace Tizen.Content.MediaContent } set { - int result = Interop.MediaInformation.SetAgeRating(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set age rating"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetAgeRating(_handle, value), "Failed to set value"); } } @@ -832,11 +686,9 @@ namespace Tizen.Content.MediaContent get { string keyword = ""; - int result = Interop.MediaInformation.GetKeyword(_handle, out keyword); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetKeyword(_handle, out keyword), "Failed to get value"); + if (keyword == null) { keyword = ""; @@ -845,11 +697,8 @@ namespace Tizen.Content.MediaContent } set { - int result = Interop.MediaInformation.SetKeyword(_handle, value); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set keyword"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetKeyword(_handle, value), "failed to set value"); } } @@ -861,11 +710,9 @@ namespace Tizen.Content.MediaContent get { string storageId = ""; - int result = Interop.MediaInformation.GetStorageId(_handle, out storageId); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetStorageId(_handle, out storageId), "Failed to get value"); + if (storageId == null) { storageId = ""; @@ -882,11 +729,9 @@ namespace Tizen.Content.MediaContent get { bool isDRM = false; - int result = Interop.MediaInformation.IsDrm(_handle, out isDRM); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.IsDrm(_handle, out isDRM), "Failed to get value"); + return isDRM; } } @@ -899,11 +744,9 @@ namespace Tizen.Content.MediaContent get { ContentStorageType storageType = ContentStorageType.Internal; - int result = Interop.MediaInformation.GetStorageType(_handle, out storageType); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetStorageType(_handle, out storageType), "Failed to get value"); + return storageType; } } @@ -917,20 +760,15 @@ namespace Tizen.Content.MediaContent get { int playedCount = 0; - int result = Interop.MediaInformation.GetPlayedCount(_handle, out playedCount); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetPlayedCount(_handle, out playedCount), "Failed to get value"); + return playedCount; } set { - int result = Interop.MediaInformation.IncreasePlayedCount(_handle); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set increase played count"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.IncreasePlayedCount(_handle), "failed to set value"); } } @@ -944,32 +782,25 @@ namespace Tizen.Content.MediaContent { DateTime addedAt; int time; - int result = Interop.MediaInformation.GetPlayedAt(_handle, out time); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetPlayedAt(_handle, out time), "Failed to get value"); + DateTime utc; if (time != 0) { - Tizen.Log.Info(Globals.LogTag, "Ticks received: " + time); utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc); addedAt = utc.ToLocalTime(); } else { - Tizen.Log.Info(Globals.LogTag, "No Date received"); addedAt = DateTime.Now; } return addedAt; } set { - int result = Interop.MediaInformation.SetPlayedAt(_handle); - if ((MediaContentError)result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException((MediaContentError)result, "failed to set played time"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.SetPlayedAt(_handle), "failed to set value"); } } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlayList.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlayList.cs index 0f4cfcb..79c36fb 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlayList.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlayList.cs @@ -47,25 +47,19 @@ namespace Tizen.Content.MediaContent private void refreshPlaylistDictionary() { _dictionary.Clear(); - MediaContentError res; Interop.Playlist.PlaylistMemberCallback callback = (int memberId, IntPtr mediaHandle, IntPtr data) => { Interop.MediaInformation.SafeMediaInformationHandle newHandle; - res = (MediaContentError)Interop.MediaInformation.Clone(out newHandle, mediaHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to clone media"); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media"); + string mediaId; Interop.MediaInformation.GetMediaId(newHandle, out mediaId); _dictionary.Add(mediaId, memberId); return true; }; - res = (MediaContentError)Interop.Playlist.ForeachMediaFromDb(Id, IntPtr.Zero, callback, IntPtr.Zero); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to get playlist items"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.ForeachMediaFromDb(Id, IntPtr.Zero, callback, IntPtr.Zero), "Failed to get playlist items"); } /// <summary> @@ -76,11 +70,9 @@ namespace Tizen.Content.MediaContent get { int id; - MediaContentError res = (MediaContentError)Interop.Playlist.GetPlaylistId(_playlistHandle, out id); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Id for the PlayList"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.GetPlaylistId(_playlistHandle, out id), "Failed to get value"); + return id; } } @@ -97,15 +89,9 @@ namespace Tizen.Content.MediaContent } set { - MediaContentError res = (MediaContentError)Interop.Playlist.SetName(_playlistHandle, value); - if (res == MediaContentError.None) - { - _playListName = value; - } - else - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to set Name for the PlayList"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.SetName(_playlistHandle, value), "Failed to set value"); + _playListName = value; } } /// <summary> @@ -116,20 +102,14 @@ namespace Tizen.Content.MediaContent get { string path; - MediaContentError res = (MediaContentError)Interop.Playlist.GetThumbnailPath(_playlistHandle, out path); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Thumbnail Path for the PlayList"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.GetThumbnailPath(_playlistHandle, out path), "Failed to get value"); return path; } set { - MediaContentError res = (MediaContentError)Interop.Playlist.SetThumbnailPath(_playlistHandle, value); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to set Thumbnail Path for the PlayList"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.SetThumbnailPath(_playlistHandle, value), "Failed to set value"); } } @@ -145,11 +125,8 @@ namespace Tizen.Content.MediaContent internal PlayList(IntPtr handle) { _playlistHandle = handle; - MediaContentError res = (MediaContentError)Interop.Playlist.GetName(handle, out _playListName); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Name for the PlayList"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.GetName(handle, out _playListName), "Failed to get value"); } /// <summary> @@ -158,12 +135,8 @@ namespace Tizen.Content.MediaContent /// <param name="mediaContent">The AudioContent obect to be added</param> public void AddItem(MediaInformation mediaContent) { - MediaContentError res = (MediaContentError)Interop.Playlist.AddMedia(_playlistHandle, mediaContent.MediaId); - if (res != MediaContentError.None) - { - //TODO improve the error message once media content is implemented - throw MediaContentErrorFactory.CreateException(res, "Failed to add media content to the playlist"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.AddMedia(_playlistHandle, mediaContent.MediaId), "Failed to add item"); } /// <summary> @@ -175,11 +148,8 @@ namespace Tizen.Content.MediaContent int memberId = 0; refreshPlaylistDictionary(); _dictionary.TryGetValue(media.MediaId, out memberId); - MediaContentError res = (MediaContentError)Interop.Playlist.RemoveMedia(_playlistHandle, memberId); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to remove media content from the playlist"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.RemoveMedia(_playlistHandle, memberId), "Failed to remove item"); } /// <summary> @@ -189,16 +159,11 @@ namespace Tizen.Content.MediaContent /// <param name="playOrder">The playing order</param> public void SetPlayOrder(MediaInformation media, int playOrder) { - Tizen.Log.Info("TCT", "Order set for Media Id: " + media.MediaId); int memberId; refreshPlaylistDictionary(); _dictionary.TryGetValue(media.MediaId, out memberId); - Tizen.Log.Info("TCT", "Order set for member Id: " + memberId); - MediaContentError res = (MediaContentError)Interop.Playlist.SetPlayOrder(_playlistHandle, memberId, playOrder); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to set play order for the playlist member " + memberId); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.SetPlayOrder(_playlistHandle, memberId, playOrder), "Failed to set play order"); } /// <summary> @@ -207,17 +172,13 @@ namespace Tizen.Content.MediaContent /// <param name="media"></param> public int GetPlayOrder(MediaInformation media) { - Tizen.Log.Info("TCT", "Getting order for Media Id: " + media.MediaId); int playOrder; int memberId; refreshPlaylistDictionary(); _dictionary.TryGetValue(media.MediaId, out memberId); - Tizen.Log.Info("TCT", "Order get for Member Id: " + memberId); - MediaContentError res = (MediaContentError)Interop.Playlist.GetPlayOrder(_playlistHandle, memberId, out playOrder); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to get play order for the playlist member " + memberId); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.GetPlayOrder(_playlistHandle, memberId, out playOrder), "Failed to get play order"); + return playOrder; } @@ -232,11 +193,9 @@ namespace Tizen.Content.MediaContent PlayList playList = null; IntPtr playlistHandle; - MediaContentError res = (MediaContentError)Interop.Playlist.ImportFromFile(name, filePath, out playlistHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to import playlist " + name + " from " + filePath); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.ImportFromFile(name, filePath, out playlistHandle), "Failed to import"); + playList = new PlayList(name); playList._playlistHandle = playlistHandle; return playList; @@ -248,11 +207,8 @@ namespace Tizen.Content.MediaContent /// <returns>path The path to export the playlist</returns> public static void Export(PlayList list, string filePath) { - MediaContentError res = (MediaContentError)Interop.Playlist.ExportToFile(list.Handle, filePath); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to export playlist " + list.Name + " to " + filePath); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.ExportToFile(list.Handle, filePath), "Failed to export playlist:" + filePath); } /// <summary> @@ -264,21 +220,17 @@ namespace Tizen.Content.MediaContent { int mediaCount; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res = (MediaContentError)Interop.Playlist.GetMediaCountFromDb(Id, handle, out mediaCount); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to get media count for the playlist"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get media count"); + return mediaCount; } public override void Dispose() { - MediaContentError res = (MediaContentError)Interop.Playlist.Destroy(_playlistHandle); - _playlistHandle = IntPtr.Zero; - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to dispose the playlist"); + if (_playlistHandle != IntPtr.Zero) { + Interop.Playlist.Destroy(_playlistHandle); + _playlistHandle = IntPtr.Zero; } } @@ -294,24 +246,18 @@ namespace Tizen.Content.MediaContent var tcs = new TaskCompletionSource<IEnumerable<MediaInformation>>(); List<MediaInformation> mediaContents = new List<MediaInformation>(); IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res; Interop.Playlist.PlaylistMemberCallback callback = (int memberId, IntPtr mediaHandle, IntPtr data) => { Interop.MediaInformation.SafeMediaInformationHandle newHandle; - res = (MediaContentError)Interop.MediaInformation.Clone(out newHandle, mediaHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to clone media"); - } - MediaInformation info = new MediaInformation(newHandle); - mediaContents.Add(info); + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media"); + + mediaContents.Add(new MediaInformation(newHandle)); return true; }; - res = (MediaContentError)Interop.Playlist.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to get media information for the playlist"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Playlist.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get media information"); + tcs.TrySetResult(mediaContents); return tcs.Task; } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Storage.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Storage.cs index efa9890..f08fe79 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Storage.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Storage.cs @@ -45,11 +45,9 @@ namespace Tizen.Content.MediaContent get { string id; - MediaContentError res = (MediaContentError)Interop.Storage.GetId(_storageHandle, out id); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Id for the Storage"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Storage.GetId(_storageHandle, out id), "Failed to get value"); + return id; } } @@ -62,11 +60,9 @@ namespace Tizen.Content.MediaContent get { string path; - MediaContentError res = (MediaContentError)Interop.Storage.GetPath(_storageHandle, out path); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Path for the Storage"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Storage.GetPath(_storageHandle, out path), "Failed to get value"); + return path; } } @@ -79,11 +75,9 @@ namespace Tizen.Content.MediaContent get { string name; - MediaContentError res = (MediaContentError)Interop.Storage.GetName(_storageHandle, out name); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Name for the Storage"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Storage.GetName(_storageHandle, out name), "Failed to get value"); + return name; } } @@ -96,11 +90,9 @@ namespace Tizen.Content.MediaContent get { int storageType; - MediaContentError res = (MediaContentError)Interop.Storage.GetType(_storageHandle, out storageType); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get type for the Storage"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Storage.GetType(_storageHandle, out storageType), "Failed to get value"); + return (ContentStorageType)storageType; } } @@ -119,21 +111,18 @@ namespace Tizen.Content.MediaContent { int mediaCount; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res = (MediaContentError)Interop.Storage.GetMediaCountFromDb(Id, handle, out mediaCount); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get media count for the storage"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Storage.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count"); + return mediaCount; } public override void Dispose() { - MediaContentError res = (MediaContentError)Interop.Storage.Destroy(_storageHandle); - _storageHandle = IntPtr.Zero; - if (res != MediaContentError.None) + if (_storageHandle != IntPtr.Zero) { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to dispose the storage"); + Interop.Storage.Destroy(_storageHandle); + _storageHandle = IntPtr.Zero; } } @@ -148,25 +137,20 @@ namespace Tizen.Content.MediaContent { var tcs = new TaskCompletionSource<IEnumerable<MediaInformation>>(); List<MediaInformation> mediaContents = new List<MediaInformation>(); - MediaContentError res; + IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; Interop.Storage.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) => { Interop.MediaInformation.SafeMediaInformationHandle newHandle; - res = (MediaContentError)Interop.MediaInformation.Clone(out newHandle, mediaHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to clone media"); - } - MediaInformation info = new MediaInformation(newHandle); - mediaContents.Add(info); + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media"); + + mediaContents.Add(new MediaInformation(newHandle)); return true; }; - res = (MediaContentError)Interop.Storage.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to get media information for the storage"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Storage.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information"); + tcs.TrySetResult(mediaContents); return tcs.Task; } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Tag.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Tag.cs index b645f91..7098042 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Tag.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Tag.cs @@ -48,11 +48,8 @@ namespace Tizen.Content.MediaContent get { int id; - MediaContentError res = (MediaContentError)Interop.Tag.GetTagId(_tagHandle, out id); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get Id for the Tag"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.GetTagId(_tagHandle, out id), "Failed to get value"); return id; } } @@ -68,26 +65,17 @@ namespace Tizen.Content.MediaContent } set { - MediaContentError res = (MediaContentError)Interop.Tag.SetName(_tagHandle, value); - if (res == MediaContentError.None) - { - _tagName = value; - } - else - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to set name for the Tag"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.SetName(_tagHandle, value), "Failed to set value"); + _tagName = value; } } internal Tag(IntPtr tagHandle) { _tagHandle = tagHandle; - MediaContentError error = (MediaContentError)Interop.Tag.GetName(tagHandle, out _tagName); - if (error != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(error, "Failed to get the tage Name"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.GetName(tagHandle, out _tagName), "Failed to get value"); } /// <summary> /// Creates a Tag object which can be inserted to the media database using ContentManager:InsertToDatabaseAsync(ContentCollection) @@ -104,13 +92,8 @@ namespace Tizen.Content.MediaContent /// <param name="mediaContent">The media info which is added</param> public void AddItem(MediaInformation mediaContent) { - Console.WriteLine("Tag add item info: " + mediaContent.MediaId); - MediaContentError res = (MediaContentError)Interop.Tag.AddMedia(_tagHandle, mediaContent.MediaId); - if (res != MediaContentError.None) - { - Console.WriteLine("exception :" + res); - throw MediaContentErrorFactory.CreateException(res, "Failed to add the media item to the Tag"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.AddMedia(_tagHandle, mediaContent.MediaId), "Failed to add item"); } /// <summary> @@ -119,11 +102,8 @@ namespace Tizen.Content.MediaContent /// <param name="mediaContent">The media info which is removed</param> public void RemoveItem(MediaInformation mediaContent) { - MediaContentError res = (MediaContentError)Interop.Tag.RemoveMedia(_tagHandle, mediaContent.MediaId); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to remove the media item from the Tag"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.RemoveMedia(_tagHandle, mediaContent.MediaId), "Failed to remove item"); } /// <summary> @@ -135,21 +115,18 @@ namespace Tizen.Content.MediaContent { int mediaCount; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res = (MediaContentError)Interop.Tag.GetMediaCountFromDb(Id, handle, out mediaCount); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to get media count for the tag"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count"); + return mediaCount; } public override void Dispose() { - MediaContentError res = (MediaContentError)Interop.Tag.Destroy(_tagHandle); - _tagHandle = IntPtr.Zero; - if (res != MediaContentError.None) + if (_tagHandle != IntPtr.Zero) { - throw MediaContentErrorFactory.CreateException(res, "Failed to dispose the tag"); + Interop.Tag.Destroy(_tagHandle); + _tagHandle = IntPtr.Zero; } } @@ -165,23 +142,18 @@ namespace Tizen.Content.MediaContent var tcs = new TaskCompletionSource<IEnumerable<MediaInformation>>(); List<MediaInformation> mediaContents = new List<MediaInformation>(); IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res; + Interop.Tag.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) => { Interop.MediaInformation.SafeMediaInformationHandle newHandle; - res = (MediaContentError)Interop.MediaInformation.Clone(out newHandle, mediaHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to clone media"); - } - MediaInformation info = new MediaInformation(newHandle); - mediaContents.Add(info); + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media"); + + mediaContents.Add(new MediaInformation(newHandle)); }; - res = (MediaContentError)Interop.Tag.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero); - if (res != MediaContentError.None) - { - Log.Warn(MediaContentErrorFactory.LogTag, "Failed to get media information for the tag"); - } + MediaContentRetValidator.ThrowIfError( + Interop.Tag.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information"); + tcs.TrySetResult(mediaContents); return tcs.Task; } diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/VideoInformation.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/VideoInformation.cs index 1c7872c..838f8a0 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/VideoInformation.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/VideoInformation.cs @@ -38,11 +38,9 @@ namespace Tizen.Content.MediaContent get { string mediaId = ""; - int result = Interop.VideoInformation.GetMediaId(_handle, out mediaId); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetMediaId(_handle, out mediaId), "Failed to get value"); + if (mediaId == null) { mediaId = ""; @@ -60,11 +58,9 @@ namespace Tizen.Content.MediaContent get { string album = ""; - int result = Interop.VideoInformation.GetAlbum(_handle, out album); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetAlbum(_handle, out album), "Failed to get value"); + if (album == null) { album = ""; @@ -82,11 +78,9 @@ namespace Tizen.Content.MediaContent get { string artist = ""; - int result = Interop.VideoInformation.GetArtist(_handle, out artist); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetArtist(_handle, out artist), "Failed to get value"); + if (artist == null) { artist = ""; @@ -104,11 +98,9 @@ namespace Tizen.Content.MediaContent get { string albumArtist = ""; - int result = Interop.VideoInformation.GetAlbumArtist(_handle, out albumArtist); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetAlbumArtist(_handle, out albumArtist), "Failed to get value"); + if (albumArtist == null) { albumArtist = ""; @@ -126,11 +118,9 @@ namespace Tizen.Content.MediaContent get { string genre = ""; - int result = Interop.VideoInformation.GetGenre(_handle, out genre); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetGenre(_handle, out genre), "Failed to get value"); + if (genre == null) { genre = ""; @@ -148,11 +138,9 @@ namespace Tizen.Content.MediaContent get { string composer = ""; - int result = Interop.VideoInformation.GetComposer(_handle, out composer); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetComposer(_handle, out composer), "Failed to get value"); + if (composer == null) { composer = ""; @@ -170,11 +158,9 @@ namespace Tizen.Content.MediaContent get { string year = ""; - int result = Interop.VideoInformation.GetYear(_handle, out year); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetYear(_handle, out year), "Failed to get value"); + if (year == null) { year = ""; @@ -191,11 +177,9 @@ namespace Tizen.Content.MediaContent get { string recordedDate = ""; - int result = Interop.VideoInformation.GetRecordedDate(_handle, out recordedDate); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetRecordedDate(_handle, out recordedDate), "Failed to get value"); + if (recordedDate == null) { recordedDate = ""; @@ -213,11 +197,9 @@ namespace Tizen.Content.MediaContent get { string copyright = ""; - int result = Interop.VideoInformation.GetCopyright(_handle, out copyright); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetCopyright(_handle, out copyright), "Failed to get value"); + if (copyright == null) { copyright = ""; @@ -235,11 +217,9 @@ namespace Tizen.Content.MediaContent get { string trackNumber = ""; - int result = Interop.VideoInformation.GetTrackNum(_handle, out trackNumber); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetTrackNum(_handle, out trackNumber), "Failed to get value"); + if (trackNumber == null) { trackNumber = ""; @@ -256,11 +236,9 @@ namespace Tizen.Content.MediaContent get { int bitrate = 0; - int result = Interop.VideoInformation.GetBitRate(_handle, out bitrate); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetBitRate(_handle, out bitrate), "Failed to get value"); + return bitrate; } } @@ -273,11 +251,9 @@ namespace Tizen.Content.MediaContent get { int duration = 0; - int result = Interop.VideoInformation.GetDuration(_handle, out duration); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetDuration(_handle, out duration), "Failed to get value"); + return duration; } } @@ -290,11 +266,9 @@ namespace Tizen.Content.MediaContent get { int width = 0; - int result = Interop.VideoInformation.GetWidth(_handle, out width); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetWidth(_handle, out width), "Failed to get value"); + return width; } } @@ -307,11 +281,9 @@ namespace Tizen.Content.MediaContent get { int height = 0; - int result = Interop.VideoInformation.GetHeight(_handle, out height); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.VideoInformation.GetHeight(_handle, out height), "Failed to get value"); + return height; } } @@ -326,11 +298,9 @@ namespace Tizen.Content.MediaContent { int count = 0; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError result = (MediaContentError)Interop.MediaInformation.GetBookmarkCount(MediaId, handle, out count); - if (result != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(result, "Error Occured with error code: "); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetBookmarkCount(MediaId, handle, out count), "Failed to get count"); + return count; } @@ -343,26 +313,20 @@ namespace Tizen.Content.MediaContent public Task<IEnumerable<MediaBookmark>> GetMediaBookmarksAsync(ContentFilter filter) { var task = new TaskCompletionSource<IEnumerable<MediaBookmark>>(); - MediaContentError result; + Collection<MediaBookmark> coll = new Collection<MediaBookmark>(); IntPtr filterHandle = (filter != null) ? filter.Handle : IntPtr.Zero; Interop.MediaInformation.MediaBookmarkCallback bookmarksCallback = (IntPtr handle, IntPtr userData) => { IntPtr newHandle; - result = (MediaContentError)Interop.MediaBookmark.Clone(out newHandle, handle); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Failed to clone Tag"); - } - MediaBookmark bookmark = new MediaBookmark(newHandle); - coll.Add(bookmark); + MediaContentRetValidator.ThrowIfError( + Interop.MediaBookmark.Clone(out newHandle, handle), "Failed to clone Tag"); + coll.Add(new MediaBookmark(newHandle)); return true; }; - result = (MediaContentError)Interop.MediaInformation.GetAllBookmarks(MediaId, filterHandle, bookmarksCallback, IntPtr.Zero); - if (result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } + MediaContentRetValidator.ThrowIfError( + Interop.MediaInformation.GetAllBookmarks(MediaId, filterHandle, bookmarksCallback, IntPtr.Zero), "Failed to get value"); + task.SetResult(coll); return task.Task; } |