From 794518df48fdb39e7ac9eb0c7b81c5112d40259e Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Sat, 16 Mar 2013 01:16:43 +0900 Subject: [PATCH] merge with master --- CMakeLists.txt | 1 - inc/FCntAudioMetadata.h | 9 + inc/FCntContentInfo.h | 2 +- inc/FCntContentManager.h | 91 ++- inc/FCntContentManagerUtil.h | 67 ++- inc/FCntContentSearch.h | 9 +- inc/FCntContentTransfer.h | 12 +- inc/FCntDownloadManager.h | 13 +- inc/FCntDownloadRequest.h | 99 +++ inc/FCntIContentScanListener.h | 68 ++- inc/FCntIContentUpdateEventListener.h | 162 +++++ inc/FCntTypes.h | 22 +- inc/FCntVideoMetadata.h | 18 + inc/FContent.h | 1 + packaging/osp-content.spec | 10 +- src/FCntAudioContentInfo.cpp | 2 - src/FCntAudioMetadata.cpp | 12 +- src/FCntContentDirectory.cpp | 1 - src/FCntContentManager.cpp | 43 +- src/FCntContentManagerUtil.cpp | 47 +- src/FCntContentSearch.cpp | 1 - src/FCntContentSearchResult.cpp | 2 - src/FCntContentTransfer.cpp | 2 - src/FCntDownloadRequest.cpp | 62 ++ src/FCntImageContentInfo.cpp | 2 - src/FCntImageMetadata.cpp | 2 - src/FCntOtherContentInfo.cpp | 2 - src/FCntPlayList.cpp | 4 +- src/FCntVideoContentInfo.cpp | 2 - src/FCntVideoMetadata.cpp | 22 +- src/FCnt_AudioMetadataImpl.cpp | 86 ++- src/FCnt_ContentDirectoryImpl.cpp | 22 +- src/FCnt_ContentDownloadListener.cpp | 6 +- src/FCnt_ContentManagerImpl.cpp | 320 +++++++--- src/FCnt_ContentManagerUtilImpl.cpp | 1057 ++++++++++++++++++++++++++++----- src/FCnt_ContentSearchImpl.cpp | 3 - src/FCnt_ContentUtility.cpp | 20 +- src/FCnt_DownloadManagerImpl.cpp | 285 ++++++--- src/FCnt_DownloadRequestImpl.cpp | 137 +++++ src/FCnt_ImageMetadataImpl.cpp | 26 +- src/FCnt_PlayListImpl.cpp | 10 +- src/FCnt_PlayListManagerImpl.cpp | 8 +- src/FCnt_VideoMetadataImpl.cpp | 121 +++- src/inc/FCnt_AudioMetadataImpl.h | 12 + src/inc/FCnt_ContentManagerImpl.h | 34 +- src/inc/FCnt_ContentManagerUtilImpl.h | 25 +- src/inc/FCnt_DownloadManagerImpl.h | 11 +- src/inc/FCnt_DownloadRequestImpl.h | 29 +- src/inc/FCnt_PlayListImpl.h | 2 +- src/inc/FCnt_VideoMetadataImpl.h | 24 + 50 files changed, 2521 insertions(+), 507 deletions(-) mode change 100755 => 100644 inc/FCntContentManager.h mode change 100755 => 100644 inc/FCntContentSearch.h mode change 100755 => 100644 inc/FCntContentTransfer.h mode change 100755 => 100644 inc/FCntDownloadManager.h create mode 100644 inc/FCntIContentUpdateEventListener.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a34019d..c7ed77d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,6 @@ TARGET_LINK_LIBRARIES(${this_target} "-losp-media") TARGET_LINK_LIBRARIES(${this_target} "-losp-locations") TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" ) TARGET_LINK_LIBRARIES(${this_target} "-lexif" ) -TARGET_LINK_LIBRARIES(${this_target} "-lmmffile" ) TARGET_LINK_LIBRARIES(${this_target} "-lcapi-content-media-content") TARGET_LINK_LIBRARIES(${this_target} "-lcapi-media-metadata-extractor") TARGET_LINK_LIBRARIES(${this_target} "-lcapi-content-mime-type") diff --git a/inc/FCntAudioMetadata.h b/inc/FCntAudioMetadata.h index a330859..03fb89b 100644 --- a/inc/FCntAudioMetadata.h +++ b/inc/FCntAudioMetadata.h @@ -188,6 +188,15 @@ public: Tizen::Base::String GetComment(void) const; /** + * Gets the description of the audio file. + * + * @since 2.1 + * + * @return The description of the audio file + */ + Tizen::Base::String GetDescription(void) const; + + /** * Gets the track number of the audio file. * * @since 2.0 diff --git a/inc/FCntContentInfo.h b/inc/FCntContentInfo.h index 1b5b344..b213e4a 100644 --- a/inc/FCntContentInfo.h +++ b/inc/FCntContentInfo.h @@ -313,7 +313,7 @@ public: * @page CompContentInfoGetThumbnailNPage Compatibility for GetThumbnailN(). * @section CompContentInfoGetThumbnailNPageIssueSection Issue * The thumbnail size of this method in OSP compatible applications has the following issues: @n - *
The size is changed from 80x60 pixels to the size of image which is returned from the platform since %Tizen
+ *
The size is changed from 80x60 pixels to the size of image which is returned from the platform since %Tizen API 2.1.
* * @endif */ diff --git a/inc/FCntContentManager.h b/inc/FCntContentManager.h old mode 100755 new mode 100644 index 22831e2..ef31aa5 --- a/inc/FCntContentManager.h +++ b/inc/FCntContentManager.h @@ -37,7 +37,8 @@ namespace Tizen { namespace Content class ContentInfo; class _ContentManagerImpl; -class _IContentScanListener; +class IContentScanListener; +class IContentUpdateEventListener; /** * @class ContentManager @@ -162,7 +163,8 @@ public: * Creates the content information. * * @since 2.0 - * @privilege %http://tizen.org/privilege/content.write + * @privlevel public + * @privilege http://tizen.org/privilege/content.write * * @return The content ID * @param[in] contentInfo An instance of ContentInfo @@ -192,7 +194,8 @@ public: * @compatibility This method has compatibility issues with OSP compatible applications. @n * For more information, see @ref CompContentManagerCreateContentPage "here". * @endif - * @privilege %http://tizen.org/privilege/content.write + * @privlevel public + * @privilege http://tizen.org/privilege/content.write * * @return The content ID * @param[in] byteBuffer The @c byteBuffer of the content to create @@ -229,7 +232,8 @@ public: * @compatibility This method has compatibility issues with OSP compatible applications. @n * For more information, see @ref CompContentManagerCreateContentPage "here". * @endif - * @privilege %http://tizen.org/privilege/content.write + * @privlevel public + * @privilege http://tizen.org/privilege/content.write * * @return The content ID * @param[in] sourcePath The source file path @@ -253,7 +257,7 @@ public: * @exception E_SYSTEM A system error has occurred. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @exception E_SERVICE_BUSY The database is busy. - * @remarks The source path should start with the directory path returned by either Tizen::System::Environment::GetAppRootPath() or Tizen::System::Environment::GetExternalStoragePath(). @n + * @remarks The source path should start with the directory path returned by either Tizen::App::App::GetAppRootPath() or Tizen::System::Environment::GetExternalStoragePath(). @n * The destination path should start with the directory path returned by either Tizen::System::Environment::GetMediaPath() or Tizen::System::Environment::GetExternalStoragePath(). @n * The specific error code can be accessed using the GetLastResult() method. @n * For using CreateContent(), check @ref CreateContentUsage "here". @@ -369,7 +373,8 @@ public: * Gets the content information. * * @since 2.0 - * @privilege %http://tizen.org/privilege/content.read + * @privlevel public + * @privilege http://tizen.org/privilege/content.read * * @return A pointer to ContentInfo * @param[in] contentId The content ID @@ -389,7 +394,8 @@ public: * Updates the content information with the specified instance of ContentInfo. * * @since 2.0 - * @privilege %http://tizen.org/privilege/content.write + * @privlevel public + * @privilege http://tizen.org/privilege/content.write * * @return An error code * @param[in] contentInfo An instance of ContentInfo @@ -407,7 +413,8 @@ public: * Deletes the content information with the specified content ID. * * @since 2.0 - * @privilege %http://tizen.org/privilege/content.write + * @privlevel public + * @privilege http://tizen.org/privilege/content.write * * @return An error code * @param[in] contentId The content ID @@ -424,15 +431,71 @@ public: */ result DeleteContent(const ContentId& contentId); - /* - * Requests to scan a file(for internal use) + /** + * Adds a listener to receive the database change notification + * + * @since 2.1 + * + * @return An error code + * @param[in] listener The event listener + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener has already been added. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + */ + result AddContentUpdateEventListener(IContentUpdateEventListener& listener); + + /** + * Removes a listener + * + * @since 2.1 + * + * @return An error code + * @param[in] listener The event listener + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The listener is not found. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + */ + result RemoveContentUpdateEventListener(IContentUpdateEventListener& listener); + + + /** + * Requests to scan a file + * + * @since 2.1 + * @privlevel public + * @privilege http://tizen.org/privilege/content.write + * + * @return An error code + * @param[in] contentPath The content path + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SERVICE_BUSY The database is busy. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. */ - result ScanFile(const Tizen::Base::String& contentPath); + static result ScanFile(const Tizen::Base::String& contentPath); - /* - * Requests to scan directories(for internal use) + /** + * Requests to scan a directory + * + * @since 2.1 + * @privlevel public + * @privilege http://tizen.org/privilege/content.write + * + * @return An error code + * @param[in] directoryPath The directory path + * @param[in] recursive Set to @c true in order to scan recursively sub directories, @n + * else @c false + * @param[in] pListener The scan event listener + * @param[out] reqId The request ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SERVICE_BUSY The database is busy. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * @remark Platform does not have the ownership of the listener. */ - result ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, _IContentScanListener& listener); + static result ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, IContentScanListener* pListener, RequestId& reqId); private: /** diff --git a/inc/FCntContentManagerUtil.h b/inc/FCntContentManagerUtil.h index af39384..0a4dd65 100644 --- a/inc/FCntContentManagerUtil.h +++ b/inc/FCntContentManagerUtil.h @@ -86,7 +86,7 @@ class _OSP_EXPORT_ ContentManagerUtil { public: /** - * Gets the metadata for an image. + * Gets the metadata of an image from the file. * * @if OSPCOMPAT * @brief [Compatibility] @@ -102,14 +102,28 @@ public: * @param[in] filePath The file path * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG The specified input parameter is invalid. - * @exception E_OUT_OF_MEMORY The memory is insufficient. - * @remarks The supported formats are 'jpg', 'jpeg', 'gif', 'png', 'bmp', 'wbmp', or 'tiff'. @n - * The specific error code can be accessed using the GetLastResult() method. + * @remarks If the image data is valid but meta information does not exist, the width and height are set from actual image data. + * The specific error code can be accessed using the GetLastResult() method. */ static Tizen::Content::ImageMetadata* GetImageMetaN(const Tizen::Base::String& filePath); /** - * Gets the metadata for an audio. + * Gets the metadata of an image from the buffer. + * + * @since 2.1 + * + * @return A pointer to ImageMetadata, @n + * else @c null if an exception occurs + * @param[in] byteBuffer The buffer that contains image data + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks If the image data in the buffer is valid but meta information does not exist, the width and height are set from actual image data. + * The specific error code can be accessed using the GetLastResult() method. + */ + static Tizen::Content::ImageMetadata* GetImageMetaN(const Tizen::Base::ByteBuffer& byteBuffer); + + /** + * Gets the metadata of an audio from the file. * * @if OSPCOMPAT * @brief [Compatibility] @@ -125,14 +139,28 @@ public: * @param[in] filePath The file path * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG The specified input parameter is invalid. - * @exception E_OUT_OF_MEMORY The memory is insufficient. - * @remarks The supported formats are 'mp3', 'wav', 'aac', 'wma', 'm4a', 'xmf', '3ga', or 'mmf'. @n - * The specific error code can be accessed using the GetLastResult() method. + * @remarks If the audio data is valid but meta information does not exist, the duration is set from actual audio data. + * The specific error code can be accessed using the GetLastResult() method. */ static Tizen::Content::AudioMetadata* GetAudioMetaN(const Tizen::Base::String& filePath); /** - * Gets the metadata for a video. + * Gets the metadata of an audio from the buffer. + * + * @since 2.1 + * + * @return A pointer to AudioMetadata, @n + * else @c null if an exception occurs + * @param[in] byteBuffer The buffer that contains audio data + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks If the audio data in the buffer is valid but meta information does not exist, the duration is set from actual audio data. + * The specific error code can be accessed using the GetLastResult() method. + */ + static Tizen::Content::AudioMetadata* GetAudioMetaN(const Tizen::Base::ByteBuffer& byteBuffer); + + /** + * Gets the metadata of a video from the file. * * @if OSPCOMPAT * @brief [Compatibility] @@ -148,13 +176,27 @@ public: * @param[in] filePath The file path * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG The specified input parameter is invalid. - * @exception E_OUT_OF_MEMORY The memory is insufficient. - * @remarks The supported formats are 'wmv', 'asf', 'mp4', '3gp', or 'avi'. @n - * The specific error code can be accessed using the GetLastResult() method. + * @remarks If the video data is valid but meta information does not exist, the duration is set from actual video data. + * The specific error code can be accessed using the GetLastResult() method. */ static Tizen::Content::VideoMetadata* GetVideoMetaN(const Tizen::Base::String& filePath); /** + * Gets the metadata of a video from the buffer. + * + * @since 2.1 + * + * @return A pointer to VideoMetadata, @n + * else @c null if an exception occurs + * @param[in] byteBuffer The buffer that contains video data + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks If the video data in the buffer is valid but meta information does not exist, the duration is set from actual video data. + * The specific error code can be accessed using the GetLastResult() method. + */ + static Tizen::Content::VideoMetadata* GetVideoMetaN(const Tizen::Base::ByteBuffer& byteBuffer); + + /** * Checks the content type from the file path. * * @if OSPCOMPAT @@ -171,7 +213,6 @@ public: * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG The specified input parameter is invalid, or * the length of the specified path is @c 0 or exceeds system limitations. - * @exception E_OUT_OF_MEMORY The memory is insufficient. * @exception E_FILE_NOT_FOUND The specified file cannot be found. * @exception E_UNSUPPORTED_FORMAT The specified format is invalid or not supported. * @remarks The content type can be different for each device. @n diff --git a/inc/FCntContentSearch.h b/inc/FCntContentSearch.h old mode 100755 new mode 100644 index b44a68f..4c4c912 --- a/inc/FCntContentSearch.h +++ b/inc/FCntContentSearch.h @@ -144,7 +144,8 @@ public: * Searches the content and returns the search result list according to the query. * * @since 2.0 - * @privilege %http://tizen.org/privilege/content.read + * @privlevel public + * @privilege http://tizen.org/privilege/content.read * * @return A pointer to a list containing the ContentSearchResult instances @n * An empty list is returned if there is no result and there is no error, @n @@ -213,7 +214,8 @@ public: * Gets the value list of the specified column within a specified range. * * @since 2.0 - * @privilege %http://tizen.org/privilege/content.read + * @privlevel public + * @privilege http://tizen.org/privilege/content.read * * @return A pointer to a list containing the values of a column @n * The type of value can be Tizen::Base::Float, Tizen::Base::Double, Tizen::Base::LongLong, Tizen::Base::DateTime, or Tizen::Base::String. @n @@ -281,7 +283,8 @@ public: * @deprecated This method is deprecated. Instead of using this method, it is recommended to use the GetValueListN(int, int, int&, int&, const Tizen::Base::String&, @n * Tizen::Base::SortOrder) method, that gets the value list of the specified column. * @since 2.0 - * @privilege %http://tizen.org/privilege/content.read + * @privlevel public + * @privilege http://tizen.org/privilege/content.read * * @return A pointer to a list containing the values of a column @n * The type of value can be Tizen::Base::Integer, Tizen::Base::Double, Tizen::Base::LongLong, Tizen::Base::DateTime, or Tizen::Base::String. @n diff --git a/inc/FCntContentTransfer.h b/inc/FCntContentTransfer.h old mode 100755 new mode 100644 index fc502ce..d20a511 --- a/inc/FCntContentTransfer.h +++ b/inc/FCntContentTransfer.h @@ -169,7 +169,8 @@ public: * @deprecated This method is deprecated due to the operation policy of the Tizen Server. * When downloading the contents from a third party server, it is recommended to use the Download(const Tizen::Base::Utility::Uri&, const Tizen::Base::String&, RequestId&, bool, int, int) method. * @since 2.0 - * @privilege %http://tizen.org/privilege/download + * @privlevel public + * @privilege http://tizen.org/privilege/download * * @return An error code * @param[in] uri The content URL @@ -214,7 +215,8 @@ public: * @compatibility This method has compatibility issues with OSP compatible applications. @n * For more information, see @ref CompContentTransferDownloadPage3 "here". * @endif - * @privilege %http://tizen.org/privilege/download + * @privlevel public + * @privilege http://tizen.org/privilege/download * * @return An error code * @param[in] uri The content URL @@ -271,7 +273,8 @@ public: * @deprecated This method is deprecated due to the operation policy of the Tizen Server. * When downloading the contents to a buffer from a third party server, it is recommended to use the DownloadToBuffer(const Tizen::Base::Utility::Uri&, RequestId&, int, int) method. * @since 2.0 - * @privilege %http://tizen.org/privilege/download + * @privlevel public + * @privilege http://tizen.org/privilege/download * * @return An error code * @param[in] uri The content URL @@ -299,7 +302,8 @@ public: * @brief [Deprecated] * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class. * @since 2.0 - * @privilege %http://tizen.org/privilege/download + * @privlevel public + * @privilege http://tizen.org/privilege/download * * @return An error code * @param[in] uri The content URL diff --git a/inc/FCntDownloadManager.h b/inc/FCntDownloadManager.h old mode 100755 new mode 100644 index 94e4a93..4457561 --- a/inc/FCntDownloadManager.h +++ b/inc/FCntDownloadManager.h @@ -119,7 +119,6 @@ public: * @return A pointer to the %DownloadManager instance, @n * else @c null if it fails * @exception E_SUCCESS The method is successful. - * @exception E_OUT_OF_MEMORY The memory is insufficient. * @exception E_SYSTEM The method cannot proceed due to a severe system error. * @remarks The specific error code can be accessed using the GetLastResult() method. */ @@ -130,7 +129,8 @@ public: * If this operation succeeds, the IDownloadListener::OnDownloadInProgress() method is called. @n * * @since 2.0 - * @privilege %http://tizen.org/privilege/download + * @privlevel public + * @privilege http://tizen.org/privilege/download * * @return An error code * @param[in] request The download request @@ -139,7 +139,6 @@ public: * @exception E_INVALID_ARG The URL of the download request is invalid. * @exception E_ILLEGAL_ACCESS Access to the path of the download request is denied due to insufficient permission. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. - * @exception E_OUT_OF_MEMORY The memory is insufficient. * @exception E_SYSTEM The method cannot proceed due to a severe system error. */ result Start(const DownloadRequest& request, RequestId& reqId); @@ -156,7 +155,6 @@ public: * @exception E_INVALID_ARG There is no download request for the specified @c reqId. * @exception E_INVALID_OPERATION The current download state prohibits the execution of this operation. @n * The download state of the request ID is not downloading. - * @exception E_OUT_OF_MEMORY The memory is insufficient. * @exception E_SYSTEM The method cannot proceed due to a severe system error. */ result Pause(RequestId reqId); @@ -172,8 +170,7 @@ public: * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG There is no download request for the specified @c reqId. * @exception E_INVALID_OPERATION The current download state prohibits the execution of this operation. @n - * The download operation of the request ID is not paused. - * @exception E_OUT_OF_MEMORY The memory is insufficient. + * The download state of the request ID is not paused or failed. * @exception E_SYSTEM The method cannot proceed due to a severe system error. */ result Resume(RequestId reqId); @@ -187,7 +184,6 @@ public: * @param[in] reqId The request ID returned by Start() * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG There is no download request for the specified @c reqId. - * @exception E_OUT_OF_MEMORY The memory is insufficient. * @exception E_SYSTEM The method cannot proceed due to a severe system error. */ result Cancel(RequestId reqId); @@ -201,7 +197,6 @@ public: * @param[in] reqId The request ID returned by Start() * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG There is no download request for the specified @c reqId. - * @exception E_OUT_OF_MEMORY The memory is insufficient. * @remarks The specific error code can be accessed using the GetLastResult() method. */ DownloadRequest* GetDownloadRequestN(RequestId reqId) const; @@ -228,7 +223,7 @@ public: * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG There is no download request for the specified @c reqId. * @exception E_INVALID_OPERATION The current download state prohibits the execution of this operation. @n - * The download state of the request ID is not downloading or paused. + * The download operation is not started. * @exception E_SYSTEM The method cannot proceed due to a severe system error. */ result GetMimeType(RequestId reqId, Tizen::Base::String& mimeType) const; diff --git a/inc/FCntDownloadRequest.h b/inc/FCntDownloadRequest.h index 5c0fc26..1dbbff2 100644 --- a/inc/FCntDownloadRequest.h +++ b/inc/FCntDownloadRequest.h @@ -25,6 +25,8 @@ #include #include +#include +#include namespace Tizen { namespace Content { @@ -155,6 +157,103 @@ public: */ Tizen::Base::String GetFileName(void) const; + /** + * Sets to show the download notification by the system or not. @n + * If true, the system posts notifications about this download request through the Tizen::Shell::NotificationManager. @n + * By default, this value sets to true. + * @since 2.1 + * @param[in] enable whether the system should show a notification for this download request + * @see Tizen::Shell::NotificationManager + */ + void SetNotification(bool enable); + + /** + * Sets the extra data which is delivered to the application when the notification message is selected. @n + * The extra data will be passed to the application through the + * Tizen::App::IAppControlProviderEventListener::OnAppControlRequestReceived(). + * @since 2.1 + * @return An error code + * @param[in] pExtraData A pointer to an argument map of the Tizen::Base::String key and Tizen::Base::String value pair + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - The argument is null. @n + * - The argument is not a map of Tizen::Base::String key and Tizen::Base::String value pair. + * @see Tizen::Shell::NotificationManager + * @see Tizen::App::IAppControlProviderEventListener::OnAppControlRequestReceived() + */ + result SetNotificationExtraData(const Tizen::Base::Collection::IMap *pExtraData); + + /** + * Sets the allowed network type. By default, all network types are allowed. + * @since 2.1 + * @param[in] type The download network type + */ + void SetNetworkType(DownloadNetworkType type); + + /** + * Checks whether the system should show a notification for this download request. + * @since 2.1 + * @return @c true if the system should show a notification for this download request, @n + * else @c false + */ + bool IsNotificationEnabled(void) const; + + /** + * Gets the extra data which is delivered to the application when the notification message is seleted. + * @since 2.1 + * @return The extra data map which consists of the Tizen::Base::String key and Tizen::Base::String value pair + */ + const Tizen::Base::Collection::IMap* GetNotificationExtraData(void) const; + + /** + * Gets the allowed network type. + * @since 2.1 + * @return network type + */ + DownloadNetworkType GetNetworkType(void) const; + + /** + * Adds an HTTP header field. + * @since 2.1 + * @return An error code + * @param[in] field The HTTP header field + * @param[in] value The value of the header field + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The field is empty or already exist. + */ + result AddRequestHeader(const Tizen::Base::String& field, const Tizen::Base::String& value); + + /** + * Sets an HTTP header field. + * @since 2.1 + * @return An error code + * @param[in] field The HTTP header field + * @param[in] value The value of the header field + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The field is empty or does not exist. + */ + result SetRequestHeader(const Tizen::Base::String& field, const Tizen::Base::String& value); + + /** + * Removes an HTTP header field. + * @since 2.1 + * @return An error code + * @param[in] field The HTTP header field + * @param[in] value The value of the header field + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The field is empty or does not exist. + */ + result RemoveRequestHeader(const Tizen::Base::String& field); + + /** + * Gets the value of the HTTP header field. + * @since 2.1 + * @return The value of HTTP header field if successful, @n + * else null if there is no HTTP header field + * @param[in] field The HTTP header field + */ + Tizen::Base::String* GetRequestHeaderN(const Tizen::Base::String& field); + private: /** * This default constructor is intentionally declared as private so that only the platform can create an instance. diff --git a/inc/FCntIContentScanListener.h b/inc/FCntIContentScanListener.h index f0e6dc3..37df100 100644 --- a/inc/FCntIContentScanListener.h +++ b/inc/FCntIContentScanListener.h @@ -14,35 +14,81 @@ // See the License for the specific language governing permissions and // limitations under the License. // + /** * @file FCntIContentScanListener.h - * @brief This is the header file for the %_IContentScanListener interface. + * @brief This is the header file for the %IContentScanListener interface. * - * This header file contains the declarations of the %_IContentScanListener interface. + * This header file contains the declarations of the %IContentScanListener interface. */ #ifndef _FCNT_ICONTENT_SCAN_LISTENER_H_ #define _FCNT_ICONTENT_SCAN_LISTENER_H_ -#include #include namespace Tizen { namespace Content { - -class _OSP_EXPORT_ _IContentScanListener +/** + * @interface IContentScanListener + * @brief This interface is used for receiving the scan operation event. + * + * @since 2.1 + * + * The %IContentScanListener interface is used for receiving the scan operation event. + */ +class _OSP_EXPORT_ IContentScanListener : virtual public Tizen::Base::Runtime::IEventListener { public: - virtual ~_IContentScanListener(void) {} - virtual void OnContentScanCompleted(const Tizen::Base::String& scanPath, result r) = 0; + /** + * This polymorphic destructor should be overridden if required. @n + * This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.1 + */ + virtual ~IContentScanListener(void) {} + + /** + * Called when a scan operation is completed. + * + * @since 2.1 + * + * @param[in] reqId The request ID returned by ContentManager::ScanDirectory() + * @param[in] scanPath The scan path. + * @param[in] r The error of scan operation. + * The following exception is given through this parameter. + * @exception E_SUCCESS The method is successful + * @exception E_SERVICE_BUSY The database is busy. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + */ + virtual void OnContentScanCompleted(RequestId reqId, const Tizen::Base::String& scanPath, result r) = 0; protected: - virtual void _IContentScanListener_Reserved1(void) {} - virtual void _IContentScanListener_Reserved2(void) {} -}; // class _IContentScanListener + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.1 + // + virtual void IContentScanListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.1 + // + virtual void IContentScanListener_Reserved2(void) {} + + +}; // class IContentScanListener -}} +}} // Tizen::Content #endif // _FCNT_ICONTENT_SCAN_LISTENER_H_ diff --git a/inc/FCntIContentUpdateEventListener.h b/inc/FCntIContentUpdateEventListener.h new file mode 100644 index 0000000..483173d --- /dev/null +++ b/inc/FCntIContentUpdateEventListener.h @@ -0,0 +1,162 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FCntIContentUpdateEventListener.h + * @brief This is the header file for the %IContentUpdateEventListener interface. + * + * This header file contains the declarations of the %IContentUpdateEventListener interface. + */ + +#ifndef _FCNT_ICONTENT_UPDATE_EVENT_LISTENER_H_ +#define _FCNT_ICONTENT_UPDATE_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Content +{ +/** + * @interface IContentUpdateEventListener + * @brief This interface is used for receiving the database change notification. + * + * @since 2.1 + * + * The %IContentUpdateEventListener interface is used for receiving the database change notification. + */ +class _OSP_EXPORT_ IContentUpdateEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. @n + * This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.1 + */ + virtual ~IContentUpdateEventListener(void) {} + + /** + * Called when the content is created. + * + * @since 2.1 + * + * @param[in] contentId The content ID + * @param[in] contentType The content type + * @param[in] r An error code + * The following exception is given through this parameter. + * @exception E_SUCCESS The method is successful + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + */ + virtual void OnContentFileCreated(ContentId contentId, ContentType contentType, result r) = 0; + + /** + * Called when the content is updated. + * + * @since 2.1 + * + * @param[in] contentId The content ID + * @param[in] contentType The content type + * @param[in] r An error code + * The following exception is given through this parameter. + * @exception E_SUCCESS The method is successful + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + */ + virtual void OnContentFileUpdated(ContentId contentId, ContentType contentType, result r) = 0; + + /** + * Called when the content is deleted.. + * + * @since 2.1 + * + * @param[in] contentId The content ID + * @param[in] contentType The content type + * @param[in] r An error code + * The following exception is given through this parameter. + * @exception E_SUCCESS The method is successful + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + */ + virtual void OnContentFileDeleted(ContentId contentId, ContentType contentType, result r) = 0; + + /** + * Called when the scan for a directory is completed. + * + * @since 2.1 + * + * @param[in] directoryPath The directory path + * @param[in] r An error code + * The following exception is given through this parameter. + * @exception E_SUCCESS The method is successful + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + */ + virtual void OnContentDirectoryScanCompleted(const Tizen::Base::String& directoryPath, result r) = 0; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.1 + // + virtual void IContentUpdateEventListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.1 + // + virtual void IContentUpdateEventListener_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.1 + // + virtual void IContentUpdateEventListener_Reserved3(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.1 + // + virtual void IContentUpdateEventListener_Reserved4(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.1 + // + virtual void IContentUpdateEventListener_Reserved5(void) {} + +}; // class IContentUpdateEventListener + +}} // Tizen::Content + +#endif // _FCNT_ICONTENT_UPDATE_EVENT_LISTENER_H_ diff --git a/inc/FCntTypes.h b/inc/FCntTypes.h index 59b113b..f6ca091 100644 --- a/inc/FCntTypes.h +++ b/inc/FCntTypes.h @@ -82,6 +82,18 @@ enum ImageOrientationType }; /** + * @enum DownloadNetworkType + * Defines the download network type. + * @since 2.1 + */ +enum DownloadNetworkType +{ + DOWNLOAD_NETWORK_DATA_NETWORK = 1, /**< The data network is allowed */ + DOWNLOAD_NETWORK_WIFI, /*< The wifi network is allowed */ + DOWNLOAD_NETWORK_ALL = 100 /*< The all network types are allowed */ +}; + +/** * @enum DownloadState * * Defines the download state. @@ -96,13 +108,13 @@ enum DownloadState DOWNLOAD_STATE_PAUSED, /**< The download request is in a paused state by user request */ DOWNLOAD_STATE_CANCELLED, /**< The download request is cancelled by user request */ DOWNLOAD_STATE_COMPLETED, /**< The download request is in a completed state */ - DOWNLOAD_STATE_FAILED, /**< The download request failed */ + DOWNLOAD_STATE_FAILED /**< The download request failed */ }; -extern const Tizen::Base::String OSP_HOME; -extern const Tizen::Base::String OSP_HOME_EXT; -extern const Tizen::Base::String OSP_MEDIA_PHONE; -extern const Tizen::Base::String OSP_MEDIA_MMC; +_OSP_EXPORT_ extern const wchar_t OSP_HOME[]; +_OSP_EXPORT_ extern const wchar_t OSP_HOME_EXT[]; +_OSP_EXPORT_ extern const wchar_t OSP_MEDIA_PHONE[]; +_OSP_EXPORT_ extern const wchar_t OSP_MEDIA_MMC[]; } } // Tizen::Content diff --git a/inc/FCntVideoMetadata.h b/inc/FCntVideoMetadata.h index 99e8ba0..b91fd70 100644 --- a/inc/FCntVideoMetadata.h +++ b/inc/FCntVideoMetadata.h @@ -176,6 +176,24 @@ public: Tizen::Base::String GetGenre(void) const; /** + * Gets the comment of the video file. + * + * @since 2.1 + * + * @return The comment of the video file + */ + Tizen::Base::String GetComment(void) const; + + /** + * Gets the description of the video file. + * + * @since 2.1 + * + * @return The description of the video file + */ + Tizen::Base::String GetDescription(void) const; + + /** * Gets the album art of the video. * * @since 2.0 diff --git a/inc/FContent.h b/inc/FContent.h index d0e2fc6..679ba5b 100644 --- a/inc/FContent.h +++ b/inc/FContent.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include diff --git a/packaging/osp-content.spec b/packaging/osp-content.spec index 873179b..a6af7da 100644 --- a/packaging/osp-content.spec +++ b/packaging/osp-content.spec @@ -3,7 +3,7 @@ Name: osp-content Summary: osp content library -Version: 1.2.0.0 +Version: 1.2.1.0 Release: 2 Group: System/Libraries License: Apache License, Version 2.0 @@ -34,7 +34,7 @@ BuildRequires: libcurl-devel BuildRequires: openssl-devel # runtime requires -Requires: osp-appfw +Requires: osp-appfw Requires: osp-net Requires: osp-image Requires: osp-media @@ -53,6 +53,12 @@ osp content library Summary: osp content library (Development) Group: TO_BE/FILLED_IN Requires: %{name} = %{version}-%{release} +Requires: osp-appfw-devel +Requires: osp-uifw-devel +Requires: osp-image-core-devel +Requires: osp-image-devel +Requires: osp-locations-devel +Requires: osp-net-devel %description devel osp content library (DEV) diff --git a/src/FCntAudioContentInfo.cpp b/src/FCntAudioContentInfo.cpp index 7093a36..056cfa9 100644 --- a/src/FCntAudioContentInfo.cpp +++ b/src/FCntAudioContentInfo.cpp @@ -27,8 +27,6 @@ #include #include #include -//#include -//#include #include #include diff --git a/src/FCntAudioMetadata.cpp b/src/FCntAudioMetadata.cpp index 6805730..ccebf35 100644 --- a/src/FCntAudioMetadata.cpp +++ b/src/FCntAudioMetadata.cpp @@ -21,12 +21,10 @@ * This file contains implementation of the %AudioMetadata class. */ -// includes #include #include #include -// using namespaces using namespace Tizen::Base; using namespace Tizen::Graphics; @@ -148,6 +146,16 @@ AudioMetadata::GetComment(void) const return __pImpl->GetComment(); } +String +AudioMetadata::GetDescription(void) const +{ + if (__pImpl == null) + { + return String(); + } + return __pImpl->GetDescription(); +} + int AudioMetadata::GetTrack(void) const { diff --git a/src/FCntContentDirectory.cpp b/src/FCntContentDirectory.cpp index f1705c9..fc2aa51 100644 --- a/src/FCntContentDirectory.cpp +++ b/src/FCntContentDirectory.cpp @@ -21,7 +21,6 @@ * This is the implementation file for %ContentDirectory class. */ -// includes #include #include #include diff --git a/src/FCntContentManager.cpp b/src/FCntContentManager.cpp index 16d55d6..525a8db 100644 --- a/src/FCntContentManager.cpp +++ b/src/FCntContentManager.cpp @@ -21,7 +21,6 @@ * This file contains implementation of the %ContentManager class. */ -// includes #include #include #include @@ -32,7 +31,6 @@ #include #include -// using namespaces using namespace Tizen::Base; using namespace Tizen::Security; @@ -251,7 +249,35 @@ ContentManager::DeleteContent(const ContentId& contentId) } result -ContentManager::ScanFile(const String& contentPath) +ContentManager::AddContentUpdateEventListener(IContentUpdateEventListener& listener) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); + + r = __pImpl->AddContentUpdateEventListener(listener); + SysTryReturnResult(NID_CNT, !IsFailed(r), r, "[%s] AddContentUpdateEventListener failed.", GetErrorMessage(r)); + + return r; +} + +result +ContentManager::RemoveContentUpdateEventListener(IContentUpdateEventListener& listener) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); + + r = __pImpl->RemoveContentUpdateEventListener(listener); + SysTryReturnResult(NID_CNT, !IsFailed(r), r, "[%s] RemoveContentUpdateEventListener failed.", GetErrorMessage(r)); + + return r; +} + +result +ContentManager::ScanFile(const Tizen::Base::String& contentPath) { ClearLastResult(); result r = E_SUCCESS; @@ -261,16 +287,14 @@ ContentManager::ScanFile(const String& contentPath) SysTryReturn(NID_CNT, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); - SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); - - r = __pImpl->ScanFile(contentPath); + r = _ContentManagerImpl::ScanFile(contentPath); SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] ScanFile failed.", GetErrorMessage(r)); return r; } result -ContentManager::ScanDirectory(const String& directoryPath, bool recursive, _IContentScanListener& listener) +ContentManager::ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, IContentScanListener* pListener, RequestId& reqId) { ClearLastResult(); result r = E_SUCCESS; @@ -280,11 +304,10 @@ ContentManager::ScanDirectory(const String& directoryPath, bool recursive, _ICon SysTryReturn(NID_CNT, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); - SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); - - r = __pImpl->ScanDirectory(directoryPath, recursive, listener); + r = _ContentManagerImpl::ScanDirectory(directoryPath, recursive, pListener, reqId); SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] ScanDirectory failed.", GetErrorMessage(r)); return r; } + }} diff --git a/src/FCntContentManagerUtil.cpp b/src/FCntContentManagerUtil.cpp index 0e4ef0a..c40b126 100644 --- a/src/FCntContentManagerUtil.cpp +++ b/src/FCntContentManagerUtil.cpp @@ -21,7 +21,6 @@ * This file contains implementation of the %ContentManagerUtil class. */ -// includes #include #include #include @@ -29,7 +28,6 @@ #include #include -// using namespace using namespace Tizen::Base; namespace Tizen { namespace Content @@ -80,6 +78,51 @@ ContentManagerUtil::GetVideoMetaN(const String& filePath) return pVideoMetadata; } +ImageMetadata* +ContentManagerUtil::GetImageMetaN(const ByteBuffer& byteBuffer) +{ + ClearLastResult(); + + result r = E_SUCCESS; + ImageMetadata* pImageMetadata = null; + + pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(byteBuffer); + r = GetLastResult(); + SysTryReturn(NID_CNT, pImageMetadata != null, null, r, "[%s] GetImageMetaN failed.", GetErrorMessage(r)); + + return pImageMetadata; +} + +AudioMetadata* +ContentManagerUtil::GetAudioMetaN(const ByteBuffer& byteBuffer) +{ + ClearLastResult(); + + result r = E_SUCCESS; + AudioMetadata* pAudioMetadata = null; + + pAudioMetadata = _ContentManagerUtilImpl::GetAudioMetaN(byteBuffer); + r = GetLastResult(); + SysTryReturn(NID_CNT, pAudioMetadata != null, null, r, "[%s] GetAudioMetaN failed.", GetErrorMessage(r)); + + return pAudioMetadata; +} + +VideoMetadata* +ContentManagerUtil::GetVideoMetaN(const ByteBuffer& byteBuffer) +{ + ClearLastResult(); + + result r = E_SUCCESS; + VideoMetadata* pVideoMetadata = null; + + pVideoMetadata = _ContentManagerUtilImpl::GetVideoMetaN(byteBuffer); + r = GetLastResult(); + SysTryReturn(NID_CNT, pVideoMetadata != null, null, r, "[%s] GetVideoMetaN failed.", GetErrorMessage(r)); + + return pVideoMetadata; +} + ContentType ContentManagerUtil::CheckContentType(const String& filePath) { diff --git a/src/FCntContentSearch.cpp b/src/FCntContentSearch.cpp index 438549d..ef3caf1 100644 --- a/src/FCntContentSearch.cpp +++ b/src/FCntContentSearch.cpp @@ -21,7 +21,6 @@ * This is the implementation file for %ContentSearch class. */ -// includes #include #include #include diff --git a/src/FCntContentSearchResult.cpp b/src/FCntContentSearchResult.cpp index 7e64c94..b3d98f2 100644 --- a/src/FCntContentSearchResult.cpp +++ b/src/FCntContentSearchResult.cpp @@ -21,11 +21,9 @@ * This file contains implementation of the %ContentSearchResult class. */ -// includes #include #include -// using namespace using namespace Tizen::Base; namespace Tizen { namespace Content diff --git a/src/FCntContentTransfer.cpp b/src/FCntContentTransfer.cpp index de6a180..6853da8 100644 --- a/src/FCntContentTransfer.cpp +++ b/src/FCntContentTransfer.cpp @@ -21,7 +21,6 @@ * This file contains implementation of the %ContentTransfer class. */ -// includes #include #include #include @@ -29,7 +28,6 @@ #include #include -// using namespace using namespace Tizen::Base; using namespace Tizen::Security; diff --git a/src/FCntDownloadRequest.cpp b/src/FCntDownloadRequest.cpp index 4589852..fec2d39 100644 --- a/src/FCntDownloadRequest.cpp +++ b/src/FCntDownloadRequest.cpp @@ -26,6 +26,7 @@ #include "FCnt_DownloadRequestImpl.h" using namespace Tizen::Base; +using namespace Tizen::Base::Collection; namespace Tizen { namespace Content { @@ -129,4 +130,65 @@ DownloadRequest::GetFileName(void) const return __pDownloadRequestImpl->GetFileName(); } +void +DownloadRequest::SetNotification(bool enable) +{ + __pDownloadRequestImpl->SetNotification(enable); +} + +result +DownloadRequest::SetNotificationExtraData(const IMap *pExtraData) +{ + SysTryReturnResult(NID_CNT, pExtraData != null, E_INVALID_ARG, "pExtraData is null."); + return __pDownloadRequestImpl->SetNotificationExtraData(pExtraData); +} + +void +DownloadRequest::SetNetworkType(DownloadNetworkType type) +{ + __pDownloadRequestImpl->SetNetworkType(type); +} + +bool +DownloadRequest::IsNotificationEnabled(void) const +{ + return __pDownloadRequestImpl->IsNotificationEnabled(); +} + +const IMap* +DownloadRequest::GetNotificationExtraData(void) const +{ + return __pDownloadRequestImpl->GetNotificationExtraData(); +} + +DownloadNetworkType +DownloadRequest::GetNetworkType(void) const +{ + return __pDownloadRequestImpl->GetNetworkType(); +} + +result +DownloadRequest::AddRequestHeader(const String& field, const String& value) +{ + return __pDownloadRequestImpl->AddRequestHeader(field, value); +} + +result +DownloadRequest::SetRequestHeader(const String& field, const String& value) +{ + return __pDownloadRequestImpl->SetRequestHeader(field, value); +} + +result +DownloadRequest::RemoveRequestHeader(const String& field) +{ + return __pDownloadRequestImpl->RemoveRequestHeader(field); +} + +String* +DownloadRequest::GetRequestHeaderN(const String& field) +{ + return __pDownloadRequestImpl->GetRequestHeaderN(field); +} + } } // Tizen::Content diff --git a/src/FCntImageContentInfo.cpp b/src/FCntImageContentInfo.cpp index f8a7d86..4e3e795 100644 --- a/src/FCntImageContentInfo.cpp +++ b/src/FCntImageContentInfo.cpp @@ -26,8 +26,6 @@ #include #include #include -//#include -//#include #include #include diff --git a/src/FCntImageMetadata.cpp b/src/FCntImageMetadata.cpp index 7aa7909..c9cdd9f 100644 --- a/src/FCntImageMetadata.cpp +++ b/src/FCntImageMetadata.cpp @@ -21,12 +21,10 @@ * This file contains implementation of the %ImageMetadata class. */ -// includes #include #include #include -// using namespaces using namespace Tizen::Base; using namespace Tizen::Graphics; diff --git a/src/FCntOtherContentInfo.cpp b/src/FCntOtherContentInfo.cpp index a025902..5cfdb17 100644 --- a/src/FCntOtherContentInfo.cpp +++ b/src/FCntOtherContentInfo.cpp @@ -26,8 +26,6 @@ #include #include #include -//#include -//#include #include #include diff --git a/src/FCntPlayList.cpp b/src/FCntPlayList.cpp index c678383..08d9045 100644 --- a/src/FCntPlayList.cpp +++ b/src/FCntPlayList.cpp @@ -195,8 +195,8 @@ PlayList::SetPlayListName(const Tizen::Base::String& playListName) SysTryReturn(NID_CNT, !playListName.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty."); - r = __pImpl->SetPlalyListName(__playListName, playListName); // impl need old and new name - SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] SetPlalyListName failed. ", GetErrorMessage(r)); + r = __pImpl->SetPlayListName(__playListName, playListName); // impl need old and new name + SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] SetPlayListName failed. ", GetErrorMessage(r)); __playListName = playListName; diff --git a/src/FCntVideoContentInfo.cpp b/src/FCntVideoContentInfo.cpp index 0c13701..577ecb3 100644 --- a/src/FCntVideoContentInfo.cpp +++ b/src/FCntVideoContentInfo.cpp @@ -28,8 +28,6 @@ #include #include #include -//#include -//#include #include #include diff --git a/src/FCntVideoMetadata.cpp b/src/FCntVideoMetadata.cpp index a696c93..11d4813 100644 --- a/src/FCntVideoMetadata.cpp +++ b/src/FCntVideoMetadata.cpp @@ -21,12 +21,10 @@ * This file contains implementation of the %VideoMetadata class. */ -// includes #include #include #include -// using namespaces using namespace Tizen::Base; using namespace Tizen::Graphics; @@ -168,6 +166,26 @@ VideoMetadata::GetGenre(void) const return __pImpl->GetGenre(); } +String +VideoMetadata::GetComment(void) const +{ + if (__pImpl == null) + { + return String(); + } + return __pImpl->GetComment(); +} + +String +VideoMetadata::GetDescription(void) const +{ + if (__pImpl == null) + { + return String(); + } + return __pImpl->GetDescription(); +} + Bitmap* VideoMetadata::GetAlbumArtN(void) const { diff --git a/src/FCnt_AudioMetadataImpl.cpp b/src/FCnt_AudioMetadataImpl.cpp index ae4325b..39a2f0a 100644 --- a/src/FCnt_AudioMetadataImpl.cpp +++ b/src/FCnt_AudioMetadataImpl.cpp @@ -21,13 +21,11 @@ * This file contains implementation of the %_AudioMetadataImpl class. */ -// includes #include #include #include #include -// using namespaces using namespace std; using namespace Tizen::Base; using namespace Tizen::Graphics; @@ -97,6 +95,11 @@ _AudioMetadataImpl::SetAudioMetadata(const AudioMeta* pAudioMeta) __pAudioMeta->pComment = new (nothrow) String(*(pAudioMeta->pComment)); SysTryReturnResult(NID_CNT, __pAudioMeta->pComment != null, E_OUT_OF_MEMORY, "The memory is insufficient."); } + if (pAudioMeta->pDescription != null) + { + __pAudioMeta->pDescription = new (nothrow) String(*(pAudioMeta->pDescription)); + SysTryReturnResult(NID_CNT, __pAudioMeta->pDescription != null, E_OUT_OF_MEMORY, "The memory is insufficient."); + } if (pAudioMeta->pComposer != null) { __pAudioMeta->pComposer = new (nothrow) String(*(pAudioMeta->pComposer)); @@ -199,6 +202,16 @@ _AudioMetadataImpl::_AudioMetadataImpl(const _AudioMetadataImpl& rhs) return; } } + // pDescription + if ((rhs.__pAudioMeta)->pDescription != null) + { + pNewAudioMeta->pDescription = new (nothrow) String(*((rhs.__pAudioMeta)->pDescription)); + if (pNewAudioMeta->pDescription == null) + { + SysLog(NID_CNT, "The memory is insufficient."); + return; + } + } // pComposer if ((rhs.__pAudioMeta)->pComposer != null) { @@ -390,6 +403,25 @@ _AudioMetadataImpl::operator =(const _AudioMetadataImpl& rhs) __pAudioMeta->pComment = new (nothrow) String(*((rhs.__pAudioMeta)->pComment)); } + // pDescription + if (__pAudioMeta->pDescription != null && (rhs.__pAudioMeta)->pDescription != null) + { + // delete previous data + delete __pAudioMeta->pDescription; + __pAudioMeta->pDescription = null; + + __pAudioMeta->pDescription = new (nothrow) String(*((rhs.__pAudioMeta)->pDescription)); + } + else if (__pAudioMeta->pDescription != null) + { + delete __pAudioMeta->pDescription; + __pAudioMeta->pDescription = null; + } + else if ((rhs.__pAudioMeta)->pDescription != null) + { + __pAudioMeta->pDescription = new (nothrow) String(*((rhs.__pAudioMeta)->pDescription)); + } + // pComposer if (__pAudioMeta->pComposer != null && (rhs.__pAudioMeta)->pComposer != null) { @@ -575,6 +607,10 @@ _AudioMetadataImpl::Equals(const Tizen::Base::Object& rhs) const { return false; } + if (!((this->GetDescription()).Equals(pRhs->GetDescription()))) + { + return false; + } if (!((this->GetComposer()).Equals(pRhs->GetComposer()))) { return false; @@ -622,25 +658,22 @@ _AudioMetadataImpl::Equals(const Tizen::Base::Object& rhs) const int _AudioMetadataImpl::GetHashCode(void) const { - int hash = 0; - - hash += (this->GetAlbumName()).GetHashCode(); - hash += (this->GetArtist()).GetHashCode(); - hash += Integer::GetHashCode(this->GetBitrate()); - hash += Integer::GetHashCode(this->GetChannelCount()); - hash += (this->GetComment()).GetHashCode(); - hash += (this->GetComposer()).GetHashCode(); - hash += (this->GetCopyright()).GetHashCode(); - hash += Long::GetHashCode(this->GetDuration()); - hash += Integer::GetHashCode(this->GetFrequency()); - hash += (this->GetGenre()).GetHashCode(); - hash += (this->GetRecordingDate()).GetHashCode(); - hash += (this->GetTitle()).GetHashCode(); - hash += Integer::GetHashCode(this->GetTrack()); - hash += (this->GetTrackInfo()).GetHashCode(); - hash += Integer::GetHashCode(this->GetYear()); - - return hash; + return (this->GetAlbumName()).GetHashCode() + ^ (this->GetArtist()).GetHashCode() + ^ Integer::GetHashCode(this->GetBitrate()) + ^ Integer::GetHashCode(this->GetChannelCount()) + ^ (this->GetComment()).GetHashCode() + ^ (this->GetDescription()).GetHashCode() + ^ (this->GetComposer()).GetHashCode() + ^ (this->GetCopyright()).GetHashCode() + ^ Long::GetHashCode(this->GetDuration()) + ^ Integer::GetHashCode(this->GetFrequency()) + ^ (this->GetGenre()).GetHashCode() + ^ (this->GetRecordingDate()).GetHashCode() + ^ (this->GetTitle()).GetHashCode() + ^ Integer::GetHashCode(this->GetTrack()) + ^ (this->GetTrackInfo()).GetHashCode() + ^ Integer::GetHashCode(this->GetYear()); } String @@ -709,6 +742,17 @@ _AudioMetadataImpl::GetComment(void) const return *(__pAudioMeta->pComment); } +String +_AudioMetadataImpl::GetDescription(void) const +{ + if (__pAudioMeta == null || __pAudioMeta->pDescription == null) + { + SysLog(NID_CNT, "__pAudioMeta or __pAudioMeta->pDescription is null."); + return String(); + } + return *(__pAudioMeta->pDescription); +} + int _AudioMetadataImpl::GetTrack(void) const { diff --git a/src/FCnt_ContentDirectoryImpl.cpp b/src/FCnt_ContentDirectoryImpl.cpp index 111576b..fc1225f 100644 --- a/src/FCnt_ContentDirectoryImpl.cpp +++ b/src/FCnt_ContentDirectoryImpl.cpp @@ -354,7 +354,15 @@ _ContentDirectoryImpl::GetContentDirectoryItemCount(const Tizen::Base::String& c SysTryReturn(NID_CNT, CheckMediaPath(contentDirectoryPath), directoryItemCount, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform CheckMediaPath operation."); - r = CreateFolderFilter(__isMultiContentType, contentDirectoryPath); + String detachedPath = contentDirectoryPath; + + if (contentDirectoryPath.EndsWith(L"/")) + { + r = detachedPath.Remove(detachedPath.GetLength() - 1, 1); + SysTryReturn(NID_CNT, !IsFailed(r), directoryItemCount, E_INVALID_ARG, "[E_INVALID_ARG] Failed to remove the path string."); + } + + r = CreateFolderFilter(__isMultiContentType, detachedPath); SysTryReturn(NID_CNT, !IsFailed(r), directoryItemCount, E_SYSTEM, "[E_SYSTEM] Failed to perform CreateFolderFilter operation."); ret = media_folder_foreach_folder_from_db(*(__pFilterHandle.get()), MediaFoldersCb, &pItemList); @@ -498,13 +506,21 @@ _ContentDirectoryImpl::GetContentDirectoryItemListN(const Tizen::Base::String& c SysTryReturn(NID_CNT, CheckMediaPath(contentDirectoryPath), null, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform CheckMediaPath operation."); + String detachedPath = contentDirectoryPath; + + if (contentDirectoryPath.EndsWith(L"/")) + { + r = detachedPath.Remove(detachedPath.GetLength() - 1, 1); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] Failed to remove the path string."); + } + __pFinalOutList = std::unique_ptr(new (std::nothrow) ArrayList()); SysTryReturn(NID_CNT, __pFinalOutList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] FinalOutList is null."); r = __pFinalOutList->Construct(); SysTryReturn(NID_CNT, r == E_SUCCESS, null, r, "[%s] Failed to construct __pFinalOutList ArrayList.", GetErrorMessage(r)); - r = CreateFolderFilter(__isMultiContentType, contentDirectoryPath); + r = CreateFolderFilter(__isMultiContentType, detachedPath); SysTryReturn(NID_CNT, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] Failed to perform CreateFolderFilter operation."); if ((!column.IsEmpty()) && (sortOrder != SORT_ORDER_NONE)) @@ -575,7 +591,7 @@ _ContentDirectoryImpl::GetContentDirectoryItemListN(const Tizen::Base::String& c SysLog(NID_CNT, "totalCount is [%d].", totalCount); } - + if (totalCount > 0) { if ((totalCount % countPerPage) == 0) diff --git a/src/FCnt_ContentDownloadListener.cpp b/src/FCnt_ContentDownloadListener.cpp index 174b5d4..e97959c 100644 --- a/src/FCnt_ContentDownloadListener.cpp +++ b/src/FCnt_ContentDownloadListener.cpp @@ -25,12 +25,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include "FCnt_ContentDownloadListener.h" @@ -422,7 +422,7 @@ _ContentDownloadListener::DownloadCompleted(HttpSession& httpSession, HttpTransa return; CATCH: - ContentManager contentManager; + _ContentManagerImpl contentManager; r = contentManager.Construct(); SysTryLog(NID_CNT, !IsFailed(r), "[%s] Failed to construct ContentManager.", GetErrorMessage(r)); @@ -462,7 +462,7 @@ _ContentDownloadListener::RegisterMediaFile(HttpSession& httpSession, HttpTransa ClearLastResult(); result r = E_SUCCESS; ContentId contentId; - ContentManager contentManager; + _ContentManagerImpl contentManager; ContentType contentType = CONTENT_TYPE_UNKNOWN; ImageContentInfo imageContentInfo; AudioContentInfo audioContentInfo; diff --git a/src/FCnt_ContentManagerImpl.cpp b/src/FCnt_ContentManagerImpl.cpp index 3f103f1..ef721c4 100644 --- a/src/FCnt_ContentManagerImpl.cpp +++ b/src/FCnt_ContentManagerImpl.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,8 @@ using namespace std; namespace Tizen { namespace Content { +static RequestId requestId = 0; + static const int SYSTEM_TYPE_IMAGE = 0; static const int SYSTEM_TYPE_VIDEO = 1; static const int SYSTEM_TYPE_SOUND = 2; @@ -62,17 +65,52 @@ static const double DEFAULT_COORDINATE = -200.0; static const int SOURCE_PATH_LENGTH = 200; // For extern declaration in FCntTypes.h -const String OSP_HOME = L"/Home/"; -const String OSP_HOME_EXT = L"/HomeExt/"; -const String OSP_MEDIA_PHONE = L"/Media/"; -const String OSP_MEDIA_MMC = L"/Storagecard/Media/"; +const wchar_t OSP_HOME[] = L"/Home/"; +const wchar_t OSP_HOME_EXT[] = L"/HomeExt/"; +const wchar_t OSP_MEDIA_PHONE[] = L"/Media/"; +const wchar_t OSP_MEDIA_MMC[] = L"/Storagecard/Media/"; + +static result +ConvertError(int error) +{ + result r = E_SUCCESS; + + switch (error) + { + case MEDIA_CONTENT_ERROR_NONE: + r = E_SUCCESS; + break; + + case MEDIA_CONTENT_ERROR_INVALID_PARAMETER: + r = E_INVALID_ARG; + break; + + case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY: + r = E_OUT_OF_MEMORY; + break; + + case MEDIA_CONTENT_ERROR_DB_BUSY: + r = E_SERVICE_BUSY; + break; + + case MEDIA_CONTENT_ERROR_DB_FAILED: + r = E_SYSTEM; + break; + + default: + r = E_SYSTEM; + break; + } + + return r; +} static void -OnScanCompleted(media_content_error_e error, void *user_data) +OnScanCompleted(media_content_error_e error, void* user_data) { ClearLastResult(); - SysLog(NID_CNT, "OnScanCompleted start."); + SysLog(NID_CNT, "OnScanCompleted callback method is called."); if (user_data == null) { @@ -80,49 +118,128 @@ OnScanCompleted(media_content_error_e error, void *user_data) return; } - ScanResult* pScanResult = (ScanResult*)user_data; + ScanResult* pScanResult = static_cast< ScanResult* >(user_data); - if (pScanResult == null || pScanResult->pData == null || pScanResult->pContentPath == null) + if (pScanResult == null || pScanResult->pScanPath == null || pScanResult->pScanListener == null) { SysLog(NID_CNT, "OnScanCompleted failed."); return; } - _ContentManagerImpl* __pManagerImpl = (_ContentManagerImpl*)pScanResult->pData; - String contentPath(pScanResult->pContentPath); + String scanPath(pScanResult->pScanPath); + IContentScanListener* pListener = pScanResult->pScanListener; + RequestId reqId = pScanResult->requestId; delete pScanResult; + result r = ConvertError(error); + + pListener->OnContentScanCompleted(reqId, scanPath, r); + + int val = media_content_disconnect(); + SysTryLog(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, "The disconnection failed[%d].", val); + + SysLog(NID_CNT, "Fire the OnContentScanCompleted method."); +} + +static void +OnContentUpdateCompleted(media_content_error_e error, int pid, media_content_db_update_item_type_e update_item, + media_content_db_update_type_e update_type, media_content_type_e media_type, char* uuid, char* path, char* mime_type, void* user_data) +{ + SysLog(NID_CNT, "OnContentUpdateCompleted callback method is called."); + result r = E_SUCCESS; - switch (error) + + SysTryLogReturn(NID_CNT, user_data != null, , "OnContentUpdateCompleted failed."); + + _ContentManagerImpl* pTempManagerImpl = static_cast< _ContentManagerImpl* >(user_data); + + IContentUpdateEventListener* pListener = pTempManagerImpl->GetListener(); + SysTryLogReturn(NID_CNT, pListener != null, , "IContentUpdateEventListener is null."); + + if (error != MEDIA_CONTENT_ERROR_NONE) { - case MEDIA_CONTENT_ERROR_NONE: - r = E_SUCCESS; - break; + r = E_SYSTEM; + } - case MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT: - // fall through - case MEDIA_CONTENT_ERROR_INVALID_PARAMETER: - r = E_INVALID_ARG; - break; + switch (update_item) + { + case MEDIA_ITEM_FILE: + { + ContentType contentType = CONTENT_TYPE_UNKNOWN; - case MEDIA_CONTENT_ERROR_DB_BUSY: - r = E_SERVICE_BUSY; + switch (media_type) + { + case MEDIA_CONTENT_TYPE_IMAGE: + contentType = CONTENT_TYPE_IMAGE; + break; + + case MEDIA_CONTENT_TYPE_VIDEO: + contentType = CONTENT_TYPE_VIDEO; + break; + + case MEDIA_CONTENT_TYPE_SOUND: + // fall through + case MEDIA_CONTENT_TYPE_MUSIC: + contentType = CONTENT_TYPE_AUDIO; + break; + + case MEDIA_CONTENT_TYPE_OTHERS: + contentType = CONTENT_TYPE_OTHER; + break; + + default: + r = E_SYSTEM; + SysLog(NID_CNT, "media_type is invalid."); + break; + } + + String str(uuid); + ContentId contentId; + + result res = UuId::Parse(str, contentId); + SysTryLogReturn(NID_CNT, !IsFailed(res), , "Failed to parse to the content ID."); + + switch (update_type) + { + case MEDIA_CONTENT_INSERT: + pListener->OnContentFileCreated(contentId, contentType, r); + break; + + case MEDIA_CONTENT_DELETE: + pListener->OnContentFileDeleted(contentId, contentType, r); + break; + + case MEDIA_CONTENT_UPDATE: + pListener->OnContentFileUpdated(contentId, contentType, r); + break; + + default: + SysLog(NID_CNT, "update_type is invalid."); + break; + } + } + + case MEDIA_ITEM_DIRECTORY: + { + String directoryPath(path); + + pListener->OnContentDirectoryScanCompleted(directoryPath, r); break; + } default: - r = E_SYSTEM; + SysLog(NID_CNT, "update_item is invalid."); break; } - (__pManagerImpl->GetListener())->OnContentScanCompleted(contentPath, r); - - SysLog(NID_CNT, "OnScanCompleted end."); + SysLog(NID_CNT, "Fire the OnContentUpdateCompleted method."); } _ContentManagerImpl::_ContentManagerImpl(void) : Object() , __isConnected(false) + , __pListener(null) { } @@ -715,56 +832,110 @@ _ContentManagerImpl::DeleteContent(const ContentId& contentId) return r; } +// +// E_SUCCESS +// E_OBJ_ALREADY_EXIST +// E_SYSTEM +// result -_ContentManagerImpl::ScanFile(const String& contentPath) +_ContentManagerImpl::AddContentUpdateEventListener(IContentUpdateEventListener& listener) { - SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use."); - ClearLastResult(); - unique_ptr pContentPath(_StringConverter::CopyToCharArrayN(contentPath)); + SysTryReturnResult(NID_CNT, GetListener() == null, E_OBJ_ALREADY_EXIST, "IContentUpdateEventListener is already set."); - int val = media_content_scan_file(pContentPath.get()); - SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val), - "media_content_scan_file failed[%d].", val); + SetListener(&listener); + + int val = media_content_set_db_updated_cb(OnContentUpdateCompleted, this); + SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "media_content_set_db_updated_cb failed[%d].", val); return E_SUCCESS; } +// +// E_SUCCESS +// E_OBJ_NOT_FOUND +// E_SYSTEM +// result -_ContentManagerImpl::ScanDirectory(const String& directoryPath, bool recursive, _IContentScanListener& listener) +_ContentManagerImpl::RemoveContentUpdateEventListener(IContentUpdateEventListener& listener) { - SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use."); + ClearLastResult(); + + SysTryReturnResult(NID_CNT, GetListener() == &listener, E_OBJ_NOT_FOUND, "The input listener is not equal to the registered listener."); + + int val = media_content_unset_db_updated_cb(); + SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "media_content_unset_db_updated_cb failed[%d].", val); + + SetListener(null); + + return E_SUCCESS; +} +// +// E_SUCCESS +// E_INVALID_ARG +// E_SYSTEM +// E_SERVICE_BUSY +// E_PRIVILEGE_DENIED(in public) +// +result +_ContentManagerImpl::ScanFile(const Tizen::Base::String& contentPath) +{ ClearLastResult(); - unique_ptr pDirPath(_StringConverter::CopyToCharArrayN(directoryPath)); + SysLog(NID_CNT, "The scan path is [%ls].", contentPath.GetPointer()); - SetListener(&listener); + unique_ptr pContentPath(_StringConverter::CopyToCharArrayN(contentPath)); + SysTryReturnResult(NID_CNT, (pContentPath.get())[0] != null, E_SYSTEM, "pContentPath is NULL."); - ScanResult* pScanResult = new (nothrow) ScanResult; - SysTryReturnResult(NID_CNT, pScanResult != null, E_OUT_OF_MEMORY, "The memory is insufficient."); + int val = media_content_connect(); + SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The connection failed[%d].", val); - pScanResult->pData = this; - pScanResult->pContentPath = pDirPath.get(); + val = media_content_scan_file(pContentPath.get()); + SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val), "media_content_scan_file failed[%d].", val); - int val = media_content_scan_folder(pDirPath.release(), OnScanCompleted, pScanResult); - SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val), - "media_content_scan_folder failed[%d].", val); + val = media_content_disconnect(); + SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The disconnection failed[%d].", val); return E_SUCCESS; } -void -_ContentManagerImpl::SetListener(_IContentScanListener* pListener) +// +// E_SUCCESS +// E_INVALID_ARG +// E_SYSTEM +// E_SERVICE_BUSY +// E_PRIVILEGE_DENIED(in public) +// +result +_ContentManagerImpl::ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, IContentScanListener* pListener, RequestId& reqId) { - this->__pListener = pListener; -} + ClearLastResult(); -_IContentScanListener* -_ContentManagerImpl::GetListener(void) const -{ - return this->__pListener; + SysLog(NID_CNT, "The scan path is [%ls].", directoryPath.GetPointer()); + + SysTryReturnResult(NID_CNT, pListener != null, E_INVALID_ARG, "Failed to ScanDirectory method."); + + unique_ptr pDirPath(_StringConverter::CopyToCharArrayN(directoryPath)); + SysTryReturnResult(NID_CNT, (pDirPath.get())[0] != null, E_SYSTEM, "pDirPath is NULL."); + + int val = media_content_connect(); + SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The connection failed[%d].", val); + + ScanResult* pScanResult = new (nothrow) ScanResult; + SysTryReturnResult(NID_CNT, pScanResult != null, E_OUT_OF_MEMORY, "The memory is insufficient."); + + reqId = requestId++; + + pScanResult->pScanPath = pDirPath.get(); + pScanResult->pScanListener = pListener; + pScanResult->requestId = reqId; + + val = media_content_scan_folder(pDirPath.release(), recursive, OnScanCompleted, pScanResult); + SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val), "media_content_scan_folder failed[%d].", val); + + return E_SUCCESS; } // @@ -1692,41 +1863,6 @@ _ContentManagerImpl::MakeContentInfo(const media_info_h pMediaInfo, ContentInfo: return r; } -result -_ContentManagerImpl::ConvertError(int error) const -{ - result r = E_SUCCESS; - - switch (error) - { - case MEDIA_CONTENT_ERROR_NONE: - r = E_SUCCESS; - break; - - case MEDIA_CONTENT_ERROR_INVALID_PARAMETER: - r = E_INVALID_ARG; - break; - - case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY: - r = E_OUT_OF_MEMORY; - break; - - case MEDIA_CONTENT_ERROR_DB_BUSY: - r = E_SERVICE_BUSY; - break; - - case MEDIA_CONTENT_ERROR_DB_FAILED: - r = E_SYSTEM; - break; - - default: - r = E_SYSTEM; - break; - } - - return r; -} - bool _ContentManagerImpl::VerifyHomeFilePathCompatibility(const String& contentPath) const { @@ -1804,4 +1940,16 @@ _ContentManagerImpl::VerifyMediaFilePathCompatibility(const String& contentPath, return true; } +void +_ContentManagerImpl::SetListener(IContentUpdateEventListener* pListener) +{ + __pListener = pListener; +} + +IContentUpdateEventListener* +_ContentManagerImpl::GetListener(void) const +{ + return __pListener; +} + }} diff --git a/src/FCnt_ContentManagerUtilImpl.cpp b/src/FCnt_ContentManagerUtilImpl.cpp index 62db6c4..942720b 100644 --- a/src/FCnt_ContentManagerUtilImpl.cpp +++ b/src/FCnt_ContentManagerUtilImpl.cpp @@ -24,10 +24,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -58,18 +60,7 @@ static const int IMAGE_BUFF_LENGTH = 100; static const int THUMBNAIL_IMAGE_WIDTH = 80; static const int THUMBNAIL_IMAGE_HEIGHT = 60; static const int MINUTES = 60; -static const int SECONDS = 3600; // 60*60 -static const wchar_t CONTENT_FORMAT[] = - L"jpg1 JPG1 jpeg1 JPEG1 png1 PNG1 gif1 GIF1 wbmp1 WBMP1 bmp1 BMP1 tiff1 TIFF1 tif1 TIF1 \ - mp32 MP32 aac2 AAC2 wma2 WMA2 m4a2 M4A2 3ga2 3GA2 midi2 MIDI2 mid2 MID2 mmf2 MMF2 \ - wav2 WAV2 amr2 AMR2 imy2 IMY2 mxmf2 MXMF2 xmf2 XMF2 pmd2 PMD2 sdc2 SDC2 spm2 SPM2 flac2 FLAC2 pya2 PYA2 \ - ogg2 OGG2 oga2 OGA2 \ - wmv3 WMV3 avi3 AVI3 asf3 ASF3 sdp3 SDP3 divx3 DIVX3 mkv3 MKV3 skm3 SKM3 k3g3 K3G3 pyv3 PYV3 rv3 RV3 \ - rm3 RM3 ram3 RAM3 mov3 MOV3 qt3 QT3 mpeg3 MPEG3 flv3 FLV3 ra2 RA2 \ - txt0 TXT0 fb20 FB20 smt0 SMT0 docx0 DOCX0 doc0 DOC0 pdf0 PDF0 pptx0 PPTX0 ppt0 PPT0 xlsx0 XLSX0 \ - xls0 XLS0 html0 HTML0 htm0 HTM0 jad0 JAD0 jar0 JAR0 vbm0 VBM0 vcf0 VCF0 vcs0 VCS0 vmg0 VMG0 eml0 EML0 \ - zse0 ZSE0 cer0 CER0 crt0 CRT0 der0 DER0 p120 P120 pfx0 PFX0 wgt0 WGT0 svgz0 SVGZ0 svg0 SVG0 swf0 SWF0 \ - enc0 ENC0 ics0 ICS0 oap0 OAP0 mp45 MP45 3gpp5 3GPP5 3gp5 3GP5"; +static const int SECONDS = 3600; // // E_SUCCESS @@ -117,7 +108,7 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal) if (imgType == IMG_FORMAT_JPG) { unique_ptr pFileName(_StringConverter::CopyToCharArrayN(contentPath)); - SysTryReturn(NID_CNT, pFileName != null, pImageMetadata.release(), E_OUT_OF_MEMORY, + SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); unique_ptr pExifdata(exif_data_new_from_file(pFileName.get())); @@ -456,11 +447,754 @@ _ContentManagerUtilImpl::GetAudioMetaN(const String& contentPath) "[%s] metadata_extractor_get_metadata(title) failed.", GetErrorMessage(r)); } + // comment + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_COMMENT, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->pComment = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pComment != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(comment) failed.", GetErrorMessage(r)); + } + // description retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DESCRIPTION, &__pAudioMeta); if (__pAudioMeta != null) { pAudioMeta.reset(__pAudioMeta); + pMetadata->pDescription = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pDescription != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(description) failed.", GetErrorMessage(r)); + } + + // recording date + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_RECDATE, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->pRecordingDate = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pRecordingDate != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(recording date) failed.", GetErrorMessage(r)); + } + + // author + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_AUTHOR, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->pComposer = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pComposer != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(author) failed.", GetErrorMessage(r)); + } + + // track info + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_TRACK_NUM, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->pTrackInfo = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pTrackInfo != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + + // if the string contains the track info like track num/track position, + // then track position will be ignored and only track num is returned + // no need to parse this string, since only track number is required + pMetadata->trackNum = atoi(pAudioMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(track info) failed.", GetErrorMessage(r)); + } + + // date + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DATE, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->year = atoi(pAudioMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(date) failed.", GetErrorMessage(r)); + } + + // artwork + int size = 0; + void* __pArtwork = null; + unique_ptr pArtwork(null); + + // Get the artwork image in media file + retVal = metadata_extractor_get_artwork(*(pExtractor.get()), &__pArtwork, &size, &__pAudioMeta); + + //Check if the albumart present and pass it to client if it is successfully processed, otherwise ignore any errors + //while processing albumart. This is to pass the other metadata tags to application. + if (__pArtwork != null) + { + pArtwork.reset(__pArtwork); + + Image img; + ImageFormat format = IMG_FORMAT_NONE; + ByteBuffer buffer; + + r = buffer.Construct(size); + if (!IsFailed(r)) //Ignore the error codes to send other metadata to app + { + r = buffer.SetArray((const byte*)(pArtwork.get()), 0, size); + if (!IsFailed(r)) + { + r = img.Construct(); + if (!IsFailed(r)) + { + format = img.GetImageFormat(buffer); + pMetadata->pThumbnail = img.DecodeN(buffer, format, BITMAP_PIXEL_FORMAT_ARGB8888, + THUMBNAIL_IMAGE_WIDTH, THUMBNAIL_IMAGE_HEIGHT); + if (pMetadata->pThumbnail == null) + { + // Because Thumbnail is one of the metadata, it is not exception in this function. + SysLog(NID_CNT, "DecodeN failed."); + } + pMetadata->pAlbumArt = img.DecodeN(buffer, format, BITMAP_PIXEL_FORMAT_ARGB8888); + if (pMetadata->pAlbumArt == null) + { + // Because Album Art is one of the metadata, it is not exception in this function. + SysLog(NID_CNT, "DecodeN failed."); + } + } + } + } + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_artwork failed.", GetErrorMessage(r)); + } + + return pAudioMetadata.release(); +} + +// +// E_SUCCESS +// E_INVALID_ARG +// E_OUT_OF_MEMORY +// +VideoMetadata* +_ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath) +{ + ClearLastResult(); + + SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), null, E_INVALID_ARG, + "[E_INVALID_ARG] %ls is not compatible.", contentPath.GetPointer()); + SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), null, E_INVALID_ARG, + "[E_INVALID_ARG] The file corresponding to contentPath could not be found."); + + // need to create here to make sure that all get APIs will not crash in case of corrupted file + unique_ptr pVideoMetadata(new (nothrow) VideoMetadata()); + SysTryReturn(NID_CNT, pVideoMetadata != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory insufficient."); + + _VideoMetadataImpl* pVideoMetaImpl = _VideoMetadataImpl::GetInstance(*(pVideoMetadata.get())); + SysTryReturn(NID_CNT, pVideoMetaImpl != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] pVideoMetaImpl is null."); + + VideoMeta* pMetadata = pVideoMetaImpl->GetVideoMetadata(); + SysTryReturn(NID_CNT, pMetadata != null, null, E_INVALID_ARG, + "[E_INVALID_ARG] pMetadata is null."); + + pMetadata->contentPath = contentPath; + + // Create the metadata extractor handle + unique_ptr pExtractor(new (nothrow) metadata_extractor_h); + SysTryReturn(NID_CNT, pExtractor != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory insufficient."); + + int retVal = metadata_extractor_create(pExtractor.get()); + result r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r, + "[%s] metadata_extractor_create failed.", GetErrorMessage(r)); + + // Set file path of content to extract the metadata + unique_ptr pFileName(_StringConverter::CopyToCharArrayN(contentPath)); + SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + + retVal = metadata_extractor_set_path(*(pExtractor.get()), pFileName.get()); + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r, + "[%s] metadata_extractor_set_path failed.", GetErrorMessage(r)); + + // Get all relavent video metadata by passing relavent attirbutes + char* __pVideoMeta = null; + unique_ptr pVideoMeta(null); + + // width + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_VIDEO_WIDTH, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->width = atoi(pVideoMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(width) failed.", GetErrorMessage(r)); + } + + // height + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_VIDEO_HEIGHT, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->height = atoi(pVideoMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(height) failed.", GetErrorMessage(r)); + } + + // video bitrate + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_VIDEO_BITRATE, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->videoBitrate = atoi(pVideoMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(video bitrate) failed.", GetErrorMessage(r)); + } + + // audio bitrate + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_AUDIO_BITRATE, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->audioBitrate = atoi(pVideoMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(audio bitrate) failed.", GetErrorMessage(r)); + } + + // framerate + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_VIDEO_FPS, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->framerate = atoi(pVideoMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(framerate) failed.", GetErrorMessage(r)); + } + + // duration + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DURATION, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->duration = atoi(pVideoMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(duration) failed.", GetErrorMessage(r)); + } + + // genre + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_GENRE, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->pGenre = new (nothrow) String(pVideoMeta.get()); //allocate memory + SysTryReturn(NID_CNT, pMetadata->pGenre != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(genre) failed.", GetErrorMessage(r)); + } + + // comment + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_COMMENT, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->pComment = new (nothrow) String(pVideoMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pComment != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(comment) failed.", GetErrorMessage(r)); + } + + // description + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DESCRIPTION, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->pDescription = new (nothrow) String(pVideoMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pDescription != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(description) failed.", GetErrorMessage(r)); + } + + // artwork + int size = 0; + void* __pArtwork = null; + unique_ptr pArtwork(null); + + // Get the artwork image in media file + retVal = metadata_extractor_get_artwork(*(pExtractor.get()), &__pArtwork, &size, &__pVideoMeta); + if (__pArtwork != null) + { + pArtwork.reset(__pArtwork); + + Image img; + ImageFormat format = IMG_FORMAT_NONE; + ByteBuffer buffer; + + r = buffer.Construct(size); + if (!IsFailed(r)) //Ignore the error codes to send other metadata to app + { + r = buffer.SetArray((const byte*)(pArtwork.get()), 0, size); + if (!IsFailed(r)) + { + r = img.Construct(); + if (!IsFailed(r)) + { + format = img.GetImageFormat(buffer); + + pMetadata->pAlbumArt = img.DecodeN(buffer, format, BITMAP_PIXEL_FORMAT_ARGB8888); + if (pMetadata->pAlbumArt == null) + { + // Because Album Art is one of the metadata, it is not exception in this function. + SysLog(NID_CNT, "DecodeN failed."); + } + } + } + } + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_artwork failed.", GetErrorMessage(r)); + } + + return pVideoMetadata.release(); +} + +ImageMetadata* +_ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer) +{ + ClearLastResult(); + + int bufferLen = byteBuffer.GetRemaining(); + SysTryReturn(NID_CNT, bufferLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The length of buffer is less than zero."); + + // create object here as it needs to be passed to client in any case to make sure Get APIs do not crash + unique_ptr pImageMetadata(new (nothrow) ImageMetadata()); + SysTryReturn(NID_CNT, pImageMetadata != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] pImageMetadata is null."); + + _ImageMetadataImpl* pImageMetaImpl = _ImageMetadataImpl::GetInstance(*(pImageMetadata.get())); + SysTryReturn(NID_CNT, pImageMetaImpl != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] pImageMetaImpl is null."); + + ImageMeta* pMetadata = pImageMetaImpl->GetImageMetadata(); + SysTryReturn(NID_CNT, pMetadata != null, null, E_INVALID_ARG, + "[E_INVALID_ARG] pMetadata is null."); + + //assign by default here and overwrite below if width and height presents in EXIF data. + ImageFormat imgType = IMG_FORMAT_NONE; + int imageWidth = 0; + int imageHeight = 0; + + result r = ImageBuffer::GetImageInfo(byteBuffer, imgType, imageWidth, imageHeight); + SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_INVALID_ARG, + "[E_INVALID_ARG] GetImageInfo failed."); + + pMetadata->width = imageWidth; + pMetadata->height = imageHeight; + + if (imgType == IMG_FORMAT_JPG) + { + const byte* pByte = byteBuffer.GetPointer(); + + unique_ptr pExifdata(exif_data_new_from_data(pByte, bufferLen)); + if (pExifdata != null) + { + ExifTag tag; + ExifByteOrder byteOrder; + ExifEntry** pEntries = null; + const char* pData = null; + char buf[IMAGE_BUFF_LENGTH] = {0, }; + char mmBuff[IMAGE_BUFF_LENGTH] = {0, }; // to store minutes value of GPS data + char ssBuff[IMAGE_BUFF_LENGTH] = {0, }; // to store seconds value of GPS data + ExifContent* pExifcont[EXIF_IFD_COUNT]; + int index = 0; + char latitudeRef = 0; // to store latitude reference (quadrasphere designation 'N', 'S', 'W' or 'E') + char longitudeRef = 0; // to store longitude reference (quadrasphere designation 'N', 'S', 'W' or 'E') + unsigned int entryCount = 0; + + for (int i = 0; i < EXIF_IFD_COUNT; i++) + { + pExifcont[i] = pExifdata->ifd[i]; + entryCount = pExifcont[i]->count; + pEntries = pExifcont[i]->entries; + for (unsigned int j = 0; j < entryCount; j++) + { + tag = pEntries[j]->tag; + pData = exif_entry_get_value(pEntries[j], buf, sizeof(buf)); + SysTryReturn(NID_CNT, pData != null, pImageMetadata.release(), E_INVALID_ARG, + "[E_INVALID_ARG] exif_entry_get_value failed."); + + if (tag == EXIF_TAG_PIXEL_X_DIMENSION) + { + pMetadata->width = atoi(buf); + } + else if (tag == EXIF_TAG_PIXEL_Y_DIMENSION) + { + pMetadata->height = atoi(buf); + } + else if (tag == EXIF_TAG_MAKE) + { + pMetadata->pManufacturer = new (nothrow) String(buf); + SysTryReturn(NID_CNT, pMetadata->pManufacturer != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else if (tag == EXIF_TAG_MODEL) + { + pMetadata->pModel = new (nothrow) String(buf); + SysTryReturn(NID_CNT, pMetadata->pModel != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else if (tag == EXIF_TAG_DATE_TIME) + { + pMetadata->pDateTime = new (nothrow) String(buf); + SysTryReturn(NID_CNT, pMetadata->pDateTime != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else if (tag == EXIF_TAG_ORIENTATION) + { + //get the byte order(little endian or big endian) before extracting orientation type + byteOrder = exif_data_get_byte_order(pEntries[j]->parent->parent); + pMetadata->orientation = static_cast(exif_get_short(pEntries[j]->data, byteOrder)); + } + else if (tag == EXIF_TAG_SOFTWARE) + { + pMetadata->pSoftware = new (nothrow) String(buf); + SysTryReturn(NID_CNT, pMetadata->pSoftware != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else if (tag == EXIF_TAG_GPS_LATITUDE_REF) + { + latitudeRef = buf[0]; // GPS Latitude reference value will be 'N'(NORTH) or 'S'(SOUTH) + } + else if (tag == EXIF_TAG_GPS_LATITUDE) + { + ParseBuffer(buf, index); // to extract the minutes value of GPS data, if present + for (int l = 0; l < IMAGE_BUFF_LENGTH-1; l++) + { + mmBuff[l] = buf[l + index + 1]; //add 1 to skip the ',' + } + index = 0; //re-assign index value as this is new buffer + ParseBuffer(mmBuff, index); // to extract the seconds value of GPS data, if present + for (int l = 0; l < IMAGE_BUFF_LENGTH-1; l++) + { + ssBuff[l] = mmBuff[l + index + 1]; //add 1 to skip the ',' + } + double ddVal = atof(buf); // degree value + double mmVal = atof(mmBuff); // minutesvalue + double ssVal = atof(ssBuff); // seconds value + pMetadata->latitude = ddVal + (mmVal/MINUTES) + (ssVal/SECONDS); + + // if latitude designation is Southern (SOUTH) then latitude degree will be negative DD + if (latitudeRef == 'S') + { + pMetadata->latitude = (pMetadata->latitude * (double)(-1)); + } + } + else if (tag == EXIF_TAG_GPS_LONGITUDE_REF) + { + longitudeRef = buf[0]; // GPS Longitude reference value will be 'W'(WEST) or 'E'(EAST) + } + else if (tag == EXIF_TAG_GPS_LONGITUDE) + { + index = 0; //re-assign index value as this is new buffer + ParseBuffer(buf, index); // to extract the minutes value of GPS data, if present + for (int l = 0; l < IMAGE_BUFF_LENGTH-1; l++) + { + mmBuff[l] = buf[l + index + 1]; //add 1 to skip the ',' + } + index = 0; //re-assign index value as this is new buffer + ParseBuffer(mmBuff, index); // to extract the seconds value of GPS data, if present + for (int l = 0; l < IMAGE_BUFF_LENGTH-1; l++) + { + ssBuff[l] = mmBuff[l + index + 1]; //add 1 to skip the ',' + } + double ddVal = atof(buf); // degree value + double mmVal = atof(mmBuff); // minutesvalue + double ssVal = atof(ssBuff); // seconds value + pMetadata->longitude = ddVal + (mmVal/MINUTES) + (ssVal/SECONDS); + + // if longitude designation is Western (WEST) then longitude degree will be negative DD + if (longitudeRef == 'W') + { + pMetadata->longitude = (pMetadata->longitude * (double)(-1)); + } + } + else if (tag == EXIF_TAG_WHITE_BALANCE) + { + pMetadata->pWhiteBalance = new (nothrow) String(buf); + SysTryReturn(NID_CNT, pMetadata->pWhiteBalance != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + } + } + } + } + + return pImageMetadata.release(); +} + +// +// E_SUCCESS +// E_INVALID_ARG +// E_OUT_OF_MEMORY +// +AudioMetadata* +_ContentManagerUtilImpl::GetAudioMetaN(const ByteBuffer& byteBuffer) +{ + ClearLastResult(); + + int bufferLen = byteBuffer.GetRemaining(); + SysTryReturn(NID_CNT, bufferLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The length of buffer is less than zero."); + + // create here to make sure that get apis will not crash though the below API calls fails in case of invalid file. + unique_ptr pAudioMetadata(new (nothrow) AudioMetadata()); + SysTryReturn(NID_CNT, pAudioMetadata != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _AudioMetadataImpl* pAudioMetaImpl = _AudioMetadataImpl::GetInstance(*(pAudioMetadata.get())); + SysTryReturn(NID_CNT, pAudioMetaImpl != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] pAudioMetaImpl is null."); + + AudioMeta* pMetadata = pAudioMetaImpl->GetAudioMetadata(); + SysTryReturn(NID_CNT, pMetadata != null, null, E_INVALID_ARG, + "[E_INVALID_ARG] pMetadata is null."); + + // Create the metadata extractor handle + unique_ptr pExtractor(new (nothrow) metadata_extractor_h); + SysTryReturn(NID_CNT, pExtractor != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + + int retVal = metadata_extractor_create(pExtractor.get()); + result r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r, + "[%s] metadata_extractor_create failed.", GetErrorMessage(r)); + + const byte* pByte = byteBuffer.GetPointer(); + + retVal = metadata_extractor_set_buffer(*(pExtractor.get()), pByte, bufferLen); + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r, + "[%s] metadata_extractor_set_path failed.", GetErrorMessage(r)); + + // Get all relavent audio metadata by passing relavent attirbutes + char* __pAudioMeta = null; + unique_ptr pAudioMeta(null); + + // bitrate + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_AUDIO_BITRATE, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->bitrate = atoi(pAudioMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(bitrate) failed.", GetErrorMessage(r)); + } + + // channelcount + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_AUDIO_CHANNELS, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->channelCount = atoi(pAudioMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(channels) failed.", GetErrorMessage(r)); + } + + // duration + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DURATION, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->duration = atoi(pAudioMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(duration) failed.", GetErrorMessage(r)); + } + + // frequency + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_AUDIO_SAMPLERATE, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->frequency = atoi(pAudioMeta.get()); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(frequency) failed.", GetErrorMessage(r)); + } + + // albumname + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_ALBUM, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->pAlbumName = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pAlbumName != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(album name) failed.", GetErrorMessage(r)); + } + + // artist + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_ARTIST, &__pAudioMeta); + if (pAudioMeta.get() != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->pArtist = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pArtist != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(artist) failed.", GetErrorMessage(r)); + } + + // copyright + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_COPYRIGHT, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->pCopyright = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pCopyright != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(copyright) failed.", GetErrorMessage(r)); + } + + // genre + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_GENRE, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->pGenre = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pGenre != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(genre) failed.", GetErrorMessage(r)); + } + + // title + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_TITLE, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->pTitle = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pTitle != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(title) failed.", GetErrorMessage(r)); + } + + // comment + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_COMMENT, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); pMetadata->pComment = new (nothrow) String(pAudioMeta.get()); SysTryReturn(NID_CNT, pMetadata->pComment != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); @@ -469,6 +1203,22 @@ _ContentManagerUtilImpl::GetAudioMetaN(const String& contentPath) { r = ErrorMapToRetVal(retVal); SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(comment) failed.", GetErrorMessage(r)); + } + + // description + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DESCRIPTION, &__pAudioMeta); + if (__pAudioMeta != null) + { + pAudioMeta.reset(__pAudioMeta); + pMetadata->pDescription = new (nothrow) String(pAudioMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pDescription != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r, "[%s] metadata_extractor_get_metadata(description) failed.", GetErrorMessage(r)); } @@ -600,14 +1350,12 @@ _ContentManagerUtilImpl::GetAudioMetaN(const String& contentPath) // E_OUT_OF_MEMORY // VideoMetadata* -_ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath) +_ContentManagerUtilImpl::GetVideoMetaN(const ByteBuffer& byteBuffer) { ClearLastResult(); - SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), null, E_INVALID_ARG, - "[E_INVALID_ARG] %ls is not compatible.", contentPath.GetPointer()); - SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), null, E_INVALID_ARG, - "[E_INVALID_ARG] The file corresponding to contentPath could not be found."); + int bufferLen = byteBuffer.GetRemaining(); + SysTryReturn(NID_CNT, bufferLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The length of buffer is less than zero."); // need to create here to make sure that all get APIs will not crash in case of corrupted file unique_ptr pVideoMetadata(new (nothrow) VideoMetadata()); @@ -622,8 +1370,6 @@ _ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath) SysTryReturn(NID_CNT, pMetadata != null, null, E_INVALID_ARG, "[E_INVALID_ARG] pMetadata is null."); - pMetadata->contentPath = contentPath; - // Create the metadata extractor handle unique_ptr pExtractor(new (nothrow) metadata_extractor_h); SysTryReturn(NID_CNT, pExtractor != null, null, E_OUT_OF_MEMORY, @@ -634,12 +1380,9 @@ _ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath) SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r, "[%s] metadata_extractor_create failed.", GetErrorMessage(r)); - // Set file path of content to extract the metadata - unique_ptr pFileName(_StringConverter::CopyToCharArrayN(contentPath)); - SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY, - "[E_OUT_OF_MEMORY] The memory is insufficient."); + const byte* pByte = byteBuffer.GetPointer(); - retVal = metadata_extractor_set_path(*(pExtractor.get()), pFileName.get()); + retVal = metadata_extractor_set_buffer(*(pExtractor.get()), pByte, bufferLen); r = ErrorMapToRetVal(retVal); SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r, "[%s] metadata_extractor_set_path failed.", GetErrorMessage(r)); @@ -748,6 +1491,38 @@ _ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath) "[%s] metadata_extractor_get_metadata(genre) failed.", GetErrorMessage(r)); } + // comment + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_COMMENT, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->pComment = new (nothrow) String(pVideoMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pComment != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(comment) failed.", GetErrorMessage(r)); + } + + // description + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DESCRIPTION, &__pVideoMeta); + if (__pVideoMeta != null) + { + pVideoMeta.reset(__pVideoMeta); + pMetadata->pDescription = new (nothrow) String(pVideoMeta.get()); + SysTryReturn(NID_CNT, pMetadata->pDescription != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r, + "[%s] metadata_extractor_get_metadata(description) failed.", GetErrorMessage(r)); + } + // artwork int size = 0; void* __pArtwork = null; @@ -817,190 +1592,144 @@ _ContentManagerUtilImpl::CheckContentType(const String& contentPath, bool intern "[E_INVALID_ARG] The length of contentPath is 0."); SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), contentType, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] The file corresponding to contentPath could not be found."); - String fileExt = _FileImpl::GetFileExtension(contentPath); - - // The type of ISMA and ISMV can be changed from other to video. - String format; - fileExt.ToLowerCase(format); - - if (format == L"isma" || format == L"ismv") - { - contentType = GetDrmFileType(format); - result r = GetLastResult(); - SysTryReturn(NID_CNT, !IsFailed(r), contentType, r, "[%s] GetDrmFileType failed.", GetErrorMessage(r)); - - return contentType; - } - int index = 0; + String fileExt = _FileImpl::GetFileExtension(contentPath); + result r = GetLastResult(); + SysTryReturn(NID_CNT, !IsFailed(r), contentType, r, "[%s] GetFileExtension failed.", GetErrorMessage(r)); - result r = String(CONTENT_FORMAT).LastIndexOf(format, String(CONTENT_FORMAT).GetLength() - 1, index); - if (IsFailed(r)) - { - if (r == E_OBJ_NOT_FOUND) - { - SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT, - "[E_UNSUPPORTED_FORMAT] The file format is not supported[%ls].", format.GetPointer()); - } - else - { - SysLogException(NID_CNT, E_INVALID_ARG, - "[E_INVALID_ARG] The contentPath is invalid[%ls].", contentPath.GetPointer()); - } - return contentType; - } + unique_ptr pFormat(_StringConverter::CopyToCharArrayN(fileExt)); + SysTryReturn(NID_CNT, pFormat != null, contentType, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); - String subStr; - int length = fileExt.GetLength(); + char* __pMimeType = null; + int retVal = mime_type_get_mime_type(pFormat.get(), &__pMimeType); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, E_INVALID_ARG, + "[E_INVALID_ARG] mime_type_get_mime_type failed."); + SysTryReturn(NID_CNT, __pMimeType != null, contentType, E_INVALID_ARG, + "[E_INVALID_ARG] mime_type_get_mime_type failed."); - r = String(CONTENT_FORMAT).SubString(index+length, 1, subStr); - SysTryReturn(NID_CNT, !(IsFailed(r)), contentType, E_INVALID_ARG, "[E_INVALID_ARG] SubString failed."); + unique_ptr pMimeType; + pMimeType.reset(__pMimeType); - SysLog(NID_CNT, "index = %d, length = %d, subStr = %ls", index, length, subStr.GetPointer()); + SysLog(NID_CNT, "The MIME type for %ls is %s", fileExt.GetPointer(), __pMimeType); - const String image(L"1"); - const String audio(L"2"); - const String video(L"3"); - const String other(L"0"); - const String audioOrVideo(L"5"); + String mimeType(pMimeType.get()); - if (subStr.CompareTo(image) == 0) + if (mimeType.Contains(L"image")) { return CONTENT_TYPE_IMAGE; } - else if (subStr.CompareTo(audio) == 0) + else if (mimeType.Contains(L"audio")) { + if (mimeType.Contains(L"x-mpegurl")) + { + SysLog(NID_CNT, "The type of x-mpegurl is other."); + return CONTENT_TYPE_OTHER; + } return CONTENT_TYPE_AUDIO; } - else if (subStr.CompareTo(video) == 0) + else if (mimeType.Contains(L"video")) { + String format; + fileExt.ToLowerCase(format); + + if (format == L"3gp" || format == L"mp4") + { + return CheckStream(contentPath); + } return CONTENT_TYPE_VIDEO; } - else if (subStr.CompareTo(other) == 0) + else if (mimeType.Contains(L"application")) { + if (mimeType.Contains(L"x-smaf")) + { + SysLog(NID_CNT, "The type of x-smaf is audio."); + return CONTENT_TYPE_AUDIO; + } return CONTENT_TYPE_OTHER; } - else if (subStr.CompareTo(audioOrVideo) == 0) - { - //Create metadata extractor handle - unique_ptr pExtractor(new (nothrow) metadata_extractor_h); - SysTryReturn(NID_CNT, pExtractor != null, contentType, E_OUT_OF_MEMORY, - "[E_OUT_OF_MEMORY] The memory is insufficient."); - int retVal = metadata_extractor_create(pExtractor.get()); - result r = ErrorMapToRetVal(retVal); - SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r, - "[%s] metadata_extractor_create failed.", GetErrorMessage(r)); + return CONTENT_TYPE_OTHER; +} - //Set file path of content to extract metadata. - unique_ptr pContentPath(_StringConverter::CopyToCharArrayN(contentPath)); - SysTryReturn(NID_CNT, pContentPath != null, contentType, E_INVALID_ARG, - "[E_INVALID_ARG] The memory is insufficient."); +ContentType +_ContentManagerUtilImpl::CheckStream(const String& contentPath) +{ + ClearLastResult(); - retVal = metadata_extractor_set_path(*(pExtractor.get()), pContentPath.get()); - r = ErrorMapToRetVal(retVal); - SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE && pExtractor, contentType, r, - "[%s] metadata_extractor_set_path failed.", GetErrorMessage(r)); + ContentType contentType = CONTENT_TYPE_UNKNOWN; - //Get the metadata info, to check whether audio or video present in the file - char* __pAudio = null; - unique_ptr pAudio(null); + unique_ptr pExtractor(new (nothrow) metadata_extractor_h); + SysTryReturn(NID_CNT, pExtractor != null, contentType, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); - char* __pVideo = null; - unique_ptr pVideo(null); + int retVal = metadata_extractor_create(pExtractor.get()); + result r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r, + "[%s] metadata_extractor_create failed.", GetErrorMessage(r)); - retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_HAS_AUDIO, &__pAudio); - if (__pAudio != null) - { - pAudio.reset(__pAudio); - } - else - { - r = ErrorMapToRetVal(retVal); - SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r, - "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r)); - } + //Set the file path to extract metadata. + unique_ptr pContentPath(_StringConverter::CopyToCharArrayN(contentPath)); + SysTryReturn(NID_CNT, pContentPath != null, contentType, E_INVALID_ARG, + "[E_INVALID_ARG] The memory is insufficient."); - retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_HAS_VIDEO, &__pVideo); - if (__pVideo != null) - { - pVideo.reset(__pVideo); - } - else - { - r = ErrorMapToRetVal(retVal); - SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r, - "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r)); - } + retVal = metadata_extractor_set_path(*(pExtractor.get()), pContentPath.get()); + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE && pExtractor, contentType, r, + "[%s] metadata_extractor_set_path failed.", GetErrorMessage(r)); - if (*(pAudio.get()) > 0 && *(pVideo.get()) == 0) - { - contentType = CONTENT_TYPE_AUDIO; - } - else if (*(pAudio.get()) == 0 && *(pVideo.get()) > 0) - { - contentType = CONTENT_TYPE_VIDEO; - } - else if (*(pAudio.get()) > 0 && *(pVideo.get()) > 0) - { - contentType = CONTENT_TYPE_VIDEO; - } - else - { - SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] The stream is empty."); - } + //Check whether it is an audio or video file. + char* __pAudio = null; + unique_ptr pAudio(null); + + char* __pVideo = null; + unique_ptr pVideo(null); + + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_HAS_AUDIO, &__pAudio); + if (__pAudio != null) + { + pAudio.reset(__pAudio); } else { - // The file extension is invalid(.jp, .bm, .m). - SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT, - "[E_UNSUPPORTED_FORMAT] The file extension is invalid[%ls].", subStr.GetPointer()); + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r, + "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r)); } - return contentType; -} - -ContentType -_ContentManagerUtilImpl::GetDrmFileType(const String& fileExt) -{ - ClearLastResult(); - - unique_ptr pFormat(_StringConverter::CopyToCharArrayN(fileExt)); - SysTryReturn(NID_CNT, pFormat != null, CONTENT_TYPE_UNKNOWN, E_OUT_OF_MEMORY, - "The memory is insufficient."); - - char* __pMimeType = null; - int retVal = mime_type_get_mime_type(pFormat.get(), &__pMimeType); - SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, CONTENT_TYPE_UNKNOWN, E_INVALID_ARG, - "mime_type_get_mime_type failed."); - SysTryReturn(NID_CNT, __pMimeType != null, CONTENT_TYPE_UNKNOWN, E_INVALID_ARG, - "mime_type_get_mime_type failed."); - - unique_ptr pMimeType; - pMimeType.reset(__pMimeType); - - SysLog(NID_CNT, "The MIME type for %ls is %s", fileExt.GetPointer(), __pMimeType); - - String mimeType(pMimeType.get()); + retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_HAS_VIDEO, &__pVideo); + if (__pVideo != null) + { + pVideo.reset(__pVideo); + } + else + { + r = ErrorMapToRetVal(retVal); + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r, + "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r)); + } - if (mimeType == L"audio/mp4") + if (*(pAudio.get()) > 0 && *(pVideo.get()) == 0) { + SysLog(NID_CNT, "The result of CheckStream() is audio"); return CONTENT_TYPE_AUDIO; } - else if (mimeType == L"video/mp4") + else if (*(pAudio.get()) == 0 && *(pVideo.get()) > 0) { + SysLog(NID_CNT, "The result of CheckStream() is video"); return CONTENT_TYPE_VIDEO; } - else if (mimeType == L"application/octet-stream") + else if (*(pAudio.get()) > 0 && *(pVideo.get()) > 0) { - return CONTENT_TYPE_OTHER; + SysLog(NID_CNT, "The result of CheckStream() is video"); + return CONTENT_TYPE_VIDEO; } else { - SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT, "The MIME type is invalid."); + SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] The stream is empty."); } - return CONTENT_TYPE_UNKNOWN; + return contentType; } bool diff --git a/src/FCnt_ContentSearchImpl.cpp b/src/FCnt_ContentSearchImpl.cpp index 3ef0155..2aff5cf 100644 --- a/src/FCnt_ContentSearchImpl.cpp +++ b/src/FCnt_ContentSearchImpl.cpp @@ -21,8 +21,6 @@ * This file contains implementation of the %_ContentSearchImpl class. */ -// includes - #include #include #include @@ -36,7 +34,6 @@ #include #include -// using namespace using namespace Tizen::Base; using namespace Tizen::Base::Collection; using namespace Tizen::Base::Utility; diff --git a/src/FCnt_ContentUtility.cpp b/src/FCnt_ContentUtility.cpp index 454704f..dae36d6 100644 --- a/src/FCnt_ContentUtility.cpp +++ b/src/FCnt_ContentUtility.cpp @@ -21,8 +21,6 @@ * This file contains implementation of the %_ContentUtility class. */ -// includes - #include #include #include @@ -30,7 +28,6 @@ #include #include -// using namespace using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -94,6 +91,7 @@ _ContentUtility::FillContentData(media_info_h mediaHandle, ContentInfo::_Content std::unique_ptr pProvider; std::unique_ptr pKeyword; std::unique_ptr pContentRating; + std::unique_ptr pMimeType; media_content_type_e mediaType; media_content_storage_e storageType; @@ -227,6 +225,16 @@ _ContentUtility::FillContentData(media_info_h mediaHandle, ContentInfo::_Content ret = media_info_get_media_type(mediaHandle, &mediaType); SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_media_type operation."); + ret = media_info_get_mime_type(mediaHandle, &pGetMediaValue); + if (pGetMediaValue != null) + { + pMimeType.reset(pGetMediaValue); + } + else + { + SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_mime_type operation."); + } + ret = media_info_get_keyword(mediaHandle, &pGetMediaValue); if (pGetMediaValue != null) { @@ -328,6 +336,12 @@ _ContentUtility::FillContentData(media_info_h mediaHandle, ContentInfo::_Content SysLog(NID_CNT, "pContentData->pKeyword = %ls", pContentData->pKeyword->GetPointer()); } + if (pMimeType.get() != NULL) + { + pContentData->mimeType = String(pMimeType.get()); + SysLog(NID_CNT, "pContentData->mimeType = %ls", (pContentData->mimeType).GetPointer()); + } + switch (storageType) { case MEDIA_CONTENT_STORAGE_INTERNAL: diff --git a/src/FCnt_DownloadManagerImpl.cpp b/src/FCnt_DownloadManagerImpl.cpp index 4e9ade1..072fc6f 100644 --- a/src/FCnt_DownloadManagerImpl.cpp +++ b/src/FCnt_DownloadManagerImpl.cpp @@ -31,17 +31,21 @@ #include #include +#include +#include #include #include #include #include +#include #include "FCnt_DownloadManagerImpl.h" using namespace std; using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; using namespace Tizen::Base::Collection; namespace Tizen { namespace Content @@ -49,6 +53,73 @@ namespace Tizen { namespace Content _DownloadManagerImpl* _DownloadManagerImpl::__pInstance = null; +class _DownloadEventArg + : public IEventArg +{ +public: + _DownloadEventArg() + : __id(-1) + , __state((download_state_e)DOWNLOAD_STATE_NONE) + , __result(-1) + , __received(-1) + , __total(-1) + { + } + RequestId __id; + download_state_e __state; + String __path; + result __result; + String __errorCode; + unsigned long long __received; + unsigned long long __total; +}; + +class _DownloadEvent + : public Event +{ +protected: + virtual void FireImpl(IEventListener& listener, const IEventArg& arg) + { + IDownloadListener* pListener = dynamic_cast (&listener); + if (pListener != null) + { + const _DownloadEventArg* pArg = dynamic_cast(&arg); + if (pArg != null) + { + switch(pArg->__state) + { + case DOWNLOAD_STATE_NONE: + case DOWNLOAD_STATE_QUEUED: + break; + + case DOWNLOAD_STATE_DOWNLOADING: + pListener->OnDownloadInProgress(pArg->__id, pArg->__received, pArg->__total); + break; + + case DOWNLOAD_STATE_PAUSED: + pListener->OnDownloadPaused(pArg->__id); + break; + + case DOWNLOAD_STATE_COMPLETED: + pListener->OnDownloadCompleted(pArg->__id, pArg->__path); + break; + + case DOWNLOAD_STATE_FAILED: + pListener->OnDownloadFailed(pArg->__id, pArg->__result, pArg->__errorCode); + break; + + case DOWNLOAD_STATE_CANCELED: + pListener->OnDownloadCanceled(pArg->__id); + break; + + default: + break; + } + } + } + } +}; + static void OnStateChanged(int download_id, download_state_e state, void* data) { @@ -58,7 +129,7 @@ OnStateChanged(int download_id, download_state_e state, void* data) _DownloadManagerImpl* pDMImpl = (_DownloadManagerImpl*)data; - if (!data || !pDMImpl->__pListener) + if (!data || !pDMImpl->__pEvent) { return; } @@ -71,47 +142,70 @@ OnStateChanged(int download_id, download_state_e state, void* data) break; case DOWNLOAD_STATE_PAUSED: - pDMImpl->__pListener->OnDownloadPaused(reqId); - break; + { + _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg(); + pEventArg->__id = reqId; + pEventArg->__state = state; + + pDMImpl->__pEvent->Fire(*pEventArg); + break; + } case DOWNLOAD_STATE_COMPLETED: { + _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg(); + pEventArg->__id = reqId; + pEventArg->__state = state; + char* path = null; download_get_downloaded_file_path(download_id, &path); - pDMImpl->__pListener->OnDownloadCompleted(reqId, path); + pEventArg->__path = path; delete[] path; + pDMImpl->__pEvent->Fire(*pEventArg); + // Remove the resource from url_download pDMImpl->DestroyResources(reqId); + break; } case DOWNLOAD_STATE_FAILED: { - result r = E_SUCCESS; - download_error_e error; - int http_status = 0; + _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg(); + pEventArg->__id = reqId; + pEventArg->__state = state; + download_error_e error; download_get_error(download_id, &error); + pEventArg->__result = pDMImpl->ConvertToResult(error); + + int http_status = 0; download_get_http_status(download_id, &http_status); - r = pDMImpl->ConvertToResult(error); + pEventArg->__errorCode = Integer::ToString(http_status); - String errorCode; - pDMImpl->__pListener->OnDownloadFailed(reqId, r, http_status); + pDMImpl->__pEvent->Fire(*pEventArg); // Comment out due to resume the failed request //pDMImpl->DestroyResources(reqId); + break; } case DOWNLOAD_STATE_CANCELED: - pDMImpl->__pListener->OnDownloadCanceled(reqId); + { + _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg(); + pEventArg->__id = reqId; + pEventArg->__state = state; + + pDMImpl->__pEvent->Fire(*pEventArg); // Remove the resource from url_download pDMImpl->DestroyResources(reqId); - break; + break; + } default: break; } @@ -125,25 +219,35 @@ OnProgress(int download_id, unsigned long long received, void* data) _DownloadManagerImpl* pDMImpl = (_DownloadManagerImpl*)data; - if (data && pDMImpl->__pListener) + if (data && pDMImpl->__pEvent) { + _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg(); + pEventArg->__id = reqId; + pEventArg->__state = (download_state_e)DOWNLOAD_STATE_DOWNLOADING; + pEventArg->__received = received; + unsigned long long total = 0; download_get_content_size(download_id, &total); + pEventArg->__total = total; SysLog(NID_CNT, "OnProgress, id = %d, received = %lld, total = %lld", download_id, received, total); - pDMImpl->__pListener->OnDownloadInProgress(reqId, received, total); + pDMImpl->__pEvent->Fire(*pEventArg); } } _DownloadManagerImpl::_DownloadManagerImpl(void) - : __pListener(null) + : __pEvent(null) { } _DownloadManagerImpl::~_DownloadManagerImpl(void) { + if (__pEvent) + { + delete __pEvent; + } } result @@ -152,8 +256,9 @@ _DownloadManagerImpl::Construct(void) result r = E_SUCCESS; r = __handleMap.Construct(100, 0); + SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "Failed to initialize a download manager."); - return r; + return E_SUCCESS; } void @@ -208,18 +313,62 @@ _DownloadManagerImpl::Start(const DownloadRequest& request, RequestId& reqId) String url = request.GetUrl(); String dirPath = request.GetDirectoryPath(); String fileName = request.GetFileName(); + NetworkType networkType = (NetworkType)request.GetNetworkType(); SysTryReturnResult(NID_CNT, !url.IsEmpty(), E_INVALID_ARG, "The url of the download request is empty."); // Create a download id ret = download_create(&download_id); - SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available."); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); // Set the url unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); ret = download_set_url(download_id, pUrl.get()); - SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available."); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); + + //Set network type + if (networkType == NETWORK_ALL) + { + ret = download_set_network_type(download_id, (download_network_type_e)DOWNLOAD_NETWORK_ALL); + } + else + { + ret = download_set_network_type(download_id, (download_network_type_e)networkType); + } + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); + + //Set notification + ret = download_set_notification(download_id, request.IsNotificationEnabled()); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); + + //Set notification extra data + std::unique_ptr pMapEnum(const_cast< IMap* >(request.GetNotificationExtraData())->GetMapEnumeratorN()); + while (pMapEnum->MoveNext() == E_SUCCESS) + { + String* pMapKey = dynamic_cast(pMapEnum->GetKey()); + unique_ptr pKey(_StringConverter::CopyToCharArrayN(*pMapKey)); + String* pMapValue = dynamic_cast(pMapEnum->GetValue()); + const char* pValue = _StringConverter::CopyToCharArrayN(*pMapValue); + + ret = download_add_notification_extra_param(download_id, pKey.get(), &pValue, 1); + delete[] pValue; + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); + } + + //Add http headers + IMap* pRequestHeader = _DownloadRequestImpl::GetInstance(&request)->GetRequestHeader(); + std::unique_ptr pMapEnume(const_cast< IMap* >(pRequestHeader)->GetMapEnumeratorN()); + while (pMapEnume->MoveNext() == E_SUCCESS) + { + String* pMapKey = dynamic_cast(pMapEnume->GetKey()); + unique_ptr pKey(_StringConverter::CopyToCharArrayN(*pMapKey)); + String* pMapValue = dynamic_cast(pMapEnume->GetValue()); + unique_ptr pValue(_StringConverter::CopyToCharArrayN(*pMapValue)); + + ret = download_add_http_header_field(download_id, pKey.get(), pValue.get()); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); + } // Check the download path if (!dirPath.IsEmpty()) @@ -234,7 +383,7 @@ _DownloadManagerImpl::Start(const DownloadRequest& request, RequestId& reqId) } ret = download_set_destination(download_id, pStr.get()); - SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available."); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); } // Set the file name @@ -243,7 +392,7 @@ _DownloadManagerImpl::Start(const DownloadRequest& request, RequestId& reqId) unique_ptr pStr(_StringConverter::CopyToCharArrayN(fileName)); ret = download_set_file_name(download_id, pStr.get()); - SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available."); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); } // Set the callback functions @@ -253,7 +402,7 @@ _DownloadManagerImpl::Start(const DownloadRequest& request, RequestId& reqId) // Start the download request ret = download_start(download_id); SysTryCatch(NID_CNT, ret != DOWNLOAD_ERROR_INVALID_PARAMETER, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is not valid"); - SysTryCatch(NID_CNT, ret >= 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The internal system service is not available. error = %d", ret); + SysTryCatch(NID_CNT, ret >= 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The internal system service is not available. %d", ret); // Set a request Id reqId = (long)download_id; @@ -275,22 +424,11 @@ _DownloadManagerImpl::Pause(RequestId reqId) result r = E_SUCCESS; int ret = 0; - DownloadRequest* pRequest = null; State state = STATE_NONE; - // Check the request Id - pRequest = GetDownloadRequestN(reqId); - if(pRequest == null) - { - r = GetLastResult(); - SysPropagate(NID_CNT, r); - return r; - } - - delete pRequest; - // Get the current state state = GetState(reqId); + SysTryReturnResult(NID_CNT, state != STATE_NONE, E_INVALID_ARG, "There is no download request for the request ID."); // Check the pre-state r = CheckPrestate(DOWNLOAD_OPERATION_PAUSE, state); @@ -302,7 +440,7 @@ _DownloadManagerImpl::Pause(RequestId reqId) // Pause the download request ret = download_pause((int)reqId); - SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available."); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); return E_SUCCESS; } @@ -313,22 +451,11 @@ _DownloadManagerImpl::Resume(RequestId reqId) result r = E_SUCCESS; int ret = 0; - - DownloadRequest* pRequest = null; State state = STATE_NONE; - // Check the request Id - pRequest = GetDownloadRequestN(reqId); - if(pRequest == null) - { - r = GetLastResult(); - SysPropagate(NID_CNT, r); - return r; - } - delete pRequest; - // Get the current state state = GetState(reqId); + SysTryReturnResult(NID_CNT, state != STATE_NONE, E_INVALID_ARG, "There is no download request for the request ID."); // Check the pre-state r = CheckPrestate(DOWNLOAD_OPERATION_RESUME, state); @@ -340,7 +467,7 @@ _DownloadManagerImpl::Resume(RequestId reqId) // Resume the download request ret = download_start((int)reqId); - SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available."); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); return E_SUCCESS; } @@ -349,23 +476,15 @@ result _DownloadManagerImpl::Cancel(RequestId reqId) { int ret = 0; + State state = STATE_NONE; - DownloadRequest* pRequest = null; - - // Check the request Id - pRequest = GetDownloadRequestN(reqId); - if(pRequest == null) - { - result r = GetLastResult(); - SysPropagate(NID_CNT, r); - return r; - } - - delete pRequest; + // Get the current state + state = GetState(reqId); + SysTryReturnResult(NID_CNT, state != STATE_NONE, E_INVALID_ARG, "There is no download request for the request ID."); // Stop the download request ret = download_cancel((int)reqId); - SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available."); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); return E_SUCCESS; } @@ -377,7 +496,7 @@ _DownloadManagerImpl::GetDownloadRequestN(RequestId reqId) DownloadRequest* pRequest = null; r = __handleMap.GetValue(reqId, pRequest); - SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] There is no download request for the request ID"); + SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] There is no download request for the request ID."); pRequest = new (std::nothrow) DownloadRequest(*pRequest); SysTryReturn(NID_CNT, pRequest != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); @@ -408,7 +527,7 @@ _DownloadManagerImpl::GetMimeType(RequestId reqId, String& mimeType) ret = download_get_mime_type((int)reqId, &pStr); SysTryReturnResult(NID_CNT, ret != DOWNLOAD_ERROR_INVALID_STATE, E_INVALID_OPERATION, "The current download state is not downloading or paused."); - SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available."); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); mimeType = pStr; delete[] pStr; @@ -421,11 +540,12 @@ _DownloadManagerImpl::GetState(RequestId reqId) const { int ret = 0; - download_state_e download_state = DOWNLOAD_STATE_NONE; + download_state_e download_state = (download_state_e)DOWNLOAD_STATE_NONE; State state = STATE_NONE; ret = download_get_state((int)reqId, &download_state); - SysTryReturn(NID_CNT, ret >= 0, STATE_NONE, E_SYSTEM, "[E_SYSTEM] The internal system service is not available."); + SysTryReturn(NID_CNT, ret != DOWNLOAD_ERROR_ID_NOT_FOUND, STATE_NONE, E_INVALID_ARG, "[E_INVALID_ARG] The request ID is not valid."); + SysTryReturn(NID_CNT, ret >= 0, STATE_NONE, E_SYSTEM, "[E_SYSTEM] The internal system service is not available. %d", ret); switch(download_state) { @@ -433,9 +553,9 @@ _DownloadManagerImpl::GetState(RequestId reqId) const state = STATE_NONE; break; - case DOWNLOAD_STATE_READY: - state = STATE_QUEUED; - break; + //case DOWNLOAD_STATE_READY: + // state = STATE_QUEUED; + // break; case DOWNLOAD_STATE_QUEUED: state = STATE_QUEUED; @@ -462,7 +582,8 @@ _DownloadManagerImpl::GetState(RequestId reqId) const break; default: - state = STATE_NONE; + //state = STATE_NONE; + state = STATE_QUEUED; break; } @@ -486,7 +607,24 @@ _DownloadManagerImpl::SetAllowedNetwork(unsigned long flags) void _DownloadManagerImpl::SetDownloadListener(IDownloadListener* pListener) { - __pListener = pListener; + if (pListener != null) + { + _DownloadEvent* pEvent = new (std::nothrow) _DownloadEvent(); + SysTryReturnVoidResult(NID_IO, pEvent != null, E_OUT_OF_MEMORY, "The memory is insufficient."); + + pEvent->AddListener(*pListener); + + __pEvent = pEvent; + } + else + { + if (__pEvent != null) + { + delete __pEvent; + } + + __pEvent = null; + } } result @@ -503,15 +641,12 @@ _DownloadManagerImpl::CheckPrestate(DownloadOperation operation, State current) break; case DOWNLOAD_OPERATION_RESUME: - // Check the pre-state: paused + // Check the pre-state: paused / failed SysTryReturnResult(NID_CNT, !(current != STATE_PAUSED && current != STATE_FAILED), E_INVALID_OPERATION, "The current download state is not STATE_PAUSED or STATE_FAILED."); break; case DOWNLOAD_OPERATION_CANCEL: - // Check the pre-state: downloading - //SysTryReturnResult(NID_CNT, current == STATE_DOWNLOADING, E_INVALID_OPERATION, - //"The current download state prohibits the execution of this operation."); break; default: @@ -602,6 +737,10 @@ _DownloadManagerImpl::ConvertToResult(int error) r = E_INVALID_URL; break; + case DOWNLOAD_ERROR_ID_NOT_FOUND: + r = E_INVALID_ARG; + break; + case DOWNLOAD_ERROR_CONNECTION_FAILED: case DOWNLOAD_ERROR_NETWORK_UNREACHABLE: r = E_CONNECTION_FAILED; diff --git a/src/FCnt_DownloadRequestImpl.cpp b/src/FCnt_DownloadRequestImpl.cpp index 0152376..663f7d6 100644 --- a/src/FCnt_DownloadRequestImpl.cpp +++ b/src/FCnt_DownloadRequestImpl.cpp @@ -21,36 +21,57 @@ * */ +#include #include +#include +#include #include "FCnt_DownloadRequestImpl.h" using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace std; namespace Tizen { namespace Content { _DownloadRequestImpl::_DownloadRequestImpl(void) + : __notification(true) + , __networkType(DOWNLOAD_NETWORK_ALL) { + __notifyExtraData.Construct(); + __requestHeader.Construct(); } _DownloadRequestImpl::_DownloadRequestImpl(const String& url) : __url(url) + , __notification(true) + , __networkType(DOWNLOAD_NETWORK_ALL) { + __notifyExtraData.Construct(); + __requestHeader.Construct(); } _DownloadRequestImpl::_DownloadRequestImpl(const String& url, const String& dirPath) : __url(url) , __dirPath(dirPath) + , __notification(true) + , __networkType(DOWNLOAD_NETWORK_ALL) { + __notifyExtraData.Construct(); + __requestHeader.Construct(); } _DownloadRequestImpl::_DownloadRequestImpl(const _DownloadRequestImpl& rhs) : __url(rhs.__url) , __dirPath(rhs.__dirPath) , __fileName(rhs.__fileName) + , __notification(rhs.__notification) + , __networkType(rhs.__networkType) { + __notifyExtraData.Construct(rhs.__notifyExtraData); + __requestHeader.Construct(rhs.__requestHeader); } _DownloadRequestImpl::~_DownloadRequestImpl(void) @@ -64,6 +85,12 @@ _DownloadRequestImpl::operator =(const _DownloadRequestImpl& rhs) __url = rhs.__url; __dirPath = rhs.__dirPath; __fileName = rhs.__fileName; + __notification = rhs.__notification; + __networkType = rhs.__networkType; + __notifyExtraData.RemoveAll(); + __notifyExtraData.Construct(rhs.__notifyExtraData); + __requestHeader.RemoveAll(); + __requestHeader.Construct(rhs.__requestHeader); return *this; } @@ -140,4 +167,114 @@ _DownloadRequestImpl::GetFileName(void) const return __fileName; } +void +_DownloadRequestImpl::SetNotification(bool enable) +{ + __notification = enable; +} + +result +_DownloadRequestImpl::SetNotificationExtraData(const IMap* pExtraData) +{ + String* pKey = null; + String* pValue = null; + result r = E_SUCCESS; + + std::unique_ptr pMapEnum(const_cast< IMap* >(pExtraData)->GetMapEnumeratorN()); + while (pMapEnum->MoveNext() == E_SUCCESS) + { + pKey = dynamic_cast< String* >(pMapEnum->GetKey()); + SysTryReturnResult(NID_CNT, pKey != null, E_INVALID_ARG, "The object is not a String class."); + + pValue = dynamic_cast< String* >(pMapEnum->GetValue()); + SysTryReturnResult(NID_CNT, pValue != null, E_INVALID_ARG, "The object is not a String class."); + + r = __notifyExtraData.Add(new String(*pKey), new String(*pValue)); + } + return r; +} + +void +_DownloadRequestImpl::SetNetworkType(DownloadNetworkType type) +{ + __networkType = type; +} + +bool +_DownloadRequestImpl::IsNotificationEnabled(void) const +{ + return __notification; +} + +const IMap* +_DownloadRequestImpl::GetNotificationExtraData(void) const +{ + return &__notifyExtraData; +} + +DownloadNetworkType +_DownloadRequestImpl::GetNetworkType(void) const +{ + return __networkType; +} + +result +_DownloadRequestImpl::AddRequestHeader(const String& field, const String& value) +{ + SysTryReturnResult(NID_CNT, !field.IsEmpty(), E_INVALID_ARG, "The field is empty."); + SysTryReturnResult(NID_CNT, !__requestHeader.ContainsKey(field), E_INVALID_ARG, "The field already exist."); + return __requestHeader.Add(new String(field), new String(value)); +} + +result +_DownloadRequestImpl::SetRequestHeader(const String& field, const String& value) +{ + SysTryReturnResult(NID_CNT, !field.IsEmpty(), E_INVALID_ARG, "The field is empty."); + SysTryReturnResult(NID_CNT, __requestHeader.ContainsKey(field), E_INVALID_ARG, "The field does not exist."); + return __requestHeader.SetValue(field, new String(value)); +} + +result +_DownloadRequestImpl::RemoveRequestHeader(const String& field) +{ + SysTryReturnResult(NID_CNT, !field.IsEmpty(), E_INVALID_ARG, "The field is empty."); + SysTryReturnResult(NID_CNT, __requestHeader.ContainsKey(field), E_INVALID_ARG, "The field does not exist."); + return __requestHeader.Remove(field); +} + +String* +_DownloadRequestImpl::GetRequestHeaderN(const String& field) +{ + String* pValue = null; + String* pKey = null; + IMapEnumerator* pMapEnum = null; + + pMapEnum = __requestHeader.GetMapEnumeratorN(); + while (pMapEnum->MoveNext() == E_SUCCESS) + { + pKey = static_cast< String* > (pMapEnum->GetKey()); + if (*pKey == field) + { + pValue = new String (*(static_cast< String* > (pMapEnum->GetValue()))); + SysTryReturn(NID_CNT, pValue != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); + break; + } + } + + delete pMapEnum; + return pValue; +} + +_DownloadRequestImpl* +_DownloadRequestImpl::GetInstance(const DownloadRequest* pRequest) +{ + return pRequest->__pDownloadRequestImpl; +} + +IMap* +_DownloadRequestImpl::GetRequestHeader(void) +{ + return &__requestHeader; +} + } } // Tizen::Content diff --git a/src/FCnt_ImageMetadataImpl.cpp b/src/FCnt_ImageMetadataImpl.cpp index b80ed52..23f6217 100644 --- a/src/FCnt_ImageMetadataImpl.cpp +++ b/src/FCnt_ImageMetadataImpl.cpp @@ -21,7 +21,6 @@ * This file contains implementation of the %_ImageMetadataImpl class. */ -// includes #include #include #include @@ -30,7 +29,6 @@ #include #include -// using namespaces using namespace std; using namespace Tizen::Base; using namespace Tizen::Io; @@ -391,20 +389,16 @@ _ImageMetadataImpl::Equals(const Tizen::Base::Object& rhs) const int _ImageMetadataImpl::GetHashCode(void) const { - int hash = 0; - - hash += (this->GetCameraManufacturer()).GetHashCode(); - hash += (this->GetCameraModel()).GetHashCode(); - hash += (this->GetDateTime()).GetHashCode(); - hash += Integer::GetHashCode(this->GetHeight()); - hash += Double::GetHashCode(this->GetLatitude()); - hash += Double::GetHashCode(this->GetLongitude()); - hash += Integer::GetHashCode(this->GetOrientation()); - hash += (this->GetSoftware()).GetHashCode(); - hash += (this->GetWhiteBalance()).GetHashCode(); - hash += Integer::GetHashCode(this->GetWidth()); - - return hash; + return (this->GetCameraManufacturer()).GetHashCode() + ^ (this->GetCameraModel()).GetHashCode() + ^ (this->GetDateTime()).GetHashCode() + ^ Integer::GetHashCode(this->GetHeight()) + ^ Double::GetHashCode(this->GetLatitude()) + ^ Double::GetHashCode(this->GetLongitude()) + ^ Integer::GetHashCode(this->GetOrientation()) + ^ (this->GetSoftware()).GetHashCode() + ^ (this->GetWhiteBalance()).GetHashCode() + ^ Integer::GetHashCode(this->GetWidth()); } int diff --git a/src/FCnt_PlayListImpl.cpp b/src/FCnt_PlayListImpl.cpp index 3701429..cde274d 100644 --- a/src/FCnt_PlayListImpl.cpp +++ b/src/FCnt_PlayListImpl.cpp @@ -154,9 +154,13 @@ _PlayListImpl::CreateFilter(const Tizen::Base::String& playListName)const if (!nameExpr.IsEmpty()) { - r = nameExpr.Insert('"', 0); + r = nameExpr.Replace("\'", "''"); + SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Replace operation for nameExpr."); + + r = nameExpr.Insert('\'', 0); SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation for nameExpr."); - r = nameExpr.Insert('"', nameExpr.GetLength()); + + r = nameExpr.Insert('\'', nameExpr.GetLength()); SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation for nameExpr."); r = inputCondition.Append(nameExpr); @@ -545,7 +549,7 @@ _PlayListImpl::RemoveItems(const Tizen::Base::Collection::IList& contentIdList) } result -_PlayListImpl::SetPlalyListName(const Tizen::Base::String& oldName, const Tizen::Base::String& newName) +_PlayListImpl::SetPlayListName(const Tizen::Base::String& oldName, const Tizen::Base::String& newName) { std::unique_ptr pPlayListHandle; media_playlist_h tempHandle = NULL; diff --git a/src/FCnt_PlayListManagerImpl.cpp b/src/FCnt_PlayListManagerImpl.cpp index f40e886..b271c79 100644 --- a/src/FCnt_PlayListManagerImpl.cpp +++ b/src/FCnt_PlayListManagerImpl.cpp @@ -99,9 +99,13 @@ _PlayListManagerImpl::CreateFilter(const Tizen::Base::String& playListName) cons if (!nameExpr.IsEmpty()) { - r = nameExpr.Insert('"', 0); + r = nameExpr.Replace("\'", "''"); + SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Replace operation for nameExpr."); + + r = nameExpr.Insert('\'', 0); SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation for nameExpr."); - r = nameExpr.Insert('"', nameExpr.GetLength()); + + r = nameExpr.Insert('\'', nameExpr.GetLength()); SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation for nameExpr."); r = inputCondition.Append(nameExpr); diff --git a/src/FCnt_VideoMetadataImpl.cpp b/src/FCnt_VideoMetadataImpl.cpp index a20f4b1..536a13e 100644 --- a/src/FCnt_VideoMetadataImpl.cpp +++ b/src/FCnt_VideoMetadataImpl.cpp @@ -21,13 +21,11 @@ * This file contains implementation of the %_VideoMetadataImpl class. */ -// includes #include #include #include #include -// using namespaces using namespace std; using namespace Tizen::Base; using namespace Tizen::Graphics; @@ -87,6 +85,16 @@ _VideoMetadataImpl::SetVideoMetadata(const VideoMeta* pVideoMeta) __pVideoMeta->pGenre = new (nothrow) String(*(pVideoMeta->pGenre)); SysTryReturnResult(NID_CNT, __pVideoMeta->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient."); } + if (pVideoMeta->pComment != null) + { + __pVideoMeta->pComment = new (nothrow) String(*(pVideoMeta->pComment)); + SysTryReturnResult(NID_CNT, __pVideoMeta->pComment != null, E_OUT_OF_MEMORY, "The memory is insufficient."); + } + if (pVideoMeta->pDescription != null) + { + __pVideoMeta->pDescription = new (nothrow) String(*(pVideoMeta->pDescription)); + SysTryReturnResult(NID_CNT, __pVideoMeta->pDescription != null, E_OUT_OF_MEMORY, "The memory is insufficient."); + } if (pVideoMeta->pAlbumArt != null) { __pVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*(pVideoMeta->pAlbumArt)); @@ -120,6 +128,7 @@ _VideoMetadataImpl::_VideoMetadataImpl(const _VideoMetadataImpl& rhs) pNewVideoMeta->duration = (rhs.__pVideoMeta)->duration; pNewVideoMeta->contentPath = (rhs.__pVideoMeta)->contentPath; + // pGenre if ((rhs.__pVideoMeta)->pGenre != null) { pNewVideoMeta->pGenre = new (nothrow) String(*((rhs.__pVideoMeta)->pGenre)); @@ -129,6 +138,26 @@ _VideoMetadataImpl::_VideoMetadataImpl(const _VideoMetadataImpl& rhs) return; } } + // pComment + if ((rhs.__pVideoMeta)->pComment != null) + { + pNewVideoMeta->pComment = new (nothrow) String(*((rhs.__pVideoMeta)->pComment)); + if (pNewVideoMeta->pComment == null) + { + SysLog(NID_CNT, "The memory is insufficient."); + return; + } + } + // pDescription + if ((rhs.__pVideoMeta)->pDescription != null) + { + pNewVideoMeta->pDescription = new (nothrow) String(*((rhs.__pVideoMeta)->pDescription)); + if (pNewVideoMeta->pDescription == null) + { + SysLog(NID_CNT, "The memory is insufficient."); + return; + } + } if ((rhs.__pVideoMeta)->pAlbumArt != null) { pNewVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pVideoMeta)->pAlbumArt)); @@ -211,6 +240,44 @@ _VideoMetadataImpl::operator =(const _VideoMetadataImpl& rhs) __pVideoMeta->pGenre = new String(*((rhs.__pVideoMeta)->pGenre)); } + // pComment + if (__pVideoMeta->pComment != null && (rhs.__pVideoMeta)->pComment != null) + { + // delete previous data + delete __pVideoMeta->pComment; + __pVideoMeta->pComment = null; + + __pVideoMeta->pComment = new (nothrow) String(*((rhs.__pVideoMeta)->pComment)); + } + else if (__pVideoMeta->pComment != null) + { + delete __pVideoMeta->pComment; + __pVideoMeta->pComment = null; + } + else if ((rhs.__pVideoMeta)->pComment != null) + { + __pVideoMeta->pComment = new (nothrow) String(*((rhs.__pVideoMeta)->pComment)); + } + + // pDescription + if (__pVideoMeta->pDescription != null && (rhs.__pVideoMeta)->pDescription != null) + { + // delete previous data + delete __pVideoMeta->pDescription; + __pVideoMeta->pDescription = null; + + __pVideoMeta->pDescription = new (nothrow) String(*((rhs.__pVideoMeta)->pDescription)); + } + else if (__pVideoMeta->pDescription != null) + { + delete __pVideoMeta->pDescription; + __pVideoMeta->pDescription = null; + } + else if ((rhs.__pVideoMeta)->pDescription != null) + { + __pVideoMeta->pDescription = new (nothrow) String(*((rhs.__pVideoMeta)->pDescription)); + } + // pAlbumArt if (__pVideoMeta->pAlbumArt != null && (rhs.__pVideoMeta)->pAlbumArt != null) { @@ -259,6 +326,14 @@ _VideoMetadataImpl::Equals(const Tizen::Base::Object& rhs) const { return false; } + if (!((this->GetComment()).Equals(pRhs->GetComment()))) + { + return false; + } + if (!((this->GetDescription()).Equals(pRhs->GetDescription()))) + { + return false; + } if (this->GetHeight() != pRhs->GetHeight()) { return false; @@ -278,17 +353,15 @@ _VideoMetadataImpl::Equals(const Tizen::Base::Object& rhs) const int _VideoMetadataImpl::GetHashCode(void) const { - int hash = 0; - - hash += Integer::GetHashCode(this->GetAudioBitrate()); - hash += Long::GetHashCode(this->GetDuration()); - hash += Integer::GetHashCode(this->GetFramerate()); - hash += (this->GetGenre()).GetHashCode(); - hash += Integer::GetHashCode(this->GetHeight()); - hash += Integer::GetHashCode(this->GetVideoBitrate()); - hash += Integer::GetHashCode(this->GetWidth()); - - return hash; + return Integer::GetHashCode(this->GetAudioBitrate()) + ^ Long::GetHashCode(this->GetDuration()) + ^ Integer::GetHashCode(this->GetFramerate()) + ^ (this->GetGenre()).GetHashCode() + ^ (this->GetComment()).GetHashCode() + ^ (this->GetDescription()).GetHashCode() + ^ Integer::GetHashCode(this->GetHeight()) + ^ Integer::GetHashCode(this->GetVideoBitrate()) + ^ Integer::GetHashCode(this->GetWidth()); } int @@ -368,6 +441,28 @@ _VideoMetadataImpl::GetGenre(void) const return *(__pVideoMeta->pGenre); } +String +_VideoMetadataImpl::GetComment(void) const +{ + if (__pVideoMeta == null || __pVideoMeta->pComment == null) + { + SysLog(NID_CNT, "__pVideoMeta or __pVideoMeta->pComment is null."); + return String(); + } + return *(__pVideoMeta->pComment); +} + +String +_VideoMetadataImpl::GetDescription(void) const +{ + if (__pVideoMeta == null || __pVideoMeta->pDescription == null) + { + SysLog(NID_CNT, "__pVideoMeta or __pVideoMeta->pDescription is null."); + return String(); + } + return *(__pVideoMeta->pDescription); +} + // // E_SUCCESS // E_DATA_NOT_FOUND diff --git a/src/inc/FCnt_AudioMetadataImpl.h b/src/inc/FCnt_AudioMetadataImpl.h index 25cf2dd..2e05a45 100644 --- a/src/inc/FCnt_AudioMetadataImpl.h +++ b/src/inc/FCnt_AudioMetadataImpl.h @@ -46,6 +46,7 @@ struct AudioMeta , pAlbumName(null) , pArtist(null) , pComment(null) + , pDescription(null) , pComposer(null) , pCopyright(null) , pGenre(null) @@ -65,6 +66,7 @@ struct AudioMeta Tizen::Base::String* pAlbumName; Tizen::Base::String* pArtist; Tizen::Base::String* pComment; + Tizen::Base::String* pDescription; Tizen::Base::String* pComposer; Tizen::Base::String* pCopyright; Tizen::Base::String* pGenre; @@ -96,6 +98,11 @@ struct AudioMetaDeleter delete pAudioMeta->pComment; pAudioMeta->pComment = null; } + if (pAudioMeta->pDescription) + { + delete pAudioMeta->pDescription; + pAudioMeta->pDescription = null; + } if (pAudioMeta->pComposer) { delete pAudioMeta->pComposer; @@ -199,6 +206,11 @@ public: Tizen::Base::String GetComment(void) const; /** + * @see @ref Tizen::Content::AudioMetadata::GetDescription() + */ + Tizen::Base::String GetDescription(void) const; + + /** * @see @ref Tizen::Content::AudioMetadata::GetTrack() */ int GetTrack(void) const; diff --git a/src/inc/FCnt_ContentManagerImpl.h b/src/inc/FCnt_ContentManagerImpl.h index e6dbb28..444cd6a 100644 --- a/src/inc/FCnt_ContentManagerImpl.h +++ b/src/inc/FCnt_ContentManagerImpl.h @@ -32,7 +32,9 @@ namespace Tizen { namespace Content { class ContentManager; -class _IContentScanListener; +class IContentScanListener; +class IContentUpdateEventListener; + typedef struct media_info_s* media_info_h; struct MediaInfoDeleter @@ -73,8 +75,9 @@ struct VideoMetaDeleter struct ScanResult { - void* pData; - char* pContentPath; + char* pScanPath; + IContentScanListener* pScanListener; + RequestId requestId; }; class _ContentManagerImpl @@ -130,15 +133,25 @@ public: */ result DeleteContent(const ContentId& contentId); - /* + /** + * @see @ref Tizen::Content::ContentManager::AddContentUpdateEventListener() + */ + result AddContentUpdateEventListener(IContentUpdateEventListener& listener); + + /** + * @see @ref Tizen::Content::ContentManager::RemoveContentUpdateEventListener() + */ + result RemoveContentUpdateEventListener(IContentUpdateEventListener& listener); + + /** * @see @ref Tizen::Content::ContentManager::ScanFile() */ - result ScanFile(const Tizen::Base::String& contentPath); + static result ScanFile(const Tizen::Base::String& contentPath); - /* + /** * @see @ref Tizen::Content::ContentManager::ScanDirectory() */ - result ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, _IContentScanListener& listener); + static result ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, IContentScanListener* pListener, RequestId& reqId); /** * Gets the Impl instance. @@ -158,23 +171,22 @@ public: */ static const _ContentManagerImpl* GetInstance(const ContentManager& contentManager); - void SetListener(_IContentScanListener* pListener); + void SetListener(IContentUpdateEventListener* pListener); - _IContentScanListener* GetListener(void) const; + IContentUpdateEventListener* GetListener(void) const; private: _ContentManagerImpl(const _ContentManagerImpl& rhs); ContentId SaveDataToDatabase(const media_info_h pMediaInfo, ContentInfo::_ContentData* pContentData) const; result UpdateDataToDatabase(const ContentInfo::_ContentData* pContentData) const; result MakeContentInfo(const media_info_h pMediaInfo, ContentInfo::_ContentData* pContentData, int systemType, void* pMetadata) const; - result ConvertError(int error) const; bool VerifyMediaFilePathCompatibility(const Tizen::Base::String& contentPath, bool checkVersion) const; bool VerifyHomeFilePathCompatibility(const Tizen::Base::String& contentPath) const; _ContentManagerImpl& operator =(const _ContentManagerImpl& rhs); private: bool __isConnected; - _IContentScanListener* __pListener; + IContentUpdateEventListener* __pListener; friend class _ContentDownloadHandler; }; // class _ContentManagerImpl diff --git a/src/inc/FCnt_ContentManagerUtilImpl.h b/src/inc/FCnt_ContentManagerUtilImpl.h index dca9d9a..0062077 100644 --- a/src/inc/FCnt_ContentManagerUtilImpl.h +++ b/src/inc/FCnt_ContentManagerUtilImpl.h @@ -73,22 +73,37 @@ class _ContentManagerUtilImpl { public: /** - * @see @ref Tizen::Content::ContentManagerUtil::GetImageMetaN() + * @see @ref Tizen::Content::ContentManagerUtil::GetImageMetaN(const Tizen::Base::String&) */ static Tizen::Content::ImageMetadata* GetImageMetaN(const Tizen::Base::String& contentPath, bool internal = false); /** - * @see @ref Tizen::Content::ContentManagerUtil::GetAudioMetaN() + * @see @ref Tizen::Content::ContentManagerUtil::GetImageMetaN(const Tizen::Base::ByteBuffer&) + */ + static Tizen::Content::ImageMetadata* GetImageMetaN(const Tizen::Base::ByteBuffer& byteBuffer); + + /** + * @see @ref Tizen::Content::ContentManagerUtil::GetAudioMetaN(const Tizen::Base::String&) */ static Tizen::Content::AudioMetadata* GetAudioMetaN(const Tizen::Base::String& contentPath); /** - * @see @ref Tizen::Content::ContentManagerUtil::GetVideoMetaN() + * @see @ref Tizen::Content::ContentManagerUtil::GetAudioMetaN(const Tizen::Base::ByteBuffer&) + */ + static Tizen::Content::AudioMetadata* GetAudioMetaN(const Tizen::Base::ByteBuffer& byteBuffer); + + /** + * @see @ref Tizen::Content::ContentManagerUtil::GetVideoMetaN(const Tizen::Base::String&) */ static Tizen::Content::VideoMetadata* GetVideoMetaN(const Tizen::Base::String& contentPath); /** - * @see @ref Tizen::Content::ContentManagerUtil::CheckContentType() + * @see @ref Tizen::Content::ContentManagerUtil::GetVideoMetaN(const Tizen::Base::ByteBuffer&) + */ + static Tizen::Content::VideoMetadata* GetVideoMetaN(const Tizen::Base::ByteBuffer& byteBuffer); + + /** + * @see @ref Tizen::Content::ContentManagerUtil::CheckContentType(const Tizen::Base::String&) */ static Tizen::Content::ContentType CheckContentType(const Tizen::Base::String& contentPath, bool internal = false); @@ -110,7 +125,7 @@ private: static bool VerifyFilePathCompatibility(const Tizen::Base::String& contentPath); _ContentManagerUtilImpl& operator =(const _ContentManagerUtilImpl& rhs); static result ErrorMapToRetVal(int retVal); - static ContentType GetDrmFileType(const Tizen::Base::String& fileExt); + static ContentType CheckStream(const Tizen::Base::String& contentPath); }; // class _ContentManagerUtilImpl diff --git a/src/inc/FCnt_DownloadManagerImpl.h b/src/inc/FCnt_DownloadManagerImpl.h index 5ee47cf..94d7b9c 100644 --- a/src/inc/FCnt_DownloadManagerImpl.h +++ b/src/inc/FCnt_DownloadManagerImpl.h @@ -25,6 +25,7 @@ #include #include +#include #include namespace Tizen { namespace Content @@ -47,7 +48,14 @@ public: STATE_PAUSED, STATE_CANCELLED, STATE_COMPLETED, - STATE_FAILED, + STATE_FAILED + }; + + enum NetworkType + { + NETWORK_DATA = 1, + NETWORK_WIFI, + NETWORK_ALL = 100 }; public: @@ -81,6 +89,7 @@ public: public: IDownloadListener* __pListener; + Tizen::Base::Runtime::Event* __pEvent; private: _DownloadManagerImpl(const _DownloadManagerImpl& clientChannel); diff --git a/src/inc/FCnt_DownloadRequestImpl.h b/src/inc/FCnt_DownloadRequestImpl.h index 16d663d..013b05d 100644 --- a/src/inc/FCnt_DownloadRequestImpl.h +++ b/src/inc/FCnt_DownloadRequestImpl.h @@ -20,17 +20,22 @@ * * This header file contains the declarations of the %_DownloadRequestImpl class. */ -#ifndef _FCNT_DOWNLOAD_MANAGER_IMPL_H_ -#define _FCNT_DOWNLOAD_MANAGER_IMPL_H_ +#ifndef _FCNT_DOWNLOAD_REQUEST_IMPL_H_ +#define _FCNT_DOWNLOAD_REQUEST_IMPL_H_ #include #include +#include +#include + +#include namespace Tizen { namespace Content { class IDownloadEventListener; class IDownloadProgressListener; +class DownloadRequest; class _OSP_EXPORT_ _DownloadRequestImpl : public Tizen::Base::Object @@ -56,11 +61,31 @@ public: Tizen::Base::String GetDirectoryPath(void) const; Tizen::Base::String GetFileName(void) const; + void SetNotification(bool enable); + result SetNotificationExtraData(const Tizen::Base::Collection::IMap *pExtraData); + void SetNetworkType(DownloadNetworkType type); + + bool IsNotificationEnabled(void) const; + const Tizen::Base::Collection::IMap* GetNotificationExtraData(void) const; + DownloadNetworkType GetNetworkType(void) const; + + result AddRequestHeader(const Tizen::Base::String& field, const Tizen::Base::String& value); + result SetRequestHeader(const Tizen::Base::String& field, const Tizen::Base::String& value); + result RemoveRequestHeader(const Tizen::Base::String& field); + Tizen::Base::String* GetRequestHeaderN(const Tizen::Base::String& field); + + static _DownloadRequestImpl* GetInstance(const DownloadRequest* pRequest); + Tizen::Base::Collection::IMap* GetRequestHeader(void); + private: Tizen::Base::String __url; Tizen::Base::String __dirPath; Tizen::Base::String __fileName; + bool __notification; + DownloadNetworkType __networkType; + Tizen::Base::Collection::HashMap __notifyExtraData; + Tizen::Base::Collection::HashMap __requestHeader; }; // _DownloadRequestImpl diff --git a/src/inc/FCnt_PlayListImpl.h b/src/inc/FCnt_PlayListImpl.h index da8d827..48b2d87 100644 --- a/src/inc/FCnt_PlayListImpl.h +++ b/src/inc/FCnt_PlayListImpl.h @@ -102,7 +102,7 @@ public: result RemoveItems(const Tizen::Base::Collection::IList& contentIdList); - result SetPlalyListName(const Tizen::Base::String& oldName, const Tizen::Base::String& newName); + result SetPlayListName(const Tizen::Base::String& oldName, const Tizen::Base::String& newName); result SetPlayOrder(const ContentId& contentId, const ContentId& nextContentId); diff --git a/src/inc/FCnt_VideoMetadataImpl.h b/src/inc/FCnt_VideoMetadataImpl.h index 9e9df55..dc33c19 100644 --- a/src/inc/FCnt_VideoMetadataImpl.h +++ b/src/inc/FCnt_VideoMetadataImpl.h @@ -44,6 +44,8 @@ struct VideoMeta , duration(0) , contentPath(L"") , pGenre(null) + , pComment(null) + , pDescription(null) , pAlbumArt(null) {} int width; @@ -54,6 +56,8 @@ struct VideoMeta long duration; Tizen::Base::String contentPath; Tizen::Base::String* pGenre; + Tizen::Base::String* pComment; + Tizen::Base::String* pDescription; Tizen::Graphics::Bitmap* pAlbumArt; }; @@ -68,6 +72,16 @@ struct VideoMetaDeleter delete pVideoMeta->pGenre; pVideoMeta->pGenre = null; } + if (pVideoMeta->pComment) + { + delete pVideoMeta->pComment; + pVideoMeta->pComment = null; + } + if (pVideoMeta->pDescription) + { + delete pVideoMeta->pDescription; + pVideoMeta->pDescription = null; + } if (pVideoMeta->pAlbumArt != null) { delete pVideoMeta->pAlbumArt; @@ -141,6 +155,16 @@ public: Tizen::Base::String GetGenre(void) const; /** + * @see @ref Tizen::Content::VideoMetadata::GetComment() + */ + Tizen::Base::String GetComment(void) const; + + /** + * @see @ref Tizen::Content::VideoMetadata::GetDescription() + */ + Tizen::Base::String GetDescription(void) const; + + /** * @see @ref Tizen::Content::VideoMetadata::GetAlbumArtN() */ Tizen::Graphics::Bitmap* GetAlbumArtN(void) const; -- 2.7.4