Bulk modification of code related to memory allocation
authorMinje Ahn <minje.ahn@samsung.com>
Tue, 7 Mar 2017 10:48:09 +0000 (19:48 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Wed, 8 Mar 2017 01:34:18 +0000 (10:34 +0900)
Fix memory leaks
Remove unnecessary code

Change-Id: Ibbd4a5026536e15f50ac9941823675e9ebc7819f
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
28 files changed:
src/Tizen.Content.MediaContent/Interop/Interop.AudioInformation.cs
src/Tizen.Content.MediaContent/Interop/Interop.ImageInformation.cs
src/Tizen.Content.MediaContent/Interop/Interop.MediaBookmark.cs
src/Tizen.Content.MediaContent/Interop/Interop.MediaFace.cs
src/Tizen.Content.MediaContent/Interop/Interop.MediaFilter.cs
src/Tizen.Content.MediaContent/Interop/Interop.MediaFolder.cs
src/Tizen.Content.MediaContent/Interop/Interop.MediaGroup.cs
src/Tizen.Content.MediaContent/Interop/Interop.MediaInformation.cs
src/Tizen.Content.MediaContent/Interop/Interop.MediaPlaylist.cs
src/Tizen.Content.MediaContent/Interop/Interop.MediaStorage.cs
src/Tizen.Content.MediaContent/Interop/Interop.MediaTag.cs
src/Tizen.Content.MediaContent/Interop/Interop.VideoInformation.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Album.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/AudioInformation.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentDatabase.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentFilter.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentManager.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Group.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ImageInformation.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaBookmark.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaContentError.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFace.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFolder.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInformation.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlayList.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Storage.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Tag.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/VideoInformation.cs

index b3ea641..06412a6 100755 (executable)
@@ -22,34 +22,34 @@ internal static partial class Interop
         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 MediaContentError GetMediaId(SafeAudioInformationHandle audioInformationHandle, out string mediaId);
+        internal static extern MediaContentError GetMediaId(SafeAudioInformationHandle audioInformationHandle, out IntPtr mediaId);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_album", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetAlbum(SafeAudioInformationHandle audioInformationHandle, out string albumName);
+        internal static extern MediaContentError GetAlbum(SafeAudioInformationHandle audioInformationHandle, out IntPtr albumName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_artist", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetArtist(SafeAudioInformationHandle audioInformationHandle, out string artistName);
+        internal static extern MediaContentError GetArtist(SafeAudioInformationHandle audioInformationHandle, out IntPtr artistName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_album_artist", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetAlbumArtist(SafeAudioInformationHandle audioInformationHandle, out string albumArtistName);
+        internal static extern MediaContentError GetAlbumArtist(SafeAudioInformationHandle audioInformationHandle, out IntPtr albumArtistName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_genre", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetGenre(SafeAudioInformationHandle audioInformationHandle, out string genreName);
+        internal static extern MediaContentError GetGenre(SafeAudioInformationHandle audioInformationHandle, out IntPtr genreName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_composer", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetComposer(SafeAudioInformationHandle audioInformationHandle, out string composerName);
+        internal static extern MediaContentError GetComposer(SafeAudioInformationHandle audioInformationHandle, out IntPtr composerName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_year", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetYear(SafeAudioInformationHandle audioInformationHandle, out string year);
+        internal static extern MediaContentError GetYear(SafeAudioInformationHandle audioInformationHandle, out IntPtr year);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_recorded_date", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetRecordedDate(SafeAudioInformationHandle audioInformationHandle, out string recordedDate);
+        internal static extern MediaContentError GetRecordedDate(SafeAudioInformationHandle audioInformationHandle, out IntPtr recordedDate);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_copyright", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetCopyright(SafeAudioInformationHandle audioInformationHandle, out string copyright);
+        internal static extern MediaContentError GetCopyright(SafeAudioInformationHandle audioInformationHandle, out IntPtr copyright);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_track_num", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetTrackNum(SafeAudioInformationHandle audioInformationHandle, out string trackNum);
+        internal static extern MediaContentError GetTrackNum(SafeAudioInformationHandle audioInformationHandle, out IntPtr trackNum);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_bit_rate", CallingConvention = CallingConvention.Cdecl)]
         internal static extern MediaContentError GetBitRate(SafeAudioInformationHandle audioInformationHandle, out int bitRate);
index 3dd5c53..466e7b3 100755 (executable)
@@ -25,13 +25,13 @@ internal static partial class Interop
         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 MediaContentError GetDateTaken(SafeImageInformationHandle imageInformationHandle, out string dateTaken);
+        internal static extern MediaContentError GetDateTaken(SafeImageInformationHandle imageInformationHandle, out IntPtr dateTaken);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_burst_id", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetBurstId(SafeImageInformationHandle imageInformationHandle, out string burstId);
+        internal static extern MediaContentError GetBurstId(SafeImageInformationHandle imageInformationHandle, out IntPtr burstId);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_exposure_time", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetExposureTime(SafeImageInformationHandle imageInformationHandle, out string exposureTime);
+        internal static extern MediaContentError GetExposureTime(SafeImageInformationHandle imageInformationHandle, out IntPtr exposureTime);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_fnumber", CallingConvention = CallingConvention.Cdecl)]
         internal static extern MediaContentError GetFNumber(SafeImageInformationHandle imageInformationHandle, out double fNumber);
@@ -40,7 +40,7 @@ internal static partial class Interop
         internal static extern MediaContentError GetISO(SafeImageInformationHandle imageInformationHandle, out int iso);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_model", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetModel(SafeImageInformationHandle imageInformationHandle, out string model);
+        internal static extern MediaContentError GetModel(SafeImageInformationHandle imageInformationHandle, out IntPtr model);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_is_burst_shot", CallingConvention = CallingConvention.Cdecl)]
         internal static extern MediaContentError IsBurstShot(SafeImageInformationHandle imageInformationHandle, out bool isBurstShot);
@@ -49,7 +49,7 @@ internal static partial class Interop
         internal static extern MediaContentError SetOrientation(SafeImageInformationHandle imageInformationHandle, MediaContentOrientation orientation);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_media_id", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetMediaId(SafeImageInformationHandle imageInformationHandle, out string mediaId);
+        internal static extern MediaContentError GetMediaId(SafeImageInformationHandle imageInformationHandle, out IntPtr mediaId);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_width", CallingConvention = CallingConvention.Cdecl)]
         internal static extern MediaContentError GetWidth(SafeImageInformationHandle imageInformationHandle, out int width);
index 8b03a43..7ecb239 100755 (executable)
@@ -28,6 +28,6 @@ internal partial class Interop
         internal static extern MediaContentError GetMarkedTime(IntPtr bookmark, out uint marked_time);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_get_thumbnail_path")]
-        internal static extern MediaContentError GetThumbnailPath(IntPtr bookmark, out string filePath);
+        internal static extern MediaContentError GetThumbnailPath(IntPtr bookmark, out IntPtr filePath);
     }
 }
index 242f2c1..425f013 100755 (executable)
@@ -13,10 +13,10 @@ internal static partial class Interop
         internal static extern MediaContentError Destroy(IntPtr face);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_face_id")]
-        internal static extern MediaContentError GetFaceId(IntPtr face, out string face_id);
+        internal static extern MediaContentError GetFaceId(IntPtr face, out IntPtr face_id);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_media_id")]
-        internal static extern MediaContentError GetMediaId(IntPtr face, out string media_id);
+        internal static extern MediaContentError GetMediaId(IntPtr face, out IntPtr media_id);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_face_rect")]
         internal static extern MediaContentError GetFaceRect(IntPtr face, out int rect_x, out int rect_y, out int rect_w, out int IntPtr);
@@ -25,7 +25,7 @@ internal static partial class Interop
         internal static extern MediaContentError GetOrientation(IntPtr face, out int orientation);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_tag")]
-        internal static extern MediaContentError GetTag(IntPtr face, out string tag);
+        internal static extern MediaContentError GetTag(IntPtr face, out IntPtr tag);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_face_create")]
         internal static extern MediaContentError Create(string media_id, out IntPtr face);
index b017583..5b6f9e2 100755 (executable)
@@ -25,24 +25,24 @@ internal static partial class Interop
         internal static extern MediaContentError SetOffset(IntPtr filter, int offset, int count);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_set_condition")]
-        internal static extern MediaContentError SetCondition(IntPtr filter, string condition, int collate_type);
+        internal static extern MediaContentError SetCondition(IntPtr filter, string condition, ContentCollation type);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_set_order")]
-        internal static extern MediaContentError SetOrder(IntPtr filter, ContentOrder order_type, string order_keyword, ContentCollation collate_type);
+        internal static extern MediaContentError SetOrder(IntPtr filter, ContentOrder order, string keyword, ContentCollation type);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_set_storage")]
-        internal static extern MediaContentError SetStorage(IntPtr filter, string storage_id);
+        internal static extern MediaContentError SetStorage(IntPtr filter, string storageId);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_offset")]
         internal static extern MediaContentError GetOffset(IntPtr filter, out int offset, out int count);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_condition")]
-        internal static extern MediaContentError GetCondition(IntPtr filter, out string condition, out int collate_type);
+        internal static extern MediaContentError GetCondition(IntPtr filter, out IntPtr condition, out ContentCollation type);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_order")]
-        internal static extern MediaContentError GetOrder(IntPtr filter, out int order_type, out string order_keyword, out int collate_type);
+        internal static extern MediaContentError GetOrder(IntPtr filter, out ContentOrder order, out IntPtr keyword, out ContentCollation type);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_storage")]
-        internal static extern MediaContentError GetStorage(IntPtr filter, out string storage_id);
+        internal static extern MediaContentError GetStorage(IntPtr filter, out IntPtr storageId);
     }
 }
\ No newline at end of file
index 8d22955..430cb7d 100755 (executable)
@@ -19,26 +19,26 @@ internal static partial class Interop
         internal static extern MediaContentError Destroy(IntPtr folder);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_folder_id")]
-        internal static extern MediaContentError GetFolderId(IntPtr folder, out string folder_id);
+        internal static extern MediaContentError GetFolderId(IntPtr folder, out IntPtr folder_id);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_parent_folder_id")]
-        internal static extern MediaContentError GetParentFolderId(IntPtr folder, out string parent_folder_id);
+        internal static extern MediaContentError GetParentFolderId(IntPtr folder, out IntPtr parent_folder_id);
 
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_path")]
-        internal static extern MediaContentError GetPath(IntPtr folder, out string folderPath);
+        internal static extern MediaContentError GetPath(IntPtr folder, out IntPtr folderPath);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_name")]
-        internal static extern MediaContentError GetName(IntPtr folder, out string folder_name);
+        internal static extern MediaContentError GetName(IntPtr folder, out IntPtr folder_name);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_modified_time")]
         internal static extern MediaContentError GetModifiedTime(IntPtr folder, out DateTime date);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_storage_type")]
-        internal static extern MediaContentError GetStorageType(IntPtr folder, out int storage_type);
+        internal static extern MediaContentError GetStorageType(IntPtr folder, out ContentStorageType storage_type);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_storage_id")]
-        internal static extern MediaContentError GetStorageId(IntPtr folder, out string storage_id);
+        internal static extern MediaContentError GetStorageId(IntPtr folder, out IntPtr storage_id);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_order")]
         internal static extern MediaContentError GetOrder(IntPtr folder, out int order);
index 8e31c57..01c9525 100755 (executable)
@@ -22,13 +22,13 @@ internal static partial class Interop
         internal static extern MediaContentError MediaAlbumGetAlbumId(IntPtr album, out int album_id);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_name")]
-        internal static extern MediaContentError MediaAlbumGetName(IntPtr album, out string album_name);
+        internal static extern MediaContentError MediaAlbumGetName(IntPtr album, out IntPtr album_name);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_artist")]
-        internal static extern MediaContentError MediaAlbumGetArtist(IntPtr album, out string artist);
+        internal static extern MediaContentError MediaAlbumGetArtist(IntPtr album, out IntPtr artist);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_album_art")]
-        internal static extern MediaContentError MediaAlbumGetAlbumArt(IntPtr album, out string album_art);
+        internal static extern MediaContentError MediaAlbumGetAlbumArt(IntPtr album, out IntPtr album_art);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_album_from_db")]
         internal static extern MediaContentError MediaAlbumGetAlbumFromDb(int album_id, out IntPtr album);
index be4f04c..f5bcd7e 100755 (executable)
@@ -91,19 +91,19 @@ internal static partial class Interop
         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 MediaContentError GetMediaId(SafeMediaInformationHandle mediaInformationHandle, out string mediaId);
+        internal static extern MediaContentError GetMediaId(SafeMediaInformationHandle mediaInformationHandle, out IntPtr mediaId);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_file_path", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetFilePath(SafeMediaInformationHandle mediaInformationHandle, out string filePath);
+        internal static extern MediaContentError GetFilePath(SafeMediaInformationHandle mediaInformationHandle, out IntPtr filePath);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_display_name", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetDisplayName(SafeMediaInformationHandle mediaInformationHandle, out string name);
+        internal static extern MediaContentError GetDisplayName(SafeMediaInformationHandle mediaInformationHandle, out IntPtr name);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_type", CallingConvention = CallingConvention.Cdecl)]
         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 MediaContentError GetMimeType(SafeMediaInformationHandle mediaInformationHandle, out string mimeType);
+        internal static extern MediaContentError GetMimeType(SafeMediaInformationHandle mediaInformationHandle, out IntPtr mimeType);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_size", CallingConvention = CallingConvention.Cdecl)]
         internal static extern MediaContentError GetSize(SafeMediaInformationHandle mediaInformationHandle, out long size);
@@ -118,10 +118,10 @@ internal static partial class Interop
         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 MediaContentError GetThumbnailPath(SafeMediaInformationHandle mediaInformationHandle, out string filePath);
+        internal static extern MediaContentError GetThumbnailPath(SafeMediaInformationHandle mediaInformationHandle, out IntPtr filePath);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_description", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetDescription(SafeMediaInformationHandle mediaInformationHandle, out string description);
+        internal static extern MediaContentError GetDescription(SafeMediaInformationHandle mediaInformationHandle, out IntPtr description);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_longitude", CallingConvention = CallingConvention.Cdecl)]
         internal static extern MediaContentError GetLongitude(SafeMediaInformationHandle mediaInformationHandle, out double longitude);
@@ -133,7 +133,7 @@ internal static partial class Interop
         internal static extern MediaContentError GetAltitude(SafeMediaInformationHandle mediaInformationHandle, out double altitude);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_weather", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetWeather(SafeMediaInformationHandle mediaInformationHandle, out string weather);
+        internal static extern MediaContentError GetWeather(SafeMediaInformationHandle mediaInformationHandle, out IntPtr weather);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_rating", CallingConvention = CallingConvention.Cdecl)]
         internal static extern MediaContentError GetRating(SafeMediaInformationHandle mediaInformationHandle, out int rating);
@@ -142,31 +142,31 @@ internal static partial class Interop
         internal static extern MediaContentError GetFavorite(SafeMediaInformationHandle mediaInformationHandle, out bool favorite);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_author", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetAuthor(SafeMediaInformationHandle mediaInformationHandle, out string author);
+        internal static extern MediaContentError GetAuthor(SafeMediaInformationHandle mediaInformationHandle, out IntPtr author);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_provider", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetProvider(SafeMediaInformationHandle mediaInformationHandle, out string provider);
+        internal static extern MediaContentError GetProvider(SafeMediaInformationHandle mediaInformationHandle, out IntPtr provider);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_content_name", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetContentName(SafeMediaInformationHandle mediaInformationHandle, out string contentName);
+        internal static extern MediaContentError GetContentName(SafeMediaInformationHandle mediaInformationHandle, out IntPtr contentName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_title", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetTitle(SafeMediaInformationHandle mediaInformationHandle, out string title);
+        internal static extern MediaContentError GetTitle(SafeMediaInformationHandle mediaInformationHandle, out IntPtr title);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_category", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetCategory(SafeMediaInformationHandle mediaInformationHandle, out string category);
+        internal static extern MediaContentError GetCategory(SafeMediaInformationHandle mediaInformationHandle, out IntPtr category);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_location_tag", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetLocationTag(SafeMediaInformationHandle mediaInformationHandle, out string locationTag);
+        internal static extern MediaContentError GetLocationTag(SafeMediaInformationHandle mediaInformationHandle, out IntPtr locationTag);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_age_rating", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetAgeRating(SafeMediaInformationHandle mediaInformationHandle, out string ageRating);
+        internal static extern MediaContentError GetAgeRating(SafeMediaInformationHandle mediaInformationHandle, out IntPtr ageRating);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_keyword", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetKeyword(SafeMediaInformationHandle mediaInformationHandle, out string keyword);
+        internal static extern MediaContentError GetKeyword(SafeMediaInformationHandle mediaInformationHandle, out IntPtr keyword);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_storage_id", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetStorageId(SafeMediaInformationHandle mediaInformationHandle, out string storageId);
+        internal static extern MediaContentError GetStorageId(SafeMediaInformationHandle mediaInformationHandle, out IntPtr storageId);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_is_drm", CallingConvention = CallingConvention.Cdecl)]
         internal static extern MediaContentError IsDrm(SafeMediaInformationHandle mediaInformationHandle, out bool isDrm);
index d4b4ab3..29a5c18 100755 (executable)
@@ -31,13 +31,13 @@ internal static partial class Interop
         internal static extern MediaContentError GetPlaylistId(IntPtr playlist, out int playlist_id);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_name")]
-        internal static extern MediaContentError GetName(IntPtr playlist, out string playlist_name);
+        internal static extern MediaContentError GetName(IntPtr playlist, out IntPtr playlist_name);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_set_name")]
         internal static extern MediaContentError SetName(IntPtr playlist, string playlist_name);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_thumbnail_path")]
-        internal static extern MediaContentError GetThumbnailPath(IntPtr playlist, out string filePath);
+        internal static extern MediaContentError GetThumbnailPath(IntPtr playlist, out IntPtr filePath);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_set_thumbnail_path")]
         internal static extern MediaContentError SetThumbnailPath(IntPtr playlist, string filePath);
index 6431a5d..3697c48 100755 (executable)
@@ -22,16 +22,16 @@ internal static partial class Interop
         internal static extern MediaContentError Clone(out IntPtr dst, IntPtr src);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_id")]
-        internal static extern MediaContentError GetId(IntPtr storage, out string storage_id);
+        internal static extern MediaContentError GetId(IntPtr storage, out IntPtr storage_id);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_name")]
-        internal static extern MediaContentError GetName(IntPtr storage, out string storage_name);
+        internal static extern MediaContentError GetName(IntPtr storage, out IntPtr storage_name);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_path")]
-        internal static extern MediaContentError GetPath(IntPtr storage, out string storage_path);
+        internal static extern MediaContentError GetPath(IntPtr storage, out IntPtr storage_path);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_type")]
-        internal static extern MediaContentError GetType(IntPtr storage, out int storage_type);
+        internal static extern MediaContentError GetType(IntPtr storage, out ContentStorageType storage_type);
 
         //Callbacks
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
index 3740231..d3f4ac5 100755 (executable)
@@ -28,7 +28,7 @@ internal static partial class Interop
         internal static extern MediaContentError GetTagId(IntPtr tag, out int tag_id);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_get_name")]
-        internal static extern MediaContentError GetName(IntPtr tag, out string tag_name);
+        internal static extern MediaContentError GetName(IntPtr tag, out IntPtr tag_name);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "media_tag_get_tag_from_db")]
         internal static extern MediaContentError GetTagFromDb(int tag_id, out IntPtr tag);
@@ -47,7 +47,7 @@ internal static partial class Interop
 
         //Callbacks
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        internal delegate void MediaInfoCallback(IntPtr mediaInformation, IntPtr data);
+        internal delegate bool MediaInfoCallback(IntPtr mediaInformation, IntPtr data);
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate bool MediaTagCallback(IntPtr tag, IntPtr data);
index e44c8a8..d38d7c2 100755 (executable)
@@ -22,34 +22,34 @@ internal static partial class Interop
         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 MediaContentError GetMediaId(SafeVideoInformationHandle videoInformationHandle, out string mediaId);
+        internal static extern MediaContentError GetMediaId(SafeVideoInformationHandle videoInformationHandle, out IntPtr mediaId);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_album", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetAlbum(SafeVideoInformationHandle videoInformationHandle, out string albumName);
+        internal static extern MediaContentError GetAlbum(SafeVideoInformationHandle videoInformationHandle, out IntPtr albumName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_artist", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetArtist(SafeVideoInformationHandle videoInformationHandle, out string artistName);
+        internal static extern MediaContentError GetArtist(SafeVideoInformationHandle videoInformationHandle, out IntPtr artistName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_album_artist", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetAlbumArtist(SafeVideoInformationHandle videoInformationHandle, out string albumArtistName);
+        internal static extern MediaContentError GetAlbumArtist(SafeVideoInformationHandle videoInformationHandle, out IntPtr albumArtistName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_genre", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetGenre(SafeVideoInformationHandle videoInformationHandle, out string genreName);
+        internal static extern MediaContentError GetGenre(SafeVideoInformationHandle videoInformationHandle, out IntPtr genreName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_composer", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetComposer(SafeVideoInformationHandle videoInformationHandle, out string composerName);
+        internal static extern MediaContentError GetComposer(SafeVideoInformationHandle videoInformationHandle, out IntPtr composerName);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_year", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetYear(SafeVideoInformationHandle videoInformationHandle, out string year);
+        internal static extern MediaContentError GetYear(SafeVideoInformationHandle videoInformationHandle, out IntPtr year);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_recorded_date", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetRecordedDate(SafeVideoInformationHandle videoInformationHandle, out string recordedDate);
+        internal static extern MediaContentError GetRecordedDate(SafeVideoInformationHandle videoInformationHandle, out IntPtr recordedDate);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_copyright", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetCopyright(SafeVideoInformationHandle videoInformationHandle, out string copyright);
+        internal static extern MediaContentError GetCopyright(SafeVideoInformationHandle videoInformationHandle, out IntPtr copyright);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_track_num", CallingConvention = CallingConvention.Cdecl)]
-        internal static extern MediaContentError GetTrackNum(SafeVideoInformationHandle videoInformationHandle, out string trackNum);
+        internal static extern MediaContentError GetTrackNum(SafeVideoInformationHandle videoInformationHandle, out IntPtr trackNum);
 
         [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_bit_rate", CallingConvention = CallingConvention.Cdecl)]
         internal static extern MediaContentError GetBitRate(SafeVideoInformationHandle videoInformationHandle, out int bitRate);
index 12c4ec2..16a8f78 100755 (executable)
@@ -18,6 +18,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 
 namespace Tizen.Content.MediaContent
@@ -37,7 +38,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int id = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Group.MediaAlbumGetAlbumId(_albumHandle, out id), "Failed to get value");
 
                 return id;
@@ -51,11 +52,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string artist = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Group.MediaAlbumGetArtist(_albumHandle, out artist), "Failed to get value");
-
-                return artist;
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Group.MediaAlbumGetArtist(_albumHandle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -66,11 +74,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string art = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Group.MediaAlbumGetAlbumArt(_albumHandle, out art), "Failed to get value");
-
-                return art;
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Group.MediaAlbumGetAlbumArt(_albumHandle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -81,11 +96,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string name = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Group.MediaAlbumGetArtist(_albumHandle, out name), "Failed to get value");
-
-                return name;
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Group.MediaAlbumGetName(_albumHandle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -105,7 +127,7 @@ namespace Tizen.Content.MediaContent
             int mediaCount = 0;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
 
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Group.MediaAlbumGetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count");
 
             return mediaCount;
@@ -135,13 +157,13 @@ namespace Tizen.Content.MediaContent
             Interop.Group.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) =>
             {
                 Interop.MediaInformation.SafeMediaInformationHandle newHandle;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone");
 
                 mediaContents.Add(new MediaInformation(newHandle));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Group.MediaAlbumForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information");
 
             tcs.TrySetResult(mediaContents);
index 110cfed..b6a2cdd 100755 (executable)
@@ -43,15 +43,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string mediaId = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.AudioInformation.GetMediaId(_handle, out mediaId), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.AudioInformation.GetMediaId(_handle, out val), "Failed to get value");
 
-                if (mediaId == null)
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
                 {
-                    mediaId = "";
+                    Interop.Libc.Free(val);
                 }
-                return mediaId;
             }
         }
 
@@ -64,15 +67,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string album = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.AudioInformation.GetAlbum(_handle, out album), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.AudioInformation.GetAlbum(_handle, out val), "Failed to get value");
 
-                if (album == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    album = "";
+                    Interop.Libc.Free(val);
                 }
-                return album;
             }
         }
 
@@ -85,15 +91,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string artist = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.AudioInformation.GetArtist(_handle, out artist), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.AudioInformation.GetArtist(_handle, out val), "Failed to get value");
 
-                if (artist == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    artist = "";
+                    Interop.Libc.Free(val);
                 }
-                return artist;
             }
         }
 
@@ -106,15 +115,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string albumArtist = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.AudioInformation.GetAlbumArtist(_handle, out albumArtist), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.AudioInformation.GetAlbumArtist(_handle, out val), "Failed to get value");
 
-                if (albumArtist == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    albumArtist = "";
+                    Interop.Libc.Free(val);
                 }
-                return albumArtist;
             }
         }
 
@@ -127,15 +139,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string genre = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.AudioInformation.GetGenre(_handle, out genre), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.AudioInformation.GetGenre(_handle, out val), "Failed to get value");
 
-                if (genre == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    genre = "";
+                    Interop.Libc.Free(val);
                 }
-                return genre;
             }
         }
 
@@ -148,15 +163,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string composer = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.AudioInformation.GetComposer(_handle, out composer), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.AudioInformation.GetComposer(_handle, out val), "Failed to get value");
 
-                if (composer == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    composer = "";
+                    Interop.Libc.Free(val);
                 }
-                return composer;
             }
         }
 
@@ -169,15 +187,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string year = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.AudioInformation.GetYear(_handle, out year), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.AudioInformation.GetYear(_handle, out val), "Failed to get value");
 
-                if (year == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    year = "";
+                    Interop.Libc.Free(val);
                 }
-                return year;
             }
         }
 
@@ -188,15 +209,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string recordedDate = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.AudioInformation.GetRecordedDate(_handle, out recordedDate), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.AudioInformation.GetRecordedDate(_handle, out val), "Failed to get value");
 
-                if (recordedDate == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    recordedDate = "";
+                    Interop.Libc.Free(val);
                 }
-                return recordedDate;
             }
         }
 
@@ -208,15 +232,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string copyright = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.AudioInformation.GetCopyright(_handle, out copyright), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.AudioInformation.GetCopyright(_handle, out val), "Failed to get value");
 
-                if (copyright == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    copyright = "";
+                    Interop.Libc.Free(val);
                 }
-                return copyright;
             }
         }
 
@@ -228,15 +255,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string trackNumber = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.AudioInformation.GetTrackNum(_handle, out trackNumber), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.AudioInformation.GetTrackNum(_handle, out val), "Failed to get value");
 
-                if (trackNumber == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    trackNumber = "";
+                    Interop.Libc.Free(val);
                 }
-                return trackNumber;
             }
         }
 
@@ -248,7 +278,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int bitrate = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.AudioInformation.GetBitRate(_handle, out bitrate), "Failed to get value");
 
                 return bitrate;
@@ -263,7 +293,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int bitPerSample = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.AudioInformation.GetBitPerSample(_handle, out bitPerSample), "Failed to get value");
 
                 return bitPerSample;
@@ -278,7 +308,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int sampleRate = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.AudioInformation.GetSampleRate(_handle, out sampleRate), "Failed to get value");
 
                 return sampleRate;
@@ -293,7 +323,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int channel = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.AudioInformation.GetChannel(_handle, out channel), "Failed to get value");
 
                 return channel;
@@ -308,7 +338,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int duration = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.AudioInformation.GetDuration(_handle, out duration), "Failed to get value");
 
                 return duration;
@@ -326,7 +356,7 @@ namespace Tizen.Content.MediaContent
         {
             int count = 0;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.GetBookmarkCount(MediaId, handle, out count), "Failed to get count");
 
             return count;
@@ -348,14 +378,14 @@ namespace Tizen.Content.MediaContent
             IntPtr filterHandle = (filter != null) ? filter.Handle : IntPtr.Zero;
             Interop.MediaInformation.MediaBookmarkCallback callback = (IntPtr handle, IntPtr userData) =>
             {
-                IntPtr newHandle;
-                MediaContentRetValidator.ThrowIfError(
+                IntPtr newHandle = IntPtr.Zero;
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaBookmark.Clone(out newHandle, handle), "Failed to clone");
 
                 coll.Add(new MediaBookmark(newHandle));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.GetAllBookmarks(MediaId, filterHandle, callback, IntPtr.Zero), "Failed to get value");
 
             task.SetResult(coll);
index b6b6892..e37ca93 100755 (executable)
@@ -18,6 +18,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 /// <summary>
 /// The Media Content API provides functions, enumerations used in the entire Content Service.
@@ -51,7 +52,7 @@ namespace Tizen.Content.MediaContent
         {
             if (!_isConnected)
             {
-                MediaContentRetValidator.ThrowIfError(Interop.Content.Connect(), "Connect failed");
+                MediaContentValidator.ThrowIfError(Interop.Content.Connect(), "Connect failed");
 
                 _isConnected = true;
             }
@@ -60,17 +61,27 @@ namespace Tizen.Content.MediaContent
         {
             if (_isConnected)
             {
-                MediaContentRetValidator.ThrowIfError(Interop.Content.Disconnect(), "Disconnect failed");
+                MediaContentValidator.ThrowIfError(Interop.Content.Disconnect(), "Disconnect failed");
 
                 _isConnected = false;
             }
         }
 
-        private static readonly Interop.Content.MediaContentDBUpdatedCallback s_contentUpdatedCallback = (MediaContentError error, int pid, MediaContentUpdateItemType updateItem, MediaContentDBUpdateType updateType, MediaContentType mediaType, string uuid, string filePath, string mimeType, IntPtr userData) =>
+        private static readonly Interop.Content.MediaContentDBUpdatedCallback s_contentUpdatedCallback = (
+            MediaContentError error,
+            int pid,
+            MediaContentUpdateItemType updateItem,
+            MediaContentDBUpdateType updateType,
+            MediaContentType mediaType,
+            string uuid,
+            string filePath,
+            string mimeType,
+            IntPtr userData) =>
         {
-            ContentUpdatedEventArgs eventArgs = new ContentUpdatedEventArgs(error, pid, updateItem, updateType, mediaType, uuid, filePath, mimeType);
-            s_contentUpdated?.Invoke(null, eventArgs);
+            s_contentUpdated?.Invoke(
+                null, new ContentUpdatedEventArgs(error, pid, updateItem, updateType, mediaType, uuid, filePath, mimeType));
         };
+
         private static event EventHandler<ContentUpdatedEventArgs> s_contentUpdated;
         /// <summary>
         /// ContentUpdated event is triggered when the media DB changes.
@@ -83,7 +94,7 @@ namespace Tizen.Content.MediaContent
             {
                 if (s_contentUpdated == null)
                 {
-                    MediaContentRetValidator.ThrowIfError(
+                    MediaContentValidator.ThrowIfError(
                         Interop.Content.SetDbUpdatedCb(s_contentUpdatedCallback, IntPtr.Zero), "Failed to set callback");
                 }
                 s_contentUpdated += value;
@@ -94,7 +105,7 @@ namespace Tizen.Content.MediaContent
                 s_contentUpdated -= value;
                 if (s_contentUpdated == null)
                 {
-                    MediaContentRetValidator.ThrowIfError(
+                    MediaContentValidator.ThrowIfError(
                         Interop.Content.UnsetDbUpdatedCb(), "Failed to unset callback");
                 }
             }
@@ -109,52 +120,59 @@ namespace Tizen.Content.MediaContent
         {
             int count = 0;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentError res = MediaContentError.None;
             MediaGroupType groupType = MediaGroupType.DisplayName;
             if (handle != IntPtr.Zero)
+            {
                 groupType = filter.GroupType;
+            }
 
             ConnectToDB();
 
             if (typeof(T) == typeof(MediaInformation))
             {
-                res = (MediaContentError)Interop.MediaInformation.GetMediaCount(handle, out count);
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.GetMediaCount(handle, out count), "Failed to get count");
             }
             else if (typeof(T) == typeof(MediaBookmark))
             {
-                res = (MediaContentError)Interop.MediaBookmark.GetBookmarkCountFromDb(handle, out count);
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaBookmark.GetBookmarkCountFromDb(handle, out count), "Failed to get count");
             }
             else if (typeof(T) == typeof(Album))
             {
-                res = (MediaContentError)Interop.Group.MediaAlbumGetAlbumCountFromDb(handle, out count);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Group.MediaAlbumGetAlbumCountFromDb(handle, out count), "Failed to get count");
             }
             else if (typeof(T) == typeof(MediaFolder))
             {
-                res = (MediaContentError)Interop.Folder.GetFolderCountFromDb(handle, out count);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Folder.GetFolderCountFromDb(handle, out count), "Failed to get count");
             }
             else if (typeof(T) == typeof(Storage))
             {
-                res = (MediaContentError)Interop.Storage.GetStorageCountFromDb(handle, out count);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Storage.GetStorageCountFromDb(handle, out count), "Failed to get count");
             }
             else if (typeof(T) == typeof(Tag))
             {
-                res = (MediaContentError)Interop.Tag.GetTagCountFromDb(handle, out count);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Tag.GetTagCountFromDb(handle, out count), "Failed to get count");
             }
             else if (typeof(T) == typeof(PlayList))
             {
-                res = (MediaContentError)Interop.Playlist.GetPlaylistCountFromDb(handle, out count);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Playlist.GetPlaylistCountFromDb(handle, out count), "Failed to get count");
             }
             else if (typeof(T) == typeof(Group))
             {
-                res = (MediaContentError)Interop.Group.GetGroupCountFromDb(handle, groupType, out count);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Group.GetGroupCountFromDb(handle, groupType, out count), "Failed to get count");
             }
             else
             {
-                res = MediaContentError.InvalidParameter;
+                throw new ArgumentException("Wrong type");
             }
 
-            MediaContentRetValidator.ThrowIfError(res, "Failed to get count for the content");
-
             return count;
         }
 
@@ -166,13 +184,11 @@ namespace Tizen.Content.MediaContent
         public MediaInformation Select(string id)
         {
             ConnectToDB();
-            MediaInformation result;
             Interop.MediaInformation.SafeMediaInformationHandle mediaHandle;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.GetMediaFromDB(id, out mediaHandle), "Failed to get information");
 
-            result = new MediaInformation(mediaHandle);
-            return result;
+            return new MediaInformation(mediaHandle);
         }
 
         /// <summary>
@@ -185,27 +201,28 @@ namespace Tizen.Content.MediaContent
         {
             ConnectToDB();
             ContentCollection result = null;
+            IntPtr handle = IntPtr.Zero;
+
             if (typeof(T) == typeof(MediaFolder))
             {
-                IntPtr handle = IntPtr.Zero;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Folder.GetFolderFromDb(id, out handle), "Failed to get information");
 
-                if (handle != IntPtr.Zero)
-                    result = new MediaFolder(handle);
+                result = new MediaFolder(handle);
+
+                return (T)result;
             }
             else if (typeof(T) == typeof(Storage))
             {
-                IntPtr handle = IntPtr.Zero;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Storage.GetStorageInfoFromDb(id, out handle), "Failed to get information");
 
-                if (handle != IntPtr.Zero)
-                {
-                    result = new Storage(handle);
-                }
+                result = new Storage(handle);
+
+                return (T)result;
             }
-            return (result != null) ? (T)result : null;
+
+            return null;
         }
 
 
@@ -218,71 +235,75 @@ namespace Tizen.Content.MediaContent
         public T Select<T>(int id) where T : ContentCollection
         {
             ConnectToDB();
-            ContentCollection contentCollection = null;
-            IntPtr _handle;
+            ContentCollection result = null;
+            IntPtr handle = IntPtr.Zero;
+
             if (typeof(T) == typeof(PlayList))
             {
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Playlist.GetPlaylistFromDb(id, out _handle), "Failed to get information");
+                MediaContentValidator.ThrowIfError(
+                    Interop.Playlist.GetPlaylistFromDb(id, out handle), "Failed to get information");
 
-                if (_handle != IntPtr.Zero)
-                    contentCollection = new PlayList(_handle);
+                result = new PlayList(handle);
+
+                return (T)result;
             }
             else if (typeof(T) == typeof(Album))
             {
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Group.MediaAlbumGetAlbumFromDb(id, out _handle), "Failed to get information");
+                MediaContentValidator.ThrowIfError(
+                Interop.Group.MediaAlbumGetAlbumFromDb(id, out handle), "Failed to get information");
+
+                result = new Album(handle);
 
-                if (_handle != IntPtr.Zero)
-                    contentCollection = new Album(_handle);
+                return (T)result;
             }
             else if (typeof(T) == typeof(Tag))
             {
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Tag.GetTagFromDb(id, out _handle), "Failed to get information");
+                MediaContentValidator.ThrowIfError(
+                    Interop.Tag.GetTagFromDb(id, out handle), "Failed to get information");
 
-                if (_handle != IntPtr.Zero)
-                    contentCollection = new Tag(_handle);
+                result = new Tag(handle);
+
+                return (T)result;
             }
-            return (contentCollection != null) ? (T)contentCollection : null;
+            return null;
         }
 
         private static IEnumerable<MediaFolder> ForEachFolder(ContentFilter filter)
         {
-            List<MediaFolder> folderCollections = new List<MediaFolder>();
-            Interop.Folder.MediaFolderCallback folderCallback = (IntPtr folderHandle, IntPtr data) =>
+            List<MediaFolder> result = new List<MediaFolder>();
+            Interop.Folder.MediaFolderCallback callback = (IntPtr handle, IntPtr data) =>
             {
-                IntPtr newHandle;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Folder.Clone(out newHandle, folderHandle), "Failed to clone");
+                IntPtr newHandle = IntPtr.Zero;
+                MediaContentValidator.ThrowIfError(
+                    Interop.Folder.Clone(out newHandle, handle), "Failed to clone");
 
-                folderCollections.Add(new MediaFolder(newHandle));
+                result.Add(new MediaFolder(newHandle));
                 return true;
             };
             IntPtr filterHandle = filter != null ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
-                Interop.Folder.ForeachFolderFromDb(filterHandle, folderCallback, IntPtr.Zero), "Failed to get information");
+            MediaContentValidator.ThrowIfError(
+                Interop.Folder.ForeachFolderFromDb(filterHandle, callback, IntPtr.Zero), "Failed to get information");
 
-            return folderCollections;
+            return result;
         }
 
         private static IEnumerable<Album> ForEachAlbum(ContentFilter filter)
         {
-            List<Album> albumCollections = new List<Album>();
-            Interop.Group.MediaAlbumCallback albumCallback = (IntPtr albumHandle, IntPtr data) =>
+            List<Album> result = new List<Album>();
+            Interop.Group.MediaAlbumCallback callback = (IntPtr handle, IntPtr data) =>
             {
                 IntPtr newHandle = IntPtr.Zero;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Group.MediaAlbumClone(out newHandle, albumHandle), "Failed to clone");
+                MediaContentValidator.ThrowIfError(
+                    Interop.Group.MediaAlbumClone(out newHandle, handle), "Failed to clone");
 
-                albumCollections.Add(new Album(newHandle));
+                result.Add(new Album(newHandle));
                 return true;
             };
-            IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
-                Interop.Group.MediaAlbumForeachAlbumFromDb(handle, albumCallback, IntPtr.Zero), "Failed to get information");
+            IntPtr filterHandle = (filter != null) ? filter.Handle : IntPtr.Zero;
+            MediaContentValidator.ThrowIfError(
+                Interop.Group.MediaAlbumForeachAlbumFromDb(filterHandle, callback, IntPtr.Zero), "Failed to get information");
 
-            return albumCollections;
+            return result;
         }
 
         private static IEnumerable<Group> ForEachGroup(ContentFilter filter)
@@ -298,75 +319,75 @@ namespace Tizen.Content.MediaContent
                 groupType = filter.GroupType;
             }
 
-            List<Group> groupCollections = new List<Group>();
-            Interop.Group.MediaGroupCallback groupCallback = (string groupName, IntPtr data) =>
+            List<Group> result = new List<Group>();
+            Interop.Group.MediaGroupCallback callback = (string groupName, IntPtr data) =>
             {
-                groupCollections.Add(new Group(groupName, groupType));
+                result.Add(new Group(groupName, groupType));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
-                Interop.Group.ForeachGroupFromDb(handle, groupType, groupCallback, IntPtr.Zero), "Failed to get information");
+            MediaContentValidator.ThrowIfError(
+                Interop.Group.ForeachGroupFromDb(handle, groupType, callback, IntPtr.Zero), "Failed to get information");
 
-            return groupCollections;
+            return result;
         }
 
         private static IEnumerable<Storage> ForEachStorage(ContentFilter filter)
         {
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            List<Storage> storageCollections = new List<Storage>();
-            Interop.Storage.MediaStorageCallback storageCallback = (IntPtr storageHandle, IntPtr data) =>
+            List<Storage> result = new List<Storage>();
+            Interop.Storage.MediaStorageCallback callback = (IntPtr storageHandle, IntPtr data) =>
             {
-                IntPtr newHandle;
-                MediaContentRetValidator.ThrowIfError(
+                IntPtr newHandle = IntPtr.Zero;
+                MediaContentValidator.ThrowIfError(
                     Interop.Storage.Clone(out newHandle, storageHandle), "Failed to clone");
 
-                storageCollections.Add(new Storage(newHandle));
+                result.Add(new Storage(newHandle));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
-                Interop.Storage.ForeachStorageFromDb(handle, storageCallback, IntPtr.Zero), "Failed to get information");
+            MediaContentValidator.ThrowIfError(
+                Interop.Storage.ForeachStorageFromDb(handle, callback, IntPtr.Zero), "Failed to get information");
 
-            return storageCollections;
+            return result;
         }
 
         private static IEnumerable<Tag> ForEachTag(ContentFilter filter)
         {
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
 
-            List<Tag> tagCollections = new List<Tag>();
-            Interop.Tag.MediaTagCallback tagCallback = (IntPtr tagHandle, IntPtr data) =>
+            List<Tag> result = new List<Tag>();
+            Interop.Tag.MediaTagCallback callback = (IntPtr tagHandle, IntPtr data) =>
             {
-                IntPtr newHandle;
-                MediaContentRetValidator.ThrowIfError(
+                IntPtr newHandle = IntPtr.Zero;
+                MediaContentValidator.ThrowIfError(
                     Interop.Tag.Clone(out newHandle, tagHandle), "Failed to clone");
 
-                tagCollections.Add(new Tag(newHandle));
+                result.Add(new Tag(newHandle));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
-                Interop.Tag.ForeachTagFromDb(handle, tagCallback, IntPtr.Zero), "Failed to get information");
+            MediaContentValidator.ThrowIfError(
+                Interop.Tag.ForeachTagFromDb(handle, callback, IntPtr.Zero), "Failed to get information");
 
-            return tagCollections;
+            return result;
         }
 
         private static IEnumerable<PlayList> ForEachPlayList(ContentFilter filter)
         {
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
 
-            List<PlayList> playListCollections = new List<PlayList>();
-            Interop.Playlist.MediaPlaylistCallback playListCallback = (IntPtr playListHandle, IntPtr data) =>
+            List<PlayList> result = new List<PlayList>();
+            Interop.Playlist.MediaPlaylistCallback callback = (IntPtr playListHandle, IntPtr data) =>
             {
-                IntPtr newHandle;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Tag.Clone(out newHandle, playListHandle), "Failed to clone");
+                IntPtr newHandle = IntPtr.Zero;
+                MediaContentValidator.ThrowIfError(
+                    Interop.Playlist.Clone(out newHandle, playListHandle), "Failed to clone");
 
-                playListCollections.Add(new PlayList(newHandle));
+                result.Add(new PlayList(newHandle));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
-                Interop.Playlist.ForeachPlaylistFromDb(handle, playListCallback, IntPtr.Zero), "Failed to get information");
+            MediaContentValidator.ThrowIfError(
+                Interop.Playlist.ForeachPlaylistFromDb(handle, callback, IntPtr.Zero), "Failed to get information");
 
-            return playListCollections;
+            return result;
         }
 
         /// <summary>
@@ -433,15 +454,15 @@ namespace Tizen.Content.MediaContent
             Interop.MediaInformation.MediaInformationCallback callback = (IntPtr mediaHandle, IntPtr userData) =>
             {
                 Interop.MediaInformation.SafeMediaInformationHandle newHandle;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone");
+                MediaContentValidator.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;
-                    MediaContentRetValidator.ThrowIfError(
+                    MediaContentValidator.ThrowIfError(
                         Interop.MediaInformation.GetImage(mediaHandle, out imageInfo), "Failed to get image information");
 
                     mediaInformationList.Add(new ImageInformation(imageInfo, newHandle));
@@ -449,7 +470,7 @@ namespace Tizen.Content.MediaContent
                 else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound))
                 {
                     Interop.AudioInformation.SafeAudioInformationHandle audioInfo;
-                    MediaContentRetValidator.ThrowIfError(
+                    MediaContentValidator.ThrowIfError(
                         Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo), "Failed to get audio information");
 
                     mediaInformationList.Add(new AudioInformation(audioInfo, newHandle));
@@ -457,7 +478,7 @@ namespace Tizen.Content.MediaContent
                 else if (type == MediaContentType.Video)
                 {
                     Interop.VideoInformation.SafeVideoInformationHandle videoInfo;
-                    MediaContentRetValidator.ThrowIfError(
+                    MediaContentValidator.ThrowIfError(
                         Interop.MediaInformation.GetVideo(mediaHandle, out videoInfo), "Failed to get video information");
 
                     mediaInformationList.Add(new VideoInformation(videoInfo, newHandle));
@@ -466,9 +487,10 @@ namespace Tizen.Content.MediaContent
                 {
                     mediaInformationList.Add(new MediaInformation(newHandle));
                 }
+
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.GetAllMedia(handle, callback, IntPtr.Zero), "Failed to get media information");
 
             return mediaInformationList;
@@ -481,7 +503,7 @@ namespace Tizen.Content.MediaContent
         public void Delete(MediaInformation mediaInfo)
         {
             ConnectToDB();
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.Delete(mediaInfo.MediaId), "Failed to remove information");
         }
 
@@ -499,12 +521,12 @@ namespace Tizen.Content.MediaContent
 
             if (type == typeof(Tag))
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Tag.DeleteFromDb(((Tag)contentcollection).Id), "Failed to remove information");
             }
             else if (type == typeof(PlayList))
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Playlist.DeleteFromDb(((PlayList)contentcollection).Id), "Failed to remove information");
             }
             else
@@ -516,14 +538,14 @@ namespace Tizen.Content.MediaContent
         internal void Delete(MediaBookmark bookmark)
         {
             ConnectToDB();
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaBookmark.DeleteFromDb(bookmark.Id), "Failed to remove information");
         }
 
         internal void Delete(MediaFace face)
         {
             ConnectToDB();
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Face.DeleteFromDb(face.Id), "Failed to remove face information");
         }
 
@@ -536,25 +558,25 @@ namespace Tizen.Content.MediaContent
         {
             ConnectToDB();
             Type type = contentCollection.GetType();
-            MediaContentError result = MediaContentError.None;
             if (type == typeof(Tag))
             {
-                result = (MediaContentError)Interop.Tag.UpdateToDb(((Tag)contentCollection).Handle);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Tag.UpdateToDb(((Tag)contentCollection).Handle), "Failed to update DB");
             }
             else if (type == typeof(PlayList))
             {
-                result = (MediaContentError)Interop.Playlist.UpdateToDb(((PlayList)contentCollection).Handle);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Playlist.UpdateToDb(((PlayList)contentCollection).Handle), "Failed to update DB");
             }
             else if (type == typeof(MediaFolder))
             {
-                result = (MediaContentError)Interop.Folder.UpdateToDb(((MediaFolder)contentCollection).Handle);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Folder.UpdateToDb(((MediaFolder)contentCollection).Handle), "Failed to update DB");
             }
             else
             {
-                result = MediaContentError.InvalidParameter;
+                throw new ArgumentException("The type of content collection is wrong");
             }
-
-            MediaContentRetValidator.ThrowIfError(result, "Failed to update DB");
         }
 
         /// <summary>
@@ -565,36 +587,36 @@ namespace Tizen.Content.MediaContent
         {
             ConnectToDB();
             Type type = mediaInfo.GetType();
-            MediaContentError result = MediaContentError.None;
             if (type == typeof(ImageInformation))
             {
-                result = (MediaContentError)Interop.ImageInformation.UpdateToDB(((ImageInformation)mediaInfo).ImageHandle);
+                MediaContentValidator.ThrowIfError(
+                    Interop.ImageInformation.UpdateToDB(((ImageInformation)mediaInfo).ImageHandle), "Failed to update DB");
             }
             else if (type == typeof(AudioInformation))
             {
-                result = (MediaContentError)Interop.AudioInformation.UpdateToDB(((AudioInformation)mediaInfo).AudioHandle);
+                MediaContentValidator.ThrowIfError(
+                    Interop.AudioInformation.UpdateToDB(((AudioInformation)mediaInfo).AudioHandle), "Failed to update DB");
             }
             else if (type == typeof(VideoInformation))
             {
-                result = (MediaContentError)Interop.VideoInformation.UpdateToDB(((VideoInformation)mediaInfo).VideoHandle);
+                MediaContentValidator.ThrowIfError(
+                    Interop.VideoInformation.UpdateToDB(((VideoInformation)mediaInfo).VideoHandle), "Failed to update DB");
             }
             else if (type == typeof(MediaInformation))
             {
-                result = (MediaContentError)Interop.MediaInformation.UpdateToDB(((MediaInformation)mediaInfo).MediaHandle);
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.UpdateToDB(((MediaInformation)mediaInfo).MediaHandle), "Failed to update DB");
             }
             else
             {
-                result = MediaContentError.InvalidOperation;
+                throw new ArgumentException("Invalid information type");
             }
-
-            MediaContentRetValidator.ThrowIfError(result, "Failed to update DB");
         }
 
         internal void Update(MediaFace face)
         {
             ConnectToDB();
-
-            MediaContentRetValidator.ThrowIfError(Interop.Face.UpdateToDb(face.Handle), "Failed to update DB");
+            MediaContentValidator.ThrowIfError(Interop.Face.UpdateToDb(face.Handle), "Failed to update DB");
         }
 
         /// <summary>
@@ -606,38 +628,36 @@ namespace Tizen.Content.MediaContent
         {
             ConnectToDB();
             Type type = contentCollection.GetType();
-            MediaContentError result = MediaContentError.None;
             IntPtr handle = IntPtr.Zero;
             if (type == typeof(Tag))
             {
-                result = (MediaContentError)Interop.Tag.InsertToDb(((Tag)contentCollection).Name, out handle);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Tag.InsertToDb(((Tag)contentCollection).Name, out handle), "Failed to insert collection");
                 ((Tag)contentCollection).Handle = handle;
             }
             else if (type == typeof(PlayList))
             {
-                Console.WriteLine("Playlist insert");
-                result = (MediaContentError)Interop.Playlist.InsertToDb(((PlayList)contentCollection).Name, out handle);
+                MediaContentValidator.ThrowIfError(
+                    Interop.Playlist.InsertToDb(((PlayList)contentCollection).Name, out handle), "Failed to insert collection");
                 ((PlayList)contentCollection).Handle = handle;
             }
             else
             {
-                Console.WriteLine("Inalid insert");
-                result = MediaContentError.InvalidParameter;
+                throw new ArgumentException("collection type is wrong");
             }
-            MediaContentRetValidator.ThrowIfError(result, "Failed to insert collection to the database");
         }
 
         internal void Insert(string mediaId, uint offset, string thumbnailPath)
         {
             ConnectToDB();
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaBookmark.InsertToDb(mediaId, offset, thumbnailPath), "Failed to insert information");
         }
 
         internal void Insert(MediaFace face)
         {
             ConnectToDB();
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Face.InsertToDb(((MediaFace)face).Handle), "Failed to insert information");
         }
     }
index 7e09f23..822b9d5 100755 (executable)
@@ -16,6 +16,7 @@
 
 
 using System;
+using System.Runtime.InteropServices;
 
 namespace Tizen.Content.MediaContent
 {
@@ -100,9 +101,7 @@ namespace Tizen.Content.MediaContent
     {
         private IntPtr _filterHandle = IntPtr.Zero;
         private bool _disposedValue = false;
-        //private ContentOrder _order = ContentOrder.Asc;
-        //private string _orderKey = "MEDIA_ID";
-        private ContentCollation _collationType = ContentCollation.Default;
+
         internal IntPtr Handle
         {
             get
@@ -120,20 +119,20 @@ namespace Tizen.Content.MediaContent
             {
                 int offset;
                 int count;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to Get offset");
+                MediaContentValidator.ThrowIfError(
+                    Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to get offset");
 
                 return offset;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.SetOffset(_filterHandle, value, this.Count), "Failed to Set offset");
+                MediaContentValidator.ThrowIfError(
+                    Interop.Filter.SetOffset(_filterHandle, value, this.Count), "Failed to set offset");
             }
         }
         public ContentFilter()
         {
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Filter.Create(out _filterHandle), "Failed to Create Filter handle.");
         }
         /// <summary>
@@ -145,15 +144,15 @@ namespace Tizen.Content.MediaContent
             {
                 int offset;
                 int count;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to Getoffset/count");
+                MediaContentValidator.ThrowIfError(
+                    Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to get count");
 
                 return count;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.SetOffset(_filterHandle, this.Offset, value), "Failed to Setoffset/Count");
+                MediaContentValidator.ThrowIfError(
+                    Interop.Filter.SetOffset(_filterHandle, this.Offset, value), "Failed to set count");
             }
         }
         /// <summary>
@@ -163,13 +162,20 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                int orderType;
-                string orderKey;
-                int collatetType;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.GetOrder(_filterHandle, out orderType, out orderKey, out collatetType), "Failed to GetOrder");
+                ContentOrder order;
+                IntPtr val = IntPtr.Zero;
+                ContentCollation collate;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Filter.GetOrder(_filterHandle, out order, out val, out collate), "Failed to get order");
 
-                return (ContentOrder)orderType;
+                    return order;
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
         /// <summary>
@@ -179,18 +185,24 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string condition;
-                int collatetType;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.GetCondition(_filterHandle, out condition, out collatetType), "Failed to GetCondition for CollationType");
+                IntPtr val = IntPtr.Zero;
+                ContentCollation type;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Filter.GetCondition(_filterHandle, out val, out type), "Failed to get collation");
 
-                return (ContentCollation)collatetType;
+                    return type;
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
             set
             {
-                _collationType = value;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.SetCondition(_filterHandle, this.Condition, (int)value), "Failed to SetCondition for CollationType");
+                MediaContentValidator.ThrowIfError(
+                    Interop.Filter.SetCondition(_filterHandle, this.Condition, value), "Failed to set collation");
             }
         }
         /// <summary>
@@ -200,17 +212,24 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string conditionVal = "";
-                int collatetType;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.GetCondition(_filterHandle, out conditionVal, out collatetType), "Failed to GetCondition");
+                IntPtr val = IntPtr.Zero;
+                ContentCollation type;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Filter.GetCondition(_filterHandle, out val, out type), "Failed to get condition");
 
-                return conditionVal;
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.SetCondition(_filterHandle, value, (int)_collationType), "Failed to SetCondition");
+                MediaContentValidator.ThrowIfError(
+                    Interop.Filter.SetCondition(_filterHandle, value, this.CollationType), "Failed to set condition");
             }
         }
         /// <summary>
@@ -221,16 +240,23 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string storageId;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.GetStorage(_filterHandle, out storageId), "Failed to GetCondition");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Filter.GetStorage(_filterHandle, out val), "Failed to get condition");
 
-                return storageId;
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.SetStorage(_filterHandle, value), "Failed to SetCondition");
+                MediaContentValidator.ThrowIfError(
+                    Interop.Filter.SetStorage(_filterHandle, value), "Failed to set condition");
             }
         }
         /// <summary>
@@ -240,29 +266,35 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                int orderType;
-                string orderKey;
-                int collatetType;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Filter.GetOrder(_filterHandle, out orderType, out orderKey, out collatetType), "Failed to GetOrder for OrderKey");
+                ContentOrder order;
+                IntPtr val = IntPtr.Zero;
+                ContentCollation type;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Filter.GetOrder(_filterHandle, out order, out val, out type), "Failed to GetOrder for OrderKey");
 
-                return orderKey;
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
+
         /// <summary>
         /// The type of the media group
         /// </summary>
-        public MediaGroupType GroupType
-        {
-            get; set;
-        }
+        public MediaGroupType GroupType { get; set; }
+
         /// <summary>
         /// SetOrderProperties like OrderType and OrderKey.
         /// </summary>
         public void SetOrderProperties(ContentOrder order, string oderKey)
         {
-            MediaContentRetValidator.ThrowIfError(
-                Interop.Filter.SetOrder(_filterHandle, order, oderKey, CollationType), "Failed to SetOrder");
+            MediaContentValidator.ThrowIfError(
+                Interop.Filter.SetOrder(_filterHandle, order, oderKey, CollationType), "Failed to set order");
         }
 
 
@@ -282,8 +314,7 @@ namespace Tizen.Content.MediaContent
             {
                 if (_filterHandle != IntPtr.Zero)
                 {
-                    Interop.Filter.Destroy(_filterHandle); //destroy filterHandle
-
+                    Interop.Filter.Destroy(_filterHandle);
                     _filterHandle = IntPtr.Zero;
                 }
                 _disposedValue = true;
index 8853246..df3aeef 100755 (executable)
@@ -73,8 +73,7 @@ namespace Tizen.Content.MediaContent
         public static void Scan(string filePath)
         {
             Database.ConnectToDB();
-            MediaContentRetValidator.ThrowIfError(
-                Interop.Content.ScanFile(filePath), "Failed scan");
+            MediaContentValidator.ThrowIfError(Interop.Content.ScanFile(filePath), "Failed scan");
         }
 
         /// <summary>
@@ -85,7 +84,7 @@ namespace Tizen.Content.MediaContent
         {
             Database.ConnectToDB();
             Interop.MediaInformation.SafeMediaInformationHandle mediaInformationHandle;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.Insert(filePath, out mediaInformationHandle), "Failed to Insert MediaInformation to DB");
 
             return new MediaInformation(mediaInformationHandle);
@@ -107,10 +106,12 @@ namespace Tizen.Content.MediaContent
 
             Interop.Content.MediaScanCompletedCallback scanCompleted = (MediaContentError scanResult, IntPtr data) =>
             {
-                MediaContentRetValidator.ThrowIfError(scanResult, "Failed to scan");
+                MediaContentValidator.ThrowIfError(scanResult, "Failed to scan");
                 task.SetResult((int)scanResult);
             };
-            MediaContentRetValidator.ThrowIfError(Interop.Content.ScanFolder(folderPath, recursive, scanCompleted, IntPtr.Zero), "Failed to scan");
+
+            MediaContentValidator.ThrowIfError(
+                Interop.Content.ScanFolder(folderPath, recursive, scanCompleted, IntPtr.Zero), "Failed to scan");
 
             return task.Task;
         }
@@ -140,7 +141,7 @@ namespace Tizen.Content.MediaContent
                     if (!taskCompleted)
                     {
                         taskCompleted = true;
-                        MediaContentRetValidator.ThrowIfError(
+                        MediaContentValidator.ThrowIfError(
                             Interop.Content.CancelScanFolder(folderPath), "Failed CancelScanFolder");
 
                         task.SetCanceled();
@@ -154,13 +155,13 @@ namespace Tizen.Content.MediaContent
                     if (!taskCompleted)
                     {
                         taskCompleted = true;
-                        MediaContentRetValidator.ThrowIfError(scanResult, "Failed scan");
+                        MediaContentValidator.ThrowIfError(scanResult, "Failed scan");
                         task.SetResult((int)scanResult);
                     }
                 }
             };
 
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Content.ScanFolder(folderPath, recursive, scanCompletedWithToken, IntPtr.Zero), "Failed to scan");
 
             return task.Task;
@@ -179,10 +180,10 @@ namespace Tizen.Content.MediaContent
             string[] paths = ((List<string>)filePaths).ToArray();
             Interop.MediaInformation.MediaInsertCompletedCallback callback = (MediaContentError error, IntPtr userData) =>
             {
-                MediaContentRetValidator.ThrowIfError(error, "Failed to batch insert");
+                MediaContentValidator.ThrowIfError(error, "Failed to batch insert");
                 task.SetResult((int)error);
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.BatchInsert(paths, paths.Length, callback, IntPtr.Zero), "Failed to add batch media");
 
             return task.Task;
@@ -200,10 +201,10 @@ namespace Tizen.Content.MediaContent
             string[] paths = ((List<string>)filePaths).ToArray();
             Interop.MediaInformation.MediaInsertBurstShotCompletedCallback callback = (MediaContentError error, IntPtr userData) =>
             {
-                MediaContentRetValidator.ThrowIfError(error, "Failed to add burstshot");
+                MediaContentValidator.ThrowIfError(error, "Failed to add burstshot");
                 task.SetResult((int)error);
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.BurstShotInsert(paths, paths.Length, callback, IntPtr.Zero), "Failed to add burst shots to db");
 
             return task.Task;
index beca4e9..73cc45c 100755 (executable)
@@ -17,6 +17,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 
 namespace Tizen.Content.MediaContent
@@ -68,7 +69,7 @@ namespace Tizen.Content.MediaContent
         {
             int mediaCount = 0;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Group.GetMediaCountFromDb(Name, _groupType, handle, out mediaCount), "Failed to GetMediaCountFromDb");
 
             return mediaCount;
@@ -90,13 +91,13 @@ namespace Tizen.Content.MediaContent
             Interop.Group.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) =>
             {
                 Interop.MediaInformation.SafeMediaInformationHandle newHandle;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone MediaInformation instance");
 
                 mediaContents.Add(new MediaInformation(newHandle));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Group.ForeachMediaFromDb(Name, _groupType, handle, callback, IntPtr.Zero), "Failed to get media information for the group");
 
             tcs.TrySetResult(mediaContents);
index 3059a09..3940325 100755 (executable)
@@ -22,6 +22,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Collections.ObjectModel;
+using System.Runtime.InteropServices;
 
 namespace Tizen.Content.MediaContent
 {
@@ -38,15 +39,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string mediaId = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.ImageInformation.GetMediaId(_handle, out mediaId), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.ImageInformation.GetMediaId(_handle, out val), "Failed to get value");
 
-                if (mediaId == null)
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
                 {
-                    mediaId = "";
+                    Interop.Libc.Free(val);
                 }
-                return mediaId;
             }
         }
 
@@ -58,7 +62,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int width = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.ImageInformation.GetWidth(_handle, out width), "Failed to get value");
 
                 return width;
@@ -73,7 +77,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int height = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.ImageInformation.GetHeight(_handle, out height), "Failed to get value");
 
                 return height;
@@ -88,14 +92,14 @@ namespace Tizen.Content.MediaContent
             get
             {
                 MediaContentOrientation orientation = MediaContentOrientation.NotAvailable;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.ImageInformation.GetOrientation(_handle, out orientation), "Failed to get value");
 
                 return orientation;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.ImageInformation.SetOrientation(_handle, value), "Failed to set value");
             }
         }
@@ -107,15 +111,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string takenDate = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.ImageInformation.GetDateTaken(_handle, out takenDate), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.ImageInformation.GetDateTaken(_handle, out val), "Failed to get value");
 
-                if (takenDate == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    takenDate = "";
+                    Interop.Libc.Free(val);
                 }
-                return takenDate;
             }
         }
 
@@ -127,15 +134,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string burstId = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.ImageInformation.GetBurstId(_handle, out burstId), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.ImageInformation.GetBurstId(_handle, out val), "Failed to get value");
 
-                if (burstId == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    burstId = "";
+                    Interop.Libc.Free(val);
                 }
-                return burstId;
             }
         }
 
@@ -146,15 +156,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string exposureTime = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.ImageInformation.GetExposureTime(_handle, out exposureTime), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.ImageInformation.GetExposureTime(_handle, out val), "Failed to get value");
 
-                if (exposureTime == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    exposureTime = "";
+                    Interop.Libc.Free(val);
                 }
-                return exposureTime;
             }
         }
 
@@ -166,7 +179,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 double fNumber = 0.0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.ImageInformation.GetFNumber(_handle, out fNumber), "Failed to get value");
 
                 return fNumber;
@@ -181,7 +194,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int iso = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.ImageInformation.GetISO(_handle, out iso), "Failed to get value");
 
                 return iso;
@@ -195,15 +208,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string model = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.ImageInformation.GetModel(_handle, out model), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.ImageInformation.GetModel(_handle, out val), "Failed to get value");
 
-                if (model == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    model = "";
+                    Interop.Libc.Free(val);
                 }
-                return model;
             }
         }
 
@@ -217,7 +233,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 bool isBurst = false;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.ImageInformation.IsBurstShot(_handle, out isBurst), "Failed to get value");
 
                 return isBurst;
@@ -236,18 +252,18 @@ namespace Tizen.Content.MediaContent
             var task = new TaskCompletionSource<IEnumerable<MediaFace>>();
             Collection<MediaFace> coll = new Collection<MediaFace>();
 
-            Interop.MediaInformation.MediaFaceCallback faceCallback = (IntPtr facehandle, IntPtr userData) =>
+            Interop.MediaInformation.MediaFaceCallback callback = (IntPtr faceHandle, IntPtr userData) =>
             {
                 IntPtr newHandle = IntPtr.Zero;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Face.Clone(out newHandle, facehandle), "Failed to clone Tag");
+                MediaContentValidator.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;
-            MediaContentRetValidator.ThrowIfError(
-                Interop.MediaInformation.GetAllFaces(MediaId, filterHandle, faceCallback, IntPtr.Zero), "Failed to get value");
+            MediaContentValidator.ThrowIfError(
+                Interop.MediaInformation.GetAllFaces(MediaId, filterHandle, callback, IntPtr.Zero), "Failed to get value");
             task.SetResult(coll);
             return task.Task;
         }
@@ -262,7 +278,7 @@ namespace Tizen.Content.MediaContent
         {
             int count = 0;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.GetFaceCount(MediaId, handle, out count), "Failed to get value");
 
             return count;
index dfb8ab7..930247e 100755 (executable)
@@ -19,6 +19,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Runtime.InteropServices;
 using System.Text;
 
 namespace Tizen.Content.MediaContent
@@ -36,11 +37,21 @@ namespace Tizen.Content.MediaContent
         internal MediaBookmark(IntPtr handle)
         {
             _bookmarkHandle = handle;
-            MediaContentRetValidator.ThrowIfError(
+            IntPtr val = IntPtr.Zero;
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaBookmark.GetMarkedTime(_bookmarkHandle, out _offset), "Failed to Get Offset");
 
-            MediaContentRetValidator.ThrowIfError(
-                Interop.MediaBookmark.GetThumbnailPath(_bookmarkHandle, out _thumbnailPath), "Failed to Get Thumbnail Path");
+            try
+            {
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaBookmark.GetThumbnailPath(_bookmarkHandle, out val), "Failed to Get Thumbnail Path");
+
+                _thumbnailPath = Marshal.PtrToStringAnsi(val);
+            }
+            finally
+            {
+                Interop.Libc.Free(val);
+            }
         }
 
         ~MediaBookmark()
@@ -55,7 +66,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int id;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaBookmark.GetBookmarkId(_bookmarkHandle, out id), "Failed to get bookmark id");
 
                 return id;
index 51b069d..595d82e 100755 (executable)
@@ -40,7 +40,7 @@ namespace Tizen.Content.MediaContent
         UnsupportedContent = TizenMediaContentError | 0x04,
         NotSupported = ErrorCode.NotSupported,
     }
-    internal class MediaContentRetValidator
+    internal class MediaContentValidator
     {
         internal const string LogTag = "Tizen.Content.MediaContent";
 
@@ -68,5 +68,10 @@ namespace Tizen.Content.MediaContent
                     throw new PlatformNotSupportedException(msg);
             }
         }
+
+        internal static string CheckString(string value)
+        {
+            return (value != null) ? value : "";
+        }
     }
 }
index 17abc93..cdfe8ed 100755 (executable)
@@ -17,6 +17,7 @@
 
 
 using System;
+using System.Runtime.InteropServices;
 
 namespace Tizen.Content.MediaContent
 {
@@ -52,11 +53,19 @@ namespace Tizen.Content.MediaContent
         ///</param>
         internal MediaFace(MediaInformation image, FaceRect rect)
         {
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.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");
+            try
+            {
+                MediaContentValidator.ThrowIfError(
+                    Interop.Face.SetFaceRect(_faceHandle, rect.X, rect.Y, rect.Width, rect.Height), "Failed to set Rect to MediaFace");
+            }
+            catch (Exception)
+            {
+                Interop.Face.Destroy(_faceHandle);
+                throw;
+            }
         }
 
         ~MediaFace()
@@ -75,7 +84,7 @@ namespace Tizen.Content.MediaContent
                 int y;
                 int width;
                 int height;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.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);
@@ -83,7 +92,7 @@ namespace Tizen.Content.MediaContent
             set
             {
                 FaceRect rect = (FaceRect)value;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Face.SetFaceRect(_faceHandle, rect.X, rect.Y, rect.Width, rect.Height), "Failed to set Rect for the Face");
             }
         }
@@ -95,11 +104,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string id;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Face.GetFaceId(_faceHandle, out id), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Face.GetFaceId(_faceHandle, out val), "Failed to get value");
 
-                return id;
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -110,11 +126,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string mediaId;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Face.GetMediaId(_faceHandle, out mediaId), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Face.GetMediaId(_faceHandle, out val), "Failed to get value");
 
-                return mediaId;
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
         /// <summary>
@@ -124,15 +147,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string tag;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Face.GetTag(_faceHandle, out tag), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Face.GetTag(_faceHandle, out val), "Failed to get value");
 
-                return tag;
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Face.SetTag(_faceHandle, value), "Failed to set value");
             }
         }
@@ -145,14 +175,14 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int orientation;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Face.GetOrientation(_faceHandle, out orientation), "Failed to value");
 
                 return (MediaContentOrientation)orientation;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Face.SetOrientation(_faceHandle, (int)value), "Failed to set value");
             }
         }
index f2506de..d3bfac0 100755 (executable)
@@ -18,6 +18,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 
 namespace Tizen.Content.MediaContent
@@ -49,11 +50,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string id;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Folder.GetFolderId(_folderHandle, out id), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Folder.GetFolderId(_folderHandle, out val), "Failed to get value");
 
-                return id;
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -64,10 +72,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string parentId;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Folder.GetParentFolderId(_folderHandle, out parentId), "Failed to get value");
-                return parentId;
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Folder.GetParentFolderId(_folderHandle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -78,10 +94,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string path;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Folder.GetPath(_folderHandle, out path), "Failed to get value");
-                return path;
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Folder.GetPath(_folderHandle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -92,14 +116,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string name;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Folder.GetName(_folderHandle, out name), "Failed to get value");
-                return name;
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Folder.GetName(_folderHandle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Folder.SetName(_folderHandle, value), "Failed to set value");
             }
         }
@@ -112,11 +144,11 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                int type;
-                MediaContentRetValidator.ThrowIfError(
+                ContentStorageType type;
+                MediaContentValidator.ThrowIfError(
                     Interop.Folder.GetStorageType(_folderHandle, out type), "Failed to get value");
 
-                return (ContentStorageType)type;
+                return type;
             }
         }
 
@@ -127,11 +159,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string storageId;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Folder.GetStorageId(_folderHandle, out storageId), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Folder.GetStorageId(_folderHandle, out val), "Failed to get value");
 
-                return storageId;
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -143,7 +182,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 DateTime date;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Folder.GetModifiedTime(_folderHandle, out date), "Failed to get value");
 
                 return date;
@@ -160,14 +199,14 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int order;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Folder.GetOrder(_folderHandle, out order), "Failed to get value");
 
                 return order;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Folder.SetOrder(_folderHandle, value), "Failed to set value");
             }
         }
@@ -187,7 +226,7 @@ namespace Tizen.Content.MediaContent
         {
             int mediaCount;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Folder.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count");
 
             return mediaCount;
@@ -233,13 +272,13 @@ namespace Tizen.Content.MediaContent
             Interop.Folder.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) =>
             {
                 Interop.MediaInformation.SafeMediaInformationHandle newHandle;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone");
 
                 mediaContents.Add(new MediaInformation(newHandle));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Folder.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information");
 
             tcs.TrySetResult(mediaContents);
index 0ba324c..b801bf5 100755 (executable)
@@ -47,7 +47,7 @@ namespace Tizen.Content.MediaContent
         {
             int count = 0;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.GetTagCount(MediaId, handle, out count), "Failed to get count");
 
             return count;
@@ -61,7 +61,7 @@ namespace Tizen.Content.MediaContent
         /// <param name="destination">The Destination path</param>
         public void Move(string destination)
         {
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.MoveToDB(_handle, destination), "Failed to move");
         }
 
@@ -72,7 +72,7 @@ namespace Tizen.Content.MediaContent
         /// void </returns>
         public void Refresh()
         {
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.RefreshMetadataToDB(MediaId), "Failed to refresh");
         }
 
@@ -87,10 +87,10 @@ namespace Tizen.Content.MediaContent
             var task = new TaskCompletionSource<string>();
             Interop.MediaInformation.MediaThumbnailCompletedCallback thumbnailResult = (MediaContentError createResult, string path, IntPtr userData) =>
             {
-                MediaContentRetValidator.ThrowIfError(createResult, "Failed to create thumbnail");
+                MediaContentValidator.ThrowIfError(createResult, "Failed to create thumbnail");
                 task.SetResult(path);
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero), "Failed to create thumbnail");
 
             return await task.Task;
@@ -107,16 +107,16 @@ namespace Tizen.Content.MediaContent
         {
             var task = new TaskCompletionSource<string>();
             cancellationToken.Register(() => {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.CancelThumbnail(_handle), "Failed to cancel");
                 task.SetCanceled();
             });
             Interop.MediaInformation.MediaThumbnailCompletedCallback thumbnailResult = (MediaContentError createResult, string path, IntPtr userData) =>
             {
-                MediaContentRetValidator.ThrowIfError(createResult, "Failed to create thumbnail");
+                MediaContentValidator.ThrowIfError(createResult, "Failed to create thumbnail");
                 task.SetResult(path);
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero), "Failed to create thumbnail");
 
             return await task.Task;
@@ -137,13 +137,13 @@ namespace Tizen.Content.MediaContent
             Interop.MediaInformation.MediaTagCallback tagsCallback = (IntPtr tagHandle, IntPtr userData) =>
             {
                 IntPtr newHandle;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Tag.Clone(out newHandle, tagHandle), "Failed to clone");
                 coll.Add(new Tag(newHandle));
 
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.GetAllTags(MediaId, handle, tagsCallback, IntPtr.Zero), "Failed to get information");
 
             task.SetResult(coll);
@@ -157,14 +157,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string mediaId = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetMediaId(_handle, out mediaId), "Failed to get value");
-                if (mediaId == null)
+                IntPtr val = IntPtr.Zero;
+                try
                 {
-                    mediaId = "";
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetMediaId(_handle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
                 }
-                return mediaId;
             }
         }
 
@@ -175,14 +179,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string path = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetFilePath(_handle, out path), "Failed to get value");
-                if (path == null)
+                IntPtr val = IntPtr.Zero;
+                try
                 {
-                    path = "";
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetFilePath(_handle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
                 }
-                return path;
             }
         }
 
@@ -193,19 +201,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string displayname = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetDisplayName(_handle, out displayname), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetDisplayName(_handle, out val), "Failed to get value");
 
-                if (displayname == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    displayname = "";
+                    Interop.Libc.Free(val);
                 }
-                return displayname;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetDisplayName(_handle, value), "failed to set value");
             }
         }
@@ -218,7 +229,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 MediaContentType contentType = MediaContentType.Others;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetMediaType(_handle, out contentType), "Failed to get value");
 
                 return contentType;
@@ -232,15 +243,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string mimeType = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetMimeType(_handle, out mimeType), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetMimeType(_handle, out val), "Failed to get value");
 
-                if (mimeType == null)
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
                 {
-                    mimeType = "";
+                    Interop.Libc.Free(val);
                 }
-                return mimeType;
             }
         }
 
@@ -252,7 +266,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 long size;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetSize(_handle, out size), "Failed to get value");
 
                 return size;
@@ -266,27 +280,17 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                DateTime addedAt;
                 int time;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetAddedTime(_handle, out time), "Failed to get value");
 
-                DateTime utc;
-                if (time != 0)
-                {
-                    utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
-                    addedAt = utc.ToLocalTime();
-                }
-                else
-                {
-                    addedAt = DateTime.Now;
-                }
-                return addedAt;
-            }
+                DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
 
+                return utc.ToLocalTime();
+            }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetAddedTime(_handle, (int)value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds), "failed to set time");
             }
         }
@@ -298,22 +302,13 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                DateTime modifiedAt;
                 int time;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetModifiedTime(_handle, out time), "Failed to get value");
 
-                DateTime utc;
-                if (time != 0)
-                {
-                    utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
-                    modifiedAt = utc.ToLocalTime();
-                }
-                else
-                {
-                    modifiedAt = DateTime.Now;
-                }
-                return modifiedAt;
+                DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
+
+                return utc.ToLocalTime();
             }
         }
 
@@ -324,22 +319,13 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                DateTime timeline;
                 int time;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetTimeline(_handle, out time), "Failed to get value");
 
-                DateTime utc;
-                if (time != 0)
-                {
-                    utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
-                    timeline = utc.ToLocalTime();
-                }
-                else
-                {
-                    timeline = DateTime.Now;
-                }
-                return timeline;
+                DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
+
+                return utc.ToLocalTime();
             }
         }
 
@@ -350,15 +336,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string thumbnailPath = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetThumbnailPath(_handle, out thumbnailPath), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetThumbnailPath(_handle, out val), "Failed to get value");
 
-                if (thumbnailPath == null)
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
                 {
-                    thumbnailPath = "";
+                    Interop.Libc.Free(val);
                 }
-                return thumbnailPath;
             }
         }
 
@@ -370,19 +359,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string description = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetDescription(_handle, out description), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetDescription(_handle, out val), "Failed to get value");
 
-                if (description == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    description = "";
+                    Interop.Libc.Free(val);
                 }
-                return description;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetDescription(_handle, value), "failed to set value");
             }
         }
@@ -396,14 +388,14 @@ namespace Tizen.Content.MediaContent
             get
             {
                 double longitude = 0.0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetLongitude(_handle, out longitude), "Failed to get value");
 
                 return longitude;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetLongitude(_handle, value), "failed to set value");
             }
         }
@@ -417,14 +409,14 @@ namespace Tizen.Content.MediaContent
             get
             {
                 double latitude = 0.0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetLatitude(_handle, out latitude), "Failed to get value");
 
                 return latitude;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetLatitude(_handle, value), "failed to set value");
             }
         }
@@ -438,14 +430,14 @@ namespace Tizen.Content.MediaContent
             get
             {
                 double altitude = 0.0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetAltitude(_handle, out altitude), "Failed to get value");
 
                 return altitude;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetAltitude(_handle, value), "failed to set value");
             }
         }
@@ -458,19 +450,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string weather = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetWeather(_handle, out weather), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetWeather(_handle, out val), "Failed to get value");
 
-                if (weather == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    weather = "";
+                    Interop.Libc.Free(val);
                 }
-                return weather;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetWeather(_handle, value), "failed to set value");
             }
         }
@@ -483,13 +478,13 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int rating = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetRating(_handle, out rating), "Failed to get value");
                 return rating;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetRating(_handle, value), "failed to set value");
             }
         }
@@ -503,14 +498,14 @@ namespace Tizen.Content.MediaContent
             get
             {
                 bool isFavourtite = false;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetFavorite(_handle, out isFavourtite), "Failed to get value");
 
                 return isFavourtite;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetFavorite(_handle, value), "failed to set value");
             }
         }
@@ -522,19 +517,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string author = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetAuthor(_handle, out author), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetAuthor(_handle, out val), "Failed to get value");
 
-                if(author == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    author = "";
+                    Interop.Libc.Free(val);
                 }
-                return author;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetAuthor(_handle, value), "failed to set value");
             }
         }
@@ -546,19 +544,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string provider = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetProvider(_handle, out provider), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetProvider(_handle, out val), "Failed to get value");
 
-                if (provider == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    provider = "";
+                    Interop.Libc.Free(val);
                 }
-                return provider;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetProvider(_handle, value), "failed to set value");
             }
         }
@@ -570,19 +571,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string contentName = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetContentName(_handle, out contentName), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetContentName(_handle, out val), "Failed to get value");
 
-                if (contentName == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    contentName = "";
+                    Interop.Libc.Free(val);
                 }
-                return contentName;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetContentName(_handle, value), "failed to set value");
             }
         }
@@ -594,15 +598,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string title = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetTitle(_handle, out title), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetTitle(_handle, out val), "Failed to get value");
 
-                if (title == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    title = "";
+                    Interop.Libc.Free(val);
                 }
-                return title;
             }
         }
 
@@ -613,19 +620,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string category = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetCategory(_handle, out category), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetCategory(_handle, out val), "Failed to get value");
 
-                if (category == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    category = "";
+                    Interop.Libc.Free(val);
                 }
-                return category;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetCategory(_handle, value), "failed to set value");
             }
         }
@@ -637,19 +647,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string loationTag = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetLocationTag(_handle, out loationTag), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetLocationTag(_handle, out val), "Failed to get value");
 
-                if (loationTag == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    loationTag = "";
+                    Interop.Libc.Free(val);
                 }
-                return loationTag;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetLocationTag(_handle, value), "failed to set value");
             }
         }
@@ -661,19 +674,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string ageRating = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetAgeRating(_handle, out ageRating), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetAgeRating(_handle, out val), "Failed to get value");
 
-                if (ageRating == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    ageRating = "";
+                    Interop.Libc.Free(val);
                 }
-                return ageRating;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetAgeRating(_handle, value), "Failed to set value");
             }
         }
@@ -685,19 +701,22 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string keyword = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetKeyword(_handle, out keyword), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetKeyword(_handle, out val), "Failed to get value");
 
-                if (keyword == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    keyword = "";
+                    Interop.Libc.Free(val);
                 }
-                return keyword;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetKeyword(_handle, value), "failed to set value");
             }
         }
@@ -709,15 +728,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string storageId = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.GetStorageId(_handle, out storageId), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetStorageId(_handle, out val), "Failed to get value");
 
-                if (storageId == null)
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
                 {
-                    storageId = "";
+                    Interop.Libc.Free(val);
                 }
-                return storageId;
             }
         }
 
@@ -729,7 +751,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 bool isDRM = false;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.IsDrm(_handle, out isDRM), "Failed to get value");
 
                 return isDRM;
@@ -744,7 +766,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 ContentStorageType storageType = ContentStorageType.Internal;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetStorageType(_handle, out storageType), "Failed to get value");
 
                 return storageType;
@@ -760,14 +782,14 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int playedCount = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetPlayedCount(_handle, out playedCount), "Failed to get value");
 
                 return playedCount;
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.IncreasePlayedCount(_handle), "failed to set value");
             }
         }
@@ -780,26 +802,17 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                DateTime addedAt;
                 int time;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.GetPlayedAt(_handle, out time), "Failed to get value");
 
-                DateTime utc;
-                if (time != 0)
-                {
-                    utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
-                    addedAt = utc.ToLocalTime();
-                }
-                else
-                {
-                    addedAt = DateTime.Now;
-                }
-                return addedAt;
+                DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
+
+                return utc.ToLocalTime();
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.SetPlayedAt(_handle), "failed to set value");
             }
         }
index 79c36fb..9a8d716 100755 (executable)
@@ -17,6 +17,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 
 namespace Tizen.Content.MediaContent
@@ -50,15 +51,22 @@ namespace Tizen.Content.MediaContent
             Interop.Playlist.PlaylistMemberCallback callback = (int memberId, IntPtr mediaHandle, IntPtr data) =>
             {
                 Interop.MediaInformation.SafeMediaInformationHandle newHandle;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.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;
+                    Interop.MediaInformation.GetMediaId(newHandle, out val);
+                    _dictionary.Add(Marshal.PtrToStringAnsi(val), memberId);
+                    return true;
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Playlist.ForeachMediaFromDb(Id, IntPtr.Zero, callback, IntPtr.Zero), "Failed to get playlist items");
         }
 
@@ -70,7 +78,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int id;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Playlist.GetPlaylistId(_playlistHandle, out id), "Failed to get value");
 
                 return id;
@@ -89,7 +97,7 @@ namespace Tizen.Content.MediaContent
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Playlist.SetName(_playlistHandle, value), "Failed to set value");
                 _playListName = value;
             }
@@ -101,14 +109,21 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string path;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Playlist.GetThumbnailPath(_playlistHandle, out path), "Failed to get value");
-                return path;
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Playlist.GetThumbnailPath(_playlistHandle, out val), "Failed to get value");
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Playlist.SetThumbnailPath(_playlistHandle, value), "Failed to set value");
             }
         }
@@ -125,8 +140,17 @@ namespace Tizen.Content.MediaContent
         internal PlayList(IntPtr handle)
         {
             _playlistHandle = handle;
-            MediaContentRetValidator.ThrowIfError(
-                Interop.Playlist.GetName(handle, out _playListName), "Failed to get value");
+            IntPtr val = IntPtr.Zero;
+            try
+            {
+                MediaContentValidator.ThrowIfError(
+                    Interop.Playlist.GetName(handle, out val), "Failed to get value");
+                _playListName = Marshal.PtrToStringAnsi(val);
+            }
+            finally
+            {
+                Interop.Libc.Free(val);
+            }
         }
 
         /// <summary>
@@ -135,7 +159,7 @@ namespace Tizen.Content.MediaContent
         /// <param name="mediaContent">The AudioContent obect to be added</param>
         public void AddItem(MediaInformation mediaContent)
         {
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Playlist.AddMedia(_playlistHandle, mediaContent.MediaId), "Failed to add item");
         }
 
@@ -148,7 +172,7 @@ namespace Tizen.Content.MediaContent
             int memberId = 0;
             refreshPlaylistDictionary();
             _dictionary.TryGetValue(media.MediaId, out memberId);
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Playlist.RemoveMedia(_playlistHandle, memberId), "Failed to remove item");
         }
 
@@ -162,7 +186,7 @@ namespace Tizen.Content.MediaContent
             int memberId;
             refreshPlaylistDictionary();
             _dictionary.TryGetValue(media.MediaId, out memberId);
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Playlist.SetPlayOrder(_playlistHandle, memberId, playOrder), "Failed to set play order");
         }
 
@@ -176,7 +200,7 @@ namespace Tizen.Content.MediaContent
             int memberId;
             refreshPlaylistDictionary();
             _dictionary.TryGetValue(media.MediaId, out memberId);
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Playlist.GetPlayOrder(_playlistHandle, memberId, out playOrder), "Failed to get play order");
 
             return playOrder;
@@ -193,7 +217,7 @@ namespace Tizen.Content.MediaContent
             PlayList playList = null;
             IntPtr playlistHandle;
 
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Playlist.ImportFromFile(name, filePath, out playlistHandle), "Failed to import");
 
             playList = new PlayList(name);
@@ -207,7 +231,7 @@ namespace Tizen.Content.MediaContent
         /// <returns>path The path to export the playlist</returns>
         public static void Export(PlayList list, string filePath)
         {
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Playlist.ExportToFile(list.Handle, filePath), "Failed to export playlist:" + filePath);
         }
 
@@ -220,7 +244,7 @@ namespace Tizen.Content.MediaContent
         {
             int mediaCount;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Playlist.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get media count");
 
             return mediaCount;
@@ -249,13 +273,13 @@ namespace Tizen.Content.MediaContent
             Interop.Playlist.PlaylistMemberCallback callback = (int memberId, IntPtr mediaHandle, IntPtr data) =>
             {
                 Interop.MediaInformation.SafeMediaInformationHandle newHandle;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
 
                 mediaContents.Add(new MediaInformation(newHandle));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Playlist.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get media information");
 
             tcs.TrySetResult(mediaContents);
index f08fe79..039d85b 100755 (executable)
@@ -18,6 +18,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 
 namespace Tizen.Content.MediaContent
@@ -44,11 +45,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string id;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Storage.GetId(_storageHandle, out id), "Failed to get value");
-
-                return id;
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Storage.GetId(_storageHandle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -59,11 +67,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string path;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Storage.GetPath(_storageHandle, out path), "Failed to get value");
-
-                return path;
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Storage.GetPath(_storageHandle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -74,11 +89,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string name;
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.Storage.GetName(_storageHandle, out name), "Failed to get value");
-
-                return name;
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.Storage.GetName(_storageHandle, out val), "Failed to get value");
+
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
+                {
+                    Interop.Libc.Free(val);
+                }
             }
         }
 
@@ -89,11 +111,11 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                int storageType;
-                MediaContentRetValidator.ThrowIfError(
+                ContentStorageType storageType;
+                MediaContentValidator.ThrowIfError(
                     Interop.Storage.GetType(_storageHandle, out storageType), "Failed to get value");
 
-                return (ContentStorageType)storageType;
+                return storageType;
             }
         }
 
@@ -111,7 +133,7 @@ namespace Tizen.Content.MediaContent
         {
             int mediaCount;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Storage.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count");
 
             return mediaCount;
@@ -142,13 +164,13 @@ namespace Tizen.Content.MediaContent
             Interop.Storage.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) =>
             {
                 Interop.MediaInformation.SafeMediaInformationHandle newHandle;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
 
                 mediaContents.Add(new MediaInformation(newHandle));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Storage.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information");
 
             tcs.TrySetResult(mediaContents);
index 7098042..d398df6 100755 (executable)
@@ -17,6 +17,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 
 namespace Tizen.Content.MediaContent
@@ -48,7 +49,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int id;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Tag.GetTagId(_tagHandle, out id), "Failed to get value");
                 return id;
             }
@@ -65,7 +66,7 @@ namespace Tizen.Content.MediaContent
             }
             set
             {
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.Tag.SetName(_tagHandle, value), "Failed to set value");
                 _tagName = value;
             }
@@ -74,8 +75,17 @@ namespace Tizen.Content.MediaContent
         internal Tag(IntPtr tagHandle)
         {
             _tagHandle = tagHandle;
-            MediaContentRetValidator.ThrowIfError(
-                Interop.Tag.GetName(tagHandle, out _tagName), "Failed to get value");
+            IntPtr val = IntPtr.Zero;
+            try
+            {
+                MediaContentValidator.ThrowIfError(
+                    Interop.Tag.GetName(_tagHandle, out val), "Failed to get value");
+                _tagName = Marshal.PtrToStringAnsi(val);
+            }
+            finally
+            {
+                Interop.Libc.Free(val);
+            }
         }
         /// <summary>
         /// Creates a Tag object which can be inserted to the media database using ContentManager:InsertToDatabaseAsync(ContentCollection)
@@ -92,7 +102,7 @@ namespace Tizen.Content.MediaContent
         /// <param name="mediaContent">The media info which is added</param>
         public void AddItem(MediaInformation mediaContent)
         {
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Tag.AddMedia(_tagHandle, mediaContent.MediaId), "Failed to add item");
         }
 
@@ -102,7 +112,7 @@ namespace Tizen.Content.MediaContent
         /// <param name="mediaContent">The media info which is removed</param>
         public void RemoveItem(MediaInformation mediaContent)
         {
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Tag.RemoveMedia(_tagHandle, mediaContent.MediaId), "Failed to remove item");
         }
 
@@ -115,7 +125,7 @@ namespace Tizen.Content.MediaContent
         {
             int mediaCount;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Tag.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count");
 
             return mediaCount;
@@ -146,12 +156,13 @@ namespace Tizen.Content.MediaContent
             Interop.Tag.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) =>
             {
                 Interop.MediaInformation.SafeMediaInformationHandle newHandle;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
 
                 mediaContents.Add(new MediaInformation(newHandle));
+                return true;
             };
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.Tag.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information");
 
             tcs.TrySetResult(mediaContents);
index 838f8a0..aadcb1c 100755 (executable)
@@ -37,15 +37,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string mediaId = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.VideoInformation.GetMediaId(_handle, out mediaId), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.VideoInformation.GetMediaId(_handle, out val), "Failed to get value");
 
-                if (mediaId == null)
+                    return Marshal.PtrToStringAnsi(val);
+                }
+                finally
                 {
-                    mediaId = "";
+                    Interop.Libc.Free(val);
                 }
-                return mediaId;
             }
         }
 
@@ -57,15 +60,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string album = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.VideoInformation.GetAlbum(_handle, out album), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.VideoInformation.GetAlbum(_handle, out val), "Failed to get value");
 
-                if (album == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    album = "";
+                    Interop.Libc.Free(val);
                 }
-                return album;
             }
         }
 
@@ -77,15 +83,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string artist = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.VideoInformation.GetArtist(_handle, out artist), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.VideoInformation.GetArtist(_handle, out val), "Failed to get value");
 
-                if (artist == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    artist = "";
+                    Interop.Libc.Free(val);
                 }
-                return artist;
             }
         }
 
@@ -97,15 +106,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string albumArtist = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.VideoInformation.GetAlbumArtist(_handle, out albumArtist), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.VideoInformation.GetAlbumArtist(_handle, out val), "Failed to get value");
 
-                if (albumArtist == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    albumArtist = "";
+                    Interop.Libc.Free(val);
                 }
-                return albumArtist;
             }
         }
 
@@ -117,15 +129,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string genre = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.VideoInformation.GetGenre(_handle, out genre), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.VideoInformation.GetGenre(_handle, out val), "Failed to get value");
 
-                if (genre == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    genre = "";
+                    Interop.Libc.Free(val);
                 }
-                return genre;
             }
         }
 
@@ -137,15 +152,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string composer = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.VideoInformation.GetComposer(_handle, out composer), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.VideoInformation.GetComposer(_handle, out val), "Failed to get value");
 
-                if (composer == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    composer = "";
+                    Interop.Libc.Free(val);
                 }
-                return composer;
             }
         }
 
@@ -157,15 +175,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string year = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.VideoInformation.GetYear(_handle, out year), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.VideoInformation.GetYear(_handle, out val), "Failed to get value");
 
-                if (year == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    year = "";
+                    Interop.Libc.Free(val);
                 }
-                return year;
             }
         }
 
@@ -176,15 +197,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string recordedDate = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.VideoInformation.GetRecordedDate(_handle, out recordedDate), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.VideoInformation.GetRecordedDate(_handle, out val), "Failed to get value");
 
-                if (recordedDate == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    recordedDate = "";
+                    Interop.Libc.Free(val);
                 }
-                return recordedDate;
             }
         }
 
@@ -196,15 +220,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string copyright = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.VideoInformation.GetCopyright(_handle, out copyright), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.VideoInformation.GetCopyright(_handle, out val), "Failed to get value");
 
-                if (copyright == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    copyright = "";
+                    Interop.Libc.Free(val);
                 }
-                return copyright;
             }
         }
 
@@ -216,15 +243,18 @@ namespace Tizen.Content.MediaContent
         {
             get
             {
-                string trackNumber = "";
-                MediaContentRetValidator.ThrowIfError(
-                    Interop.VideoInformation.GetTrackNum(_handle, out trackNumber), "Failed to get value");
+                IntPtr val = IntPtr.Zero;
+                try
+                {
+                    MediaContentValidator.ThrowIfError(
+                        Interop.VideoInformation.GetTrackNum(_handle, out val), "Failed to get value");
 
-                if (trackNumber == null)
+                    return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+                }
+                finally
                 {
-                    trackNumber = "";
+                    Interop.Libc.Free(val);
                 }
-                return trackNumber;
             }
         }
 
@@ -236,7 +266,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int bitrate = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.VideoInformation.GetBitRate(_handle, out bitrate), "Failed to get value");
 
                 return bitrate;
@@ -251,7 +281,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int duration = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.VideoInformation.GetDuration(_handle, out duration), "Failed to get value");
 
                 return duration;
@@ -266,7 +296,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int width = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.VideoInformation.GetWidth(_handle, out width), "Failed to get value");
 
                 return width;
@@ -281,7 +311,7 @@ namespace Tizen.Content.MediaContent
             get
             {
                 int height = 0;
-                MediaContentRetValidator.ThrowIfError(
+                MediaContentValidator.ThrowIfError(
                     Interop.VideoInformation.GetHeight(_handle, out height), "Failed to get value");
 
                 return height;
@@ -298,7 +328,7 @@ namespace Tizen.Content.MediaContent
         {
             int count = 0;
             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
-            MediaContentRetValidator.ThrowIfError(
+            MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.GetBookmarkCount(MediaId, handle, out count), "Failed to get count");
 
             return count;
@@ -314,20 +344,20 @@ namespace Tizen.Content.MediaContent
         {
             var task = new TaskCompletionSource<IEnumerable<MediaBookmark>>();
 
-            Collection<MediaBookmark> coll = new Collection<MediaBookmark>();
+            Collection<MediaBookmark> result = 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;
-                MediaContentRetValidator.ThrowIfError(
+                IntPtr newHandle = IntPtr.Zero;
+                MediaContentValidator.ThrowIfError(
                     Interop.MediaBookmark.Clone(out newHandle, handle), "Failed to clone Tag");
-                coll.Add(new MediaBookmark(newHandle));
+                result.Add(new MediaBookmark(newHandle));
                 return true;
             };
-            MediaContentRetValidator.ThrowIfError(
-                Interop.MediaInformation.GetAllBookmarks(MediaId, filterHandle, bookmarksCallback, IntPtr.Zero), "Failed to get value");
+            MediaContentValidator.ThrowIfError(
+                Interop.MediaInformation.GetAllBookmarks(MediaId, filterHandle, callback, IntPtr.Zero), "Failed to get value");
 
-            task.SetResult(coll);
+            task.SetResult(result);
             return task.Task;
         }